@@ -417,8 +417,7 @@ int QgsGeos::splitGeometry( const QgsLineString &splitLine,
417
417
}
418
418
else if ( splitLine.numPoints () == 1 )
419
419
{
420
- QgsPointV2 pt = splitLine.pointN ( 0 );
421
- splitLineGeos = createGeosPoint ( &pt, 2 , mPrecision );
420
+ splitLineGeos = createGeosPointXY ( splitLine.xAt ( 0 ), splitLine.yAt ( 0 ), false , 0 , false , 0 , 2 , mPrecision );
422
421
}
423
422
else
424
423
{
@@ -1544,33 +1543,31 @@ GEOSCoordSequence *QgsGeos::createCoordinateSequence( const QgsCurve *curve, dou
1544
1543
{
1545
1544
for ( int i = 0 ; i < numOutPoints; ++i )
1546
1545
{
1547
- const QgsPointV2 &pt = line->pointN ( i % numPoints ); // todo: create method to get const point reference
1548
- GEOSCoordSeq_setX_r ( geosinit.ctxt , coordSeq, i, qgsRound ( pt.x () / precision ) * precision );
1549
- GEOSCoordSeq_setY_r ( geosinit.ctxt , coordSeq, i, qgsRound ( pt.y () / precision ) * precision );
1546
+ GEOSCoordSeq_setX_r ( geosinit.ctxt , coordSeq, i, qgsRound ( line->xAt ( i % numPoints ) / precision ) * precision );
1547
+ GEOSCoordSeq_setY_r ( geosinit.ctxt , coordSeq, i, qgsRound ( line->yAt ( i % numPoints ) / precision ) * precision );
1550
1548
if ( hasZ )
1551
1549
{
1552
- GEOSCoordSeq_setOrdinate_r ( geosinit.ctxt , coordSeq, i, 2 , qgsRound ( pt. z ( ) / precision ) * precision );
1550
+ GEOSCoordSeq_setOrdinate_r ( geosinit.ctxt , coordSeq, i, 2 , qgsRound ( line-> zAt ( i % numPoints ) / precision ) * precision );
1553
1551
}
1554
1552
if ( hasM )
1555
1553
{
1556
- GEOSCoordSeq_setOrdinate_r ( geosinit.ctxt , coordSeq, i, 3 , pt. m ( ) );
1554
+ GEOSCoordSeq_setOrdinate_r ( geosinit.ctxt , coordSeq, i, 3 , line-> mAt ( i % numPoints ) );
1557
1555
}
1558
1556
}
1559
1557
}
1560
1558
else
1561
1559
{
1562
1560
for ( int i = 0 ; i < numOutPoints; ++i )
1563
1561
{
1564
- const QgsPointV2 &pt = line->pointN ( i % numPoints ); // todo: create method to get const point reference
1565
- GEOSCoordSeq_setX_r ( geosinit.ctxt , coordSeq, i, pt.x () );
1566
- GEOSCoordSeq_setY_r ( geosinit.ctxt , coordSeq, i, pt.y () );
1562
+ GEOSCoordSeq_setX_r ( geosinit.ctxt , coordSeq, i, line->xAt ( i % numPoints ) );
1563
+ GEOSCoordSeq_setY_r ( geosinit.ctxt , coordSeq, i, line->yAt ( i % numPoints ) );
1567
1564
if ( hasZ )
1568
1565
{
1569
- GEOSCoordSeq_setOrdinate_r ( geosinit.ctxt , coordSeq, i, 2 , pt. z ( ) );
1566
+ GEOSCoordSeq_setOrdinate_r ( geosinit.ctxt , coordSeq, i, 2 , line-> zAt ( i % numPoints ) );
1570
1567
}
1571
1568
if ( hasM )
1572
1569
{
1573
- GEOSCoordSeq_setOrdinate_r ( geosinit.ctxt , coordSeq, i, 3 , pt. m ( ) );
1570
+ GEOSCoordSeq_setOrdinate_r ( geosinit.ctxt , coordSeq, i, 3 , line-> mAt ( i % numPoints ) );
1574
1571
}
1575
1572
}
1576
1573
}
@@ -1590,6 +1587,14 @@ GEOSGeometry *QgsGeos::createGeosPoint( const QgsAbstractGeometry *point, int co
1590
1587
if ( !pt )
1591
1588
return nullptr ;
1592
1589
1590
+ return createGeosPointXY ( pt->x (), pt->y (), pt->is3D (), pt->z (), pt->isMeasure (), pt->m (), coordDims, precision );
1591
+ }
1592
+
1593
+ GEOSGeometry *QgsGeos::createGeosPointXY ( double x, double y, bool hasZ, double z, bool hasM, double m, int coordDims, double precision )
1594
+ {
1595
+ Q_UNUSED ( hasM );
1596
+ Q_UNUSED ( m );
1597
+
1593
1598
GEOSGeometry *geosPoint = nullptr ;
1594
1599
1595
1600
try
@@ -1602,26 +1607,26 @@ GEOSGeometry *QgsGeos::createGeosPoint( const QgsAbstractGeometry *point, int co
1602
1607
}
1603
1608
if ( precision > 0 . )
1604
1609
{
1605
- GEOSCoordSeq_setX_r ( geosinit.ctxt , coordSeq, 0 , qgsRound ( pt-> x () / precision ) * precision );
1606
- GEOSCoordSeq_setY_r ( geosinit.ctxt , coordSeq, 0 , qgsRound ( pt-> y () / precision ) * precision );
1607
- if ( pt-> is3D () )
1610
+ GEOSCoordSeq_setX_r ( geosinit.ctxt , coordSeq, 0 , qgsRound ( x / precision ) * precision );
1611
+ GEOSCoordSeq_setY_r ( geosinit.ctxt , coordSeq, 0 , qgsRound ( y / precision ) * precision );
1612
+ if ( hasZ )
1608
1613
{
1609
- GEOSCoordSeq_setOrdinate_r ( geosinit.ctxt , coordSeq, 0 , 2 , qgsRound ( pt-> z () / precision ) * precision );
1614
+ GEOSCoordSeq_setOrdinate_r ( geosinit.ctxt , coordSeq, 0 , 2 , qgsRound ( z / precision ) * precision );
1610
1615
}
1611
1616
}
1612
1617
else
1613
1618
{
1614
- GEOSCoordSeq_setX_r ( geosinit.ctxt , coordSeq, 0 , pt-> x () );
1615
- GEOSCoordSeq_setY_r ( geosinit.ctxt , coordSeq, 0 , pt-> y () );
1616
- if ( pt-> is3D () )
1619
+ GEOSCoordSeq_setX_r ( geosinit.ctxt , coordSeq, 0 , x );
1620
+ GEOSCoordSeq_setY_r ( geosinit.ctxt , coordSeq, 0 , y );
1621
+ if ( hasZ )
1617
1622
{
1618
- GEOSCoordSeq_setOrdinate_r ( geosinit.ctxt , coordSeq, 0 , 2 , pt-> z () );
1623
+ GEOSCoordSeq_setOrdinate_r ( geosinit.ctxt , coordSeq, 0 , 2 , z );
1619
1624
}
1620
1625
}
1621
1626
#if 0 //disabled until geos supports m-coordinates
1622
- if ( pt->isMeasure() )
1627
+ if ( hasM )
1623
1628
{
1624
- GEOSCoordSeq_setOrdinate_r( geosinit.ctxt, coordSeq, 0, 3, pt->m() );
1629
+ GEOSCoordSeq_setOrdinate_r( geosinit.ctxt, coordSeq, 0, 3, m );
1625
1630
}
1626
1631
#endif
1627
1632
geosPoint = GEOSGeom_createPoint_r ( geosinit.ctxt , coordSeq );
@@ -2165,10 +2170,8 @@ GEOSGeometry *QgsGeos::reshapeLine( const GEOSGeometry *line, const GEOSGeometry
2165
2170
if ( !_linestringEndpoints ( line, x1, y1, x2, y2 ) )
2166
2171
return nullptr ;
2167
2172
2168
- QgsPointV2 beginPoint ( x1, y1 );
2169
- GEOSGeometry *beginLineVertex = createGeosPoint ( &beginPoint, 2 , precision );
2170
- QgsPointV2 endPoint ( x2, y2 );
2171
- GEOSGeometry *endLineVertex = createGeosPoint ( &endPoint, 2 , precision );
2173
+ GEOSGeometry *beginLineVertex = createGeosPointXY ( x1, y1, false , 0 , false , 0 , 2 , precision );
2174
+ GEOSGeometry *endLineVertex = createGeosPointXY ( x2, y2, false , 0 , false , 0 , 2 , precision );
2172
2175
2173
2176
bool isRing = false ;
2174
2177
if ( GEOSGeomTypeId_r ( geosinit.ctxt , line ) == GEOS_LINEARRING
@@ -2225,10 +2228,8 @@ GEOSGeometry *QgsGeos::reshapeLine( const GEOSGeometry *line, const GEOSGeometry
2225
2228
GEOSCoordSeq_getY_r ( geosinit.ctxt , currentCoordSeq, 0 , &yBegin );
2226
2229
GEOSCoordSeq_getX_r ( geosinit.ctxt , currentCoordSeq, currentCoordSeqSize - 1 , &xEnd );
2227
2230
GEOSCoordSeq_getY_r ( geosinit.ctxt , currentCoordSeq, currentCoordSeqSize - 1 , &yEnd );
2228
- QgsPointV2 beginPoint ( xBegin, yBegin );
2229
- GEOSGeometry *beginCurrentGeomVertex = createGeosPoint ( &beginPoint, 2 , precision );
2230
- QgsPointV2 endPoint ( xEnd, yEnd );
2231
- GEOSGeometry *endCurrentGeomVertex = createGeosPoint ( &endPoint, 2 , precision );
2231
+ GEOSGeometry *beginCurrentGeomVertex = createGeosPointXY ( xBegin, yBegin, false , 0 , false , 0 , 2 , precision );
2232
+ GEOSGeometry *endCurrentGeomVertex = createGeosPointXY ( xEnd, yEnd, false , 0 , false , 0 , 2 , precision );
2232
2233
2233
2234
// check how many endpoints of the line merge result are on the (original) line
2234
2235
int nEndpointsOnOriginalLine = 0 ;
0 commit comments