revert geometry changes for now - will develop them in branch to reduce downstream breakage

This commit is contained in:
Dane Springmeyer 2016-04-11 14:00:27 -07:00
parent 0025f70a6b
commit abe943c983
22 changed files with 37 additions and 310 deletions

View file

@ -10,7 +10,7 @@
#include <mapnik/geometry.hpp>
#include <mapnik/vertex_adapters.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/geometry/boost_geometry_adapters.hpp>
#include <mapnik/geometry_adapters.hpp>
#include <mapnik/geometry_envelope.hpp>
#include <mapnik/geometry_correct.hpp>
#include <mapnik/geometry_is_empty.hpp>

View file

@ -38,7 +38,6 @@ subdirs = [
'text',
'text/placements',
'text/formatting',
'geometry',
'markers_placements'
]

View file

@ -1,220 +0,0 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 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_GEOMETRY_ADAPTERS_HPP
#define MAPNIK_GEOMETRY_ADAPTERS_HPP
#include <mapnik/config.hpp>
// undef B0 to workaround https://svn.boost.org/trac/boost/ticket/10467
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#undef B0
#include <boost/geometry/geometries/register/linestring.hpp>
#include <boost/geometry/geometries/register/point.hpp>
#include <boost/geometry/geometries/register/ring.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>
// register point
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, boost::geometry::cs::cartesian, x, y)
namespace boost {
template <typename CoordinateType>
struct range_iterator<mapnik::geometry::line_string<CoordinateType> >
{
using type = typename mapnik::geometry::line_string<CoordinateType>::iterator;
};
template <typename CoordinateType>
struct range_const_iterator<mapnik::geometry::line_string<CoordinateType> >
{
using type = typename mapnik::geometry::line_string<CoordinateType>::const_iterator;
};
template <typename CoordinateType>
inline typename mapnik::geometry::line_string<CoordinateType>::iterator
range_begin(mapnik::geometry::line_string<CoordinateType> & line) {return line.begin();}
template <typename CoordinateType>
inline typename mapnik::geometry::line_string<CoordinateType>::iterator
range_end(mapnik::geometry::line_string<CoordinateType> & line) {return line.end();}
template <typename CoordinateType>
inline typename mapnik::geometry::line_string<CoordinateType>::const_iterator
range_begin(mapnik::geometry::line_string<CoordinateType> const& line) {return line.begin();}
template <typename CoordinateType>
inline typename mapnik::geometry::line_string<CoordinateType>::const_iterator
range_end(mapnik::geometry::line_string<CoordinateType> const& line) {return line.end();}
namespace geometry { namespace traits {
// register mapnik::box2d<double>
template<> struct tag<mapnik::box2d<double> > { using type = box_tag; };
template<> struct point_type<mapnik::box2d<double> > { using type = mapnik::coord2d; };
template <>
struct indexed_access<mapnik::box2d<double>, min_corner, 0>
{
using ct = coordinate_type<mapnik::coord2d>::type;
static inline ct get(mapnik::box2d<double> const& b) { return b.minx();}
static inline void set(mapnik::box2d<double> &b, ct const& value) { b.set_minx(value); }
};
template <>
struct indexed_access<mapnik::box2d<double>, min_corner, 1>
{
using ct = coordinate_type<mapnik::coord2d>::type;
static inline ct get(mapnik::box2d<double> const& b) { return b.miny();}
static inline void set(mapnik::box2d<double> &b, ct const& value) { b.set_miny(value); }
};
template <>
struct indexed_access<mapnik::box2d<double>, max_corner, 0>
{
using ct = coordinate_type<mapnik::coord2d>::type;
static inline ct get(mapnik::box2d<double> const& b) { return b.maxx();}
static inline void set(mapnik::box2d<double> &b, ct const& value) { b.set_maxx(value); }
};
template <>
struct indexed_access<mapnik::box2d<double>, max_corner, 1>
{
using ct = coordinate_type<mapnik::coord2d>::type;
static inline ct get(mapnik::box2d<double> const& b) { return b.maxy();}
static inline void set(mapnik::box2d<double> &b , ct const& value) { b.set_maxy(value); }
};
// mapnik::geometry::line_string
template<typename CoordinateType>
struct tag<mapnik::geometry::line_string<CoordinateType> >
{
using type = linestring_tag;
};
// mapnik::geometry::polygon
template<typename CoordinateType>
struct tag<mapnik::geometry::polygon<CoordinateType> >
{
using type = polygon_tag;
};
template <typename CoordinateType>
struct point_order<mapnik::geometry::linear_ring<CoordinateType> >
{
static const order_selector value = counterclockwise;
};
template<typename CoordinateType>
struct tag<mapnik::geometry::multi_point<CoordinateType> >
{
using type = multi_point_tag;
};
template<typename CoordinateType>
struct tag<mapnik::geometry::multi_line_string<CoordinateType> >
{
using type = multi_linestring_tag;
};
template<typename CoordinateType>
struct tag<mapnik::geometry::multi_polygon<CoordinateType> >
{
using type = multi_polygon_tag;
};
// ring
template <typename CoordinateType>
struct ring_const_type<mapnik::geometry::polygon<CoordinateType> >
{
using type = typename mapnik::geometry::linear_ring<CoordinateType> const&;
};
template <typename CoordinateType>
struct ring_mutable_type<mapnik::geometry::polygon<CoordinateType> >
{
using type = typename mapnik::geometry::linear_ring<CoordinateType>&;
};
// interior
template <typename CoordinateType>
struct interior_const_type<mapnik::geometry::polygon<CoordinateType> >
{
using type = typename mapnik::geometry::polygon<CoordinateType>::rings_container const&;
};
template <typename CoordinateType>
struct interior_mutable_type<mapnik::geometry::polygon<CoordinateType> >
{
using type = typename mapnik::geometry::polygon<CoordinateType>::rings_container&;
};
// exterior
template <typename CoordinateType>
struct exterior_ring<mapnik::geometry::polygon<CoordinateType> >
{
static mapnik::geometry::linear_ring<CoordinateType> & get(mapnik::geometry::polygon<CoordinateType> & p)
{
return p.exterior_ring;
}
static mapnik::geometry::linear_ring<CoordinateType> const& get(mapnik::geometry::polygon<CoordinateType> const& p)
{
return p.exterior_ring;
}
};
template <typename CoordinateType>
struct interior_rings<mapnik::geometry::polygon<CoordinateType> >
{
using holes_type = typename mapnik::geometry::polygon<CoordinateType>::rings_container;
static holes_type& get(mapnik::geometry::polygon<CoordinateType> & p)
{
return p.interior_rings;
}
static holes_type const& get(mapnik::geometry::polygon<CoordinateType> const& p)
{
return p.interior_rings;
}
};
}}}
#endif //MAPNIK_GEOMETRY_ADAPTERS_HPP

