From 87fb41907a8add363d59c86251d41059db84dd2b Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Thu, 9 Apr 2015 15:22:51 -0500 Subject: [PATCH] Added template to geometries --- benchmark/test_polygon_clipping.cpp | 78 +- bindings/python/mapnik_geometry.cpp | 64 +- include/mapnik/feature.hpp | 8 +- include/mapnik/geometry.hpp | 71 +- include/mapnik/geometry_adapters.hpp | 98 +-- include/mapnik/geometry_centroid.hpp | 29 +- include/mapnik/geometry_correct.hpp | 12 +- include/mapnik/geometry_envelope_impl.hpp | 14 +- include/mapnik/geometry_fusion_adapted.hpp | 8 +- include/mapnik/geometry_is_empty.hpp | 16 +- include/mapnik/geometry_is_simple.hpp | 24 +- include/mapnik/geometry_is_valid.hpp | 24 +- include/mapnik/geometry_reprojection.hpp | 3 +- include/mapnik/geometry_to_path.hpp | 25 +- include/mapnik/geometry_transform.hpp | 20 +- include/mapnik/geometry_type.hpp | 14 +- include/mapnik/hit_test_filter.hpp | 16 +- .../json/extract_bounding_box_grammar.hpp | 2 +- .../mapnik/json/feature_generator_grammar.hpp | 6 +- .../json/geometry_generator_grammar.hpp | 32 +- include/mapnik/json/geometry_grammar.hpp | 8 +- include/mapnik/json/geometry_parser.hpp | 2 +- include/mapnik/json/geometry_util.hpp | 20 +- include/mapnik/json/positions_grammar.hpp | 2 +- include/mapnik/marker_helpers.hpp | 14 +- include/mapnik/memory_featureset.hpp | 2 +- include/mapnik/proj_transform.hpp | 12 +- .../renderer_common/pattern_alignment.hpp | 6 +- .../process_building_symbolizer.hpp | 12 +- .../process_group_symbolizer.hpp | 2 +- .../process_point_symbolizer.hpp | 4 +- include/mapnik/text/symbolizer_helpers.hpp | 6 +- include/mapnik/util/geometry_to_ds_type.hpp | 16 +- include/mapnik/util/geometry_to_geojson.hpp | 4 +- include/mapnik/util/geometry_to_wkb.hpp | 20 +- include/mapnik/util/geometry_to_wkt.hpp | 4 +- .../util/spirit_transform_attribute.hpp | 78 +- include/mapnik/vertex_adapters.hpp | 53 +- include/mapnik/vertex_processor.hpp | 34 +- include/mapnik/well_known_srs.hpp | 4 +- include/mapnik/wkb.hpp | 2 +- include/mapnik/wkt/wkt_factory.hpp | 2 +- include/mapnik/wkt/wkt_generator_grammar.hpp | 32 +- .../mapnik/wkt/wkt_generator_grammar_impl.hpp | 2 +- include/mapnik/wkt/wkt_grammar.hpp | 42 +- include/mapnik/wkt/wkt_grammar_impl.hpp | 4 +- plugins/input/csv/csv_datasource.cpp | 6 +- plugins/input/gdal/gdal_featureset.cpp | 2 +- plugins/input/ogr/ogr_converter.cpp | 36 +- plugins/input/ogr/ogr_converter.hpp | 16 +- plugins/input/osm/osm_featureset.cpp | 6 +- plugins/input/postgis/postgis_featureset.cpp | 2 +- plugins/input/shape/shape_featureset.cpp | 6 +- .../input/shape/shape_index_featureset.cpp | 6 +- plugins/input/shape/shape_io.cpp | 20 +- plugins/input/shape/shape_io.hpp | 4 +- plugins/input/sqlite/sqlite_datasource.cpp | 2 +- plugins/input/sqlite/sqlite_featureset.cpp | 2 +- plugins/input/sqlite/sqlite_utils.hpp | 6 +- .../templates/helloworld/hello_featureset.cpp | 2 +- .../input/topojson/topojson_featureset.cpp | 20 +- src/geometry_envelope.cpp | 16 +- src/geometry_reprojection.cpp | 188 ++--- src/json/mapnik_json_generator_grammar.cpp | 2 +- src/proj_transform.cpp | 8 +- src/text/symbolizer_helpers.cpp | 26 +- src/wkb.cpp | 42 +- src/wkt/mapnik_wkt_generator_grammar.cpp | 2 +- tests/cpp_tests/fontset_runtime_test.cpp | 2 +- tests/cpp_tests/label_algo_test.cpp | 6 +- tests/cpp_tests/wkb_formats_test.cpp | 2 +- tests/cxx/datasources.cpp | 8 +- tests/cxx/geometry.cpp | 12 +- tests/cxx/geometry_envelope_test.cpp | 42 +- tests/cxx/geometry_equal.hpp | 40 +- tests/cxx/geometry_hit_test.cpp | 54 +- tests/cxx/geometry_reprojection.cpp | 704 +++++++++--------- tests/cxx/vertex_adapter.cpp | 14 +- utils/geometry_to_wkb/main.cpp | 2 +- utils/pgsql2sqlite/pgsql2sqlite.hpp | 2 +- 80 files changed, 1171 insertions(+), 1088 deletions(-) diff --git a/benchmark/test_polygon_clipping.cpp b/benchmark/test_polygon_clipping.cpp index b29ca521d..f30abd770 100644 --- a/benchmark/test_polygon_clipping.cpp +++ b/benchmark/test_polygon_clipping.cpp @@ -33,7 +33,7 @@ #include #include -void render(mapnik::geometry::multi_polygon const& geom, +void render(mapnik::geometry::multi_polygon const& geom, mapnik::box2d const& extent, std::string const& name) { @@ -79,7 +79,7 @@ public: expected_("./benchmark/data/polygon_clipping_agg") {} bool validate() const { - mapnik::geometry::geometry geom; + mapnik::geometry::geometry geom; if (!mapnik::from_wkt(wkt_in_, geom)) { throw std::runtime_error("Failed to parse WKT"); @@ -89,12 +89,12 @@ public: std::clog << "empty geom!\n"; return false; } - if (!geom.is()) + if (!geom.is>()) { std::clog << "not a polygon!\n"; return false; } - mapnik::geometry::polygon const& poly = mapnik::util::get(geom); + mapnik::geometry::polygon const& poly = mapnik::util::get>(geom); mapnik::geometry::polygon_vertex_adapter va(poly); @@ -107,8 +107,8 @@ public: clipped.rewind(0); - mapnik::geometry::polygon poly2; - mapnik::geometry::linear_ring ring; + mapnik::geometry::polygon poly2; + mapnik::geometry::linear_ring ring; // exterior ring unsigned cmd; double x, y, x0, y0; @@ -147,7 +147,7 @@ public: std::string expect = expected_+".png"; std::string actual = expected_+"_actual.png"; - mapnik::geometry::multi_polygon mp; + mapnik::geometry::multi_polygon mp; mp.emplace_back(poly2); auto env = mapnik::geometry::envelope(mp); if (!mapnik::util::exists(expect) || (std::getenv("UPDATE") != nullptr)) @@ -160,7 +160,7 @@ public: } bool operator()() const { - mapnik::geometry::geometry geom; + mapnik::geometry::geometry geom; if (!mapnik::from_wkt(wkt_in_, geom)) { throw std::runtime_error("Failed to parse WKT"); @@ -170,7 +170,7 @@ public: std::clog << "empty geom!\n"; return false; } - if (!geom.is()) + if (!geom.is>()) { std::clog << "not a polygon!\n"; return false; @@ -179,7 +179,7 @@ public: for (unsigned i=0;i(geom); + mapnik::geometry::polygon const& poly = mapnik::util::get>(geom); mapnik::geometry::polygon_vertex_adapter va(poly); conv_clip clipped(va); clipped.clip_box( @@ -222,7 +222,7 @@ public: expected_("./benchmark/data/polygon_clipping_clipper") {} bool validate() const { - mapnik::geometry::geometry geom; + mapnik::geometry::geometry geom; if (!mapnik::from_wkt(wkt_in_, geom)) { throw std::runtime_error("Failed to parse WKT"); @@ -232,12 +232,12 @@ public: std::clog << "empty geom!\n"; return false; } - if (!geom.is()) + if (!geom.is>()) { std::clog << "not a polygon!\n"; return false; } - mapnik::geometry::polygon & poly = mapnik::util::get(geom); + mapnik::geometry::polygon & poly = mapnik::util::get>(geom); agg::path_storage ps; ps.move_to(extent_.minx(), extent_.miny()); ps.line_to(extent_.minx(), extent_.maxy()); @@ -253,8 +253,8 @@ public: unsigned cmd; double x,y; clipped.rewind(0); - mapnik::geometry::polygon poly2; - mapnik::geometry::linear_ring ring; + mapnik::geometry::polygon poly2; + mapnik::geometry::linear_ring ring; // TODO: handle resulting multipolygon // exterior ring while (true) @@ -274,7 +274,7 @@ public: mapnik::geometry::correct(poly2); std::string expect = expected_+".png"; std::string actual = expected_+"_actual.png"; - mapnik::geometry::multi_polygon mp; + mapnik::geometry::multi_polygon mp; mp.emplace_back(poly2); auto env = mapnik::geometry::envelope(mp); if (!mapnik::util::exists(expect) || (std::getenv("UPDATE") != nullptr)) @@ -287,7 +287,7 @@ public: } bool operator()() const { - mapnik::geometry::geometry geom; + mapnik::geometry::geometry geom; if (!mapnik::from_wkt(wkt_in_, geom)) { throw std::runtime_error("Failed to parse WKT"); @@ -297,12 +297,12 @@ public: std::clog << "empty geom!\n"; return false; } - if (!geom.is()) + if (!geom.is>()) { std::clog << "not a polygon!\n"; return false; } - mapnik::geometry::polygon const& poly = mapnik::util::get(geom); + mapnik::geometry::polygon const& poly = mapnik::util::get>(geom); agg::path_storage ps; ps.move_to(extent_.minx(), extent_.miny()); ps.line_to(extent_.minx(), extent_.maxy()); @@ -350,7 +350,7 @@ public: expected_("./benchmark/data/polygon_clipping_boost") {} bool validate() const { - mapnik::geometry::geometry geom; + mapnik::geometry::geometry geom; if (!mapnik::from_wkt(wkt_in_, geom)) { throw std::runtime_error("Failed to parse WKT"); @@ -360,25 +360,25 @@ public: std::clog << "empty geom!\n"; return false; } - if (!geom.is()) + if (!geom.is >()) { std::clog << "not a polygon!\n"; return false; } - mapnik::geometry::polygon & poly = mapnik::util::get(geom); + mapnik::geometry::polygon & poly = mapnik::util::get >(geom); mapnik::geometry::correct(poly); - std::deque result; + std::deque > result; mapnik::geometry::bounding_box bbox(extent_.minx(),extent_.miny(),extent_.maxx(),extent_.maxy()); boost::geometry::intersection(bbox,poly,result); std::string expect = expected_+".png"; std::string actual = expected_+"_actual.png"; - mapnik::geometry::multi_polygon mp; + mapnik::geometry::multi_polygon mp; for (auto const& geom: result) { //std::clog << boost::geometry::dsv(geom) << "\n"; mp.emplace_back(geom); } - mapnik::geometry::geometry geom2(mp); + mapnik::geometry::geometry geom2(mp); auto env = mapnik::geometry::envelope(geom2); if (!mapnik::util::exists(expect) || (std::getenv("UPDATE") != nullptr)) { @@ -390,7 +390,7 @@ public: } bool operator()() const { - mapnik::geometry::geometry geom; + mapnik::geometry::geometry geom; if (!mapnik::from_wkt(wkt_in_, geom)) { throw std::runtime_error("Failed to parse WKT"); @@ -400,18 +400,18 @@ public: std::clog << "empty geom!\n"; return false; } - if (!geom.is()) + if (!geom.is >()) { std::clog << "not a polygon!\n"; return false; } - mapnik::geometry::polygon & poly = mapnik::util::get(geom); + mapnik::geometry::polygon & poly = mapnik::util::get >(geom); mapnik::geometry::correct(poly); mapnik::geometry::bounding_box bbox(extent_.minx(),extent_.miny(),extent_.maxx(),extent_.maxy()); bool valid = true; for (unsigned i=0;i result; + std::deque > result; boost::geometry::intersection(bbox,poly,result); unsigned count = 0; for (auto const& geom : result) @@ -448,7 +448,7 @@ public: expected_("./benchmark/data/polygon_clipping_clipper") {} bool validate() const { - mapnik::geometry::geometry geom; + mapnik::geometry::geometry geom; if (!mapnik::from_wkt(wkt_in_, geom)) { throw std::runtime_error("Failed to parse WKT"); @@ -458,12 +458,12 @@ public: std::clog << "empty geom!\n"; return false; } - if (!geom.is()) + if (!geom.is >()) { std::clog << "not a polygon!\n"; return false; } - mapnik::geometry::polygon & poly = mapnik::util::get(geom); + mapnik::geometry::polygon & poly = mapnik::util::get >(geom); mapnik::geometry::correct(poly); ClipperLib::Clipper clipper; @@ -509,7 +509,7 @@ public: clipper.Execute(ClipperLib::ctIntersection, polygons, ClipperLib::pftNonZero, ClipperLib::pftNonZero); clipper.Clear(); ClipperLib::PolyNode* polynode = polygons.GetFirst(); - mapnik::geometry::multi_polygon mp; + mapnik::geometry::multi_polygon mp; mp.emplace_back(); bool first = true; while (polynode) @@ -526,7 +526,7 @@ public: } else { - mapnik::geometry::linear_ring hole; + mapnik::geometry::linear_ring hole; for (auto const& pt : polynode->Contour) { hole.add_coord(pt.X, pt.Y); @@ -538,7 +538,7 @@ public: } std::string expect = expected_+".png"; std::string actual = expected_+"_actual.png"; - mapnik::geometry::geometry geom2(mp); + mapnik::geometry::geometry geom2(mp); auto env = mapnik::geometry::envelope(geom2); if (!mapnik::util::exists(expect) || (std::getenv("UPDATE") != nullptr)) { @@ -550,7 +550,7 @@ public: } bool operator()() const { - mapnik::geometry::geometry geom; + mapnik::geometry::geometry geom; if (!mapnik::from_wkt(wkt_in_, geom)) { throw std::runtime_error("Failed to parse WKT"); @@ -560,18 +560,18 @@ public: std::clog << "empty geom!\n"; return false; } - if (!geom.is()) + if (!geom.is >()) { std::clog << "not a polygon!\n"; return false; } - mapnik::geometry::polygon & poly = mapnik::util::get(geom); + mapnik::geometry::polygon & poly = mapnik::util::get >(geom); mapnik::geometry::correct(poly); mapnik::geometry::bounding_box bbox(extent_.minx(),extent_.miny(),extent_.maxx(),extent_.maxy()); bool valid = true; for (unsigned i=0;i result; + std::deque > result; boost::geometry::intersection(bbox,poly,result); unsigned count = 0; for (auto const& geom : result) diff --git a/bindings/python/mapnik_geometry.cpp b/bindings/python/mapnik_geometry.cpp index 81c96e8bd..4dcb046ff 100644 --- a/bindings/python/mapnik_geometry.cpp +++ b/bindings/python/mapnik_geometry.cpp @@ -62,9 +62,9 @@ namespace { -std::shared_ptr from_wkb_impl(std::string const& wkb) +std::shared_ptr > from_wkb_impl(std::string const& wkb) { - std::shared_ptr geom = std::make_shared(); + std::shared_ptr > geom = std::make_shared >(); try { *geom = std::move(mapnik::geometry_utils::from_wkb(wkb.c_str(), wkb.size())); @@ -76,17 +76,17 @@ std::shared_ptr from_wkb_impl(std::string const& wkb return geom; } -std::shared_ptr from_wkt_impl(std::string const& wkt) +std::shared_ptr > from_wkt_impl(std::string const& wkt) { - std::shared_ptr geom = std::make_shared(); + std::shared_ptr > geom = std::make_shared >(); if (!mapnik::from_wkt(wkt, *geom)) throw std::runtime_error("Failed to parse WKT geometry"); return geom; } -std::shared_ptr from_geojson_impl(std::string const& json) +std::shared_ptr > from_geojson_impl(std::string const& json) { - std::shared_ptr geom = std::make_shared(); + std::shared_ptr > geom = std::make_shared >(); if (!mapnik::json::from_geojson(json, *geom)) throw std::runtime_error("Failed to parse geojson geometry"); return geom; @@ -101,7 +101,7 @@ inline std::string boost_version() return s.str(); } -PyObject* to_wkb_impl(mapnik::geometry::geometry const& geom, mapnik::wkbByteOrder byte_order) +PyObject* to_wkb_impl(mapnik::geometry::geometry const& geom, mapnik::wkbByteOrder byte_order) { mapnik::util::wkb_buffer_ptr wkb = mapnik::util::to_wkb(geom,byte_order); if (wkb) @@ -120,7 +120,7 @@ PyObject* to_wkb_impl(mapnik::geometry::geometry const& geom, mapnik::wkbByteOrd } } -std::string to_geojson_impl(mapnik::geometry::geometry const& geom) +std::string to_geojson_impl(mapnik::geometry::geometry const& geom) { std::string wkt; if (!mapnik::util::to_geojson(wkt, geom)) @@ -130,7 +130,7 @@ std::string to_geojson_impl(mapnik::geometry::geometry const& geom) return wkt; } -std::string to_wkt_impl(mapnik::geometry::geometry const& geom) +std::string to_wkt_impl(mapnik::geometry::geometry const& geom) { std::string wkt; if (!mapnik::util::to_wkt(wkt,geom)) @@ -140,49 +140,49 @@ std::string to_wkt_impl(mapnik::geometry::geometry const& geom) return wkt; } -mapnik::geometry::geometry_types geometry_type_impl(mapnik::geometry::geometry const& geom) +mapnik::geometry::geometry_types geometry_type_impl(mapnik::geometry::geometry const& geom) { return mapnik::geometry::geometry_type(geom); } -mapnik::box2d geometry_envelope_impl(mapnik::geometry::geometry const& geom) +mapnik::box2d geometry_envelope_impl(mapnik::geometry::geometry const& geom) { return mapnik::geometry::envelope(geom); } -bool geometry_is_valid_impl(mapnik::geometry::geometry const& geom) +bool geometry_is_valid_impl(mapnik::geometry::geometry const& geom) { return mapnik::geometry::is_valid(geom); } -bool geometry_is_simple_impl(mapnik::geometry::geometry const& geom) +bool geometry_is_simple_impl(mapnik::geometry::geometry const& geom) { return mapnik::geometry::is_simple(geom); } -bool geometry_is_empty_impl(mapnik::geometry::geometry const& geom) +bool geometry_is_empty_impl(mapnik::geometry::geometry const& geom) { return mapnik::geometry::is_empty(geom); } -void geometry_correct_impl(mapnik::geometry::geometry & geom) +void geometry_correct_impl(mapnik::geometry::geometry & geom) { mapnik::geometry::correct(geom); } -void polygon_set_exterior_impl(mapnik::geometry::polygon & poly, mapnik::geometry::linear_ring const& ring) +void polygon_set_exterior_impl(mapnik::geometry::polygon & poly, mapnik::geometry::linear_ring const& ring) { poly.exterior_ring = ring; // copy } -void polygon_add_hole_impl(mapnik::geometry::polygon & poly, mapnik::geometry::linear_ring const& ring) +void polygon_add_hole_impl(mapnik::geometry::polygon & poly, mapnik::geometry::linear_ring const& ring) { poly.interior_rings.push_back(ring); // copy } -mapnik::geometry::point geometry_centroid_impl(mapnik::geometry::geometry const& geom) +mapnik::geometry::point geometry_centroid_impl(mapnik::geometry::geometry const& geom) { - mapnik::geometry::point pt; + mapnik::geometry::point pt; mapnik::geometry::centroid(geom, pt); return pt; } @@ -192,9 +192,9 @@ void export_geometry() { using namespace boost::python; - implicitly_convertible(); - implicitly_convertible(); - implicitly_convertible(); + implicitly_convertible, mapnik::geometry::geometry >(); + implicitly_convertible, mapnik::geometry::geometry >(); + implicitly_convertible, mapnik::geometry::geometry >(); enum_("GeometryType") .value("Unknown",mapnik::geometry::geometry_types::Unknown) .value("Point",mapnik::geometry::geometry_types::Point) @@ -217,10 +217,10 @@ void export_geometry() using mapnik::geometry::linear_ring; using mapnik::geometry::polygon; - class_("Point", init((arg("x"), arg("y")), + class_ >("Point", init((arg("x"), arg("y")), "Constructs a new Point object\n")) - .add_property("x", &point::x, "X coordinate") - .add_property("y", &point::y, "Y coordinate") + .add_property("x", &point::x, "X coordinate") + .add_property("y", &point::y, "Y coordinate") .def("is_valid", &geometry_is_valid_impl) .def("is_simple", &geometry_is_simple_impl) .def("to_geojson",&to_geojson_impl) @@ -228,9 +228,9 @@ void export_geometry() .def("to_wkt",&to_wkt_impl) ; - class_("LineString", init<>( + class_ >("LineString", init<>( "Constructs a new LineString object\n")) - .def("add_coord", &line_string::add_coord, "Adds coord") + .def("add_coord", &line_string::add_coord, "Adds coord") .def("is_valid", &geometry_is_valid_impl) .def("is_simple", &geometry_is_simple_impl) .def("to_geojson",&to_geojson_impl) @@ -238,14 +238,14 @@ void export_geometry() .def("to_wkt",&to_wkt_impl) ; - class_("LinearRing", init<>( + class_ >("LinearRing", init<>( "Constructs a new LinearRtring object\n")) - .def("add_coord", &linear_ring::add_coord, "Adds coord") + .def("add_coord", &linear_ring::add_coord, "Adds coord") ; - class_("Polygon", init<>( + class_ >("Polygon", init<>( "Constructs a new Polygon object\n")) - .add_property("exterior_ring", &polygon::exterior_ring , "Exterior ring") + .add_property("exterior_ring", &polygon::exterior_ring , "Exterior ring") .def("add_hole", &polygon_add_hole_impl, "Add interior ring") .def("num_rings", polygon_set_exterior_impl, "Number of rings (at least 1)") .def("is_valid", &geometry_is_valid_impl) @@ -255,7 +255,7 @@ void export_geometry() .def("to_wkt",&to_wkt_impl) ; - class_, boost::noncopyable>("Geometry",no_init) + class_, std::shared_ptr >, boost::noncopyable>("Geometry",no_init) .def("envelope",&geometry_envelope_impl) .def("from_geojson", from_geojson_impl) .def("from_wkt", from_wkt_impl) diff --git a/include/mapnik/feature.hpp b/include/mapnik/feature.hpp index 6d975bf49..c4888f386 100644 --- a/include/mapnik/feature.hpp +++ b/include/mapnik/feature.hpp @@ -195,17 +195,17 @@ public: return ctx_; } - inline void set_geometry(geometry::geometry && geom) + inline void set_geometry(geometry::geometry && geom) { geom_ = std::move(geom); } - inline void set_geometry_copy(geometry::geometry const& geom) + inline void set_geometry_copy(geometry::geometry const& geom) { geom_ = geom; } - inline geometry::geometry const& get_geometry() const + inline geometry::geometry const& get_geometry() const { return geom_; } @@ -262,7 +262,7 @@ private: mapnik::value_integer id_; context_ptr ctx_; cont_type data_; - geometry::geometry geom_; + geometry::geometry geom_; raster_ptr raster_; }; diff --git a/include/mapnik/geometry.hpp b/include/mapnik/geometry.hpp index 8745be2d7..12e7a0efb 100644 --- a/include/mapnik/geometry.hpp +++ b/include/mapnik/geometry.hpp @@ -31,11 +31,12 @@ namespace mapnik { namespace geometry { +template struct point { - using value_type = double; + using value_type = T; point() {} - point(double x_, double y_) + point(T x_, T y_) : x(x_), y(y_) {} @@ -46,41 +47,44 @@ struct point value_type y; }; +template struct bounding_box { bounding_box() {} // no-init - bounding_box(double lox, double loy, double hix, double hiy) + bounding_box(T lox, T loy, T hix, T hiy) : p0(lox,loy), p1(hix,hiy) {} - point p0; - point p1; + point p0; + point p1; }; -struct line_string : std::vector +template +struct line_string : std::vector > { line_string() = default; line_string (line_string && other) = default ; line_string& operator=(line_string &&) = default; line_string (line_string const& ) = default; line_string& operator=(line_string const&) = default; - inline std::size_t num_points() const { return size(); } - inline void add_coord(double x, double y) { emplace_back(x,y);} + inline std::size_t num_points() const { return std::vector>::template size(); } + inline void add_coord(T x, T y) { std::vector>::template emplace_back(x,y);} }; +template +struct linear_ring : line_string {}; -struct linear_ring : line_string {}; - +template struct polygon { - linear_ring exterior_ring; - std::vector interior_rings; + linear_ring exterior_ring; + std::vector> interior_rings; - inline void set_exterior_ring(linear_ring && ring) + inline void set_exterior_ring(linear_ring && ring) { exterior_ring = std::move(ring); } - inline void add_hole(linear_ring && ring) + inline void add_hole(linear_ring && ring) { interior_rings.emplace_back(std::move(ring)); } @@ -93,21 +97,32 @@ struct polygon } }; -struct multi_point : line_string {}; -struct multi_line_string : std::vector {}; -struct multi_polygon : std::vector {}; -struct geometry_collection; -struct geometry_empty {}; -using geometry = mapnik::util::variant >; +template +struct multi_point : line_string {}; -struct geometry_collection : std::vector {}; +template +struct multi_line_string : std::vector> {}; + +template +struct multi_polygon : std::vector> {}; + +template +struct geometry_collection; + +struct geometry_empty {}; + +template +using geometry = mapnik::util::variant, + line_string, + polygon, + multi_point, + multi_line_string, + multi_polygon, + mapnik::util::recursive_wrapper > >; + +template +struct geometry_collection : std::vector> {}; }} diff --git a/include/mapnik/geometry_adapters.hpp b/include/mapnik/geometry_adapters.hpp index c73c5df1a..8003d89bd 100644 --- a/include/mapnik/geometry_adapters.hpp +++ b/include/mapnik/geometry_adapters.hpp @@ -36,155 +36,155 @@ #include // register point -BOOST_GEOMETRY_REGISTER_POINT_2D (mapnik::geometry::point, double, cs::cartesian, x, y) +BOOST_GEOMETRY_REGISTER_POINT_2D (mapnik::geometry::point, double, cs::cartesian, x, y) // ring -BOOST_GEOMETRY_REGISTER_RING(mapnik::geometry::linear_ring) +BOOST_GEOMETRY_REGISTER_RING(mapnik::geometry::linear_ring) namespace boost { template <> -struct range_iterator +struct range_iterator > { - using type = mapnik::geometry::line_string::iterator; + using type = mapnik::geometry::line_string::iterator; }; template <> -struct range_const_iterator +struct range_const_iterator > { - using type = mapnik::geometry::line_string::const_iterator; + using type = mapnik::geometry::line_string::const_iterator; }; -inline mapnik::geometry::line_string::iterator -range_begin(mapnik::geometry::line_string & line) {return line.begin();} +inline mapnik::geometry::line_string::iterator +range_begin(mapnik::geometry::line_string & line) {return line.begin();} -inline mapnik::geometry::line_string::iterator -range_end(mapnik::geometry::line_string & line) {return line.end();} +inline mapnik::geometry::line_string::iterator +range_end(mapnik::geometry::line_string & line) {return line.end();} -inline mapnik::geometry::line_string::const_iterator -range_begin(mapnik::geometry::line_string const& line) {return line.begin();} +inline mapnik::geometry::line_string::const_iterator +range_begin(mapnik::geometry::line_string const& line) {return line.begin();} -inline mapnik::geometry::line_string::const_iterator -range_end(mapnik::geometry::line_string const& line) {return line.end();} +inline mapnik::geometry::line_string::const_iterator +range_end(mapnik::geometry::line_string const& line) {return line.end();} namespace geometry { namespace traits { -template<> struct tag { using type = box_tag; }; +template<> struct tag> { using type = box_tag; }; -template<> struct point_type { using type = mapnik::geometry::point; }; +template<> struct point_type> { using type = mapnik::geometry::point; }; template <> -struct indexed_access +struct indexed_access, min_corner, 0> { - static inline double get(mapnik::geometry::bounding_box const& b) { return b.p0.x;} - static inline void set(mapnik::geometry::bounding_box& b, double value) { b.p0.x = value; } + static inline double get(mapnik::geometry::bounding_box const& b) { return b.p0.x;} + static inline void set(mapnik::geometry::bounding_box & b, double value) { b.p0.x = value; } }; template <> -struct indexed_access +struct indexed_access, min_corner, 1> { - static inline double get(mapnik::geometry::bounding_box const& b) { return b.p0.y;} - static inline void set(mapnik::geometry::bounding_box& b, double value) { b.p0.y = value; } + static inline double get(mapnik::geometry::bounding_box const& b) { return b.p0.y;} + static inline void set(mapnik::geometry::bounding_box & b, double value) { b.p0.y = value; } }; template <> -struct indexed_access +struct indexed_access, max_corner, 0> { - static inline double get(mapnik::geometry::bounding_box const& b) { return b.p1.x;} - static inline void set(mapnik::geometry::bounding_box& b, double value) { b.p1.x = value; } + static inline double get(mapnik::geometry::bounding_box const& b) { return b.p1.x;} + static inline void set(mapnik::geometry::bounding_box & b, double value) { b.p1.x = value; } }; template <> -struct indexed_access +struct indexed_access, max_corner, 1> { - static inline double get(mapnik::geometry::bounding_box const& b) { return b.p1.y;} - static inline void set(mapnik::geometry::bounding_box& b, double value) { b.p1.y = value; } + static inline double get(mapnik::geometry::bounding_box const& b) { return b.p1.y;} + static inline void set(mapnik::geometry::bounding_box & b, double value) { b.p1.y = value; } }; template<> -struct tag +struct tag > { using type = linestring_tag; }; // mapnik::geometry::polygon template<> -struct tag +struct tag > { using type = polygon_tag; }; template <> -struct point_order +struct point_order > { static const order_selector value = counterclockwise; }; template<> -struct tag +struct tag > { using type = multi_point_tag; }; template<> -struct tag +struct tag > { using type = multi_linestring_tag; }; -template<> struct tag +template<> struct tag > { using type = multi_polygon_tag; }; // ring -template<> struct ring_const_type +template<> struct ring_const_type > { - using type = mapnik::geometry::linear_ring const&; + using type = mapnik::geometry::linear_ring const&; }; -template<> struct ring_mutable_type +template<> struct ring_mutable_type > { - using type = mapnik::geometry::linear_ring&; + using type = mapnik::geometry::linear_ring&; }; // interior -template<> struct interior_const_type +template<> struct interior_const_type > { - using type = std::vector const&; + using type = std::vector > const&; }; -template<> struct interior_mutable_type +template<> struct interior_mutable_type > { - using type = std::vector&; + using type = std::vector >&; }; // exterior template<> -struct exterior_ring +struct exterior_ring > { - static mapnik::geometry::linear_ring& get(mapnik::geometry::polygon & p) + static mapnik::geometry::linear_ring & get(mapnik::geometry::polygon & p) { return p.exterior_ring; } - static mapnik::geometry::linear_ring const& get(mapnik::geometry::polygon const& p) + static mapnik::geometry::linear_ring const& get(mapnik::geometry::polygon const& p) { return p.exterior_ring; } }; template<> -struct interior_rings +struct interior_rings > { - using holes_type = std::vector; - static holes_type& get(mapnik::geometry::polygon & p) + using holes_type = std::vector >; + static holes_type& get(mapnik::geometry::polygon & p) { return p.interior_rings; } - static holes_type const& get(mapnik::geometry::polygon const& p) + static holes_type const& get(mapnik::geometry::polygon const& p) { return p.interior_rings; } diff --git a/include/mapnik/geometry_centroid.hpp b/include/mapnik/geometry_centroid.hpp index 4419e7a86..2e7dec199 100644 --- a/include/mapnik/geometry_centroid.hpp +++ b/include/mapnik/geometry_centroid.hpp @@ -31,15 +31,16 @@ namespace mapnik { namespace geometry { namespace detail { +template struct geometry_centroid { using result_type = bool; - geometry_centroid(point & pt) + geometry_centroid(point & pt) : pt_(pt) {} - template - result_type operator() (T const& geom) const + template + result_type operator() (T1 const& geom) const { return util::apply_visitor(*this, geom); } @@ -49,55 +50,55 @@ struct geometry_centroid return false; } - result_type operator() (geometry_collection const& collection) const + result_type operator() (geometry_collection const& collection) const { return false; } - result_type operator() (point const& geom) const + result_type operator() (point const& geom) const { boost::geometry::centroid(geom, pt_); return true; } - result_type operator() (line_string const& geom) const + result_type operator() (line_string const& geom) const { boost::geometry::centroid(geom, pt_); return true; } - result_type operator() (polygon const& geom) const + result_type operator() (polygon const& geom) const { boost::geometry::centroid(geom, pt_); return true; } - result_type operator() (multi_point const& geom) const + result_type operator() (multi_point const& geom) const { boost::geometry::centroid(geom, pt_); return true; } - result_type operator() (multi_line_string const& geom) const + result_type operator() (multi_line_string const& geom) const { boost::geometry::centroid(geom, pt_); return true; } - result_type operator() (multi_polygon const& geom) const + result_type operator() (multi_polygon const& geom) const { boost::geometry::centroid(geom, pt_); return true; } - point & pt_; + point & pt_; }; } -template -inline bool centroid(T const& geom, point & pt) +template +inline bool centroid(T1 const& geom, point & pt) { - return detail::geometry_centroid(pt)(geom); + return detail::geometry_centroid(pt)(geom); } }} diff --git a/include/mapnik/geometry_correct.hpp b/include/mapnik/geometry_correct.hpp index 9c9f0ec6d..dcb3452aa 100644 --- a/include/mapnik/geometry_correct.hpp +++ b/include/mapnik/geometry_correct.hpp @@ -37,12 +37,14 @@ struct geometry_correct { using result_type = void; - result_type operator() (geometry & geom) const + template + result_type operator() (geometry & geom) const { mapnik::util::apply_visitor(*this, geom); } - result_type operator() (geometry_collection & collection) const + template + result_type operator() (geometry_collection & collection) const { for (auto & geom : collection) { @@ -50,12 +52,14 @@ struct geometry_correct } } - result_type operator() (polygon & poly) const + template + result_type operator() (polygon & poly) const { boost::geometry::correct(poly); } - result_type operator() (multi_polygon & multi_poly) const + template + result_type operator() (multi_polygon & multi_poly) const { boost::geometry::correct(multi_poly); } diff --git a/include/mapnik/geometry_envelope_impl.hpp b/include/mapnik/geometry_envelope_impl.hpp index ea0d952db..c4a2e6abe 100644 --- a/include/mapnik/geometry_envelope_impl.hpp +++ b/include/mapnik/geometry_envelope_impl.hpp @@ -44,7 +44,7 @@ struct geometry_envelope void operator() (mapnik::geometry::geometry_empty const&) const {} - void operator() (mapnik::geometry::point const& pt) const + void operator() (mapnik::geometry::point const& pt) const { if (!bbox.valid()) { @@ -53,7 +53,7 @@ struct geometry_envelope bbox.expand_to_include(pt.x, pt.y); } - void operator() (mapnik::geometry::line_string const& line) const + void operator() (mapnik::geometry::line_string const& line) const { bool first = true; for (auto const& pt : line) @@ -70,7 +70,7 @@ struct geometry_envelope } } - void operator() (mapnik::geometry::polygon const& poly) const + void operator() (mapnik::geometry::polygon const& poly) const { bool first = true; for (auto const& pt : poly.exterior_ring) @@ -87,7 +87,7 @@ struct geometry_envelope } } - void operator() (mapnik::geometry::multi_point const& multi_point) const + void operator() (mapnik::geometry::multi_point const& multi_point) const { bool first = true; for (auto const& pt : multi_point) @@ -104,7 +104,7 @@ struct geometry_envelope } } - void operator() (mapnik::geometry::multi_line_string const& multi_line) const + void operator() (mapnik::geometry::multi_line_string const& multi_line) const { for (auto const& line : multi_line) { @@ -112,7 +112,7 @@ struct geometry_envelope } } - void operator() (mapnik::geometry::multi_polygon const& multi_poly) const + void operator() (mapnik::geometry::multi_polygon const& multi_poly) const { for (auto const& poly : multi_poly) { @@ -120,7 +120,7 @@ struct geometry_envelope } } - void operator() (mapnik::geometry::geometry_collection const& collection) const + void operator() (mapnik::geometry::geometry_collection const& collection) const { for (auto const& geom : collection) { diff --git a/include/mapnik/geometry_fusion_adapted.hpp b/include/mapnik/geometry_fusion_adapted.hpp index 8cc68fd0b..4dad27e7d 100644 --- a/include/mapnik/geometry_fusion_adapted.hpp +++ b/include/mapnik/geometry_fusion_adapted.hpp @@ -29,14 +29,14 @@ #include BOOST_FUSION_ADAPT_STRUCT( - mapnik::geometry::point, + mapnik::geometry::point, (double, x) (double, y) ) BOOST_FUSION_ADAPT_STRUCT( - mapnik::geometry::polygon, - (mapnik::geometry::linear_ring const&, exterior_ring) - (std::vector const& , interior_rings)) + mapnik::geometry::polygon, + (mapnik::geometry::linear_ring const&, exterior_ring) + (std::vector > const& , interior_rings)) #endif // MAPNIK_GEOMETRY_FUSION_ADAPTED_HPP diff --git a/include/mapnik/geometry_is_empty.hpp b/include/mapnik/geometry_is_empty.hpp index a999d76db..5d017aa06 100644 --- a/include/mapnik/geometry_is_empty.hpp +++ b/include/mapnik/geometry_is_empty.hpp @@ -31,42 +31,42 @@ namespace detail { struct geometry_is_empty { - bool operator() (mapnik::geometry::geometry const& geom) const + bool operator() (mapnik::geometry::geometry const& geom) const { return mapnik::util::apply_visitor(*this, geom); } - bool operator() (mapnik::geometry::point const&) const + bool operator() (mapnik::geometry::point const&) const { return false; } - bool operator() (mapnik::geometry::line_string const& geom) const + bool operator() (mapnik::geometry::line_string const& geom) const { return geom.empty(); } - bool operator() (mapnik::geometry::polygon const& geom) const + bool operator() (mapnik::geometry::polygon const& geom) const { return geom.empty(); } - bool operator() (mapnik::geometry::multi_point const& geom) const + bool operator() (mapnik::geometry::multi_point const& geom) const { return geom.empty(); } - bool operator() (mapnik::geometry::multi_line_string const& geom) const + bool operator() (mapnik::geometry::multi_line_string const& geom) const { return geom.empty(); } - bool operator() (mapnik::geometry::multi_polygon const& geom) const + bool operator() (mapnik::geometry::multi_polygon const& geom) const { return geom.empty(); } - bool operator() (mapnik::geometry::geometry_collection const& geom) const + bool operator() (mapnik::geometry::geometry_collection const& geom) const { return geom.empty(); } diff --git a/include/mapnik/geometry_is_simple.hpp b/include/mapnik/geometry_is_simple.hpp index 8759a8244..15539f408 100644 --- a/include/mapnik/geometry_is_simple.hpp +++ b/include/mapnik/geometry_is_simple.hpp @@ -35,7 +35,8 @@ struct geometry_is_simple { using result_type = bool; - result_type operator() (geometry const& geom) const + template + result_type operator() (geometry const& geom) const { return mapnik::util::apply_visitor(*this, geom); } @@ -45,7 +46,8 @@ struct geometry_is_simple return false; } - result_type operator() (geometry_collection const& collection) const + template + result_type operator() (geometry_collection const& collection) const { for (auto const& geom : collection) { @@ -54,27 +56,33 @@ struct geometry_is_simple return true; } - result_type operator() (point const& pt) const + template + result_type operator() (point const& pt) const { return boost::geometry::is_simple(pt); } - result_type operator() (line_string const& line) const + template + result_type operator() (line_string const& line) const { return boost::geometry::is_simple(line); } - result_type operator() (polygon const& poly) const + template + result_type operator() (polygon const& poly) const { return boost::geometry::is_simple(poly); } - result_type operator() (multi_point const& multi_pt) const + template + result_type operator() (multi_point const& multi_pt) const { return boost::geometry::is_simple(multi_pt); } - result_type operator() (multi_line_string const& multi_line) const + template + result_type operator() (multi_line_string const& multi_line) const { return boost::geometry::is_simple(multi_line); } - result_type operator() (multi_polygon const& multi_poly) const + template + result_type operator() (multi_polygon const& multi_poly) const { return boost::geometry::is_simple(multi_poly); } diff --git a/include/mapnik/geometry_is_valid.hpp b/include/mapnik/geometry_is_valid.hpp index 77c400c0d..f63139b69 100644 --- a/include/mapnik/geometry_is_valid.hpp +++ b/include/mapnik/geometry_is_valid.hpp @@ -35,7 +35,8 @@ struct geometry_is_valid { using result_type = bool; - result_type operator() (geometry const& geom) const + template + result_type operator() (geometry const& geom) const { return mapnik::util::apply_visitor(*this, geom); } @@ -45,7 +46,8 @@ struct geometry_is_valid return false; } - result_type operator() (geometry_collection const& collection) const + template + result_type operator() (geometry_collection const& collection) const { for (auto const& geom : collection) { @@ -54,32 +56,38 @@ struct geometry_is_valid return true; } - result_type operator() (point const& pt) const + template + result_type operator() (point const& pt) const { return boost::geometry::is_valid(pt); } - result_type operator() (line_string const& line) const + template + result_type operator() (line_string const& line) const { return boost::geometry::is_valid(line); } - result_type operator() (polygon const& poly) const + template + result_type operator() (polygon const& poly) const { return boost::geometry::is_valid(poly); } - result_type operator() (multi_point const& multi_pt) const + template + result_type operator() (multi_point const& multi_pt) const { return boost::geometry::is_valid(multi_pt); } - result_type operator() (multi_line_string const& multi_line) const + template + result_type operator() (multi_line_string const& multi_line) const { return boost::geometry::is_valid(multi_line); } - result_type operator() (multi_polygon const& multi_poly) const + template + result_type operator() (multi_polygon const& multi_poly) const { return boost::geometry::is_valid(multi_poly); } diff --git a/include/mapnik/geometry_reprojection.hpp b/include/mapnik/geometry_reprojection.hpp index 568b2d44a..83a429ae2 100644 --- a/include/mapnik/geometry_reprojection.hpp +++ b/include/mapnik/geometry_reprojection.hpp @@ -37,7 +37,8 @@ namespace geometry { // This is done this way so that large geometry collections that only have a few failing points or polygon parts could // still be return with out the few failing projections. -MAPNIK_DECL geometry reproject_copy(geometry const& geom, proj_transform const& proj_trans, unsigned int & n_err); +template +MAPNIK_DECL geometry reproject_copy(geometry const& geom, proj_transform const& proj_trans, unsigned int & n_err); template MAPNIK_DECL T reproject_copy(T const& geom, proj_transform const& proj_trans, unsigned int & n_err); diff --git a/include/mapnik/geometry_to_path.hpp b/include/mapnik/geometry_to_path.hpp index 72a938d99..308dc1e24 100644 --- a/include/mapnik/geometry_to_path.hpp +++ b/include/mapnik/geometry_to_path.hpp @@ -34,13 +34,15 @@ struct geometry_to_path geometry_to_path(path_type & p) : p_(p) {} - void operator() (geometry const& geom) const + template + void operator() (geometry const& geom) const { return mapnik::util::apply_visitor(*this, geom); } // point - void operator() (point const& pt) const + template + void operator() (point const& pt) const { //point pt_new; //Transformer::apply(pt, pt_new); @@ -48,7 +50,8 @@ struct geometry_to_path } // line_string - void operator() (line_string const& line) const + template + void operator() (line_string const& line) const { bool first = true; for (auto const& pt : line) @@ -61,7 +64,8 @@ struct geometry_to_path } // polygon - void operator() (polygon const& poly) const + template + void operator() (polygon const& poly) const { // exterior bool first = true; @@ -87,7 +91,8 @@ struct geometry_to_path } // multi point - void operator() (multi_point const& multi_pt) const + template + void operator() (multi_point const& multi_pt) const { for (auto const& pt : multi_pt) { @@ -95,7 +100,8 @@ struct geometry_to_path } } // multi_line_string - void operator() (multi_line_string const& multi_line) const + template + void operator() (multi_line_string const& multi_line) const { for (auto const& line : multi_line) { @@ -104,7 +110,8 @@ struct geometry_to_path } // multi_polygon - void operator() (multi_polygon const& multi_poly) const + template + void operator() (multi_polygon const& multi_poly) const { for (auto const& poly : multi_poly) { @@ -112,7 +119,8 @@ struct geometry_to_path } } - void operator() (geometry_collection const& collection) const + template + void operator() (geometry_collection const& collection) const { for (auto const& geom : collection) { @@ -120,7 +128,6 @@ struct geometry_to_path } } - path_type & p_; }; diff --git a/include/mapnik/geometry_transform.hpp b/include/mapnik/geometry_transform.hpp index e286583e2..ae39580b4 100644 --- a/include/mapnik/geometry_transform.hpp +++ b/include/mapnik/geometry_transform.hpp @@ -29,22 +29,22 @@ namespace mapnik { namespace geometry { namespace detail { -template +template struct geometry_transform { geometry_transform(Transformer const& transformer) : transformer_(transformer) {} - using result_type = geometry; + using result_type = geometry; - geometry operator() (geometry_empty const& empty) const + geometry operator() (geometry_empty const& empty) const { return empty; } - geometry operator() (geometry_collection const& collection) const + geometry operator() (geometry_collection const& collection) const { - geometry_collection collection_out; + geometry_collection collection_out; for (auto const& geom : collection) { collection_out.push_back(std::move((*this)(geom))); @@ -52,13 +52,13 @@ struct geometry_transform return collection_out; } - geometry operator() (geometry const& geom) const + geometry operator() (geometry const& geom) const { return mapnik::util::apply_visitor(*this, geom); } template - geometry operator() (T const& geom) const + geometry operator() (T const& geom) const { using geometry_type = T; geometry_type geom_transformed; @@ -72,10 +72,10 @@ struct geometry_transform }; } // ns detail -template -geometry transform(T0 const& geom, T1 const& transformer) +template +geometry transform(T1 const& geom, T2 const& transformer) { - return detail::geometry_transform(transformer)(geom); + return detail::geometry_transform(transformer)(geom); } }} diff --git a/include/mapnik/geometry_type.hpp b/include/mapnik/geometry_type.hpp index f34cc3927..823fa3925 100644 --- a/include/mapnik/geometry_type.hpp +++ b/include/mapnik/geometry_type.hpp @@ -42,37 +42,37 @@ struct geometry_type return mapnik::geometry::geometry_types::Unknown; } - mapnik::geometry::geometry_types operator () (mapnik::geometry::point const&) const + mapnik::geometry::geometry_types operator () (mapnik::geometry::point const&) const { return mapnik::geometry::geometry_types::Point; } - mapnik::geometry::geometry_types operator () (mapnik::geometry::line_string const&) const + mapnik::geometry::geometry_types operator () (mapnik::geometry::line_string const&) const { return mapnik::geometry::geometry_types::LineString; } - mapnik::geometry::geometry_types operator () (mapnik::geometry::polygon const&) const + mapnik::geometry::geometry_types operator () (mapnik::geometry::polygon const&) const { return mapnik::geometry::geometry_types::Polygon; } - mapnik::geometry::geometry_types operator () (mapnik::geometry::multi_point const&) const + mapnik::geometry::geometry_types operator () (mapnik::geometry::multi_point const&) const { return mapnik::geometry::geometry_types::MultiPoint; } - mapnik::geometry::geometry_types operator () (mapnik::geometry::multi_line_string const&) const + mapnik::geometry::geometry_types operator () (mapnik::geometry::multi_line_string const&) const { return mapnik::geometry::geometry_types::MultiLineString; } - mapnik::geometry::geometry_types operator () (mapnik::geometry::multi_polygon const&) const + mapnik::geometry::geometry_types operator () (mapnik::geometry::multi_polygon const&) const { return mapnik::geometry::geometry_types::MultiPolygon; } - mapnik::geometry::geometry_types operator () (mapnik::geometry::geometry_collection const&) const + mapnik::geometry::geometry_types operator () (mapnik::geometry::geometry_collection const&) const { return mapnik::geometry::geometry_types::GeometryCollection; } diff --git a/include/mapnik/hit_test_filter.hpp b/include/mapnik/hit_test_filter.hpp index d2d559b9d..d81a9497b 100644 --- a/include/mapnik/hit_test_filter.hpp +++ b/include/mapnik/hit_test_filter.hpp @@ -54,11 +54,11 @@ struct hit_test_visitor return false; } - bool operator() (geometry::point const& geom) const + bool operator() (geometry::point const& geom) const { return distance(geom.x, geom.y, x_, y_) <= tol_; } - bool operator() (geometry::multi_point const& geom) const + bool operator() (geometry::multi_point const& geom) const { for (auto const& pt : geom) { @@ -66,7 +66,7 @@ struct hit_test_visitor } return false; } - bool operator() (geometry::line_string const& geom) const + bool operator() (geometry::line_string const& geom) const { std::size_t num_points = geom.num_points(); if (num_points > 1) @@ -81,7 +81,7 @@ struct hit_test_visitor } return false; } - bool operator() (geometry::multi_line_string const& geom) const + bool operator() (geometry::multi_line_string const& geom) const { for (auto const& line: geom) { @@ -89,7 +89,7 @@ struct hit_test_visitor } return false; } - bool operator() (geometry::polygon const& geom) const + bool operator() (geometry::polygon const& geom) const { auto const& exterior = geom.exterior_ring; std::size_t num_points = exterior.num_points(); @@ -126,7 +126,7 @@ struct hit_test_visitor } return inside; } - bool operator() (geometry::multi_polygon const& geom) const + bool operator() (geometry::multi_polygon const& geom) const { for (auto const& poly: geom) { @@ -134,7 +134,7 @@ struct hit_test_visitor } return false; } - bool operator() (geometry::geometry_collection const& collection) const + bool operator() (geometry::geometry_collection const& collection) const { for (auto const& geom: collection) { @@ -150,7 +150,7 @@ struct hit_test_visitor } -inline bool hit_test(mapnik::geometry::geometry const& geom, double x, double y, double tol) +inline bool hit_test(mapnik::geometry::geometry const& geom, double x, double y, double tol) { return mapnik::util::apply_visitor(detail::hit_test_visitor(x,y,tol), geom); } diff --git a/include/mapnik/json/extract_bounding_box_grammar.hpp b/include/mapnik/json/extract_bounding_box_grammar.hpp index 7f291e21a..0cc37336a 100644 --- a/include/mapnik/json/extract_bounding_box_grammar.hpp +++ b/include/mapnik/json/extract_bounding_box_grammar.hpp @@ -42,7 +42,7 @@ namespace mapnik { namespace json { -using position = mapnik::geometry::point; +using position = mapnik::geometry::point; using boxes = std::vector, std::pair>>; namespace qi = boost::spirit::qi; diff --git a/include/mapnik/json/feature_generator_grammar.hpp b/include/mapnik/json/feature_generator_grammar.hpp index 79714aaae..3852c7ba6 100644 --- a/include/mapnik/json/feature_generator_grammar.hpp +++ b/include/mapnik/json/feature_generator_grammar.hpp @@ -65,9 +65,9 @@ struct end_container template <> struct transform_attribute, - mapnik::geometry::geometry const& , karma::domain> + mapnik::geometry::geometry const& , karma::domain> { - using type = mapnik::geometry::geometry const&; + using type = mapnik::geometry::geometry const&; static type pre(const boost::fusion::cons& f) { return boost::fusion::at >(f).get_geometry(); @@ -98,7 +98,7 @@ struct feature_generator_grammar : { feature_generator_grammar(); karma::rule feature; - geometry_generator_grammar geometry; + geometry_generator_grammar > geometry; properties_generator_grammar properties; boost::phoenix::function > id_; }; diff --git a/include/mapnik/json/geometry_generator_grammar.hpp b/include/mapnik/json/geometry_generator_grammar.hpp index 15745b694..a26de5b34 100644 --- a/include/mapnik/json/geometry_generator_grammar.hpp +++ b/include/mapnik/json/geometry_generator_grammar.hpp @@ -94,22 +94,22 @@ struct geometry_generator_grammar : geometry_generator_grammar(); karma::rule geometry; karma::rule, Geometry const&() > geometry_dispatch; - karma::rule point; - karma::rule point_coord; - karma::rule linestring; - karma::rule linestring_coord; - karma::rule polygon; - karma::rule polygon_coord; - karma::rule exterior_ring_coord; - karma::rule const&()> interior_ring_coord; - karma::rule multi_point; - karma::rule multi_point_coord; - karma::rule multi_linestring; - karma::rule multi_linestring_coord; - karma::rule multi_polygon; - karma::rule multi_polygon_coord; - karma::rule geometry_collection; - karma::rule geometries; + karma::rule const&()> point; + karma::rule const&()> point_coord; + karma::rule const&()> linestring; + karma::rule const&()> linestring_coord; + karma::rule const&()> polygon; + karma::rule const&()> polygon_coord; + karma::rule const&()> exterior_ring_coord; + karma::rule > const&()> interior_ring_coord; + karma::rule const& ()> multi_point; + karma::rule const& ()> multi_point_coord; + karma::rule const& ()> multi_linestring; + karma::rule const& ()> multi_linestring_coord; + karma::rule const& ()> multi_polygon; + karma::rule const& ()> multi_polygon_coord; + karma::rule const& ()> geometry_collection; + karma::rule const& ()> geometries; boost::phoenix::function > geometry_type; karma::real_generator > coordinate; diff --git a/include/mapnik/json/geometry_grammar.hpp b/include/mapnik/json/geometry_grammar.hpp index 28a9615f5..2414557f6 100644 --- a/include/mapnik/json/geometry_grammar.hpp +++ b/include/mapnik/json/geometry_grammar.hpp @@ -40,13 +40,13 @@ namespace qi = boost::spirit::qi; template > struct geometry_grammar : - qi::grammar + qi::grammar() ,space_type> { geometry_grammar(); - qi::rule start; - qi::rule, mapnik::geometry::geometry(), space_type> geometry; + qi::rule(), space_type> start; + qi::rule, mapnik::geometry::geometry(), space_type> geometry; qi::symbols geometry_type_dispatch; - qi::rule geometry_collection; + qi::rule(), space_type> geometry_collection; positions_grammar coordinates; boost::phoenix::function create_geometry; // error handler diff --git a/include/mapnik/json/geometry_parser.hpp b/include/mapnik/json/geometry_parser.hpp index bf927024f..f4aabe51c 100644 --- a/include/mapnik/json/geometry_parser.hpp +++ b/include/mapnik/json/geometry_parser.hpp @@ -34,7 +34,7 @@ namespace mapnik { namespace json { -inline bool from_geojson(std::string const& json, mapnik::geometry::geometry & geom) +inline bool from_geojson(std::string const& json, mapnik::geometry::geometry & geom) { using namespace boost::spirit; static const geometry_grammar g; diff --git a/include/mapnik/json/geometry_util.hpp b/include/mapnik/json/geometry_util.hpp index 22692aea8..93e2a1172 100644 --- a/include/mapnik/json/geometry_util.hpp +++ b/include/mapnik/json/geometry_util.hpp @@ -39,7 +39,7 @@ struct create_point void operator() (position const& pos) const { - mapnik::geometry::point point(pos.x, pos.y); + mapnik::geometry::point point(pos.x, pos.y); geom_ = std::move(point); } @@ -59,7 +59,7 @@ struct create_linestring std::size_t size = ring.size(); if (size > 1) { - mapnik::geometry::line_string line; + mapnik::geometry::line_string line; line.reserve(size); for (auto && pt : ring) { @@ -83,7 +83,7 @@ struct create_polygon void operator() (std::vector const& rings) const { - mapnik::geometry::polygon poly; + mapnik::geometry::polygon poly; std::size_t num_rings = rings.size(); if (num_rings > 1) poly.interior_rings.reserve(num_rings - 1); @@ -91,7 +91,7 @@ struct create_polygon for ( std::size_t i = 0; i < num_rings; ++i) { std::size_t size = rings[i].size(); - mapnik::geometry::linear_ring ring; + mapnik::geometry::linear_ring ring; ring.reserve(size); for ( auto && pt : rings[i]) { @@ -120,7 +120,7 @@ struct create_multipoint void operator() (positions const& points) const { - mapnik::geometry::multi_point multi_point; + mapnik::geometry::multi_point multi_point; multi_point.reserve(points.size()); for (auto && pos : points) { @@ -143,12 +143,12 @@ struct create_multilinestring void operator() (std::vector const& rings) const { - mapnik::geometry::multi_line_string multi_line; + mapnik::geometry::multi_line_string multi_line; multi_line.reserve(rings.size()); for (auto const& ring : rings) { - mapnik::geometry::line_string line; + mapnik::geometry::line_string line; line.reserve(ring.size()); for (auto && pt : ring) { @@ -173,11 +173,11 @@ struct create_multipolygon void operator()(std::vector > const& rings_array) const { - mapnik::geometry::multi_polygon multi_poly; + mapnik::geometry::multi_polygon multi_poly; multi_poly.reserve(rings_array.size()); for (auto const& rings : rings_array) { - mapnik::geometry::polygon poly; + mapnik::geometry::polygon poly; std::size_t num_rings = rings.size(); if ( num_rings > 1) poly.interior_rings.reserve(num_rings - 1); @@ -185,7 +185,7 @@ struct create_multipolygon for ( std::size_t i = 0; i < num_rings; ++i) { std::size_t size = rings[i].size(); - mapnik::geometry::linear_ring ring; + mapnik::geometry::linear_ring ring; ring.reserve(size); for ( auto && pt : rings[i]) { diff --git a/include/mapnik/json/positions_grammar.hpp b/include/mapnik/json/positions_grammar.hpp index 2cdf03321..2a70306ef 100644 --- a/include/mapnik/json/positions_grammar.hpp +++ b/include/mapnik/json/positions_grammar.hpp @@ -45,7 +45,7 @@ namespace mapnik { namespace json { struct empty {}; -using position = mapnik::geometry::point; +using position = mapnik::geometry::point; using positions = std::vector; using coordinates = util::variant, std::vector > > ; diff --git a/include/mapnik/marker_helpers.hpp b/include/mapnik/marker_helpers.hpp index 71e7cfcd2..03ba7cbfb 100644 --- a/include/mapnik/marker_helpers.hpp +++ b/include/mapnik/marker_helpers.hpp @@ -219,12 +219,12 @@ void apply_markers_multi(feature_impl const& feature, attributes const& vars, Co if (placement == MARKER_POINT_PLACEMENT && multi_policy == MARKER_WHOLE_MULTI) { - geometry::point pt; + geometry::point pt; if (geometry::centroid(geom, pt)) { // unset any clipping since we're now dealing with a point converter.template unset(); - geometry::point_vertex_adapter va(pt); + geometry::point_vertex_adapter va(pt); converter.apply(va); } } @@ -235,13 +235,13 @@ void apply_markers_multi(feature_impl const& feature, attributes const& vars, Co // TODO: consider using true area for polygon types if (type == geometry::geometry_types::MultiPolygon) { - geometry::multi_polygon const& multi_poly = mapnik::util::get(geom); + geometry::multi_polygon const& multi_poly = mapnik::util::get >(geom); double maxarea = 0; - geometry::polygon const* largest = 0; - for (geometry::polygon const& poly : multi_poly) + geometry::polygon const* largest = 0; + for (geometry::polygon const& poly : multi_poly) { box2d bbox = geometry::envelope(poly); - geometry::polygon_vertex_adapter va(poly); + geometry::polygon_vertex_adapter va(poly); double area = bbox.width() * bbox.height(); if (area > maxarea) { @@ -251,7 +251,7 @@ void apply_markers_multi(feature_impl const& feature, attributes const& vars, Co } if (largest) { - geometry::polygon_vertex_adapter va(*largest); + geometry::polygon_vertex_adapter va(*largest); converter.apply(va); } } diff --git a/include/mapnik/memory_featureset.hpp b/include/mapnik/memory_featureset.hpp index 25731acb5..5193c8cc3 100644 --- a/include/mapnik/memory_featureset.hpp +++ b/include/mapnik/memory_featureset.hpp @@ -78,7 +78,7 @@ public: } else { - geometry::geometry const& geom = (*pos_)->get_geometry(); + geometry::geometry const& geom = (*pos_)->get_geometry(); if (bbox_.intersects(geometry::envelope(geom))) { return *pos_++; diff --git a/include/mapnik/proj_transform.hpp b/include/mapnik/proj_transform.hpp index da26d242c..2f83c7120 100644 --- a/include/mapnik/proj_transform.hpp +++ b/include/mapnik/proj_transform.hpp @@ -30,8 +30,8 @@ namespace mapnik { namespace geometry { -struct point; -struct line_string; +template struct point; +template struct line_string; } class projection; template class box2d; @@ -48,10 +48,10 @@ public: bool backward (double& x, double& y , double& z) const; bool forward (double *x, double *y , double *z, int point_count) const; bool backward (double *x, double *y , double *z, int point_count) const; - bool forward (geometry::point & p) const; - bool backward (geometry::point & p) const; - unsigned int forward (geometry::line_string & ls) const; - unsigned int backward (geometry::line_string & ls) const; + bool forward (geometry::point & p) const; + bool backward (geometry::point & p) const; + unsigned int forward (geometry::line_string & ls) const; + unsigned int backward (geometry::line_string & ls) const; bool forward (box2d & box) const; bool backward (box2d & box) const; bool forward (box2d & box, int points) const; diff --git a/include/mapnik/renderer_common/pattern_alignment.hpp b/include/mapnik/renderer_common/pattern_alignment.hpp index 74d65ffa2..53084b824 100644 --- a/include/mapnik/renderer_common/pattern_alignment.hpp +++ b/include/mapnik/renderer_common/pattern_alignment.hpp @@ -39,10 +39,10 @@ struct apply_local_alignment clip_box_(clip_box), x_(x), y_(y) {} - - void operator() (geometry::polygon_vertex_adapter & va) + + void operator() (geometry::polygon_vertex_adapter & va) { - using clipped_geometry_type = agg::conv_clip_polygon; + using clipped_geometry_type = agg::conv_clip_polygon >; using path_type = transform_path_adapter; clipped_geometry_type clipped(va); clipped.clip_box(clip_box_.minx(),clip_box_.miny(),clip_box_.maxx(),clip_box_.maxy()); diff --git a/include/mapnik/renderer_common/process_building_symbolizer.hpp b/include/mapnik/renderer_common/process_building_symbolizer.hpp index 196ec6320..809d36aba 100644 --- a/include/mapnik/renderer_common/process_building_symbolizer.hpp +++ b/include/mapnik/renderer_common/process_building_symbolizer.hpp @@ -36,7 +36,7 @@ namespace mapnik { namespace detail { template -void make_building(geometry::polygon const& poly, double height, F1 const& face_func, F2 const& frame_func, F3 const& roof_func) +void make_building(geometry::polygon const& poly, double height, F1 const& face_func, F2 const& frame_func, F3 const& roof_func) { const std::unique_ptr frame(new path_type(path_type::types::LineString)); const std::unique_ptr roof(new path_type(path_type::types::Polygon)); @@ -44,7 +44,7 @@ void make_building(geometry::polygon const& poly, double height, F1 const& face_ double x0 = 0; double y0 = 0; double x,y; - geometry::polygon_vertex_adapter va(poly); + geometry::polygon_vertex_adapter va(poly); va.rewind(0); for (unsigned cm = va.vertex(&x, &y); cm != SEG_END; cm = va.vertex(&x, &y)) @@ -115,14 +115,14 @@ void render_building_symbolizer(mapnik::feature_impl const& feature, { auto const& geom = feature.get_geometry(); - if (geom.is()) + if (geom.is >()) { - auto const& poly = geom.get(); + auto const& poly = geom.get >(); detail::make_building(poly, height, face_func, frame_func, roof_func); } - else if (geom.is()) + else if (geom.is >()) { - auto const& multi_poly = geom.get(); + auto const& multi_poly = geom.get >(); for (auto const& poly : multi_poly) { detail::make_building(poly, height, face_func, frame_func, roof_func); diff --git a/include/mapnik/renderer_common/process_group_symbolizer.hpp b/include/mapnik/renderer_common/process_group_symbolizer.hpp index 74c448f93..66e2392e3 100644 --- a/include/mapnik/renderer_common/process_group_symbolizer.hpp +++ b/include/mapnik/renderer_common/process_group_symbolizer.hpp @@ -343,7 +343,7 @@ void render_group_symbolizer(group_symbolizer const& sym, // try to ensure that we don't get edge artefacts due to any // symbolizers with avoid-edges set: only the avoid-edges of // the group symbolizer itself should matter. - geometry::point origin_pt(x,y); + geometry::point origin_pt(x,y); sub_feature->set_geometry(origin_pt); // get the layout for this set of properties for (auto const& rule : props->get_rules()) diff --git a/include/mapnik/renderer_common/process_point_symbolizer.hpp b/include/mapnik/renderer_common/process_point_symbolizer.hpp index 8e6901a64..af3a7d671 100644 --- a/include/mapnik/renderer_common/process_point_symbolizer.hpp +++ b/include/mapnik/renderer_common/process_point_symbolizer.hpp @@ -63,8 +63,8 @@ void render_point_symbolizer(point_symbolizer const &sym, agg::trans_affine recenter_tr = recenter * tr; box2d label_ext = bbox * recenter_tr * agg::trans_affine_scaling(common.scale_factor_); - mapnik::geometry::geometry const& geometry = feature.get_geometry(); - mapnik::geometry::point pt; + mapnik::geometry::geometry const& geometry = feature.get_geometry(); + mapnik::geometry::point pt; if (placement == CENTROID_POINT_PLACEMENT) { if (!geometry::centroid(geometry, pt)) return; diff --git a/include/mapnik/text/symbolizer_helpers.hpp b/include/mapnik/text/symbolizer_helpers.hpp index 1acda8a8a..33525c012 100644 --- a/include/mapnik/text/symbolizer_helpers.hpp +++ b/include/mapnik/text/symbolizer_helpers.hpp @@ -62,9 +62,9 @@ class base_symbolizer_helper { public: - using point_cref = std::reference_wrapper; - using line_string_cref = std::reference_wrapper; - using polygon_cref = std::reference_wrapper; + using point_cref = std::reference_wrapper const>; + using line_string_cref = std::reference_wrapper const>; + using polygon_cref = std::reference_wrapper const>; using geometry_cref = util::variant; // Using list instead of vector, because we delete random elements and need iterators to stay valid. using geometry_container_type = std::list; diff --git a/include/mapnik/util/geometry_to_ds_type.hpp b/include/mapnik/util/geometry_to_ds_type.hpp index 955314ff8..4d89cc018 100644 --- a/include/mapnik/util/geometry_to_ds_type.hpp +++ b/include/mapnik/util/geometry_to_ds_type.hpp @@ -42,44 +42,44 @@ struct datasource_geometry_type return mapnik::datasource_geometry_t::Unknown; } - mapnik::datasource_geometry_t operator () (mapnik::geometry::point const&) const + mapnik::datasource_geometry_t operator () (mapnik::geometry::point const&) const { return mapnik::datasource_geometry_t::Point; } - mapnik::datasource_geometry_t operator () (mapnik::geometry::line_string const&) const + mapnik::datasource_geometry_t operator () (mapnik::geometry::line_string const&) const { return mapnik::datasource_geometry_t::LineString; } - mapnik::datasource_geometry_t operator () (mapnik::geometry::polygon const&) const + mapnik::datasource_geometry_t operator () (mapnik::geometry::polygon const&) const { return mapnik::datasource_geometry_t::Polygon; } - mapnik::datasource_geometry_t operator () (mapnik::geometry::multi_point const&) const + mapnik::datasource_geometry_t operator () (mapnik::geometry::multi_point const&) const { return mapnik::datasource_geometry_t::Point; } - mapnik::datasource_geometry_t operator () (mapnik::geometry::multi_line_string const&) const + mapnik::datasource_geometry_t operator () (mapnik::geometry::multi_line_string const&) const { return mapnik::datasource_geometry_t::LineString; } - mapnik::datasource_geometry_t operator () (mapnik::geometry::multi_polygon const&) const + mapnik::datasource_geometry_t operator () (mapnik::geometry::multi_polygon const&) const { return mapnik::datasource_geometry_t::Polygon; } - mapnik::datasource_geometry_t operator () (mapnik::geometry::geometry_collection const&) const + mapnik::datasource_geometry_t operator () (mapnik::geometry::geometry_collection const&) const { return mapnik::datasource_geometry_t::Collection; } }; } // detail -static inline mapnik::datasource_geometry_t to_ds_type(mapnik::geometry::geometry const& geom) +static inline mapnik::datasource_geometry_t to_ds_type(mapnik::geometry::geometry const& geom) { return util::apply_visitor(detail::datasource_geometry_type(), geom); } diff --git a/include/mapnik/util/geometry_to_geojson.hpp b/include/mapnik/util/geometry_to_geojson.hpp index 6d554eda1..beffda79f 100644 --- a/include/mapnik/util/geometry_to_geojson.hpp +++ b/include/mapnik/util/geometry_to_geojson.hpp @@ -29,10 +29,10 @@ namespace mapnik { namespace util { -inline bool to_geojson(std::string & json, mapnik::geometry::geometry const& geom) +inline bool to_geojson(std::string & json, mapnik::geometry::geometry const& geom) { using sink_type = std::back_insert_iterator; - static const mapnik::json::geometry_generator_grammar grammar; + static const mapnik::json::geometry_generator_grammar > grammar; sink_type sink(json); return boost::spirit::karma::generate(sink, grammar, geom); } diff --git a/include/mapnik/util/geometry_to_wkb.hpp b/include/mapnik/util/geometry_to_wkb.hpp index e210d0889..d810abbec 100644 --- a/include/mapnik/util/geometry_to_wkb.hpp +++ b/include/mapnik/util/geometry_to_wkb.hpp @@ -131,7 +131,7 @@ struct wkb_buffer using wkb_buffer_ptr = std::unique_ptr; -wkb_buffer_ptr point_wkb( geometry::point const& pt, wkbByteOrder byte_order) +wkb_buffer_ptr point_wkb( geometry::point const& pt, wkbByteOrder byte_order) { std::size_t size = 1 + 4 + 8 * 2 ; // byteOrder + wkbType + Point wkb_buffer_ptr wkb = std::make_unique(size); @@ -144,7 +144,7 @@ wkb_buffer_ptr point_wkb( geometry::point const& pt, wkbByteOrder byte_order) return std::move(wkb); } -wkb_buffer_ptr line_string_wkb(geometry::line_string const& line, wkbByteOrder byte_order) +wkb_buffer_ptr line_string_wkb(geometry::line_string const& line, wkbByteOrder byte_order) { unsigned num_points = line.size(); assert(num_points > 1); @@ -156,7 +156,7 @@ wkb_buffer_ptr line_string_wkb(geometry::line_string const& line, wkbByteOrder b write(ss, num_points, 4, byte_order); for (unsigned i=0; i< num_points; ++i) { - geometry::point const& pt = line[i]; + geometry::point const& pt = line[i]; write(ss, pt.x, 8, byte_order); write(ss, pt.y, 8, byte_order); } @@ -164,7 +164,7 @@ wkb_buffer_ptr line_string_wkb(geometry::line_string const& line, wkbByteOrder b return std::move(wkb); } -wkb_buffer_ptr polygon_wkb( geometry::polygon const& poly, wkbByteOrder byte_order) +wkb_buffer_ptr polygon_wkb( geometry::polygon const& poly, wkbByteOrder byte_order) { std::size_t size = 1 + 4 + 4 ; // byteOrder + wkbType + numRings size += 4 + 2 * 8 * poly.exterior_ring.size(); @@ -202,7 +202,7 @@ wkb_buffer_ptr polygon_wkb( geometry::polygon const& poly, wkbByteOrder byte_ord return std::move(wkb); } -wkb_buffer_ptr multi_point_wkb( geometry::multi_point const& multi_pt, wkbByteOrder byte_order) +wkb_buffer_ptr multi_point_wkb( geometry::multi_point const& multi_pt, wkbByteOrder byte_order) { std::size_t size = 1 + 4 + 4 + (1 + 4 + 8 * 2) * multi_pt.size() ; // byteOrder + wkbType + num_point + Point.size * num_points wkb_buffer_ptr wkb = std::make_unique(size); @@ -233,7 +233,7 @@ struct geometry_to_wkb geometry_to_wkb(wkbByteOrder byte_order) : byte_order_(byte_order) {} - result_type operator() (geometry::geometry const& geom) const + result_type operator() (geometry::geometry const& geom) const { return util::apply_visitor(*this, geom); } @@ -243,24 +243,24 @@ struct geometry_to_wkb return result_type(); } - result_type operator() (geometry::point const& pt) const + result_type operator() (geometry::point const& pt) const { return point_wkb(pt, byte_order_); } - result_type operator() (geometry::line_string const& line) const + result_type operator() (geometry::line_string const& line) const { return line_string_wkb(line, byte_order_); } - result_type operator() (geometry::polygon const& poly) const + result_type operator() (geometry::polygon const& poly) const { return polygon_wkb(poly, byte_order_); } // multi/collection - result_type operator() (geometry::multi_point const& multi_pt) const + result_type operator() (geometry::multi_point const& multi_pt) const { return multi_point_wkb(multi_pt, byte_order_); } diff --git a/include/mapnik/util/geometry_to_wkt.hpp b/include/mapnik/util/geometry_to_wkt.hpp index 3cbbc5097..cca17e1dc 100644 --- a/include/mapnik/util/geometry_to_wkt.hpp +++ b/include/mapnik/util/geometry_to_wkt.hpp @@ -32,10 +32,10 @@ namespace mapnik { namespace util { -inline bool to_wkt(std::string & wkt, mapnik::geometry::geometry const& geom) +inline bool to_wkt(std::string & wkt, mapnik::geometry::geometry const& geom) { using sink_type = std::back_insert_iterator; - static const mapnik::wkt::wkt_generator_grammar generator; + static const mapnik::wkt::wkt_generator_grammar > generator; sink_type sink(wkt); return boost::spirit::karma::generate(sink, generator, geom); } diff --git a/include/mapnik/util/spirit_transform_attribute.hpp b/include/mapnik/util/spirit_transform_attribute.hpp index eb0ea94b3..c613774c1 100644 --- a/include/mapnik/util/spirit_transform_attribute.hpp +++ b/include/mapnik/util/spirit_transform_attribute.hpp @@ -28,90 +28,90 @@ namespace boost { namespace spirit { namespace traits { template <> - struct transform_attribute + struct transform_attribute const, + mapnik::geometry::point const&, karma::domain> { - using type = mapnik::geometry::point const&; - static type pre(mapnik::geometry::geometry const& geom) + using type = mapnik::geometry::point const&; + static type pre(mapnik::geometry::geometry const& geom) { - return mapnik::util::get(geom); + return mapnik::util::get >(geom); } }; template <> - struct transform_attribute + struct transform_attribute const, + mapnik::geometry::line_string const&, karma::domain> { - using type = mapnik::geometry::line_string const&; - static type pre(mapnik::geometry::geometry const& geom) + using type = mapnik::geometry::line_string const&; + static type pre(mapnik::geometry::geometry const& geom) { - return mapnik::util::get(geom); + return mapnik::util::get >(geom); } }; template <> - struct transform_attribute + struct transform_attribute const, + mapnik::geometry::polygon const&, karma::domain> { - using type = mapnik::geometry::polygon const&; - static type pre(mapnik::geometry::geometry const& geom) + using type = mapnik::geometry::polygon const&; + static type pre(mapnik::geometry::geometry const& geom) { - return mapnik::util::get(geom); + return mapnik::util::get >(geom); } }; template <> - struct transform_attribute const&, karma::domain> + struct transform_attribute const, + std::vector > const&, karma::domain> { - using type = std::vector const&; - static type pre(mapnik::geometry::polygon const& poly) + using type = std::vector > const&; + static type pre(mapnik::geometry::polygon const& poly) { return poly.interior_rings; } }; template <> - struct transform_attribute + struct transform_attribute const, + mapnik::geometry::multi_point const&, karma::domain> { - using type = mapnik::geometry::multi_point const&; - static type pre(mapnik::geometry::geometry const& geom) + using type = mapnik::geometry::multi_point const&; + static type pre(mapnik::geometry::geometry const& geom) { - return mapnik::util::get(geom); + return mapnik::util::get >(geom); } }; template <> - struct transform_attribute + struct transform_attribute const, + mapnik::geometry::multi_line_string const&, karma::domain> { - using type = mapnik::geometry::multi_line_string const&; - static type pre(mapnik::geometry::geometry const& geom) + using type = mapnik::geometry::multi_line_string const&; + static type pre(mapnik::geometry::geometry const& geom) { - return mapnik::util::get(geom); + return mapnik::util::get >(geom); } }; template <> - struct transform_attribute + struct transform_attribute const, + mapnik::geometry::multi_polygon const&, karma::domain> { - using type = mapnik::geometry::multi_polygon const&; - static type pre(mapnik::geometry::geometry const& geom) + using type = mapnik::geometry::multi_polygon const&; + static type pre(mapnik::geometry::geometry const& geom) { - return mapnik::util::get(geom); + return mapnik::util::get >(geom); } }; template <> - struct transform_attribute + struct transform_attribute const, + mapnik::geometry::geometry_collection const&, karma::domain> { - using type = mapnik::geometry::geometry_collection const&; - static type pre(mapnik::geometry::geometry const& geom) + using type = mapnik::geometry::geometry_collection const&; + static type pre(mapnik::geometry::geometry const& geom) { - return mapnik::util::get(geom); + return mapnik::util::get >(geom); } }; diff --git a/include/mapnik/vertex_adapters.hpp b/include/mapnik/vertex_adapters.hpp index 20230b178..f09c737fb 100644 --- a/include/mapnik/vertex_adapters.hpp +++ b/include/mapnik/vertex_adapters.hpp @@ -29,11 +29,12 @@ namespace mapnik { namespace geometry { +template struct point_vertex_adapter { - using value_type = typename point::value_type; + using value_type = typename point::value_type; - point_vertex_adapter(point const& pt) + point_vertex_adapter(point const& pt) : pt_(pt), first_(true) {} @@ -59,14 +60,15 @@ struct point_vertex_adapter return geometry_types::Point; } - point const& pt_; + point const& pt_; mutable bool first_; }; +template struct line_string_vertex_adapter { - using value_type = typename point::value_type; - line_string_vertex_adapter(line_string const& line) + using value_type = typename point::value_type; + line_string_vertex_adapter(line_string const& line) : line_(line), current_index_(0), end_index_(line.size()) @@ -76,7 +78,7 @@ struct line_string_vertex_adapter { if (current_index_ != end_index_) { - point const& coord = line_[current_index_++]; + point const& coord = line_[current_index_++]; *x = coord.x; *y = coord.y; if (current_index_ == 1) @@ -101,16 +103,17 @@ struct line_string_vertex_adapter return geometry_types::LineString; } - line_string const& line_; + line_string const& line_; mutable std::size_t current_index_; const std::size_t end_index_; }; +template struct polygon_vertex_adapter { - using value_type = typename point::value_type; - polygon_vertex_adapter(polygon const& poly) + using value_type = typename point::value_type; + polygon_vertex_adapter(polygon const& poly) : poly_(poly), rings_itr_(0), rings_end_(poly_.interior_rings.size() + 1), @@ -135,7 +138,7 @@ struct polygon_vertex_adapter } if (current_index_ < end_index_) { - point const& coord = (rings_itr_ == 0) ? + point const& coord = (rings_itr_ == 0) ? poly_.exterior_ring[current_index_++] : poly_.interior_rings[rings_itr_- 1][current_index_++]; *x = coord.x; *y = coord.y; @@ -156,7 +159,7 @@ struct polygon_vertex_adapter { current_index_ = 0; end_index_ = poly_.interior_rings[rings_itr_ - 1].size(); - point const& coord = poly_.interior_rings[rings_itr_ - 1][current_index_++]; + point const& coord = poly_.interior_rings[rings_itr_ - 1][current_index_++]; *x = coord.x; *y = coord.y; return mapnik::SEG_MOVETO; @@ -170,7 +173,7 @@ struct polygon_vertex_adapter } private: - polygon const& poly_; + polygon const& poly_; mutable std::size_t rings_itr_; mutable std::size_t rings_end_; mutable std::size_t current_index_; @@ -179,42 +182,42 @@ private: }; template -struct vertex_adapter_traits{}; +struct vertex_adapter_traits {}; template <> -struct vertex_adapter_traits +struct vertex_adapter_traits > { - using type = point_vertex_adapter; + using type = point_vertex_adapter; }; template <> -struct vertex_adapter_traits +struct vertex_adapter_traits > { - using type = line_string_vertex_adapter; + using type = line_string_vertex_adapter; }; template <> -struct vertex_adapter_traits +struct vertex_adapter_traits > { - using type = polygon_vertex_adapter; + using type = polygon_vertex_adapter; }; template <> -struct vertex_adapter_traits +struct vertex_adapter_traits > { - using type = point_vertex_adapter; + using type = point_vertex_adapter; }; template <> -struct vertex_adapter_traits +struct vertex_adapter_traits > { - using type = line_string_vertex_adapter; + using type = line_string_vertex_adapter; }; template <> -struct vertex_adapter_traits +struct vertex_adapter_traits > { - using type = polygon_vertex_adapter; + using type = polygon_vertex_adapter; }; }} diff --git a/include/mapnik/vertex_processor.hpp b/include/mapnik/vertex_processor.hpp index b098bff02..a3b63c133 100644 --- a/include/mapnik/vertex_processor.hpp +++ b/include/mapnik/vertex_processor.hpp @@ -43,52 +43,60 @@ struct vertex_processor { // no-op } - void operator() (point const& pt) + + template + void operator() (point const& pt) { - point_vertex_adapter va(pt); + point_vertex_adapter va(pt); proc_(va); } - void operator() (line_string const& line) + template + void operator() (line_string const& line) { - line_string_vertex_adapter va(line); + line_string_vertex_adapter va(line); proc_(va); } - void operator() (polygon const& poly) + template + void operator() (polygon const& poly) { - polygon_vertex_adapter va(poly); + polygon_vertex_adapter va(poly); proc_(va); } - void operator() (multi_point const& multi_pt) + template + void operator() (multi_point const& multi_pt) { for (auto const& pt : multi_pt) { - point_vertex_adapter va(pt); + point_vertex_adapter va(pt); proc_(va); } } - void operator() (multi_line_string const& multi_line) + template + void operator() (multi_line_string const& multi_line) { for (auto const& line : multi_line) { - line_string_vertex_adapter va(line); + line_string_vertex_adapter va(line); proc_(va); } } - void operator() (multi_polygon const& multi_poly) + template + void operator() (multi_polygon const& multi_poly) { for ( auto const& poly : multi_poly) { - polygon_vertex_adapter va(poly); + polygon_vertex_adapter va(poly); proc_(va); } } - void operator() (geometry_collection const& collection) + template + void operator() (geometry_collection const& collection) { for (auto const& geom : collection) { diff --git a/include/mapnik/well_known_srs.hpp b/include/mapnik/well_known_srs.hpp index 89549e581..41d4cac57 100644 --- a/include/mapnik/well_known_srs.hpp +++ b/include/mapnik/well_known_srs.hpp @@ -90,7 +90,7 @@ static inline bool merc2lonlat(double * x, double * y , int point_count) return true; } -static inline bool lonlat2merc(geometry::line_string & ls) +static inline bool lonlat2merc(geometry::line_string & ls) { for(auto & p : ls) { @@ -105,7 +105,7 @@ static inline bool lonlat2merc(geometry::line_string & ls) return true; } -static inline bool merc2lonlat(geometry::line_string & ls) +static inline bool merc2lonlat(geometry::line_string & ls) { for (auto & p : ls) { diff --git a/include/mapnik/wkb.hpp b/include/mapnik/wkb.hpp index 953386957..b14bdf57c 100644 --- a/include/mapnik/wkb.hpp +++ b/include/mapnik/wkb.hpp @@ -59,7 +59,7 @@ class MAPNIK_DECL geometry_utils : private util::noncopyable { public: - static mapnik::geometry::geometry from_wkb(const char* wkb, + static mapnik::geometry::geometry from_wkb(const char* wkb, unsigned size, wkbFormat format = wkbGeneric); }; diff --git a/include/mapnik/wkt/wkt_factory.hpp b/include/mapnik/wkt/wkt_factory.hpp index 5e97df963..3e2ece1e7 100644 --- a/include/mapnik/wkt/wkt_factory.hpp +++ b/include/mapnik/wkt/wkt_factory.hpp @@ -34,7 +34,7 @@ namespace mapnik { -inline bool from_wkt(std::string const& wkt, mapnik::geometry::geometry & geom) +inline bool from_wkt(std::string const& wkt, mapnik::geometry::geometry & geom) { using namespace boost::spirit; static const mapnik::wkt::wkt_grammar g; diff --git a/include/mapnik/wkt/wkt_generator_grammar.hpp b/include/mapnik/wkt/wkt_generator_grammar.hpp index 3b685f417..1138a3ad4 100644 --- a/include/mapnik/wkt/wkt_generator_grammar.hpp +++ b/include/mapnik/wkt/wkt_generator_grammar.hpp @@ -95,22 +95,22 @@ struct wkt_generator_grammar : // rules karma::rule geometry; karma::rule, Geometry const&() > geometry_dispatch; - karma::rule point; - karma::rule point_coord; - karma::rule linestring; - karma::rule linestring_coord; - karma::rule polygon; - karma::rule polygon_coord; - karma::rule exterior_ring_coord; - karma::rule const&()> interior_ring_coord; - karma::rule multi_point; - karma::rule multi_point_coord; - karma::rule multi_linestring; - karma::rule multi_linestring_coord; - karma::rule multi_polygon; - karma::rule multi_polygon_coord; - karma::rule geometry_collection; - karma::rule geometries; + karma::rule const&()> point; + karma::rule const&()> point_coord; + karma::rule const&()> linestring; + karma::rule const&()> linestring_coord; + karma::rule const&()> polygon; + karma::rule const&()> polygon_coord; + karma::rule const&()> exterior_ring_coord; + karma::rule > const&()> interior_ring_coord; + karma::rule const& ()> multi_point; + karma::rule const& ()> multi_point_coord; + karma::rule const& ()> multi_linestring; + karma::rule const& ()> multi_linestring_coord; + karma::rule const& ()> multi_polygon; + karma::rule const& ()> multi_polygon_coord; + karma::rule const& ()> geometry_collection; + karma::rule const& ()> geometries; boost::phoenix::function > geometry_type; karma::symbols empty; // diff --git a/include/mapnik/wkt/wkt_generator_grammar_impl.hpp b/include/mapnik/wkt/wkt_generator_grammar_impl.hpp index cbd98b7fc..7205db6d8 100644 --- a/include/mapnik/wkt/wkt_generator_grammar_impl.hpp +++ b/include/mapnik/wkt/wkt_generator_grammar_impl.hpp @@ -75,7 +75,7 @@ wkt_generator_grammar::wkt_generator_grammar() << (geometry_collection | empty[_1 = _a])) | (&uint_(geometry::geometry_types::Unknown)[_1 = _a] - << lit("POINT EMPTY")) // special case for geometry_empty as mapnik::geometry::point can't be empty + << lit("POINT EMPTY")) // special case for geometry_empty as mapnik::geometry::point can't be empty ; point = lit("POINT(") << point_coord << lit(")") diff --git a/include/mapnik/wkt/wkt_grammar.hpp b/include/mapnik/wkt/wkt_grammar.hpp index b731ca8a7..80fa06648 100644 --- a/include/mapnik/wkt/wkt_grammar.hpp +++ b/include/mapnik/wkt/wkt_grammar.hpp @@ -85,29 +85,29 @@ struct add_hole } template -struct wkt_grammar : qi::grammar +struct wkt_grammar : qi::grammar &) , ascii::space_type> { wkt_grammar(); - qi::rule geometry_tagged_text; - qi::rule point_tagged_text; - qi::rule linestring_tagged_text; - qi::rule polygon_tagged_text; - qi::rule multipoint_tagged_text; - qi::rule multilinestring_tagged_text; - qi::rule multipolygon_tagged_text; - qi::rule geometrycollection_tagged_text; - qi::rule point_text; - qi::rule linestring_text; - qi::rule linearring_text; - qi::rule polygon_text; - qi::rule multipoint_text; - qi::rule multilinestring_text; - qi::rule multipolygon_text; - qi::rule, - mapnik::geometry::geometry_collection(), ascii::space_type> geometrycollection_text; - qi::rule point; - qi::rule points; - qi::rule ring_points; + qi::rule &), ascii::space_type> geometry_tagged_text; + qi::rule &), ascii::space_type> point_tagged_text; + qi::rule &), ascii::space_type> linestring_tagged_text; + qi::rule &), ascii::space_type> polygon_tagged_text; + qi::rule &), ascii::space_type> multipoint_tagged_text; + qi::rule &), ascii::space_type> multilinestring_tagged_text; + qi::rule &), ascii::space_type> multipolygon_tagged_text; + qi::rule &), ascii::space_type> geometrycollection_tagged_text; + qi::rule(), ascii::space_type> point_text; + qi::rule(), ascii::space_type> linestring_text; + qi::rule(), ascii::space_type> linearring_text; + qi::rule(), ascii::space_type> polygon_text; + qi::rule(), ascii::space_type> multipoint_text; + qi::rule(), ascii::space_type> multilinestring_text; + qi::rule(), ascii::space_type> multipolygon_text; + qi::rule >, + mapnik::geometry::geometry_collection(), ascii::space_type> geometrycollection_text; + qi::rule(), ascii::space_type> point; + qi::rule(), ascii::space_type> points; + qi::rule(), ascii::space_type> ring_points; qi::rule empty_set; boost::phoenix::function assign; boost::phoenix::function move_part; diff --git a/include/mapnik/wkt/wkt_grammar_impl.hpp b/include/mapnik/wkt/wkt_grammar_impl.hpp index 62e377317..85a927451 100644 --- a/include/mapnik/wkt/wkt_grammar_impl.hpp +++ b/include/mapnik/wkt/wkt_grammar_impl.hpp @@ -63,7 +63,7 @@ wkt_grammar::wkt_grammar() // ::= | point_text = (lit("(") >> point >> lit(')')) //| empty_set - we're catching 'POINT EMPTY' case in point_tagged_text rule ^^ by creating geometry_empty - // because our geometry::point can't be empty + // because our geometry::point can't be empty ; // ::= linestring @@ -133,7 +133,7 @@ wkt_grammar::wkt_grammar() // geometry collection text geometrycollection_text = (lit('(') - >> ( eps[_a = construct()] + >> ( eps[_a = construct >()] >> geometry_tagged_text(_a)[move_part(_val,_a)] % lit(',')) >> lit(')')) | diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index e692eb427..934e57982 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -541,7 +541,7 @@ void csv_datasource::parse_csv(T & stream, { break; } - mapnik::geometry::geometry geom; + mapnik::geometry::geometry geom; if (mapnik::from_wkt(value, geom)) { // correct orientations etc @@ -581,7 +581,7 @@ void csv_datasource::parse_csv(T & stream, { break; } - mapnik::geometry::geometry geom; + mapnik::geometry::geometry geom; if (mapnik::json::from_geojson(value, geom)) { feature->set_geometry(std::move(geom)); @@ -816,7 +816,7 @@ void csv_datasource::parse_csv(T & stream, { if (parsed_x && parsed_y) { - mapnik::geometry::point pt(x,y); + mapnik::geometry::point pt(x,y); feature->set_geometry(std::move(pt)); features_.push_back(feature); null_geom = false; diff --git a/plugins/input/gdal/gdal_featureset.cpp b/plugins/input/gdal/gdal_featureset.cpp index 9aa20c79c..916f57cfc 100644 --- a/plugins/input/gdal/gdal_featureset.cpp +++ b/plugins/input/gdal/gdal_featureset.cpp @@ -613,7 +613,7 @@ feature_ptr gdal_featureset::get_feature_at_point(mapnik::coord2d const& pt) { // construct feature feature_ptr feature = feature_factory::create(ctx_,1); - feature->set_geometry(mapnik::geometry::point(pt.x,pt.y)); + feature->set_geometry(mapnik::geometry::point(pt.x,pt.y)); feature->put_new("value",value); if (raster_has_nodata) { diff --git a/plugins/input/ogr/ogr_converter.cpp b/plugins/input/ogr/ogr_converter.cpp index 3da62ff11..8f22aaffe 100644 --- a/plugins/input/ogr/ogr_converter.cpp +++ b/plugins/input/ogr/ogr_converter.cpp @@ -29,7 +29,7 @@ #include #include -mapnik::geometry::geometry ogr_converter::convert_geometry(OGRGeometry* ogr_geom) +mapnik::geometry::geometry ogr_converter::convert_geometry(OGRGeometry* ogr_geom) { // NOTE: wkbFlatten macro in ogr flattens 2.5d types into base 2d type switch (wkbFlatten(ogr_geom->getGeometryType())) @@ -65,19 +65,19 @@ mapnik::geometry::geometry ogr_converter::convert_geometry(OGRGeometry* ogr_geom MAPNIK_LOG_WARN(ogr) << "ogr_converter: unknown geometry_type=" << wkbFlatten(ogr_geom->getGeometryType()); } - return mapnik::geometry::geometry(); + return mapnik::geometry::geometry(); break; } } -mapnik::geometry::point ogr_converter::convert_point(OGRPoint* ogr_geom) +mapnik::geometry::point ogr_converter::convert_point(OGRPoint* ogr_geom) { - return mapnik::geometry::point(ogr_geom->getX(), ogr_geom->getY()); + return mapnik::geometry::point(ogr_geom->getX(), ogr_geom->getY()); } -mapnik::geometry::multi_point ogr_converter::convert_multipoint(OGRMultiPoint* ogr_geom) +mapnik::geometry::multi_point ogr_converter::convert_multipoint(OGRMultiPoint* ogr_geom) { - mapnik::geometry::multi_point geom; + mapnik::geometry::multi_point geom; int num_geometries = ogr_geom->getNumGeometries(); geom.reserve(num_geometries); for (int i = 0; i < num_geometries; ++i) @@ -88,9 +88,9 @@ mapnik::geometry::multi_point ogr_converter::convert_multipoint(OGRMultiPoint* o return geom; } -mapnik::geometry::line_string ogr_converter::convert_linestring(OGRLineString* ogr_geom) +mapnik::geometry::line_string ogr_converter::convert_linestring(OGRLineString* ogr_geom) { - mapnik::geometry::line_string geom; + mapnik::geometry::line_string geom; int num_points = ogr_geom->getNumPoints(); geom.reserve(num_points); for (int i = 0; i < num_points; ++i) @@ -100,9 +100,9 @@ mapnik::geometry::line_string ogr_converter::convert_linestring(OGRLineString* o return geom; } -mapnik::geometry::multi_line_string ogr_converter::convert_multilinestring(OGRMultiLineString* ogr_geom) +mapnik::geometry::multi_line_string ogr_converter::convert_multilinestring(OGRMultiLineString* ogr_geom) { - mapnik::geometry::multi_line_string geom; + mapnik::geometry::multi_line_string geom; int num_geometries = ogr_geom->getNumGeometries(); geom.reserve(num_geometries); for (int i = 0; i < num_geometries; ++i) @@ -114,10 +114,10 @@ mapnik::geometry::multi_line_string ogr_converter::convert_multilinestring(OGRMu } -mapnik::geometry::polygon ogr_converter::convert_polygon(OGRPolygon* ogr_geom) +mapnik::geometry::polygon ogr_converter::convert_polygon(OGRPolygon* ogr_geom) { - mapnik::geometry::polygon geom; - mapnik::geometry::linear_ring exterior; + mapnik::geometry::polygon geom; + mapnik::geometry::linear_ring exterior; OGRLinearRing* ogr_exterior = ogr_geom->getExteriorRing(); int num_points = ogr_exterior->getNumPoints(); exterior.reserve(num_points); @@ -131,7 +131,7 @@ mapnik::geometry::polygon ogr_converter::convert_polygon(OGRPolygon* ogr_geom) for (int r = 0; r < num_interior; ++r) { OGRLinearRing* ogr_interior = ogr_geom->getInteriorRing(r); - mapnik::geometry::linear_ring interior; + mapnik::geometry::linear_ring interior; int num_interior_points = ogr_interior->getNumPoints(); interior.reserve(num_interior_points); for (int i = 0; i < num_interior_points; ++i) @@ -143,9 +143,9 @@ mapnik::geometry::polygon ogr_converter::convert_polygon(OGRPolygon* ogr_geom) return geom; } -mapnik::geometry::multi_polygon ogr_converter::convert_multipolygon(OGRMultiPolygon* ogr_geom) +mapnik::geometry::multi_polygon ogr_converter::convert_multipolygon(OGRMultiPolygon* ogr_geom) { - mapnik::geometry::multi_polygon geom; + mapnik::geometry::multi_polygon geom; int num_geometries = ogr_geom->getNumGeometries(); geom.reserve(num_geometries); for (int i = 0; i < num_geometries; ++i) @@ -156,9 +156,9 @@ mapnik::geometry::multi_polygon ogr_converter::convert_multipolygon(OGRMultiPoly return geom; } -mapnik::geometry::geometry_collection ogr_converter::convert_collection(OGRGeometryCollection* ogr_geom) +mapnik::geometry::geometry_collection ogr_converter::convert_collection(OGRGeometryCollection* ogr_geom) { - mapnik::geometry::geometry_collection geom; + mapnik::geometry::geometry_collection geom; int num_geometries = ogr_geom->getNumGeometries(); geom.reserve(num_geometries); for (int i = 0; i < num_geometries; ++i) diff --git a/plugins/input/ogr/ogr_converter.hpp b/plugins/input/ogr/ogr_converter.hpp index c55f78aa0..e3e2bb335 100644 --- a/plugins/input/ogr/ogr_converter.hpp +++ b/plugins/input/ogr/ogr_converter.hpp @@ -39,14 +39,14 @@ class ogr_converter { public: - static mapnik::geometry::geometry convert_geometry (OGRGeometry* ogr_geom); - static mapnik::geometry::point convert_point (OGRPoint* ogr_geom); - static mapnik::geometry::multi_point convert_multipoint (OGRMultiPoint* ogr_geom); - static mapnik::geometry::line_string convert_linestring (OGRLineString* ogr_geom); - static mapnik::geometry::multi_line_string convert_multilinestring (OGRMultiLineString* ogr_geom); - static mapnik::geometry::polygon convert_polygon (OGRPolygon* ogr_geom); - static mapnik::geometry::multi_polygon convert_multipolygon (OGRMultiPolygon* ogr_geom); - static mapnik::geometry::geometry_collection convert_collection (OGRGeometryCollection* ogr_geom); + static mapnik::geometry::geometry convert_geometry (OGRGeometry* ogr_geom); + static mapnik::geometry::point convert_point (OGRPoint* ogr_geom); + static mapnik::geometry::multi_point convert_multipoint (OGRMultiPoint* ogr_geom); + static mapnik::geometry::line_string convert_linestring (OGRLineString* ogr_geom); + static mapnik::geometry::multi_line_string convert_multilinestring (OGRMultiLineString* ogr_geom); + static mapnik::geometry::polygon convert_polygon (OGRPolygon* ogr_geom); + static mapnik::geometry::multi_polygon convert_multipolygon (OGRMultiPolygon* ogr_geom); + static mapnik::geometry::geometry_collection convert_collection (OGRGeometryCollection* ogr_geom); }; #endif // OGR_CONVERTER_HPP diff --git a/plugins/input/osm/osm_featureset.cpp b/plugins/input/osm/osm_featureset.cpp index 1123e35cd..7d77094fc 100644 --- a/plugins/input/osm/osm_featureset.cpp +++ b/plugins/input/osm/osm_featureset.cpp @@ -81,7 +81,7 @@ feature_ptr osm_featureset::next() feature = feature_factory::create(ctx_, cur_item->id); if (static_cast(cur_item)->is_polygon()) { - mapnik::geometry::linear_ring ring; + mapnik::geometry::linear_ring ring; for (unsigned int count = 0; count < static_cast(cur_item)->nodes.size(); count++) @@ -89,13 +89,13 @@ feature_ptr osm_featureset::next() ring.add_coord(static_cast(cur_item)->nodes[count]->lon, static_cast(cur_item)->nodes[count]->lat); } - mapnik::geometry::polygon geom; + mapnik::geometry::polygon geom; geom.set_exterior_ring(std::move(ring)); feature->set_geometry(std::move(geom)); } else { - mapnik::geometry::line_string geom; + mapnik::geometry::line_string geom; for (unsigned int count = 0; count < static_cast(cur_item)->nodes.size(); count++) diff --git a/plugins/input/postgis/postgis_featureset.cpp b/plugins/input/postgis/postgis_featureset.cpp index 1be31f07a..56c3749c9 100644 --- a/plugins/input/postgis/postgis_featureset.cpp +++ b/plugins/input/postgis/postgis_featureset.cpp @@ -122,7 +122,7 @@ feature_ptr postgis_featureset::next() int size = rs_->getFieldLength(0); const char *data = rs_->getValue(0); - mapnik::geometry::geometry geometry = geometry_utils::from_wkb(data, size); + mapnik::geometry::geometry geometry = geometry_utils::from_wkb(data, size); feature->set_geometry(std::move(geometry)); totalGeomSize_ += size; diff --git a/plugins/input/shape/shape_featureset.cpp b/plugins/input/shape/shape_featureset.cpp index 488573260..6367cbfec 100644 --- a/plugins/input/shape/shape_featureset.cpp +++ b/plugins/input/shape/shape_featureset.cpp @@ -87,7 +87,7 @@ feature_ptr shape_featureset::next() double y = record.read_double(); if (!filter_.pass(mapnik::box2d(x,y,x,y))) continue; - feature->set_geometry(mapnik::geometry::point(x,y)); + feature->set_geometry(mapnik::geometry::point(x,y)); break; } case shape_io::shape_multipoint: @@ -97,12 +97,12 @@ feature_ptr shape_featureset::next() shape_io::read_bbox(record, feature_bbox_); if (!filter_.pass(feature_bbox_)) continue; int num_points = record.read_ndr_integer(); - mapnik::geometry::multi_point multi_point; + mapnik::geometry::multi_point multi_point; for (int i = 0; i < num_points; ++i) { double x = record.read_double(); double y = record.read_double(); - multi_point.emplace_back(mapnik::geometry::point(x, y)); + multi_point.emplace_back(mapnik::geometry::point(x, y)); } feature->set_geometry(std::move(multi_point)); break; diff --git a/plugins/input/shape/shape_index_featureset.cpp b/plugins/input/shape/shape_index_featureset.cpp index 1cd0b9e6f..89628fa99 100644 --- a/plugins/input/shape/shape_index_featureset.cpp +++ b/plugins/input/shape/shape_index_featureset.cpp @@ -103,7 +103,7 @@ feature_ptr shape_index_featureset::next() { double x = record.read_double(); double y = record.read_double(); - feature->set_geometry(mapnik::geometry::point(x,y)); + feature->set_geometry(mapnik::geometry::point(x,y)); break; } case shape_io::shape_multipoint: @@ -113,12 +113,12 @@ feature_ptr shape_index_featureset::next() shape_io::read_bbox(record, feature_bbox_); if (!filter_.pass(feature_bbox_)) continue; int num_points = record.read_ndr_integer(); - mapnik::geometry::multi_point multi_point; + mapnik::geometry::multi_point multi_point; for (int i = 0; i < num_points; ++i) { double x = record.read_double(); double y = record.read_double(); - multi_point.emplace_back(mapnik::geometry::point(x, y)); + multi_point.emplace_back(mapnik::geometry::point(x, y)); } feature->set_geometry(std::move(multi_point)); break; diff --git a/plugins/input/shape/shape_io.cpp b/plugins/input/shape/shape_io.cpp index 4865195c7..d2791d176 100644 --- a/plugins/input/shape/shape_io.cpp +++ b/plugins/input/shape/shape_io.cpp @@ -88,15 +88,15 @@ void shape_io::read_bbox(shape_file::record_type & record, mapnik::box2d bbox.init(lox, loy, hix, hiy); } -mapnik::geometry::geometry shape_io::read_polyline(shape_file::record_type & record) +mapnik::geometry::geometry shape_io::read_polyline(shape_file::record_type & record) { - mapnik::geometry::geometry geom; // default empty + mapnik::geometry::geometry geom; // default empty int num_parts = record.read_ndr_integer(); int num_points = record.read_ndr_integer(); if (num_parts == 1) { - mapnik::geometry::line_string line; + mapnik::geometry::line_string line; line.reserve(num_points); record.skip(4); for (int i = 0; i < num_points; ++i) @@ -116,7 +116,7 @@ mapnik::geometry::geometry shape_io::read_polyline(shape_file::record_type & rec } int start, end; - mapnik::geometry::multi_line_string multi_line; + mapnik::geometry::multi_line_string multi_line; for (int k = 0; k < num_parts; ++k) { start = parts[k]; @@ -129,7 +129,7 @@ mapnik::geometry::geometry shape_io::read_polyline(shape_file::record_type & rec end = parts[k + 1]; } - mapnik::geometry::line_string line; + mapnik::geometry::line_string line; line.reserve(end - start); for (int j = start; j < end; ++j) { @@ -145,9 +145,9 @@ mapnik::geometry::geometry shape_io::read_polyline(shape_file::record_type & rec } -mapnik::geometry::geometry shape_io::read_polygon(shape_file::record_type & record) +mapnik::geometry::geometry shape_io::read_polygon(shape_file::record_type & record) { - mapnik::geometry::geometry geom; // default empty + mapnik::geometry::geometry geom; // default empty int num_parts = record.read_ndr_integer(); int num_points = record.read_ndr_integer(); @@ -158,15 +158,15 @@ mapnik::geometry::geometry shape_io::read_polygon(shape_file::record_type & reco parts[i] = record.read_ndr_integer(); } - mapnik::geometry::multi_polygon multi_poly; - mapnik::geometry::polygon poly; + mapnik::geometry::multi_polygon multi_poly; + mapnik::geometry::polygon poly; for (int k = 0; k < num_parts; ++k) { int start = parts[k]; int end; if (k == num_parts - 1) end = num_points; else end = parts[k + 1]; - mapnik::geometry::linear_ring ring; + mapnik::geometry::linear_ring ring; ring.reserve(end - start); for (int j = start; j < end; ++j) { diff --git a/plugins/input/shape/shape_io.hpp b/plugins/input/shape/shape_io.hpp index 0ba5f12b0..ebf31dacf 100644 --- a/plugins/input/shape/shape_io.hpp +++ b/plugins/input/shape/shape_io.hpp @@ -76,8 +76,8 @@ public: void move_to(std::streampos pos); static void read_bbox(shape_file::record_type & record, mapnik::box2d & bbox); - static mapnik::geometry::geometry read_polyline(shape_file::record_type & record); - static mapnik::geometry::geometry read_polygon(shape_file::record_type & record); + static mapnik::geometry::geometry read_polyline(shape_file::record_type & record); + static mapnik::geometry::geometry read_polygon(shape_file::record_type & record); shapeType type_; shape_file shp_; diff --git a/plugins/input/sqlite/sqlite_datasource.cpp b/plugins/input/sqlite/sqlite_datasource.cpp index bba4789aa..9c837bd2b 100644 --- a/plugins/input/sqlite/sqlite_datasource.cpp +++ b/plugins/input/sqlite/sqlite_datasource.cpp @@ -448,7 +448,7 @@ boost::optional sqlite_datasource::get_geometry_t if (data) { - mapnik::geometry::geometry geom = mapnik::geometry_utils::from_wkb(data, size, format_); + mapnik::geometry::geometry geom = mapnik::geometry_utils::from_wkb(data, size, format_); if (mapnik::geometry::is_empty(geom)) { continue; diff --git a/plugins/input/sqlite/sqlite_featureset.cpp b/plugins/input/sqlite/sqlite_featureset.cpp index 61701d14f..e6ee0d425 100644 --- a/plugins/input/sqlite/sqlite_featureset.cpp +++ b/plugins/input/sqlite/sqlite_featureset.cpp @@ -81,7 +81,7 @@ feature_ptr sqlite_featureset::next() } feature_ptr feature = feature_factory::create(ctx_,rs_->column_integer64(1)); - mapnik::geometry::geometry geom = geometry_utils::from_wkb(data, size, format_); + mapnik::geometry::geometry geom = geometry_utils::from_wkb(data, size, format_); if (mapnik::geometry::is_empty(geom)) { continue; diff --git a/plugins/input/sqlite/sqlite_utils.hpp b/plugins/input/sqlite/sqlite_utils.hpp index 194c283fe..b38dd0654 100644 --- a/plugins/input/sqlite/sqlite_utils.hpp +++ b/plugins/input/sqlite/sqlite_utils.hpp @@ -196,7 +196,7 @@ public: const char* data = static_cast(rs->column_blob(0, size)); if (data) { - mapnik::geometry::geometry geom = mapnik::geometry_utils::from_wkb(data, size, mapnik::wkbAuto); + mapnik::geometry::geometry geom = mapnik::geometry_utils::from_wkb(data, size, mapnik::wkbAuto); if (!mapnik::geometry::is_empty(geom)) { mapnik::box2d bbox = mapnik::geometry::envelope(geom); @@ -280,7 +280,7 @@ public: const char* data = (const char*) rs->column_blob(0, size); if (data) { - mapnik::geometry::geometry geom = mapnik::geometry_utils::from_wkb(data, size, mapnik::wkbAuto); + mapnik::geometry::geometry geom = mapnik::geometry_utils::from_wkb(data, size, mapnik::wkbAuto); if (!mapnik::geometry::is_empty(geom)) { mapnik::box2d bbox = mapnik::geometry::envelope(geom); @@ -356,7 +356,7 @@ public: const char* data = static_cast(rs->column_blob(0, size)); if (data) { - mapnik::geometry::geometry geom = mapnik::geometry_utils::from_wkb(data, size, mapnik::wkbAuto); + mapnik::geometry::geometry geom = mapnik::geometry_utils::from_wkb(data, size, mapnik::wkbAuto); if (!mapnik::geometry::is_empty(geom)) { mapnik::box2d bbox = mapnik::geometry::envelope(geom); diff --git a/plugins/input/templates/helloworld/hello_featureset.cpp b/plugins/input/templates/helloworld/hello_featureset.cpp index 0badad361..bea10be37 100644 --- a/plugins/input/templates/helloworld/hello_featureset.cpp +++ b/plugins/input/templates/helloworld/hello_featureset.cpp @@ -53,7 +53,7 @@ mapnik::feature_ptr hello_featureset::next() // take the outer ring of the bbox that was used to query // to dynamically generate a fake line - mapnik::geometry::line_string line; + mapnik::geometry::line_string line; line.reserve(4); line.add_coord(box_.minx(),box_.maxy()); line.add_coord(box_.maxx(),box_.maxy()); diff --git a/plugins/input/topojson/topojson_featureset.cpp b/plugins/input/topojson/topojson_featureset.cpp index 7eb88f665..8626de960 100644 --- a/plugins/input/topojson/topojson_featureset.cpp +++ b/plugins/input/topojson/topojson_featureset.cpp @@ -96,7 +96,7 @@ struct feature_generator x = x * (*topo_.tr).scale_x + (*topo_.tr).translate_x; y = y * (*topo_.tr).scale_y + (*topo_.tr).translate_y; } - mapnik::geometry::point point(x, y); + mapnik::geometry::point point(x, y); feature->set_geometry(std::move(point)); assign_properties(*feature, pt, tr_); return feature; @@ -105,7 +105,7 @@ struct feature_generator feature_ptr operator() (multi_point const& multi_pt) const { mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx_,feature_id_)); - mapnik::geometry::multi_point multi_point; + mapnik::geometry::multi_point multi_point; multi_point.reserve(multi_pt.points.size()); for (auto const& pt : multi_pt.points) { @@ -129,7 +129,7 @@ struct feature_generator double px = 0, py = 0; index_type arc_index = line.ring; - mapnik::geometry::line_string line_string; + mapnik::geometry::line_string line_string; line_string.reserve( topo_.arcs[arc_index].coordinates.size()); for (auto pt : topo_.arcs[arc_index].coordinates) @@ -152,14 +152,14 @@ struct feature_generator { mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx_,feature_id_)); - mapnik::geometry::multi_line_string multi_line_string; + mapnik::geometry::multi_line_string multi_line_string; multi_line_string.reserve(multi_line.rings.size()); for (auto const& index : multi_line.rings) { double px = 0, py = 0; bool reverse = index < 0; index_type arc_index = reverse ? std::abs(index) - 1 : index; - mapnik::geometry::line_string line_string; + mapnik::geometry::line_string line_string; line_string.reserve(topo_.arcs[arc_index].coordinates.size()); for (auto pt : topo_.arcs[arc_index].coordinates) { @@ -183,12 +183,12 @@ struct feature_generator { mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx_,feature_id_)); std::vector processed_coords; - mapnik::geometry::polygon polygon; + mapnik::geometry::polygon polygon; if (poly.rings.size() > 1) polygon.interior_rings.reserve(poly.rings.size() - 1); bool first = true; for (auto const& ring : poly.rings) { - mapnik::geometry::linear_ring linear_ring; + mapnik::geometry::linear_ring linear_ring; for (auto const& index : ring) { double px = 0, py = 0; @@ -248,18 +248,18 @@ struct feature_generator { mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx_,feature_id_)); std::vector processed_coords; - mapnik::geometry::multi_polygon multi_polygon; + mapnik::geometry::multi_polygon multi_polygon; multi_polygon.reserve(multi_poly.polygons.size()); for (auto const& poly : multi_poly.polygons) { bool first = true; - mapnik::geometry::polygon polygon; + mapnik::geometry::polygon polygon; if (poly.size() > 1) polygon.interior_rings.reserve(poly.size() - 1); for (auto const& ring : poly) { - mapnik::geometry::linear_ring linear_ring; + mapnik::geometry::linear_ring linear_ring; for (auto const& index : ring) { double px = 0, py = 0; diff --git a/src/geometry_envelope.cpp b/src/geometry_envelope.cpp index e486f75fa..0b7b61c6b 100644 --- a/src/geometry_envelope.cpp +++ b/src/geometry_envelope.cpp @@ -26,16 +26,16 @@ namespace mapnik { namespace geometry { -template MAPNIK_DECL mapnik::box2d envelope(geometry const& geom); +template MAPNIK_DECL mapnik::box2d envelope(geometry const& geom); template MAPNIK_DECL mapnik::box2d envelope(mapnik::base_symbolizer_helper::geometry_cref const& geom); template MAPNIK_DECL mapnik::box2d envelope(geometry_empty const& geom); -template MAPNIK_DECL mapnik::box2d envelope(point const& geom); -template MAPNIK_DECL mapnik::box2d envelope(line_string const& geom); -template MAPNIK_DECL mapnik::box2d envelope(polygon const& geom); -template MAPNIK_DECL mapnik::box2d envelope(multi_point const& geom); -template MAPNIK_DECL mapnik::box2d envelope(multi_line_string const& geom); -template MAPNIK_DECL mapnik::box2d envelope(multi_polygon const& geom); -template MAPNIK_DECL mapnik::box2d envelope(geometry_collection const& geom); +template MAPNIK_DECL mapnik::box2d envelope(point const& geom); +template MAPNIK_DECL mapnik::box2d envelope(line_string const& geom); +template MAPNIK_DECL mapnik::box2d envelope(polygon const& geom); +template MAPNIK_DECL mapnik::box2d envelope(multi_point const& geom); +template MAPNIK_DECL mapnik::box2d envelope(multi_line_string const& geom); +template MAPNIK_DECL mapnik::box2d envelope(multi_polygon const& geom); +template MAPNIK_DECL mapnik::box2d envelope(geometry_collection const& geom); } // end ns geometry } // end ns mapnik diff --git a/src/geometry_reprojection.cpp b/src/geometry_reprojection.cpp index 9f2a3d497..b6dd3e4e2 100644 --- a/src/geometry_reprojection.cpp +++ b/src/geometry_reprojection.cpp @@ -35,9 +35,10 @@ geometry_empty reproject_internal(geometry_empty const&, proj_transform const&, return geometry_empty(); } -point reproject_internal(point const & p, proj_transform const& proj_trans, unsigned int & n_err) +template +point reproject_internal(point const & p, proj_transform const& proj_trans, unsigned int & n_err) { - point new_p(p); + point new_p(p); if (!proj_trans.forward(new_p)) { ++n_err; @@ -45,9 +46,10 @@ point reproject_internal(point const & p, proj_transform const& proj_trans, unsi return new_p; } -line_string reproject_internal(line_string const & ls, proj_transform const& proj_trans, unsigned int & n_err) +template +line_string reproject_internal(line_string const & ls, proj_transform const& proj_trans, unsigned int & n_err) { - line_string new_ls(ls); + line_string new_ls(ls); unsigned int err = proj_trans.forward(new_ls); if (err > 0) { @@ -56,10 +58,11 @@ line_string reproject_internal(line_string const & ls, proj_transform const& pro return new_ls; } -polygon reproject_internal(polygon const & poly, proj_transform const& proj_trans, unsigned int & n_err) +template +polygon reproject_internal(polygon const & poly, proj_transform const& proj_trans, unsigned int & n_err) { - polygon new_poly; - linear_ring new_ext(poly.exterior_ring); + polygon new_poly; + linear_ring new_ext(poly.exterior_ring); unsigned int err = proj_trans.forward(new_ext); // If the exterior ring doesn't transform don't bother with the holes. if (err > 0 || new_ext.empty()) @@ -73,7 +76,7 @@ polygon reproject_internal(polygon const & poly, proj_transform const& proj_tran for (auto const& lr : poly.interior_rings) { - linear_ring new_lr(lr); + linear_ring new_lr(lr); err = proj_trans.forward(new_lr); if (err > 0 || new_lr.empty()) { @@ -88,9 +91,10 @@ polygon reproject_internal(polygon const & poly, proj_transform const& proj_tran return new_poly; } -multi_point reproject_internal(multi_point const & mp, proj_transform const& proj_trans, unsigned int & n_err) +template +multi_point reproject_internal(multi_point const & mp, proj_transform const& proj_trans, unsigned int & n_err) { - multi_point new_mp; + multi_point new_mp; if (proj_trans.is_known()) { // If the projection is known we do them all at once because it is faster @@ -103,7 +107,7 @@ multi_point reproject_internal(multi_point const & mp, proj_transform const& pro new_mp.reserve(mp.size()); for (auto const& p : mp) { - point new_p(p); + point new_p(p); if (!proj_trans.forward(new_p)) { ++n_err; @@ -117,13 +121,14 @@ multi_point reproject_internal(multi_point const & mp, proj_transform const& pro return new_mp; } -multi_line_string reproject_internal(multi_line_string const & mls, proj_transform const& proj_trans, unsigned int & n_err) +template +multi_line_string reproject_internal(multi_line_string const & mls, proj_transform const& proj_trans, unsigned int & n_err) { - multi_line_string new_mls; + multi_line_string new_mls; new_mls.reserve(mls.size()); for (auto const& ls : mls) { - line_string new_ls = reproject_internal(ls, proj_trans, n_err); + line_string new_ls = reproject_internal(ls, proj_trans, n_err); if (!new_ls.empty()) { new_mls.emplace_back(std::move(new_ls)); @@ -132,13 +137,14 @@ multi_line_string reproject_internal(multi_line_string const & mls, proj_transfo return new_mls; } -multi_polygon reproject_internal(multi_polygon const & mpoly, proj_transform const& proj_trans, unsigned int & n_err) +template +multi_polygon reproject_internal(multi_polygon const & mpoly, proj_transform const& proj_trans, unsigned int & n_err) { - multi_polygon new_mpoly; + multi_polygon new_mpoly; new_mpoly.reserve(mpoly.size()); for (auto const& poly : mpoly) { - polygon new_poly = reproject_internal(poly, proj_trans, n_err); + polygon new_poly = reproject_internal(poly, proj_trans, n_err); if (!new_poly.exterior_ring.empty()) { new_mpoly.emplace_back(std::move(new_poly)); @@ -147,14 +153,16 @@ multi_polygon reproject_internal(multi_polygon const & mpoly, proj_transform con return new_mpoly; } -geometry_collection reproject_internal(geometry_collection const & c, proj_transform const& proj_trans, unsigned int & n_err) +template +geometry_collection reproject_internal(geometry_collection const & c, proj_transform const& proj_trans, unsigned int & n_err) { - geometry_collection new_c; + geometry_collection new_c; new_c.reserve(c.size()); for (auto const& g : c) { - geometry new_g(std::move(reproject_copy(g, proj_trans, n_err))); - if (!new_g.is()) + + geometry new_g(std::move(reproject_copy(g, proj_trans, n_err))); + if (!new_g.template is()) { new_c.emplace_back(std::move(new_g)); } @@ -162,77 +170,78 @@ geometry_collection reproject_internal(geometry_collection const & c, proj_trans return new_c; } +template struct geom_reproj_copy_visitor { geom_reproj_copy_visitor(proj_transform const & proj_trans, unsigned int & n_err) : proj_trans_(proj_trans), n_err_(n_err) {} - geometry operator() (geometry_empty const&) + geometry operator() (geometry_empty const&) { return geometry_empty(); } - geometry operator() (point const& p) + geometry operator() (point const& p) { - geometry geom; // default empty + geometry geom; // default empty unsigned int intial_err = n_err_; - point new_p = reproject_internal(p, proj_trans_, n_err_); + point new_p = reproject_internal(p, proj_trans_, n_err_); if (n_err_ > intial_err) return geom; geom = std::move(new_p); return geom; } - geometry operator() (line_string const& ls) + geometry operator() (line_string const& ls) { - geometry geom; // default empty + geometry geom; // default empty int intial_err = n_err_; - line_string new_ls = reproject_internal(ls, proj_trans_, n_err_); + line_string new_ls = reproject_internal(ls, proj_trans_, n_err_); if (n_err_ > intial_err || new_ls.empty()) return geom; geom = std::move(new_ls); return geom; } - geometry operator() (polygon const& poly) + geometry operator() (polygon const& poly) { - geometry geom; // default empty - polygon new_poly = reproject_internal(poly, proj_trans_, n_err_); + geometry geom; // default empty + polygon new_poly = reproject_internal(poly, proj_trans_, n_err_); if (new_poly.exterior_ring.empty()) return geom; geom = std::move(new_poly); return geom; } - geometry operator() (multi_point const& mp) + geometry operator() (multi_point const& mp) { - geometry geom; // default empty - multi_point new_mp = reproject_internal(mp, proj_trans_, n_err_); + geometry geom; // default empty + multi_point new_mp = reproject_internal(mp, proj_trans_, n_err_); if (new_mp.empty()) return geom; geom = std::move(new_mp); return geom; } - geometry operator() (multi_line_string const& mls) + geometry operator() (multi_line_string const& mls) { - geometry geom; // default empty - multi_line_string new_mls = reproject_internal(mls, proj_trans_, n_err_); + geometry geom; // default empty + multi_line_string new_mls = reproject_internal(mls, proj_trans_, n_err_); if (new_mls.empty()) return geom; geom = std::move(new_mls); return geom; } - geometry operator() (multi_polygon const& mpoly) + geometry operator() (multi_polygon const& mpoly) { - geometry geom; // default empty - multi_polygon new_mpoly = reproject_internal(mpoly, proj_trans_, n_err_); + geometry geom; // default empty + multi_polygon new_mpoly = reproject_internal(mpoly, proj_trans_, n_err_); if (new_mpoly.empty()) return geom; geom = std::move(new_mpoly); return geom; } - geometry operator() (geometry_collection const& c) + geometry operator() (geometry_collection const& c) { - geometry geom; // default empty - geometry_collection new_c = reproject_internal(c, proj_trans_, n_err_); + geometry geom; // default empty + geometry_collection new_c = reproject_internal(c, proj_trans_, n_err_); if (new_c.empty()) return geom; geom = std::move(new_c); return geom; @@ -246,9 +255,10 @@ private: } // end detail ns -geometry reproject_copy(geometry const& geom, proj_transform const& proj_trans, unsigned int & n_err) +template +geometry reproject_copy(geometry const& geom, proj_transform const& proj_trans, unsigned int & n_err) { - detail::geom_reproj_copy_visitor visit(proj_trans, n_err); + detail::geom_reproj_copy_visitor visit(proj_trans, n_err); return mapnik::util::apply_visitor(visit, geom); } @@ -259,13 +269,13 @@ T reproject_copy(T const& geom, proj_transform const& proj_trans, unsigned int & } template MAPNIK_DECL geometry_empty reproject_copy(geometry_empty const& geom, proj_transform const& proj_trans, unsigned int & n_err); -template MAPNIK_DECL point reproject_copy(point const& geom, proj_transform const& proj_trans, unsigned int & n_err); -template MAPNIK_DECL line_string reproject_copy(line_string const& geom, proj_transform const& proj_trans, unsigned int & n_err); -template MAPNIK_DECL polygon reproject_copy(polygon const& geom, proj_transform const& proj_trans, unsigned int & n_err); -template MAPNIK_DECL multi_point reproject_copy(multi_point const& geom, proj_transform const& proj_trans, unsigned int & n_err); -template MAPNIK_DECL multi_line_string reproject_copy(multi_line_string const& geom, proj_transform const& proj_trans, unsigned int & n_err); -template MAPNIK_DECL multi_polygon reproject_copy(multi_polygon const& geom, proj_transform const& proj_trans, unsigned int & n_err); -template MAPNIK_DECL geometry_collection reproject_copy(geometry_collection const& geom, proj_transform const& proj_trans, unsigned int & n_err); +template MAPNIK_DECL point reproject_copy(point const& geom, proj_transform const& proj_trans, unsigned int & n_err); +template MAPNIK_DECL line_string reproject_copy(line_string const& geom, proj_transform const& proj_trans, unsigned int & n_err); +template MAPNIK_DECL polygon reproject_copy(polygon const& geom, proj_transform const& proj_trans, unsigned int & n_err); +template MAPNIK_DECL multi_point reproject_copy(multi_point const& geom, proj_transform const& proj_trans, unsigned int & n_err); +template MAPNIK_DECL multi_line_string reproject_copy(multi_line_string const& geom, proj_transform const& proj_trans, unsigned int & n_err); +template MAPNIK_DECL multi_polygon reproject_copy(multi_polygon const& geom, proj_transform const& proj_trans, unsigned int & n_err); +template MAPNIK_DECL geometry_collection reproject_copy(geometry_collection const& geom, proj_transform const& proj_trans, unsigned int & n_err); template T reproject_copy(T const& geom, projection const& source, projection const& dest, unsigned int & n_err) @@ -274,15 +284,15 @@ T reproject_copy(T const& geom, projection const& source, projection const& dest return reproject_copy(geom, proj_trans, n_err); } -template MAPNIK_DECL geometry reproject_copy(geometry const& geom, projection const& source, projection const& dest, unsigned int & n_err); +template MAPNIK_DECL geometry reproject_copy(geometry const& geom, projection const& source, projection const& dest, unsigned int & n_err); template MAPNIK_DECL geometry_empty reproject_copy(geometry_empty const& geom, projection const& source, projection const& dest, unsigned int & n_err); -template MAPNIK_DECL point reproject_copy(point const& geom, projection const& source, projection const& dest, unsigned int & n_err); -template MAPNIK_DECL line_string reproject_copy(line_string const& geom, projection const& source, projection const& dest, unsigned int & n_err); -template MAPNIK_DECL polygon reproject_copy(polygon const& geom, projection const& source, projection const& dest, unsigned int & n_err); -template MAPNIK_DECL multi_point reproject_copy(multi_point const& geom, projection const& source, projection const& dest, unsigned int & n_err); -template MAPNIK_DECL multi_line_string reproject_copy(multi_line_string const& geom, projection const& source, projection const& dest, unsigned int & n_err); -template MAPNIK_DECL multi_polygon reproject_copy(multi_polygon const& geom, projection const& source, projection const& dest, unsigned int & n_err); -template MAPNIK_DECL geometry_collection reproject_copy(geometry_collection const& geom, projection const& source, projection const& dest, unsigned int & n_err); +template MAPNIK_DECL point reproject_copy(point const& geom, projection const& source, projection const& dest, unsigned int & n_err); +template MAPNIK_DECL line_string reproject_copy(line_string const& geom, projection const& source, projection const& dest, unsigned int & n_err); +template MAPNIK_DECL polygon reproject_copy(polygon const& geom, projection const& source, projection const& dest, unsigned int & n_err); +template MAPNIK_DECL multi_point reproject_copy(multi_point const& geom, projection const& source, projection const& dest, unsigned int & n_err); +template MAPNIK_DECL multi_line_string reproject_copy(multi_line_string const& geom, projection const& source, projection const& dest, unsigned int & n_err); +template MAPNIK_DECL multi_polygon reproject_copy(multi_polygon const& geom, projection const& source, projection const& dest, unsigned int & n_err); +template MAPNIK_DECL geometry_collection reproject_copy(geometry_collection const& geom, projection const& source, projection const& dest, unsigned int & n_err); namespace detail { @@ -291,14 +301,16 @@ struct geom_reproj_visitor { geom_reproj_visitor(proj_transform const & proj_trans) : proj_trans_(proj_trans) {} - bool operator() (geometry & geom) + template + bool operator() (geometry & geom) { return mapnik::util::apply_visitor((*this), geom); } bool operator() (geometry_empty &) { return true; } - bool operator() (point & p) + template + bool operator() (point & p) { if (!proj_trans_.forward(p)) { @@ -307,7 +319,8 @@ struct geom_reproj_visitor { return true; } - bool operator() (line_string & ls) + template + bool operator() (line_string & ls) { if (proj_trans_.forward(ls) > 0) { @@ -316,7 +329,8 @@ struct geom_reproj_visitor { return true; } - bool operator() (polygon & poly) + template + bool operator() (polygon & poly) { if (proj_trans_.forward(poly.exterior_ring) > 0) { @@ -333,12 +347,14 @@ struct geom_reproj_visitor { return true; } - bool operator() (multi_point & mp) + template + bool operator() (multi_point & mp) { - return (*this) (static_cast(mp)); + return (*this) (static_cast &>(mp)); } - bool operator() (multi_line_string & mls) + template + bool operator() (multi_line_string & mls) { for (auto & ls : mls) { @@ -350,7 +366,8 @@ struct geom_reproj_visitor { return true; } - bool operator() (multi_polygon & mpoly) + template + bool operator() (multi_polygon & mpoly) { for (auto & poly : mpoly) { @@ -362,7 +379,8 @@ struct geom_reproj_visitor { return true; } - bool operator() (geometry_collection & c) + template + bool operator() (geometry_collection & c) { for (auto & g : c) { @@ -388,15 +406,15 @@ bool reproject(T & geom, proj_transform const& proj_trans) return visit(geom); } -template MAPNIK_DECL bool reproject(geometry & geom, proj_transform const& proj_trans); +template MAPNIK_DECL bool reproject(geometry & geom, proj_transform const& proj_trans); template MAPNIK_DECL bool reproject(geometry_empty & geom, proj_transform const& proj_trans); -template MAPNIK_DECL bool reproject(point & geom, proj_transform const& proj_trans); -template MAPNIK_DECL bool reproject(line_string & geom, proj_transform const& proj_trans); -template MAPNIK_DECL bool reproject(polygon & geom, proj_transform const& proj_trans); -template MAPNIK_DECL bool reproject(multi_point & geom, proj_transform const& proj_trans); -template MAPNIK_DECL bool reproject(multi_line_string & geom, proj_transform const& proj_trans); -template MAPNIK_DECL bool reproject(multi_polygon & geom, proj_transform const& proj_trans); -template MAPNIK_DECL bool reproject(geometry_collection & geom, proj_transform const& proj_trans); +template MAPNIK_DECL bool reproject(point & geom, proj_transform const& proj_trans); +template MAPNIK_DECL bool reproject(line_string & geom, proj_transform const& proj_trans); +template MAPNIK_DECL bool reproject(polygon & geom, proj_transform const& proj_trans); +template MAPNIK_DECL bool reproject(multi_point & geom, proj_transform const& proj_trans); +template MAPNIK_DECL bool reproject(multi_line_string & geom, proj_transform const& proj_trans); +template MAPNIK_DECL bool reproject(multi_polygon & geom, proj_transform const& proj_trans); +template MAPNIK_DECL bool reproject(geometry_collection & geom, proj_transform const& proj_trans); template bool reproject(T & geom, projection const& source, projection const& dest) @@ -406,15 +424,15 @@ bool reproject(T & geom, projection const& source, projection const& dest) return visit(geom); } -template MAPNIK_DECL bool reproject(geometry & geom, projection const& source, projection const& dest); +template MAPNIK_DECL bool reproject(geometry & geom, projection const& source, projection const& dest); template MAPNIK_DECL bool reproject(geometry_empty & geom, projection const& source, projection const& dest); -template MAPNIK_DECL bool reproject(point & geom, projection const& source, projection const& dest); -template MAPNIK_DECL bool reproject(line_string & geom, projection const& source, projection const& dest); -template MAPNIK_DECL bool reproject(polygon & geom, projection const& source, projection const& dest); -template MAPNIK_DECL bool reproject(multi_point & geom, projection const& source, projection const& dest); -template MAPNIK_DECL bool reproject(multi_line_string & geom, projection const& source, projection const& dest); -template MAPNIK_DECL bool reproject(multi_polygon & geom, projection const& source, projection const& dest); -template MAPNIK_DECL bool reproject(geometry_collection & geom, projection const& source, projection const& dest); +template MAPNIK_DECL bool reproject(point & geom, projection const& source, projection const& dest); +template MAPNIK_DECL bool reproject(line_string & geom, projection const& source, projection const& dest); +template MAPNIK_DECL bool reproject(polygon & geom, projection const& source, projection const& dest); +template MAPNIK_DECL bool reproject(multi_point & geom, projection const& source, projection const& dest); +template MAPNIK_DECL bool reproject(multi_line_string & geom, projection const& source, projection const& dest); +template MAPNIK_DECL bool reproject(multi_polygon & geom, projection const& source, projection const& dest); +template MAPNIK_DECL bool reproject(geometry_collection & geom, projection const& source, projection const& dest); } // end geometry ns diff --git a/src/json/mapnik_json_generator_grammar.cpp b/src/json/mapnik_json_generator_grammar.cpp index 9473d30e7..10b13829a 100644 --- a/src/json/mapnik_json_generator_grammar.cpp +++ b/src/json/mapnik_json_generator_grammar.cpp @@ -32,4 +32,4 @@ using sink_type = std::back_insert_iterator; template struct mapnik::json::properties_generator_grammar; template struct mapnik::json::feature_generator_grammar; -template struct mapnik::json::geometry_generator_grammar; +template struct mapnik::json::geometry_generator_grammar >; diff --git a/src/proj_transform.cpp b/src/proj_transform.cpp index f49eb49cf..8b058a456 100644 --- a/src/proj_transform.cpp +++ b/src/proj_transform.cpp @@ -97,13 +97,13 @@ bool proj_transform::forward (double & x, double & y , double & z) const return forward(&x, &y, &z, 1); } -bool proj_transform::forward (geometry::point & p) const +bool proj_transform::forward (geometry::point & p) const { double z = 0; return forward(&(p.x), &(p.y), &z, 1); } -unsigned int proj_transform::forward (geometry::line_string & ls) const +unsigned int proj_transform::forward (geometry::line_string & ls) const { if (is_source_equal_dest_) return 0; @@ -220,13 +220,13 @@ bool proj_transform::backward (double & x, double & y , double & z) const return backward(&x, &y, &z, 1); } -bool proj_transform::backward (geometry::point & p) const +bool proj_transform::backward (geometry::point & p) const { double z = 0; return backward(&(p.x), &(p.y), &z, 1); } -unsigned int proj_transform::backward (geometry::line_string & ls) const +unsigned int proj_transform::backward (geometry::line_string & ls) const { if (is_source_equal_dest_) return 0; diff --git a/src/text/symbolizer_helpers.cpp b/src/text/symbolizer_helpers.cpp index 7e946fdbb..634ce9f36 100644 --- a/src/text/symbolizer_helpers.cpp +++ b/src/text/symbolizer_helpers.cpp @@ -86,14 +86,14 @@ struct split_multi_geometries minimum_path_length_(minimum_path_length) {} void operator() (geometry::geometry_empty const&) const {} - void operator() (geometry::multi_point const& multi_pt) const + void operator() (geometry::multi_point const& multi_pt) const { for ( auto const& pt : multi_pt ) { cont_.push_back(std::move(base_symbolizer_helper::geometry_cref(std::cref(pt)))); } } - void operator() (geometry::multi_line_string const& multi_line) const + void operator() (geometry::multi_line_string const& multi_line) const { for ( auto const& line : multi_line ) { @@ -101,7 +101,7 @@ struct split_multi_geometries } } - void operator() (geometry::polygon const& poly) const + void operator() (geometry::polygon const& poly) const { if (minimum_path_length_ > 0) { @@ -117,7 +117,7 @@ struct split_multi_geometries } } - void operator() (geometry::multi_polygon const& multi_poly) const + void operator() (geometry::multi_polygon const& multi_poly) const { for ( auto const& poly : multi_poly ) { @@ -125,7 +125,7 @@ struct split_multi_geometries } } - void operator() (geometry::geometry_collection const& collection) const + void operator() (geometry::geometry_collection const& collection) const { for ( auto const& geom : collection) { @@ -173,7 +173,7 @@ base_symbolizer_helper::base_symbolizer_helper( struct largest_bbox_first { - bool operator() (geometry::geometry const* g0, geometry::geometry const* g1) const + bool operator() (geometry::geometry const* g0, geometry::geometry const* g1) const { box2d b0 = geometry::envelope(*g0); box2d b1 = geometry::envelope(*g1); @@ -239,13 +239,13 @@ void base_symbolizer_helper::initialize_points() const // FIXME: how to handle MultiLineString? if (type == geometry::geometry_types::LineString) { - auto const& line = mapnik::util::get(geom); - geometry::line_string_vertex_adapter va(line); + auto const& line = mapnik::util::get >(geom); + geometry::line_string_vertex_adapter va(line); success = label::middle_point(va, label_x,label_y); } else if (how_placed == POINT_PLACEMENT) { - geometry::point pt; + geometry::point pt; geometry::centroid(geom, pt); label_x = pt.x; label_y = pt.y; @@ -255,8 +255,8 @@ void base_symbolizer_helper::initialize_points() const { if (type == geometry::geometry_types::Polygon) { - auto const& poly = mapnik::util::get(geom); - geometry::polygon_vertex_adapter va(poly); + auto const& poly = mapnik::util::get >(geom); + geometry::polygon_vertex_adapter va(poly); success = label::interior_position(va, label_x, label_y); } } @@ -333,8 +333,8 @@ bool text_symbolizer_helper::next_line_placement() const if (geo_itr_->is()) // line_string { - auto const& line = util::get(*geo_itr_); - geometry::line_string_vertex_adapter va(line); + auto const& line = util::get const>(*geo_itr_); + geometry::line_string_vertex_adapter va(line); converter_.apply(va); if (adapter_.status()) { diff --git a/src/wkb.cpp b/src/wkb.cpp index 5ee1edb6c..0a9b8900a 100644 --- a/src/wkb.cpp +++ b/src/wkb.cpp @@ -118,9 +118,9 @@ public: needSwap_ = byteOrder_ ? wkbXDR : wkbNDR; } - mapnik::geometry::geometry read() + mapnik::geometry::geometry read() { - mapnik::geometry::geometry geom = mapnik::geometry::geometry_empty(); + mapnik::geometry::geometry geom = mapnik::geometry::geometry_empty(); int type = read_integer(); switch (type) { @@ -263,19 +263,19 @@ private: } template - mapnik::geometry::point read_point() + mapnik::geometry::point read_point() { double x = read_double(); double y = read_double(); if (Z) pos_ += 8; if (M) pos_ += 8; - return mapnik::geometry::point(x, y); + return mapnik::geometry::point(x, y); } template - mapnik::geometry::multi_point read_multipoint() + mapnik::geometry::multi_point read_multipoint() { - mapnik::geometry::multi_point multi_point; + mapnik::geometry::multi_point multi_point; int num_points = read_integer(); multi_point.reserve(num_points); for (int i = 0; i < num_points; ++i) @@ -287,23 +287,23 @@ private: } template - mapnik::geometry::line_string read_linestring() + mapnik::geometry::line_string read_linestring() { - mapnik::geometry::line_string line; + mapnik::geometry::line_string line; int num_points = read_integer(); if (num_points > 0) { line.reserve(num_points); - read_coords(line, num_points); + read_coords, M, Z>(line, num_points); } return line; } template - mapnik::geometry::multi_line_string read_multilinestring() + mapnik::geometry::multi_line_string read_multilinestring() { int num_lines = read_integer(); - mapnik::geometry::multi_line_string multi_line; + mapnik::geometry::multi_line_string multi_line; multi_line.reserve(num_lines); for (int i = 0; i < num_lines; ++i) { @@ -314,10 +314,10 @@ private: } template - mapnik::geometry::polygon read_polygon() + mapnik::geometry::polygon read_polygon() { int num_rings = read_integer(); - mapnik::geometry::polygon poly; + mapnik::geometry::polygon poly; if (num_rings > 1) { poly.interior_rings.reserve(num_rings - 1); @@ -325,12 +325,12 @@ private: for (int i = 0; i < num_rings; ++i) { - mapnik::geometry::linear_ring ring; + mapnik::geometry::linear_ring ring; int num_points = read_integer(); if (num_points > 0) { ring.reserve(num_points); - read_coords(ring, num_points); + read_coords, M, Z>(ring, num_points); } if ( i == 0) poly.set_exterior_ring(std::move(ring)); else poly.add_hole(std::move(ring)); @@ -339,10 +339,10 @@ private: } template - mapnik::geometry::multi_polygon read_multipolygon() + mapnik::geometry::multi_polygon read_multipolygon() { int num_polys = read_integer(); - mapnik::geometry::multi_polygon multi_poly; + mapnik::geometry::multi_polygon multi_poly; for (int i = 0; i < num_polys; ++i) { pos_ += 5; @@ -351,10 +351,10 @@ private: return multi_poly; } - mapnik::geometry::geometry_collection read_collection() + mapnik::geometry::geometry_collection read_collection() { int num_geometries = read_integer(); - mapnik::geometry::geometry_collection collection; + mapnik::geometry::geometry_collection collection; for (int i = 0; i < num_geometries; ++i) { pos_ += 1; // skip byte order @@ -405,12 +405,12 @@ private: }; -mapnik::geometry::geometry geometry_utils::from_wkb(const char* wkb, +mapnik::geometry::geometry geometry_utils::from_wkb(const char* wkb, unsigned size, wkbFormat format) { wkb_reader reader(wkb, size, format); - mapnik::geometry::geometry geom(reader.read()); + mapnik::geometry::geometry geom(reader.read()); mapnik::geometry::correct(geom); return geom; } diff --git a/src/wkt/mapnik_wkt_generator_grammar.cpp b/src/wkt/mapnik_wkt_generator_grammar.cpp index 05fa6610b..15606d5eb 100644 --- a/src/wkt/mapnik_wkt_generator_grammar.cpp +++ b/src/wkt/mapnik_wkt_generator_grammar.cpp @@ -27,6 +27,6 @@ namespace mapnik { namespace wkt { using sink_type = std::back_insert_iterator; -template struct wkt_generator_grammar; +template struct wkt_generator_grammar >; }} diff --git a/tests/cpp_tests/fontset_runtime_test.cpp b/tests/cpp_tests/fontset_runtime_test.cpp index 357dd2ab2..73d4c9feb 100644 --- a/tests/cpp_tests/fontset_runtime_test.cpp +++ b/tests/cpp_tests/fontset_runtime_test.cpp @@ -50,7 +50,7 @@ int main(int argc, char** argv) feature->put("name",ustr); //auto pt = std::make_unique(mapnik::geometry::geometry_types::Point); //pt->move_to(128,128); - mapnik::geometry::point pt(128,128); + mapnik::geometry::point pt(128,128); feature->set_geometry(std::move(pt)); mapnik::parameters params; diff --git a/tests/cpp_tests/label_algo_test.cpp b/tests/cpp_tests/label_algo_test.cpp index 49a669b91..f872edec7 100644 --- a/tests/cpp_tests/label_algo_test.cpp +++ b/tests/cpp_tests/label_algo_test.cpp @@ -18,10 +18,10 @@ int main(int argc, char** argv) try { // reused these for simplicity - mapnik::geometry::point centroid; + mapnik::geometry::point centroid; { // single point - mapnik::geometry::point pt(10,10); + mapnik::geometry::point pt(10,10); BOOST_TEST( mapnik::geometry::centroid(pt, centroid)); BOOST_TEST( pt.x == centroid.x); BOOST_TEST( pt.y == centroid.y); @@ -29,7 +29,7 @@ int main(int argc, char** argv) // linestring with three consecutive verticies { - mapnik::geometry::line_string line; + mapnik::geometry::line_string line; line.add_coord(0, 0); line.add_coord(25, 25); line.add_coord(50, 50); diff --git a/tests/cpp_tests/wkb_formats_test.cpp b/tests/cpp_tests/wkb_formats_test.cpp index 72c49c050..af541c94c 100644 --- a/tests/cpp_tests/wkb_formats_test.cpp +++ b/tests/cpp_tests/wkb_formats_test.cpp @@ -68,7 +68,7 @@ int main(int argc, char** argv) try { // spatialite blob - mapnik::geometry::geometry geom = mapnik::geometry_utils::from_wkb((const char*)sp_valid_blob, + mapnik::geometry::geometry geom = mapnik::geometry_utils::from_wkb((const char*)sp_valid_blob, sizeof(sp_valid_blob) / sizeof(sp_valid_blob[0]), mapnik::wkbSpatiaLite); BOOST_TEST(mapnik::geometry::is_valid(geom) && mapnik::geometry::is_simple(geom)); diff --git a/tests/cxx/datasources.cpp b/tests/cxx/datasources.cpp index 2a34f0905..ae2cbca70 100644 --- a/tests/cxx/datasources.cpp +++ b/tests/cxx/datasources.cpp @@ -29,13 +29,13 @@ SECTION("hello world") { REQUIRE( feat1->id() == static_cast(1) ); REQUIRE( feat2->id() == static_cast(2) ); auto const& geom1 = feat1->get_geometry(); - REQUIRE( geom1.is() ); - auto const& point = mapnik::util::get(geom1); + REQUIRE( geom1.is >() ); + auto const& point = mapnik::util::get >(geom1); REQUIRE( point.x == bbox.center().x ); REQUIRE( point.y == bbox.center().y ); auto const& geom2 = feat2->get_geometry(); - REQUIRE( geom2.is() ); - auto const& line = mapnik::util::get(geom2); + REQUIRE( geom2.is >() ); + auto const& line = mapnik::util::get >(geom2); REQUIRE( line.size() == 4 ); REQUIRE( line[0].x == bbox.minx() ); REQUIRE( line[0].y == bbox.maxy() ); diff --git a/tests/cxx/geometry.cpp b/tests/cxx/geometry.cpp index 7b329152b..fd17eabef 100644 --- a/tests/cxx/geometry.cpp +++ b/tests/cxx/geometry.cpp @@ -11,11 +11,11 @@ TEST_CASE("geometry") { SECTION("json point") { mapnik::util::file input("./tests/data/json/fixtures/point1.json"); auto json = input.data(); - mapnik::geometry::geometry geom; + mapnik::geometry::geometry geom; std::string json_string(json.get()); REQUIRE( mapnik::json::from_geojson(json_string, geom) ); - REQUIRE( geom.is() ); - auto const& point = mapnik::util::get(geom); + REQUIRE( geom.is >() ); + auto const& point = mapnik::util::get >(geom); REQUIRE( point.x == 30 ); REQUIRE( point.y == 10 ); std::string new_json; @@ -25,11 +25,11 @@ SECTION("json point") { SECTION("json point reversed") { mapnik::util::file input("./tests/data/json/fixtures/point2.json"); auto json = input.data(); - mapnik::geometry::geometry geom; + mapnik::geometry::geometry geom; std::string json_string(json.get()); REQUIRE( mapnik::json::from_geojson(json_string,geom) ); - REQUIRE( geom.is() ); - auto const& point = mapnik::util::get(geom); + REQUIRE( geom.is >() ); + auto const& point = mapnik::util::get >(geom); REQUIRE( point.x == 30 ); REQUIRE( point.y == 10 ); } diff --git a/tests/cxx/geometry_envelope_test.cpp b/tests/cxx/geometry_envelope_test.cpp index 58818a067..88d3b08b3 100644 --- a/tests/cxx/geometry_envelope_test.cpp +++ b/tests/cxx/geometry_envelope_test.cpp @@ -6,10 +6,10 @@ TEST_CASE("geometry ops - envelope") { -SECTION("envelope_test") { +SECTION("envelope_test - double") { using namespace mapnik::geometry; { - geometry geom(point(1,2)); + geometry geom(point(1,2)); mapnik::box2d bbox = mapnik::geometry::envelope(geom); REQUIRE( bbox.minx() == 1 ); REQUIRE( bbox.miny() == 2 ); @@ -18,16 +18,16 @@ SECTION("envelope_test") { } { // Test empty geom - geometry geom(std::move(mapnik::geometry::geometry_empty())); + geometry geom(std::move(mapnik::geometry::geometry_empty())); mapnik::box2d bbox = mapnik::geometry::envelope(geom); REQUIRE_FALSE( bbox.valid() ); } { - line_string line; + line_string line; line.add_coord(0,0); line.add_coord(1,1); line.add_coord(2,2); - geometry geom(line); + geometry geom(line); mapnik::box2d bbox = mapnik::geometry::envelope(geom); REQUIRE( bbox.minx() == 0 ); REQUIRE( bbox.miny() == 0 ); @@ -35,18 +35,18 @@ SECTION("envelope_test") { REQUIRE( bbox.maxy() == 2 ); } { - line_string line; + line_string line; line.add_coord(0,0); line.add_coord(1,1); line.add_coord(2,2); - line_string line2; + line_string line2; line2.add_coord(0,0); line2.add_coord(-1,-1); line2.add_coord(-2,-2); - multi_line_string multi_line; + multi_line_string multi_line; multi_line.emplace_back(std::move(line)); multi_line.emplace_back(std::move(line2)); - geometry geom(multi_line); + geometry geom(multi_line); mapnik::box2d bbox = mapnik::geometry::envelope(geom); REQUIRE( bbox.minx() == -2 ); REQUIRE( bbox.miny() == -2 ); @@ -54,24 +54,24 @@ SECTION("envelope_test") { REQUIRE( bbox.maxy() == 2 ); } { - polygon poly; - linear_ring ring; + polygon poly; + linear_ring ring; ring.add_coord(0,0); ring.add_coord(-10,0); ring.add_coord(-10,10); ring.add_coord(0,10); ring.add_coord(0,0); poly.set_exterior_ring(std::move(ring)); - geometry geom(poly); + geometry geom(poly); mapnik::box2d bbox = mapnik::geometry::envelope(geom); REQUIRE( bbox.minx() == -10 ); REQUIRE( bbox.miny() == 0 ); REQUIRE( bbox.maxx() == 0 ); REQUIRE( bbox.maxy() == 10 ); - multi_polygon mp; + multi_polygon mp; mp.push_back(poly); - geometry geom_mp(mp); + geometry geom_mp(mp); bbox = mapnik::geometry::envelope(geom_mp); REQUIRE( bbox.minx() == -10 ); REQUIRE( bbox.miny() == 0 ); @@ -91,7 +91,7 @@ SECTION("envelope_test") { REQUIRE( bbox.maxx() == 0 ); REQUIRE( bbox.maxy() == 10 ); - geometry_collection gc; + geometry_collection gc; bbox = mapnik::geometry::envelope(gc); REQUIRE_FALSE( bbox.valid() ); gc.push_back(geom_mp); @@ -100,7 +100,7 @@ SECTION("envelope_test") { REQUIRE( bbox.miny() == 0 ); REQUIRE( bbox.maxx() == 0 ); REQUIRE( bbox.maxy() == 10 ); - gc.emplace_back(point(-50,-50)); + gc.emplace_back(point(-50,-50)); bbox = mapnik::geometry::envelope(gc); REQUIRE( bbox.minx() == -50 ); REQUIRE( bbox.miny() == -50 ); @@ -110,22 +110,22 @@ SECTION("envelope_test") { { // polygon with hole - polygon poly; - linear_ring ring; + polygon poly; + linear_ring ring; ring.add_coord(0,0); ring.add_coord(-10,0); ring.add_coord(-10,10); ring.add_coord(0,10); ring.add_coord(0,0); poly.set_exterior_ring(std::move(ring)); - linear_ring hole; + linear_ring hole; hole.add_coord(-7,7); hole.add_coord(-7,3); hole.add_coord(-3,3); hole.add_coord(-3,7); hole.add_coord(-7,7); poly.add_hole(std::move(hole)); - geometry geom(poly); + geometry geom(poly); mapnik::box2d bbox = mapnik::geometry::envelope(poly); REQUIRE( bbox.minx() == -10 ); REQUIRE( bbox.miny() == 0 ); @@ -133,7 +133,7 @@ SECTION("envelope_test") { REQUIRE( bbox.maxy() == 10 ); // add another hole inside the first hole // which should be considered a hit - linear_ring fill; + linear_ring fill; fill.add_coord(-6,4); fill.add_coord(-6,6); fill.add_coord(-4,6); diff --git a/tests/cxx/geometry_equal.hpp b/tests/cxx/geometry_equal.hpp index 1608bbf8e..8325895e7 100644 --- a/tests/cxx/geometry_equal.hpp +++ b/tests/cxx/geometry_equal.hpp @@ -79,7 +79,8 @@ auto zip_crange(Conts&... conts) using namespace mapnik::geometry; -void assert_g_equal(geometry const& g1, geometry const& g2); +template +void assert_g_equal(geometry const& g1, geometry const& g2); struct geometry_equal_visitor { @@ -95,13 +96,15 @@ struct geometry_equal_visitor REQUIRE(true); } - void operator() (point const& p1, point const& p2) + template + void operator() (point const& p1, point const& p2) { REQUIRE(p1.x == Approx(p2.x)); REQUIRE(p1.y == Approx(p2.y)); } - void operator() (line_string const& ls1, line_string const& ls2) + template + void operator() (line_string const& ls1, line_string const& ls2) { if (ls1.size() != ls2.size()) { @@ -115,9 +118,10 @@ struct geometry_equal_visitor } } - void operator() (polygon const& p1, polygon const& p2) + template + void operator() (polygon const& p1, polygon const& p2) { - (*this)(static_cast(p1.exterior_ring), static_cast(p2.exterior_ring)); + (*this)(static_cast const&>(p1.exterior_ring), static_cast const&>(p2.exterior_ring)); if (p1.interior_rings.size() != p2.interior_rings.size()) { @@ -126,16 +130,18 @@ struct geometry_equal_visitor for (auto const& p : zip_crange(p1.interior_rings, p2.interior_rings)) { - (*this)(static_cast(p.get<0>()),static_cast(p.get<1>())); + (*this)(static_cast const&>(p.get<0>()),static_cast const&>(p.get<1>())); } } - void operator() (multi_point const& mp1, multi_point const& mp2) + template + void operator() (multi_point const& mp1, multi_point const& mp2) { - (*this)(static_cast(mp1), static_cast(mp2)); + (*this)(static_cast const&>(mp1), static_cast const&>(mp2)); } - void operator() (multi_line_string const& mls1, multi_line_string const& mls2) + template + void operator() (multi_line_string const& mls1, multi_line_string const& mls2) { if (mls1.size() != mls2.size()) { @@ -148,7 +154,8 @@ struct geometry_equal_visitor } } - void operator() (multi_polygon const& mpoly1, multi_polygon const& mpoly2) + template + void operator() (multi_polygon const& mpoly1, multi_polygon const& mpoly2) { if (mpoly1.size() != mpoly2.size()) { @@ -161,10 +168,11 @@ struct geometry_equal_visitor } } - void operator() (mapnik::util::recursive_wrapper const& c1_, mapnik::util::recursive_wrapper const& c2_) + template + void operator() (mapnik::util::recursive_wrapper > const& c1_, mapnik::util::recursive_wrapper > const& c2_) { - geometry_collection const& c1 = static_cast(c1_); - geometry_collection const& c2 = static_cast(c2_); + geometry_collection const& c1 = static_cast const&>(c1_); + geometry_collection const& c2 = static_cast const&>(c2_); if (c1.size() != c2.size()) { REQUIRE(false); @@ -176,7 +184,8 @@ struct geometry_equal_visitor } } - void operator() (geometry_collection const& c1, geometry_collection const& c2) + template + void operator() (geometry_collection const& c1, geometry_collection const& c2) { if (c1.size() != c2.size()) { @@ -190,7 +199,8 @@ struct geometry_equal_visitor } }; -void assert_g_equal(geometry const& g1, geometry const& g2) +template +void assert_g_equal(geometry const& g1, geometry const& g2) { return mapnik::util::apply_visitor(geometry_equal_visitor(), g1, g2); } diff --git a/tests/cxx/geometry_hit_test.cpp b/tests/cxx/geometry_hit_test.cpp index ad9538165..7552d0143 100644 --- a/tests/cxx/geometry_hit_test.cpp +++ b/tests/cxx/geometry_hit_test.cpp @@ -6,57 +6,57 @@ TEST_CASE("geometry ops") { -SECTION("hit_test_filter") { +SECTION("hit_test_filter - double") { using namespace mapnik::geometry; { - geometry geom(point(0,0)); + geometry geom(point(0,0)); REQUIRE( mapnik::hit_test(geom,0,0,0) ); } { - geometry geom(point(0,0)); + geometry geom(point(0,0)); REQUIRE( mapnik::hit_test(geom,1,0,1) ); } { - geometry geom(point(0,0)); + geometry geom(point(0,0)); REQUIRE( mapnik::hit_test(geom,0,1,1) ); } { - geometry geom(point(0,0)); + geometry geom(point(0,0)); REQUIRE( mapnik::hit_test(geom,1,1,1.5) ); } { - line_string line; + line_string line; line.add_coord(0,0); line.add_coord(1,1); line.add_coord(2,2); - geometry geom(line); + geometry geom(line); REQUIRE( mapnik::hit_test(geom,0,0,1.5) ); } { - line_string line; + line_string line; line.add_coord(0,0); line.add_coord(1,1); line.add_coord(2,2); - multi_line_string multi_line; + multi_line_string multi_line; multi_line.emplace_back(std::move(line)); - geometry geom(multi_line); + geometry geom(multi_line); REQUIRE( mapnik::hit_test(geom,0,0,1.5) ); } { - polygon poly; - linear_ring ring; + polygon poly; + linear_ring ring; ring.add_coord(0,0); ring.add_coord(-10,0); ring.add_coord(-10,10); ring.add_coord(0,10); ring.add_coord(0,0); poly.set_exterior_ring(std::move(ring)); - geometry geom(poly); + geometry geom(poly); REQUIRE( mapnik::hit_test(geom,-5,5,0) ); - multi_polygon mp; + multi_polygon mp; mp.push_back(poly); - geometry geom_mp(mp); + geometry geom_mp(mp); REQUIRE( mapnik::hit_test(geom_mp,-5,5,0) ); correct(geom); @@ -64,44 +64,44 @@ SECTION("hit_test_filter") { correct(geom_mp); REQUIRE( mapnik::hit_test(geom_mp,-5,5,0) ); - geometry_collection gc; - REQUIRE( !mapnik::hit_test(geometry(gc),-5,5,0) ); + geometry_collection gc; + REQUIRE( !mapnik::hit_test(geometry(gc),-5,5,0) ); gc.push_back(geom_mp); - REQUIRE( mapnik::hit_test(geometry(gc),-5,5,0) ); - REQUIRE( !mapnik::hit_test(geometry(gc),-50,-50,0) ); - gc.emplace_back(point(-50,-50)); - REQUIRE( mapnik::hit_test(geometry(gc),-50,-50,0) ); + REQUIRE( mapnik::hit_test(geometry(gc),-5,5,0) ); + REQUIRE( !mapnik::hit_test(geometry(gc),-50,-50,0) ); + gc.emplace_back(point(-50,-50)); + REQUIRE( mapnik::hit_test(geometry(gc),-50,-50,0) ); } { // polygon with hole - polygon poly; - linear_ring ring; + polygon poly; + linear_ring ring; ring.add_coord(0,0); ring.add_coord(-10,0); ring.add_coord(-10,10); ring.add_coord(0,10); ring.add_coord(0,0); poly.set_exterior_ring(std::move(ring)); - linear_ring hole; + linear_ring hole; hole.add_coord(-7,7); hole.add_coord(-7,3); hole.add_coord(-3,3); hole.add_coord(-3,7); hole.add_coord(-7,7); poly.add_hole(std::move(hole)); - geometry geom(poly); + geometry geom(poly); REQUIRE( !mapnik::hit_test(geom,-5,5,0) ); // add another hole inside the first hole // which should be considered a hit - linear_ring fill; + linear_ring fill; fill.add_coord(-6,4); fill.add_coord(-6,6); fill.add_coord(-4,6); fill.add_coord(-4,4); fill.add_coord(-6,4); poly.add_hole(std::move(fill)); - REQUIRE( mapnik::hit_test(geometry(poly),-5,5,0) ); + REQUIRE( mapnik::hit_test(geometry(poly),-5,5,0) ); } } diff --git a/tests/cxx/geometry_reprojection.cpp b/tests/cxx/geometry_reprojection.cpp index 59a9d1cc1..988d44979 100644 --- a/tests/cxx/geometry_reprojection.cpp +++ b/tests/cxx/geometry_reprojection.cpp @@ -45,10 +45,10 @@ SECTION("test_projection_4326_3857 - Empty Geometry in Geometry Variant") { mapnik::projection dest("+init=epsg:3857"); mapnik::proj_transform proj_trans(source, dest); { - geometry geom(std::move(geometry_empty())); + geometry geom(std::move(geometry_empty())); unsigned int err = 0; // Test Standard Transform - geometry new_geom = reproject_copy(geom, proj_trans, err); + geometry new_geom = reproject_copy(geom, proj_trans, err); REQUIRE(err == 0); REQUIRE(new_geom.is()); // Transform providing projections not transfrom @@ -74,36 +74,36 @@ SECTION("test_projection_4326_3857 - Point Geometry Object") { mapnik::projection dest("+init=epsg:3857"); mapnik::proj_transform proj_trans1(source, dest); mapnik::proj_transform proj_trans2(dest, source); - point geom1(-97.552175, 35.522895); - point geom2(-10859458.446776, 4235169.496066); + point geom1(-97.552175, 35.522895); + point geom2(-10859458.446776, 4235169.496066); unsigned int err = 0; { // Test Standard Transform - point new_geom = reproject_copy(geom1, proj_trans1, err); + point new_geom = reproject_copy(geom1, proj_trans1, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform in reverse - point new_geom = reproject_copy(geom2, proj_trans2, err); + point new_geom = reproject_copy(geom2, proj_trans2, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform providing projections not transfrom - point new_geom = reproject_copy(geom1, source, dest, err); + point new_geom = reproject_copy(geom1, source, dest, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform providing projections in reverse - point new_geom = reproject_copy(geom2, dest, source, err); + point new_geom = reproject_copy(geom2, dest, source, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform in place - point geom3(-97.552175, 35.522895); + point geom3(-97.552175, 35.522895); REQUIRE(reproject(geom3, proj_trans1)); assert_g_equal(geom3, geom2); // Transform in place reverse - back @@ -112,7 +112,7 @@ SECTION("test_projection_4326_3857 - Point Geometry Object") { } { // Transform in place providing projections - point geom3(-97.552175, 35.522895); + point geom3(-97.552175, 35.522895); REQUIRE(reproject(geom3, source, dest)); assert_g_equal(geom3, geom2); // Transform in place provoding projections reversed @@ -131,35 +131,35 @@ SECTION("test_projection_4326_3857 - Point Geometry Variant Object") { double y1 = 35.522895; double x2 = -10859458.446776; double y2 = 4235169.496066; - geometry geom1(point(x1, y1)); - geometry geom2(point(x2, y2)); + geometry geom1(point(x1, y1)); + geometry geom2(point(x2, y2)); unsigned int err = 0; { // Test Standard Transform - geometry new_geom = reproject_copy(geom1, proj_trans1, err); + geometry new_geom = reproject_copy(geom1, proj_trans1, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform in reverse - geometry new_geom = reproject_copy(geom2, proj_trans2, err); + geometry new_geom = reproject_copy(geom2, proj_trans2, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform providing projections not transfrom - geometry new_geom = reproject_copy(geom1, source, dest, err); + geometry new_geom = reproject_copy(geom1, source, dest, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform providing projections in reverse - geometry new_geom = reproject_copy(geom2, dest, source, err); + geometry new_geom = reproject_copy(geom2, dest, source, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { - geometry geom3(point(-97.552175, 35.522895)); + geometry geom3(point(-97.552175, 35.522895)); // Transform in place REQUIRE(reproject(geom3, proj_trans1)); assert_g_equal(geom3, geom2); @@ -168,7 +168,7 @@ SECTION("test_projection_4326_3857 - Point Geometry Variant Object") { assert_g_equal(geom3, geom1); } { - geometry geom3(point(-97.552175, 35.522895)); + geometry geom3(point(-97.552175, 35.522895)); // Transform in place providing projections REQUIRE(reproject(geom3, source, dest)); assert_g_equal(geom3, geom2); @@ -184,48 +184,48 @@ SECTION("test_projection_4326_3857 - Line_String Geometry Object") { mapnik::projection dest("+init=epsg:3857"); mapnik::proj_transform proj_trans1(source, dest); mapnik::proj_transform proj_trans2(dest, source); - line_string geom1; - geom1.emplace_back(point(-97.48872756958008, 35.360286150765084)); - geom1.emplace_back(point(-97.48065948486328, 35.34894577151337)); - geom1.emplace_back(point(-97.47267723083496, 35.36224605490395)); - geom1.emplace_back(point(-97.46323585510252, 35.34523530173256)); - geom1.emplace_back(point(-97.45963096618651, 35.36329598397908)); - geom1.emplace_back(point(-97.47550964355469, 35.369245324153866)); - line_string geom2; - geom2.emplace_back(point(-10852395.511130, 4212951.024108)); - geom2.emplace_back(point(-10851497.376047, 4211403.174286)); - geom2.emplace_back(point(-10850608.795594, 4213218.553707)); - geom2.emplace_back(point(-10849557.786455, 4210896.778973)); - geom2.emplace_back(point(-10849156.492056, 4213361.873135)); - geom2.emplace_back(point(-10850924.098335, 4214174.016561)); + line_string geom1; + geom1.emplace_back(point(-97.48872756958008, 35.360286150765084)); + geom1.emplace_back(point(-97.48065948486328, 35.34894577151337)); + geom1.emplace_back(point(-97.47267723083496, 35.36224605490395)); + geom1.emplace_back(point(-97.46323585510252, 35.34523530173256)); + geom1.emplace_back(point(-97.45963096618651, 35.36329598397908)); + geom1.emplace_back(point(-97.47550964355469, 35.369245324153866)); + line_string geom2; + geom2.emplace_back(point(-10852395.511130, 4212951.024108)); + geom2.emplace_back(point(-10851497.376047, 4211403.174286)); + geom2.emplace_back(point(-10850608.795594, 4213218.553707)); + geom2.emplace_back(point(-10849557.786455, 4210896.778973)); + geom2.emplace_back(point(-10849156.492056, 4213361.873135)); + geom2.emplace_back(point(-10850924.098335, 4214174.016561)); unsigned int err = 0; { // Test Standard Transform - line_string new_geom = reproject_copy(geom1, proj_trans1, err); + line_string new_geom = reproject_copy(geom1, proj_trans1, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform in reverse - line_string new_geom = reproject_copy(geom2, proj_trans2, err); + line_string new_geom = reproject_copy(geom2, proj_trans2, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform providing projections not transfrom - line_string new_geom = reproject_copy(geom1, source, dest, err); + line_string new_geom = reproject_copy(geom1, source, dest, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform providing projections in reverse - line_string new_geom = reproject_copy(geom2, dest, source, err); + line_string new_geom = reproject_copy(geom2, dest, source, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform in place - line_string geom3(geom1); + line_string geom3(geom1); REQUIRE(reproject(geom3, proj_trans1)); assert_g_equal(geom3, geom2); // Transform in place reverse @@ -234,7 +234,7 @@ SECTION("test_projection_4326_3857 - Line_String Geometry Object") { } { // Transform in place providing projections - line_string geom3(geom1); + line_string geom3(geom1); REQUIRE(reproject(geom3, source, dest)); assert_g_equal(geom3, geom2); // Transform in place provoding projections reversed @@ -249,58 +249,58 @@ SECTION("test_projection_4326_3857 - Line_String Geometry Variant Object") { mapnik::projection dest("+init=epsg:3857"); mapnik::proj_transform proj_trans1(source, dest); mapnik::proj_transform proj_trans2(dest, source); - line_string geom1_; - geom1_.emplace_back(point(-97.48872756958008, 35.360286150765084)); - geom1_.emplace_back(point(-97.48065948486328, 35.34894577151337)); - geom1_.emplace_back(point(-97.47267723083496, 35.36224605490395)); - geom1_.emplace_back(point(-97.46323585510252, 35.34523530173256)); - geom1_.emplace_back(point(-97.45963096618651, 35.36329598397908)); - geom1_.emplace_back(point(-97.47550964355469, 35.369245324153866)); - line_string geom2_; - geom2_.emplace_back(point(-10852395.511130, 4212951.024108)); - geom2_.emplace_back(point(-10851497.376047, 4211403.174286)); - geom2_.emplace_back(point(-10850608.795594, 4213218.553707)); - geom2_.emplace_back(point(-10849557.786455, 4210896.778973)); - geom2_.emplace_back(point(-10849156.492056, 4213361.873135)); - geom2_.emplace_back(point(-10850924.098335, 4214174.016561)); - line_string geom0_; - geometry geom0(geom0_); - geometry geom1(geom1_); - geometry geom2(geom2_); + line_string geom1_; + geom1_.emplace_back(point(-97.48872756958008, 35.360286150765084)); + geom1_.emplace_back(point(-97.48065948486328, 35.34894577151337)); + geom1_.emplace_back(point(-97.47267723083496, 35.36224605490395)); + geom1_.emplace_back(point(-97.46323585510252, 35.34523530173256)); + geom1_.emplace_back(point(-97.45963096618651, 35.36329598397908)); + geom1_.emplace_back(point(-97.47550964355469, 35.369245324153866)); + line_string geom2_; + geom2_.emplace_back(point(-10852395.511130, 4212951.024108)); + geom2_.emplace_back(point(-10851497.376047, 4211403.174286)); + geom2_.emplace_back(point(-10850608.795594, 4213218.553707)); + geom2_.emplace_back(point(-10849557.786455, 4210896.778973)); + geom2_.emplace_back(point(-10849156.492056, 4213361.873135)); + geom2_.emplace_back(point(-10850924.098335, 4214174.016561)); + line_string geom0_; + geometry geom0(geom0_); + geometry geom1(geom1_); + geometry geom2(geom2_); unsigned int err = 0; { // Reprojecting empty line string will return a geometry_empty - geometry new_geom = reproject_copy(geom0, proj_trans1, err); + geometry new_geom = reproject_copy(geom0, proj_trans1, err); REQUIRE(err == 0); REQUIRE(new_geom.is()); } { // Test Standard Transform - geometry new_geom = reproject_copy(geom1, proj_trans1, err); + geometry new_geom = reproject_copy(geom1, proj_trans1, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform in reverse - geometry new_geom = reproject_copy(geom2, proj_trans2, err); + geometry new_geom = reproject_copy(geom2, proj_trans2, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform providing projections not transfrom - geometry new_geom = reproject_copy(geom1, source, dest, err); + geometry new_geom = reproject_copy(geom1, source, dest, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform providing projections in reverse - geometry new_geom = reproject_copy(geom2, dest, source, err); + geometry new_geom = reproject_copy(geom2, dest, source, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform in place - geometry geom3(geom1); + geometry geom3(geom1); REQUIRE(reproject(geom3, proj_trans1)); assert_g_equal(geom3, geom2); // Transform in place reverse @@ -309,7 +309,7 @@ SECTION("test_projection_4326_3857 - Line_String Geometry Variant Object") { } { // Transform in place providing projections - geometry geom3(geom1); + geometry geom3(geom1); REQUIRE(reproject(geom3, source, dest)); assert_g_equal(geom3, geom2); // Transform in place provoding projections reversed @@ -324,37 +324,37 @@ SECTION("test_projection_4326_3857 - Polygon Geometry Object") { mapnik::projection dest("+init=epsg:3857"); mapnik::proj_transform proj_trans1(source, dest); mapnik::proj_transform proj_trans2(dest, source); - polygon geom1; - geom1.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); - geom1.exterior_ring.emplace_back(point(-97.79067993164062, 35.43941441533686)); - geom1.exterior_ring.emplace_back(point(-97.60391235351562, 35.34425514918409)); - geom1.exterior_ring.emplace_back(point(-97.42813110351562, 35.48191987272801)); - geom1.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); + polygon geom1; + geom1.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); + geom1.exterior_ring.emplace_back(point(-97.79067993164062, 35.43941441533686)); + geom1.exterior_ring.emplace_back(point(-97.60391235351562, 35.34425514918409)); + geom1.exterior_ring.emplace_back(point(-97.42813110351562, 35.48191987272801)); + geom1.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); geom1.interior_rings.emplace_back(); - geom1.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); - geom1.interior_rings.back().emplace_back(point(-97.61489868164062, 35.54116627999813)); - geom1.interior_rings.back().emplace_back(point(-97.53799438476562, 35.459551379037606)); - geom1.interior_rings.back().emplace_back(point(-97.62451171875, 35.42598697382711)); - geom1.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); - polygon geom2; - geom2.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); - geom2.exterior_ring.emplace_back(point(-10886008.694318, 4223757.308982)); - geom2.exterior_ring.emplace_back(point(-10865217.822625, 4210763.014174)); - geom2.exterior_ring.emplace_back(point(-10845649.943384, 4229566.523132)); - geom2.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); + geom1.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); + geom1.interior_rings.back().emplace_back(point(-97.61489868164062, 35.54116627999813)); + geom1.interior_rings.back().emplace_back(point(-97.53799438476562, 35.459551379037606)); + geom1.interior_rings.back().emplace_back(point(-97.62451171875, 35.42598697382711)); + geom1.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); + polygon geom2; + geom2.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); + geom2.exterior_ring.emplace_back(point(-10886008.694318, 4223757.308982)); + geom2.exterior_ring.emplace_back(point(-10865217.822625, 4210763.014174)); + geom2.exterior_ring.emplace_back(point(-10845649.943384, 4229566.523132)); + geom2.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); geom2.interior_rings.emplace_back(); - geom2.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); - geom2.interior_rings.back().emplace_back(point(-10866440.815077, 4237668.848130)); - geom2.interior_rings.back().emplace_back(point(-10857879.867909, 4226509.042001)); - geom2.interior_rings.back().emplace_back(point(-10867510.933473, 4221922.820303)); - geom2.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); + geom2.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); + geom2.interior_rings.back().emplace_back(point(-10866440.815077, 4237668.848130)); + geom2.interior_rings.back().emplace_back(point(-10857879.867909, 4226509.042001)); + geom2.interior_rings.back().emplace_back(point(-10867510.933473, 4221922.820303)); + geom2.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); unsigned int err = 0; { // Test Standard Transform // Add extra vector to outer ring. geom1.interior_rings.emplace_back(); REQUIRE(geom1.interior_rings.size() == 2); - polygon new_geom = reproject_copy(geom1, proj_trans1, err); + polygon new_geom = reproject_copy(geom1, proj_trans1, err); REQUIRE(err == 0); // Should remove the empty ring added to back of geom1 REQUIRE(new_geom.interior_rings.size() == 1); @@ -365,25 +365,25 @@ SECTION("test_projection_4326_3857 - Polygon Geometry Object") { } { // Transform in reverse - polygon new_geom = reproject_copy(geom2, proj_trans2, err); + polygon new_geom = reproject_copy(geom2, proj_trans2, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform providing projections not transfrom - polygon new_geom = reproject_copy(geom1, source, dest, err); + polygon new_geom = reproject_copy(geom1, source, dest, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform providing projections in reverse - polygon new_geom = reproject_copy(geom2, dest, source, err); + polygon new_geom = reproject_copy(geom2, dest, source, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform in place - polygon geom3(geom1); + polygon geom3(geom1); geom3.interior_rings.emplace_back(); REQUIRE(reproject(geom3, proj_trans1)); // Should NOT remove the empty ring added to back of geom1 @@ -398,7 +398,7 @@ SECTION("test_projection_4326_3857 - Polygon Geometry Object") { } { // Transform in place providing projections - polygon geom3(geom1); + polygon geom3(geom1); REQUIRE(reproject(geom3, source, dest)); assert_g_equal(geom3, geom2); // Transform in place provoding projections reversed @@ -413,68 +413,68 @@ SECTION("test_projection_4326_3857 - Polygon Geometry Variant Object") { mapnik::projection dest("+init=epsg:3857"); mapnik::proj_transform proj_trans1(source, dest); mapnik::proj_transform proj_trans2(dest, source); - polygon geom1_; - geom1_.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); - geom1_.exterior_ring.emplace_back(point(-97.79067993164062, 35.43941441533686)); - geom1_.exterior_ring.emplace_back(point(-97.60391235351562, 35.34425514918409)); - geom1_.exterior_ring.emplace_back(point(-97.42813110351562, 35.48191987272801)); - geom1_.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); + polygon geom1_; + geom1_.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); + geom1_.exterior_ring.emplace_back(point(-97.79067993164062, 35.43941441533686)); + geom1_.exterior_ring.emplace_back(point(-97.60391235351562, 35.34425514918409)); + geom1_.exterior_ring.emplace_back(point(-97.42813110351562, 35.48191987272801)); + geom1_.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); geom1_.interior_rings.emplace_back(); - geom1_.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); - geom1_.interior_rings.back().emplace_back(point(-97.61489868164062, 35.54116627999813)); - geom1_.interior_rings.back().emplace_back(point(-97.53799438476562, 35.459551379037606)); - geom1_.interior_rings.back().emplace_back(point(-97.62451171875, 35.42598697382711)); - geom1_.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); - polygon geom2_; - geom2_.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); - geom2_.exterior_ring.emplace_back(point(-10886008.694318, 4223757.308982)); - geom2_.exterior_ring.emplace_back(point(-10865217.822625, 4210763.014174)); - geom2_.exterior_ring.emplace_back(point(-10845649.943384, 4229566.523132)); - geom2_.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); + geom1_.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); + geom1_.interior_rings.back().emplace_back(point(-97.61489868164062, 35.54116627999813)); + geom1_.interior_rings.back().emplace_back(point(-97.53799438476562, 35.459551379037606)); + geom1_.interior_rings.back().emplace_back(point(-97.62451171875, 35.42598697382711)); + geom1_.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); + polygon geom2_; + geom2_.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); + geom2_.exterior_ring.emplace_back(point(-10886008.694318, 4223757.308982)); + geom2_.exterior_ring.emplace_back(point(-10865217.822625, 4210763.014174)); + geom2_.exterior_ring.emplace_back(point(-10845649.943384, 4229566.523132)); + geom2_.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); geom2_.interior_rings.emplace_back(); - geom2_.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); - geom2_.interior_rings.back().emplace_back(point(-10866440.815077, 4237668.848130)); - geom2_.interior_rings.back().emplace_back(point(-10857879.867909, 4226509.042001)); - geom2_.interior_rings.back().emplace_back(point(-10867510.933473, 4221922.820303)); - geom2_.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); - polygon geom0_; - geometry geom0(geom0_); - geometry geom1(geom1_); - geometry geom2(geom2_); + geom2_.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); + geom2_.interior_rings.back().emplace_back(point(-10866440.815077, 4237668.848130)); + geom2_.interior_rings.back().emplace_back(point(-10857879.867909, 4226509.042001)); + geom2_.interior_rings.back().emplace_back(point(-10867510.933473, 4221922.820303)); + geom2_.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); + polygon geom0_; + geometry geom0(geom0_); + geometry geom1(geom1_); + geometry geom2(geom2_); unsigned int err = 0; { // Reprojecting empty poly will return a geometry_empty - geometry new_geom = reproject_copy(geom0, proj_trans1, err); + geometry new_geom = reproject_copy(geom0, proj_trans1, err); REQUIRE(err == 0); REQUIRE(new_geom.is()); } { // Test Standard Transform - geometry new_geom = reproject_copy(geom1, proj_trans1, err); + geometry new_geom = reproject_copy(geom1, proj_trans1, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform in reverse - geometry new_geom = reproject_copy(geom2, proj_trans2, err); + geometry new_geom = reproject_copy(geom2, proj_trans2, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform providing projections not transfrom - geometry new_geom = reproject_copy(geom1, source, dest, err); + geometry new_geom = reproject_copy(geom1, source, dest, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform providing projections in reverse - geometry new_geom = reproject_copy(geom2, dest, source, err); + geometry new_geom = reproject_copy(geom2, dest, source, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform in place - geometry geom3(geom1); + geometry geom3(geom1); REQUIRE(reproject(geom3, proj_trans1)); assert_g_equal(geom3, geom2); // Transform in place reverse @@ -483,7 +483,7 @@ SECTION("test_projection_4326_3857 - Polygon Geometry Variant Object") { } { // Transform in place providing projections - geometry geom3(geom1); + geometry geom3(geom1); REQUIRE(reproject(geom3, source, dest)); assert_g_equal(geom3, geom2); // Transform in place provoding projections reversed @@ -498,48 +498,48 @@ SECTION("test_projection_4326_3857 - Multi_Point Geometry Object") { mapnik::projection dest("+init=epsg:3857"); mapnik::proj_transform proj_trans1(source, dest); mapnik::proj_transform proj_trans2(dest, source); - multi_point geom1; - geom1.emplace_back(point(-97.48872756958008, 35.360286150765084)); - geom1.emplace_back(point(-97.48065948486328, 35.34894577151337)); - geom1.emplace_back(point(-97.47267723083496, 35.36224605490395)); - geom1.emplace_back(point(-97.46323585510252, 35.34523530173256)); - geom1.emplace_back(point(-97.45963096618651, 35.36329598397908)); - geom1.emplace_back(point(-97.47550964355469, 35.369245324153866)); - multi_point geom2; - geom2.emplace_back(point(-10852395.511130, 4212951.024108)); - geom2.emplace_back(point(-10851497.376047, 4211403.174286)); - geom2.emplace_back(point(-10850608.795594, 4213218.553707)); - geom2.emplace_back(point(-10849557.786455, 4210896.778973)); - geom2.emplace_back(point(-10849156.492056, 4213361.873135)); - geom2.emplace_back(point(-10850924.098335, 4214174.016561)); + multi_point geom1; + geom1.emplace_back(point(-97.48872756958008, 35.360286150765084)); + geom1.emplace_back(point(-97.48065948486328, 35.34894577151337)); + geom1.emplace_back(point(-97.47267723083496, 35.36224605490395)); + geom1.emplace_back(point(-97.46323585510252, 35.34523530173256)); + geom1.emplace_back(point(-97.45963096618651, 35.36329598397908)); + geom1.emplace_back(point(-97.47550964355469, 35.369245324153866)); + multi_point geom2; + geom2.emplace_back(point(-10852395.511130, 4212951.024108)); + geom2.emplace_back(point(-10851497.376047, 4211403.174286)); + geom2.emplace_back(point(-10850608.795594, 4213218.553707)); + geom2.emplace_back(point(-10849557.786455, 4210896.778973)); + geom2.emplace_back(point(-10849156.492056, 4213361.873135)); + geom2.emplace_back(point(-10850924.098335, 4214174.016561)); unsigned int err = 0; { // Test Standard Transform - multi_point new_geom = reproject_copy(geom1, proj_trans1, err); + multi_point new_geom = reproject_copy(geom1, proj_trans1, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform in reverse - multi_point new_geom = reproject_copy(geom2, proj_trans2, err); + multi_point new_geom = reproject_copy(geom2, proj_trans2, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform providing projections not transfrom - multi_point new_geom = reproject_copy(geom1, source, dest, err); + multi_point new_geom = reproject_copy(geom1, source, dest, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform providing projections in reverse - multi_point new_geom = reproject_copy(geom2, dest, source, err); + multi_point new_geom = reproject_copy(geom2, dest, source, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform in place - multi_point geom3(geom1); + multi_point geom3(geom1); REQUIRE(reproject(geom3, proj_trans1)); assert_g_equal(geom3, geom2); // Transform in place reverse @@ -548,7 +548,7 @@ SECTION("test_projection_4326_3857 - Multi_Point Geometry Object") { } { // Transform in place providing projections - multi_point geom3(geom1); + multi_point geom3(geom1); REQUIRE(reproject(geom3, source, dest)); assert_g_equal(geom3, geom2); // Transform in place provoding projections reversed @@ -563,58 +563,58 @@ SECTION("test_projection_4326_3857 - Multi_Point Geometry Variant Object") { mapnik::projection dest("+init=epsg:3857"); mapnik::proj_transform proj_trans1(source, dest); mapnik::proj_transform proj_trans2(dest, source); - multi_point geom1_; - geom1_.emplace_back(point(-97.48872756958008, 35.360286150765084)); - geom1_.emplace_back(point(-97.48065948486328, 35.34894577151337)); - geom1_.emplace_back(point(-97.47267723083496, 35.36224605490395)); - geom1_.emplace_back(point(-97.46323585510252, 35.34523530173256)); - geom1_.emplace_back(point(-97.45963096618651, 35.36329598397908)); - geom1_.emplace_back(point(-97.47550964355469, 35.369245324153866)); - multi_point geom2_; - geom2_.emplace_back(point(-10852395.511130, 4212951.024108)); - geom2_.emplace_back(point(-10851497.376047, 4211403.174286)); - geom2_.emplace_back(point(-10850608.795594, 4213218.553707)); - geom2_.emplace_back(point(-10849557.786455, 4210896.778973)); - geom2_.emplace_back(point(-10849156.492056, 4213361.873135)); - geom2_.emplace_back(point(-10850924.098335, 4214174.016561)); - multi_point geom0_; - geometry geom0(geom0_); - geometry geom1(geom1_); - geometry geom2(geom2_); + multi_point geom1_; + geom1_.emplace_back(point(-97.48872756958008, 35.360286150765084)); + geom1_.emplace_back(point(-97.48065948486328, 35.34894577151337)); + geom1_.emplace_back(point(-97.47267723083496, 35.36224605490395)); + geom1_.emplace_back(point(-97.46323585510252, 35.34523530173256)); + geom1_.emplace_back(point(-97.45963096618651, 35.36329598397908)); + geom1_.emplace_back(point(-97.47550964355469, 35.369245324153866)); + multi_point geom2_; + geom2_.emplace_back(point(-10852395.511130, 4212951.024108)); + geom2_.emplace_back(point(-10851497.376047, 4211403.174286)); + geom2_.emplace_back(point(-10850608.795594, 4213218.553707)); + geom2_.emplace_back(point(-10849557.786455, 4210896.778973)); + geom2_.emplace_back(point(-10849156.492056, 4213361.873135)); + geom2_.emplace_back(point(-10850924.098335, 4214174.016561)); + multi_point geom0_; + geometry geom0(geom0_); + geometry geom1(geom1_); + geometry geom2(geom2_); unsigned int err = 0; { // Reprojecting empty multi point will return a geometry_empty - geometry new_geom = reproject_copy(geom0, proj_trans1, err); + geometry new_geom = reproject_copy(geom0, proj_trans1, err); REQUIRE(err == 0); REQUIRE(new_geom.is()); } { // Test Standard Transform - geometry new_geom = reproject_copy(geom1, proj_trans1, err); + geometry new_geom = reproject_copy(geom1, proj_trans1, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform in reverse - geometry new_geom = reproject_copy(geom2, proj_trans2, err); + geometry new_geom = reproject_copy(geom2, proj_trans2, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform providing projections not transfrom - geometry new_geom = reproject_copy(geom1, source, dest, err); + geometry new_geom = reproject_copy(geom1, source, dest, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform providing projections in reverse - geometry new_geom = reproject_copy(geom2, dest, source, err); + geometry new_geom = reproject_copy(geom2, dest, source, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform in place - geometry geom3(geom1); + geometry geom3(geom1); REQUIRE(reproject(geom3, proj_trans1)); assert_g_equal(geom3, geom2); // Transform in place reverse @@ -623,7 +623,7 @@ SECTION("test_projection_4326_3857 - Multi_Point Geometry Variant Object") { } { // Transform in place providing projections - geometry geom3(geom1); + geometry geom3(geom1); REQUIRE(reproject(geom3, source, dest)); assert_g_equal(geom3, geom2); // Transform in place provoding projections reversed @@ -638,23 +638,23 @@ SECTION("test_projection_4326_3857 - Multi_Line_String Geometry Object") { mapnik::projection dest("+init=epsg:3857"); mapnik::proj_transform proj_trans1(source, dest); mapnik::proj_transform proj_trans2(dest, source); - line_string geom1a; - geom1a.emplace_back(point(-97.48872756958008, 35.360286150765084)); - geom1a.emplace_back(point(-97.48065948486328, 35.34894577151337)); - geom1a.emplace_back(point(-97.47267723083496, 35.36224605490395)); - geom1a.emplace_back(point(-97.46323585510252, 35.34523530173256)); - geom1a.emplace_back(point(-97.45963096618651, 35.36329598397908)); - geom1a.emplace_back(point(-97.47550964355469, 35.369245324153866)); - multi_line_string geom1; + line_string geom1a; + geom1a.emplace_back(point(-97.48872756958008, 35.360286150765084)); + geom1a.emplace_back(point(-97.48065948486328, 35.34894577151337)); + geom1a.emplace_back(point(-97.47267723083496, 35.36224605490395)); + geom1a.emplace_back(point(-97.46323585510252, 35.34523530173256)); + geom1a.emplace_back(point(-97.45963096618651, 35.36329598397908)); + geom1a.emplace_back(point(-97.47550964355469, 35.369245324153866)); + multi_line_string geom1; geom1.emplace_back(geom1a); - line_string geom2a; - geom2a.emplace_back(point(-10852395.511130, 4212951.024108)); - geom2a.emplace_back(point(-10851497.376047, 4211403.174286)); - geom2a.emplace_back(point(-10850608.795594, 4213218.553707)); - geom2a.emplace_back(point(-10849557.786455, 4210896.778973)); - geom2a.emplace_back(point(-10849156.492056, 4213361.873135)); - geom2a.emplace_back(point(-10850924.098335, 4214174.016561)); - multi_line_string geom2; + line_string geom2a; + geom2a.emplace_back(point(-10852395.511130, 4212951.024108)); + geom2a.emplace_back(point(-10851497.376047, 4211403.174286)); + geom2a.emplace_back(point(-10850608.795594, 4213218.553707)); + geom2a.emplace_back(point(-10849557.786455, 4210896.778973)); + geom2a.emplace_back(point(-10849156.492056, 4213361.873135)); + geom2a.emplace_back(point(-10850924.098335, 4214174.016561)); + multi_line_string geom2; geom2.emplace_back(geom2a); unsigned int err = 0; { @@ -663,7 +663,7 @@ SECTION("test_projection_4326_3857 - Multi_Line_String Geometry Object") { geom1.emplace_back(); REQUIRE(geom1.size() == 2); // Test Standard Transform - multi_line_string new_geom = reproject_copy(geom1, proj_trans1, err); + multi_line_string new_geom = reproject_copy(geom1, proj_trans1, err); REQUIRE(err == 0); REQUIRE(new_geom.size() == 1); // Restore geom1 removing empty for later tests. @@ -673,25 +673,25 @@ SECTION("test_projection_4326_3857 - Multi_Line_String Geometry Object") { } { // Transform in reverse - multi_line_string new_geom = reproject_copy(geom2, proj_trans2, err); + multi_line_string new_geom = reproject_copy(geom2, proj_trans2, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform providing projections not transfrom - multi_line_string new_geom = reproject_copy(geom1, source, dest, err); + multi_line_string new_geom = reproject_copy(geom1, source, dest, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform providing projections in reverse - multi_line_string new_geom = reproject_copy(geom2, dest, source, err); + multi_line_string new_geom = reproject_copy(geom2, dest, source, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform in place - multi_line_string geom3(geom1); + multi_line_string geom3(geom1); REQUIRE(reproject(geom3, proj_trans1)); assert_g_equal(geom3, geom2); // Transform in place reverse @@ -700,7 +700,7 @@ SECTION("test_projection_4326_3857 - Multi_Line_String Geometry Object") { } { // Transform in place providing projections - multi_line_string geom3(geom1); + multi_line_string geom3(geom1); REQUIRE(reproject(geom3, source, dest)); assert_g_equal(geom3, geom2); // Transform in place provoding projections reversed @@ -715,62 +715,62 @@ SECTION("test_projection_4326_3857 - Multi_Line_String Geometry Variant Object") mapnik::projection dest("+init=epsg:3857"); mapnik::proj_transform proj_trans1(source, dest); mapnik::proj_transform proj_trans2(dest, source); - line_string geom1a_; - geom1a_.emplace_back(point(-97.48872756958008, 35.360286150765084)); - geom1a_.emplace_back(point(-97.48065948486328, 35.34894577151337)); - geom1a_.emplace_back(point(-97.47267723083496, 35.36224605490395)); - geom1a_.emplace_back(point(-97.46323585510252, 35.34523530173256)); - geom1a_.emplace_back(point(-97.45963096618651, 35.36329598397908)); - geom1a_.emplace_back(point(-97.47550964355469, 35.369245324153866)); - multi_line_string geom1_; + line_string geom1a_; + geom1a_.emplace_back(point(-97.48872756958008, 35.360286150765084)); + geom1a_.emplace_back(point(-97.48065948486328, 35.34894577151337)); + geom1a_.emplace_back(point(-97.47267723083496, 35.36224605490395)); + geom1a_.emplace_back(point(-97.46323585510252, 35.34523530173256)); + geom1a_.emplace_back(point(-97.45963096618651, 35.36329598397908)); + geom1a_.emplace_back(point(-97.47550964355469, 35.369245324153866)); + multi_line_string geom1_; geom1_.emplace_back(geom1a_); - line_string geom2a_; - geom2a_.emplace_back(point(-10852395.511130, 4212951.024108)); - geom2a_.emplace_back(point(-10851497.376047, 4211403.174286)); - geom2a_.emplace_back(point(-10850608.795594, 4213218.553707)); - geom2a_.emplace_back(point(-10849557.786455, 4210896.778973)); - geom2a_.emplace_back(point(-10849156.492056, 4213361.873135)); - geom2a_.emplace_back(point(-10850924.098335, 4214174.016561)); - multi_line_string geom2_; + line_string geom2a_; + geom2a_.emplace_back(point(-10852395.511130, 4212951.024108)); + geom2a_.emplace_back(point(-10851497.376047, 4211403.174286)); + geom2a_.emplace_back(point(-10850608.795594, 4213218.553707)); + geom2a_.emplace_back(point(-10849557.786455, 4210896.778973)); + geom2a_.emplace_back(point(-10849156.492056, 4213361.873135)); + geom2a_.emplace_back(point(-10850924.098335, 4214174.016561)); + multi_line_string geom2_; geom2_.emplace_back(geom2a_); - multi_line_string geom0_; - geometry geom0(geom0_); - geometry geom1(geom1_); - geometry geom2(geom2_); + multi_line_string geom0_; + geometry geom0(geom0_); + geometry geom1(geom1_); + geometry geom2(geom2_); unsigned int err = 0; { // Reprojecting empty line string will return a geometry_empty - geometry new_geom = reproject_copy(geom0, proj_trans1, err); + geometry new_geom = reproject_copy(geom0, proj_trans1, err); REQUIRE(err == 0); REQUIRE(new_geom.is()); } { // Test Standard Transform - geometry new_geom = reproject_copy(geom1, proj_trans1, err); + geometry new_geom = reproject_copy(geom1, proj_trans1, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform in reverse - geometry new_geom = reproject_copy(geom2, proj_trans2, err); + geometry new_geom = reproject_copy(geom2, proj_trans2, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform providing projections not transfrom - geometry new_geom = reproject_copy(geom1, source, dest, err); + geometry new_geom = reproject_copy(geom1, source, dest, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform providing projections in reverse - geometry new_geom = reproject_copy(geom2, dest, source, err); + geometry new_geom = reproject_copy(geom2, dest, source, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform in place - geometry geom3(geom1); + geometry geom3(geom1); REQUIRE(reproject(geom3, proj_trans1)); assert_g_equal(geom3, geom2); // Transform in place reverse @@ -779,7 +779,7 @@ SECTION("test_projection_4326_3857 - Multi_Line_String Geometry Variant Object") } { // Transform in place providing projections - geometry geom3(geom1); + geometry geom3(geom1); REQUIRE(reproject(geom3, source, dest)); assert_g_equal(geom3, geom2); // Transform in place provoding projections reversed @@ -794,33 +794,33 @@ SECTION("test_projection_4326_3857 - Multi_Polygon Geometry Object") { mapnik::projection dest("+init=epsg:3857"); mapnik::proj_transform proj_trans1(source, dest); mapnik::proj_transform proj_trans2(dest, source); - polygon geom1a; - geom1a.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); - geom1a.exterior_ring.emplace_back(point(-97.79067993164062, 35.43941441533686)); - geom1a.exterior_ring.emplace_back(point(-97.60391235351562, 35.34425514918409)); - geom1a.exterior_ring.emplace_back(point(-97.42813110351562, 35.48191987272801)); - geom1a.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); + polygon geom1a; + geom1a.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); + geom1a.exterior_ring.emplace_back(point(-97.79067993164062, 35.43941441533686)); + geom1a.exterior_ring.emplace_back(point(-97.60391235351562, 35.34425514918409)); + geom1a.exterior_ring.emplace_back(point(-97.42813110351562, 35.48191987272801)); + geom1a.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); geom1a.interior_rings.emplace_back(); - geom1a.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); - geom1a.interior_rings.back().emplace_back(point(-97.61489868164062, 35.54116627999813)); - geom1a.interior_rings.back().emplace_back(point(-97.53799438476562, 35.459551379037606)); - geom1a.interior_rings.back().emplace_back(point(-97.62451171875, 35.42598697382711)); - geom1a.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); - multi_polygon geom1; + geom1a.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); + geom1a.interior_rings.back().emplace_back(point(-97.61489868164062, 35.54116627999813)); + geom1a.interior_rings.back().emplace_back(point(-97.53799438476562, 35.459551379037606)); + geom1a.interior_rings.back().emplace_back(point(-97.62451171875, 35.42598697382711)); + geom1a.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); + multi_polygon geom1; geom1.emplace_back(geom1a); - polygon geom2a; - geom2a.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); - geom2a.exterior_ring.emplace_back(point(-10886008.694318, 4223757.308982)); - geom2a.exterior_ring.emplace_back(point(-10865217.822625, 4210763.014174)); - geom2a.exterior_ring.emplace_back(point(-10845649.943384, 4229566.523132)); - geom2a.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); + polygon geom2a; + geom2a.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); + geom2a.exterior_ring.emplace_back(point(-10886008.694318, 4223757.308982)); + geom2a.exterior_ring.emplace_back(point(-10865217.822625, 4210763.014174)); + geom2a.exterior_ring.emplace_back(point(-10845649.943384, 4229566.523132)); + geom2a.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); geom2a.interior_rings.emplace_back(); - geom2a.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); - geom2a.interior_rings.back().emplace_back(point(-10866440.815077, 4237668.848130)); - geom2a.interior_rings.back().emplace_back(point(-10857879.867909, 4226509.042001)); - geom2a.interior_rings.back().emplace_back(point(-10867510.933473, 4221922.820303)); - geom2a.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); - multi_polygon geom2; + geom2a.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); + geom2a.interior_rings.back().emplace_back(point(-10866440.815077, 4237668.848130)); + geom2a.interior_rings.back().emplace_back(point(-10857879.867909, 4226509.042001)); + geom2a.interior_rings.back().emplace_back(point(-10867510.933473, 4221922.820303)); + geom2a.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); + multi_polygon geom2; geom2.emplace_back(geom2a); unsigned int err = 0; { @@ -828,7 +828,7 @@ SECTION("test_projection_4326_3857 - Multi_Polygon Geometry Object") { // Add extra polygon to outer ring. geom1.emplace_back(); REQUIRE(geom1.size() == 2); - multi_polygon new_geom = reproject_copy(geom1, proj_trans1, err); + multi_polygon new_geom = reproject_copy(geom1, proj_trans1, err); REQUIRE(err == 0); // Should remove the empty polygon added to back of geom1 REQUIRE(new_geom.size() == 1); @@ -839,25 +839,25 @@ SECTION("test_projection_4326_3857 - Multi_Polygon Geometry Object") { } { // Transform in reverse - multi_polygon new_geom = reproject_copy(geom2, proj_trans2, err); + multi_polygon new_geom = reproject_copy(geom2, proj_trans2, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform providing projections not transfrom - multi_polygon new_geom = reproject_copy(geom1, source, dest, err); + multi_polygon new_geom = reproject_copy(geom1, source, dest, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform providing projections in reverse - multi_polygon new_geom = reproject_copy(geom2, dest, source, err); + multi_polygon new_geom = reproject_copy(geom2, dest, source, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform in place - multi_polygon geom3(geom1); + multi_polygon geom3(geom1); geom3.emplace_back(); REQUIRE(reproject(geom3, proj_trans1)); // Should NOT remove the empty ring added to back of geom1 @@ -872,7 +872,7 @@ SECTION("test_projection_4326_3857 - Multi_Polygon Geometry Object") { } { // Transform in place providing projections - multi_polygon geom3(geom1); + multi_polygon geom3(geom1); REQUIRE(reproject(geom3, source, dest)); assert_g_equal(geom3, geom2); // Transform in place provoding projections reversed @@ -887,72 +887,72 @@ SECTION("test_projection_4326_3857 - Multi_Polygon Geometry Variant Object") { mapnik::projection dest("+init=epsg:3857"); mapnik::proj_transform proj_trans1(source, dest); mapnik::proj_transform proj_trans2(dest, source); - polygon geom1a_; - geom1a_.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); - geom1a_.exterior_ring.emplace_back(point(-97.79067993164062, 35.43941441533686)); - geom1a_.exterior_ring.emplace_back(point(-97.60391235351562, 35.34425514918409)); - geom1a_.exterior_ring.emplace_back(point(-97.42813110351562, 35.48191987272801)); - geom1a_.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); + polygon geom1a_; + geom1a_.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); + geom1a_.exterior_ring.emplace_back(point(-97.79067993164062, 35.43941441533686)); + geom1a_.exterior_ring.emplace_back(point(-97.60391235351562, 35.34425514918409)); + geom1a_.exterior_ring.emplace_back(point(-97.42813110351562, 35.48191987272801)); + geom1a_.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); geom1a_.interior_rings.emplace_back(); - geom1a_.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); - geom1a_.interior_rings.back().emplace_back(point(-97.61489868164062, 35.54116627999813)); - geom1a_.interior_rings.back().emplace_back(point(-97.53799438476562, 35.459551379037606)); - geom1a_.interior_rings.back().emplace_back(point(-97.62451171875, 35.42598697382711)); - geom1a_.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); - multi_polygon geom1_; + geom1a_.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); + geom1a_.interior_rings.back().emplace_back(point(-97.61489868164062, 35.54116627999813)); + geom1a_.interior_rings.back().emplace_back(point(-97.53799438476562, 35.459551379037606)); + geom1a_.interior_rings.back().emplace_back(point(-97.62451171875, 35.42598697382711)); + geom1a_.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); + multi_polygon geom1_; geom1_.emplace_back(geom1a_); - polygon geom2a_; - geom2a_.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); - geom2a_.exterior_ring.emplace_back(point(-10886008.694318, 4223757.308982)); - geom2a_.exterior_ring.emplace_back(point(-10865217.822625, 4210763.014174)); - geom2a_.exterior_ring.emplace_back(point(-10845649.943384, 4229566.523132)); - geom2a_.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); + polygon geom2a_; + geom2a_.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); + geom2a_.exterior_ring.emplace_back(point(-10886008.694318, 4223757.308982)); + geom2a_.exterior_ring.emplace_back(point(-10865217.822625, 4210763.014174)); + geom2a_.exterior_ring.emplace_back(point(-10845649.943384, 4229566.523132)); + geom2a_.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); geom2a_.interior_rings.emplace_back(); - geom2a_.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); - geom2a_.interior_rings.back().emplace_back(point(-10866440.815077, 4237668.848130)); - geom2a_.interior_rings.back().emplace_back(point(-10857879.867909, 4226509.042001)); - geom2a_.interior_rings.back().emplace_back(point(-10867510.933473, 4221922.820303)); - geom2a_.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); - multi_polygon geom2_; + geom2a_.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); + geom2a_.interior_rings.back().emplace_back(point(-10866440.815077, 4237668.848130)); + geom2a_.interior_rings.back().emplace_back(point(-10857879.867909, 4226509.042001)); + geom2a_.interior_rings.back().emplace_back(point(-10867510.933473, 4221922.820303)); + geom2a_.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); + multi_polygon geom2_; geom2_.emplace_back(geom2a_); - multi_polygon geom0_; - geometry geom0(geom0_); - geometry geom1(geom1_); - geometry geom2(geom2_); + multi_polygon geom0_; + geometry geom0(geom0_); + geometry geom1(geom1_); + geometry geom2(geom2_); unsigned int err = 0; { // Reprojecting empty poly will return a geometry_empty - geometry new_geom = reproject_copy(geom0, proj_trans1, err); + geometry new_geom = reproject_copy(geom0, proj_trans1, err); REQUIRE(err == 0); REQUIRE(new_geom.is()); } { // Test Standard Transform - geometry new_geom = reproject_copy(geom1, proj_trans1, err); + geometry new_geom = reproject_copy(geom1, proj_trans1, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform in reverse - geometry new_geom = reproject_copy(geom2, proj_trans2, err); + geometry new_geom = reproject_copy(geom2, proj_trans2, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform providing projections not transfrom - geometry new_geom = reproject_copy(geom1, source, dest, err); + geometry new_geom = reproject_copy(geom1, source, dest, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform providing projections in reverse - geometry new_geom = reproject_copy(geom2, dest, source, err); + geometry new_geom = reproject_copy(geom2, dest, source, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform in place - geometry geom3(geom1); + geometry geom3(geom1); REQUIRE(reproject(geom3, proj_trans1)); assert_g_equal(geom3, geom2); // Transform in place reverse @@ -961,7 +961,7 @@ SECTION("test_projection_4326_3857 - Multi_Polygon Geometry Variant Object") { } { // Transform in place providing projections - geometry geom3(geom1); + geometry geom3(geom1); REQUIRE(reproject(geom3, source, dest)); assert_g_equal(geom3, geom2); // Transform in place provoding projections reversed @@ -976,41 +976,41 @@ SECTION("test_projection_4326_3857 - Geometry Collection Object") { mapnik::projection dest("+init=epsg:3857"); mapnik::proj_transform proj_trans1(source, dest); mapnik::proj_transform proj_trans2(dest, source); - polygon geom1a; - geom1a.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); - geom1a.exterior_ring.emplace_back(point(-97.79067993164062, 35.43941441533686)); - geom1a.exterior_ring.emplace_back(point(-97.60391235351562, 35.34425514918409)); - geom1a.exterior_ring.emplace_back(point(-97.42813110351562, 35.48191987272801)); - geom1a.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); + polygon geom1a; + geom1a.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); + geom1a.exterior_ring.emplace_back(point(-97.79067993164062, 35.43941441533686)); + geom1a.exterior_ring.emplace_back(point(-97.60391235351562, 35.34425514918409)); + geom1a.exterior_ring.emplace_back(point(-97.42813110351562, 35.48191987272801)); + geom1a.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); geom1a.interior_rings.emplace_back(); - geom1a.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); - geom1a.interior_rings.back().emplace_back(point(-97.61489868164062, 35.54116627999813)); - geom1a.interior_rings.back().emplace_back(point(-97.53799438476562, 35.459551379037606)); - geom1a.interior_rings.back().emplace_back(point(-97.62451171875, 35.42598697382711)); - geom1a.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); - geometry_collection geom1; - geom1.emplace_back(geometry(geom1a)); - polygon geom2a; - geom2a.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); - geom2a.exterior_ring.emplace_back(point(-10886008.694318, 4223757.308982)); - geom2a.exterior_ring.emplace_back(point(-10865217.822625, 4210763.014174)); - geom2a.exterior_ring.emplace_back(point(-10845649.943384, 4229566.523132)); - geom2a.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); + geom1a.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); + geom1a.interior_rings.back().emplace_back(point(-97.61489868164062, 35.54116627999813)); + geom1a.interior_rings.back().emplace_back(point(-97.53799438476562, 35.459551379037606)); + geom1a.interior_rings.back().emplace_back(point(-97.62451171875, 35.42598697382711)); + geom1a.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); + geometry_collection geom1; + geom1.emplace_back(geometry(geom1a)); + polygon geom2a; + geom2a.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); + geom2a.exterior_ring.emplace_back(point(-10886008.694318, 4223757.308982)); + geom2a.exterior_ring.emplace_back(point(-10865217.822625, 4210763.014174)); + geom2a.exterior_ring.emplace_back(point(-10845649.943384, 4229566.523132)); + geom2a.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); geom2a.interior_rings.emplace_back(); - geom2a.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); - geom2a.interior_rings.back().emplace_back(point(-10866440.815077, 4237668.848130)); - geom2a.interior_rings.back().emplace_back(point(-10857879.867909, 4226509.042001)); - geom2a.interior_rings.back().emplace_back(point(-10867510.933473, 4221922.820303)); - geom2a.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); - geometry_collection geom2; - geom2.emplace_back(geometry(geom2a)); + geom2a.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); + geom2a.interior_rings.back().emplace_back(point(-10866440.815077, 4237668.848130)); + geom2a.interior_rings.back().emplace_back(point(-10857879.867909, 4226509.042001)); + geom2a.interior_rings.back().emplace_back(point(-10867510.933473, 4221922.820303)); + geom2a.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); + geometry_collection geom2; + geom2.emplace_back(geometry(geom2a)); unsigned int err = 0; { // Test Standard Transform // Add extra geometry to outer ring. geom1.emplace_back(); REQUIRE(geom1.size() == 2); - geometry_collection new_geom = reproject_copy(geom1, proj_trans1, err); + geometry_collection new_geom = reproject_copy(geom1, proj_trans1, err); REQUIRE(err == 0); // Should remove the empty geometry added to back of geom1 REQUIRE(new_geom.size() == 1); @@ -1021,25 +1021,25 @@ SECTION("test_projection_4326_3857 - Geometry Collection Object") { } { // Transform in reverse - geometry_collection new_geom = reproject_copy(geom2, proj_trans2, err); + geometry_collection new_geom = reproject_copy(geom2, proj_trans2, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform providing projections not transfrom - geometry_collection new_geom = reproject_copy(geom1, source, dest, err); + geometry_collection new_geom = reproject_copy(geom1, source, dest, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform providing projections in reverse - geometry_collection new_geom = reproject_copy(geom2, dest, source, err); + geometry_collection new_geom = reproject_copy(geom2, dest, source, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform in place - geometry_collection geom3(geom1); + geometry_collection geom3(geom1); geom3.emplace_back(); REQUIRE(reproject(geom3, proj_trans1)); // Should NOT remove the empty ring added to back of geom1 @@ -1054,7 +1054,7 @@ SECTION("test_projection_4326_3857 - Geometry Collection Object") { } { // Transform in place providing projections - geometry_collection geom3(geom1); + geometry_collection geom3(geom1); REQUIRE(reproject(geom3, source, dest)); assert_g_equal(geom3, geom2); // Transform in place provoding projections reversed @@ -1069,72 +1069,72 @@ SECTION("test_projection_4326_3857 - Geometry Collection Variant Object") { mapnik::projection dest("+init=epsg:3857"); mapnik::proj_transform proj_trans1(source, dest); mapnik::proj_transform proj_trans2(dest, source); - polygon geom1a_; - geom1a_.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); - geom1a_.exterior_ring.emplace_back(point(-97.79067993164062, 35.43941441533686)); - geom1a_.exterior_ring.emplace_back(point(-97.60391235351562, 35.34425514918409)); - geom1a_.exterior_ring.emplace_back(point(-97.42813110351562, 35.48191987272801)); - geom1a_.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); + polygon geom1a_; + geom1a_.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); + geom1a_.exterior_ring.emplace_back(point(-97.79067993164062, 35.43941441533686)); + geom1a_.exterior_ring.emplace_back(point(-97.60391235351562, 35.34425514918409)); + geom1a_.exterior_ring.emplace_back(point(-97.42813110351562, 35.48191987272801)); + geom1a_.exterior_ring.emplace_back(point(-97.62588500976562, 35.62939577711732)); geom1a_.interior_rings.emplace_back(); - geom1a_.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); - geom1a_.interior_rings.back().emplace_back(point(-97.61489868164062, 35.54116627999813)); - geom1a_.interior_rings.back().emplace_back(point(-97.53799438476562, 35.459551379037606)); - geom1a_.interior_rings.back().emplace_back(point(-97.62451171875, 35.42598697382711)); - geom1a_.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); - geometry_collection geom1_; - geom1_.emplace_back(geometry(geom1a_)); - polygon geom2a_; - geom2a_.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); - geom2a_.exterior_ring.emplace_back(point(-10886008.694318, 4223757.308982)); - geom2a_.exterior_ring.emplace_back(point(-10865217.822625, 4210763.014174)); - geom2a_.exterior_ring.emplace_back(point(-10845649.943384, 4229566.523132)); - geom2a_.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); + geom1a_.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); + geom1a_.interior_rings.back().emplace_back(point(-97.61489868164062, 35.54116627999813)); + geom1a_.interior_rings.back().emplace_back(point(-97.53799438476562, 35.459551379037606)); + geom1a_.interior_rings.back().emplace_back(point(-97.62451171875, 35.42598697382711)); + geom1a_.interior_rings.back().emplace_back(point(-97.66571044921875, 35.46849952318069)); + geometry_collection geom1_; + geom1_.emplace_back(geometry(geom1a_)); + polygon geom2a_; + geom2a_.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); + geom2a_.exterior_ring.emplace_back(point(-10886008.694318, 4223757.308982)); + geom2a_.exterior_ring.emplace_back(point(-10865217.822625, 4210763.014174)); + geom2a_.exterior_ring.emplace_back(point(-10845649.943384, 4229566.523132)); + geom2a_.exterior_ring.emplace_back(point(-10867663.807530, 4249745.898599)); geom2a_.interior_rings.emplace_back(); - geom2a_.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); - geom2a_.interior_rings.back().emplace_back(point(-10866440.815077, 4237668.848130)); - geom2a_.interior_rings.back().emplace_back(point(-10857879.867909, 4226509.042001)); - geom2a_.interior_rings.back().emplace_back(point(-10867510.933473, 4221922.820303)); - geom2a_.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); - geometry_collection geom2_; - geom2_.emplace_back(geometry(geom2a_)); - multi_polygon geom0_; - geometry geom0(geom0_); - geometry geom1(geom1_); - geometry geom2(geom2_); + geom2a_.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); + geom2a_.interior_rings.back().emplace_back(point(-10866440.815077, 4237668.848130)); + geom2a_.interior_rings.back().emplace_back(point(-10857879.867909, 4226509.042001)); + geom2a_.interior_rings.back().emplace_back(point(-10867510.933473, 4221922.820303)); + geom2a_.interior_rings.back().emplace_back(point(-10872097.155170, 4227732.034453)); + geometry_collection geom2_; + geom2_.emplace_back(geometry(geom2a_)); + multi_polygon geom0_; + geometry geom0(geom0_); + geometry geom1(geom1_); + geometry geom2(geom2_); unsigned int err = 0; { // Reprojecting empty poly will return a geometry_empty - geometry new_geom = reproject_copy(geom0, proj_trans1, err); + geometry new_geom = reproject_copy(geom0, proj_trans1, err); REQUIRE(err == 0); REQUIRE(new_geom.is()); } { // Test Standard Transform - geometry new_geom = reproject_copy(geom1, proj_trans1, err); + geometry new_geom = reproject_copy(geom1, proj_trans1, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform in reverse - geometry new_geom = reproject_copy(geom2, proj_trans2, err); + geometry new_geom = reproject_copy(geom2, proj_trans2, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform providing projections not transfrom - geometry new_geom = reproject_copy(geom1, source, dest, err); + geometry new_geom = reproject_copy(geom1, source, dest, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom2); } { // Transform providing projections in reverse - geometry new_geom = reproject_copy(geom2, dest, source, err); + geometry new_geom = reproject_copy(geom2, dest, source, err); REQUIRE(err == 0); assert_g_equal(new_geom, geom1); } { // Transform in place - geometry geom3(geom1); + geometry geom3(geom1); REQUIRE(reproject(geom3, proj_trans1)); assert_g_equal(geom3, geom2); // Transform in place reverse @@ -1143,7 +1143,7 @@ SECTION("test_projection_4326_3857 - Geometry Collection Variant Object") { } { // Transform in place providing projections - geometry geom3(geom1); + geometry geom3(geom1); REQUIRE(reproject(geom3, source, dest)); assert_g_equal(geom3, geom2); // Transform in place provoding projections reversed diff --git a/tests/cxx/vertex_adapter.cpp b/tests/cxx/vertex_adapter.cpp index 503cee980..ab6c9ab53 100644 --- a/tests/cxx/vertex_adapter.cpp +++ b/tests/cxx/vertex_adapter.cpp @@ -6,13 +6,13 @@ TEST_CASE("vertex_adapters") { SECTION("polygon") { - mapnik::geometry::polygon g; + mapnik::geometry::polygon g; g.exterior_ring.add_coord(1,1); g.exterior_ring.add_coord(2,2); g.exterior_ring.add_coord(100,100); g.exterior_ring.add_coord(1,1); - mapnik::geometry::polygon_vertex_adapter va(g); + mapnik::geometry::polygon_vertex_adapter va(g); double x,y; unsigned cmd; @@ -45,14 +45,14 @@ SECTION("polygon") { } SECTION("polygon with hole") { - mapnik::geometry::polygon g; + mapnik::geometry::polygon g; g.exterior_ring.add_coord(0,0); g.exterior_ring.add_coord(-10,0); g.exterior_ring.add_coord(-10,10); g.exterior_ring.add_coord(0,10); g.exterior_ring.add_coord(0,0); - std::vector interior_rings; - mapnik::geometry::linear_ring hole; + std::vector > interior_rings; + mapnik::geometry::linear_ring hole; hole.add_coord(-7,7); hole.add_coord(-7,3); hole.add_coord(-3,3); @@ -60,7 +60,7 @@ SECTION("polygon with hole") { hole.add_coord(-7,7); g.add_hole(std::move(hole)); - mapnik::geometry::linear_ring hole_in_hole; + mapnik::geometry::linear_ring hole_in_hole; hole_in_hole.add_coord(-6,4); hole_in_hole.add_coord(-6,6); hole_in_hole.add_coord(-4,6); @@ -68,7 +68,7 @@ SECTION("polygon with hole") { hole_in_hole.add_coord(-6,4); g.add_hole(std::move(hole_in_hole)); - mapnik::geometry::polygon_vertex_adapter va(g); + mapnik::geometry::polygon_vertex_adapter va(g); double x,y; unsigned cmd; diff --git a/utils/geometry_to_wkb/main.cpp b/utils/geometry_to_wkb/main.cpp index 248fda262..1b0056ae2 100644 --- a/utils/geometry_to_wkb/main.cpp +++ b/utils/geometry_to_wkb/main.cpp @@ -81,7 +81,7 @@ int main (int argc, char ** argv ) while(f) { std::cerr << *f << std::endl; - mapnik::geometry::geometry const& geom = f->get_geometry(); + mapnik::geometry::geometry const& geom = f->get_geometry(); // NDR { mapnik::util::wkb_buffer_ptr wkb = mapnik::util::to_wkb(geom,mapnik::wkbNDR); diff --git a/utils/pgsql2sqlite/pgsql2sqlite.hpp b/utils/pgsql2sqlite/pgsql2sqlite.hpp index dab2c4b95..78db58fe5 100644 --- a/utils/pgsql2sqlite/pgsql2sqlite.hpp +++ b/utils/pgsql2sqlite/pgsql2sqlite.hpp @@ -389,7 +389,7 @@ void pgsql2sqlite(Connection conn, if (oid == geometry_oid) { mapnik::Feature feat(ctx,pkid); - mapnik::geometry::geometry geom = geometry_utils::from_wkb(buf, size, wkbGeneric); + mapnik::geometry::geometry geom = geometry_utils::from_wkb(buf, size, wkbGeneric); if (!mapnik::geometry::is_empty(geom)) { box2d bbox = mapnik::geometry::envelope(geom);