@@ -986,6 +986,10 @@ bool QgsGeometryAnalyzer::eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer*
986
986
if ( locationField2 != -1 )
987
987
{
988
988
measure2 = fet.attribute ( locationField2 ).toDouble ();
989
+ if ( qgsDoubleNear (( measure2 - measure1 ), 0.0 ) )
990
+ {
991
+ continue ;
992
+ }
989
993
}
990
994
991
995
QList<QgsFeature> featureIdList = lineLayerIdMap.values ( fet.attribute ( eventField ).toString () );
@@ -1052,7 +1056,11 @@ void QgsGeometryAnalyzer::addEventLayerFeature( QgsFeature& feature, QgsGeometry
1052
1056
{
1053
1057
double offsetVal = feature.attribute ( offsetField ).toDouble ();
1054
1058
offsetVal *= offsetScale;
1055
- createOffsetGeometry ( *geomIt, lineGeom, offsetVal );
1059
+ if ( !createOffsetGeometry ( *geomIt, lineGeom, offsetVal ) )
1060
+ {
1061
+ delete *geomIt;
1062
+ continue ;
1063
+ }
1056
1064
}
1057
1065
1058
1066
feature.setGeometry ( *geomIt );
@@ -1072,11 +1080,11 @@ void QgsGeometryAnalyzer::addEventLayerFeature( QgsFeature& feature, QgsGeometry
1072
1080
}
1073
1081
}
1074
1082
1075
- void QgsGeometryAnalyzer::createOffsetGeometry ( QgsGeometry* geom, QgsGeometry* lineGeom, double offset )
1083
+ bool QgsGeometryAnalyzer::createOffsetGeometry ( QgsGeometry* geom, QgsGeometry* lineGeom, double offset )
1076
1084
{
1077
1085
if ( !geom || !lineGeom )
1078
1086
{
1079
- return ;
1087
+ return false ;
1080
1088
}
1081
1089
1082
1090
QList<QgsGeometry*> inputGeomList;
@@ -1099,7 +1107,17 @@ void QgsGeometryAnalyzer::createOffsetGeometry( QgsGeometry* geom, QgsGeometry*
1099
1107
// geos 3.3 needed for line offsets
1100
1108
#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
1101
1109
((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 );
1103
1121
#else
1104
1122
outputGeomList.push_back ( GEOSGeom_clone (( *inputGeomIt )->asGeos () ) );
1105
1123
#endif
@@ -1143,6 +1161,7 @@ void QgsGeometryAnalyzer::createOffsetGeometry( QgsGeometry* geom, QgsGeometry*
1143
1161
geom->fromGeos ( collection );
1144
1162
delete[] geomArray;
1145
1163
}
1164
+ return true ;
1146
1165
}
1147
1166
1148
1167
QgsPoint QgsGeometryAnalyzer::createPointOffset ( double x, double y, double dist, QgsGeometry* lineGeom ) const
0 commit comments