View file

@ -1,52 +0,0 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 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_GEOMETRY_FUSION_ADAPTED_HPP
#define MAPNIK_GEOMETRY_FUSION_ADAPTED_HPP
#include <mapnik/geometry.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
BOOST_FUSION_ADAPT_STRUCT(
mapnik::geometry::point<double>,
(double, x)
(double, y)
)
BOOST_FUSION_ADAPT_STRUCT(
mapnik::geometry::point<std::int64_t>,
(std::int64_t, x)
(std::int64_t, y)
)
BOOST_FUSION_ADAPT_STRUCT(
mapnik::geometry::polygon<double>,
(mapnik::geometry::linear_ring<double> const&, exterior_ring)
(mapnik::geometry::polygon<double>::rings_container const& , interior_rings))
BOOST_FUSION_ADAPT_STRUCT(
mapnik::geometry::polygon<std::int64_t>,
(mapnik::geometry::linear_ring<std::int64_t> const&, exterior_ring)
(mapnik::geometry::polygon<std::int64_t>::rings_container const& , interior_rings))
#endif // MAPNIK_GEOMETRY_FUSION_ADAPTED_HPP

View file

@ -24,7 +24,7 @@
#define MAPNIK_GEOMETRY_CENTROID_HPP
#include <mapnik/geometry.hpp>
#include <mapnik/geometry/boost_geometry_adapters.hpp>
#include <mapnik/geometry_adapters.hpp>
#include <boost/geometry/algorithms/centroid.hpp>
#include <mapnik/geometry_is_empty.hpp>
#include <mapnik/geometry_remove_empty.hpp>

View file

@ -24,7 +24,7 @@
#define MAPNIK_GEOMETRY_CORRECT_HPP
#include <mapnik/geometry.hpp>
#include <mapnik/geometry/boost_geometry_adapters.hpp>
#include <mapnik/geometry_adapters.hpp>
#include <mapnik/util/variant.hpp>
#pragma GCC diagnostic push

View file

