@@ -229,17 +229,16 @@ QgsGeometry QgsGeometry::collectGeometry( const QList< QgsGeometry > &geometries
229
229
{
230
230
QgsGeometry collected;
231
231
232
- QList< QgsGeometry >::const_iterator git = geometries.constBegin ();
233
- for ( ; git != geometries.constEnd (); ++git )
232
+ for ( const QgsGeometry &g : geometries )
234
233
{
235
234
if ( collected.isNull () )
236
235
{
237
- collected = QgsGeometry ( *git ) ;
236
+ collected = g ;
238
237
collected.convertToMultiType ();
239
238
}
240
239
else
241
240
{
242
- collected.addPart ( *git );
241
+ collected.addPart ( g );
243
242
}
244
243
}
245
244
return collected;
@@ -2133,10 +2132,9 @@ QPolygonF QgsGeometry::asQPolygonF() const
2133
2132
return result;
2134
2133
}
2135
2134
2136
- QgsPolyline::const_iterator lineIt = polyline.constBegin ();
2137
- for ( ; lineIt != polyline.constEnd (); ++lineIt )
2135
+ for ( const QgsPointXY &p : qgsAsConst ( polyline ) )
2138
2136
{
2139
- result << lineIt-> toQPointF ();
2137
+ result << p. toQPointF ();
2140
2138
}
2141
2139
return result;
2142
2140
}
@@ -2245,12 +2243,11 @@ QgsGeometry QgsGeometry::unaryUnion( const QList<QgsGeometry> &geometries )
2245
2243
QgsGeos geos ( nullptr );
2246
2244
2247
2245
QList<QgsAbstractGeometry *> geomV2List;
2248
- QList<QgsGeometry>::const_iterator it = geometries.constBegin ();
2249
- for ( ; it != geometries.constEnd (); ++it )
2246
+ for ( const QgsGeometry &g : geometries )
2250
2247
{
2251
- if ( !( ( *it ) .isNull () ) )
2248
+ if ( !( g .isNull () ) )
2252
2249
{
2253
- geomV2List.append ( ( *it ) .geometry () );
2250
+ geomV2List.append ( g .geometry () );
2254
2251
}
2255
2252
}
2256
2253
@@ -2266,12 +2263,11 @@ QgsGeometry QgsGeometry::polygonize( const QList<QgsGeometry> &geometryList )
2266
2263
QgsGeos geos ( nullptr );
2267
2264
2268
2265
QList<QgsAbstractGeometry *> geomV2List;
2269
- QList<QgsGeometry>::const_iterator it = geometryList.constBegin ();
2270
- for ( ; it != geometryList.constEnd (); ++it )
2266
+ for ( const QgsGeometry &g : geometryList )
2271
2267
{
2272
- if ( !( ( *it ) .isNull () ) )
2268
+ if ( !( g .isNull () ) )
2273
2269
{
2274
- geomV2List.append ( ( *it ) .geometry () );
2270
+ geomV2List.append ( g .geometry () );
2275
2271
}
2276
2272
}
2277
2273
@@ -2512,20 +2508,18 @@ QString QgsGeometry::lastError() const
2512
2508
void QgsGeometry::convertPointList ( const QList<QgsPointXY> &input, QgsPointSequence &output )
2513
2509
{
2514
2510
output.clear ();
2515
- QList<QgsPointXY>::const_iterator it = input.constBegin ();
2516
- for ( ; it != input.constEnd (); ++it )
2511
+ for ( const QgsPointXY &p : input )
2517
2512
{
2518
- output.append ( QgsPoint ( it-> x (), it-> y () ) );
2513
+ output.append ( QgsPoint ( p ) );
2519
2514
}
2520
2515
}
2521
2516
2522
2517
void QgsGeometry::convertPointList ( const QgsPointSequence &input, QList<QgsPointXY> &output )
2523
2518
{
2524
2519
output.clear ();
2525
- QgsPointSequence::const_iterator it = input.constBegin ();
2526
- for ( ; it != input.constEnd (); ++it )
2520
+ for ( const QgsPoint &p : input )
2527
2521
{
2528
- output.append ( QgsPointXY ( it-> x (), it-> y () ) );
2522
+ output.append ( QgsPointXY ( p. x (), p. y () ) );
2529
2523
}
2530
2524
}
2531
2525
@@ -2595,10 +2589,9 @@ QgsPolygon QgsGeometry::createPolygonFromQPolygonF( const QPolygonF &polygon )
2595
2589
QgsPolyline QgsGeometry::createPolylineFromQPolygonF ( const QPolygonF &polygon )
2596
2590
{
2597
2591
QgsPolyline result;
2598
- QPolygonF::const_iterator it = polygon.constBegin ();
2599
- for ( ; it != polygon.constEnd (); ++it )
2592
+ for ( const QPointF &p : polygon )
2600
2593
{
2601
- result.append ( QgsPointXY ( *it ) );
2594
+ result.append ( QgsPointXY ( p ) );
2602
2595
}
2603
2596
return result;
2604
2597
}
@@ -2857,11 +2850,11 @@ QgsGeometry QgsGeometry::convertToPoint( bool destMultipart ) const
2857
2850
// input geometry is multipart
2858
2851
if ( isMultipart () )
2859
2852
{
2860
- QgsMultiPolyline multiLine = asMultiPolyline ();
2853
+ const QgsMultiPolyline multiLine = asMultiPolyline ();
2861
2854
QgsMultiPoint multiPoint;
2862
- for ( QgsMultiPolyline::const_iterator multiLineIt = multiLine. constBegin (); multiLineIt != multiLine. constEnd (); ++multiLineIt )
2863
- for ( QgsPolyline::const_iterator lineIt = ( *multiLineIt ). constBegin (); lineIt != ( *multiLineIt ). constEnd (); ++lineIt )
2864
- multiPoint << *lineIt ;
2855
+ for ( const QgsPolyline &l : multiLine )
2856
+ for ( const QgsPointXY &p : l )
2857
+ multiPoint << p ;
2865
2858
return fromMultiPoint ( multiPoint );
2866
2859
}
2867
2860
// input geometry is not multipart: copy directly the line into a multipoint
@@ -2883,22 +2876,22 @@ QgsGeometry QgsGeometry::convertToPoint( bool destMultipart ) const
2883
2876
// input geometry is multipart: make a multipoint from multipolygon
2884
2877
if ( isMultipart () )
2885
2878
{
2886
- QgsMultiPolygon multiPolygon = asMultiPolygon ();
2879
+ const QgsMultiPolygon multiPolygon = asMultiPolygon ();
2887
2880
QgsMultiPoint multiPoint;
2888
- for ( QgsMultiPolygon::const_iterator polygonIt = multiPolygon. constBegin (); polygonIt != multiPolygon. constEnd (); ++polygonIt )
2889
- for ( QgsMultiPolyline::const_iterator multiLineIt = ( *polygonIt ). constBegin (); multiLineIt != ( *polygonIt ). constEnd (); ++multiLineIt )
2890
- for ( QgsPolyline::const_iterator lineIt = ( *multiLineIt ). constBegin (); lineIt != ( *multiLineIt ). constEnd (); ++lineIt )
2891
- multiPoint << *lineIt ;
2881
+ for ( const QgsPolygon &poly : multiPolygon )
2882
+ for ( const QgsPolyline &line : poly )
2883
+ for ( const QgsPointXY &pt : line )
2884
+ multiPoint << pt ;
2892
2885
return fromMultiPoint ( multiPoint );
2893
2886
}
2894
2887
// input geometry is not multipart: make a multipoint from polygon
2895
2888
else
2896
2889
{
2897
- QgsPolygon polygon = asPolygon ();
2890
+ const QgsPolygon polygon = asPolygon ();
2898
2891
QgsMultiPoint multiPoint;
2899
- for ( QgsMultiPolyline::const_iterator multiLineIt = polygon. constBegin (); multiLineIt != polygon. constEnd (); ++multiLineIt )
2900
- for ( QgsPolyline::const_iterator lineIt = ( *multiLineIt ). constBegin (); lineIt != ( *multiLineIt ). constEnd (); ++lineIt )
2901
- multiPoint << *lineIt ;
2892
+ for ( const QgsPolyline &line : polygon )
2893
+ for ( const QgsPointXY &pt : line )
2894
+ multiPoint << pt ;
2902
2895
return fromMultiPoint ( multiPoint );
2903
2896
}
2904
2897
}
@@ -2959,11 +2952,11 @@ QgsGeometry QgsGeometry::convertToLine( bool destMultipart ) const
2959
2952
// input geometry is multipolygon
2960
2953
if ( isMultipart () )
2961
2954
{
2962
- QgsMultiPolygon multiPolygon = asMultiPolygon ();
2955
+ const QgsMultiPolygon multiPolygon = asMultiPolygon ();
2963
2956
QgsMultiPolyline multiLine;
2964
- for ( QgsMultiPolygon::const_iterator polygonIt = multiPolygon. constBegin (); polygonIt != multiPolygon. constEnd (); ++polygonIt )
2965
- for ( QgsMultiPolyline::const_iterator multiLineIt = ( *polygonIt ). constBegin (); multiLineIt != ( *polygonIt ). constEnd (); ++multiLineIt )
2966
- multiLine << *multiLineIt ;
2957
+ for ( const QgsPolygon &poly : multiPolygon )
2958
+ for ( const QgsPolyline &line : poly )
2959
+ multiLine << line ;
2967
2960
2968
2961
if ( destMultipart )
2969
2962
{
@@ -2987,10 +2980,10 @@ QgsGeometry QgsGeometry::convertToLine( bool destMultipart ) const
2987
2980
// TODO: would it be better to remove rings?
2988
2981
if ( destMultipart )
2989
2982
{
2990
- QgsPolygon polygon = asPolygon ();
2983
+ const QgsPolygon polygon = asPolygon ();
2991
2984
QgsMultiPolyline multiLine;
2992
- for ( QgsMultiPolyline::const_iterator multiLineIt = polygon. constBegin (); multiLineIt != polygon. constEnd (); ++multiLineIt )
2993
- multiLine << *multiLineIt ;
2985
+ for ( const QgsPolyline &line : polygon )
2986
+ multiLine << line ;
2994
2987
return fromMultiPolyline ( multiLine );
2995
2988
}
2996
2989
}
0 commit comments