diff --git a/benchmark/test_polygon_clipping.cpp b/benchmark/test_polygon_clipping.cpp index 02296927b..1591fb174 100644 --- a/benchmark/test_polygon_clipping.cpp +++ b/benchmark/test_polygon_clipping.cpp @@ -15,6 +15,7 @@ #include #include #include +#include // agg #include "agg_conv_clip_polygon.h" // clipper diff --git a/include/mapnik/geometry_adapters.hpp b/include/mapnik/geometry_adapters.hpp index b2e911a3f..93076a82b 100644 --- a/include/mapnik/geometry_adapters.hpp +++ b/include/mapnik/geometry_adapters.hpp @@ -29,27 +29,29 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-local-typedef" #undef B0 -#include -#include #include +#include #include -#include -#include -#include -#include -#include +// NOTE: ideally we would not include all of boost/geometry here to save on compile time +// however we need to pull in for things to work +// and once we do that the compile time is == to just including boost/geometry.hpp +#include #pragma GCC diagnostic pop #include +#include #include +#include +#include + // register point -BOOST_GEOMETRY_REGISTER_POINT_2D (mapnik::geometry::point, double, cs::cartesian, x, y) -BOOST_GEOMETRY_REGISTER_POINT_2D (mapnik::geometry::point, std::int64_t, cs::cartesian, x, y) +BOOST_GEOMETRY_REGISTER_POINT_2D (mapnik::geometry::point, double, boost::geometry::cs::cartesian, x, y) +BOOST_GEOMETRY_REGISTER_POINT_2D (mapnik::geometry::point, std::int64_t, boost::geometry::cs::cartesian, x, y) // ring BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(mapnik::geometry::linear_ring) // needed by box2d -BOOST_GEOMETRY_REGISTER_POINT_2D(mapnik::coord2d, double, cs::cartesian, x, y) +BOOST_GEOMETRY_REGISTER_POINT_2D(mapnik::coord2d, double, boost::geometry::cs::cartesian, x, y) namespace boost { diff --git a/include/mapnik/geometry_correct.hpp b/include/mapnik/geometry_correct.hpp index dcb3452aa..8698c129a 100644 --- a/include/mapnik/geometry_correct.hpp +++ b/include/mapnik/geometry_correct.hpp @@ -25,7 +25,14 @@ #include #include +#include + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Wunused-variable" +#pragma GCC diagnostic ignored "-Wunused-local-typedef" #include +#pragma GCC diagnostic pop #include diff --git a/include/mapnik/json/geometry_util.hpp b/include/mapnik/json/geometry_util.hpp index 6ef6eee59..0e44ae40b 100644 --- a/include/mapnik/json/geometry_util.hpp +++ b/include/mapnik/json/geometry_util.hpp @@ -24,7 +24,6 @@ #define MAPNIK_JSON_GEOMETRY_UTIL_HPP #include -#include namespace mapnik { namespace json { diff --git a/include/mapnik/proj_strategy.hpp b/include/mapnik/proj_strategy.hpp new file mode 100644 index 000000000..69ef18a1c --- /dev/null +++ b/include/mapnik/proj_strategy.hpp @@ -0,0 +1,149 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2014 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef MAPNIK_PROJ_STRATEGY_HPP +#define MAPNIK_PROJ_STRATEGY_HPP + +// mapnik +#include +#include +#include + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Wunused-local-typedef" +#include +#include +#include +#pragma GCC diagnostic pop + + +namespace mapnik { + +namespace geometry { +template struct point; +template struct line_string; +} +class projection; +template class box2d; + +struct proj_strategy +{ + proj_strategy(proj_transform const& prj_trans) + : prj_trans_(prj_trans) {} + + template + inline bool apply(P1 const& p1, P2 & p2) const + { + using p2_type = typename boost::geometry::coordinate_type::type; + double x = boost::geometry::get<0>(p1); + double y = boost::geometry::get<1>(p1); + double z = 0.0; + if (!prj_trans_.forward(x, y, z)) return false; + try { + boost::geometry::set<0>(p2, boost::numeric_cast(x)); + } + catch(boost::numeric::negative_overflow&) + { + boost::geometry::set<0>(p2, std::numeric_limits::min()); + } + catch(boost::numeric::positive_overflow&) + { + boost::geometry::set<0>(p2, std::numeric_limits::max()); + } + try { + boost::geometry::set<1>(p2, boost::numeric_cast(y)); + } + catch(boost::numeric::negative_overflow&) + { + boost::geometry::set<1>(p2, std::numeric_limits::min()); + } + catch(boost::numeric::positive_overflow&) + { + boost::geometry::set<1>(p2, std::numeric_limits::max()); + } + return true; + } + + template + inline P2 execute(P1 const& p1, bool & status) const + { + P2 p2; + status = apply(p1, p2); + return p2; + } + + proj_transform const& prj_trans_; +}; + +struct proj_backward_strategy +{ + proj_backward_strategy(proj_transform const& prj_trans) + : prj_trans_(prj_trans) {} + + template + inline bool apply(P1 const& p1, P2 & p2) const + { + using p2_type = typename boost::geometry::coordinate_type::type; + double x = boost::geometry::get<0>(p1); + double y = boost::geometry::get<1>(p1); + double z = 0.0; + if (!prj_trans_.backward(x, y, z)) return false; + try { + boost::geometry::set<0>(p2, boost::numeric_cast(x)); + } + catch(boost::numeric::negative_overflow&) + { + boost::geometry::set<0>(p2, std::numeric_limits::min()); + } + catch(boost::numeric::positive_overflow&) + { + boost::geometry::set<0>(p2, std::numeric_limits::max()); + } + try { + boost::geometry::set<1>(p2, boost::numeric_cast(y)); + } + catch(boost::numeric::negative_overflow&) + { + boost::geometry::set<1>(p2, std::numeric_limits::min()); + } + catch(boost::numeric::positive_overflow&) + { + boost::geometry::set<1>(p2, std::numeric_limits::max()); + } + return true; + } + + template + inline P2 execute(P1 const& p1, bool & status) const + { + P2 p2; + status = apply(p1, p2); + return p2; + } + + proj_transform const& prj_trans_; +}; + +} + +#endif // MAPNIK_PROJ_STRATEGY_HPP diff --git a/include/mapnik/proj_transform.hpp b/include/mapnik/proj_transform.hpp index 2c1b06da9..fa27b6341 100644 --- a/include/mapnik/proj_transform.hpp +++ b/include/mapnik/proj_transform.hpp @@ -26,7 +26,6 @@ // mapnik #include #include -#include namespace mapnik { @@ -70,104 +69,6 @@ private: bool merc_to_wgs84_; }; -struct proj_strategy -{ - proj_strategy(proj_transform const& prj_trans) - : prj_trans_(prj_trans) {} - - template - inline bool apply(P1 const& p1, P2 & p2) const - { - using p2_type = typename boost::geometry::coordinate_type::type; - double x = boost::geometry::get<0>(p1); - double y = boost::geometry::get<1>(p1); - double z = 0.0; - if (!prj_trans_.forward(x, y, z)) return false; - try { - boost::geometry::set<0>(p2, boost::numeric_cast(x)); - } - catch(boost::numeric::negative_overflow&) - { - boost::geometry::set<0>(p2, std::numeric_limits::min()); - } - catch(boost::numeric::positive_overflow&) - { - boost::geometry::set<0>(p2, std::numeric_limits::max()); - } - try { - boost::geometry::set<1>(p2, boost::numeric_cast(y)); - } - catch(boost::numeric::negative_overflow&) - { - boost::geometry::set<1>(p2, std::numeric_limits::min()); - } - catch(boost::numeric::positive_overflow&) - { - boost::geometry::set<1>(p2, std::numeric_limits::max()); - } - return true; - } - - template - inline P2 execute(P1 const& p1, bool & status) const - { - P2 p2; - status = apply(p1, p2); - return p2; - } - - proj_transform const& prj_trans_; -}; - -struct proj_backward_strategy -{ - proj_backward_strategy(proj_transform const& prj_trans) - : prj_trans_(prj_trans) {} - - template - inline bool apply(P1 const& p1, P2 & p2) const - { - using p2_type = typename boost::geometry::coordinate_type::type; - double x = boost::geometry::get<0>(p1); - double y = boost::geometry::get<1>(p1); - double z = 0.0; - if (!prj_trans_.backward(x, y, z)) return false; - try { - boost::geometry::set<0>(p2, boost::numeric_cast(x)); - } - catch(boost::numeric::negative_overflow&) - { - boost::geometry::set<0>(p2, std::numeric_limits::min()); - } - catch(boost::numeric::positive_overflow&) - { - boost::geometry::set<0>(p2, std::numeric_limits::max()); - } - try { - boost::geometry::set<1>(p2, boost::numeric_cast(y)); - } - catch(boost::numeric::negative_overflow&) - { - boost::geometry::set<1>(p2, std::numeric_limits::min()); - } - catch(boost::numeric::positive_overflow&) - { - boost::geometry::set<1>(p2, std::numeric_limits::max()); - } - return true; - } - - template - inline P2 execute(P1 const& p1, bool & status) const - { - P2 p2; - status = apply(p1, p2); - return p2; - } - - proj_transform const& prj_trans_; -}; - } #endif // MAPNIK_PROJ_TRANSFORM_HPP diff --git a/include/mapnik/view_strategy.hpp b/include/mapnik/view_strategy.hpp new file mode 100644 index 000000000..cdc9204f8 --- /dev/null +++ b/include/mapnik/view_strategy.hpp @@ -0,0 +1,92 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2014 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef MAPNIK_VIEW_STRATEGY_HPP +#define MAPNIK_VIEW_STRATEGY_HPP + +// mapnik +#include +#include +#include + +namespace mapnik +{ + +struct view_strategy +{ + view_strategy(view_transform const& tr) + : tr_(tr) {} + + template + inline bool apply(P1 const& p1, P2 & p2) const + { + using coordinate_type = typename boost::geometry::coordinate_type::type; + double x = boost::geometry::get<0>(p1); + double y = boost::geometry::get<1>(p1); + tr_.forward(&x,&y); + boost::geometry::set<0>(p2, boost::numeric_cast(x)); + boost::geometry::set<1>(p2, boost::numeric_cast(y)); + return true; + } + + template + inline P2 execute(P1 const& p1, bool & status) const + { + P2 p2; + status = apply(p1, p2); + return p2; + } + + view_transform const& tr_; +}; + +struct unview_strategy +{ + unview_strategy(view_transform const& tr) + : tr_(tr) {} + + template + inline bool apply(P1 const& p1, P2 & p2) const + { + using coordinate_type = typename boost::geometry::coordinate_type::type; + double x = boost::geometry::get<0>(p1); + double y = boost::geometry::get<1>(p1); + tr_.backward(&x,&y); + boost::geometry::set<0>(p2, boost::numeric_cast(x)); + boost::geometry::set<1>(p2, boost::numeric_cast(y)); + return true; + } + + template + inline P2 execute(P1 const& p1, bool & status) const + { + P2 p2; + status = apply(p1, p2); + return p2; + } + + view_transform const& tr_; +}; + +} + +#endif // MAPNIK_VIEW_STRATEGY_HPP diff --git a/include/mapnik/view_transform.hpp b/include/mapnik/view_transform.hpp index 5529b7c68..e293eb608 100644 --- a/include/mapnik/view_transform.hpp +++ b/include/mapnik/view_transform.hpp @@ -179,62 +179,6 @@ public: } }; -struct view_strategy -{ - view_strategy(view_transform const& tr) - : tr_(tr) {} - - template - inline bool apply(P1 const& p1, P2 & p2) const - { - using coordinate_type = typename boost::geometry::coordinate_type::type; - double x = boost::geometry::get<0>(p1); - double y = boost::geometry::get<1>(p1); - tr_.forward(&x,&y); - boost::geometry::set<0>(p2, boost::numeric_cast(x)); - boost::geometry::set<1>(p2, boost::numeric_cast(y)); - return true; - } - - template - inline P2 execute(P1 const& p1, bool & status) const - { - P2 p2; - status = apply(p1, p2); - return p2; - } - - view_transform const& tr_; -}; - -struct unview_strategy -{ - unview_strategy(view_transform const& tr) - : tr_(tr) {} - - template - inline bool apply(P1 const& p1, P2 & p2) const - { - using coordinate_type = typename boost::geometry::coordinate_type::type; - double x = boost::geometry::get<0>(p1); - double y = boost::geometry::get<1>(p1); - tr_.backward(&x,&y); - boost::geometry::set<0>(p2, boost::numeric_cast(x)); - boost::geometry::set<1>(p2, boost::numeric_cast(y)); - return true; - } - - template - inline P2 execute(P1 const& p1, bool & status) const - { - P2 p2; - status = apply(p1, p2); - return p2; - } - - view_transform const& tr_; -}; - } #endif // MAPNIK_VIEW_TRANSFORM_HPP diff --git a/include/mapnik/wkt/wkt_grammar.hpp b/include/mapnik/wkt/wkt_grammar.hpp index 80fa06648..b0566635b 100644 --- a/include/mapnik/wkt/wkt_grammar.hpp +++ b/include/mapnik/wkt/wkt_grammar.hpp @@ -25,7 +25,6 @@ // mapnik #include -#include #include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp index 4f1f4fb25..1dc5a084e 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include diff --git a/plugins/input/geojson/geojson_datasource.hpp b/plugins/input/geojson/geojson_datasource.hpp index 02f607f4f..42610dbd8 100644 --- a/plugins/input/geojson/geojson_datasource.hpp +++ b/plugins/input/geojson/geojson_datasource.hpp @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #pragma GCC diagnostic pop diff --git a/src/wkb.cpp b/src/wkb.cpp index 055163051..092261f26 100644 --- a/src/wkb.cpp +++ b/src/wkb.cpp @@ -27,7 +27,6 @@ #include #include #include -#include namespace mapnik { diff --git a/test/unit/geometry/geometry_envelope_test.cpp b/test/unit/geometry/geometry_envelope_test.cpp index 88d3b08b3..1898f0a42 100644 --- a/test/unit/geometry/geometry_envelope_test.cpp +++ b/test/unit/geometry/geometry_envelope_test.cpp @@ -1,6 +1,8 @@ #include "catch.hpp" +#include #include +#include #include #include diff --git a/test/unit/geometry/geometry_strategy_test.cpp b/test/unit/geometry/geometry_strategy_test.cpp index f59a72f1d..abf116431 100644 --- a/test/unit/geometry/geometry_strategy_test.cpp +++ b/test/unit/geometry/geometry_strategy_test.cpp @@ -7,6 +7,8 @@ #include #include #include +#include +#include TEST_CASE("geometry strategy tests") {