@@ -46,14 +46,14 @@ std::unique_ptr<OGRPolygon> CoastlinePolygons::create_rectangular_polygon(double
46
46
// make sure we are inside the bounds for the output SRS
47
47
e.Intersect (srs.max_extent ());
48
48
49
- std::unique_ptr<OGRLinearRing> ring { new OGRLinearRing () };
49
+ std::unique_ptr<OGRLinearRing> ring{ new OGRLinearRing ()};
50
50
ring->addPoint (e.MinX , e.MinY );
51
51
ring->addPoint (e.MinX , e.MaxY );
52
52
ring->addPoint (e.MaxX , e.MaxY );
53
53
ring->addPoint (e.MaxX , e.MinY );
54
54
ring->closeRings ();
55
55
56
- std::unique_ptr<OGRPolygon> polygon { new OGRPolygon () };
56
+ std::unique_ptr<OGRPolygon> polygon{ new OGRPolygon ()};
57
57
polygon->addRingDirectly (ring.release ());
58
58
polygon->assignSpatialReference (srs.out ());
59
59
@@ -95,7 +95,7 @@ void CoastlinePolygons::split_geometry(std::unique_ptr<OGRGeometry>&& geom, int
95
95
} else { // wkbMultiPolygon
96
96
const auto mp = static_cast_unique_ptr<OGRMultiPolygon>(std::move (geom));
97
97
while (mp->getNumGeometries () > 0 ) {
98
- std::unique_ptr<OGRPolygon> polygon { static_cast <OGRPolygon*>(mp->getGeometryRef (0 )) };
98
+ std::unique_ptr<OGRPolygon> polygon{ static_cast <OGRPolygon*>(mp->getGeometryRef (0 ))};
99
99
mp->removeGeometry (0 , false );
100
100
polygon->assignSpatialReference (srs.out ());
101
101
split_polygon (std::move (polygon), level);
@@ -108,7 +108,7 @@ void CoastlinePolygons::split_polygon(std::unique_ptr<OGRPolygon>&& polygon, int
108
108
m_max_split_depth = level;
109
109
}
110
110
111
- int num_points = polygon->getExteriorRing ()->getNumPoints ();
111
+ const int num_points = polygon->getExteriorRing ()->getNumPoints ();
112
112
if (num_points <= m_max_points_in_polygon) {
113
113
// do not split the polygon if it is small enough
114
114
m_polygons.push_back (std::move (polygon));
@@ -139,7 +139,7 @@ void CoastlinePolygons::split_polygon(std::unique_ptr<OGRPolygon>&& polygon, int
139
139
}
140
140
141
141
// split vertically
142
- double MidY = (envelope.MaxY +envelope.MinY ) / 2 ;
142
+ const double MidY = (envelope.MaxY +envelope.MinY ) / 2 ;
143
143
144
144
b1 = create_rectangular_polygon (envelope.MinX , envelope.MinY , envelope.MaxX , MidY, m_expand);
145
145
b2 = create_rectangular_polygon (envelope.MinX , MidY, envelope.MaxX , envelope.MaxY , m_expand);
@@ -151,15 +151,15 @@ void CoastlinePolygons::split_polygon(std::unique_ptr<OGRPolygon>&& polygon, int
151
151
}
152
152
153
153
// split horizontally
154
- double MidX = (envelope.MaxX +envelope.MinX ) / 2 ;
154
+ const double MidX = (envelope.MaxX +envelope.MinX ) / 2 ;
155
155
156
156
b1 = create_rectangular_polygon (envelope.MinX , envelope.MinY , MidX, envelope.MaxY , m_expand);
157
157
b2 = create_rectangular_polygon (MidX, envelope.MinY , envelope.MaxX , envelope.MaxY , m_expand);
158
158
}
159
159
160
160
// Use intersection with bbox polygons to split polygon into two halfes
161
- std::unique_ptr<OGRGeometry> geom1 { polygon->Intersection (b1.get ()) };
162
- std::unique_ptr<OGRGeometry> geom2 { polygon->Intersection (b2.get ()) };
161
+ std::unique_ptr<OGRGeometry> geom1{ polygon->Intersection (b1.get ())};
162
+ std::unique_ptr<OGRGeometry> geom2{ polygon->Intersection (b2.get ())};
163
163
164
164
if (geom1 && (geom1->getGeometryType () == wkbPolygon || geom1->getGeometryType () == wkbMultiPolygon) &&
165
165
geom2 && (geom2->getGeometryType () == wkbPolygon || geom2->getGeometryType () == wkbMultiPolygon)) {
@@ -247,12 +247,12 @@ void CoastlinePolygons::add_line_to_output(std::unique_ptr<OGRLineString> line,
247
247
// Add a coastline ring as LineString to output. Segments in this line that are
248
248
// near the southern edge of the map or near the antimeridian are suppressed.
249
249
void CoastlinePolygons::output_polygon_ring_as_lines (int max_points, const OGRLinearRing* ring) const {
250
- int num = ring->getNumPoints ();
250
+ const int num = ring->getNumPoints ();
251
251
assert (num > 2 );
252
252
253
- std::unique_ptr<OGRPoint> point1 { new OGRPoint };
254
- std::unique_ptr<OGRPoint> point2 { new OGRPoint };
255
- std::unique_ptr<OGRLineString> line { new OGRLineString };
253
+ std::unique_ptr<OGRPoint> point1{ new OGRPoint};
254
+ std::unique_ptr<OGRPoint> point2{ new OGRPoint};
255
+ std::unique_ptr<OGRLineString> line{ new OGRLineString};
256
256
257
257
ring->getPoint (0 , point1.get ());
258
258
for (int i=1 ; i < num; ++i) {
@@ -262,7 +262,7 @@ void CoastlinePolygons::output_polygon_ring_as_lines(int max_points, const OGRLi
262
262
263
263
if (line->getNumPoints () >= max_points || !added) {
264
264
if (line->getNumPoints () >= 2 ) {
265
- std::unique_ptr<OGRLineString> new_line { new OGRLineString };
265
+ std::unique_ptr<OGRLineString> new_line{ new OGRLineString};
266
266
using std::swap;
267
267
swap (line, new_line);
268
268
add_line_to_output (std::move (new_line), ring->getSpatialReference ());
@@ -333,7 +333,7 @@ void CoastlinePolygons::split_bbox(OGREnvelope e, polygon_vector_type&& v) {
333
333
334
334
if (e.MaxX - e.MinX < e.MaxY -e.MinY ) {
335
335
// split vertically
336
- double MidY = (e.MaxY +e.MinY ) / 2 ;
336
+ const double MidY = (e.MaxY +e.MinY ) / 2 ;
337
337
338
338
e1 .MinX = e.MinX ;
339
339
e1 .MinY = e.MinY ;
@@ -347,7 +347,7 @@ void CoastlinePolygons::split_bbox(OGREnvelope e, polygon_vector_type&& v) {
347
347
348
348
} else {
349
349
// split horizontally
350
- double MidX = (e.MaxX +e.MinX ) / 2 ;
350
+ const double MidX = (e.MaxX +e.MinX ) / 2 ;
351
351
352
352
e1 .MinX = e.MinX ;
353
353
e1 .MinY = e.MinY ;
@@ -371,8 +371,8 @@ void CoastlinePolygons::split_bbox(OGREnvelope e, polygon_vector_type&& v) {
371
371
OGREnvelope e;
372
372
polygon->getEnvelope (&e);
373
373
374
- bool e1_intersects_e = e1 .Intersects (e);
375
- bool e2_intersects_e = e2 .Intersects (e);
374
+ const bool e1_intersects_e = e1 .Intersects (e);
375
+ const bool e2_intersects_e = e2 .Intersects (e);
376
376
377
377
if (e1_intersects_e && e2_intersects_e) {
378
378
v1.emplace_back (static_cast <OGRPolygon*>(polygon->clone ()));
0 commit comments