@@ -3156,14 +3156,14 @@ int QgsGeometry::splitGeometry( const QList<QgsPoint>& splitLine, QList<QgsGeome
31563156 return 1 ;
31573157 }
31583158
3159- if (topological)
3159+ if ( topological )
3160+ {
3161+ // find out candidate points for topological corrections
3162+ if ( topologicalTestPointsSplit ( splitLineGeos, topologyTestPoints ) != 0 )
31603163 {
3161- // find out candidate points for topological corrections
3162- if (topologicalTestPointsSplit (splitLineGeos, topologyTestPoints) != 0 )
3163- {
3164- return 1 ;
3165- }
3164+ return 1 ;
31663165 }
3166+ }
31673167
31683168 // call split function depending on geometry type
31693169 if ( vectorType () == QGis::Line )
@@ -4713,7 +4713,7 @@ void QgsGeometry::transformVertex( int& wkbPosition, QgsCoordinateTransform& ct,
47134713 y = *(( double * )( &( mGeometry [wkbPosition + sizeof ( double )] ) ) );
47144714 z = 0.0 ; // Ignore Z for now.
47154715
4716- ct.transformInPlace ( x, y, z);
4716+ ct.transformInPlace ( x, y, z );
47174717
47184718 // new x-coordinate
47194719 memcpy ( &( mGeometry [wkbPosition] ), &x, sizeof ( double ) );
@@ -4894,61 +4894,61 @@ int QgsGeometry::splitPolygonGeometry( GEOSGeometry* splitLine, QList<QgsGeometr
48944894 return 0 ;
48954895}
48964896
4897- int QgsGeometry::topologicalTestPointsSplit ( const GEOSGeometry* splitLine, QList<QgsPoint>& testPoints) const
4897+ int QgsGeometry::topologicalTestPointsSplit ( const GEOSGeometry* splitLine, QList<QgsPoint>& testPoints ) const
48984898{
48994899 // Find out the intersection points between splitLineGeos and this geometry.
49004900 // These points need to be tested for topological correctness by the calling function
49014901 // if topological editing is enabled
49024902
49034903 testPoints.clear ();
4904- GEOSGeometry* intersectionGeom = GEOSIntersection (mGeos , splitLine);
4905- if ( intersectionGeom == NULL )
4906- {
4907- return 1 ;
4908- }
4909-
4904+ GEOSGeometry* intersectionGeom = GEOSIntersection ( mGeos , splitLine );
4905+ if ( intersectionGeom == NULL )
4906+ {
4907+ return 1 ;
4908+ }
4909+
49104910 bool simple = false ;
49114911 int nIntersectGeoms = 1 ;
4912- if (GEOSGeomTypeId (intersectionGeom) == (GEOS_LINESTRING) || GEOSGeomTypeId (intersectionGeom) == (GEOS_POINT))
4912+ if ( GEOSGeomTypeId ( intersectionGeom ) == GEOS_LINESTRING || GEOSGeomTypeId ( intersectionGeom ) == GEOS_POINT )
4913+ {
4914+ simple = true ;
4915+ }
4916+
4917+ if ( !simple )
4918+ {
4919+ nIntersectGeoms = GEOSGetNumGeometries ( intersectionGeom );
4920+ }
4921+
4922+ for ( int i = 0 ; i < nIntersectGeoms; ++i )
4923+ {
4924+ const GEOSGeometry* currentIntersectGeom;
4925+ if ( simple )
49134926 {
4914- simple = true ;
4927+ currentIntersectGeom = intersectionGeom ;
49154928 }
4916-
4917- if (!simple)
4929+ else
49184930 {
4919- nIntersectGeoms = GEOSGetNumGeometries ( intersectionGeom);
4931+ currentIntersectGeom = GEOSGetGeometryN ( intersectionGeom, i );
49204932 }
4921-
4922- for (int i = 0 ; i < nIntersectGeoms; ++i)
4933+
4934+ const GEOSCoordSequence* lineSequence = GEOSGeom_getCoordSeq ( currentIntersectGeom );
4935+ unsigned int sequenceSize = 0 ;
4936+ double x, y;
4937+ if ( GEOSCoordSeq_getSize ( lineSequence, &sequenceSize ) != 0 )
49234938 {
4924- GEOSGeometry* currentIntersectGeom;
4925- if (simple)
4926- {
4927- currentIntersectGeom = intersectionGeom;
4928- }
4929- else
4930- {
4931- currentIntersectGeom = GEOSGetGeometryN (intersectionGeom, i);
4932- }
4933-
4934- GEOSCoordSequence* lineSequence = GEOSGeom_getCoordSeq (currentIntersectGeom);
4935- unsigned int sequenceSize = 0 ;
4936- double x, y;
4937- if (GEOSCoordSeq_getSize (lineSequence, &sequenceSize) != 0 )
4938- {
4939- for (int i = 0 ; i < sequenceSize; ++i)
4940- {
4941- if (GEOSCoordSeq_getX (lineSequence, i, &x) != 0 )
4942- {
4943- if (GEOSCoordSeq_getY (lineSequence, i, &y) != 0 )
4944- {
4945- testPoints.push_back (QgsPoint (x, y));
4946- }
4947- }
4948- }
4949- }
4939+ for ( unsigned int i = 0 ; i < sequenceSize; ++i )
4940+ {
4941+ if ( GEOSCoordSeq_getX ( lineSequence, i, &x ) != 0 )
4942+ {
4943+ if ( GEOSCoordSeq_getY ( lineSequence, i, &y ) != 0 )
4944+ {
4945+ testPoints.push_back ( QgsPoint ( x, y ) );
4946+ }
4947+ }
4948+ }
49504949 }
4951- GEOSGeom_destroy (intersectionGeom);
4950+ }
4951+ GEOSGeom_destroy ( intersectionGeom );
49524952 return 0 ;
49534953}
49544954
0 commit comments