@ -29,7 +29,7 @@
#if BOOST_VERSION >= 105600
#include <mapnik/geometry.hpp>
#include <mapnik/geometry/boost_geometry_adapters.hpp>
#include <mapnik/geometry_adapters.hpp>
#include <boost/geometry/algorithms/is_simple.hpp>
namespace mapnik { namespace geometry {

View file

@ -29,7 +29,7 @@
#if BOOST_VERSION >= 105800
#include <mapnik/geometry.hpp>
#include <mapnik/geometry/boost_geometry_adapters.hpp>
#include <mapnik/geometry_adapters.hpp>
#include <boost/geometry/algorithms/is_valid.hpp>
#include <boost/geometry/algorithms/validity_failure_type.hpp>
@ -102,7 +102,7 @@ struct geometry_is_valid
struct geometry_is_valid_reason
{
using result_type = bool;
boost::geometry::validity_failure_type & failure_;
geometry_is_valid_reason(boost::geometry::validity_failure_type & failure):
@ -170,7 +170,7 @@ struct geometry_is_valid_reason
struct geometry_is_valid_string
{
using result_type = bool;
std::string & message_;
geometry_is_valid_string(std::string & message):
@ -257,7 +257,7 @@ inline bool is_valid(T const& geom, boost::geometry::validity_failure_type & fai
}
template <typename T>
inline bool is_valid(mapnik::geometry::geometry<T> const& geom,
inline bool is_valid(mapnik::geometry::geometry<T> const& geom,
boost::geometry::validity_failure_type & failure)
{
return util::apply_visitor(detail::geometry_is_valid_reason(failure), geom);
@ -270,7 +270,7 @@ inline bool is_valid(T const& geom, std::string & message)
}
template <typename T>
inline bool is_valid(mapnik::geometry::geometry<T> const& geom,
inline bool is_valid(mapnik::geometry::geometry<T> const& geom,
std::string & message)
{
return util::apply_visitor(detail::geometry_is_valid_string(message), geom);

View file

@ -23,20 +23,20 @@
#ifndef MAPNIK_GEOMETRY_STRATEGY_HPP
#define MAPNIK_GEOMETRY_STRATEGY_HPP
#include <mapnik/geometry/boost_geometry_adapters.hpp>
#include <mapnik/geometry_adapters.hpp>
#include <mapnik/util/rounding_cast.hpp>
namespace mapnik {
namespace mapnik {
namespace geometry {
namespace helper
{
template <std::size_t... Ts>
struct index {};
template <std::size_t N, std::size_t... Ts>
struct gen_seq : gen_seq<N - 1, N - 1, Ts...> {};
template <std::size_t... Ts>
struct gen_seq<0, Ts...> : index<Ts...> {};
}
@ -70,7 +70,7 @@ struct strategy_group
template <typename P1, typename P2, typename T, typename ...Args>
inline P2 execute(P1 const& p, bool & status, T const& strat, Args const& ... args) const
{
{
return execute<P1,P2>(strat.template execute<P1,P1>(p, status), status, args...);
}
@ -79,7 +79,7 @@ struct strategy_group
{
return strat.template execute<P1,P2>(p, status);
}
private:
std::tuple<Strategies const& ...> ops_;
@ -87,7 +87,7 @@ private:
// The difference between this strategy group and the previous is that the conversion from P1 to P2 happens
// in the first strategy rather then the last strategy.
// in the first strategy rather then the last strategy.
template <typename... Strategies>
struct strategy_group_first
{
@ -116,13 +116,13 @@ struct strategy_group_first
template <typename P1, typename P2, typename T, typename ...Args>
inline P2 execute_first(P1 const& p, bool & status, T const& strat, Args const& ... args) const
{
{
return execute<P2>(strat.template execute<P1,P2>(p, status), status, args...);
}
template <typename P2, typename T, typename ...Args>
inline P2 execute(P2 const& p, bool & status, T const& strat, Args const& ... args) const
{
{
return execute<P2>(strat.template execute<P2,P2>(p, status), status, args...);
}
@ -131,13 +131,13 @@ struct strategy_group_first
{
return strat.template execute<P2,P2>(p, status);
}
template <typename P2>
inline P2 execute(P2 const& p, bool & status) const
{
return p;
}
private:
std::tuple<Strategies const& ...> ops_;
@ -151,7 +151,7 @@ struct scale_strategy
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) * scale_) + offset_;
double y = (boost::geometry::get<1>(p1) * scale_) + offset_;
@ -159,7 +159,7 @@ struct scale_strategy
boost::geometry::set<1>(p2, static_cast<p2_type>(y));
return true;
}
template <typename P1, typename P2>
inline P2 execute(P1 const& p1, bool & status) const
{
@ -181,7 +181,7 @@ struct scale_rounding_strategy
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) * scale_) + offset_;
double y = (boost::geometry::get<1>(p1) * scale_) + offset_;
@ -189,7 +189,7 @@ struct scale_rounding_strategy
boost::geometry::set<1>(p2, static_cast<p2_type>(std::round(y)));
return true;
}
template <typename P1, typename P2>
inline P2 execute(P1 const& p1, bool & status) const
{

View file

@ -24,7 +24,7 @@
#define MAPNIK_GEOMETRY_TRANSFORM_HPP
#include <mapnik/geometry.hpp>
#include <mapnik/geometry/boost_geometry_adapters.hpp>
#include <mapnik/geometry_adapters.hpp>
#include <boost/geometry/algorithms/transform.hpp>
namespace mapnik { namespace geometry { namespace detail {

View file

@ -22,7 +22,7 @@
// mapnik
#include <mapnik/json/extract_bounding_box_grammar.hpp>
#include <mapnik/geometry/fusion_adapted.hpp>
#include <mapnik/geometry_fusion_adapted.hpp>
// boost
#include <boost/spirit/include/qi_omit.hpp>
#include <boost/spirit/include/phoenix_object.hpp>

View file

@ -24,7 +24,7 @@
#include <mapnik/json/geometry_generator_grammar.hpp>
#include <mapnik/util/spirit_transform_attribute.hpp>
#include <mapnik/geometry_types.hpp>
#include <mapnik/geometry/fusion_adapted.hpp>
#include <mapnik/geometry_fusion_adapted.hpp>
// boost
#pragma GCC diagnostic push

View file

@ -24,7 +24,7 @@
#include <mapnik/config.hpp>
#include <mapnik/json/error_handler.hpp>
#include <mapnik/json/geometry_grammar.hpp>
#include <mapnik/geometry/fusion_adapted.hpp>
#include <mapnik/geometry_fusion_adapted.hpp>
// boost
#include <boost/spirit/include/phoenix_stl.hpp>
#include <boost/spirit/include/phoenix_function.hpp>

View file

@ -22,7 +22,7 @@
// mapnik
#include <mapnik/json/positions_grammar.hpp>
#include <mapnik/geometry/fusion_adapted.hpp>
#include <mapnik/geometry_fusion_adapted.hpp>
// boost
#include <boost/spirit/include/qi_omit.hpp>
#include <boost/spirit/include/phoenix_object.hpp>

View file

@ -33,7 +33,7 @@
BOOST_FUSION_ADAPT_STRUCT(
mapnik::topojson::coordinate,
(double, x)
(double, y)
(double, y)
)
BOOST_FUSION_ADAPT_STRUCT(

View file

@ -28,7 +28,7 @@
#include <mapnik/unicode.hpp>
#include <mapnik/json/topology.hpp>
#include <mapnik/feature_factory.hpp>
#include <mapnik/geometry/boost_geometry_adapters.hpp>
#include <mapnik/geometry_adapters.hpp>
#include <mapnik/geometry_correct.hpp>
namespace mapnik { namespace topojson {

View file

@ -23,7 +23,7 @@
// mapnik
#include <mapnik/wkt/wkt_generator_grammar.hpp>
#include <mapnik/util/spirit_transform_attribute.hpp>
#include <mapnik/geometry/fusion_adapted.hpp>
#include <mapnik/geometry_fusion_adapted.hpp>
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>

View file

@ -21,7 +21,7 @@
*****************************************************************************/
#include <mapnik/wkt/wkt_grammar.hpp>
#include <mapnik/geometry/fusion_adapted.hpp>
#include <mapnik/geometry_fusion_adapted.hpp>
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>

View file

@ -38,7 +38,7 @@
#include <mapnik/boolean.hpp>
#include <mapnik/util/trim.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/geometry/boost_geometry_adapters.hpp>
#include <mapnik/geometry_adapters.hpp>
#include <mapnik/util/geometry_to_ds_type.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/util/fs.hpp>

View file

@ -49,7 +49,7 @@
#include <mapnik/util/file_io.hpp>
#include <mapnik/util/geometry_to_ds_type.hpp>
#include <mapnik/make_unique.hpp>
#include <mapnik/geometry/boost_geometry_adapters.hpp>
#include <mapnik/geometry_adapters.hpp>
#include <mapnik/json/feature_collection_grammar.hpp>
#include <mapnik/json/extract_bounding_box_grammar_impl.hpp>
#include <mapnik/util/fs.hpp>

View file

@ -33,7 +33,7 @@
#include <mapnik/unicode.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/geometry/boost_geometry_adapters.hpp>
#include <mapnik/geometry_adapters.hpp>
#include <mapnik/json/topojson_grammar.hpp>
#include <mapnik/json/topojson_utils.hpp>
#include <mapnik/util/variant.hpp>

View file

@ -2,7 +2,7 @@
// mapnik
#include <mapnik/wkb.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/geometry/boost_geometry_adapters.hpp>
#include <mapnik/geometry_adapters.hpp>
#include <mapnik/geometry_is_empty.hpp>
#include <mapnik/util/geometry_to_wkt.hpp>
// bool