@@ -986,6 +986,10 @@ bool QgsGeometryAnalyzer::eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer*
986986 if ( locationField2 != -1 )
987987 {
988988 measure2 = fet.attribute ( locationField2 ).toDouble ();
989+ if ( qgsDoubleNear (( measure2 - measure1 ), 0.0 ) )
990+ {
991+ continue ;
992+ }
989993 }
990994
991995 QList<QgsFeature> featureIdList = lineLayerIdMap.values ( fet.attribute ( eventField ).toString () );
@@ -1052,7 +1056,11 @@ void QgsGeometryAnalyzer::addEventLayerFeature( QgsFeature& feature, QgsGeometry
10521056 {
10531057 double offsetVal = feature.attribute ( offsetField ).toDouble ();
10541058 offsetVal *= offsetScale;
1055- createOffsetGeometry ( *geomIt, lineGeom, offsetVal );
1059+ if ( !createOffsetGeometry ( *geomIt, lineGeom, offsetVal ) )
1060+ {
1061+ delete *geomIt;
1062+ continue ;
1063+ }
10561064 }
10571065
10581066 feature.setGeometry ( *geomIt );
@@ -1072,11 +1080,11 @@ void QgsGeometryAnalyzer::addEventLayerFeature( QgsFeature& feature, QgsGeometry
10721080 }
10731081}
10741082
1075- void QgsGeometryAnalyzer::createOffsetGeometry ( QgsGeometry* geom, QgsGeometry* lineGeom, double offset )
1083+ bool QgsGeometryAnalyzer::createOffsetGeometry ( QgsGeometry* geom, QgsGeometry* lineGeom, double offset )
10761084{
10771085 if ( !geom || !lineGeom )
10781086 {
1079- return ;
1087+ return false ;
10801088 }
10811089
10821090 QList<QgsGeometry*> inputGeomList;
@@ -1099,7 +1107,17 @@ void QgsGeometryAnalyzer::createOffsetGeometry( QgsGeometry* geom, QgsGeometry*
10991107 // geos 3.3 needed for line offsets
11001108#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
11011109 ((GEOS_VERSION_MAJOR>3 ) || ((GEOS_VERSION_MAJOR==3 ) && (GEOS_VERSION_MINOR>=3 )))
1102- outputGeomList.push_back ( GEOSOffsetCurve (( *inputGeomIt )->asGeos (), -offset, 8 /* quadSegments*/ , 0 /* joinStyle*/ , 5.0 /* mitreLimit*/ ) );
1110+ GEOSGeometry* offsetGeom = GEOSOffsetCurve (( *inputGeomIt )->asGeos (), -offset, 8 /* quadSegments*/ , 0 /* joinStyle*/ , 5.0 /* mitreLimit*/ );
1111+ if ( !offsetGeom || !GEOSisValid ( offsetGeom ) )
1112+ {
1113+ return false ;
1114+ }
1115+ if ( !GEOSisValid ( offsetGeom ) || GEOSGeomTypeId ( offsetGeom ) != GEOS_LINESTRING || GEOSGeomGetNumPoints ( offsetGeom ) < 1 )
1116+ {
1117+ GEOSGeom_destroy ( offsetGeom );
1118+ return false ;
1119+ }
1120+ outputGeomList.push_back ( offsetGeom );
11031121#else
11041122 outputGeomList.push_back ( GEOSGeom_clone (( *inputGeomIt )->asGeos () ) );
11051123#endif
@@ -1143,6 +1161,7 @@ void QgsGeometryAnalyzer::createOffsetGeometry( QgsGeometry* geom, QgsGeometry*
11431161 geom->fromGeos ( collection );
11441162 delete[] geomArray;
11451163 }
1164+ return true ;
11461165}
11471166
11481167QgsPoint QgsGeometryAnalyzer::createPointOffset ( double x, double y, double dist, QgsGeometry* lineGeom ) const
0 commit comments