30
30
31
31
32
32
bool QgsGeometryAnalyzer::singlepartsToMultipart ( QgsVectorLayer* layer,
33
- const QString& shapefileName,
34
- const QString& fileEncoding,
35
- const int fieldIndex )
33
+ const QString& shapefileName,
34
+ const QString& fileEncoding,
35
+ const int fieldIndex )
36
36
{
37
- /*
38
- QgsVectorDataProvider* provider = layer->dataProvider();
39
- QgsAttributeList allAttrs = provider->attributeIndexes();
40
- provider->select( allAttrs, QgsRectangle(), true );
41
- const QgsCoordinateReferenceSystem* outputCRS;
42
- outputCRS = &layer->srs();
43
- QgsVectorFileWriter* writer = new QgsVectorFileWriter( shapefileName,
44
- fileEncoding, provider->fields(), provider->geometryType(), outputCRS );
45
-
46
- QgsGeometry inGeom;
47
- QgsGeometry outGeom;
48
- QList<QVariant> unique;
49
- provider->uniqueValues( index, unique )
50
- if ( unique->size() < layer->featureCount() )
51
- {
52
- QList<QgsGeometry> multiGeom;
53
- bool first;
54
- QgsAttributeMap atMap;
55
-
56
- for ( int it = unique.begin(); it != unique.end(); ++it )
37
+ return false ;
38
+ /*
39
+ QgsVectorDataProvider* provider = layer->dataProvider();
40
+ QgsAttributeList allAttrs = provider->attributeIndexes();
41
+ provider->select( allAttrs, QgsRectangle(), true );
42
+ const QgsCoordinateReferenceSystem* outputCRS;
43
+ outputCRS = &layer->srs();
44
+ QgsVectorFileWriter* writer = new QgsVectorFileWriter( shapefileName,
45
+ fileEncoding, provider->fields(), provider->geometryType(), outputCRS );
46
+
47
+ QgsGeometry inGeom;
48
+ QgsGeometry outGeom;
49
+ QList<QVariant> unique;
50
+ provider->uniqueValues( index, unique )
51
+ if ( unique->size() < layer->featureCount() )
57
52
{
58
- provider->select( allAttrs, QgsRectangle(), true );
59
- first = true;
60
- while ( provider->nextFeature( inFeat ) )
53
+ QList<QgsGeometry> multiGeom;
54
+ bool first;
55
+ QgsAttributeMap atMap;
56
+
57
+ for ( int it = unique.begin(); it != unique.end(); ++it )
61
58
{
62
- if ( inFeat.attributeMap()[ index ].toString().trimmed() == it.toString().trimmed() )
59
+ provider->select( allAttrs, QgsRectangle(), true );
60
+ first = true;
61
+ while ( provider->nextFeature( inFeat ) )
63
62
{
64
- if (first )
63
+ if ( inFeat.attributeMap()[ index ].toString().trimmed() == it.toString().trimmed() )
65
64
{
66
- atMap = inFeat.attributeMap();
67
- first = false;
65
+ if (first)
66
+ {
67
+ atMap = inFeat.attributeMap();
68
+ first = false;
69
+ }
70
+ inGeom = inFeat.geometry();
71
+ multiGeom << inGeom.asGeometryCollection()
68
72
}
69
- inGeom = inFeat.geometry();
70
- multiGeom << inGeom.asGeometryCollection()
73
+ outFeat.setAttributeMap( atMap );
74
+ outGeom = convertGeometry( multifeature, vtype );
75
+ outFeat.setGeometry( outGeom );
76
+ writer.addFeature( outFeat );
71
77
}
72
- outFeat.setAttributeMap( atMap );
73
- outGeom = convertGeometry( multifeature, vtype );
74
- outFeat.setGeometry( outGeom );
75
- writer.addFeature( outFeat );
76
78
}
77
- }
78
- delete writer;
79
- return true;
80
- */
79
+ delete writer;
80
+ return true;
81
+ */
81
82
}
82
83
83
84
bool QgsGeometryAnalyzer::multipartToSingleparts ( QgsVectorLayer* layer,
84
- const QString& shapefileName,
85
- const QString& fileEncoding )
85
+ const QString& shapefileName,
86
+ const QString& fileEncoding )
86
87
{
88
+ return false ;
87
89
/*
88
90
QgsVectorDataProvider* provider = layer->dataProvider();
89
91
QgsAttributeList allAttrs = provider->attributeIndexes();
90
92
provider->select( allAttrs, QgsRectangle(), true );
91
93
const QgsCoordinateReferenceSystem* outputCRS;
92
94
outputCRS = &layer->srs();
93
- QgsVectorFileWriter* writer = new QgsVectorFileWriter( shapefileName,
95
+ QgsVectorFileWriter* writer = new QgsVectorFileWriter( shapefileName,
94
96
fileEncoding, provider->fields(), provider->geometryType(), outputCRS );
95
97
inFeat = QgsFeature()
96
98
outFeat = QgsFeature()
@@ -101,7 +103,7 @@ bool QgsGeometryAnalyzer::multipartToSingleparts( QgsVectorLayer* layer,
101
103
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
102
104
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
103
105
while vprovider.nextFeature( inFeat )
104
- nElement += 1
106
+ nElement += 1
105
107
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), nElement )
106
108
inGeom = inFeat.geometry()
107
109
atMap = inFeat.attributeMap()
@@ -113,82 +115,84 @@ bool QgsGeometryAnalyzer::multipartToSingleparts( QgsVectorLayer* layer,
113
115
del writer
114
116
return True
115
117
116
- */
118
+ */
117
119
}
118
120
119
121
bool QgsGeometryAnalyzer::extractNodes ( QgsVectorLayer* layer,
120
- const QString& shapefileName,
121
- const QString& fileEncoding )
122
+ const QString& shapefileName,
123
+ const QString& fileEncoding )
122
124
{
123
- /*
124
- QgsVectorDataProvider* provider = layer->dataProvider();
125
- QgsAttributeList allAttrs = provider->attributeIndexes();
126
- provider->select( allAttrs, QgsRectangle(), true );
127
- const QgsCoordinateReferenceSystem* outputCRS;
128
- outputCRS = &layer->srs();
129
- QgsVectorFileWriter* writer = new QgsVectorFileWriter( shapefileName,
130
- fileEncoding, provider->fields(), provider->geometryType(), outputCRS );
131
-
132
- QgsFeature inFeat;
133
- QgsFeature outFeat;
134
-
135
- QgsGeometry outGeom;
136
- QList<QgsPoint> pointList;
137
- QgsPoint geomPoint;
138
- QList<QgsPoint>::iterator it;
139
- while ( provider->nextFeature( inFeat ) )
140
- {
141
- pointList = extractPoints( inFeat.geometry() );
142
- outFeat.setAttributeMap( inFeat.attributeMap() );
143
- for (it = pointList.begin(); it != pointList.end(); ++it )
125
+ return false ;
126
+ /*
127
+ QgsVectorDataProvider* provider = layer->dataProvider();
128
+ QgsAttributeList allAttrs = provider->attributeIndexes();
129
+ provider->select( allAttrs, QgsRectangle(), true );
130
+ const QgsCoordinateReferenceSystem* outputCRS;
131
+ outputCRS = &layer->srs();
132
+ QgsVectorFileWriter* writer = new QgsVectorFileWriter( shapefileName,
133
+ fileEncoding, provider->fields(), provider->geometryType(), outputCRS );
134
+
135
+ QgsFeature inFeat;
136
+ QgsFeature outFeat;
137
+
138
+ QgsGeometry outGeom;
139
+ QList<QgsPoint> pointList;
140
+ QgsPoint geomPoint;
141
+ QList<QgsPoint>::iterator it;
142
+ while ( provider->nextFeature( inFeat ) )
144
143
{
145
- geomPoint = QgsGeometry::fromPoint( it );
146
- outFeat.setGeometry( geomPoint );
147
- writer.addFeature( outFeat );
144
+ pointList = extractPoints( inFeat.geometry() );
145
+ outFeat.setAttributeMap( inFeat.attributeMap() );
146
+ for (it = pointList.begin(); it != pointList.end(); ++it )
147
+ {
148
+ geomPoint = QgsGeometry::fromPoint( it );
149
+ outFeat.setGeometry( geomPoint );
150
+ writer.addFeature( outFeat );
151
+ }
148
152
}
149
- }
150
- delete writer;
151
- return true;
152
- */
153
+ delete writer;
154
+ return true;
155
+ */
153
156
}
154
157
155
158
bool QgsGeometryAnalyzer::polygonsToLines ( QgsVectorLayer* layer,
156
- const QString& shapefileName,
157
- const QString& fileEncoding )
159
+ const QString& shapefileName,
160
+ const QString& fileEncoding )
158
161
{
159
- /*
160
- QgsVectorDataProvider* provider = layer->dataProvider();
161
- QgsAttributeList allAttrs = provider->attributeIndexes();
162
- provider->select( allAttrs, QgsRectangle(), true );
163
- QgsVectorFileWriter* writer = new QgsVectorFileWriter( shapefileName,
164
- fileEncoding, provider->fields(), QGis::WKBPoint, provider->crs() );
162
+ return false ;
163
+ /*
164
+ QgsVectorDataProvider* provider = layer->dataProvider();
165
+ QgsAttributeList allAttrs = provider->attributeIndexes();
166
+ provider->select( allAttrs, QgsRectangle(), true );
167
+ QgsVectorFileWriter* writer = new QgsVectorFileWriter( shapefileName,
168
+ fileEncoding, provider->fields(), QGis::WKBPoint, provider->crs() );
165
169
166
170
167
-
168
- QgsFeature inFeat;
169
- QgsFeature outFeat;
170
- QgsGeometry inGeom;
171
- QgsGeometry outGeom;
172
- QList<QgsPolyline> lineList;
173
171
174
- while ( provider->nextFeature( inFeat ) )
175
- {
176
- lineList = QgsGeometryAnalyzer::extractLines( inFeat.geometry() );
177
- outFeat.setAttributeMap( inFeat.attributeMap() );
178
- for ( line = lineList.begin(); line != lineList.end(); line++ )
172
+ QgsFeature inFeat;
173
+ QgsFeature outFeat;
174
+ QgsGeometry inGeom;
175
+ QgsGeometry outGeom;
176
+ QList<QgsPolyline> lineList;
177
+
178
+ while ( provider->nextFeature( inFeat ) )
179
179
{
180
- outFeat.setGeometry( outGeom.fromPolyline( line ) );
181
- writer.addFeature( outFeat );
180
+ lineList = QgsGeometryAnalyzer::extractLines( inFeat.geometry() );
181
+ outFeat.setAttributeMap( inFeat.attributeMap() );
182
+ for ( line = lineList.begin(); line != lineList.end(); line++ )
183
+ {
184
+ outFeat.setGeometry( outGeom.fromPolyline( line ) );
185
+ writer.addFeature( outFeat );
186
+ }
182
187
}
183
- }
184
- delete writer;
185
- return true;
186
- */
188
+ delete writer;
189
+ return true;
190
+ */
187
191
}
188
192
189
193
bool QgsGeometryAnalyzer::exportGeometryInformation ( QgsVectorLayer* layer,
190
- const QString& shapefileName,
191
- const QString& fileEncoding )
194
+ const QString& shapefileName,
195
+ const QString& fileEncoding )
192
196
{
193
197
QgsVectorDataProvider* provider = layer->dataProvider ();
194
198
QgsAttributeList allAttrs = provider->attributeIndexes ();
@@ -197,41 +201,41 @@ bool QgsGeometryAnalyzer::exportGeometryInformation( QgsVectorLayer* layer,
197
201
int index1;
198
202
int index2;
199
203
// ( fields, index1, index2 ) = self.checkGeometryFields( self.vlayer )
200
-
201
- QgsVectorFileWriter writer = QgsVectorFileWriter ( shapefileName,
202
- fileEncoding, provider->fields (), provider->geometryType (), &outputCRS );
203
-
204
+
205
+ QgsVectorFileWriter writer = QgsVectorFileWriter ( shapefileName,
206
+ fileEncoding, provider->fields (), provider->geometryType (), &outputCRS );
207
+
204
208
QgsFeature inFeat;
205
209
QgsFeature outFeat;
206
210
QgsGeometry* inGeom;
207
211
QList<double > attrs;
208
-
212
+
209
213
while ( provider->nextFeature ( inFeat ) )
210
214
{
211
215
inGeom = inFeat.geometry ();
212
216
outFeat.setAttributeMap ( inFeat.attributeMap () );
213
217
attrs = QgsGeometryAnalyzer::simpleMeasure ( inGeom );
214
218
outFeat.setGeometry ( inGeom );
215
219
outFeat.setAttributeMap ( inFeat.attributeMap () );
216
- outFeat.addAttribute ( index1, QVariant ( attrs[0 ] ) );
217
- outFeat.addAttribute ( index2, QVariant ( attrs[1 ] ) );
220
+ outFeat.addAttribute ( index1, QVariant ( attrs[0 ] ) ); // FIXME: index1 unset
221
+ outFeat.addAttribute ( index2, QVariant ( attrs[1 ] ) ); // FIXME: index2 unset
218
222
writer.addFeature ( outFeat );
219
223
}
220
224
return true ;
221
225
222
226
}
223
227
bool QgsGeometryAnalyzer::simplifyGeometry ( QgsVectorLayer* layer,
224
- const QString shapefileName,
225
- const QString fileEncoding,
226
- const double tolerance )
228
+ const QString shapefileName,
229
+ const QString fileEncoding,
230
+ const double tolerance )
227
231
{
228
232
QgsVectorDataProvider* provider = layer->dataProvider ();
229
233
QgsAttributeList allAttrs = provider->attributeIndexes ();
230
234
provider->select ( allAttrs, QgsRectangle (), true );
231
235
QgsCoordinateReferenceSystem outputCRS = layer->srs ();
232
- QgsVectorFileWriter writer = QgsVectorFileWriter ( shapefileName,
233
- fileEncoding, provider->fields (), provider->geometryType (), &outputCRS );
234
-
236
+ QgsVectorFileWriter writer = QgsVectorFileWriter ( shapefileName,
237
+ fileEncoding, provider->fields (), provider->geometryType (), &outputCRS );
238
+
235
239
QgsFeature inFeat;
236
240
QgsFeature outFeat;
237
241
QgsGeometry* inGeom;
@@ -249,20 +253,20 @@ bool QgsGeometryAnalyzer::simplifyGeometry( QgsVectorLayer* layer,
249
253
}
250
254
251
255
bool QgsGeometryAnalyzer::polygonCentroids ( QgsVectorLayer* layer,
252
- const QString& shapefileName,
253
- const QString& fileEncoding )
256
+ const QString& shapefileName,
257
+ const QString& fileEncoding )
254
258
{
255
259
QgsVectorDataProvider* provider = layer->dataProvider ();
256
260
QgsAttributeList allAttrs = provider->attributeIndexes ();
257
261
provider->select ( allAttrs, QgsRectangle (), true );
258
262
QgsCoordinateReferenceSystem outputCRS = layer->srs ();
259
- QgsVectorFileWriter writer = QgsVectorFileWriter ( shapefileName,
260
- fileEncoding, provider->fields (), provider->geometryType (), &outputCRS );
261
-
263
+ QgsVectorFileWriter writer = QgsVectorFileWriter ( shapefileName,
264
+ fileEncoding, provider->fields (), provider->geometryType (), &outputCRS );
265
+
262
266
QgsFeature inFeat;
263
267
QgsFeature outFeat;
264
268
QgsGeometry* inGeom;
265
-
269
+
266
270
while ( provider->nextFeature ( inFeat ) )
267
271
{
268
272
inGeom = inFeat.geometry ();
@@ -274,8 +278,8 @@ bool QgsGeometryAnalyzer::polygonCentroids( QgsVectorLayer* layer,
274
278
}
275
279
276
280
bool QgsGeometryAnalyzer::layerExtent ( QgsVectorLayer* layer,
277
- const QString& shapefileName,
278
- const QString& fileEncoding )
281
+ const QString& shapefileName,
282
+ const QString& fileEncoding )
279
283
{
280
284
QgsFieldMap fields;
281
285
fields.insert ( 0 , QgsField ( QString ( " MINX" ), QVariant::Double ) );
@@ -287,12 +291,12 @@ bool QgsGeometryAnalyzer::layerExtent( QgsVectorLayer* layer,
287
291
fields.insert ( 6 , QgsField ( QString ( " AREA" ), QVariant::Double ) );
288
292
fields.insert ( 7 , QgsField ( QString ( " PERIM" ), QVariant::Double ) );
289
293
fields.insert ( 8 , QgsField ( QString ( " HEIGHT" ), QVariant::Double ) );
290
- fields.insert ( 9 , QgsField ( QString ( " WIDTH" ), QVariant::Double ) );
291
-
294
+ fields.insert ( 9 , QgsField ( QString ( " WIDTH" ), QVariant::Double ) );
295
+
292
296
QgsVectorDataProvider* provider = layer->dataProvider ();
293
297
QgsCoordinateReferenceSystem outputCRS = layer->srs ();
294
- QgsVectorFileWriter writer = QgsVectorFileWriter ( shapefileName,
295
- fileEncoding, provider->fields (), provider->geometryType (), &outputCRS );
298
+ QgsVectorFileWriter writer = QgsVectorFileWriter ( shapefileName,
299
+ fileEncoding, provider->fields (), provider->geometryType (), &outputCRS );
296
300
297
301
QgsRectangle rect;
298
302
rect = layer->extent ();
@@ -302,11 +306,11 @@ bool QgsGeometryAnalyzer::layerExtent( QgsVectorLayer* layer,
302
306
double maxy = rect.yMaximum ();
303
307
double height = rect.height ();
304
308
double width = rect.width ();
305
-
309
+
306
310
double cntx = minx + ( width / 2.0 );
307
311
double cnty = miny + ( height / 2.0 );
308
312
double area = width * height;
309
- double perim = ( 2 * width ) + (2 * height );
313
+ double perim = ( 2 * width ) + ( 2 * height );
310
314
311
315
QgsFeature feat;
312
316
QgsAttributeMap atMap;
@@ -345,7 +349,7 @@ QList<double> QgsGeometryAnalyzer::simpleMeasure( QgsGeometry* mpGeometry )
345
349
}
346
350
}
347
351
return list;
348
-
352
+
349
353
}
350
354
351
355
double QgsGeometryAnalyzer::perimeterMeasure ( QgsGeometry* geometry, QgsDistanceArea& measure )
@@ -378,166 +382,169 @@ double QgsGeometryAnalyzer::perimeterMeasure( QgsGeometry* geometry, QgsDistance
378
382
379
383
QgsFieldMap QgsGeometryAnalyzer::checkGeometryFields ( QgsVectorLayer* layer, int & index1, int & index2 )
380
384
{
381
- /* QgsVectorDataProvider* provider = layer->dataProvider ();
382
- QgsAttributeList allAttrs = provider->attributeIndexes ();
383
- // provider->select( allAttrs, QgsRectangle(), true );
384
- QgsFieldMap fields = provider->fields()
385
- QGis::GeometryType geomType = layer->geometryType();
386
-
387
- for i in fieldList.keys()
388
- nameList.append( fieldList[ i ].name().toLower() )
389
- if geomType == QGis.Polygon:
390
- plp = "Poly"
391
- ( found, index1 ) = self.checkForField( nameList, "AREA" )
392
- if not found:
393
- field = QgsField( "AREA", QVariant.Double, "double", 10, 6, "Polygon area" )
394
- index1 = len( fieldList.keys() )
395
- fieldList[ index1 ] = field
396
- ( found, index2 ) = self.checkForField( nameList, "PERIMETER" )
397
-
398
- if not found:
399
- field = QgsField( "PERIMETER", QVariant.Double, "double", 10, 6, "Polygon perimeter" )
400
- index2 = len( fieldList.keys() )
401
- fieldList[ index2 ] = field
402
- elif geomType == QGis.Line:
403
- plp = " Line"
404
- (found, index1) = self.checkForField(nameList, "LENGTH")
405
- if not found:
406
- field = QgsField("LENGTH", QVariant.Double, "double", 10, 6, "Line length")
407
- index1 = len(fieldList.keys() )
408
- fieldList[ index1] = field
409
- index2 = index1
410
- else:
411
- plp = "Point"
412
- (found, index1) = self.checkForField(nameList, "XCOORD")
413
- if not found:
414
- field = QgsField("XCOORD", QVariant.Double, "double", 10, 6, "Point x coordinate")
415
- index1 = len(fieldList.keys() )
416
- fieldList[ index1] = field
417
- (found, index2) = self.checkForField(nameList, "YCOORD")
418
- if not found:
419
- field = QgsField("YCOORD", QVariant.Double, "double", 10, 6, "Point y coordinate")
420
- index2 = len(fieldList.keys() )
421
- fieldList[ index2] = field
422
- return (fieldList, index1, index2)
423
- */
424
-
385
+ return QgsFieldMap ();
386
+ /* QgsVectorDataProvider* provider = layer->dataProvider ();
387
+ QgsAttributeList allAttrs = provider->attributeIndexes( );
388
+ // provider->select( allAttrs, QgsRectangle(), true );
389
+ QgsFieldMap fields = provider->fields()
390
+ QGis::GeometryType geomType = layer->geometryType();
391
+
392
+ for i in fieldList.keys( )
393
+ nameList.append( fieldList[ i ].name().toLower() )
394
+ if geomType == QGis.Polygon:
395
+ plp = "Poly"
396
+ ( found, index1 ) = self.checkForField( nameList, "AREA" )
397
+ if not found:
398
+ field = QgsField( "AREA", QVariant.Double, "double", 10, 6, "Polygon area" )
399
+ index1 = len( fieldList.keys() )
400
+ fieldList[ index1 ] = field
401
+ ( found, index2 ) = self.checkForField( nameList, "PERIMETER" )
402
+
403
+ if not found:
404
+ field = QgsField( "PERIMETER", QVariant.Double, "double", 10, 6, "Polygon perimeter" )
405
+ index2 = len( fieldList.keys() )
406
+ fieldList[ index2 ] = field
407
+ elif geomType == QGis. Line:
408
+ plp = "Line"
409
+ ( found, index1) = self.checkForField(nameList, "LENGTH")
410
+ if not found:
411
+ field = QgsField("LENGTH", QVariant.Double, "double", 10, 6, "Line length" )
412
+ index1 = len(fieldList.keys())
413
+ fieldList[ index1] = field
414
+ index2 = index1
415
+ else:
416
+ plp = "Point"
417
+ ( found, index1) = self.checkForField(nameList, "XCOORD")
418
+ if not found:
419
+ field = QgsField("XCOORD", QVariant.Double, "double", 10, 6, "Point x coordinate" )
420
+ index1 = len(fieldList.keys())
421
+ fieldList[index1] = field
422
+ ( found, index2) = self.checkForField(nameList, "YCOORD")
423
+ if not found:
424
+ field = QgsField("YCOORD", QVariant.Double, "double", 10, 6, "Point y coordinate" )
425
+ index2 = len(fieldList.keys())
426
+ fieldList[ index2] = field
427
+ return (fieldList, index1, index2)
428
+ */
425
429
}
426
430
427
431
QgsGeometry* QgsGeometryAnalyzer::extractLines ( QgsGeometry* geometry )
428
432
{
429
- /*
430
- QGis::WkbType wkbType = geometry.wkbType();
431
- QList<QgsPolyline> lineList;
432
- QgsMultiPolygon polyList
433
- if ( geometry.type() == QGis::Polygon )
434
- {
435
- if ( geometry.isMultipart() )
433
+ return NULL ;
434
+ /*
435
+ QGis::WkbType wkbType = geometry.wkbType();
436
+ QList<QgsPolyline> lineList;
437
+ QgsMultiPolygon polyList
438
+ if ( geometry.type() == QGis::Polygon )
436
439
{
437
- polyList = geometry.asMultiPolygon();
438
- for ( polygon = polyList.begin(); polygon != polyList.end(); polygon++ )
440
+ if ( geometry.isMultipart() )
439
441
{
440
- for ( lines = polygon.begin(); lines != polygon.end(); lines++ )
442
+ polyList = geometry.asMultiPolygon();
443
+ for ( polygon = polyList.begin(); polygon != polyList.end(); polygon++ )
441
444
{
442
- lineList << lines;
445
+ for ( lines = polygon.begin(); lines != polygon.end(); lines++ )
446
+ {
447
+ lineList << lines;
448
+ }
449
+ }
450
+ else
451
+ {
452
+ lineList = geometry.asPolygon();
443
453
}
444
- }
445
- else
446
- {
447
- lineList = geometry.asPolygon();
448
454
}
449
455
}
450
- }
451
- return lineList
452
- */
456
+ return lineList
457
+ */
453
458
}
454
459
QgsGeometry* QgsGeometryAnalyzer::extractAsSingle ( QgsGeometry* geometry )
455
460
{
456
- /*
457
- multi_geom = QgsGeometry()
458
- temp_geom = []
459
- if geom.type() == 0:
460
- if geom.isMultipart()
461
- multi_geom = geom.asMultiPoint ()
462
- for i in multi_geom:
463
- temp_geom.append( QgsGeometry().fromPoint ( i ) )
464
- else:
465
- temp_geom.append( geom )
466
- elif geom.type() == 1:
467
- if geom.isMultipart()
468
- multi_geom = geom.asMultiPolyline ()
469
- for i in multi_geom:
470
- temp_geom.append( QgsGeometry().fromPolyline( i ) )
471
- else:
472
- temp_geom.append( geom )
473
- elif geom.type() == 2:
474
- if geom.isMultipart()
475
- multi_geom = geom.asMultiPolygon ()
476
- for i in multi_geom:
477
- temp_geom.append( QgsGeometry().fromPolygon( i ) )
478
- else:
479
- temp_geom.append( geom )
480
- return temp_geom
481
-
482
- */
483
-
461
+ return NULL ;
462
+ /*
463
+ multi_geom = QgsGeometry()
464
+ temp_geom = []
465
+ if geom.type() == 0:
466
+ if geom.isMultipart ()
467
+ multi_geom = geom.asMultiPoint()
468
+ for i in multi_geom:
469
+ temp_geom.append( QgsGeometry().fromPoint ( i ) )
470
+ else:
471
+ temp_geom.append( geom )
472
+ elif geom.type() == 1:
473
+ if geom.isMultipart ()
474
+ multi_geom = geom.asMultiPolyline()
475
+ for i in multi_geom:
476
+ temp_geom.append( QgsGeometry().fromPolyline( i ) )
477
+ else:
478
+ temp_geom.append( geom )
479
+ elif geom.type() == 2:
480
+ if geom.isMultipart ()
481
+ multi_geom = geom.asMultiPolygon()
482
+ for i in multi_geom:
483
+ temp_geom.append( QgsGeometry().fromPolygon( i ) )
484
+ else:
485
+ temp_geom.append( geom )
486
+ return temp_geom
487
+
488
+ */
484
489
}
485
490
486
491
QgsGeometry* QgsGeometryAnalyzer::extractAsMulti ( QgsGeometry* geometry )
487
492
{
488
- /*
489
- if ( geometry->mGeos == NULL )
490
- {
491
- geometry->exportWkbToGeos();
492
- }
493
- if ( !geometry->mGeos )
494
- {
495
- return 0;
496
- }
497
- return fromGeosGeom( GEOSIntersection( mGeos, geometry->mGeos ) );
493
+ return NULL ;
494
+ /*
495
+ if ( geometry->mGeos == NULL )
496
+ {
497
+ geometry->exportWkbToGeos();
498
+ }
499
+ if ( !geometry->mGeos )
500
+ {
501
+ return 0;
502
+ }
503
+ return fromGeosGeom( GEOSIntersection( mGeos, geometry->mGeos ) );
498
504
499
- for ( int i = 0; i < geometry.size(); i++ )
500
- geomarr[i] = geometry->mGeos[i];
505
+ for ( int i = 0; i < geometry.size(); i++ )
506
+ geomarr[i] = geometry->mGeos[i];
501
507
502
- GEOSGeometry *geom = 0;
508
+ GEOSGeometry *geom = 0;
503
509
504
- try
505
- {
506
- geom = GEOSGeom_createCollection( typeId, geomarr, geoms.size() );
507
- }
508
- catch ( GEOSException &e )
509
- {
510
- Q_UNUSED( e );
511
- }
510
+ try
511
+ {
512
+ geom = GEOSGeom_createCollection( typeId, geomarr, geoms.size() );
513
+ }
514
+ catch ( GEOSException &e )
515
+ {
516
+ Q_UNUSED( e );
517
+ }
512
518
513
- delete [] geomarr;
519
+ delete [] geomarr;
514
520
515
- return geom;
516
- }
521
+ return geom;
522
+ }
517
523
518
- temp_geom = []
519
- if geom.type() == 0:
520
- if geom.isMultipart()
521
- return geom.asMultiPoint()
522
- else:
523
- return [ geom.asPoint() ]
524
- elif geom.type() == 1:
525
- if geom.isMultipart()
526
- return geom.asMultiPolyline()
524
+ temp_geom = []
525
+ if geom.type() == 0:
526
+ if geom.isMultipart()
527
+ return geom.asMultiPoint()
528
+ else:
529
+ return [ geom.asPoint() ]
530
+ elif geom.type() == 1:
531
+ if geom.isMultipart()
532
+ return geom.asMultiPolyline()
533
+ else:
534
+ return [ geom.asPolyline() ]
527
535
else:
528
- return [ geom.asPolyline() ]
529
- else:
530
- if geom.isMultipart()
531
- return geom.asMultiPolygon()
532
- else:
533
- return [ geom.asPolygon() ]
536
+ if geom.isMultipart()
537
+ return geom.asMultiPolygon()
538
+ else:
539
+ return [ geom.asPolygon() ]
540
+
541
+ */
534
542
535
- */
536
-
537
543
}
538
544
539
545
QgsGeometry* QgsGeometryAnalyzer::convertGeometry ( QgsGeometry* geometry )
540
546
{
547
+ return NULL ;
541
548
/*
542
549
if vType == 0:
543
550
return QgsGeometry().fromMultiPoint(geom_list)
@@ -550,52 +557,53 @@ QgsGeometry* QgsGeometryAnalyzer::convertGeometry( QgsGeometry* geometry )
550
557
551
558
QList<QgsPoint> QgsGeometryAnalyzer::extractPoints ( QgsGeometry* geometry )
552
559
{
553
- /* QGis::WkbType wkbType = geometry.wkbType();
554
- QList<QgsPoint> pointList;
555
- QList<QgsPolyline> lineList;
556
- switch ( wkbType )
557
- {
558
- case QGis::WKBPoint25D:
559
- case QGis::WKBPoint:
560
- case QGis::WKBMultiLineString25D:
561
- case QGis::WKBMultiLineString:
562
- {
563
- geometry->convertToMultitype();
564
- pointList = geometry.asMultiPoint();
565
- break;
566
- }
567
- case QGis::WKBLineString25D:
568
- case QGis::WKBLineString:
569
- case QGis::WKBMultiLineString25D:
570
- case QGis::WKBMultiLineString:
560
+ return QList<QgsPoint>();
561
+ /* QGis::WkbType wkbType = geometry.wkbType();
562
+ QList<QgsPoint> pointList;
563
+ QList<QgsPolyline> lineList;
564
+ switch ( wkbType )
571
565
{
572
- geometry->convertToMultitype();
573
- lineList = geometry.asMultiPolyline();
574
- for ( line = lineList.begin(); line != lineList.end(); line++ )
566
+ case QGis::WKBPoint25D:
567
+ case QGis::WKBPoint:
568
+ case QGis::WKBMultiLineString25D:
569
+ case QGis::WKBMultiLineString:
575
570
{
576
- pointList << line;
571
+ geometry->convertToMultitype();
572
+ pointList = geometry.asMultiPoint();
573
+ break;
577
574
}
578
- break;
579
- }
580
- case QGis::WKBPolygon25D:
581
- case QGis::WKBPolygon:
582
- case QGis::WKBMultiPolygon25D:
583
- case QGis::WKBMultiPolygon:
584
- {
585
- geometry->convertToMultitype();
586
- QgsPolygon polyList = geometry.asMultiPolygon();
587
- for ( lineList = polyList.begin(); lineList != polyList.end(); lineList++ )
575
+ case QGis::WKBLineString25D:
576
+ case QGis::WKBLineString:
577
+ case QGis::WKBMultiLineString25D:
578
+ case QGis::WKBMultiLineString:
588
579
{
580
+ geometry->convertToMultitype();
581
+ lineList = geometry.asMultiPolyline();
589
582
for ( line = lineList.begin(); line != lineList.end(); line++ )
590
583
{
591
584
pointList << line;
592
585
}
586
+ break;
593
587
}
594
- break;
588
+ case QGis::WKBPolygon25D:
589
+ case QGis::WKBPolygon:
590
+ case QGis::WKBMultiPolygon25D:
591
+ case QGis::WKBMultiPolygon:
592
+ {
593
+ geometry->convertToMultitype();
594
+ QgsPolygon polyList = geometry.asMultiPolygon();
595
+ for ( lineList = polyList.begin(); lineList != polyList.end(); lineList++ )
596
+ {
597
+ for ( line = lineList.begin(); line != lineList.end(); line++ )
598
+ {
599
+ pointList << line;
600
+ }
601
+ }
602
+ break;
603
+ }
604
+ default:
605
+ break;
595
606
}
596
- default:
597
- break;
598
- }
599
- return pointList;
600
- */
607
+ return pointList;
608
+ */
601
609
}
0 commit comments