make mapnik::geometry::point<T> an alias to mapbox::geometry::point
This commit is contained in:
parent
d169fb473e
commit
19d376b7e6
23 changed files with 99 additions and 120 deletions
|
@ -46,7 +46,7 @@ struct geometry_collection;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct geometry_empty
|
struct geometry_empty
|
||||||
{
|
{
|
||||||
using coord_type = T;
|
using coordinate_type = T;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -61,7 +61,7 @@ using geometry_base = mapnik::util::variant<geometry_empty<T>,
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct geometry : geometry_base<T>
|
struct geometry : geometry_base<T>
|
||||||
{
|
{
|
||||||
using coord_type = T;
|
using coordinate_type = T;
|
||||||
|
|
||||||
geometry()
|
geometry()
|
||||||
: geometry_base<T>() {} // empty
|
: geometry_base<T>() {} // empty
|
||||||
|
@ -76,7 +76,7 @@ struct geometry : geometry_base<T>
|
||||||
template <typename T, template <typename...> class Cont>
|
template <typename T, template <typename...> class Cont>
|
||||||
struct geometry_collection : Cont<geometry<T>>
|
struct geometry_collection : Cont<geometry<T>>
|
||||||
{
|
{
|
||||||
using coord_type = T;
|
using coordinate_type = T;
|
||||||
};
|
};
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -33,14 +33,14 @@ namespace mapnik { namespace geometry {
|
||||||
template <typename T, template <typename...> class Cont = std::vector>
|
template <typename T, template <typename...> class Cont = std::vector>
|
||||||
struct line_string : Cont<point<T> >
|
struct line_string : Cont<point<T> >
|
||||||
{
|
{
|
||||||
using coord_type = T;
|
using coordinate_type = T;
|
||||||
using point_type = point<coord_type>;
|
using point_type = point<coordinate_type>;
|
||||||
using container_type = Cont<point_type>;
|
using container_type = Cont<point_type>;
|
||||||
line_string() = default;
|
line_string() = default;
|
||||||
explicit line_string(std::size_t size)
|
explicit line_string(std::size_t size)
|
||||||
: container_type(size) {}
|
: container_type(size) {}
|
||||||
inline std::size_t num_points() const { return container_type::size(); }
|
inline std::size_t num_points() const { return container_type::size(); }
|
||||||
inline void add_coord(coord_type x, coord_type y) { container_type::template emplace_back(x,y);}
|
inline void add_coord(coordinate_type x, coordinate_type y) { container_type::template emplace_back(x,y);}
|
||||||
};
|
};
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace mapnik { namespace geometry {
|
||||||
template <typename T, template <typename...> class Cont = std::vector>
|
template <typename T, template <typename...> class Cont = std::vector>
|
||||||
struct multi_line_string : Cont<line_string<T>>
|
struct multi_line_string : Cont<line_string<T>>
|
||||||
{
|
{
|
||||||
using coord_type = T;
|
using coordinate_type = T;
|
||||||
};
|
};
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -33,8 +33,8 @@ namespace mapnik { namespace geometry {
|
||||||
template <typename T, template <typename...> class Cont = std::vector>
|
template <typename T, template <typename...> class Cont = std::vector>
|
||||||
struct multi_point : Cont<point<T>>
|
struct multi_point : Cont<point<T>>
|
||||||
{
|
{
|
||||||
using coord_type = T;
|
using coordinate_type = T;
|
||||||
using point_type = point<coord_type>;
|
using point_type = point<coordinate_type>;
|
||||||
using container_type = Cont<point_type>;
|
using container_type = Cont<point_type>;
|
||||||
multi_point() = default;
|
multi_point() = default;
|
||||||
explicit multi_point(std::size_t size)
|
explicit multi_point(std::size_t size)
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace mapnik { namespace geometry {
|
||||||
template <typename T, template <typename...> class Cont = std::vector>
|
template <typename T, template <typename...> class Cont = std::vector>
|
||||||
struct multi_polygon : Cont<polygon<T>>
|
struct multi_polygon : Cont<polygon<T>>
|
||||||
{
|
{
|
||||||
using coord_type = T;
|
using coordinate_type = T;
|
||||||
};
|
};
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -23,31 +23,12 @@
|
||||||
#ifndef MAPNIK_GEOMETRY_POINT_HPP
|
#ifndef MAPNIK_GEOMETRY_POINT_HPP
|
||||||
#define MAPNIK_GEOMETRY_POINT_HPP
|
#define MAPNIK_GEOMETRY_POINT_HPP
|
||||||
|
|
||||||
|
#include <mapbox/geometry/point.hpp>
|
||||||
|
|
||||||
namespace mapnik { namespace geometry {
|
namespace mapnik { namespace geometry {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct point
|
using point = mapbox::geometry::point<T>;
|
||||||
{
|
|
||||||
using coord_type = T;
|
|
||||||
point() {}
|
|
||||||
point(T x_, T y_)
|
|
||||||
: x(x_), y(y_)
|
|
||||||
{}
|
|
||||||
coord_type x;
|
|
||||||
coord_type y;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
bool operator==(point<T> const& lhs, point<T> const& rhs)
|
|
||||||
{
|
|
||||||
return lhs.x == rhs.x && lhs.y == rhs.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
bool operator!=(point<T> const& lhs, point<T> const& rhs)
|
|
||||||
{
|
|
||||||
return lhs.x != rhs.x || lhs.y != rhs.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace mapnik { namespace geometry {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct linear_ring : line_string<T>
|
struct linear_ring : line_string<T>
|
||||||
{
|
{
|
||||||
using coord_type = T;
|
using coordinate_type = T;
|
||||||
linear_ring() = default;
|
linear_ring() = default;
|
||||||
explicit linear_ring(std::size_t size)
|
explicit linear_ring(std::size_t size)
|
||||||
: line_string<T>(size) {}
|
: line_string<T>(size) {}
|
||||||
|
@ -50,8 +50,8 @@ using rings_container = std::vector<linear_ring<T>>;
|
||||||
template <typename T, template <typename> class InteriorRings = rings_container>
|
template <typename T, template <typename> class InteriorRings = rings_container>
|
||||||
struct polygon
|
struct polygon
|
||||||
{
|
{
|
||||||
using coord_type = T;
|
using coordinate_type = T;
|
||||||
using rings_container = InteriorRings<coord_type>;
|
using rings_container = InteriorRings<coordinate_type>;
|
||||||
linear_ring<T> exterior_ring;
|
linear_ring<T> exterior_ring;
|
||||||
rings_container interior_rings;
|
rings_container interior_rings;
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace mapnik {
|
||||||
namespace geometry {
|
namespace geometry {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
MAPNIK_DECL auto envelope(T const& geom) -> box2d<typename T::coord_type>;
|
MAPNIK_DECL auto envelope(T const& geom) -> box2d<typename T::coordinate_type>;
|
||||||
|
|
||||||
} // end ns geometry
|
} // end ns geometry
|
||||||
} // end ns mapnik
|
} // end ns mapnik
|
||||||
|
|
|
@ -31,8 +31,8 @@ namespace detail {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct geometry_envelope
|
struct geometry_envelope
|
||||||
{
|
{
|
||||||
using coord_type = T;
|
using coordinate_type = T;
|
||||||
using bbox_type = box2d<coord_type>;
|
using bbox_type = box2d<coordinate_type>;
|
||||||
bbox_type & bbox;
|
bbox_type & bbox;
|
||||||
|
|
||||||
explicit geometry_envelope(bbox_type & bbox_)
|
explicit geometry_envelope(bbox_type & bbox_)
|
||||||
|
@ -139,11 +139,11 @@ struct geometry_envelope
|
||||||
} // end ns detail
|
} // end ns detail
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
auto envelope(T const& geom) -> box2d<typename T::coord_type>
|
auto envelope(T const& geom) -> box2d<typename T::coordinate_type>
|
||||||
{
|
{
|
||||||
using coord_type = typename T::coord_type;
|
using coordinate_type = typename T::coordinate_type;
|
||||||
box2d<coord_type> bbox;
|
box2d<coordinate_type> bbox;
|
||||||
detail::geometry_envelope<coord_type> op(bbox);
|
detail::geometry_envelope<coordinate_type> op(bbox);
|
||||||
op(geom);
|
op(geom);
|
||||||
return bbox;
|
return bbox;
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,15 +161,15 @@ private:
|
||||||
template <typename G>
|
template <typename G>
|
||||||
inline bool is_empty(G const& geom)
|
inline bool is_empty(G const& geom)
|
||||||
{
|
{
|
||||||
using coord_type = typename G::coord_type;
|
using coordinate_type = typename G::coordinate_type;
|
||||||
return detail::geometry_is_empty<coord_type>()(geom);
|
return detail::geometry_is_empty<coordinate_type>()(geom);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename G>
|
template <typename G>
|
||||||
inline bool has_empty(G const& geom)
|
inline bool has_empty(G const& geom)
|
||||||
{
|
{
|
||||||
using coord_type = typename G::coord_type;
|
using coordinate_type = typename G::coordinate_type;
|
||||||
return detail::geometry_has_empty<coord_type>()(geom);
|
return detail::geometry_has_empty<coordinate_type>()(geom);
|
||||||
}
|
}
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -132,8 +132,8 @@ struct geometry_is_simple
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline bool is_simple(T const& geom)
|
inline bool is_simple(T const& geom)
|
||||||
{
|
{
|
||||||
using coord_type = typename T::coord_type;
|
using coordinate_type = typename T::coordinate_type;
|
||||||
return detail::geometry_is_simple<coord_type>() (geom);
|
return detail::geometry_is_simple<coordinate_type>() (geom);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -219,8 +219,8 @@ struct geometry_is_valid_string
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline bool is_valid(T const& geom)
|
inline bool is_valid(T const& geom)
|
||||||
{
|
{
|
||||||
using coord_type = typename T::coord_type;
|
using coordinate_type = typename T::coordinate_type;
|
||||||
return detail::geometry_is_valid<coord_type>() (geom);
|
return detail::geometry_is_valid<coordinate_type>() (geom);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -232,8 +232,8 @@ inline bool is_valid(mapnik::geometry::geometry<T> const& geom)
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline bool is_valid(T const& geom, boost::geometry::validity_failure_type & failure)
|
inline bool is_valid(T const& geom, boost::geometry::validity_failure_type & failure)
|
||||||
{
|
{
|
||||||
using coord_type = typename T::coord_type;
|
using coordinate_type = typename T::coordinate_type;
|
||||||
return detail::geometry_is_valid_reason<coord_type>(failure) (geom);
|
return detail::geometry_is_valid_reason<coordinate_type>(failure) (geom);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -246,8 +246,8 @@ inline bool is_valid(mapnik::geometry::geometry<T> const& geom,
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline bool is_valid(T const& geom, std::string & message)
|
inline bool is_valid(T const& geom, std::string & message)
|
||||||
{
|
{
|
||||||
using coord_type = typename T::coord_type;
|
using coordinate_type = typename T::coordinate_type;
|
||||||
return detail::geometry_is_valid_string<coord_type>(message) (geom);
|
return detail::geometry_is_valid_string<coordinate_type>(message) (geom);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -149,8 +149,8 @@ struct geometry_to_path
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void to_path(T const& geom, path_type & p)
|
void to_path(T const& geom, path_type & p)
|
||||||
{
|
{
|
||||||
using coord_type = typename T::coord_type;
|
using coordinate_type = typename T::coordinate_type;
|
||||||
detail::geometry_to_path<coord_type> func(p);
|
detail::geometry_to_path<coordinate_type> func(p);
|
||||||
func(geom);
|
func(geom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,8 +82,8 @@ struct geometry_type
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static inline mapnik::geometry::geometry_types geometry_type(T const& geom)
|
static inline mapnik::geometry::geometry_types geometry_type(T const& geom)
|
||||||
{
|
{
|
||||||
using coord_type = typename T::coord_type;
|
using coordinate_type = typename T::coordinate_type;
|
||||||
return detail::geometry_type<coord_type>()(geom);
|
return detail::geometry_type<coordinate_type>()(geom);
|
||||||
}
|
}
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -44,8 +44,8 @@ public:
|
||||||
PolygonExterior = Polygon,
|
PolygonExterior = Polygon,
|
||||||
PolygonInterior = Polygon | ( 1 << geometry_bits)
|
PolygonInterior = Polygon | ( 1 << geometry_bits)
|
||||||
};
|
};
|
||||||
using coord_type = T;
|
using coordinate_type = T;
|
||||||
using container_type = Container<coord_type>;
|
using container_type = Container<coordinate_type>;
|
||||||
using value_type = typename container_type::value_type;
|
using value_type = typename container_type::value_type;
|
||||||
using size_type = typename container_type::size_type;
|
using size_type = typename container_type::size_type;
|
||||||
container_type cont_;
|
container_type cont_;
|
||||||
|
@ -84,17 +84,17 @@ public:
|
||||||
{
|
{
|
||||||
return cont_.size();
|
return cont_.size();
|
||||||
}
|
}
|
||||||
void push_vertex(coord_type x, coord_type y, CommandType c)
|
void push_vertex(coordinate_type x, coordinate_type y, CommandType c)
|
||||||
{
|
{
|
||||||
cont_.push_back(x,y,c);
|
cont_.push_back(x,y,c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void line_to(coord_type x,coord_type y)
|
void line_to(coordinate_type x,coordinate_type y)
|
||||||
{
|
{
|
||||||
push_vertex(x,y,SEG_LINETO);
|
push_vertex(x,y,SEG_LINETO);
|
||||||
}
|
}
|
||||||
|
|
||||||
void move_to(coord_type x,coord_type y)
|
void move_to(coordinate_type x,coordinate_type y)
|
||||||
{
|
{
|
||||||
push_vertex(x,y,SEG_MOVETO);
|
push_vertex(x,y,SEG_MOVETO);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,14 +26,12 @@
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/config.hpp>
|
#include <mapnik/config.hpp>
|
||||||
#include <mapnik/util/noncopyable.hpp>
|
#include <mapnik/util/noncopyable.hpp>
|
||||||
|
#include <mapnik/geometry/point.hpp>
|
||||||
// stl
|
// stl
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace mapnik {
|
namespace mapnik {
|
||||||
|
|
||||||
namespace geometry {
|
|
||||||
template <typename T> struct point;
|
|
||||||
}
|
|
||||||
class projection;
|
class projection;
|
||||||
template <typename T> class box2d;
|
template <typename T> class box2d;
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,7 @@ struct svg_path_generator :
|
||||||
{
|
{
|
||||||
|
|
||||||
using path_type = Path;
|
using path_type = Path;
|
||||||
using coord_type = typename boost::remove_pointer<typename path_type::value_type>::type;
|
using coordinate_type = typename boost::remove_pointer<typename path_type::value_type>::type;
|
||||||
|
|
||||||
svg_path_generator();
|
svg_path_generator();
|
||||||
// rules
|
// rules
|
||||||
|
@ -153,7 +153,7 @@ struct svg_path_generator :
|
||||||
karma::rule<OutputIterator, path_type const& ()> point;
|
karma::rule<OutputIterator, path_type const& ()> point;
|
||||||
karma::rule<OutputIterator, path_type const& ()> linestring;
|
karma::rule<OutputIterator, path_type const& ()> linestring;
|
||||||
karma::rule<OutputIterator, path_type const& ()> polygon;
|
karma::rule<OutputIterator, path_type const& ()> polygon;
|
||||||
karma::rule<OutputIterator, coord_type ()> svg_point;
|
karma::rule<OutputIterator, coordinate_type ()> svg_point;
|
||||||
karma::rule<OutputIterator, path_type const& ()> svg_path;
|
karma::rule<OutputIterator, path_type const& ()> svg_path;
|
||||||
|
|
||||||
// phoenix functions
|
// phoenix functions
|
||||||
|
|
|
@ -117,8 +117,8 @@ private:
|
||||||
void increment()
|
void increment()
|
||||||
{
|
{
|
||||||
// variables used to extract vertex components.
|
// variables used to extract vertex components.
|
||||||
geometry_type::coord_type x;
|
geometry_type::coordinate_type x;
|
||||||
geometry_type::coord_type y;
|
geometry_type::coordinate_type y;
|
||||||
|
|
||||||
// extract next vertex components.
|
// extract next vertex components.
|
||||||
unsigned cmd = path_.vertex(&x, &y);
|
unsigned cmd = path_.vertex(&x, &y);
|
||||||
|
@ -170,7 +170,7 @@ private:
|
||||||
// Specialization of geometry_iterator, as needed by mapnik::svg::svg_path_data_grammar.
|
// Specialization of geometry_iterator, as needed by mapnik::svg::svg_path_data_grammar.
|
||||||
// The Value type is a std::tuple that holds 5 elements, the command and the x and y coordinate.
|
// The Value type is a std::tuple that holds 5 elements, the command and the x and y coordinate.
|
||||||
// Each coordinate is stored twice to match the needs of the grammar.
|
// Each coordinate is stored twice to match the needs of the grammar.
|
||||||
//using path_iterator_type = path_iterator<std::tuple<unsigned, geometry_type::coord_type, geometry_type::value_type>,
|
//using path_iterator_type = path_iterator<std::tuple<unsigned, geometry_type::coordinate_type, geometry_type::value_type>,
|
||||||
// transform_path_adapter<view_transform, geometry_type> >;
|
// transform_path_adapter<view_transform, geometry_type> >;
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -39,7 +39,7 @@ enum CommandType : std::uint8_t {
|
||||||
|
|
||||||
template <typename T,int dim>
|
template <typename T,int dim>
|
||||||
struct vertex {
|
struct vertex {
|
||||||
using coord_type = T;
|
using coordinate_type = T;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -47,9 +47,9 @@ struct vertex<T,2>
|
||||||
{
|
{
|
||||||
enum no_init_t : std::uint8_t { no_init };
|
enum no_init_t : std::uint8_t { no_init };
|
||||||
|
|
||||||
using coord_type = T;
|
using coordinate_type = T;
|
||||||
coord_type x;
|
coordinate_type x;
|
||||||
coord_type y;
|
coordinate_type y;
|
||||||
unsigned cmd;
|
unsigned cmd;
|
||||||
|
|
||||||
vertex()
|
vertex()
|
||||||
|
@ -58,13 +58,13 @@ struct vertex<T,2>
|
||||||
explicit vertex(no_init_t)
|
explicit vertex(no_init_t)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
vertex(coord_type x_,coord_type y_,unsigned cmd_)
|
vertex(coordinate_type x_,coordinate_type y_,unsigned cmd_)
|
||||||
: x(x_),y(y_),cmd(cmd_) {}
|
: x(x_),y(y_),cmd(cmd_) {}
|
||||||
|
|
||||||
template <typename T2>
|
template <typename T2>
|
||||||
vertex(vertex<T2,2> const& rhs)
|
vertex(vertex<T2,2> const& rhs)
|
||||||
: x(coord_type(rhs.x)),
|
: x(coordinate_type(rhs.x)),
|
||||||
y(coord_type(rhs.y)),
|
y(coordinate_type(rhs.y)),
|
||||||
cmd(rhs.cmd) {}
|
cmd(rhs.cmd) {}
|
||||||
|
|
||||||
template <typename T2>
|
template <typename T2>
|
||||||
|
|
|
@ -32,9 +32,9 @@ namespace mapnik { namespace geometry {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct point_vertex_adapter
|
struct point_vertex_adapter
|
||||||
{
|
{
|
||||||
using coord_type = T;
|
using coordinate_type = T;
|
||||||
point_vertex_adapter(point<T> const& pt);
|
point_vertex_adapter(point<T> const& pt);
|
||||||
unsigned vertex(coord_type * x, coord_type * y) const;
|
unsigned vertex(coordinate_type * x, coordinate_type * y) const;
|
||||||
void rewind(unsigned) const;
|
void rewind(unsigned) const;
|
||||||
geometry_types type () const;
|
geometry_types type () const;
|
||||||
point<T> const& pt_;
|
point<T> const& pt_;
|
||||||
|
@ -44,9 +44,9 @@ struct point_vertex_adapter
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct line_string_vertex_adapter
|
struct line_string_vertex_adapter
|
||||||
{
|
{
|
||||||
using coord_type = T;
|
using coordinate_type = T;
|
||||||
line_string_vertex_adapter(line_string<T> const& line);
|
line_string_vertex_adapter(line_string<T> const& line);
|
||||||
unsigned vertex(coord_type * x, coord_type * y) const;
|
unsigned vertex(coordinate_type * x, coordinate_type * y) const;
|
||||||
void rewind(unsigned) const;
|
void rewind(unsigned) const;
|
||||||
geometry_types type () const;
|
geometry_types type () const;
|
||||||
line_string<T> const& line_;
|
line_string<T> const& line_;
|
||||||
|
@ -57,10 +57,10 @@ struct line_string_vertex_adapter
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct polygon_vertex_adapter
|
struct polygon_vertex_adapter
|
||||||
{
|
{
|
||||||
using coord_type = T;
|
using coordinate_type = T;
|
||||||
polygon_vertex_adapter(polygon<T> const& poly);
|
polygon_vertex_adapter(polygon<T> const& poly);
|
||||||
void rewind(unsigned) const;
|
void rewind(unsigned) const;
|
||||||
unsigned vertex(coord_type * x, coord_type * y) const;
|
unsigned vertex(coordinate_type * x, coordinate_type * y) const;
|
||||||
geometry_types type () const;
|
geometry_types type () const;
|
||||||
private:
|
private:
|
||||||
polygon<T> const& poly_;
|
polygon<T> const& poly_;
|
||||||
|
@ -74,10 +74,10 @@ private:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct ring_vertex_adapter
|
struct ring_vertex_adapter
|
||||||
{
|
{
|
||||||
using coord_type = T;
|
using coordinate_type = T;
|
||||||
ring_vertex_adapter(linear_ring<T> const& ring);
|
ring_vertex_adapter(linear_ring<T> const& ring);
|
||||||
void rewind(unsigned) const;
|
void rewind(unsigned) const;
|
||||||
unsigned vertex(coord_type * x, coord_type * y) const;
|
unsigned vertex(coordinate_type * x, coordinate_type * y) const;
|
||||||
geometry_types type () const;
|
geometry_types type () const;
|
||||||
private:
|
private:
|
||||||
linear_ring<T> const& ring_;
|
linear_ring<T> const& ring_;
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace mapnik
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class vertex_vector : private util::noncopyable
|
class vertex_vector : private util::noncopyable
|
||||||
{
|
{
|
||||||
using coord_type = T;
|
using coordinate_type = T;
|
||||||
enum block_e {
|
enum block_e {
|
||||||
block_shift = 8,
|
block_shift = 8,
|
||||||
block_size = 1<<block_shift,
|
block_size = 1<<block_shift,
|
||||||
|
@ -51,13 +51,13 @@ class vertex_vector : private util::noncopyable
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
// required for iterators support
|
// required for iterators support
|
||||||
using value_type = std::tuple<unsigned,coord_type,coord_type>;
|
using value_type = std::tuple<unsigned,coordinate_type,coordinate_type>;
|
||||||
using size_type = std::size_t;
|
using size_type = std::size_t;
|
||||||
using command_size = std::uint8_t;
|
using command_size = std::uint8_t;
|
||||||
private:
|
private:
|
||||||
unsigned num_blocks_;
|
unsigned num_blocks_;
|
||||||
unsigned max_blocks_;
|
unsigned max_blocks_;
|
||||||
coord_type** vertices_;
|
coordinate_type** vertices_;
|
||||||
command_size** commands_;
|
command_size** commands_;
|
||||||
size_type pos_;
|
size_type pos_;
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ public:
|
||||||
{
|
{
|
||||||
if ( num_blocks_ )
|
if ( num_blocks_ )
|
||||||
{
|
{
|
||||||
coord_type** vertices=vertices_ + num_blocks_ - 1;
|
coordinate_type** vertices=vertices_ + num_blocks_ - 1;
|
||||||
while ( num_blocks_-- )
|
while ( num_blocks_-- )
|
||||||
{
|
{
|
||||||
::operator delete(*vertices);
|
::operator delete(*vertices);
|
||||||
|
@ -88,14 +88,14 @@ public:
|
||||||
return pos_;
|
return pos_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_back (coord_type x,coord_type y,command_size command)
|
void push_back (coordinate_type x,coordinate_type y,command_size command)
|
||||||
{
|
{
|
||||||
size_type block = pos_ >> block_shift;
|
size_type block = pos_ >> block_shift;
|
||||||
if (block >= num_blocks_)
|
if (block >= num_blocks_)
|
||||||
{
|
{
|
||||||
allocate_block(block);
|
allocate_block(block);
|
||||||
}
|
}
|
||||||
coord_type* vertex = vertices_[block] + ((pos_ & block_mask) << 1);
|
coordinate_type* vertex = vertices_[block] + ((pos_ & block_mask) << 1);
|
||||||
command_size* cmd= commands_[block] + (pos_ & block_mask);
|
command_size* cmd= commands_[block] + (pos_ & block_mask);
|
||||||
|
|
||||||
*cmd = static_cast<command_size>(command);
|
*cmd = static_cast<command_size>(command);
|
||||||
|
@ -103,11 +103,11 @@ public:
|
||||||
*vertex = y;
|
*vertex = y;
|
||||||
++pos_;
|
++pos_;
|
||||||
}
|
}
|
||||||
unsigned get_vertex(unsigned pos,coord_type* x,coord_type* y) const
|
unsigned get_vertex(unsigned pos,coordinate_type* x,coordinate_type* y) const
|
||||||
{
|
{
|
||||||
if (pos >= pos_) return SEG_END;
|
if (pos >= pos_) return SEG_END;
|
||||||
size_type block = pos >> block_shift;
|
size_type block = pos >> block_shift;
|
||||||
const coord_type* vertex = vertices_[block] + (( pos & block_mask) << 1);
|
const coordinate_type* vertex = vertices_[block] + (( pos & block_mask) << 1);
|
||||||
*x = (*vertex++);
|
*x = (*vertex++);
|
||||||
*y = (*vertex);
|
*y = (*vertex);
|
||||||
return commands_[block] [pos & block_mask];
|
return commands_[block] [pos & block_mask];
|
||||||
|
@ -126,8 +126,8 @@ private:
|
||||||
{
|
{
|
||||||
if (block >= max_blocks_)
|
if (block >= max_blocks_)
|
||||||
{
|
{
|
||||||
coord_type** new_vertices =
|
coordinate_type** new_vertices =
|
||||||
static_cast<coord_type**>(::operator new (sizeof(coord_type*)*((max_blocks_ + grow_by) * 2)));
|
static_cast<coordinate_type**>(::operator new (sizeof(coordinate_type*)*((max_blocks_ + grow_by) * 2)));
|
||||||
command_size** new_commands = (command_size**)(new_vertices + max_blocks_ + grow_by);
|
command_size** new_commands = (command_size**)(new_vertices + max_blocks_ + grow_by);
|
||||||
if (vertices_)
|
if (vertices_)
|
||||||
{
|
{
|
||||||
|
@ -139,8 +139,8 @@ private:
|
||||||
commands_ = new_commands;
|
commands_ = new_commands;
|
||||||
max_blocks_ += grow_by;
|
max_blocks_ += grow_by;
|
||||||
}
|
}
|
||||||
vertices_[block] = static_cast<coord_type*>
|
vertices_[block] = static_cast<coordinate_type*>
|
||||||
(::operator new(sizeof(coord_type)*(block_size * 2 + block_size / (sizeof(coord_type)))));
|
(::operator new(sizeof(coordinate_type)*(block_size * 2 + block_size / (sizeof(coordinate_type)))));
|
||||||
|
|
||||||
commands_[block] = (command_size*)(vertices_[block] + block_size*2);
|
commands_[block] = (command_size*)(vertices_[block] + block_size*2);
|
||||||
++num_blocks_;
|
++num_blocks_;
|
||||||
|
|
|
@ -104,31 +104,31 @@ template <typename OutputIterator, typename Geometry>
|
||||||
struct wkt_generator_grammar :
|
struct wkt_generator_grammar :
|
||||||
karma::grammar<OutputIterator, Geometry const& ()>
|
karma::grammar<OutputIterator, Geometry const& ()>
|
||||||
{
|
{
|
||||||
using coord_type = typename Geometry::coord_type;
|
using coordinate_type = typename Geometry::coordinate_type;
|
||||||
wkt_generator_grammar();
|
wkt_generator_grammar();
|
||||||
// rules
|
// rules
|
||||||
karma::rule<OutputIterator, Geometry const&()> geometry;
|
karma::rule<OutputIterator, Geometry const&()> geometry;
|
||||||
karma::rule<OutputIterator, karma::locals<mapnik::geometry::geometry_types>, Geometry const&() > geometry_dispatch;
|
karma::rule<OutputIterator, karma::locals<mapnik::geometry::geometry_types>, Geometry const&() > geometry_dispatch;
|
||||||
karma::rule<OutputIterator, geometry::geometry<coord_type> const&()> point;
|
karma::rule<OutputIterator, geometry::geometry<coordinate_type> const&()> point;
|
||||||
karma::rule<OutputIterator, geometry::point<coord_type> const&()> point_coord;
|
karma::rule<OutputIterator, geometry::point<coordinate_type> const&()> point_coord;
|
||||||
karma::rule<OutputIterator, geometry::geometry<coord_type> const&()> linestring;
|
karma::rule<OutputIterator, geometry::geometry<coordinate_type> const&()> linestring;
|
||||||
karma::rule<OutputIterator, geometry::line_string<coord_type> const&()> linestring_coord;
|
karma::rule<OutputIterator, geometry::line_string<coordinate_type> const&()> linestring_coord;
|
||||||
karma::rule<OutputIterator, geometry::geometry<coord_type> const&()> polygon;
|
karma::rule<OutputIterator, geometry::geometry<coordinate_type> const&()> polygon;
|
||||||
karma::rule<OutputIterator, geometry::polygon<coord_type> const&()> polygon_coord;
|
karma::rule<OutputIterator, geometry::polygon<coordinate_type> const&()> polygon_coord;
|
||||||
karma::rule<OutputIterator, geometry::linear_ring<coord_type> const&()> exterior_ring_coord;
|
karma::rule<OutputIterator, geometry::linear_ring<coordinate_type> const&()> exterior_ring_coord;
|
||||||
karma::rule<OutputIterator, std::vector<geometry::linear_ring<coord_type> > const&()> interior_ring_coord;
|
karma::rule<OutputIterator, std::vector<geometry::linear_ring<coordinate_type> > const&()> interior_ring_coord;
|
||||||
karma::rule<OutputIterator, geometry::geometry<coord_type> const& ()> multi_point;
|
karma::rule<OutputIterator, geometry::geometry<coordinate_type> const& ()> multi_point;
|
||||||
karma::rule<OutputIterator, geometry::multi_point<coord_type> const& ()> multi_point_coord;
|
karma::rule<OutputIterator, geometry::multi_point<coordinate_type> const& ()> multi_point_coord;
|
||||||
karma::rule<OutputIterator, geometry::geometry<coord_type> const& ()> multi_linestring;
|
karma::rule<OutputIterator, geometry::geometry<coordinate_type> const& ()> multi_linestring;
|
||||||
karma::rule<OutputIterator, geometry::multi_line_string<coord_type> const& ()> multi_linestring_coord;
|
karma::rule<OutputIterator, geometry::multi_line_string<coordinate_type> const& ()> multi_linestring_coord;
|
||||||
karma::rule<OutputIterator, geometry::geometry<coord_type> const& ()> multi_polygon;
|
karma::rule<OutputIterator, geometry::geometry<coordinate_type> const& ()> multi_polygon;
|
||||||
karma::rule<OutputIterator, geometry::multi_polygon<coord_type> const& ()> multi_polygon_coord;
|
karma::rule<OutputIterator, geometry::multi_polygon<coordinate_type> const& ()> multi_polygon_coord;
|
||||||
karma::rule<OutputIterator, geometry::geometry<coord_type> const& ()> geometry_collection;
|
karma::rule<OutputIterator, geometry::geometry<coordinate_type> const& ()> geometry_collection;
|
||||||
karma::rule<OutputIterator, geometry::geometry_collection<coord_type> const& ()> geometries;
|
karma::rule<OutputIterator, geometry::geometry_collection<coordinate_type> const& ()> geometries;
|
||||||
boost::phoenix::function<detail::get_type<Geometry> > geometry_type;
|
boost::phoenix::function<detail::get_type<Geometry> > geometry_type;
|
||||||
karma::symbols<mapnik::geometry::geometry_types, char const*> empty;
|
karma::symbols<mapnik::geometry::geometry_types, char const*> empty;
|
||||||
//
|
//
|
||||||
typename detail::coordinate_generator<coord_type>::generator coordinate;
|
typename detail::coordinate_generator<coordinate_type>::generator coordinate;
|
||||||
};
|
};
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -34,7 +34,7 @@ point_vertex_adapter<T>::point_vertex_adapter(point<T> const& pt)
|
||||||
first_(true) {}
|
first_(true) {}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
unsigned point_vertex_adapter<T>::vertex(coord_type * x, coord_type * y) const
|
unsigned point_vertex_adapter<T>::vertex(coordinate_type * x, coordinate_type * y) const
|
||||||
{
|
{
|
||||||
if (first_)
|
if (first_)
|
||||||
{
|
{
|
||||||
|
@ -67,7 +67,7 @@ line_string_vertex_adapter<T>::line_string_vertex_adapter(line_string<T> const&
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
unsigned line_string_vertex_adapter<T>::vertex(coord_type * x, coord_type * y) const
|
unsigned line_string_vertex_adapter<T>::vertex(coordinate_type * x, coordinate_type * y) const
|
||||||
{
|
{
|
||||||
if (current_index_ != end_index_)
|
if (current_index_ != end_index_)
|
||||||
{
|
{
|
||||||
|
@ -117,7 +117,7 @@ void polygon_vertex_adapter<T>::rewind(unsigned) const
|
||||||
start_loop_ = true;
|
start_loop_ = true;
|
||||||
}
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
unsigned polygon_vertex_adapter<T>::vertex(coord_type * x, coord_type * y) const
|
unsigned polygon_vertex_adapter<T>::vertex(coordinate_type * x, coordinate_type * y) const
|
||||||
{
|
{
|
||||||
if (rings_itr_ == rings_end_)
|
if (rings_itr_ == rings_end_)
|
||||||
{
|
{
|
||||||
|
@ -177,7 +177,7 @@ void ring_vertex_adapter<T>::rewind(unsigned) const
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
unsigned ring_vertex_adapter<T>::vertex(coord_type * x, coord_type * y) const
|
unsigned ring_vertex_adapter<T>::vertex(coordinate_type * x, coordinate_type * y) const
|
||||||
{
|
{
|
||||||
if (current_index_ < end_index_)
|
if (current_index_ < end_index_)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue