@@ -1185,45 +1185,123 @@ Ring 0 is outer ring and can't be deleted.
1185
1185
:rtype: QgsPolygon
1186
1186
%End
1187
1187
1188
- static bool compare( const QgsPolyline &p1, const QgsPolyline &p2,
1189
- double epsilon = 4 * DBL_EPSILON ) /PyName=comparePolylines/;
1190
- %Docstring
1191
- Compares two polylines for equality within a specified tolerance.
1192
- \param p1 first polyline
1193
- \param p2 second polyline
1194
- \param epsilon maximum difference for coordinates between the polylines
1195
- :return: true if polylines have the same number of points and all
1196
- points are equal within the specified tolerance
1197
- .. versionadded:: 2.9
1198
- :rtype: bool
1199
- %End
1200
1188
1201
- static bool compare( const QgsPolygon &p1, const QgsPolygon &p2,
1202
- double epsilon = 4 * DBL_EPSILON ) /PyName=comparePolygons/;
1203
- %Docstring
1204
- Compares two polygons for equality within a specified tolerance.
1205
- \param p1 first polygon
1206
- \param p2 second polygon
1207
- \param epsilon maximum difference for coordinates between the polygons
1208
- :return: true if polygons have the same number of rings, and each ring has the same
1209
- number of points and all points are equal within the specified tolerance
1210
- .. versionadded:: 2.9
1211
- :rtype: bool
1212
- %End
1213
-
1214
- static bool compare( const QgsMultiPolygon &p1, const QgsMultiPolygon &p2,
1215
- double epsilon = 4 * DBL_EPSILON ) /PyName=compareMultiPolygons/;
1216
- %Docstring
1217
- Compares two multipolygons for equality within a specified tolerance.
1218
- \param p1 first multipolygon
1219
- \param p2 second multipolygon
1220
- \param epsilon maximum difference for coordinates between the multipolygons
1221
- :return: true if multipolygons have the same number of polygons, the polygons have the same number
1222
- of rings, and each ring has the same number of points and all points are equal within the specified
1189
+ static bool compare( PyObject *obj1, PyObject *obj2, double epsilon = 4 * DBL_EPSILON );
1190
+ %Docstring
1191
+ Compares two geometry objects for equality within a specified tolerance.
1192
+ The objects can be of type QgsPolyline, QgsPolygon or QgsMultiPolygon.
1193
+ The 2 types should match.
1194
+ \param p1 first geometry object
1195
+ \param p2 second geometry object
1196
+ \param epsilon maximum difference for coordinates between the objects
1197
+ :return: true if objects are
1198
+ - polylines and have the same number of points and all
1199
+ points are equal within the specified tolerance
1200
+ - polygons and have the same number of points and all
1201
+ points are equal within the specified tolerance
1202
+ - multipolygons and have the same number of polygons, the polygons have the same number
1203
+ of rings, and each ring has the same number of points and all points are equal
1204
+ within the specified
1223
1205
tolerance
1224
1206
.. versionadded:: 2.9
1225
1207
:rtype: bool
1226
1208
%End
1209
+ %MethodCode
1210
+ {
1211
+ sipRes = false;
1212
+ int state0;
1213
+ int state1;
1214
+ int sipIsErr = 0;
1215
+
1216
+ if ( PyList_Check( a0 ) && PyList_Check( a1 ) &&
1217
+ PyList_GET_SIZE( a0 ) && PyList_GET_SIZE( a1 ) )
1218
+ {
1219
+ PyObject *o0 = PyList_GetItem( a0, 0 );
1220
+ PyObject *o1 = PyList_GetItem( a1, 0 );
1221
+ if ( o0 && o1 )
1222
+ {
1223
+ // compare polyline - polyline
1224
+ if ( sipCanConvertToType( o0, sipType_QgsPoint, SIP_NOT_NONE ) &&
1225
+ sipCanConvertToType( o1, sipType_QgsPoint, SIP_NOT_NONE ) &&
1226
+ sipCanConvertToType( a0, sipType_QVector_0100QgsPoint, SIP_NOT_NONE ) &&
1227
+ sipCanConvertToType( a1, sipType_QVector_0100QgsPoint, SIP_NOT_NONE ) )
1228
+ {
1229
+ QgsPolyline *p0;
1230
+ QgsPolyline *p1;
1231
+ p0 = reinterpret_cast<QgsPolyline *>( sipConvertToType( a0, sipType_QVector_0100QgsPoint, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
1232
+ p1 = reinterpret_cast<QgsPolyline *>( sipConvertToType( a1, sipType_QVector_0100QgsPoint, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
1233
+ if ( sipIsErr )
1234
+ {
1235
+ sipReleaseType( p0, sipType_QVector_0100QgsPoint, state0 );
1236
+ sipReleaseType( p1, sipType_QVector_0100QgsPoint, state1 );
1237
+ }
1238
+ else
1239
+ {
1240
+ sipRes = QgsGeometry::compare( *p0, *p1, a2 );
1241
+ }
1242
+ }
1243
+ else if ( PyList_Check( o0 ) && PyList_Check( o1 ) &&
1244
+ PyList_GET_SIZE( o0 ) && PyList_GET_SIZE( o1 ) )
1245
+ {
1246
+ PyObject *oo0 = PyList_GetItem( o0, 0 );
1247
+ PyObject *oo1 = PyList_GetItem( o1, 0 );
1248
+ if ( oo0 && oo1 )
1249
+ {
1250
+ // compare polygon - polygon
1251
+ if ( sipCanConvertToType( oo0, sipType_QgsPoint, SIP_NOT_NONE ) &&
1252
+ sipCanConvertToType( oo1, sipType_QgsPoint, SIP_NOT_NONE ) &&
1253
+ sipCanConvertToType( a0, sipType_QVector_0600QVector_0100QgsPoint, SIP_NOT_NONE ) &&
1254
+ sipCanConvertToType( a1, sipType_QVector_0600QVector_0100QgsPoint, SIP_NOT_NONE ) )
1255
+ {
1256
+ QgsPolygon *p0;
1257
+ QgsPolygon *p1;
1258
+ p0 = reinterpret_cast<QgsPolygon *>( sipConvertToType( a0, sipType_QVector_0600QVector_0100QgsPoint, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
1259
+ p1 = reinterpret_cast<QgsPolygon *>( sipConvertToType( a1, sipType_QVector_0600QVector_0100QgsPoint, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
1260
+ if ( sipIsErr )
1261
+ {
1262
+ sipReleaseType( p0, sipType_QVector_0600QVector_0100QgsPoint, state0 );
1263
+ sipReleaseType( p1, sipType_QVector_0600QVector_0100QgsPoint, state1 );
1264
+ }
1265
+ else
1266
+ {
1267
+ sipRes = QgsGeometry::compare( *p0, *p1, a2 );
1268
+ }
1269
+ }
1270
+ else if ( PyList_Check( oo0 ) && PyList_Check( oo1 ) &&
1271
+ PyList_GET_SIZE( oo0 ) && PyList_GET_SIZE( oo1 ) )
1272
+ {
1273
+ PyObject *ooo0 = PyList_GetItem( oo0, 0 );
1274
+ PyObject *ooo1 = PyList_GetItem( oo1, 0 );
1275
+ if ( ooo0 && ooo1 )
1276
+ {
1277
+ // compare multipolygon - multipolygon
1278
+ if ( sipCanConvertToType( ooo0, sipType_QgsPoint, SIP_NOT_NONE ) &&
1279
+ sipCanConvertToType( ooo1, sipType_QgsPoint, SIP_NOT_NONE ) &&
1280
+ sipCanConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPoint, SIP_NOT_NONE ) &&
1281
+ sipCanConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPoint, SIP_NOT_NONE ) )
1282
+ {
1283
+ QgsMultiPolygon *p0;
1284
+ QgsMultiPolygon *p1;
1285
+ p0 = reinterpret_cast<QgsMultiPolygon *>( sipConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPoint, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
1286
+ p1 = reinterpret_cast<QgsMultiPolygon *>( sipConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPoint, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
1287
+ if ( sipIsErr )
1288
+ {
1289
+ sipReleaseType( p0, sipType_QVector_0600QVector_0600QVector_0100QgsPoint, state0 );
1290
+ sipReleaseType( p1, sipType_QVector_0600QVector_0600QVector_0100QgsPoint, state1 );
1291
+ }
1292
+ else
1293
+ {
1294
+ sipRes = QgsGeometry::compare( *p0, *p1, a2 );
1295
+ }
1296
+ }
1297
+ }
1298
+ }
1299
+ }
1300
+ }
1301
+ }
1302
+ }
1303
+ }
1304
+ %End
1227
1305
1228
1306
QgsGeometry smooth( const unsigned int iterations = 1, const double offset = 0.25,
1229
1307
double minimumDistance = -1.0, double maxAngle = 180.0 ) const;
0 commit comments