mapnik::geometry::polygon<double> geowave_featureset::create_polygon(Polygon polygon) { mapnik::geometry::polygon<double> polygon_out; // handle exterior ring { LineString geom = polygon.getExteriorRing(); mapnik::geometry::linear_ring<double> linear_ring; for (int point_idx = geom.getNumPoints()-1; point_idx >= 0; --point_idx) { Coordinate coord = geom.getPointN(point_idx).getCoordinate(); linear_ring.add_coord(coord.x(), coord.y()); } if (geom.isClosed()) { Coordinate coord = geom.getPointN(geom.getNumPoints()-1).getCoordinate(); linear_ring.add_coord(coord.x(), coord.y()); } polygon_out.set_exterior_ring(std::move(linear_ring)); } // handle interior rings { for (int ring_idx = 0; ring_idx < polygon.getNumInteriorRing(); ++ring_idx) { LineString geom = polygon.getInteriorRingN(ring_idx); mapnik::geometry::linear_ring<double> linear_ring; for (int point_idx = geom.getNumPoints()-1; point_idx >= 0; --point_idx) { Coordinate coord = geom.getPointN(point_idx).getCoordinate(); linear_ring.add_coord(coord.x(), coord.y()); } if (geom.isClosed()) { Coordinate coord = geom.getPointN(geom.getNumPoints()-1).getCoordinate(); linear_ring.add_coord(coord.x(), coord.y()); } polygon_out.add_hole(std::move(linear_ring)); } } return polygon_out; }
bool MultiLineString::isClosed() const { if (isEmpty()) { return false; } for (size_t i = 0, n = geometries->size(); i < n; ++i) { LineString *ls = dynamic_cast<LineString*>((*geometries)[i]); if ( ! ls->isClosed() ) { return false; } } return true; }
mapnik::geometry::line_string<double> geowave_featureset::create_line_string(LineString line_string) { mapnik::geometry::line_string<double> line_string_out; for (int point_idx = line_string.getNumPoints()-1; point_idx >= 0; --point_idx) { Coordinate coord = line_string.getPointN(point_idx).getCoordinate(); line_string_out.add_coord(coord.x(), coord.y()); } if (line_string.isClosed()) { Coordinate coord = line_string.getPointN(line_string.getNumPoints()-1).getCoordinate(); line_string_out.add_coord(coord.x(), coord.y()); } return line_string_out; }