Skip to content

Commit 2fd8667

Browse files
committed
fix compilation with mapnik/master
1 parent 0c2b066 commit 2fd8667

1 file changed

Lines changed: 31 additions & 9 deletions

File tree

src/mapnik_geometry.cpp

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,35 @@ void geometry_correct_impl(mapnik::geometry::geometry<double> & geom)
168168
mapnik::geometry::correct(geom);
169169
}
170170

171-
void polygon_set_exterior_impl(mapnik::geometry::polygon<double> & poly, mapnik::geometry::linear_ring<double> const& ring)
171+
void line_string_add_coord_impl1(mapnik::geometry::line_string<double> & l, double x, double y)
172172
{
173-
poly.exterior_ring = ring; // copy
173+
l.emplace_back(x, y);
174174
}
175175

176-
void polygon_add_hole_impl(mapnik::geometry::polygon<double> & poly, mapnik::geometry::linear_ring<double> const& ring)
176+
void line_string_add_coord_impl2(mapnik::geometry::line_string<double> & l, mapnik::geometry::point<double> const& p)
177177
{
178-
poly.interior_rings.push_back(ring); // copy
178+
l.push_back(p);
179+
}
180+
181+
void linear_ring_add_coord_impl1(mapnik::geometry::linear_ring<double> & l, double x, double y)
182+
{
183+
l.emplace_back(x, y);
184+
}
185+
186+
void linear_ring_add_coord_impl2(mapnik::geometry::linear_ring<double> & l, mapnik::geometry::point<double> const& p)
187+
{
188+
l.push_back(p);
189+
}
190+
191+
mapnik::geometry::linear_ring<double> & polygon_exterior_impl(mapnik::geometry::polygon<double> & poly)
192+
{
193+
if (poly.empty()) poly.resize(1);
194+
return poly[0];
195+
}
196+
197+
void polygon_add_ring_impl(mapnik::geometry::polygon<double> & poly, mapnik::geometry::linear_ring<double> const& ring)
198+
{
199+
poly.push_back(ring); // copy
179200
}
180201

181202
mapnik::geometry::point<double> geometry_centroid_impl(mapnik::geometry::geometry<double> const& geom)
@@ -230,7 +251,8 @@ void export_geometry()
230251

231252
class_<line_string<double> >("LineString", init<>(
232253
"Constructs a new LineString object\n"))
233-
.def("add_coord", &line_string<double>::add_coord, "Adds coord")
254+
.def("add_coord", &line_string_add_coord_impl1, "Adds coord x,y")
255+
.def("add_point", &line_string_add_coord_impl2, "Adds point")
234256
#if BOOST_VERSION >= 105800
235257
.def("is_valid", &geometry_is_valid_impl)
236258
.def("is_simple", &geometry_is_simple_impl)
@@ -242,14 +264,14 @@ void export_geometry()
242264

243265
class_<linear_ring<double> >("LinearRing", init<>(
244266
"Constructs a new LinearRtring object\n"))
245-
.def("add_coord", &linear_ring<double>::add_coord, "Adds coord")
267+
.def("add_coord", &linear_ring_add_coord_impl1, "Adds coord x,y")
268+
.def("add_point", &linear_ring_add_coord_impl2, "Adds point")
246269
;
247270

248271
class_<polygon<double> >("Polygon", init<>(
249272
"Constructs a new Polygon object\n"))
250-
.add_property("exterior_ring", &polygon<double>::exterior_ring , "Exterior ring")
251-
.def("add_hole", &polygon_add_hole_impl, "Add interior ring")
252-
.def("num_rings", polygon_set_exterior_impl, "Number of rings (at least 1)")
273+
.def("add_ring", &polygon_add_ring_impl, "Add ring")
274+
.def("num_rings", &polygon<double>::size, "Number of rings")
253275
#if BOOST_VERSION >= 105800
254276
.def("is_valid", &geometry_is_valid_impl)
255277
.def("is_simple", &geometry_is_simple_impl)

0 commit comments

Comments
 (0)