shuffle around boost/geometry usage in headers to reduce compile time
This commit is contained in:
parent
a43bec6d0b
commit
126c777c8d
14 changed files with 266 additions and 169 deletions
|
@ -15,6 +15,7 @@
|
|||
#include <mapnik/geometry_is_empty.hpp>
|
||||
#include <mapnik/image_util.hpp>
|
||||
#include <mapnik/color.hpp>
|
||||
#include <boost/geometry.hpp>
|
||||
// agg
|
||||
#include "agg_conv_clip_polygon.h"
|
||||
// clipper
|
||||
|
|
|
@ -29,27 +29,29 @@
|
|||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-local-typedef"
|
||||
#undef B0
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/register/point.hpp>
|
||||
#include <boost/geometry/geometries/register/linestring.hpp>
|
||||
#include <boost/geometry/geometries/register/point.hpp>
|
||||
#include <boost/geometry/geometries/register/ring.hpp>
|
||||
#include <boost/range.hpp>
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
#include <boost/geometry/core/mutable_range.hpp>
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
// NOTE: ideally we would not include all of boost/geometry here to save on compile time
|
||||
// however we need to pull in <boost/geometry/multi/multi.hpp> for things to work
|
||||
// and once we do that the compile time is == to just including boost/geometry.hpp
|
||||
#include <boost/geometry.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include <mapnik/geometry.hpp>
|
||||
#include <mapnik/coord.hpp>
|
||||
#include <mapnik/box2d.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
// register point
|
||||
BOOST_GEOMETRY_REGISTER_POINT_2D (mapnik::geometry::point<double>, double, cs::cartesian, x, y)
|
||||
BOOST_GEOMETRY_REGISTER_POINT_2D (mapnik::geometry::point<std::int64_t>, std::int64_t, cs::cartesian, x, y)
|
||||
BOOST_GEOMETRY_REGISTER_POINT_2D (mapnik::geometry::point<double>, double, boost::geometry::cs::cartesian, x, y)
|
||||
BOOST_GEOMETRY_REGISTER_POINT_2D (mapnik::geometry::point<std::int64_t>, std::int64_t, boost::geometry::cs::cartesian, x, y)
|
||||
// ring
|
||||
BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(mapnik::geometry::linear_ring)
|
||||
// needed by box2d<double>
|
||||
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 {
|
||||
|
||||
|
|
|
@ -25,7 +25,14 @@
|
|||
|
||||
#include <mapnik/geometry.hpp>
|
||||
#include <mapnik/geometry_adapters.hpp>
|
||||
#include <mapnik/util/variant.hpp>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
#pragma GCC diagnostic ignored "-Wunused-local-typedef"
|
||||
#include <boost/geometry/algorithms/correct.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#define MAPNIK_JSON_GEOMETRY_UTIL_HPP
|
||||
|
||||
#include <mapnik/geometry.hpp>
|
||||
#include <mapnik/geometry_adapters.hpp>
|
||||
|
||||
namespace mapnik { namespace json {
|
||||
|
||||
|
|
149
include/mapnik/proj_strategy.hpp
Normal file
149
include/mapnik/proj_strategy.hpp
Normal file
|
@ -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 <mapnik/config.hpp>
|
||||
#include <mapnik/util/noncopyable.hpp>
|
||||
#include <mapnik/proj_transform.hpp>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#pragma GCC diagnostic ignored "-Wunused-local-typedef"
|
||||
#include <boost/geometry/core/coordinate_type.hpp>
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
namespace geometry {
|
||||
template <typename T> struct point;
|
||||
template <typename T> struct line_string;
|
||||
}
|
||||
class projection;
|
||||
template <typename T> class box2d;
|
||||
|
||||
struct proj_strategy
|
||||
{
|
||||
proj_strategy(proj_transform const& prj_trans)
|
||||
: prj_trans_(prj_trans) {}
|
||||
|
||||
template <typename P1, typename P2>
|
||||
inline bool apply(P1 const& p1, P2 & p2) const
|
||||
{
|
||||
using p2_type = typename boost::geometry::coordinate_type<P2>::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<p2_type>(x));
|
||||
}
|
||||
catch(boost::numeric::negative_overflow&)
|
||||
{
|
||||
boost::geometry::set<0>(p2, std::numeric_limits<p2_type>::min());
|
||||
}
|
||||
catch(boost::numeric::positive_overflow&)
|
||||
{
|
||||
boost::geometry::set<0>(p2, std::numeric_limits<p2_type>::max());
|
||||
}
|
||||
try {
|
||||
boost::geometry::set<1>(p2, boost::numeric_cast<p2_type>(y));
|
||||
}
|
||||
catch(boost::numeric::negative_overflow&)
|
||||
{
|
||||
boost::geometry::set<1>(p2, std::numeric_limits<p2_type>::min());
|
||||
}
|
||||
catch(boost::numeric::positive_overflow&)
|
||||
{
|
||||
boost::geometry::set<1>(p2, std::numeric_limits<p2_type>::max());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename P1, typename P2>
|
||||
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 <typename P1, typename P2>
|
||||
inline bool apply(P1 const& p1, P2 & p2) const
|
||||
{
|
||||
using p2_type = typename boost::geometry::coordinate_type<P2>::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<p2_type>(x));
|
||||
}
|
||||
catch(boost::numeric::negative_overflow&)
|
||||
{
|
||||
boost::geometry::set<0>(p2, std::numeric_limits<p2_type>::min());
|
||||
}
|
||||
catch(boost::numeric::positive_overflow&)
|
||||
{
|
||||
boost::geometry::set<0>(p2, std::numeric_limits<p2_type>::max());
|
||||
}
|
||||
try {
|
||||
boost::geometry::set<1>(p2, boost::numeric_cast<p2_type>(y));
|
||||
}
|
||||
catch(boost::numeric::negative_overflow&)
|
||||
{
|
||||
boost::geometry::set<1>(p2, std::numeric_limits<p2_type>::min());
|
||||
}
|
||||
catch(boost::numeric::positive_overflow&)
|
||||
{
|
||||
boost::geometry::set<1>(p2, std::numeric_limits<p2_type>::max());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename P1, typename P2>
|
||||
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
|
|
@ -26,7 +26,6 @@
|
|||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/util/noncopyable.hpp>
|
||||
#include <mapnik/geometry_adapters.hpp>
|
||||
|
||||
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 <typename P1, typename P2>
|
||||
inline bool apply(P1 const& p1, P2 & p2) const
|
||||
{
|
||||
using p2_type = typename boost::geometry::coordinate_type<P2>::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<p2_type>(x));
|
||||
}
|
||||
catch(boost::numeric::negative_overflow&)
|
||||
{
|
||||
boost::geometry::set<0>(p2, std::numeric_limits<p2_type>::min());
|
||||
}
|
||||
catch(boost::numeric::positive_overflow&)
|
||||
{
|
||||
boost::geometry::set<0>(p2, std::numeric_limits<p2_type>::max());
|
||||
}
|
||||
try {
|
||||
boost::geometry::set<1>(p2, boost::numeric_cast<p2_type>(y));
|
||||
}
|
||||
catch(boost::numeric::negative_overflow&)
|
||||
{
|
||||
boost::geometry::set<1>(p2, std::numeric_limits<p2_type>::min());
|
||||
}
|
||||
catch(boost::numeric::positive_overflow&)
|
||||
{
|
||||
boost::geometry::set<1>(p2, std::numeric_limits<p2_type>::max());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename P1, typename P2>
|
||||
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 <typename P1, typename P2>
|
||||
inline bool apply(P1 const& p1, P2 & p2) const
|
||||
{
|
||||
using p2_type = typename boost::geometry::coordinate_type<P2>::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<p2_type>(x));
|
||||
}
|
||||
catch(boost::numeric::negative_overflow&)
|
||||
{
|
||||
boost::geometry::set<0>(p2, std::numeric_limits<p2_type>::min());
|
||||
}
|
||||
catch(boost::numeric::positive_overflow&)
|
||||
{
|
||||
boost::geometry::set<0>(p2, std::numeric_limits<p2_type>::max());
|
||||
}
|
||||
try {
|
||||
boost::geometry::set<1>(p2, boost::numeric_cast<p2_type>(y));
|
||||
}
|
||||
catch(boost::numeric::negative_overflow&)
|
||||
{
|
||||
boost::geometry::set<1>(p2, std::numeric_limits<p2_type>::min());
|
||||
}
|
||||
catch(boost::numeric::positive_overflow&)
|
||||
{
|
||||
boost::geometry::set<1>(p2, std::numeric_limits<p2_type>::max());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename P1, typename P2>
|
||||
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
|
||||
|
|
92
include/mapnik/view_strategy.hpp
Normal file
92
include/mapnik/view_strategy.hpp
Normal file
|
@ -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 <mapnik/coord.hpp>
|
||||
#include <mapnik/box2d.hpp>
|
||||
#include <mapnik/proj_strategy.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
struct view_strategy
|
||||
{
|
||||
view_strategy(view_transform const& tr)
|
||||
: tr_(tr) {}
|
||||
|
||||
template <typename P1, typename P2>
|
||||
inline bool apply(P1 const& p1, P2 & p2) const
|
||||
{
|
||||
using coordinate_type = typename boost::geometry::coordinate_type<P2>::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<coordinate_type>(x));
|
||||
boost::geometry::set<1>(p2, boost::numeric_cast<coordinate_type>(y));
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename P1, typename P2>
|
||||
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 <typename P1, typename P2>
|
||||
inline bool apply(P1 const& p1, P2 & p2) const
|
||||
{
|
||||
using coordinate_type = typename boost::geometry::coordinate_type<P2>::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<coordinate_type>(x));
|
||||
boost::geometry::set<1>(p2, boost::numeric_cast<coordinate_type>(y));
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename P1, typename P2>
|
||||
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
|
|
@ -179,62 +179,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
struct view_strategy
|
||||
{
|
||||
view_strategy(view_transform const& tr)
|
||||
: tr_(tr) {}
|
||||
|
||||
template <typename P1, typename P2>
|
||||
inline bool apply(P1 const& p1, P2 & p2) const
|
||||
{
|
||||
using coordinate_type = typename boost::geometry::coordinate_type<P2>::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<coordinate_type>(x));
|
||||
boost::geometry::set<1>(p2, boost::numeric_cast<coordinate_type>(y));
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename P1, typename P2>
|
||||
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 <typename P1, typename P2>
|
||||
inline bool apply(P1 const& p1, P2 & p2) const
|
||||
{
|
||||
using coordinate_type = typename boost::geometry::coordinate_type<P2>::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<coordinate_type>(x));
|
||||
boost::geometry::set<1>(p2, boost::numeric_cast<coordinate_type>(y));
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename P1, typename P2>
|
||||
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
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/geometry.hpp>
|
||||
#include <mapnik/geometry_adapters.hpp>
|
||||
#include <mapnik/geometry_fusion_adapted.hpp>
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include <mapnik/util/file_io.hpp>
|
||||
#include <mapnik/util/geometry_to_ds_type.hpp>
|
||||
#include <mapnik/make_unique.hpp>
|
||||
#include <mapnik/geometry_adapters.hpp>
|
||||
#include <mapnik/json/feature_collection_grammar.hpp>
|
||||
#include <mapnik/json/extract_bounding_box_grammar_impl.hpp>
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/geometries/box.hpp>
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/version.hpp>
|
||||
#include <boost/geometry/index/rtree.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include <mapnik/wkb.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/util/noncopyable.hpp>
|
||||
#include <mapnik/geometry_adapters.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "catch.hpp"
|
||||
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/geometry.hpp>
|
||||
#include <mapnik/geometry_adapters.hpp>
|
||||
#include <mapnik/geometry_envelope.hpp>
|
||||
#include <mapnik/geometry_correct.hpp>
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include <mapnik/view_transform.hpp>
|
||||
#include <mapnik/geometry_transform.hpp>
|
||||
#include <mapnik/geometry_strategy.hpp>
|
||||
#include <mapnik/proj_strategy.hpp>
|
||||
#include <mapnik/view_strategy.hpp>
|
||||
|
||||
TEST_CASE("geometry strategy tests") {
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue