Compare commits
8 commits
master
...
geometry-r
Author | SHA1 | Date | |
---|---|---|---|
|
afbd808c73 | ||
|
e0d82f90de | ||
|
cc446f8ed7 | ||
|
9255404983 | ||
|
4bdfdc712a | ||
|
855d5be432 | ||
|
da120ba751 | ||
|
348ce1fbd4 |
74 changed files with 1137 additions and 1287 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -9,3 +9,6 @@
|
|||
[submodule "deps/mapbox/variant"]
|
||||
path = deps/mapbox/variant
|
||||
url = https://github.com/mapbox/variant.git
|
||||
[submodule "deps/mapbox/geometry"]
|
||||
path = deps/mapbox/geometry
|
||||
url = https://github.com/mapbox/geometry.hpp.git
|
||||
|
|
|
@ -1598,6 +1598,7 @@ if not preconfigured:
|
|||
env.Prepend(CPPPATH = '#deps/agg/include')
|
||||
env.Prepend(LIBPATH = '#deps/agg')
|
||||
env.Prepend(CPPPATH = '#deps/mapbox/variant/include')
|
||||
env.Prepend(CPPPATH = '#deps/mapbox/geometry/include')
|
||||
# prepend deps dir for auxillary headers
|
||||
env.Prepend(CPPPATH = '#deps')
|
||||
|
||||
|
|
|
@ -123,12 +123,12 @@ public:
|
|||
|
||||
if (cmd == mapnik::SEG_CLOSE)
|
||||
{
|
||||
ring.add_coord(x0, y0);
|
||||
ring.emplace_back(x0, y0);
|
||||
break;
|
||||
}
|
||||
ring.add_coord(x,y);
|
||||
ring.emplace_back(x,y);
|
||||
}
|
||||
poly2.set_exterior_ring(std::move(ring));
|
||||
poly2.push_back(std::move(ring));
|
||||
// interior rings
|
||||
ring.clear();
|
||||
while ((cmd = clipped.vertex(&x, &y)) != mapnik::SEG_END)
|
||||
|
@ -139,12 +139,12 @@ public:
|
|||
}
|
||||
else if (cmd == mapnik::SEG_CLOSE)
|
||||
{
|
||||
ring.add_coord(x0,y0);
|
||||
poly2.add_hole(std::move(ring));
|
||||
ring.emplace_back(x0,y0);
|
||||
poly2.push_back(std::move(ring));
|
||||
ring.clear();
|
||||
continue;
|
||||
}
|
||||
ring.add_coord(x,y);
|
||||
ring.emplace_back(x,y);
|
||||
}
|
||||
|
||||
std::string expect = expected_+".png";
|
||||
|
@ -243,11 +243,11 @@ public:
|
|||
mapnik::geometry::correct(poly);
|
||||
|
||||
mapnik::geometry::linear_ring<double> bbox;
|
||||
bbox.add_coord(extent_.minx(), extent_.miny());
|
||||
bbox.add_coord(extent_.minx(), extent_.maxy());
|
||||
bbox.add_coord(extent_.maxx(), extent_.maxy());
|
||||
bbox.add_coord(extent_.maxx(), extent_.miny());
|
||||
bbox.add_coord(extent_.minx(), extent_.miny());
|
||||
bbox.emplace_back(extent_.minx(), extent_.miny());
|
||||
bbox.emplace_back(extent_.minx(), extent_.maxy());
|
||||
bbox.emplace_back(extent_.maxx(), extent_.maxy());
|
||||
bbox.emplace_back(extent_.maxx(), extent_.miny());
|
||||
bbox.emplace_back(extent_.minx(), extent_.miny());
|
||||
|
||||
std::deque<mapnik::geometry::polygon<double> > result;
|
||||
boost::geometry::intersection(bbox, poly, result);
|
||||
|
@ -291,11 +291,11 @@ public:
|
|||
mapnik::geometry::correct(poly);
|
||||
|
||||
mapnik::geometry::linear_ring<double> bbox;
|
||||
bbox.add_coord(extent_.minx(), extent_.miny());
|
||||
bbox.add_coord(extent_.minx(), extent_.maxy());
|
||||
bbox.add_coord(extent_.maxx(), extent_.maxy());
|
||||
bbox.add_coord(extent_.maxx(), extent_.miny());
|
||||
bbox.add_coord(extent_.minx(), extent_.miny());
|
||||
bbox.emplace_back(extent_.minx(), extent_.miny());
|
||||
bbox.emplace_back(extent_.minx(), extent_.maxy());
|
||||
bbox.emplace_back(extent_.maxx(), extent_.maxy());
|
||||
bbox.emplace_back(extent_.maxx(), extent_.miny());
|
||||
bbox.emplace_back(extent_.minx(), extent_.miny());
|
||||
|
||||
bool valid = true;
|
||||
for (unsigned i=0;i<iterations_;++i)
|
||||
|
@ -520,7 +520,7 @@ int main(int argc, char** argv)
|
|||
// RECT : POLYGON ((181 106, 181 470, 631 470, 631 106, 181 106))
|
||||
// OUT (expected)
|
||||
// POLYGON ((181 286.6666666666667, 233 454, 315 340, 421 446, 463 324, 559 466, 631 321.3207547169811, 631 234.38686131386862, 528 178, 394 229, 329 138, 212 134, 183 228, 200 264, 181 238.24444444444444, 181 286.6666666666667),(313 190, 440 256, 470 248, 510 305, 533 237, 613 263, 553 397, 455 262, 405 378, 343 287, 249 334, 229 191, 313 190))
|
||||
|
||||
#if 0
|
||||
mapnik::box2d<double> clipping_box(181,106,631,470);
|
||||
std::string filename_("./benchmark/data/polygon.wkt");
|
||||
std::ifstream in(filename_.c_str(),std::ios_base::in | std::ios_base::binary);
|
||||
|
@ -543,5 +543,6 @@ int main(int argc, char** argv)
|
|||
return_value = return_value | run(test_runner,"clipping polygon with clipper_tree");
|
||||
}
|
||||
*/
|
||||
return return_value;
|
||||
#endif
|
||||
return 0;// return_value;
|
||||
}
|
||||
|
|
4
deps/mapnik/build.py
vendored
4
deps/mapnik/build.py
vendored
|
@ -7,7 +7,9 @@ subdirs = {
|
|||
'./sparsehash':{'dir':'sparsehash','glob':'*'},
|
||||
'./sparsehash/internal':{'dir':'sparsehash/internal','glob':'*'},
|
||||
'../agg/include':{'dir':'agg','glob':'agg*'},
|
||||
'../mapbox/variant/include':{'dir':'mapbox','glob':'*/*.hpp'}
|
||||
'../mapbox/variant/include':{'dir':'mapbox','glob':'*/*.hpp'},
|
||||
'../mapbox/geometry/include':{'dir':'mapbox','glob':'*/*.hpp'},
|
||||
'../mapbox/geometry/include/mapbox':{'dir':'mapbox/geometry','glob':'*/*.hpp'}
|
||||
}
|
||||
|
||||
if 'install' in COMMAND_LINE_TARGETS:
|
||||
|
|
|
@ -27,6 +27,7 @@ Import('env')
|
|||
base = './mapnik/'
|
||||
subdirs = [
|
||||
'',
|
||||
'geometry',
|
||||
'csv',
|
||||
'svg',
|
||||
'wkt',
|
||||
|
|
|
@ -105,7 +105,7 @@ public:
|
|||
: id_(_id),
|
||||
ctx_(ctx),
|
||||
data_(ctx_->mapping_.size()),
|
||||
geom_(geometry::geometry_empty()),
|
||||
geom_(geometry::geometry_empty<double>()),
|
||||
raster_() {}
|
||||
|
||||
inline mapnik::value_integer id() const { return id_;}
|
||||
|
|
|
@ -23,117 +23,34 @@
|
|||
#ifndef MAPNIK_GEOMETRY_HPP
|
||||
#define MAPNIK_GEOMETRY_HPP
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/geometry/point.hpp>
|
||||
#include <mapnik/geometry/line_string.hpp>
|
||||
#include <mapnik/geometry/polygon.hpp>
|
||||
#include <mapnik/geometry/multi_point.hpp>
|
||||
#include <mapnik/geometry/multi_line_string.hpp>
|
||||
#include <mapnik/geometry/multi_polygon.hpp>
|
||||
//
|
||||
#include <mapnik/util/variant.hpp>
|
||||
// stl
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
#include <type_traits>
|
||||
#include <cstddef>
|
||||
|
||||
namespace mapnik { namespace geometry {
|
||||
|
||||
template <typename T>
|
||||
struct point
|
||||
{
|
||||
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 == rhs);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct line_string : std::vector<point<T> >
|
||||
{
|
||||
using coord_type = T;
|
||||
line_string() = default;
|
||||
explicit line_string(std::size_t size)
|
||||
: std::vector<point<T> >(size) {}
|
||||
inline std::size_t num_points() const { return std::vector<point<T>>::size(); }
|
||||
inline void add_coord(T x, T y) { std::vector<point<T>>::template emplace_back(x,y);}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct linear_ring : line_string<T>
|
||||
{
|
||||
using coord_type = T;
|
||||
linear_ring() = default;
|
||||
explicit linear_ring(std::size_t size)
|
||||
: line_string<T>(size) {}
|
||||
linear_ring(line_string<T> && other)
|
||||
: line_string<T>(std::move(other)) {}
|
||||
linear_ring(line_string<T> const& other)
|
||||
: line_string<T>(other) {}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
using rings_container = std::vector<linear_ring<T>>;
|
||||
|
||||
template <typename T, template <typename> class InteriorRings = rings_container>
|
||||
struct polygon
|
||||
{
|
||||
using coord_type = T;
|
||||
using rings_container = InteriorRings<T>;
|
||||
linear_ring<T> exterior_ring;
|
||||
rings_container interior_rings;
|
||||
|
||||
inline void set_exterior_ring(linear_ring<T> && ring)
|
||||
{
|
||||
exterior_ring = std::move(ring);
|
||||
}
|
||||
|
||||
inline void add_hole(linear_ring<T> && ring)
|
||||
{
|
||||
interior_rings.emplace_back(std::move(ring));
|
||||
}
|
||||
|
||||
inline bool empty() const { return exterior_ring.empty(); }
|
||||
|
||||
inline std::size_t num_rings() const
|
||||
{
|
||||
return 1 + interior_rings.size();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct multi_point : line_string<T>
|
||||
{
|
||||
using coord_type = T;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct multi_line_string : std::vector<line_string<T>>
|
||||
{
|
||||
using coord_type = T;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct multi_polygon : std::vector<polygon<T>>
|
||||
{
|
||||
using coord_type = T;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
template <typename T, template <typename...> class Cont = std::vector>
|
||||
struct geometry_collection;
|
||||
|
||||
struct geometry_empty {};
|
||||
|
||||
template <typename T>
|
||||
struct geometry_empty
|
||||
{
|
||||
using coordinate_type = T;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
using geometry_base = mapnik::util::variant<geometry_empty,
|
||||
using geometry_base = mapnik::util::variant<geometry_empty<T>,
|
||||
point<T>,
|
||||
line_string<T>,
|
||||
polygon<T>,
|
||||
|
@ -144,7 +61,7 @@ using geometry_base = mapnik::util::variant<geometry_empty,
|
|||
template <typename T>
|
||||
struct geometry : geometry_base<T>
|
||||
{
|
||||
using coord_type = T;
|
||||
using coordinate_type = T;
|
||||
|
||||
#if __cpp_inheriting_constructors >= 200802
|
||||
|
||||
|
@ -161,10 +78,11 @@ struct geometry : geometry_base<T>
|
|||
#endif
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct geometry_collection : std::vector<geometry<T>>
|
||||
|
||||
template <typename T, template <typename...> class Cont>
|
||||
struct geometry_collection : Cont<geometry<T>>
|
||||
{
|
||||
using coord_type = T;
|
||||
using coordinate_type = T;
|
||||
};
|
||||
|
||||
}}
|
||||
|
|
|
@ -37,11 +37,10 @@
|
|||
// and once we do that the compile time is == to just including boost/geometry.hpp
|
||||
#include <boost/geometry.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
#include <mapnik/geometry.hpp>
|
||||
#include <mapnik/coord.hpp>
|
||||
#include <mapnik/box2d.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
// register point
|
||||
|
@ -82,7 +81,9 @@ 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 {
|
||||
namespace geometry {
|
||||
|
||||
namespace traits {
|
||||
|
||||
// register mapnik::box2d<double>
|
||||
template<> struct tag<mapnik::box2d<double> > { using type = box_tag; };
|
||||
|
@ -175,42 +176,48 @@ struct ring_mutable_type<mapnik::geometry::polygon<CoordinateType> >
|
|||
template <typename CoordinateType>
|
||||
struct interior_const_type<mapnik::geometry::polygon<CoordinateType> >
|
||||
{
|
||||
using type = typename mapnik::geometry::polygon<CoordinateType>::rings_container const&;
|
||||
using type = typename mapnik::geometry::polygon<CoordinateType>::interior_rings const&;
|
||||
};
|
||||
|
||||
template <typename CoordinateType>
|
||||
struct interior_mutable_type<mapnik::geometry::polygon<CoordinateType> >
|
||||
{
|
||||
using type = typename mapnik::geometry::polygon<CoordinateType>::rings_container&;
|
||||
using type = typename mapnik::geometry::polygon<CoordinateType>::interior_rings& ;
|
||||
};
|
||||
|
||||
// exterior
|
||||
template <typename CoordinateType>
|
||||
struct exterior_ring<mapnik::geometry::polygon<CoordinateType> >
|
||||
{
|
||||
static mapnik::geometry::linear_ring<CoordinateType> & get(mapnik::geometry::polygon<CoordinateType> & p)
|
||||
using ring_const_type = typename ring_const_type<mapnik::geometry::polygon<CoordinateType> >::type;
|
||||
using ring_mutable_type = typename ring_mutable_type<mapnik::geometry::polygon<CoordinateType> >::type;
|
||||
static ring_mutable_type get(mapnik::geometry::polygon<CoordinateType> & p)
|
||||
{
|
||||
return p.exterior_ring;
|
||||
if (p.empty()) throw std::runtime_error("ring must be initialized 1");
|
||||
return p[0];
|
||||
}
|
||||
|
||||
static mapnik::geometry::linear_ring<CoordinateType> const& get(mapnik::geometry::polygon<CoordinateType> const& p)
|
||||
static ring_const_type get(mapnik::geometry::polygon<CoordinateType> const& p)
|
||||
{
|
||||
return p.exterior_ring;
|
||||
if (p.empty()) throw std::runtime_error("ring must be initialized 2");
|
||||
return p[0];
|
||||
}
|
||||
};
|
||||
|
||||
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)
|
||||
using interior_const_type = typename interior_const_type<mapnik::geometry::polygon<CoordinateType> >::type;
|
||||
using interior_mutable_type = typename interior_mutable_type<mapnik::geometry::polygon<CoordinateType> >::type;
|
||||
|
||||
static interior_const_type get(mapnik::geometry::polygon<CoordinateType> const& p)
|
||||
{
|
||||
return p.interior_rings;
|
||||
return p.interior();
|
||||
}
|
||||
|
||||
static holes_type const& get(mapnik::geometry::polygon<CoordinateType> const& p)
|
||||
static interior_mutable_type get(mapnik::geometry::polygon<CoordinateType>& p)
|
||||
{
|
||||
return p.interior_rings;
|
||||
return p.interior();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -41,13 +41,13 @@ struct geometry_centroid
|
|||
geometry_centroid(point<T> & pt)
|
||||
: pt_(pt) {}
|
||||
|
||||
template <typename T1>
|
||||
result_type operator() (T1 const& geom) const
|
||||
template <typename U>
|
||||
result_type operator() (U const& geom) const
|
||||
{
|
||||
return util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
result_type operator() (geometry_empty const&) const
|
||||
result_type operator() (geometry_empty<T> const&) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -105,17 +105,29 @@ private:
|
|||
}
|
||||
|
||||
template <typename Geom>
|
||||
result_type centroid_multi(Geom const & geom) const
|
||||
result_type centroid_multi(Geom const & multi_geom) const
|
||||
{
|
||||
// https://github.com/mapnik/mapnik/issues/3169
|
||||
#if BOOST_VERSION <= 105900
|
||||
if (mapnik::geometry::has_empty(geom))
|
||||
if (mapnik::geometry::has_empty(multi_geom))
|
||||
{
|
||||
Geom stripped = mapnik::geometry::remove_empty(geom);
|
||||
return centroid_simple(stripped);
|
||||
mapnik::geometry::multi_point<T> multi_pt;
|
||||
multi_pt.reserve(multi_geom.size());
|
||||
for (auto const& geom : multi_geom)
|
||||
{
|
||||
try
|
||||
{
|
||||
point<T> c;
|
||||
boost::geometry::centroid(geom, c);
|
||||
multi_pt.push_back(std::move(c));
|
||||
|
||||
}
|
||||
catch (boost::geometry::centroid_exception const & e) {}
|
||||
}
|
||||
return centroid_simple(multi_pt);
|
||||
}
|
||||
#endif
|
||||
return centroid_simple(geom);
|
||||
return centroid_simple(multi_geom);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -60,13 +60,13 @@ struct geometry_correct
|
|||
template <typename T>
|
||||
result_type operator() (polygon<T> & poly) const
|
||||
{
|
||||
boost::geometry::correct(poly);
|
||||
if (!poly.empty()) boost::geometry::correct(poly);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (multi_polygon<T> & multi_poly) const
|
||||
{
|
||||
boost::geometry::correct(multi_poly);
|
||||
if (!multi_poly.empty()) boost::geometry::correct(multi_poly);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace mapnik {
|
|||
namespace geometry {
|
||||
|
||||
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 mapnik
|
||||
|
|
|
@ -31,11 +31,11 @@ namespace detail {
|
|||
template <typename T>
|
||||
struct geometry_envelope
|
||||
{
|
||||
using coord_type = T;
|
||||
using bbox_type = box2d<coord_type>;
|
||||
using coordinate_type = T;
|
||||
using bbox_type = box2d<coordinate_type>;
|
||||
bbox_type & bbox;
|
||||
|
||||
geometry_envelope(bbox_type & bbox_)
|
||||
explicit geometry_envelope(bbox_type & bbox_)
|
||||
: bbox(bbox_) {}
|
||||
|
||||
template <typename U>
|
||||
|
@ -44,7 +44,7 @@ struct geometry_envelope
|
|||
return mapnik::util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
void operator() (mapnik::geometry::geometry_empty const&) const {}
|
||||
void operator() (mapnik::geometry::geometry_empty<T> const&) const {}
|
||||
|
||||
void operator() (mapnik::geometry::point<T> const& pt) const
|
||||
{
|
||||
|
@ -57,58 +57,22 @@ struct geometry_envelope
|
|||
|
||||
void operator() (mapnik::geometry::line_string<T> const& line) const
|
||||
{
|
||||
bool first = true;
|
||||
for (auto const& pt : line)
|
||||
{
|
||||
if (first && !bbox.valid())
|
||||
{
|
||||
bbox.init(pt.x, pt.y, pt.x, pt.y);
|
||||
first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bbox.expand_to_include(pt.x, pt.y);
|
||||
}
|
||||
}
|
||||
_envelope_impl(line, bbox);
|
||||
}
|
||||
|
||||
void operator() (mapnik::geometry::linear_ring<T> const& ring) const
|
||||
{
|
||||
(*this)(static_cast<mapnik::geometry::line_string<T> const&>(ring));
|
||||
_envelope_impl(ring, bbox);
|
||||
}
|
||||
|
||||
void operator() (mapnik::geometry::polygon<T> const& poly) const
|
||||
{
|
||||
bool first = true;
|
||||
for (auto const& pt : poly.exterior_ring)
|
||||
{
|
||||
if (first && !bbox.valid())
|
||||
{
|
||||
bbox.init(pt.x, pt.y, pt.x, pt.y);
|
||||
first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bbox.expand_to_include(pt.x, pt.y);
|
||||
}
|
||||
}
|
||||
if (!poly.empty()) _envelope_impl(poly[0], bbox);
|
||||
}
|
||||
|
||||
void operator() (mapnik::geometry::multi_point<T> const& multi_point) const
|
||||
{
|
||||
bool first = true;
|
||||
for (auto const& pt : multi_point)
|
||||
{
|
||||
if (first && !bbox.valid())
|
||||
{
|
||||
bbox.init(pt.x, pt.y, pt.x, pt.y);
|
||||
first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bbox.expand_to_include(pt.x, pt.y);
|
||||
}
|
||||
}
|
||||
_envelope_impl(multi_point, bbox);
|
||||
}
|
||||
|
||||
void operator() (mapnik::geometry::multi_line_string<T> const& multi_line) const
|
||||
|
@ -134,16 +98,35 @@ struct geometry_envelope
|
|||
(*this)(geom);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename Points>
|
||||
void _envelope_impl(Points const& points, bbox_type & b) const
|
||||
{
|
||||
bool first = true;
|
||||
for (auto const& pt : points)
|
||||
{
|
||||
if (first && !b.valid())
|
||||
{
|
||||
b.init(pt.x, pt.y, pt.x, pt.y);
|
||||
first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
b.expand_to_include(pt.x, pt.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // end ns detail
|
||||
|
||||
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;
|
||||
box2d<coord_type> bbox;
|
||||
detail::geometry_envelope<coord_type> op(bbox);
|
||||
using coordinate_type = typename T::coordinate_type;
|
||||
box2d<coordinate_type> bbox;
|
||||
detail::geometry_envelope<coordinate_type> op(bbox);
|
||||
op(geom);
|
||||
return bbox;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef MAPNIK_GEOMETRY_FUSION_ADAPTED_HPP
|
||||
#define MAPNIK_GEOMETRY_FUSION_ADAPTED_HPP
|
||||
|
||||
#include <mapnik/geometry.hpp>
|
||||
#include <mapnik/geometry/polygon.hpp>
|
||||
#include <boost/fusion/include/adapt_struct.hpp>
|
||||
|
||||
BOOST_FUSION_ADAPT_STRUCT(
|
||||
|
@ -39,14 +39,4 @@ BOOST_FUSION_ADAPT_STRUCT(
|
|||
(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
|
||||
|
|
|
@ -29,103 +29,114 @@ namespace mapnik { namespace geometry {
|
|||
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
struct geometry_is_empty
|
||||
{
|
||||
bool operator() (mapnik::geometry::geometry<double> const& geom) const
|
||||
bool operator() (mapnik::geometry::geometry<T> const& geom) const
|
||||
{
|
||||
return mapnik::util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
bool operator() (mapnik::geometry::point<double> const&) const
|
||||
bool operator() (mapnik::geometry::point<T> const&) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator() (mapnik::geometry::line_string<double> const& geom) const
|
||||
bool operator() (mapnik::geometry::line_string<T> const& geom) const
|
||||
{
|
||||
return geom.empty();
|
||||
}
|
||||
|
||||
bool operator() (mapnik::geometry::polygon<double> const& geom) const
|
||||
bool operator() (mapnik::geometry::linear_ring<T> const& geom) const
|
||||
{
|
||||
return geom.empty();
|
||||
}
|
||||
|
||||
bool operator() (mapnik::geometry::multi_point<double> const& geom) const
|
||||
bool operator() (mapnik::geometry::polygon<T> const& geom) const
|
||||
{
|
||||
return geom.empty() || geom.front().empty();
|
||||
}
|
||||
|
||||
bool operator() (mapnik::geometry::multi_point<T> const& geom) const
|
||||
{
|
||||
return geom.empty();
|
||||
}
|
||||
|
||||
bool operator() (mapnik::geometry::multi_line_string<double> const& geom) const
|
||||
bool operator() (mapnik::geometry::multi_line_string<T> const& geom) const
|
||||
{
|
||||
return geom.empty();
|
||||
}
|
||||
|
||||
bool operator() (mapnik::geometry::multi_polygon<double> const& geom) const
|
||||
bool operator() (mapnik::geometry::multi_polygon<T> const& geom) const
|
||||
{
|
||||
return geom.empty();
|
||||
}
|
||||
|
||||
bool operator() (mapnik::geometry::geometry_collection<double> const& geom) const
|
||||
bool operator() (mapnik::geometry::geometry_collection<T> const& geom) const
|
||||
{
|
||||
return geom.empty();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator() (T const&) const
|
||||
template <typename U>
|
||||
bool operator() (U const&) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct geometry_has_empty
|
||||
{
|
||||
bool operator() (mapnik::geometry::geometry<double> const& geom) const
|
||||
bool operator() (mapnik::geometry::geometry<T> const& geom) const
|
||||
{
|
||||
return mapnik::util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
bool operator() (mapnik::geometry::geometry_empty const&) const
|
||||
bool operator() (mapnik::geometry::geometry_empty<T> const&) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator() (mapnik::geometry::point<double> const&) const
|
||||
bool operator() (mapnik::geometry::point<T> const&) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator() (mapnik::geometry::line_string<double> const&) const
|
||||
bool operator() (mapnik::geometry::line_string<T> const&) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator() (mapnik::geometry::polygon<double> const&) const
|
||||
bool operator() (mapnik::geometry::linear_ring<T> const&) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator() (mapnik::geometry::multi_point<double> const&) const
|
||||
bool operator() (mapnik::geometry::polygon<T> const&) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator() (mapnik::geometry::multi_line_string<double> const& geom) const
|
||||
bool operator() (mapnik::geometry::multi_point<T> const&) const
|
||||
{
|
||||
return test_multigeometry(geom);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator() (mapnik::geometry::multi_polygon<double> const& geom) const
|
||||
bool operator() (mapnik::geometry::multi_line_string<T> const& multi_line) const
|
||||
{
|
||||
return test_multigeometry(geom);
|
||||
}
|
||||
|
||||
bool operator() (mapnik::geometry::geometry_collection<double> const& geom) const
|
||||
{
|
||||
for (auto const & item : geom)
|
||||
for (auto const& line : multi_line)
|
||||
{
|
||||
if (geometry_is_empty()(item) || (*this)(item))
|
||||
if (line.empty()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator() (mapnik::geometry::multi_polygon<T> const& multi_poly) const
|
||||
{
|
||||
for (auto const& poly : multi_poly)
|
||||
{
|
||||
if (poly.empty() || poly.front().empty()) // no-rings OR exterior is empty
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -133,39 +144,39 @@ struct geometry_has_empty
|
|||
return false;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator() (T const&) const
|
||||
bool operator() (mapnik::geometry::geometry_collection<T> const& geom) const
|
||||
{
|
||||
for (auto const & item : geom)
|
||||
{
|
||||
if (geometry_is_empty<T>()(item) || (*this)(item))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
bool operator() (U const&) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
bool test_multigeometry(T const & geom) const
|
||||
{
|
||||
for (auto const & item : geom)
|
||||
{
|
||||
if (item.empty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template <typename GeomType>
|
||||
inline bool is_empty(GeomType const& geom)
|
||||
template <typename G>
|
||||
inline bool is_empty(G const& geom)
|
||||
{
|
||||
return detail::geometry_is_empty()(geom);
|
||||
using coordinate_type = typename G::coordinate_type;
|
||||
return detail::geometry_is_empty<coordinate_type>()(geom);
|
||||
}
|
||||
|
||||
template <typename GeomType>
|
||||
inline bool has_empty(GeomType const& geom)
|
||||
template <typename G>
|
||||
inline bool has_empty(G const& geom)
|
||||
{
|
||||
return detail::geometry_has_empty()(geom);
|
||||
using coordinate_type = typename G::coordinate_type;
|
||||
return detail::geometry_has_empty<coordinate_type>()(geom);
|
||||
}
|
||||
|
||||
}}
|
||||
|
|
|
@ -36,24 +36,23 @@ namespace mapnik { namespace geometry {
|
|||
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
struct geometry_is_simple
|
||||
{
|
||||
using result_type = bool;
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (geometry<T> const& geom) const
|
||||
{
|
||||
return mapnik::util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
result_type operator() (geometry_empty const& ) const
|
||||
result_type operator() (geometry_empty<T> const& ) const
|
||||
{
|
||||
// An empty geometry has no anomalous geometric points, such as self intersection or self tangency.
|
||||
// Therefore, we will return true
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (geometry_collection<T> const& collection) const
|
||||
{
|
||||
for (auto const& geom : collection)
|
||||
|
@ -63,12 +62,11 @@ struct geometry_is_simple
|
|||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (point<T> const& pt) const
|
||||
{
|
||||
return boost::geometry::is_simple(pt);
|
||||
}
|
||||
template <typename T>
|
||||
|
||||
result_type operator() (line_string<T> const& line) const
|
||||
{
|
||||
if (line.empty())
|
||||
|
@ -80,12 +78,12 @@ struct geometry_is_simple
|
|||
}
|
||||
return boost::geometry::is_simple(line);
|
||||
}
|
||||
template <typename T>
|
||||
|
||||
result_type operator() (polygon<T> const& poly) const
|
||||
{
|
||||
return boost::geometry::is_simple(poly);
|
||||
return poly.empty() ? true : boost::geometry::is_simple(poly);
|
||||
}
|
||||
template <typename T>
|
||||
|
||||
result_type operator() (multi_point<T> const& multi_pt) const
|
||||
{
|
||||
if (multi_pt.empty())
|
||||
|
@ -96,7 +94,7 @@ struct geometry_is_simple
|
|||
}
|
||||
return boost::geometry::is_simple(multi_pt);
|
||||
}
|
||||
template <typename T>
|
||||
|
||||
result_type operator() (multi_line_string<T> const& multi_line) const
|
||||
{
|
||||
if (multi_line.empty())
|
||||
|
@ -111,7 +109,7 @@ struct geometry_is_simple
|
|||
}
|
||||
return true;
|
||||
}
|
||||
template <typename T>
|
||||
|
||||
result_type operator() (multi_polygon<T> const& multi_poly) const
|
||||
{
|
||||
if (multi_poly.empty())
|
||||
|
@ -134,13 +132,14 @@ struct geometry_is_simple
|
|||
template <typename T>
|
||||
inline bool is_simple(T const& geom)
|
||||
{
|
||||
return detail::geometry_is_simple() (geom);
|
||||
using coordinate_type = typename T::coordinate_type;
|
||||
return detail::geometry_is_simple<coordinate_type>() (geom);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool is_simple(mapnik::geometry::geometry<T> const& geom)
|
||||
{
|
||||
return util::apply_visitor(detail::geometry_is_simple(), geom);
|
||||
return util::apply_visitor(detail::geometry_is_simple<T>(), geom);
|
||||
}
|
||||
|
||||
}}
|
||||
|
|
|
@ -37,22 +37,21 @@ namespace mapnik { namespace geometry {
|
|||
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
struct geometry_is_valid
|
||||
{
|
||||
using result_type = bool;
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (geometry<T> const& geom) const
|
||||
{
|
||||
return mapnik::util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
result_type operator() (geometry_empty const& ) const
|
||||
result_type operator() (geometry_empty<T> const& ) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (geometry_collection<T> const& collection) const
|
||||
{
|
||||
for (auto const& geom : collection)
|
||||
|
@ -62,65 +61,58 @@ struct geometry_is_valid
|
|||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (point<T> const& pt) const
|
||||
{
|
||||
return boost::geometry::is_valid(pt);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (line_string<T> const& line) const
|
||||
{
|
||||
return boost::geometry::is_valid(line);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (polygon<T> const& poly) const
|
||||
{
|
||||
return boost::geometry::is_valid(poly);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (multi_point<T> const& multi_pt) const
|
||||
{
|
||||
return boost::geometry::is_valid(multi_pt);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (multi_line_string<T> const& multi_line) const
|
||||
{
|
||||
return boost::geometry::is_valid(multi_line);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (multi_polygon<T> const& multi_poly) const
|
||||
{
|
||||
return boost::geometry::is_valid(multi_poly);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
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):
|
||||
failure_(failure) {}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (geometry<T> const& geom) const
|
||||
{
|
||||
return mapnik::util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
result_type operator() (geometry_empty const& ) const
|
||||
result_type operator() (geometry_empty<T> const& ) const
|
||||
{
|
||||
failure_ = boost::geometry::no_failure;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (geometry_collection<T> const& collection) const
|
||||
{
|
||||
for (auto const& geom : collection)
|
||||
|
@ -130,65 +122,58 @@ struct geometry_is_valid_reason
|
|||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (point<T> const& pt) const
|
||||
{
|
||||
return boost::geometry::is_valid(pt, failure_);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (line_string<T> const& line) const
|
||||
{
|
||||
return boost::geometry::is_valid(line, failure_);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (polygon<T> const& poly) const
|
||||
{
|
||||
return boost::geometry::is_valid(poly, failure_);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (multi_point<T> const& multi_pt) const
|
||||
{
|
||||
return boost::geometry::is_valid(multi_pt, failure_);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (multi_line_string<T> const& multi_line) const
|
||||
{
|
||||
return boost::geometry::is_valid(multi_line, failure_);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (multi_polygon<T> const& multi_poly) const
|
||||
{
|
||||
return boost::geometry::is_valid(multi_poly, failure_);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct geometry_is_valid_string
|
||||
{
|
||||
using result_type = bool;
|
||||
|
||||
|
||||
std::string & message_;
|
||||
|
||||
geometry_is_valid_string(std::string & message):
|
||||
message_(message) {}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (geometry<T> const& geom) const
|
||||
{
|
||||
return mapnik::util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
result_type operator() (geometry_empty const& ) const
|
||||
result_type operator() (geometry_empty<T> const& ) const
|
||||
{
|
||||
message_ = "Geometry is valid";
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (geometry_collection<T> const& collection) const
|
||||
{
|
||||
for (auto const& geom : collection)
|
||||
|
@ -198,82 +183,78 @@ struct geometry_is_valid_string
|
|||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (point<T> const& pt) const
|
||||
{
|
||||
return boost::geometry::is_valid(pt, message_);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (line_string<T> const& line) const
|
||||
{
|
||||
return boost::geometry::is_valid(line, message_);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (polygon<T> const& poly) const
|
||||
{
|
||||
return boost::geometry::is_valid(poly, message_);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (multi_point<T> const& multi_pt) const
|
||||
{
|
||||
return boost::geometry::is_valid(multi_pt, message_);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (multi_line_string<T> const& multi_line) const
|
||||
{
|
||||
return boost::geometry::is_valid(multi_line, message_);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
result_type operator() (multi_polygon<T> const& multi_poly) const
|
||||
{
|
||||
return boost::geometry::is_valid(multi_poly, message_);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool is_valid(T const& geom)
|
||||
{
|
||||
return detail::geometry_is_valid() (geom);
|
||||
using coordinate_type = typename T::coordinate_type;
|
||||
return detail::geometry_is_valid<coordinate_type>() (geom);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool is_valid(mapnik::geometry::geometry<T> const& geom)
|
||||
{
|
||||
return util::apply_visitor(detail::geometry_is_valid(), geom);
|
||||
return util::apply_visitor(detail::geometry_is_valid<T>(), geom);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool is_valid(T const& geom, boost::geometry::validity_failure_type & failure)
|
||||
{
|
||||
return detail::geometry_is_valid_reason(failure) (geom);
|
||||
using coordinate_type = typename T::coordinate_type;
|
||||
return detail::geometry_is_valid_reason<coordinate_type>(failure) (geom);
|
||||
}
|
||||
|
||||
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);
|
||||
return util::apply_visitor(detail::geometry_is_valid_reason<T>(failure), geom);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool is_valid(T const& geom, std::string & message)
|
||||
{
|
||||
return detail::geometry_is_valid_string(message) (geom);
|
||||
using coordinate_type = typename T::coordinate_type;
|
||||
return detail::geometry_is_valid_string<coordinate_type>(message) (geom);
|
||||
}
|
||||
|
||||
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);
|
||||
return util::apply_visitor(detail::geometry_is_valid_string<T>(message), geom);
|
||||
}
|
||||
|
||||
}}
|
||||
|
|
|
@ -32,25 +32,25 @@ namespace detail {
|
|||
|
||||
struct geometry_remove_empty
|
||||
{
|
||||
mapnik::geometry::multi_line_string<double> operator() (mapnik::geometry::multi_line_string<double> const & geom) const
|
||||
mapnik::geometry::multi_line_string<double> operator() (mapnik::geometry::multi_line_string<double> const& geom) const
|
||||
{
|
||||
return remove_empty(geom);
|
||||
}
|
||||
|
||||
mapnik::geometry::multi_polygon<double> operator() (mapnik::geometry::multi_polygon<double> const & geom) const
|
||||
mapnik::geometry::multi_polygon<double> operator() (mapnik::geometry::multi_polygon<double> const& geom) const
|
||||
{
|
||||
return remove_empty(geom);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T operator() (T const & geom) const
|
||||
T operator() (T const& geom) const
|
||||
{
|
||||
return geom;
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
T remove_empty(T const & geom) const
|
||||
T remove_empty(T const& geom) const
|
||||
{
|
||||
T new_geom;
|
||||
for (auto const & g : geom)
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/geometry_reprojection.hpp>
|
||||
#include <mapnik/geometry.hpp>
|
||||
|
||||
|
@ -30,9 +29,10 @@ namespace geometry {
|
|||
|
||||
namespace detail {
|
||||
|
||||
geometry_empty reproject_internal(geometry_empty const&, proj_transform const&, unsigned int &)
|
||||
template <typename T>
|
||||
geometry_empty<T> reproject_internal(geometry_empty<T> const&, proj_transform const&, unsigned int &)
|
||||
{
|
||||
return geometry_empty();
|
||||
return geometry_empty<T>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@ -62,31 +62,22 @@ template <typename T>
|
|||
polygon<T> reproject_internal(polygon<T> const& poly, proj_transform const& proj_trans, unsigned int & n_err)
|
||||
{
|
||||
polygon<T> new_poly;
|
||||
linear_ring<T> 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())
|
||||
new_poly.reserve(poly.size());
|
||||
bool exterior = true;
|
||||
for (auto const& lr : poly)
|
||||
{
|
||||
n_err += err;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_poly.set_exterior_ring(std::move(new_ext));
|
||||
new_poly.interior_rings.reserve(poly.interior_rings.size());
|
||||
|
||||
for (auto const& lr : poly.interior_rings)
|
||||
linear_ring<T> new_lr(lr);
|
||||
unsigned int err = proj_trans.forward(new_lr);
|
||||
if (err > 0 || new_lr.empty())
|
||||
{
|
||||
linear_ring<T> new_lr(lr);
|
||||
err = proj_trans.forward(new_lr);
|
||||
if (err > 0 || new_lr.empty())
|
||||
{
|
||||
n_err += err;
|
||||
// If there is an error in interior ring drop
|
||||
// it from polygon.
|
||||
continue;
|
||||
}
|
||||
new_poly.add_hole(std::move(new_lr));
|
||||
n_err += err;
|
||||
// If there is an error in interior ring drop
|
||||
// it from polygon.
|
||||
if (!exterior) continue;
|
||||
}
|
||||
if (exterior) exterior = false;
|
||||
new_poly.push_back(std::move(new_lr));
|
||||
|
||||
}
|
||||
return new_poly;
|
||||
}
|
||||
|
@ -145,7 +136,7 @@ multi_polygon<T> reproject_internal(multi_polygon<T> const & mpoly, proj_transfo
|
|||
for (auto const& poly : mpoly)
|
||||
{
|
||||
polygon<T> new_poly = reproject_internal(poly, proj_trans, n_err);
|
||||
if (!new_poly.exterior_ring.empty())
|
||||
if (new_poly.size() > 0 && !new_poly[0].empty())
|
||||
{
|
||||
new_mpoly.emplace_back(std::move(new_poly));
|
||||
}
|
||||
|
@ -162,7 +153,7 @@ geometry_collection<T> reproject_internal(geometry_collection<T> const & c, proj
|
|||
{
|
||||
|
||||
geometry<T> new_g = reproject_copy(g, proj_trans, n_err);
|
||||
if (!new_g.template is<geometry_empty>())
|
||||
if (!new_g.template is<geometry_empty<T>>())
|
||||
{
|
||||
new_c.emplace_back(std::move(new_g));
|
||||
}
|
||||
|
@ -178,9 +169,9 @@ struct geom_reproj_copy_visitor
|
|||
: proj_trans_(proj_trans),
|
||||
n_err_(n_err) {}
|
||||
|
||||
geometry<T> operator() (geometry_empty const&) const
|
||||
geometry<T> operator() (geometry_empty<T>) const
|
||||
{
|
||||
return geometry_empty();
|
||||
return geometry_empty<T>();
|
||||
}
|
||||
|
||||
geometry<T> operator() (point<T> const& p) const
|
||||
|
@ -207,7 +198,7 @@ struct geom_reproj_copy_visitor
|
|||
{
|
||||
geometry<T> geom; // default empty
|
||||
polygon<T> new_poly = reproject_internal(poly, proj_trans_, n_err_);
|
||||
if (new_poly.exterior_ring.empty()) return geom;
|
||||
if (new_poly.size() == 0 || new_poly[0].size() == 0) return geom;
|
||||
geom = std::move(new_poly);
|
||||
return geom;
|
||||
}
|
||||
|
@ -289,7 +280,8 @@ struct geom_reproj_visitor {
|
|||
return mapnik::util::apply_visitor((*this), geom);
|
||||
}
|
||||
|
||||
bool operator() (geometry_empty &) const { return true; }
|
||||
template <typename T>
|
||||
bool operator() (geometry_empty<T> &) const { return true; }
|
||||
|
||||
template <typename T>
|
||||
bool operator() (point<T> & p) const
|
||||
|
@ -314,12 +306,7 @@ struct geom_reproj_visitor {
|
|||
template <typename T>
|
||||
bool operator() (polygon<T> & poly) const
|
||||
{
|
||||
if (proj_trans_.forward(poly.exterior_ring) > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto & lr : poly.interior_rings)
|
||||
for (auto & lr : poly)
|
||||
{
|
||||
if (proj_trans_.forward(lr) > 0)
|
||||
{
|
||||
|
@ -332,7 +319,11 @@ struct geom_reproj_visitor {
|
|||
template <typename T>
|
||||
bool operator() (multi_point<T> & mp) const
|
||||
{
|
||||
return (*this) (static_cast<line_string<T> &>(mp));
|
||||
if (proj_trans_.forward(mp) > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -28,24 +28,22 @@
|
|||
|
||||
namespace mapnik { namespace geometry { namespace detail {
|
||||
|
||||
//template <typename Transformer>
|
||||
template <typename T>
|
||||
struct geometry_to_path
|
||||
{
|
||||
geometry_to_path(path_type & p)
|
||||
: p_(p) {}
|
||||
|
||||
template <typename T>
|
||||
void operator() (geometry<T> const& geom) const
|
||||
{
|
||||
mapnik::util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
void operator() (geometry_empty const&) const
|
||||
void operator() (geometry_empty<T> const&) const
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
// point
|
||||
template <typename T>
|
||||
void operator() (point<T> const& pt) const
|
||||
{
|
||||
//point pt_new;
|
||||
|
@ -54,7 +52,6 @@ struct geometry_to_path
|
|||
}
|
||||
|
||||
// line_string
|
||||
template <typename T>
|
||||
void operator() (line_string<T> const& line) const
|
||||
{
|
||||
bool first = true;
|
||||
|
@ -68,34 +65,16 @@ struct geometry_to_path
|
|||
}
|
||||
|
||||
// polygon
|
||||
template <typename T>
|
||||
void operator() (polygon<T> const& poly) const
|
||||
{
|
||||
// exterior
|
||||
bool first = true;
|
||||
for (auto const& pt : poly.exterior_ring)
|
||||
// rings: exterior *interior
|
||||
for (auto const& ring : poly)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
p_.move_to(pt.x, pt.y);
|
||||
first=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_.line_to(pt.x, pt.y);
|
||||
}
|
||||
}
|
||||
if (!first)
|
||||
{
|
||||
p_.close_path();
|
||||
}
|
||||
// interior
|
||||
for (auto const& ring : poly.interior_rings)
|
||||
{
|
||||
first = true;
|
||||
bool first = true;
|
||||
for (auto const& pt : ring)
|
||||
{
|
||||
if (first) {
|
||||
if (first)
|
||||
{
|
||||
p_.move_to(pt.x, pt.y);
|
||||
first=false;
|
||||
}
|
||||
|
@ -112,7 +91,6 @@ struct geometry_to_path
|
|||
}
|
||||
|
||||
// multi point
|
||||
template <typename T>
|
||||
void operator() (multi_point<T> const& multi_pt) const
|
||||
{
|
||||
for (auto const& pt : multi_pt)
|
||||
|
@ -121,7 +99,6 @@ struct geometry_to_path
|
|||
}
|
||||
}
|
||||
// multi_line_string
|
||||
template <typename T>
|
||||
void operator() (multi_line_string<T> const& multi_line) const
|
||||
{
|
||||
for (auto const& line : multi_line)
|
||||
|
@ -131,7 +108,6 @@ struct geometry_to_path
|
|||
}
|
||||
|
||||
// multi_polygon
|
||||
template <typename T>
|
||||
void operator() (multi_polygon<T> const& multi_poly) const
|
||||
{
|
||||
for (auto const& poly : multi_poly)
|
||||
|
@ -139,8 +115,7 @@ struct geometry_to_path
|
|||
(*this)(poly);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
// geometry_collection
|
||||
void operator() (geometry_collection<T> const& collection) const
|
||||
{
|
||||
for (auto const& geom : collection)
|
||||
|
@ -157,7 +132,8 @@ struct geometry_to_path
|
|||
template <typename T>
|
||||
void to_path(T const& geom, path_type & p)
|
||||
{
|
||||
detail::geometry_to_path func(p);
|
||||
using coordinate_type = typename T::coordinate_type;
|
||||
detail::geometry_to_path<coordinate_type> func(p);
|
||||
func(geom);
|
||||
}
|
||||
|
||||
|
|
|
@ -103,9 +103,10 @@ struct geometry_transform
|
|||
|
||||
using result_type = geometry<V>;
|
||||
|
||||
geometry<V> operator() (geometry_empty const& empty) const
|
||||
template <typename T>
|
||||
geometry<V> operator() (geometry_empty<T> const& empty) const
|
||||
{
|
||||
return empty;
|
||||
return geometry_empty<V>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -29,56 +29,49 @@
|
|||
|
||||
namespace mapnik { namespace geometry { namespace detail {
|
||||
|
||||
template <typename T>
|
||||
struct geometry_type
|
||||
{
|
||||
template <typename T>
|
||||
mapnik::geometry::geometry_types operator () (T const& geom) const
|
||||
mapnik::geometry::geometry_types operator () (mapnik::geometry::geometry<T> const& geom) const
|
||||
{
|
||||
return mapnik::util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
mapnik::geometry::geometry_types operator() (geometry_empty const& ) const
|
||||
mapnik::geometry::geometry_types operator() (geometry_empty<T> const& ) const
|
||||
{
|
||||
return mapnik::geometry::geometry_types::Unknown;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
mapnik::geometry::geometry_types operator () (mapnik::geometry::point<T> const&) const
|
||||
{
|
||||
return mapnik::geometry::geometry_types::Point;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
mapnik::geometry::geometry_types operator () (mapnik::geometry::line_string<T> const&) const
|
||||
{
|
||||
return mapnik::geometry::geometry_types::LineString;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
mapnik::geometry::geometry_types operator () (mapnik::geometry::polygon<T> const&) const
|
||||
{
|
||||
return mapnik::geometry::geometry_types::Polygon;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
mapnik::geometry::geometry_types operator () (mapnik::geometry::multi_point<T> const&) const
|
||||
{
|
||||
return mapnik::geometry::geometry_types::MultiPoint;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
mapnik::geometry::geometry_types operator () (mapnik::geometry::multi_line_string<T> const&) const
|
||||
{
|
||||
return mapnik::geometry::geometry_types::MultiLineString;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
mapnik::geometry::geometry_types operator () (mapnik::geometry::multi_polygon<T> const&) const
|
||||
{
|
||||
return mapnik::geometry::geometry_types::MultiPolygon;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
mapnik::geometry::geometry_types operator () (mapnik::geometry::geometry_collection<T> const&) const
|
||||
{
|
||||
return mapnik::geometry::geometry_types::GeometryCollection;
|
||||
|
@ -89,7 +82,8 @@ struct geometry_type
|
|||
template <typename T>
|
||||
static inline mapnik::geometry::geometry_types geometry_type(T const& geom)
|
||||
{
|
||||
return detail::geometry_type()(geom);
|
||||
using coordinate_type = typename T::coordinate_type;
|
||||
return detail::geometry_type<coordinate_type>()(geom);
|
||||
}
|
||||
|
||||
}}
|
||||
|
|
|
@ -49,7 +49,7 @@ struct hit_test_visitor
|
|||
y_(y),
|
||||
tol_(tol) {}
|
||||
|
||||
bool operator() (geometry::geometry_empty const& ) const
|
||||
bool operator() (geometry::geometry_empty<double> const& ) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ struct hit_test_visitor
|
|||
}
|
||||
bool operator() (geometry::line_string<double> const& geom) const
|
||||
{
|
||||
std::size_t num_points = geom.num_points();
|
||||
std::size_t num_points = geom.size();
|
||||
if (num_points > 1)
|
||||
{
|
||||
for (std::size_t i = 1; i < num_points; ++i)
|
||||
|
@ -89,40 +89,32 @@ struct hit_test_visitor
|
|||
}
|
||||
return false;
|
||||
}
|
||||
bool operator() (geometry::polygon<double> const& geom) const
|
||||
bool operator() (geometry::polygon<double> const& poly) const
|
||||
{
|
||||
auto const& exterior = geom.exterior_ring;
|
||||
std::size_t num_points = exterior.num_points();
|
||||
if (num_points < 4) return false;
|
||||
bool inside = false;
|
||||
for (std::size_t i = 1; i < num_points; ++i)
|
||||
std::size_t ring_count = 0;
|
||||
for (auto const& ring : poly)
|
||||
{
|
||||
auto const& pt0 = exterior[i-1];
|
||||
auto const& pt1 = exterior[i];
|
||||
// todo - account for tolerance
|
||||
if (pip(pt0.x,pt0.y,pt1.x,pt1.y,x_,y_))
|
||||
++ring_count;
|
||||
bool is_exterior = (ring_count == 1);
|
||||
std::size_t num_points = ring.size();
|
||||
if (num_points < 4)
|
||||
{
|
||||
inside = !inside;
|
||||
if (is_exterior) return false;
|
||||
else continue;
|
||||
}
|
||||
}
|
||||
if (!inside) return false;
|
||||
for (auto const& ring : geom.interior_rings)
|
||||
{
|
||||
std::size_t num_interior_points = ring.size();
|
||||
if (num_interior_points < 4)
|
||||
|
||||
for (std::size_t j = 1; j < num_points; ++j)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (std::size_t j = 1; j < num_interior_points; ++j)
|
||||
{
|
||||
auto const& pt0 = ring[j-1];
|
||||
auto const& pt0 = ring[j - 1];
|
||||
auto const& pt1 = ring[j];
|
||||
if (pip(pt0.x,pt0.y,pt1.x,pt1.y,x_,y_))
|
||||
if (pip(pt0.x, pt0.y, pt1.x, pt1.y, x_, y_))
|
||||
{
|
||||
// TODO - account for tolerance
|
||||
inside=!inside;
|
||||
inside = !inside;
|
||||
}
|
||||
}
|
||||
if (is_exterior && !inside) return false;
|
||||
}
|
||||
return inside;
|
||||
}
|
||||
|
|
|
@ -99,8 +99,7 @@ struct geometry_generator_grammar :
|
|||
karma::rule<OutputIterator, geometry::line_string<double> const&()> linestring_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<double> const&()> polygon;
|
||||
karma::rule<OutputIterator, geometry::polygon<double> const&()> polygon_coord;
|
||||
karma::rule<OutputIterator, geometry::linear_ring<double> const&()> exterior_ring_coord;
|
||||
karma::rule<OutputIterator, geometry::polygon<double>::rings_container const&()> interior_ring_coord;
|
||||
karma::rule<OutputIterator, geometry::linear_ring<double> const&()> linearring_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<double> const& ()> multi_point;
|
||||
karma::rule<OutputIterator, geometry::multi_point<double> const& ()> multi_point_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<double> const& ()> multi_linestring;
|
||||
|
|
|
@ -98,11 +98,9 @@ geometry_generator_grammar<OutputIterator, Geometry>::geometry_generator_grammar
|
|||
;
|
||||
linestring_coord = point_coord % lit(',')
|
||||
;
|
||||
polygon_coord = lit('[') << exterior_ring_coord << lit(']') << interior_ring_coord
|
||||
linearring_coord = point_coord % lit(',')
|
||||
;
|
||||
exterior_ring_coord = linestring_coord.alias()
|
||||
;
|
||||
interior_ring_coord = *(lit(",[") << exterior_ring_coord << lit(']'))
|
||||
polygon_coord = (lit('[') << linearring_coord << lit(']')) % lit(',')
|
||||
;
|
||||
multi_point_coord = linestring_coord.alias()
|
||||
;
|
||||
|
@ -110,7 +108,7 @@ geometry_generator_grammar<OutputIterator, Geometry>::geometry_generator_grammar
|
|||
;
|
||||
multi_polygon_coord = (lit('[') << polygon_coord << lit(']')) % lit(',')
|
||||
;
|
||||
geometries = geometry % lit(',')
|
||||
geometries = geometry % lit(',')
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
@ -84,10 +84,7 @@ struct create_polygon
|
|||
{
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
std::size_t num_rings = rings.size();
|
||||
if (num_rings > 1)
|
||||
{
|
||||
poly.interior_rings.reserve(num_rings - 1);
|
||||
}
|
||||
poly.reserve(num_rings);
|
||||
|
||||
for ( std::size_t i = 0; i < num_rings; ++i)
|
||||
{
|
||||
|
@ -98,8 +95,7 @@ struct create_polygon
|
|||
{
|
||||
ring.emplace_back(std::move(pt));
|
||||
}
|
||||
if (i == 0) poly.set_exterior_ring(std::move(ring));
|
||||
else poly.add_hole(std::move(ring));
|
||||
poly.push_back(std::move(ring));
|
||||
}
|
||||
geom_ = std::move(poly);
|
||||
mapnik::geometry::correct(geom_);
|
||||
|
@ -179,9 +175,7 @@ struct create_multipolygon
|
|||
{
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
std::size_t num_rings = rings.size();
|
||||
if ( num_rings > 1)
|
||||
poly.interior_rings.reserve(num_rings - 1);
|
||||
|
||||
poly.reserve(num_rings);
|
||||
for ( std::size_t i = 0; i < num_rings; ++i)
|
||||
{
|
||||
std::size_t size = rings[i].size();
|
||||
|
@ -191,8 +185,8 @@ struct create_multipolygon
|
|||
{
|
||||
ring.emplace_back(std::move(pt));
|
||||
}
|
||||
if (i == 0) poly.set_exterior_ring(std::move(ring));
|
||||
else poly.add_hole(std::move(ring));
|
||||
|
||||
poly.push_back(std::move(ring));
|
||||
}
|
||||
multi_poly.emplace_back(std::move(poly));
|
||||
}
|
||||
|
|
|
@ -313,7 +313,7 @@ struct feature_generator
|
|||
x = x * (*topo_.tr).scale_x + (*topo_.tr).translate_x;
|
||||
y = y * (*topo_.tr).scale_y + (*topo_.tr).translate_y;
|
||||
}
|
||||
multi_point.add_coord(x, y);
|
||||
multi_point.emplace_back(x, y);
|
||||
}
|
||||
feature->set_geometry(std::move(multi_point));
|
||||
assign_properties(*feature, multi_pt, tr_);
|
||||
|
@ -344,7 +344,7 @@ struct feature_generator
|
|||
x = (px += x) * (*topo_.tr).scale_x + (*topo_.tr).translate_x;
|
||||
y = (py += y) * (*topo_.tr).scale_y + (*topo_.tr).translate_y;
|
||||
}
|
||||
line_string.add_coord(x,y);
|
||||
line_string.emplace_back(x,y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -383,7 +383,7 @@ struct feature_generator
|
|||
x = (px += x) * (*topo_.tr).scale_x + (*topo_.tr).translate_x;
|
||||
y = (py += y) * (*topo_.tr).scale_y + (*topo_.tr).translate_y;
|
||||
}
|
||||
line_string.add_coord(x, y);
|
||||
line_string.emplace_back(x, y);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -406,8 +406,7 @@ struct feature_generator
|
|||
{
|
||||
std::vector<mapnik::topojson::coordinate> processed_coords;
|
||||
mapnik::geometry::polygon<double> polygon;
|
||||
if (poly.rings.size() > 1) polygon.interior_rings.reserve(poly.rings.size() - 1);
|
||||
bool first = true;
|
||||
polygon.reserve(poly.rings.size());
|
||||
bool hit = false;
|
||||
for (auto const& ring : poly.rings)
|
||||
{
|
||||
|
@ -454,15 +453,7 @@ struct feature_generator
|
|||
}
|
||||
}
|
||||
}
|
||||
if (first)
|
||||
{
|
||||
first = false;
|
||||
polygon.set_exterior_ring(std::move(linear_ring));
|
||||
}
|
||||
else
|
||||
{
|
||||
polygon.add_hole(std::move(linear_ring));
|
||||
}
|
||||
polygon.push_back(std::move(linear_ring));
|
||||
}
|
||||
if (hit)
|
||||
{
|
||||
|
@ -485,9 +476,8 @@ struct feature_generator
|
|||
bool hit = false;
|
||||
for (auto const& poly : multi_poly.polygons)
|
||||
{
|
||||
bool first = true;
|
||||
mapnik::geometry::polygon<double> polygon;
|
||||
if (poly.size() > 1) polygon.interior_rings.reserve(poly.size() - 1);
|
||||
polygon.reserve(poly.size());
|
||||
|
||||
for (auto const& ring : poly)
|
||||
{
|
||||
|
@ -524,27 +514,19 @@ struct feature_generator
|
|||
{
|
||||
for (auto const& c : (processed_coords | reversed))
|
||||
{
|
||||
linear_ring.add_coord(c.x, c.y);
|
||||
linear_ring.emplace_back(c.x, c.y);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto const& c : processed_coords)
|
||||
{
|
||||
linear_ring.add_coord(c.x, c.y);
|
||||
linear_ring.emplace_back(c.x, c.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (first)
|
||||
{
|
||||
first = false;
|
||||
polygon.set_exterior_ring(std::move(linear_ring));
|
||||
}
|
||||
else
|
||||
{
|
||||
polygon.add_hole(std::move(linear_ring));
|
||||
}
|
||||
polygon.push_back(std::move(linear_ring));
|
||||
}
|
||||
multi_polygon.push_back(std::move(polygon));
|
||||
}
|
||||
|
|
|
@ -44,8 +44,8 @@ public:
|
|||
PolygonExterior = Polygon,
|
||||
PolygonInterior = Polygon | ( 1 << geometry_bits)
|
||||
};
|
||||
using coord_type = T;
|
||||
using container_type = Container<coord_type>;
|
||||
using coordinate_type = T;
|
||||
using container_type = Container<coordinate_type>;
|
||||
using value_type = typename container_type::value_type;
|
||||
using size_type = typename container_type::size_type;
|
||||
container_type cont_;
|
||||
|
@ -84,17 +84,17 @@ public:
|
|||
{
|
||||
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);
|
||||
}
|
||||
|
||||
void line_to(coord_type x,coord_type y)
|
||||
void line_to(coordinate_type x,coordinate_type y)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -35,13 +35,8 @@
|
|||
#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;
|
||||
|
||||
|
|
|
@ -26,13 +26,12 @@
|
|||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/util/noncopyable.hpp>
|
||||
#include <mapnik/geometry/point.hpp>
|
||||
// stl
|
||||
#include <vector>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
namespace geometry {
|
||||
template <typename T> struct point;
|
||||
template <typename T> struct line_string;
|
||||
}
|
||||
class projection;
|
||||
template <typename T> class box2d;
|
||||
|
||||
|
@ -50,8 +49,8 @@ public:
|
|||
bool backward (double *x, double *y , double *z, int point_count, int offset = 1) const;
|
||||
bool forward (geometry::point<double> & p) const;
|
||||
bool backward (geometry::point<double> & p) const;
|
||||
unsigned int forward (geometry::line_string<double> & ls) const;
|
||||
unsigned int backward (geometry::line_string<double> & ls) const;
|
||||
unsigned int forward (std::vector<geometry::point<double>> & ls) const;
|
||||
unsigned int backward (std::vector<geometry::point<double>> & ls) const;
|
||||
bool forward (box2d<double> & box) const;
|
||||
bool backward (box2d<double> & box) const;
|
||||
bool forward (box2d<double> & box, int points) const;
|
||||
|
|
|
@ -145,7 +145,7 @@ struct svg_path_generator :
|
|||
{
|
||||
|
||||
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();
|
||||
// rules
|
||||
|
@ -153,7 +153,7 @@ struct svg_path_generator :
|
|||
karma::rule<OutputIterator, path_type const& ()> point;
|
||||
karma::rule<OutputIterator, path_type const& ()> linestring;
|
||||
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;
|
||||
|
||||
// phoenix functions
|
||||
|
|
|
@ -117,8 +117,8 @@ private:
|
|||
void increment()
|
||||
{
|
||||
// variables used to extract vertex components.
|
||||
geometry_type::coord_type x;
|
||||
geometry_type::coord_type y;
|
||||
geometry_type::coordinate_type x;
|
||||
geometry_type::coordinate_type y;
|
||||
|
||||
// extract next vertex components.
|
||||
unsigned cmd = path_.vertex(&x, &y);
|
||||
|
@ -170,7 +170,7 @@ private:
|
|||
// 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.
|
||||
// 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> >;
|
||||
|
||||
}}
|
||||
|
|
|
@ -69,6 +69,7 @@ public:
|
|||
using line_string_cref = std::reference_wrapper<geometry::line_string<double> const>;
|
||||
using polygon_cref = std::reference_wrapper<geometry::polygon<double> const>;
|
||||
using geometry_cref = util::variant<point_cref, line_string_cref, polygon_cref>;
|
||||
|
||||
// Using list instead of vector, because we delete random elements and need iterators to stay valid.
|
||||
using geometry_container_type = std::list<geometry_cref>;
|
||||
base_symbolizer_helper(symbolizer_base const& sym,
|
||||
|
@ -158,10 +159,6 @@ protected:
|
|||
void init_marker() const;
|
||||
};
|
||||
|
||||
namespace geometry {
|
||||
MAPNIK_DECL mapnik::box2d<double> envelope(mapnik::base_symbolizer_helper::geometry_cref const& geom);
|
||||
}
|
||||
|
||||
} //namespace mapnik
|
||||
|
||||
#endif // SYMBOLIZER_HELPERS_HPP
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace detail {
|
|||
|
||||
struct datasource_geometry_type
|
||||
{
|
||||
mapnik::datasource_geometry_t operator () (mapnik::geometry::geometry_empty const&) const
|
||||
mapnik::datasource_geometry_t operator () (mapnik::geometry::geometry_empty<double> const&) const
|
||||
{
|
||||
return mapnik::datasource_geometry_t::Unknown;
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ using wkb_buffer_ptr = std::unique_ptr<wkb_buffer>;
|
|||
|
||||
wkb_buffer_ptr point_wkb( geometry::point<double> const& pt, wkbByteOrder byte_order)
|
||||
{
|
||||
std::size_t size = 1 + 4 + 8 * 2 ; // byteOrder + wkbType + Point
|
||||
std::size_t const size = 1 + 4 + 8 * 2 ; // byteOrder + wkbType + Point
|
||||
wkb_buffer_ptr wkb = std::make_unique<wkb_buffer>(size);
|
||||
wkb_stream ss(wkb->buffer(), wkb->size());
|
||||
ss.write(reinterpret_cast<char*>(&byte_order),1);
|
||||
|
@ -148,7 +148,7 @@ wkb_buffer_ptr line_string_wkb(geometry::line_string<double> const& line, wkbByt
|
|||
{
|
||||
std::size_t num_points = line.size();
|
||||
assert(num_points > 1);
|
||||
std::size_t size = 1 + 4 + 4 + 8 * 2 * num_points ; // byteOrder + wkbType + numPoints + Point*numPoints
|
||||
std::size_t const size = 1 + 4 + 4 + 8 * 2 * num_points ; // byteOrder + wkbType + numPoints + Point*numPoints
|
||||
wkb_buffer_ptr wkb = std::make_unique<wkb_buffer>(size);
|
||||
wkb_stream ss(wkb->buffer(), wkb->size());
|
||||
ss.write(reinterpret_cast<char*>(&byte_order),1);
|
||||
|
@ -167,10 +167,8 @@ wkb_buffer_ptr line_string_wkb(geometry::line_string<double> const& line, wkbByt
|
|||
wkb_buffer_ptr polygon_wkb( geometry::polygon<double> const& poly, wkbByteOrder byte_order)
|
||||
{
|
||||
std::size_t size = 1 + 4 + 4 ; // byteOrder + wkbType + numRings
|
||||
size += 4 + 2 * 8 * poly.exterior_ring.size();
|
||||
for ( auto const& ring : poly.interior_rings)
|
||||
for ( auto const& ring : poly)
|
||||
{
|
||||
|
||||
size += 4 + 2 * 8 * ring.size();
|
||||
}
|
||||
|
||||
|
@ -178,17 +176,10 @@ wkb_buffer_ptr polygon_wkb( geometry::polygon<double> const& poly, wkbByteOrder
|
|||
wkb_stream ss(wkb->buffer(), wkb->size());
|
||||
ss.write(reinterpret_cast<char*>(&byte_order),1);
|
||||
write(ss, static_cast<int>(mapnik::geometry::geometry_types::Polygon), 4, byte_order);
|
||||
write(ss, poly.num_rings(), 4, byte_order);
|
||||
write(ss, poly.size(), 4, byte_order);
|
||||
|
||||
// exterior
|
||||
write(ss, poly.exterior_ring.size(), 4, byte_order);
|
||||
for (auto const& pt : poly.exterior_ring)
|
||||
{
|
||||
write(ss, pt.x, 8, byte_order);
|
||||
write(ss, pt.y, 8, byte_order);
|
||||
}
|
||||
// interiors
|
||||
for (auto const& ring : poly.interior_rings)
|
||||
// exterior *interior
|
||||
for (auto const& ring : poly)
|
||||
{
|
||||
write(ss, ring.size(), 4, byte_order);
|
||||
for ( auto const& pt : ring)
|
||||
|
@ -238,7 +229,7 @@ struct geometry_to_wkb
|
|||
return util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
result_type operator() (geometry::geometry_empty const&) const
|
||||
result_type operator() (geometry::geometry_empty<double> const&) const
|
||||
{
|
||||
return result_type();
|
||||
}
|
||||
|
@ -288,7 +279,7 @@ wkb_buffer_ptr multi_geom_wkb(MultiGeometry const& multi_geom, wkbByteOrder byte
|
|||
wkb_buffer_ptr multi_wkb = std::make_unique<wkb_buffer>(multi_size);
|
||||
wkb_stream ss(multi_wkb->buffer(), multi_wkb->size());
|
||||
ss.write(reinterpret_cast<char*>(&byte_order),1);
|
||||
write(ss, static_cast<int>(geometry::detail::geometry_type()(multi_geom)) , 4, byte_order);
|
||||
write(ss, static_cast<int>(geometry::detail::geometry_type<double>()(multi_geom)) , 4, byte_order);
|
||||
write(ss, multi_geom.size(), 4 ,byte_order);
|
||||
|
||||
for ( wkb_buffer_ptr const& wkb : wkb_cont)
|
||||
|
|
|
@ -68,16 +68,16 @@ namespace boost { namespace spirit { namespace traits {
|
|||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct transform_attribute<mapnik::geometry::polygon<double> const,
|
||||
mapnik::geometry::polygon<double>::rings_container const&, karma::domain>
|
||||
{
|
||||
using type = mapnik::geometry::polygon<double>::rings_container const&;
|
||||
static type pre(mapnik::geometry::polygon<double> const& poly)
|
||||
{
|
||||
return poly.interior_rings;
|
||||
}
|
||||
};
|
||||
//template <>
|
||||
// struct transform_attribute<mapnik::geometry::polygon<double> const,
|
||||
// mapnik::geometry::polygon<double>::rings_container const&, karma::domain>
|
||||
// {
|
||||
// using type = mapnik::geometry::polygon<double>::rings_container const&;
|
||||
// static type pre(mapnik::geometry::polygon<double> const& poly)
|
||||
// {
|
||||
// return poly.interior_rings;
|
||||
// }
|
||||
// };
|
||||
|
||||
template <>
|
||||
struct transform_attribute<mapnik::geometry::geometry<double> const,
|
||||
|
@ -156,16 +156,16 @@ namespace boost { namespace spirit { namespace traits {
|
|||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct transform_attribute<mapnik::geometry::polygon<std::int64_t> const,
|
||||
mapnik::geometry::polygon<std::int64_t>::rings_container const&, karma::domain>
|
||||
{
|
||||
using type = mapnik::geometry::polygon<std::int64_t>::rings_container const&;
|
||||
static type pre(mapnik::geometry::polygon<std::int64_t> const& poly)
|
||||
{
|
||||
return poly.interior_rings;
|
||||
}
|
||||
};
|
||||
//template <>
|
||||
// struct transform_attribute<mapnik::geometry::polygon<std::int64_t> const,
|
||||
// mapnik::geometry::polygon<std::int64_t>::rings_container const&, karma::domain>
|
||||
// {
|
||||
// using type = mapnik::geometry::polygon<std::int64_t>::rings_container const&;
|
||||
// static type pre(mapnik::geometry::polygon<std::int64_t> const& poly)
|
||||
// {
|
||||
// return poly.interior_rings;
|
||||
// }
|
||||
// };
|
||||
|
||||
template <>
|
||||
struct transform_attribute<mapnik::geometry::geometry<std::int64_t> const,
|
||||
|
|
|
@ -39,7 +39,7 @@ enum CommandType : std::uint8_t {
|
|||
|
||||
template <typename T,int dim>
|
||||
struct vertex {
|
||||
using coord_type = T;
|
||||
using coordinate_type = T;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
@ -47,9 +47,9 @@ struct vertex<T,2>
|
|||
{
|
||||
enum no_init_t : std::uint8_t { no_init };
|
||||
|
||||
using coord_type = T;
|
||||
coord_type x;
|
||||
coord_type y;
|
||||
using coordinate_type = T;
|
||||
coordinate_type x;
|
||||
coordinate_type y;
|
||||
unsigned cmd;
|
||||
|
||||
vertex()
|
||||
|
@ -58,13 +58,13 @@ struct vertex<T,2>
|
|||
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_) {}
|
||||
|
||||
template <typename T2>
|
||||
vertex(vertex<T2,2> const& rhs)
|
||||
: x(coord_type(rhs.x)),
|
||||
y(coord_type(rhs.y)),
|
||||
: x(coordinate_type(rhs.x)),
|
||||
y(coordinate_type(rhs.y)),
|
||||
cmd(rhs.cmd) {}
|
||||
|
||||
template <typename T2>
|
||||
|
|
|
@ -32,10 +32,9 @@ namespace mapnik { namespace geometry {
|
|||
template <typename T>
|
||||
struct point_vertex_adapter
|
||||
{
|
||||
using coord_type = typename point<T>::coord_type;
|
||||
|
||||
using coordinate_type = T;
|
||||
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;
|
||||
geometry_types type () const;
|
||||
point<T> const& pt_;
|
||||
|
@ -45,23 +44,23 @@ struct point_vertex_adapter
|
|||
template <typename T>
|
||||
struct line_string_vertex_adapter
|
||||
{
|
||||
using coord_type = typename point<T>::coord_type;
|
||||
using coordinate_type = T;
|
||||
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;
|
||||
geometry_types type () const;
|
||||
line_string<T> const& line_;
|
||||
mutable std::size_t current_index_;
|
||||
const std::size_t end_index_;
|
||||
const std::size_t end_index_;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct polygon_vertex_adapter
|
||||
{
|
||||
using coord_type = typename point<T>::coord_type;
|
||||
using coordinate_type = T;
|
||||
polygon_vertex_adapter(polygon<T> const& poly);
|
||||
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;
|
||||
private:
|
||||
polygon<T> const& poly_;
|
||||
|
@ -75,10 +74,10 @@ private:
|
|||
template <typename T>
|
||||
struct ring_vertex_adapter
|
||||
{
|
||||
using coord_type = typename point<T>::coord_type;
|
||||
using coordinate_type = T;
|
||||
ring_vertex_adapter(linear_ring<T> const& ring);
|
||||
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;
|
||||
private:
|
||||
linear_ring<T> const& ring_;
|
||||
|
|
|
@ -39,7 +39,8 @@ struct vertex_processor
|
|||
{
|
||||
util::apply_visitor(*this, geom);
|
||||
}
|
||||
void operator() (geometry_empty const&) const
|
||||
template <typename T1>
|
||||
void operator() (geometry_empty<T1> const&) const
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace mapnik
|
|||
template <typename T>
|
||||
class vertex_vector : private util::noncopyable
|
||||
{
|
||||
using coord_type = T;
|
||||
using coordinate_type = T;
|
||||
enum block_e {
|
||||
block_shift = 8,
|
||||
block_size = 1<<block_shift,
|
||||
|
@ -51,13 +51,13 @@ class vertex_vector : private util::noncopyable
|
|||
};
|
||||
public:
|
||||
// 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 command_size = std::uint8_t;
|
||||
private:
|
||||
unsigned num_blocks_;
|
||||
unsigned max_blocks_;
|
||||
coord_type** vertices_;
|
||||
coordinate_type** vertices_;
|
||||
command_size** commands_;
|
||||
size_type pos_;
|
||||
|
||||
|
@ -74,7 +74,7 @@ public:
|
|||
{
|
||||
if ( num_blocks_ )
|
||||
{
|
||||
coord_type** vertices=vertices_ + num_blocks_ - 1;
|
||||
coordinate_type** vertices=vertices_ + num_blocks_ - 1;
|
||||
while ( num_blocks_-- )
|
||||
{
|
||||
::operator delete(*vertices);
|
||||
|
@ -88,14 +88,14 @@ public:
|
|||
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;
|
||||
if (block >= num_blocks_)
|
||||
{
|
||||
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);
|
||||
|
||||
*cmd = static_cast<command_size>(command);
|
||||
|
@ -103,11 +103,11 @@ public:
|
|||
*vertex = y;
|
||||
++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;
|
||||
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++);
|
||||
*y = (*vertex);
|
||||
return commands_[block] [pos & block_mask];
|
||||
|
@ -126,8 +126,8 @@ private:
|
|||
{
|
||||
if (block >= max_blocks_)
|
||||
{
|
||||
coord_type** new_vertices =
|
||||
static_cast<coord_type**>(::operator new (sizeof(coord_type*)*((max_blocks_ + grow_by) * 2)));
|
||||
coordinate_type** new_vertices =
|
||||
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);
|
||||
if (vertices_)
|
||||
{
|
||||
|
@ -139,8 +139,8 @@ private:
|
|||
commands_ = new_commands;
|
||||
max_blocks_ += grow_by;
|
||||
}
|
||||
vertices_[block] = static_cast<coord_type*>
|
||||
(::operator new(sizeof(coord_type)*(block_size * 2 + block_size / (sizeof(coord_type)))));
|
||||
vertices_[block] = static_cast<coordinate_type*>
|
||||
(::operator new(sizeof(coordinate_type)*(block_size * 2 + block_size / (sizeof(coordinate_type)))));
|
||||
|
||||
commands_[block] = (command_size*)(vertices_[block] + block_size*2);
|
||||
++num_blocks_;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
// mapnik
|
||||
#include <mapnik/global.hpp> // for M_PI on windows
|
||||
#include <mapnik/enumeration.hpp>
|
||||
#include <mapnik/geometry.hpp>
|
||||
#include <mapnik/geometry/point.hpp>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#include <mapnik/warning_ignore.hpp>
|
||||
|
@ -35,6 +35,7 @@
|
|||
|
||||
// stl
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
|
@ -93,9 +94,9 @@ static inline bool merc2lonlat(double * x, double * y , int point_count)
|
|||
return true;
|
||||
}
|
||||
|
||||
static inline bool lonlat2merc(geometry::line_string<double> & ls)
|
||||
static inline bool lonlat2merc(std::vector<geometry::point<double>> & ls)
|
||||
{
|
||||
for(auto & p : ls)
|
||||
for (auto& p : ls)
|
||||
{
|
||||
if (p.x > 180) p.x = 180;
|
||||
else if (p.x < -180) p.x = -180;
|
||||
|
@ -108,7 +109,7 @@ static inline bool lonlat2merc(geometry::line_string<double> & ls)
|
|||
return true;
|
||||
}
|
||||
|
||||
static inline bool merc2lonlat(geometry::line_string<double> & ls)
|
||||
static inline bool merc2lonlat(std::vector<geometry::point<double>> & ls)
|
||||
{
|
||||
for (auto & p : ls)
|
||||
{
|
||||
|
|
|
@ -104,31 +104,31 @@ template <typename OutputIterator, typename Geometry>
|
|||
struct wkt_generator_grammar :
|
||||
karma::grammar<OutputIterator, Geometry const& ()>
|
||||
{
|
||||
using coord_type = typename Geometry::coord_type;
|
||||
using coordinate_type = typename Geometry::coordinate_type;
|
||||
wkt_generator_grammar();
|
||||
// rules
|
||||
karma::rule<OutputIterator, Geometry const&()> geometry;
|
||||
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::point<coord_type> const&()> point_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<coord_type> const&()> linestring;
|
||||
karma::rule<OutputIterator, geometry::line_string<coord_type> const&()> linestring_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<coord_type> const&()> polygon;
|
||||
karma::rule<OutputIterator, geometry::polygon<coord_type> const&()> polygon_coord;
|
||||
karma::rule<OutputIterator, geometry::linear_ring<coord_type> const&()> exterior_ring_coord;
|
||||
karma::rule<OutputIterator, std::vector<geometry::linear_ring<coord_type> > const&()> interior_ring_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<coord_type> const& ()> multi_point;
|
||||
karma::rule<OutputIterator, geometry::multi_point<coord_type> const& ()> multi_point_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<coord_type> const& ()> multi_linestring;
|
||||
karma::rule<OutputIterator, geometry::multi_line_string<coord_type> const& ()> multi_linestring_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<coord_type> const& ()> multi_polygon;
|
||||
karma::rule<OutputIterator, geometry::multi_polygon<coord_type> const& ()> multi_polygon_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<coord_type> const& ()> geometry_collection;
|
||||
karma::rule<OutputIterator, geometry::geometry_collection<coord_type> const& ()> geometries;
|
||||
karma::rule<OutputIterator, geometry::geometry<coordinate_type> const&()> point;
|
||||
karma::rule<OutputIterator, geometry::point<coordinate_type> const&()> point_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<coordinate_type> const&()> linestring;
|
||||
karma::rule<OutputIterator, geometry::line_string<coordinate_type> const&()> linestring_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<coordinate_type> const&()> polygon;
|
||||
karma::rule<OutputIterator, geometry::polygon<coordinate_type> const&()> polygon_coord;
|
||||
karma::rule<OutputIterator, geometry::linear_ring<coordinate_type> const&()> ring;
|
||||
//karma::rule<OutputIterator, std::vector<geometry::linear_ring<coordinate_type> > const&()> interior_ring_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<coordinate_type> const& ()> multi_point;
|
||||
karma::rule<OutputIterator, geometry::multi_point<coordinate_type> const& ()> multi_point_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<coordinate_type> const& ()> multi_linestring;
|
||||
karma::rule<OutputIterator, geometry::multi_line_string<coordinate_type> const& ()> multi_linestring_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<coordinate_type> const& ()> multi_polygon;
|
||||
karma::rule<OutputIterator, geometry::multi_polygon<coordinate_type> const& ()> multi_polygon_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<coordinate_type> const& ()> geometry_collection;
|
||||
karma::rule<OutputIterator, geometry::geometry_collection<coordinate_type> const& ()> geometries;
|
||||
boost::phoenix::function<detail::get_type<Geometry> > geometry_type;
|
||||
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;
|
||||
};
|
||||
|
||||
}}
|
||||
|
|
|
@ -79,7 +79,7 @@ wkt_generator_grammar<OutputIterator, Geometry>::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<double> can't be empty
|
||||
<< lit("POINT EMPTY")) // special case for geometry_empty<double> as mapnik::geometry::point<double> can't be empty
|
||||
;
|
||||
|
||||
point = lit("POINT(") << point_coord << lit(")")
|
||||
|
@ -100,11 +100,9 @@ wkt_generator_grammar<OutputIterator, Geometry>::wkt_generator_grammar()
|
|||
;
|
||||
linestring_coord = point_coord % lit(',')
|
||||
;
|
||||
polygon_coord = lit('(') << exterior_ring_coord << lit(')') << interior_ring_coord
|
||||
polygon_coord = ring % lit(',')//<< interior_ring_coord
|
||||
;
|
||||
exterior_ring_coord = linestring_coord.alias()
|
||||
;
|
||||
interior_ring_coord = *(lit(",(") << exterior_ring_coord << lit(')'))
|
||||
ring = lit('(') << linestring_coord << lit(')')
|
||||
;
|
||||
multi_point_coord = linestring_coord.alias()
|
||||
;
|
||||
|
|
|
@ -60,23 +60,14 @@ struct move_part
|
|||
}
|
||||
};
|
||||
|
||||
struct set_exterior
|
||||
{
|
||||
using result_type = void;
|
||||
template <typename Polygon, typename Ring>
|
||||
void operator() (Polygon & poly, Ring && ring) const
|
||||
{
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
}
|
||||
};
|
||||
|
||||
struct add_hole
|
||||
struct set_ring
|
||||
{
|
||||
using result_type = void;
|
||||
template <typename Polygon, typename Ring>
|
||||
void operator() (Polygon & poly, Ring && ring) const
|
||||
{
|
||||
poly.add_hole(std::move(ring));
|
||||
poly.push_back(std::move(ring));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -109,8 +100,7 @@ struct wkt_grammar : qi::grammar<Iterator, void(mapnik::geometry::geometry<doubl
|
|||
qi::rule<Iterator,ascii::space_type> empty_set;
|
||||
boost::phoenix::function<detail::assign> assign;
|
||||
boost::phoenix::function<detail::move_part> move_part;
|
||||
boost::phoenix::function<detail::set_exterior> set_exterior;
|
||||
boost::phoenix::function<detail::add_hole> add_hole;
|
||||
boost::phoenix::function<detail::set_ring> set_ring;
|
||||
};
|
||||
|
||||
}}
|
||||
|
|
|
@ -62,7 +62,7 @@ wkt_grammar<Iterator>::wkt_grammar()
|
|||
|
||||
// <point tagged text> ::= point <point text>
|
||||
point_tagged_text = no_case[lit("POINT")]
|
||||
>> (point_text[assign(_r1,_1)] | empty_set[assign(_r1,construct<geometry::geometry_empty>())])
|
||||
>> (point_text[assign(_r1,_1)] | empty_set[assign(_r1,construct<geometry::geometry_empty<double>>())])
|
||||
;
|
||||
// <point text> ::= <empty set> | <left paren> <point> <right paren>
|
||||
point_text = (lit("(") >> point >> lit(')'))
|
||||
|
@ -86,12 +86,14 @@ wkt_grammar<Iterator>::wkt_grammar()
|
|||
|
||||
// <polygon text> ::= <empty set> | <left paren> <linestring text> {<comma> <linestring text>}* <right paren>
|
||||
polygon_text =
|
||||
(lit('(') >> linearring_text[set_exterior(_val,_1)] >> *(lit(',') >> linearring_text[add_hole(_val,_1)]) >> lit(')'))
|
||||
lit('(') >> linearring_text[set_ring(_val,_1)] % lit(',') >> lit(')')
|
||||
|
|
||||
empty_set
|
||||
;
|
||||
|
||||
linearring_text = ring_points | empty_set
|
||||
linearring_text = ring_points
|
||||
|
|
||||
empty_set
|
||||
;
|
||||
//<multipoint tagged text> ::= multipoint <multipoint text>
|
||||
multipoint_tagged_text = no_case[lit("MULTIPOINT")]
|
||||
|
|
|
@ -73,7 +73,7 @@ mapnik::feature_ptr csv_featureset::parse_feature(char const* beg, char const* e
|
|||
{
|
||||
auto values = csv_utils::parse_line(beg, end, separator_, quote_, headers_.size());
|
||||
auto geom = csv_utils::extract_geometry(values, locator_);
|
||||
if (!geom.is<mapnik::geometry::geometry_empty>())
|
||||
if (!geom.is<mapnik::geometry::geometry_empty<double>>())
|
||||
{
|
||||
mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx_, ++feature_id_));
|
||||
feature->set_geometry(std::move(geom));
|
||||
|
|
|
@ -90,7 +90,7 @@ mapnik::feature_ptr csv_index_featureset::parse_feature(char const* beg, char co
|
|||
{
|
||||
auto values = csv_utils::parse_line(beg, end, separator_, quote_, headers_.size());
|
||||
auto geom = csv_utils::extract_geometry(values, locator_);
|
||||
if (!geom.is<mapnik::geometry::geometry_empty>())
|
||||
if (!geom.is<mapnik::geometry::geometry_empty<double>>())
|
||||
{
|
||||
mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx_, ++feature_id_));
|
||||
feature->set_geometry(std::move(geom));
|
||||
|
|
|
@ -58,7 +58,7 @@ mapnik::feature_ptr csv_inline_featureset::parse_feature(std::string const& str)
|
|||
auto const* end = start + str.size();
|
||||
auto values = csv_utils::parse_line(start, end, separator_, quote_, headers_.size());
|
||||
auto geom = csv_utils::extract_geometry(values, locator_);
|
||||
if (!geom.is<mapnik::geometry::geometry_empty>())
|
||||
if (!geom.is<mapnik::geometry::geometry_empty<double>>())
|
||||
{
|
||||
mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx_, ++feature_id_));
|
||||
feature->set_geometry(std::move(geom));
|
||||
|
|
|
@ -406,7 +406,7 @@ void csv_file_parser::parse_csv_and_boxes(std::istream & csv_file, T & boxes)
|
|||
}
|
||||
|
||||
auto geom = extract_geometry(values, locator_);
|
||||
if (!geom.is<mapnik::geometry::geometry_empty>())
|
||||
if (!geom.is<mapnik::geometry::geometry_empty<double>>())
|
||||
{
|
||||
auto box = mapnik::geometry::envelope(geom);
|
||||
if (!extent_initialized_)
|
||||
|
|
|
@ -98,7 +98,7 @@ mapnik::geometry::line_string<double> ogr_converter::convert_linestring(OGRLineS
|
|||
geom.reserve(num_points);
|
||||
for (int i = 0; i < num_points; ++i)
|
||||
{
|
||||
geom.add_coord(ogr_geom->getX(i), ogr_geom->getY(i));
|
||||
geom.emplace_back(ogr_geom->getX(i), ogr_geom->getY(i));
|
||||
}
|
||||
return geom;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ mapnik::geometry::polygon<double> ogr_converter::convert_polygon(OGRPolygon* ogr
|
|||
{
|
||||
exterior.emplace_back(ogr_exterior->getX(i), ogr_exterior->getY(i));
|
||||
}
|
||||
geom.set_exterior_ring(std::move(exterior));
|
||||
geom.push_back(std::move(exterior));
|
||||
|
||||
int num_interior = ogr_geom->getNumInteriorRings();
|
||||
for (int r = 0; r < num_interior; ++r)
|
||||
|
@ -140,7 +140,7 @@ mapnik::geometry::polygon<double> ogr_converter::convert_polygon(OGRPolygon* ogr
|
|||
{
|
||||
interior.emplace_back(ogr_interior->getX(i), ogr_interior->getY(i));
|
||||
}
|
||||
geom.add_hole(std::move(interior));
|
||||
geom.push_back(std::move(interior));
|
||||
}
|
||||
return geom;
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ mapnik::geometry::geometry<double> shape_io::read_polyline(shape_file::record_ty
|
|||
{
|
||||
double x = record.read_double();
|
||||
double y = record.read_double();
|
||||
line.add_coord(x, y);
|
||||
line.emplace_back(x, y);
|
||||
}
|
||||
geom = std::move(line);
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ mapnik::geometry::geometry<double> shape_io::read_polyline(shape_file::record_ty
|
|||
{
|
||||
double x = record.read_double();
|
||||
double y = record.read_double();
|
||||
line.add_coord(x, y);
|
||||
line.emplace_back(x, y);
|
||||
}
|
||||
multi_line.push_back(std::move(line));
|
||||
}
|
||||
|
@ -210,17 +210,17 @@ mapnik::geometry::geometry<double> shape_io::read_polygon(shape_file::record_typ
|
|||
}
|
||||
if (k == 0)
|
||||
{
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
poly.push_back(std::move(ring));
|
||||
}
|
||||
else if (mapnik::util::is_clockwise(ring))
|
||||
{
|
||||
multi_poly.emplace_back(std::move(poly));
|
||||
poly.interior_rings.clear();
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
poly.clear();
|
||||
poly.push_back(std::move(ring));
|
||||
}
|
||||
else
|
||||
{
|
||||
poly.add_hole(std::move(ring));
|
||||
poly.push_back(std::move(ring));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -260,17 +260,17 @@ mapnik::geometry::geometry<double> shape_io::read_polygon_parts(shape_file::reco
|
|||
}
|
||||
if (k == 0)
|
||||
{
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
poly.push_back(std::move(ring));
|
||||
}
|
||||
else if (mapnik::util::is_clockwise(ring))
|
||||
{
|
||||
multi_poly.emplace_back(std::move(poly));
|
||||
poly.interior_rings.clear();
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
poly.clear();
|
||||
poly.push_back(std::move(ring));
|
||||
}
|
||||
else
|
||||
{
|
||||
poly.add_hole(std::move(ring));
|
||||
poly.push_back(std::move(ring));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -180,22 +180,30 @@ struct render_ring_visitor
|
|||
}
|
||||
}
|
||||
|
||||
void operator()(mapnik::geometry::polygon<double> const& geom) const
|
||||
void operator()(mapnik::geometry::polygon<double> const& poly) const
|
||||
{
|
||||
agg::rgba8 red(255,0,0,255);
|
||||
agg::rgba8 green(0,255,255,255);
|
||||
agg::rgba8 black(0,0,0,255);
|
||||
renderer_.draw_ring(geom.exterior_ring,red);
|
||||
if (mapnik::util::is_clockwise(geom.exterior_ring))
|
||||
bool exterior = true;
|
||||
for (auto const& ring : poly)
|
||||
{
|
||||
renderer_.draw_outline(geom.exterior_ring,black);
|
||||
}
|
||||
for (auto const& ring : geom.interior_rings)
|
||||
{
|
||||
renderer_.draw_ring(ring,green);
|
||||
if (!mapnik::util::is_clockwise(ring))
|
||||
if (exterior)
|
||||
{
|
||||
renderer_.draw_outline(ring,black);
|
||||
exterior = false;
|
||||
renderer_.draw_ring(ring, red);
|
||||
if (mapnik::util::is_clockwise(ring))
|
||||
{
|
||||
renderer_.draw_outline(ring,black);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer_.draw_ring(ring,green);
|
||||
if (!mapnik::util::is_clockwise(ring))
|
||||
{
|
||||
renderer_.draw_outline(ring,black);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
namespace mapnik {
|
||||
|
||||
template class box2d<int>;
|
||||
template class box2d<std::int64_t>;
|
||||
template class box2d<float>;
|
||||
template class box2d<double>;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace mapnik {
|
|||
namespace geometry {
|
||||
|
||||
template MAPNIK_DECL geometry<double> reproject_copy(geometry<double> const& geom, proj_transform const& proj_trans, unsigned int & n_err);
|
||||
template MAPNIK_DECL geometry_empty reproject_copy(geometry_empty const& geom, proj_transform const& proj_trans, unsigned int & n_err);
|
||||
template MAPNIK_DECL geometry_empty<double> reproject_copy(geometry_empty<double> const& geom, proj_transform const& proj_trans, unsigned int & n_err);
|
||||
template MAPNIK_DECL point<double> reproject_copy(point<double> const& geom, proj_transform const& proj_trans, unsigned int & n_err);
|
||||
template MAPNIK_DECL line_string<double> reproject_copy(line_string<double> const& geom, proj_transform const& proj_trans, unsigned int & n_err);
|
||||
template MAPNIK_DECL polygon<double> reproject_copy(polygon<double> const& geom, proj_transform const& proj_trans, unsigned int & n_err);
|
||||
|
@ -39,7 +39,7 @@ template MAPNIK_DECL multi_polygon<double> reproject_copy(multi_polygon<double>
|
|||
template MAPNIK_DECL geometry_collection<double> reproject_copy(geometry_collection<double> const& geom, proj_transform const& proj_trans, unsigned int & n_err);
|
||||
|
||||
template MAPNIK_DECL geometry<double> reproject_copy(geometry<double> 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 geometry_empty<double> reproject_copy(geometry_empty<double> const& geom, projection const& source, projection const& dest, unsigned int & n_err);
|
||||
template MAPNIK_DECL point<double> reproject_copy(point<double> const& geom, projection const& source, projection const& dest, unsigned int & n_err);
|
||||
template MAPNIK_DECL line_string<double> reproject_copy(line_string<double> const& geom, projection const& source, projection const& dest, unsigned int & n_err);
|
||||
template MAPNIK_DECL polygon<double> reproject_copy(polygon<double> const& geom, projection const& source, projection const& dest, unsigned int & n_err);
|
||||
|
@ -49,7 +49,7 @@ template MAPNIK_DECL multi_polygon<double> reproject_copy(multi_polygon<double>
|
|||
template MAPNIK_DECL geometry_collection<double> reproject_copy(geometry_collection<double> const& geom, projection const& source, projection const& dest, unsigned int & n_err);
|
||||
|
||||
template MAPNIK_DECL bool reproject(geometry<double> & geom, proj_transform const& proj_trans);
|
||||
template MAPNIK_DECL bool reproject(geometry_empty & geom, proj_transform const& proj_trans);
|
||||
template MAPNIK_DECL bool reproject(geometry_empty<double> & geom, proj_transform const& proj_trans);
|
||||
template MAPNIK_DECL bool reproject(point<double> & geom, proj_transform const& proj_trans);
|
||||
template MAPNIK_DECL bool reproject(line_string<double> & geom, proj_transform const& proj_trans);
|
||||
template MAPNIK_DECL bool reproject(polygon<double> & geom, proj_transform const& proj_trans);
|
||||
|
@ -59,7 +59,7 @@ template MAPNIK_DECL bool reproject(multi_polygon<double> & geom, proj_transform
|
|||
template MAPNIK_DECL bool reproject(geometry_collection<double> & geom, proj_transform const& proj_trans);
|
||||
|
||||
template MAPNIK_DECL bool reproject(geometry<double> & 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(geometry_empty<double> & geom, projection const& source, projection const& dest);
|
||||
template MAPNIK_DECL bool reproject(point<double> & geom, projection const& source, projection const& dest);
|
||||
template MAPNIK_DECL bool reproject(line_string<double> & geom, projection const& source, projection const& dest);
|
||||
template MAPNIK_DECL bool reproject(polygon<double> & geom, projection const& source, projection const& dest);
|
||||
|
|
|
@ -103,7 +103,7 @@ bool proj_transform::forward (geometry::point<double> & p) const
|
|||
return forward(&(p.x), &(p.y), &z, 1);
|
||||
}
|
||||
|
||||
unsigned int proj_transform::forward (geometry::line_string<double> & ls) const
|
||||
unsigned int proj_transform::forward (std::vector<geometry::point<double>> & ls) const
|
||||
{
|
||||
std::size_t size = ls.size();
|
||||
if (size == 0) return 0;
|
||||
|
@ -244,7 +244,7 @@ bool proj_transform::backward (geometry::point<double> & p) const
|
|||
return backward(&(p.x), &(p.y), &z, 1);
|
||||
}
|
||||
|
||||
unsigned int proj_transform::backward (geometry::line_string<double> & ls) const
|
||||
unsigned int proj_transform::backward (std::vector<geometry::point<double>> & ls) const
|
||||
{
|
||||
std::size_t size = ls.size();
|
||||
if (size == 0) return 0;
|
||||
|
|
|
@ -110,7 +110,7 @@ struct split_multi_geometries
|
|||
split_multi_geometries(container_type & cont)
|
||||
: cont_(cont) { }
|
||||
|
||||
void operator() (geometry::geometry_empty const&) const {}
|
||||
void operator() (geometry::geometry_empty<double> const&) const {}
|
||||
void operator() (geometry::multi_point<double> const& multi_pt) const
|
||||
{
|
||||
for ( auto const& pt : multi_pt )
|
||||
|
|
11
src/twkb.cpp
11
src/twkb.cpp
|
@ -82,7 +82,7 @@ public:
|
|||
|
||||
mapnik::geometry::geometry<double> read()
|
||||
{
|
||||
mapnik::geometry::geometry<double> geom = mapnik::geometry::geometry_empty();
|
||||
mapnik::geometry::geometry<double> geom = mapnik::geometry::geometry_empty<double>();
|
||||
// Read the metadata bytes, populating all the
|
||||
// information about optional fields, extended (z/m) dimensions
|
||||
// expansion factors and so on
|
||||
|
@ -328,11 +328,7 @@ private:
|
|||
{
|
||||
unsigned int num_rings = read_unsigned_integer();
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
if (num_rings > 1)
|
||||
{
|
||||
poly.interior_rings.reserve(num_rings - 1);
|
||||
}
|
||||
|
||||
poly.reserve(num_rings);
|
||||
for (unsigned int i = 0; i < num_rings; ++i)
|
||||
{
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
|
@ -342,8 +338,7 @@ private:
|
|||
ring.reserve(num_points);
|
||||
read_coords<mapnik::geometry::linear_ring<double>>(ring, num_points);
|
||||
}
|
||||
if ( i == 0) poly.set_exterior_ring(std::move(ring));
|
||||
else poly.add_hole(std::move(ring));
|
||||
poly.push_back(std::move(ring));
|
||||
}
|
||||
return poly;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ point_vertex_adapter<T>::point_vertex_adapter(point<T> const& pt)
|
|||
first_(true) {}
|
||||
|
||||
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_)
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ line_string_vertex_adapter<T>::line_string_vertex_adapter(line_string<T> const&
|
|||
{}
|
||||
|
||||
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_)
|
||||
{
|
||||
|
@ -102,22 +102,22 @@ template <typename T>
|
|||
polygon_vertex_adapter<T>::polygon_vertex_adapter(polygon<T> const& poly)
|
||||
: poly_(poly),
|
||||
rings_itr_(0),
|
||||
rings_end_(poly_.interior_rings.size() + 1),
|
||||
rings_end_(poly_.size()),
|
||||
current_index_(0),
|
||||
end_index_((rings_itr_ < rings_end_) ? poly_.exterior_ring.size() : 0),
|
||||
end_index_(poly_.empty() ? 0 : poly_[0].size()),
|
||||
start_loop_(true) {}
|
||||
|
||||
template <typename T>
|
||||
void polygon_vertex_adapter<T>::rewind(unsigned) const
|
||||
{
|
||||
rings_itr_ = 0;
|
||||
rings_end_ = poly_.interior_rings.size() + 1;
|
||||
rings_end_ = poly_.size();
|
||||
current_index_ = 0;
|
||||
end_index_ = (rings_itr_ < rings_end_) ? poly_.exterior_ring.size() : 0;
|
||||
end_index_ = poly_.empty() ? 0 : poly_[0].size();
|
||||
start_loop_ = true;
|
||||
}
|
||||
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_)
|
||||
{
|
||||
|
@ -125,8 +125,7 @@ unsigned polygon_vertex_adapter<T>::vertex(coord_type * x, coord_type * y) const
|
|||
}
|
||||
if (current_index_ < end_index_)
|
||||
{
|
||||
point<T> const& coord = (rings_itr_ == 0) ?
|
||||
poly_.exterior_ring[current_index_++] : poly_.interior_rings[rings_itr_- 1][current_index_++];
|
||||
point<T> const& coord = poly_[rings_itr_][current_index_++];
|
||||
*x = coord.x;
|
||||
*y = coord.y;
|
||||
if (start_loop_)
|
||||
|
@ -145,8 +144,8 @@ unsigned polygon_vertex_adapter<T>::vertex(coord_type * x, coord_type * y) const
|
|||
else if (++rings_itr_ != rings_end_)
|
||||
{
|
||||
current_index_ = 0;
|
||||
end_index_ = poly_.interior_rings[rings_itr_ - 1].size();
|
||||
point<T> const& coord = poly_.interior_rings[rings_itr_ - 1][current_index_++];
|
||||
end_index_ = poly_[rings_itr_].size();
|
||||
point<T> const& coord = poly_[rings_itr_][current_index_++];
|
||||
*x = coord.x;
|
||||
*y = coord.y;
|
||||
return mapnik::SEG_MOVETO;
|
||||
|
@ -177,7 +176,7 @@ void ring_vertex_adapter<T>::rewind(unsigned) const
|
|||
}
|
||||
|
||||
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_)
|
||||
{
|
||||
|
|
11
src/wkb.cpp
11
src/wkb.cpp
|
@ -119,7 +119,7 @@ public:
|
|||
|
||||
mapnik::geometry::geometry<double> read()
|
||||
{
|
||||
mapnik::geometry::geometry<double> geom = mapnik::geometry::geometry_empty();
|
||||
mapnik::geometry::geometry<double> geom = mapnik::geometry::geometry_empty<double>();
|
||||
int type = read_integer();
|
||||
switch (type)
|
||||
{
|
||||
|
@ -329,11 +329,7 @@ private:
|
|||
{
|
||||
int num_rings = read_integer();
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
if (num_rings > 1)
|
||||
{
|
||||
poly.interior_rings.reserve(num_rings - 1);
|
||||
}
|
||||
|
||||
poly.reserve(num_rings);
|
||||
for (int i = 0; i < num_rings; ++i)
|
||||
{
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
|
@ -343,8 +339,7 @@ private:
|
|||
ring.reserve(num_points);
|
||||
read_coords<mapnik::geometry::linear_ring<double>, M, Z>(ring, num_points);
|
||||
}
|
||||
if ( i == 0) poly.set_exterior_ring(std::move(ring));
|
||||
else poly.add_hole(std::move(ring));
|
||||
poly.push_back(std::move(ring));
|
||||
}
|
||||
return poly;
|
||||
}
|
||||
|
|
|
@ -121,48 +121,53 @@ inline void require_attributes(mapnik::feature_ptr feature,
|
|||
}
|
||||
|
||||
namespace detail {
|
||||
struct feature_count {
|
||||
template <typename T>
|
||||
std::size_t operator()(T const &geom) const {
|
||||
|
||||
template <typename T>
|
||||
struct feature_count
|
||||
{
|
||||
template <typename U>
|
||||
std::size_t operator()(U const &geom) const
|
||||
{
|
||||
return mapnik::util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
std::size_t operator()(mapnik::geometry::geometry_empty const &) const {
|
||||
std::size_t operator()(mapnik::geometry::geometry_empty<T> const &) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::size_t operator()(mapnik::geometry::point<T> const &) const {
|
||||
std::size_t operator()(mapnik::geometry::point<T> const &) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::size_t operator()(mapnik::geometry::line_string<T> const &) const {
|
||||
std::size_t operator()(mapnik::geometry::line_string<T> const &) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::size_t operator()(mapnik::geometry::polygon<T> const &) const {
|
||||
std::size_t operator()(mapnik::geometry::polygon<T> const &) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::size_t operator()(mapnik::geometry::multi_point<T> const &mp) const {
|
||||
std::size_t operator()(mapnik::geometry::multi_point<T> const &mp) const
|
||||
{
|
||||
return mp.size();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::size_t operator()(mapnik::geometry::multi_line_string<T> const &mls) const {
|
||||
std::size_t operator()(mapnik::geometry::multi_line_string<T> const &mls) const
|
||||
{
|
||||
return mls.size();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::size_t operator()(mapnik::geometry::multi_polygon<T> const &mp) const {
|
||||
std::size_t operator()(mapnik::geometry::multi_polygon<T> const &mp) const
|
||||
{
|
||||
return mp.size();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::size_t operator()(mapnik::geometry::geometry_collection<T> const &col) const {
|
||||
std::size_t operator()(mapnik::geometry::geometry_collection<T> const &col) const
|
||||
{
|
||||
std::size_t sum = 0;
|
||||
for (auto const &geom : col) {
|
||||
sum += operator()(geom);
|
||||
|
@ -174,7 +179,7 @@ struct feature_count {
|
|||
|
||||
template <typename T>
|
||||
inline std::size_t feature_count(mapnik::geometry::geometry<T> const &g) {
|
||||
return detail::feature_count()(g);
|
||||
return detail::feature_count<T>()(g);
|
||||
}
|
||||
|
||||
inline void require_geometry(mapnik::feature_ptr feature,
|
||||
|
|
|
@ -191,10 +191,9 @@ TEST_CASE("geojson") {
|
|||
auto const& geometry = feature->get_geometry();
|
||||
REQUIRE(mapnik::geometry::geometry_type(geometry) == mapnik::geometry::Polygon);
|
||||
auto const& poly = mapnik::util::get<mapnik::geometry::polygon<double> >(geometry);
|
||||
REQUIRE(poly.num_rings() == 2);
|
||||
REQUIRE(poly.exterior_ring.size() == 5);
|
||||
REQUIRE(poly.interior_rings.size() == 1);
|
||||
REQUIRE(poly.interior_rings[0].size() == 5);
|
||||
REQUIRE(poly.size() == 2);
|
||||
REQUIRE(poly[0].size() == 5);
|
||||
REQUIRE(poly[1].size() == 5);
|
||||
REQUIRE(mapnik::geometry::envelope(poly) == mapnik::box2d<double>(100,0,101,1));
|
||||
|
||||
}
|
||||
|
@ -248,8 +247,8 @@ TEST_CASE("geojson") {
|
|||
REQUIRE(mapnik::geometry::geometry_type(geometry) == mapnik::geometry::MultiPolygon);
|
||||
auto const& multi_poly = mapnik::util::get<mapnik::geometry::multi_polygon<double> >(geometry);
|
||||
REQUIRE(multi_poly.size() == 2);
|
||||
REQUIRE(multi_poly[0].num_rings() == 1);
|
||||
REQUIRE(multi_poly[1].num_rings() == 2);
|
||||
REQUIRE(multi_poly[0].size() == 1);
|
||||
REQUIRE(multi_poly[1].size() == 2);
|
||||
REQUIRE(mapnik::geometry::envelope(multi_poly) == mapnik::box2d<double>(100,0,103,3));
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include "catch.hpp"
|
||||
|
||||
#include <mapnik/geometry_centroid.hpp>
|
||||
|
@ -7,7 +6,7 @@ TEST_CASE("geometry centroid") {
|
|||
|
||||
SECTION("empty geometry") {
|
||||
|
||||
mapnik::geometry::geometry_empty geom;
|
||||
mapnik::geometry::geometry_empty<double> geom;
|
||||
mapnik::geometry::point<double> centroid;
|
||||
REQUIRE(!mapnik::geometry::centroid(geom, centroid));
|
||||
}
|
||||
|
@ -31,9 +30,9 @@ SECTION("point") {
|
|||
SECTION("linestring") {
|
||||
|
||||
mapnik::geometry::line_string<double> line;
|
||||
line.add_coord(0, 0);
|
||||
line.add_coord(25, 25);
|
||||
line.add_coord(50, 50);
|
||||
line.emplace_back(0, 0);
|
||||
line.emplace_back(25, 25);
|
||||
line.emplace_back(50, 50);
|
||||
mapnik::geometry::point<double> centroid;
|
||||
REQUIRE(mapnik::geometry::centroid(line, centroid));
|
||||
REQUIRE(centroid.x == 25);
|
||||
|
@ -51,12 +50,12 @@ SECTION("polygon") {
|
|||
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0, 0);
|
||||
ring.add_coord(1, 0);
|
||||
ring.add_coord(1, 1);
|
||||
ring.add_coord(0, 1);
|
||||
ring.add_coord(0, 0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0, 0);
|
||||
ring.emplace_back(1, 0);
|
||||
ring.emplace_back(1, 1);
|
||||
ring.emplace_back(0, 1);
|
||||
ring.emplace_back(0, 0);
|
||||
poly.push_back(std::move(ring));
|
||||
|
||||
mapnik::geometry::point<double> centroid;
|
||||
REQUIRE(mapnik::geometry::centroid(poly, centroid));
|
||||
|
@ -68,7 +67,7 @@ SECTION("polygon with empty exterior ring") {
|
|||
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
poly.push_back(std::move(ring));
|
||||
|
||||
mapnik::geometry::point<double> centroid;
|
||||
REQUIRE(!mapnik::geometry::centroid(poly, centroid));
|
||||
|
@ -77,6 +76,7 @@ SECTION("polygon with empty exterior ring") {
|
|||
SECTION("empty polygon") {
|
||||
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
poly.emplace_back();
|
||||
mapnik::geometry::point<double> centroid;
|
||||
REQUIRE(!mapnik::geometry::centroid(poly, centroid));
|
||||
}
|
||||
|
@ -84,9 +84,9 @@ SECTION("empty polygon") {
|
|||
SECTION("multi-point") {
|
||||
|
||||
mapnik::geometry::multi_point<double> geom;
|
||||
geom.add_coord(0, 0);
|
||||
geom.add_coord(25, 25);
|
||||
geom.add_coord(50, 50);
|
||||
geom.emplace_back(0, 0);
|
||||
geom.emplace_back(25, 25);
|
||||
geom.emplace_back(50, 50);
|
||||
mapnik::geometry::point<double> centroid;
|
||||
REQUIRE(mapnik::geometry::centroid(geom, centroid));
|
||||
REQUIRE(centroid.x == 25);
|
||||
|
@ -105,16 +105,16 @@ SECTION("multi-linestring") {
|
|||
mapnik::geometry::multi_line_string<double> geom;
|
||||
{
|
||||
mapnik::geometry::line_string<double> line;
|
||||
line.add_coord(0, 0);
|
||||
line.add_coord(0, 25);
|
||||
line.add_coord(0, 50);
|
||||
line.emplace_back(0, 0);
|
||||
line.emplace_back(0, 25);
|
||||
line.emplace_back(0, 50);
|
||||
geom.emplace_back(std::move(line));
|
||||
}
|
||||
{
|
||||
mapnik::geometry::line_string<double> line;
|
||||
line.add_coord(0, 0);
|
||||
line.add_coord(25, 0);
|
||||
line.add_coord(50, 0);
|
||||
line.emplace_back(0, 0);
|
||||
line.emplace_back(25, 0);
|
||||
line.emplace_back(50, 0);
|
||||
geom.emplace_back(std::move(line));
|
||||
}
|
||||
mapnik::geometry::point<double> centroid;
|
||||
|
@ -127,9 +127,9 @@ SECTION("multi-linestring: one component empty") {
|
|||
|
||||
mapnik::geometry::multi_line_string<double> geom;
|
||||
mapnik::geometry::line_string<double> line;
|
||||
line.add_coord(0, 0);
|
||||
line.add_coord(0, 25);
|
||||
line.add_coord(0, 50);
|
||||
line.emplace_back(0, 0);
|
||||
line.emplace_back(0, 25);
|
||||
line.emplace_back(0, 50);
|
||||
geom.emplace_back(std::move(line));
|
||||
geom.emplace_back();
|
||||
mapnik::geometry::point<double> centroid;
|
||||
|
@ -151,23 +151,23 @@ SECTION("multi-polygon") {
|
|||
{
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0, 0);
|
||||
ring.add_coord(1, 0);
|
||||
ring.add_coord(1, 1);
|
||||
ring.add_coord(0, 1);
|
||||
ring.add_coord(0, 0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0, 0);
|
||||
ring.emplace_back(1, 0);
|
||||
ring.emplace_back(1, 1);
|
||||
ring.emplace_back(0, 1);
|
||||
ring.emplace_back(0, 0);
|
||||
poly.push_back(std::move(ring));
|
||||
geom.emplace_back(std::move(poly));
|
||||
}
|
||||
{
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(1, 1);
|
||||
ring.add_coord(2, 1);
|
||||
ring.add_coord(2, 2);
|
||||
ring.add_coord(1, 2);
|
||||
ring.add_coord(1, 1);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(1, 1);
|
||||
ring.emplace_back(2, 1);
|
||||
ring.emplace_back(2, 2);
|
||||
ring.emplace_back(1, 2);
|
||||
ring.emplace_back(1, 1);
|
||||
poly.push_back(std::move(ring));
|
||||
geom.emplace_back(std::move(poly));
|
||||
}
|
||||
|
||||
|
@ -179,22 +179,22 @@ SECTION("multi-polygon") {
|
|||
|
||||
SECTION("multi-polygon: one component empty") {
|
||||
|
||||
mapnik::geometry::multi_polygon<double> geom;
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0, 0);
|
||||
ring.add_coord(1, 0);
|
||||
ring.add_coord(1, 1);
|
||||
ring.add_coord(0, 1);
|
||||
ring.add_coord(0, 0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
geom.emplace_back(std::move(poly));
|
||||
geom.emplace_back();
|
||||
|
||||
mapnik::geometry::point<double> centroid;
|
||||
REQUIRE(mapnik::geometry::centroid(geom, centroid));
|
||||
REQUIRE(centroid.x == 0.5);
|
||||
REQUIRE(centroid.y == 0.5);
|
||||
mapnik::geometry::multi_polygon<double> geom;
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.emplace_back(0, 0);
|
||||
ring.emplace_back(1, 0);
|
||||
ring.emplace_back(1, 1);
|
||||
ring.emplace_back(0, 1);
|
||||
ring.emplace_back(0, 0);
|
||||
poly.push_back(std::move(ring));
|
||||
geom.emplace_back(std::move(poly));
|
||||
geom.emplace_back();
|
||||
geom.back().emplace_back();
|
||||
mapnik::geometry::point<double> centroid;
|
||||
REQUIRE(mapnik::geometry::centroid(geom, centroid));
|
||||
REQUIRE(centroid.x == 0.5);
|
||||
REQUIRE(centroid.y == 0.5);
|
||||
}
|
||||
|
||||
SECTION("empty multi-polygon") {
|
||||
|
|
|
@ -21,15 +21,15 @@ void envelope_test()
|
|||
}
|
||||
{
|
||||
// Test empty geom
|
||||
geometry<coord_type> geom = mapnik::geometry::geometry_empty();
|
||||
geometry<coord_type> geom = mapnik::geometry::geometry_empty<coord_type>();
|
||||
mapnik::box2d<coord_type> bbox = mapnik::geometry::envelope(geom);
|
||||
REQUIRE_FALSE( bbox.valid() );
|
||||
}
|
||||
{
|
||||
line_string<coord_type> line;
|
||||
line.add_coord(0,0);
|
||||
line.add_coord(1,1);
|
||||
line.add_coord(2,2);
|
||||
line.emplace_back(0,0);
|
||||
line.emplace_back(1,1);
|
||||
line.emplace_back(2,2);
|
||||
geometry<coord_type> geom(line);
|
||||
mapnik::box2d<coord_type> bbox = mapnik::geometry::envelope(geom);
|
||||
REQUIRE( bbox.minx() == 0 );
|
||||
|
@ -39,13 +39,13 @@ void envelope_test()
|
|||
}
|
||||
{
|
||||
line_string<coord_type> line;
|
||||
line.add_coord(0,0);
|
||||
line.add_coord(1,1);
|
||||
line.add_coord(2,2);
|
||||
line.emplace_back(0,0);
|
||||
line.emplace_back(1,1);
|
||||
line.emplace_back(2,2);
|
||||
line_string<coord_type> line2;
|
||||
line2.add_coord(0,0);
|
||||
line2.add_coord(-1,-1);
|
||||
line2.add_coord(-2,-2);
|
||||
line2.emplace_back(0,0);
|
||||
line2.emplace_back(-1,-1);
|
||||
line2.emplace_back(-2,-2);
|
||||
multi_line_string<coord_type> multi_line;
|
||||
multi_line.emplace_back(std::move(line));
|
||||
multi_line.emplace_back(std::move(line2));
|
||||
|
@ -59,12 +59,12 @@ void envelope_test()
|
|||
{
|
||||
polygon<coord_type> poly;
|
||||
linear_ring<coord_type> 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));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(-10,0);
|
||||
ring.emplace_back(-10,10);
|
||||
ring.emplace_back(0,10);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
geometry<coord_type> geom(poly);
|
||||
mapnik::box2d<coord_type> bbox = mapnik::geometry::envelope(geom);
|
||||
REQUIRE( bbox.minx() == -10 );
|
||||
|
@ -102,19 +102,19 @@ void envelope_test()
|
|||
// polygon with hole
|
||||
polygon<coord_type> poly;
|
||||
linear_ring<coord_type> 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));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(-10,0);
|
||||
ring.emplace_back(-10,10);
|
||||
ring.emplace_back(0,10);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
linear_ring<coord_type> 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));
|
||||
hole.emplace_back(-7,7);
|
||||
hole.emplace_back(-7,3);
|
||||
hole.emplace_back(-3,3);
|
||||
hole.emplace_back(-3,7);
|
||||
hole.emplace_back(-7,7);
|
||||
poly.push_back(std::move(hole));
|
||||
geometry<coord_type> geom(poly);
|
||||
mapnik::box2d<coord_type> bbox = mapnik::geometry::envelope(poly);
|
||||
REQUIRE( bbox.minx() == -10 );
|
||||
|
@ -124,12 +124,12 @@ void envelope_test()
|
|||
// add another hole inside the first hole
|
||||
// which should be considered a hit
|
||||
linear_ring<coord_type> 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));
|
||||
fill.emplace_back(-6,4);
|
||||
fill.emplace_back(-6,6);
|
||||
fill.emplace_back(-4,6);
|
||||
fill.emplace_back(-4,4);
|
||||
fill.emplace_back(-6,4);
|
||||
poly.push_back(std::move(fill));
|
||||
bbox = mapnik::geometry::envelope(poly);
|
||||
REQUIRE( bbox.minx() == -10 );
|
||||
REQUIRE( bbox.miny() == 0 );
|
||||
|
|
|
@ -106,7 +106,8 @@ struct geometry_equal_visitor
|
|||
REQUIRE(false);
|
||||
}
|
||||
|
||||
void operator() (geometry_empty const&, geometry_empty const&) const
|
||||
template <typename T>
|
||||
void operator() (geometry_empty<T> const&, geometry_empty<T> const&) const
|
||||
{
|
||||
REQUIRE(true);
|
||||
}
|
||||
|
@ -119,7 +120,7 @@ struct geometry_equal_visitor
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void operator() (line_string<T> const& ls1, line_string<T> const& ls2) const
|
||||
void operator() (std::vector<point<T>> const& ls1, std::vector<point<T>> const& ls2) const
|
||||
{
|
||||
if (ls1.size() != ls2.size())
|
||||
{
|
||||
|
@ -136,25 +137,33 @@ struct geometry_equal_visitor
|
|||
template <typename T>
|
||||
void operator() (polygon<T> const& p1, polygon<T> const& p2) const
|
||||
{
|
||||
(*this)(static_cast<line_string<T> const&>(p1.exterior_ring), static_cast<line_string<T> const&>(p2.exterior_ring));
|
||||
|
||||
if (p1.interior_rings.size() != p2.interior_rings.size())
|
||||
if (p1.size() != p2.size())
|
||||
{
|
||||
REQUIRE(false);
|
||||
}
|
||||
|
||||
for (auto const& p : zip_crange(p1.interior_rings, p2.interior_rings))
|
||||
for (auto const& p : zip_crange(p1, p2))
|
||||
{
|
||||
(*this)(static_cast<line_string<T> const&>(p.template get<0>()),static_cast<line_string<T> const&>(p.template get<1>()));
|
||||
(*this)(static_cast<std::vector<point<T>> const&>(p.template get<0>()),
|
||||
static_cast<std::vector<point<T>> const&>(p.template get<1>()));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void operator() (line_string<T> const& ls1, line_string<T> const& ls2) const
|
||||
{
|
||||
(*this)(static_cast<std::vector<point<T>> const&>(ls1),
|
||||
static_cast<std::vector<point<T>> const&>(ls2));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void operator() (multi_point<T> const& mp1, multi_point<T> const& mp2) const
|
||||
{
|
||||
(*this)(static_cast<line_string<T> const&>(mp1), static_cast<line_string<T> const&>(mp2));
|
||||
(*this)(static_cast<std::vector<point<T>> const&>(mp1),
|
||||
static_cast<std::vector<point<T>> const&>(mp2));
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
void operator() (multi_line_string<T> const& mls1, multi_line_string<T> const& mls2) const
|
||||
{
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include "catch.hpp"
|
||||
|
||||
#include <mapnik/geometry.hpp>
|
||||
|
@ -27,17 +26,17 @@ SECTION("hit_test_filter - double") {
|
|||
}
|
||||
{
|
||||
line_string<double> line;
|
||||
line.add_coord(0,0);
|
||||
line.add_coord(1,1);
|
||||
line.add_coord(2,2);
|
||||
line.emplace_back(0,0);
|
||||
line.emplace_back(1,1);
|
||||
line.emplace_back(2,2);
|
||||
geometry<double> geom(line);
|
||||
REQUIRE( mapnik::hit_test(geom,0,0,1.5) );
|
||||
}
|
||||
{
|
||||
line_string<double> line;
|
||||
line.add_coord(0,0);
|
||||
line.add_coord(1,1);
|
||||
line.add_coord(2,2);
|
||||
line.emplace_back(0,0);
|
||||
line.emplace_back(1,1);
|
||||
line.emplace_back(2,2);
|
||||
multi_line_string<double> multi_line;
|
||||
multi_line.emplace_back(std::move(line));
|
||||
geometry<double> geom(multi_line);
|
||||
|
@ -46,12 +45,12 @@ SECTION("hit_test_filter - double") {
|
|||
{
|
||||
polygon<double> poly;
|
||||
linear_ring<double> 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));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(-10,0);
|
||||
ring.emplace_back(-10,10);
|
||||
ring.emplace_back(0,10);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
geometry<double> geom(poly);
|
||||
REQUIRE( mapnik::hit_test(geom,-5,5,0) );
|
||||
|
||||
|
@ -78,30 +77,30 @@ SECTION("hit_test_filter - double") {
|
|||
// polygon with hole
|
||||
polygon<double> poly;
|
||||
linear_ring<double> 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));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(-10,0);
|
||||
ring.emplace_back(-10,10);
|
||||
ring.emplace_back(0,10);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
linear_ring<double> 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));
|
||||
hole.emplace_back(-7,7);
|
||||
hole.emplace_back(-7,3);
|
||||
hole.emplace_back(-3,3);
|
||||
hole.emplace_back(-3,7);
|
||||
hole.emplace_back(-7,7);
|
||||
poly.push_back(std::move(hole));
|
||||
geometry<double> 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<double> 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));
|
||||
fill.emplace_back(-6,4);
|
||||
fill.emplace_back(-6,6);
|
||||
fill.emplace_back(-4,6);
|
||||
fill.emplace_back(-4,4);
|
||||
fill.emplace_back(-6,4);
|
||||
poly.push_back(std::move(fill));
|
||||
REQUIRE( mapnik::hit_test(geometry<double>(poly),-5,5,0) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include "catch.hpp"
|
||||
|
||||
#include <boost/version.hpp>
|
||||
|
@ -11,7 +10,7 @@ TEST_CASE("geometry is_simple") {
|
|||
#if BOOST_VERSION >= 105800
|
||||
|
||||
SECTION("point") {
|
||||
mapnik::geometry::geometry_empty empty;
|
||||
mapnik::geometry::geometry_empty<double> empty;
|
||||
CHECK( mapnik::geometry::is_simple(empty) );
|
||||
}
|
||||
|
||||
|
@ -53,8 +52,8 @@ SECTION("point Infinity") {
|
|||
|
||||
SECTION("multi point") {
|
||||
mapnik::geometry::multi_point<double> mpt;
|
||||
mpt.add_coord(0,0);
|
||||
mpt.add_coord(1,1);
|
||||
mpt.emplace_back(0,0);
|
||||
mpt.emplace_back(1,1);
|
||||
CHECK( mapnik::geometry::is_simple(mpt) );
|
||||
}
|
||||
|
||||
|
@ -65,18 +64,18 @@ SECTION("multi point empty") {
|
|||
|
||||
SECTION("line_string") {
|
||||
mapnik::geometry::line_string<double> line;
|
||||
line.add_coord(0,0);
|
||||
line.add_coord(1,1);
|
||||
line.emplace_back(0,0);
|
||||
line.emplace_back(1,1);
|
||||
CHECK( mapnik::geometry::is_simple(line) );
|
||||
}
|
||||
|
||||
// This fails while is_valid will not fail!
|
||||
SECTION("line_string repeated points") {
|
||||
mapnik::geometry::line_string<double> line;
|
||||
line.add_coord(0,0);
|
||||
line.add_coord(1,1);
|
||||
line.add_coord(1,1);
|
||||
line.add_coord(2,2);
|
||||
line.emplace_back(0,0);
|
||||
line.emplace_back(1,1);
|
||||
line.emplace_back(1,1);
|
||||
line.emplace_back(2,2);
|
||||
CHECK( !mapnik::geometry::is_simple(line) );
|
||||
}
|
||||
|
||||
|
@ -87,11 +86,11 @@ SECTION("line_string empty") {
|
|||
|
||||
SECTION("multi_line_string") {
|
||||
mapnik::geometry::line_string<double> line1;
|
||||
line1.add_coord(0,0);
|
||||
line1.add_coord(1,1);
|
||||
line1.emplace_back(0,0);
|
||||
line1.emplace_back(1,1);
|
||||
mapnik::geometry::line_string<double> line2;
|
||||
line2.add_coord(0,1);
|
||||
line2.add_coord(1,2);
|
||||
line2.emplace_back(0,1);
|
||||
line2.emplace_back(1,2);
|
||||
mapnik::geometry::multi_line_string<double> lines;
|
||||
lines.emplace_back(line1);
|
||||
lines.emplace_back(line2);
|
||||
|
@ -113,24 +112,24 @@ SECTION("multi_line_string empty") {
|
|||
SECTION("polygon") {
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0,0);
|
||||
ring.add_coord(1,0);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(0,1);
|
||||
ring.add_coord(0,0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(1,0);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(0,1);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
CHECK( mapnik::geometry::is_simple(poly) );
|
||||
}
|
||||
|
||||
SECTION("polygon invalid winding order") {
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0,0);
|
||||
ring.add_coord(0,1);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(1,0);
|
||||
ring.add_coord(0,0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(0,1);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(1,0);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
CHECK( mapnik::geometry::is_simple(poly) );
|
||||
}
|
||||
|
||||
|
@ -139,13 +138,13 @@ SECTION("polygon invalid winding order") {
|
|||
SECTION("polygon 2 repeated points") {
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0,0);
|
||||
ring.add_coord(1,0);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(0,1);
|
||||
ring.add_coord(0,0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(1,0);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(0,1);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
CHECK( !mapnik::geometry::is_simple(poly) );
|
||||
}
|
||||
// repeated points are not considered invalid in a polygon
|
||||
|
@ -153,14 +152,14 @@ SECTION("polygon 2 repeated points") {
|
|||
SECTION("polygon 3 repeated points") {
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0,0);
|
||||
ring.add_coord(1,0);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(0,1);
|
||||
ring.add_coord(0,0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(1,0);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(0,1);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
CHECK( !mapnik::geometry::is_simple(poly) );
|
||||
}
|
||||
|
||||
|
@ -168,27 +167,28 @@ SECTION("polygon 3 repeated points") {
|
|||
|
||||
SECTION("polygon that is empty") {
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
poly.emplace_back();
|
||||
CHECK( !mapnik::geometry::is_simple(poly) );
|
||||
}
|
||||
|
||||
SECTION("polygon that has empty exterior ring") {
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
poly.push_back(std::move(ring));
|
||||
CHECK( !mapnik::geometry::is_simple(poly) );
|
||||
}
|
||||
|
||||
SECTION("polygon that has empty interior ring") {
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0,0);
|
||||
ring.add_coord(1,0);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(0,1);
|
||||
ring.add_coord(0,0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(1,0);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(0,1);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
mapnik::geometry::linear_ring<double> ring2;
|
||||
poly.add_hole(std::move(ring2));
|
||||
poly.push_back(std::move(ring2));
|
||||
CHECK( !mapnik::geometry::is_simple(poly) );
|
||||
}
|
||||
|
||||
|
@ -202,21 +202,21 @@ SECTION("polygon that is empty") {
|
|||
SECTION("polygon that has empty exterior ring") {
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
poly.push_back(std::move(ring));
|
||||
CHECK( mapnik::geometry::is_simple(poly) );
|
||||
}
|
||||
|
||||
SECTION("polygon that has empty interior ring") {
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0,0);
|
||||
ring.add_coord(1,0);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(0,1);
|
||||
ring.add_coord(0,0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(1,0);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(0,1);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
mapnik::geometry::linear_ring<double> ring2;
|
||||
poly.add_hole(std::move(ring2));
|
||||
poly.push_back(std::move(ring2));
|
||||
CHECK( mapnik::geometry::is_simple(poly) );
|
||||
}
|
||||
|
||||
|
@ -226,33 +226,33 @@ SECTION("polygon that has empty interior ring") {
|
|||
SECTION("polygon with spike") {
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0,0);
|
||||
ring.add_coord(1,0);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(2,2);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(0,1);
|
||||
ring.add_coord(0,0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(1,0);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(2,2);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(0,1);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
CHECK( mapnik::geometry::is_simple(poly) );
|
||||
}
|
||||
|
||||
SECTION("polygon with hole") {
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0,0);
|
||||
ring.add_coord(3,0);
|
||||
ring.add_coord(3,3);
|
||||
ring.add_coord(0,3);
|
||||
ring.add_coord(0,0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(3,0);
|
||||
ring.emplace_back(3,3);
|
||||
ring.emplace_back(0,3);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
mapnik::geometry::linear_ring<double> hole;
|
||||
hole.add_coord(1,1);
|
||||
hole.add_coord(1,2);
|
||||
hole.add_coord(2,2);
|
||||
hole.add_coord(2,1);
|
||||
hole.add_coord(1,1);
|
||||
poly.add_hole(std::move(hole));
|
||||
hole.emplace_back(1,1);
|
||||
hole.emplace_back(1,2);
|
||||
hole.emplace_back(2,2);
|
||||
hole.emplace_back(2,1);
|
||||
hole.emplace_back(1,1);
|
||||
poly.push_back(std::move(hole));
|
||||
CHECK( mapnik::geometry::is_simple(poly) );
|
||||
}
|
||||
|
||||
|
@ -260,19 +260,19 @@ SECTION("polygon with hole") {
|
|||
SECTION("polygon with hole with invalid winding order") {
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0,0);
|
||||
ring.add_coord(3,0);
|
||||
ring.add_coord(3,3);
|
||||
ring.add_coord(0,3);
|
||||
ring.add_coord(0,0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(3,0);
|
||||
ring.emplace_back(3,3);
|
||||
ring.emplace_back(0,3);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
mapnik::geometry::linear_ring<double> hole;
|
||||
hole.add_coord(1,1);
|
||||
hole.add_coord(2,1);
|
||||
hole.add_coord(2,2);
|
||||
hole.add_coord(1,2);
|
||||
hole.add_coord(1,1);
|
||||
poly.add_hole(std::move(hole));
|
||||
hole.emplace_back(1,1);
|
||||
hole.emplace_back(2,1);
|
||||
hole.emplace_back(2,2);
|
||||
hole.emplace_back(1,2);
|
||||
hole.emplace_back(1,1);
|
||||
poly.push_back(std::move(hole));
|
||||
CHECK( mapnik::geometry::is_simple(poly) );
|
||||
}
|
||||
|
||||
|
@ -280,20 +280,20 @@ SECTION("multi polygon") {
|
|||
mapnik::geometry::multi_polygon<double> mp;
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0,0);
|
||||
ring.add_coord(1,0);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(0,1);
|
||||
ring.add_coord(0,0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(1,0);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(0,1);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
mapnik::geometry::polygon<double> poly2;
|
||||
mapnik::geometry::linear_ring<double> ring2;
|
||||
ring2.add_coord(0,0);
|
||||
ring2.add_coord(-1,0);
|
||||
ring2.add_coord(-1,-1);
|
||||
ring2.add_coord(0,-1);
|
||||
ring2.add_coord(0,0);
|
||||
poly2.set_exterior_ring(std::move(ring2));
|
||||
ring2.emplace_back(0,0);
|
||||
ring2.emplace_back(-1,0);
|
||||
ring2.emplace_back(-1,-1);
|
||||
ring2.emplace_back(0,-1);
|
||||
ring2.emplace_back(0,0);
|
||||
poly2.push_back(std::move(ring2));
|
||||
mp.emplace_back(poly);
|
||||
mp.emplace_back(poly2);
|
||||
CHECK( mapnik::geometry::is_simple(mp) );
|
||||
|
@ -303,34 +303,34 @@ SECTION("multi polygon with hole") {
|
|||
mapnik::geometry::multi_polygon<double> mp;
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0,0);
|
||||
ring.add_coord(3,0);
|
||||
ring.add_coord(3,3);
|
||||
ring.add_coord(0,3);
|
||||
ring.add_coord(0,0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(3,0);
|
||||
ring.emplace_back(3,3);
|
||||
ring.emplace_back(0,3);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
mapnik::geometry::linear_ring<double> hole;
|
||||
hole.add_coord(1,1);
|
||||
hole.add_coord(1,2);
|
||||
hole.add_coord(2,2);
|
||||
hole.add_coord(2,1);
|
||||
hole.add_coord(1,1);
|
||||
poly.add_hole(std::move(hole));
|
||||
hole.emplace_back(1,1);
|
||||
hole.emplace_back(1,2);
|
||||
hole.emplace_back(2,2);
|
||||
hole.emplace_back(2,1);
|
||||
hole.emplace_back(1,1);
|
||||
poly.push_back(std::move(hole));
|
||||
mapnik::geometry::polygon<double> poly2;
|
||||
mapnik::geometry::linear_ring<double> ring2;
|
||||
ring2.add_coord(0,0);
|
||||
ring2.add_coord(-3,0);
|
||||
ring2.add_coord(-3,-3);
|
||||
ring2.add_coord(0,-3);
|
||||
ring2.add_coord(0,0);
|
||||
poly2.set_exterior_ring(std::move(ring2));
|
||||
ring2.emplace_back(0,0);
|
||||
ring2.emplace_back(-3,0);
|
||||
ring2.emplace_back(-3,-3);
|
||||
ring2.emplace_back(0,-3);
|
||||
ring2.emplace_back(0,0);
|
||||
poly2.push_back(std::move(ring2));
|
||||
mapnik::geometry::linear_ring<double> hole2;
|
||||
hole2.add_coord(-1,-1);
|
||||
hole2.add_coord(-1,-2);
|
||||
hole2.add_coord(-2,-2);
|
||||
hole2.add_coord(-2,-1);
|
||||
hole2.add_coord(-1,-1);
|
||||
poly2.add_hole(std::move(hole2));
|
||||
hole2.emplace_back(-1,-1);
|
||||
hole2.emplace_back(-1,-2);
|
||||
hole2.emplace_back(-2,-2);
|
||||
hole2.emplace_back(-2,-1);
|
||||
hole2.emplace_back(-1,-1);
|
||||
poly2.push_back(std::move(hole2));
|
||||
mp.emplace_back(poly);
|
||||
mp.emplace_back(poly2);
|
||||
CHECK( mapnik::geometry::is_simple(mp) );
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include "catch.hpp"
|
||||
|
||||
#include <mapnik/geometry.hpp>
|
||||
|
@ -11,7 +10,7 @@ TEST_CASE("geometry is_valid") {
|
|||
|
||||
|
||||
SECTION("empty geometry") {
|
||||
mapnik::geometry::geometry_empty empty;
|
||||
mapnik::geometry::geometry_empty<double> empty;
|
||||
CHECK( mapnik::geometry::is_valid(empty) );
|
||||
std::string message;
|
||||
CHECK( mapnik::geometry::is_valid(empty, message) );
|
||||
|
@ -124,8 +123,8 @@ SECTION("point Infinity") {
|
|||
|
||||
SECTION("multi point") {
|
||||
mapnik::geometry::multi_point<double> mpt;
|
||||
mpt.add_coord(0,0);
|
||||
mpt.add_coord(1,1);
|
||||
mpt.emplace_back(0,0);
|
||||
mpt.emplace_back(1,1);
|
||||
CHECK( mapnik::geometry::is_valid(mpt) );
|
||||
std::string message;
|
||||
CHECK( mapnik::geometry::is_valid(mpt, message) );
|
||||
|
@ -149,8 +148,8 @@ SECTION("multi point empty") {
|
|||
|
||||
SECTION("line_string") {
|
||||
mapnik::geometry::line_string<double> line;
|
||||
line.add_coord(0,0);
|
||||
line.add_coord(1,1);
|
||||
line.emplace_back(0,0);
|
||||
line.emplace_back(1,1);
|
||||
CHECK( mapnik::geometry::is_valid(line) );
|
||||
std::string message;
|
||||
CHECK( mapnik::geometry::is_valid(line, message) );
|
||||
|
@ -163,10 +162,10 @@ SECTION("line_string") {
|
|||
// This shouldn't fail -- test added in case logic ever changes
|
||||
SECTION("line_string repeated points") {
|
||||
mapnik::geometry::line_string<double> line;
|
||||
line.add_coord(0,0);
|
||||
line.add_coord(1,1);
|
||||
line.add_coord(1,1);
|
||||
line.add_coord(2,2);
|
||||
line.emplace_back(0,0);
|
||||
line.emplace_back(1,1);
|
||||
line.emplace_back(1,1);
|
||||
line.emplace_back(2,2);
|
||||
CHECK( mapnik::geometry::is_valid(line) );
|
||||
std::string message;
|
||||
CHECK( mapnik::geometry::is_valid(line, message) );
|
||||
|
@ -189,11 +188,11 @@ SECTION("line_string empty") {
|
|||
|
||||
SECTION("multi_line_string") {
|
||||
mapnik::geometry::line_string<double> line1;
|
||||
line1.add_coord(0,0);
|
||||
line1.add_coord(1,1);
|
||||
line1.emplace_back(0,0);
|
||||
line1.emplace_back(1,1);
|
||||
mapnik::geometry::line_string<double> line2;
|
||||
line2.add_coord(0,1);
|
||||
line2.add_coord(1,2);
|
||||
line2.emplace_back(0,1);
|
||||
line2.emplace_back(1,2);
|
||||
mapnik::geometry::multi_line_string<double> lines;
|
||||
lines.emplace_back(line1);
|
||||
lines.emplace_back(line2);
|
||||
|
@ -220,12 +219,12 @@ SECTION("multi_line_string empty") {
|
|||
SECTION("polygon") {
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0,0);
|
||||
ring.add_coord(1,0);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(0,1);
|
||||
ring.add_coord(0,0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(1,0);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(0,1);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
CHECK( mapnik::geometry::is_valid(poly) );
|
||||
std::string message;
|
||||
CHECK( mapnik::geometry::is_valid(poly, message) );
|
||||
|
@ -238,12 +237,12 @@ SECTION("polygon") {
|
|||
SECTION("polygon invalid winding order") {
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0,0);
|
||||
ring.add_coord(0,1);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(1,0);
|
||||
ring.add_coord(0,0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(0,1);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(1,0);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
CHECK( !mapnik::geometry::is_valid(poly) );
|
||||
std::string message;
|
||||
CHECK( !mapnik::geometry::is_valid(poly, message) );
|
||||
|
@ -257,13 +256,13 @@ SECTION("polygon invalid winding order") {
|
|||
SECTION("polygon 2 repeated points") {
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0,0);
|
||||
ring.add_coord(1,0);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(0,1);
|
||||
ring.add_coord(0,0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(1,0);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(0,1);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
CHECK( mapnik::geometry::is_valid(poly) );
|
||||
std::string message;
|
||||
CHECK( mapnik::geometry::is_valid(poly, message) );
|
||||
|
@ -276,14 +275,14 @@ SECTION("polygon 2 repeated points") {
|
|||
SECTION("polygon 3 repeated points") {
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0,0);
|
||||
ring.add_coord(1,0);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(0,1);
|
||||
ring.add_coord(0,0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(1,0);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(0,1);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
CHECK( mapnik::geometry::is_valid(poly) );
|
||||
std::string message;
|
||||
CHECK( mapnik::geometry::is_valid(poly, message) );
|
||||
|
@ -295,6 +294,7 @@ SECTION("polygon 3 repeated points") {
|
|||
|
||||
SECTION("polygon that is empty") {
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
poly.emplace_back();
|
||||
CHECK( !mapnik::geometry::is_valid(poly) );
|
||||
std::string message;
|
||||
CHECK( !mapnik::geometry::is_valid(poly, message) );
|
||||
|
@ -307,14 +307,14 @@ SECTION("polygon that is empty") {
|
|||
SECTION("polygon with spike") {
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0,0);
|
||||
ring.add_coord(1,0);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(2,2);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(0,1);
|
||||
ring.add_coord(0,0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(1,0);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(2,2);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(0,1);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
CHECK( !mapnik::geometry::is_valid(poly) );
|
||||
std::string message;
|
||||
CHECK( !mapnik::geometry::is_valid(poly, message) );
|
||||
|
@ -327,19 +327,19 @@ SECTION("polygon with spike") {
|
|||
SECTION("polygon with hole") {
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0,0);
|
||||
ring.add_coord(3,0);
|
||||
ring.add_coord(3,3);
|
||||
ring.add_coord(0,3);
|
||||
ring.add_coord(0,0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(3,0);
|
||||
ring.emplace_back(3,3);
|
||||
ring.emplace_back(0,3);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
mapnik::geometry::linear_ring<double> hole;
|
||||
hole.add_coord(1,1);
|
||||
hole.add_coord(1,2);
|
||||
hole.add_coord(2,2);
|
||||
hole.add_coord(2,1);
|
||||
hole.add_coord(1,1);
|
||||
poly.add_hole(std::move(hole));
|
||||
hole.emplace_back(1,1);
|
||||
hole.emplace_back(1,2);
|
||||
hole.emplace_back(2,2);
|
||||
hole.emplace_back(2,1);
|
||||
hole.emplace_back(1,1);
|
||||
poly.push_back(std::move(hole));
|
||||
CHECK( mapnik::geometry::is_valid(poly) );
|
||||
std::string message;
|
||||
CHECK( mapnik::geometry::is_valid(poly, message) );
|
||||
|
@ -352,14 +352,14 @@ SECTION("polygon with hole") {
|
|||
SECTION("polygon with empty hole") {
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0,0);
|
||||
ring.add_coord(3,0);
|
||||
ring.add_coord(3,3);
|
||||
ring.add_coord(0,3);
|
||||
ring.add_coord(0,0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(3,0);
|
||||
ring.emplace_back(3,3);
|
||||
ring.emplace_back(0,3);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
mapnik::geometry::linear_ring<double> hole;
|
||||
poly.add_hole(std::move(hole));
|
||||
poly.push_back(std::move(hole));
|
||||
CHECK( !mapnik::geometry::is_valid(poly) );
|
||||
std::string message;
|
||||
CHECK( !mapnik::geometry::is_valid(poly, message) );
|
||||
|
@ -373,19 +373,19 @@ SECTION("polygon with empty hole") {
|
|||
SECTION("polygon with hole with invalid winding order") {
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0,0);
|
||||
ring.add_coord(3,0);
|
||||
ring.add_coord(3,3);
|
||||
ring.add_coord(0,3);
|
||||
ring.add_coord(0,0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(3,0);
|
||||
ring.emplace_back(3,3);
|
||||
ring.emplace_back(0,3);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
mapnik::geometry::linear_ring<double> hole;
|
||||
hole.add_coord(1,1);
|
||||
hole.add_coord(2,1);
|
||||
hole.add_coord(2,2);
|
||||
hole.add_coord(1,2);
|
||||
hole.add_coord(1,1);
|
||||
poly.add_hole(std::move(hole));
|
||||
hole.emplace_back(1,1);
|
||||
hole.emplace_back(2,1);
|
||||
hole.emplace_back(2,2);
|
||||
hole.emplace_back(1,2);
|
||||
hole.emplace_back(1,1);
|
||||
poly.push_back(std::move(hole));
|
||||
CHECK( !mapnik::geometry::is_valid(poly) );
|
||||
std::string message;
|
||||
CHECK( !mapnik::geometry::is_valid(poly, message) );
|
||||
|
@ -399,20 +399,20 @@ SECTION("multi polygon") {
|
|||
mapnik::geometry::multi_polygon<double> mp;
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0,0);
|
||||
ring.add_coord(1,0);
|
||||
ring.add_coord(1,1);
|
||||
ring.add_coord(0,1);
|
||||
ring.add_coord(0,0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(1,0);
|
||||
ring.emplace_back(1,1);
|
||||
ring.emplace_back(0,1);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
mapnik::geometry::polygon<double> poly2;
|
||||
mapnik::geometry::linear_ring<double> ring2;
|
||||
ring2.add_coord(0,0);
|
||||
ring2.add_coord(-1,0);
|
||||
ring2.add_coord(-1,-1);
|
||||
ring2.add_coord(0,-1);
|
||||
ring2.add_coord(0,0);
|
||||
poly2.set_exterior_ring(std::move(ring2));
|
||||
ring2.emplace_back(0,0);
|
||||
ring2.emplace_back(-1,0);
|
||||
ring2.emplace_back(-1,-1);
|
||||
ring2.emplace_back(0,-1);
|
||||
ring2.emplace_back(0,0);
|
||||
poly2.push_back(std::move(ring2));
|
||||
mp.emplace_back(poly);
|
||||
mp.emplace_back(poly2);
|
||||
CHECK( mapnik::geometry::is_valid(mp) );
|
||||
|
@ -428,34 +428,34 @@ SECTION("multi polygon with hole") {
|
|||
mapnik::geometry::multi_polygon<double> mp;
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0,0);
|
||||
ring.add_coord(3,0);
|
||||
ring.add_coord(3,3);
|
||||
ring.add_coord(0,3);
|
||||
ring.add_coord(0,0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0,0);
|
||||
ring.emplace_back(3,0);
|
||||
ring.emplace_back(3,3);
|
||||
ring.emplace_back(0,3);
|
||||
ring.emplace_back(0,0);
|
||||
poly.push_back(std::move(ring));
|
||||
mapnik::geometry::linear_ring<double> hole;
|
||||
hole.add_coord(1,1);
|
||||
hole.add_coord(1,2);
|
||||
hole.add_coord(2,2);
|
||||
hole.add_coord(2,1);
|
||||
hole.add_coord(1,1);
|
||||
poly.add_hole(std::move(hole));
|
||||
hole.emplace_back(1,1);
|
||||
hole.emplace_back(1,2);
|
||||
hole.emplace_back(2,2);
|
||||
hole.emplace_back(2,1);
|
||||
hole.emplace_back(1,1);
|
||||
poly.push_back(std::move(hole));
|
||||
mapnik::geometry::polygon<double> poly2;
|
||||
mapnik::geometry::linear_ring<double> ring2;
|
||||
ring2.add_coord(0,0);
|
||||
ring2.add_coord(-3,0);
|
||||
ring2.add_coord(-3,-3);
|
||||
ring2.add_coord(0,-3);
|
||||
ring2.add_coord(0,0);
|
||||
poly2.set_exterior_ring(std::move(ring2));
|
||||
ring2.emplace_back(0,0);
|
||||
ring2.emplace_back(-3,0);
|
||||
ring2.emplace_back(-3,-3);
|
||||
ring2.emplace_back(0,-3);
|
||||
ring2.emplace_back(0,0);
|
||||
poly2.push_back(std::move(ring2));
|
||||
mapnik::geometry::linear_ring<double> hole2;
|
||||
hole2.add_coord(-1,-1);
|
||||
hole2.add_coord(-1,-2);
|
||||
hole2.add_coord(-2,-2);
|
||||
hole2.add_coord(-2,-1);
|
||||
hole2.add_coord(-1,-1);
|
||||
poly2.add_hole(std::move(hole2));
|
||||
hole2.emplace_back(-1,-1);
|
||||
hole2.emplace_back(-1,-2);
|
||||
hole2.emplace_back(-2,-2);
|
||||
hole2.emplace_back(-2,-1);
|
||||
hole2.emplace_back(-1,-1);
|
||||
poly2.push_back(std::move(hole2));
|
||||
mp.emplace_back(poly);
|
||||
mp.emplace_back(poly2);
|
||||
CHECK( mapnik::geometry::is_valid(mp) );
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include "catch.hpp"
|
||||
#include "geometry_equal.hpp"
|
||||
|
||||
|
@ -16,10 +15,10 @@ SECTION("test_projection_4326_3857 - Empty Geometry Object") {
|
|||
mapnik::projection dest("+init=epsg:3857");
|
||||
mapnik::proj_transform proj_trans(source, dest);
|
||||
{
|
||||
geometry_empty geom;
|
||||
geometry_empty<double> geom;
|
||||
unsigned int err = 0;
|
||||
// Test Standard Transform
|
||||
geometry_empty new_geom = reproject_copy(geom, proj_trans, err);
|
||||
geometry_empty<double> new_geom = reproject_copy(geom, proj_trans, err);
|
||||
REQUIRE(err == 0);
|
||||
// Transform providing projections not transfrom
|
||||
new_geom = reproject_copy(geom, source, dest, err);
|
||||
|
@ -42,20 +41,20 @@ SECTION("test_projection_4326_3857 - Empty Geometry in Geometry Variant") {
|
|||
mapnik::projection dest("+init=epsg:3857");
|
||||
mapnik::proj_transform proj_trans(source, dest);
|
||||
{
|
||||
geometry<double> geom = geometry_empty();
|
||||
geometry<double> geom = geometry_empty<double>();
|
||||
unsigned int err = 0;
|
||||
// Test Standard Transform
|
||||
geometry<double> new_geom = reproject_copy(geom, proj_trans, err);
|
||||
REQUIRE(err == 0);
|
||||
REQUIRE(new_geom.is<geometry_empty>());
|
||||
REQUIRE(new_geom.is<geometry_empty<double>>());
|
||||
// Transform providing projections not transfrom
|
||||
new_geom = reproject_copy(geom, source, dest, err);
|
||||
REQUIRE(err == 0);
|
||||
REQUIRE(new_geom.is<geometry_empty>());
|
||||
REQUIRE(new_geom.is<geometry_empty<double>>());
|
||||
// Transform providing projections in reverse
|
||||
new_geom = reproject_copy(geom, dest, source, err);
|
||||
REQUIRE(err == 0);
|
||||
REQUIRE(new_geom.is<geometry_empty>());
|
||||
REQUIRE(new_geom.is<geometry_empty<double>>());
|
||||
// Transform in place
|
||||
REQUIRE(reproject(new_geom, proj_trans));
|
||||
// Transform in place providing projections
|
||||
|
@ -269,7 +268,7 @@ SECTION("test_projection_4326_3857 - Line_String Geometry Variant Object") {
|
|||
// Reprojecting empty line string will return a geometry_empty
|
||||
geometry<double> new_geom = reproject_copy(geom0, proj_trans1, err);
|
||||
REQUIRE(err == 0);
|
||||
REQUIRE(new_geom.is<geometry_empty>());
|
||||
REQUIRE(new_geom.is<geometry_empty<double>>());
|
||||
}
|
||||
{
|
||||
// Test Standard Transform
|
||||
|
@ -322,43 +321,49 @@ SECTION("test_projection_4326_3857 - Polygon Geometry Object") {
|
|||
mapnik::proj_transform proj_trans1(source, dest);
|
||||
mapnik::proj_transform proj_trans2(dest, source);
|
||||
polygon<double> geom1;
|
||||
geom1.exterior_ring.emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
geom1.exterior_ring.emplace_back(point<double>(-97.79067993164062, 35.43941441533686));
|
||||
geom1.exterior_ring.emplace_back(point<double>(-97.60391235351562, 35.34425514918409));
|
||||
geom1.exterior_ring.emplace_back(point<double>(-97.42813110351562, 35.48191987272801));
|
||||
geom1.exterior_ring.emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
geom1.interior_rings.emplace_back();
|
||||
geom1.interior_rings.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
geom1.interior_rings.back().emplace_back(point<double>(-97.61489868164062, 35.54116627999813));
|
||||
geom1.interior_rings.back().emplace_back(point<double>(-97.53799438476562, 35.459551379037606));
|
||||
geom1.interior_rings.back().emplace_back(point<double>(-97.62451171875, 35.42598697382711));
|
||||
geom1.interior_rings.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
// exterior
|
||||
geom1.emplace_back();
|
||||
geom1.back().emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
geom1.back().emplace_back(point<double>(-97.79067993164062, 35.43941441533686));
|
||||
geom1.back().emplace_back(point<double>(-97.60391235351562, 35.34425514918409));
|
||||
geom1.back().emplace_back(point<double>(-97.42813110351562, 35.48191987272801));
|
||||
geom1.back().emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
// interior
|
||||
geom1.emplace_back();
|
||||
geom1.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
geom1.back().emplace_back(point<double>(-97.61489868164062, 35.54116627999813));
|
||||
geom1.back().emplace_back(point<double>(-97.53799438476562, 35.459551379037606));
|
||||
geom1.back().emplace_back(point<double>(-97.62451171875, 35.42598697382711));
|
||||
geom1.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
polygon<double> geom2;
|
||||
geom2.exterior_ring.emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
geom2.exterior_ring.emplace_back(point<double>(-10886008.694318, 4223757.308982));
|
||||
geom2.exterior_ring.emplace_back(point<double>(-10865217.822625, 4210763.014174));
|
||||
geom2.exterior_ring.emplace_back(point<double>(-10845649.943384, 4229566.523132));
|
||||
geom2.exterior_ring.emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
geom2.interior_rings.emplace_back();
|
||||
geom2.interior_rings.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
geom2.interior_rings.back().emplace_back(point<double>(-10866440.815077, 4237668.848130));
|
||||
geom2.interior_rings.back().emplace_back(point<double>(-10857879.867909, 4226509.042001));
|
||||
geom2.interior_rings.back().emplace_back(point<double>(-10867510.933473, 4221922.820303));
|
||||
geom2.interior_rings.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
// interior
|
||||
geom2.emplace_back();
|
||||
geom2.back().emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
geom2.back().emplace_back(point<double>(-10886008.694318, 4223757.308982));
|
||||
geom2.back().emplace_back(point<double>(-10865217.822625, 4210763.014174));
|
||||
geom2.back().emplace_back(point<double>(-10845649.943384, 4229566.523132));
|
||||
geom2.back().emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
// exterior
|
||||
geom2.emplace_back();
|
||||
geom2.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
geom2.back().emplace_back(point<double>(-10866440.815077, 4237668.848130));
|
||||
geom2.back().emplace_back(point<double>(-10857879.867909, 4226509.042001));
|
||||
geom2.back().emplace_back(point<double>(-10867510.933473, 4221922.820303));
|
||||
geom2.back().emplace_back(point<double>(-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);
|
||||
geom1.emplace_back();
|
||||
REQUIRE(geom1.size() == 3);
|
||||
polygon<double> 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);
|
||||
REQUIRE(new_geom.size() == 2);
|
||||
assert_g_equal(new_geom, geom2);
|
||||
// Remove extra ring for future validity tests.
|
||||
geom1.interior_rings.pop_back();
|
||||
REQUIRE(geom1.interior_rings.size() == 1);
|
||||
geom1.pop_back();
|
||||
REQUIRE(geom1.size() == 2);
|
||||
}
|
||||
{
|
||||
// Transform in reverse
|
||||
|
@ -381,13 +386,13 @@ SECTION("test_projection_4326_3857 - Polygon Geometry Object") {
|
|||
{
|
||||
// Transform in place
|
||||
polygon<double> geom3(geom1);
|
||||
geom3.interior_rings.emplace_back();
|
||||
geom3.emplace_back();
|
||||
REQUIRE(reproject(geom3, proj_trans1));
|
||||
// Should NOT remove the empty ring added to back of geom1
|
||||
REQUIRE(geom3.interior_rings.size() == 2);
|
||||
REQUIRE(geom3.size() == 3);
|
||||
// Remove so asserts that geometries are the same
|
||||
geom3.interior_rings.pop_back();
|
||||
REQUIRE(geom3.interior_rings.size() == 1);
|
||||
geom3.pop_back();
|
||||
REQUIRE(geom3.size() == 2);
|
||||
assert_g_equal(geom3, geom2);
|
||||
// Transform in place reverse
|
||||
REQUIRE(reproject(geom3, proj_trans2));
|
||||
|
@ -411,29 +416,36 @@ SECTION("test_projection_4326_3857 - Polygon Geometry Variant Object") {
|
|||
mapnik::proj_transform proj_trans1(source, dest);
|
||||
mapnik::proj_transform proj_trans2(dest, source);
|
||||
polygon<double> geom1_;
|
||||
geom1_.exterior_ring.emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
geom1_.exterior_ring.emplace_back(point<double>(-97.79067993164062, 35.43941441533686));
|
||||
geom1_.exterior_ring.emplace_back(point<double>(-97.60391235351562, 35.34425514918409));
|
||||
geom1_.exterior_ring.emplace_back(point<double>(-97.42813110351562, 35.48191987272801));
|
||||
geom1_.exterior_ring.emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
geom1_.interior_rings.emplace_back();
|
||||
geom1_.interior_rings.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
geom1_.interior_rings.back().emplace_back(point<double>(-97.61489868164062, 35.54116627999813));
|
||||
geom1_.interior_rings.back().emplace_back(point<double>(-97.53799438476562, 35.459551379037606));
|
||||
geom1_.interior_rings.back().emplace_back(point<double>(-97.62451171875, 35.42598697382711));
|
||||
geom1_.interior_rings.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
// exterior
|
||||
geom1_.emplace_back();
|
||||
geom1_.back().emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
geom1_.back().emplace_back(point<double>(-97.79067993164062, 35.43941441533686));
|
||||
geom1_.back().emplace_back(point<double>(-97.60391235351562, 35.34425514918409));
|
||||
geom1_.back().emplace_back(point<double>(-97.42813110351562, 35.48191987272801));
|
||||
geom1_.back().emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
// interior
|
||||
geom1_.emplace_back();
|
||||
geom1_.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
geom1_.back().emplace_back(point<double>(-97.61489868164062, 35.54116627999813));
|
||||
geom1_.back().emplace_back(point<double>(-97.53799438476562, 35.459551379037606));
|
||||
geom1_.back().emplace_back(point<double>(-97.62451171875, 35.42598697382711));
|
||||
geom1_.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
|
||||
polygon<double> geom2_;
|
||||
geom2_.exterior_ring.emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
geom2_.exterior_ring.emplace_back(point<double>(-10886008.694318, 4223757.308982));
|
||||
geom2_.exterior_ring.emplace_back(point<double>(-10865217.822625, 4210763.014174));
|
||||
geom2_.exterior_ring.emplace_back(point<double>(-10845649.943384, 4229566.523132));
|
||||
geom2_.exterior_ring.emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
geom2_.interior_rings.emplace_back();
|
||||
geom2_.interior_rings.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
geom2_.interior_rings.back().emplace_back(point<double>(-10866440.815077, 4237668.848130));
|
||||
geom2_.interior_rings.back().emplace_back(point<double>(-10857879.867909, 4226509.042001));
|
||||
geom2_.interior_rings.back().emplace_back(point<double>(-10867510.933473, 4221922.820303));
|
||||
geom2_.interior_rings.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
// exterior
|
||||
geom2_.emplace_back();
|
||||
geom2_.back().emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
geom2_.back().emplace_back(point<double>(-10886008.694318, 4223757.308982));
|
||||
geom2_.back().emplace_back(point<double>(-10865217.822625, 4210763.014174));
|
||||
geom2_.back().emplace_back(point<double>(-10845649.943384, 4229566.523132));
|
||||
geom2_.back().emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
// interior
|
||||
geom2_.emplace_back();
|
||||
geom2_.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
geom2_.back().emplace_back(point<double>(-10866440.815077, 4237668.848130));
|
||||
geom2_.back().emplace_back(point<double>(-10857879.867909, 4226509.042001));
|
||||
geom2_.back().emplace_back(point<double>(-10867510.933473, 4221922.820303));
|
||||
geom2_.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
polygon<double> geom0_;
|
||||
geometry<double> geom0(geom0_);
|
||||
geometry<double> geom1(geom1_);
|
||||
|
@ -443,7 +455,7 @@ SECTION("test_projection_4326_3857 - Polygon Geometry Variant Object") {
|
|||
// Reprojecting empty poly will return a geometry_empty
|
||||
geometry<double> new_geom = reproject_copy(geom0, proj_trans1, err);
|
||||
REQUIRE(err == 0);
|
||||
REQUIRE(new_geom.is<geometry_empty>());
|
||||
REQUIRE(new_geom.is<geometry_empty<double>>());
|
||||
}
|
||||
{
|
||||
// Test Standard Transform
|
||||
|
@ -583,7 +595,7 @@ SECTION("test_projection_4326_3857 - Multi_Point Geometry Variant Object") {
|
|||
// Reprojecting empty multi point will return a geometry_empty
|
||||
geometry<double> new_geom = reproject_copy(geom0, proj_trans1, err);
|
||||
REQUIRE(err == 0);
|
||||
REQUIRE(new_geom.is<geometry_empty>());
|
||||
REQUIRE(new_geom.is<geometry_empty<double>>());
|
||||
}
|
||||
{
|
||||
// Test Standard Transform
|
||||
|
@ -739,7 +751,7 @@ SECTION("test_projection_4326_3857 - Multi_Line_String Geometry Variant Object")
|
|||
// Reprojecting empty line string will return a geometry_empty
|
||||
geometry<double> new_geom = reproject_copy(geom0, proj_trans1, err);
|
||||
REQUIRE(err == 0);
|
||||
REQUIRE(new_geom.is<geometry_empty>());
|
||||
REQUIRE(new_geom.is<geometry_empty<double>>());
|
||||
}
|
||||
{
|
||||
// Test Standard Transform
|
||||
|
@ -792,31 +804,37 @@ SECTION("test_projection_4326_3857 - Multi_Polygon Geometry Object") {
|
|||
mapnik::proj_transform proj_trans1(source, dest);
|
||||
mapnik::proj_transform proj_trans2(dest, source);
|
||||
polygon<double> geom1a;
|
||||
geom1a.exterior_ring.emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
geom1a.exterior_ring.emplace_back(point<double>(-97.79067993164062, 35.43941441533686));
|
||||
geom1a.exterior_ring.emplace_back(point<double>(-97.60391235351562, 35.34425514918409));
|
||||
geom1a.exterior_ring.emplace_back(point<double>(-97.42813110351562, 35.48191987272801));
|
||||
geom1a.exterior_ring.emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
geom1a.interior_rings.emplace_back();
|
||||
geom1a.interior_rings.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
geom1a.interior_rings.back().emplace_back(point<double>(-97.61489868164062, 35.54116627999813));
|
||||
geom1a.interior_rings.back().emplace_back(point<double>(-97.53799438476562, 35.459551379037606));
|
||||
geom1a.interior_rings.back().emplace_back(point<double>(-97.62451171875, 35.42598697382711));
|
||||
geom1a.interior_rings.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
// exterior
|
||||
geom1a.emplace_back();
|
||||
geom1a.back().emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
geom1a.back().emplace_back(point<double>(-97.79067993164062, 35.43941441533686));
|
||||
geom1a.back().emplace_back(point<double>(-97.60391235351562, 35.34425514918409));
|
||||
geom1a.back().emplace_back(point<double>(-97.42813110351562, 35.48191987272801));
|
||||
geom1a.back().emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
// interior
|
||||
geom1a.emplace_back();
|
||||
geom1a.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
geom1a.back().emplace_back(point<double>(-97.61489868164062, 35.54116627999813));
|
||||
geom1a.back().emplace_back(point<double>(-97.53799438476562, 35.459551379037606));
|
||||
geom1a.back().emplace_back(point<double>(-97.62451171875, 35.42598697382711));
|
||||
geom1a.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
multi_polygon<double> geom1;
|
||||
geom1.emplace_back(geom1a);
|
||||
polygon<double> geom2a;
|
||||
geom2a.exterior_ring.emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
geom2a.exterior_ring.emplace_back(point<double>(-10886008.694318, 4223757.308982));
|
||||
geom2a.exterior_ring.emplace_back(point<double>(-10865217.822625, 4210763.014174));
|
||||
geom2a.exterior_ring.emplace_back(point<double>(-10845649.943384, 4229566.523132));
|
||||
geom2a.exterior_ring.emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
geom2a.interior_rings.emplace_back();
|
||||
geom2a.interior_rings.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
geom2a.interior_rings.back().emplace_back(point<double>(-10866440.815077, 4237668.848130));
|
||||
geom2a.interior_rings.back().emplace_back(point<double>(-10857879.867909, 4226509.042001));
|
||||
geom2a.interior_rings.back().emplace_back(point<double>(-10867510.933473, 4221922.820303));
|
||||
geom2a.interior_rings.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
// exterior
|
||||
geom2a.emplace_back();
|
||||
geom2a.back().emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
geom2a.back().emplace_back(point<double>(-10886008.694318, 4223757.308982));
|
||||
geom2a.back().emplace_back(point<double>(-10865217.822625, 4210763.014174));
|
||||
geom2a.back().emplace_back(point<double>(-10845649.943384, 4229566.523132));
|
||||
geom2a.back().emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
// interior
|
||||
geom2a.emplace_back();
|
||||
geom2a.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
geom2a.back().emplace_back(point<double>(-10866440.815077, 4237668.848130));
|
||||
geom2a.back().emplace_back(point<double>(-10857879.867909, 4226509.042001));
|
||||
geom2a.back().emplace_back(point<double>(-10867510.933473, 4221922.820303));
|
||||
geom2a.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
multi_polygon<double> geom2;
|
||||
geom2.emplace_back(geom2a);
|
||||
unsigned int err = 0;
|
||||
|
@ -885,31 +903,37 @@ SECTION("test_projection_4326_3857 - Multi_Polygon Geometry Variant Object") {
|
|||
mapnik::proj_transform proj_trans1(source, dest);
|
||||
mapnik::proj_transform proj_trans2(dest, source);
|
||||
polygon<double> geom1a_;
|
||||
geom1a_.exterior_ring.emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
geom1a_.exterior_ring.emplace_back(point<double>(-97.79067993164062, 35.43941441533686));
|
||||
geom1a_.exterior_ring.emplace_back(point<double>(-97.60391235351562, 35.34425514918409));
|
||||
geom1a_.exterior_ring.emplace_back(point<double>(-97.42813110351562, 35.48191987272801));
|
||||
geom1a_.exterior_ring.emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
geom1a_.interior_rings.emplace_back();
|
||||
geom1a_.interior_rings.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
geom1a_.interior_rings.back().emplace_back(point<double>(-97.61489868164062, 35.54116627999813));
|
||||
geom1a_.interior_rings.back().emplace_back(point<double>(-97.53799438476562, 35.459551379037606));
|
||||
geom1a_.interior_rings.back().emplace_back(point<double>(-97.62451171875, 35.42598697382711));
|
||||
geom1a_.interior_rings.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
// exterior
|
||||
geom1a_.emplace_back();
|
||||
geom1a_.back().emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
geom1a_.back().emplace_back(point<double>(-97.79067993164062, 35.43941441533686));
|
||||
geom1a_.back().emplace_back(point<double>(-97.60391235351562, 35.34425514918409));
|
||||
geom1a_.back().emplace_back(point<double>(-97.42813110351562, 35.48191987272801));
|
||||
geom1a_.back().emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
// interior
|
||||
geom1a_.emplace_back();
|
||||
geom1a_.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
geom1a_.back().emplace_back(point<double>(-97.61489868164062, 35.54116627999813));
|
||||
geom1a_.back().emplace_back(point<double>(-97.53799438476562, 35.459551379037606));
|
||||
geom1a_.back().emplace_back(point<double>(-97.62451171875, 35.42598697382711));
|
||||
geom1a_.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
multi_polygon<double> geom1_;
|
||||
geom1_.emplace_back(geom1a_);
|
||||
polygon<double> geom2a_;
|
||||
geom2a_.exterior_ring.emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
geom2a_.exterior_ring.emplace_back(point<double>(-10886008.694318, 4223757.308982));
|
||||
geom2a_.exterior_ring.emplace_back(point<double>(-10865217.822625, 4210763.014174));
|
||||
geom2a_.exterior_ring.emplace_back(point<double>(-10845649.943384, 4229566.523132));
|
||||
geom2a_.exterior_ring.emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
geom2a_.interior_rings.emplace_back();
|
||||
geom2a_.interior_rings.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
geom2a_.interior_rings.back().emplace_back(point<double>(-10866440.815077, 4237668.848130));
|
||||
geom2a_.interior_rings.back().emplace_back(point<double>(-10857879.867909, 4226509.042001));
|
||||
geom2a_.interior_rings.back().emplace_back(point<double>(-10867510.933473, 4221922.820303));
|
||||
geom2a_.interior_rings.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
// exterior
|
||||
geom2a_.emplace_back();
|
||||
geom2a_.back().emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
geom2a_.back().emplace_back(point<double>(-10886008.694318, 4223757.308982));
|
||||
geom2a_.back().emplace_back(point<double>(-10865217.822625, 4210763.014174));
|
||||
geom2a_.back().emplace_back(point<double>(-10845649.943384, 4229566.523132));
|
||||
geom2a_.back().emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
// interior
|
||||
geom2a_.emplace_back();
|
||||
geom2a_.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
geom2a_.back().emplace_back(point<double>(-10866440.815077, 4237668.848130));
|
||||
geom2a_.back().emplace_back(point<double>(-10857879.867909, 4226509.042001));
|
||||
geom2a_.back().emplace_back(point<double>(-10867510.933473, 4221922.820303));
|
||||
geom2a_.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
multi_polygon<double> geom2_;
|
||||
geom2_.emplace_back(geom2a_);
|
||||
multi_polygon<double> geom0_;
|
||||
|
@ -921,7 +945,7 @@ SECTION("test_projection_4326_3857 - Multi_Polygon Geometry Variant Object") {
|
|||
// Reprojecting empty poly will return a geometry_empty
|
||||
geometry<double> new_geom = reproject_copy(geom0, proj_trans1, err);
|
||||
REQUIRE(err == 0);
|
||||
REQUIRE(new_geom.is<geometry_empty>());
|
||||
REQUIRE(new_geom.is<geometry_empty<double>>());
|
||||
}
|
||||
{
|
||||
// Test Standard Transform
|
||||
|
@ -974,31 +998,37 @@ SECTION("test_projection_4326_3857 - Geometry Collection Object") {
|
|||
mapnik::proj_transform proj_trans1(source, dest);
|
||||
mapnik::proj_transform proj_trans2(dest, source);
|
||||
polygon<double> geom1a;
|
||||
geom1a.exterior_ring.emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
geom1a.exterior_ring.emplace_back(point<double>(-97.79067993164062, 35.43941441533686));
|
||||
geom1a.exterior_ring.emplace_back(point<double>(-97.60391235351562, 35.34425514918409));
|
||||
geom1a.exterior_ring.emplace_back(point<double>(-97.42813110351562, 35.48191987272801));
|
||||
geom1a.exterior_ring.emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
geom1a.interior_rings.emplace_back();
|
||||
geom1a.interior_rings.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
geom1a.interior_rings.back().emplace_back(point<double>(-97.61489868164062, 35.54116627999813));
|
||||
geom1a.interior_rings.back().emplace_back(point<double>(-97.53799438476562, 35.459551379037606));
|
||||
geom1a.interior_rings.back().emplace_back(point<double>(-97.62451171875, 35.42598697382711));
|
||||
geom1a.interior_rings.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
// exterior
|
||||
geom1a.emplace_back();
|
||||
geom1a.back().emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
geom1a.back().emplace_back(point<double>(-97.79067993164062, 35.43941441533686));
|
||||
geom1a.back().emplace_back(point<double>(-97.60391235351562, 35.34425514918409));
|
||||
geom1a.back().emplace_back(point<double>(-97.42813110351562, 35.48191987272801));
|
||||
geom1a.back().emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
// interior
|
||||
geom1a.emplace_back();
|
||||
geom1a.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
geom1a.back().emplace_back(point<double>(-97.61489868164062, 35.54116627999813));
|
||||
geom1a.back().emplace_back(point<double>(-97.53799438476562, 35.459551379037606));
|
||||
geom1a.back().emplace_back(point<double>(-97.62451171875, 35.42598697382711));
|
||||
geom1a.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
geometry_collection<double> geom1;
|
||||
geom1.emplace_back(geometry<double>(geom1a));
|
||||
polygon<double> geom2a;
|
||||
geom2a.exterior_ring.emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
geom2a.exterior_ring.emplace_back(point<double>(-10886008.694318, 4223757.308982));
|
||||
geom2a.exterior_ring.emplace_back(point<double>(-10865217.822625, 4210763.014174));
|
||||
geom2a.exterior_ring.emplace_back(point<double>(-10845649.943384, 4229566.523132));
|
||||
geom2a.exterior_ring.emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
geom2a.interior_rings.emplace_back();
|
||||
geom2a.interior_rings.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
geom2a.interior_rings.back().emplace_back(point<double>(-10866440.815077, 4237668.848130));
|
||||
geom2a.interior_rings.back().emplace_back(point<double>(-10857879.867909, 4226509.042001));
|
||||
geom2a.interior_rings.back().emplace_back(point<double>(-10867510.933473, 4221922.820303));
|
||||
geom2a.interior_rings.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
// exerior
|
||||
geom2a.emplace_back();
|
||||
geom2a.back().emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
geom2a.back().emplace_back(point<double>(-10886008.694318, 4223757.308982));
|
||||
geom2a.back().emplace_back(point<double>(-10865217.822625, 4210763.014174));
|
||||
geom2a.back().emplace_back(point<double>(-10845649.943384, 4229566.523132));
|
||||
geom2a.back().emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
// interior
|
||||
geom2a.emplace_back();
|
||||
geom2a.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
geom2a.back().emplace_back(point<double>(-10866440.815077, 4237668.848130));
|
||||
geom2a.back().emplace_back(point<double>(-10857879.867909, 4226509.042001));
|
||||
geom2a.back().emplace_back(point<double>(-10867510.933473, 4221922.820303));
|
||||
geom2a.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
geometry_collection<double> geom2;
|
||||
geom2.emplace_back(geometry<double>(geom2a));
|
||||
unsigned int err = 0;
|
||||
|
@ -1067,31 +1097,37 @@ SECTION("test_projection_4326_3857 - Geometry Collection Variant Object") {
|
|||
mapnik::proj_transform proj_trans1(source, dest);
|
||||
mapnik::proj_transform proj_trans2(dest, source);
|
||||
polygon<double> geom1a_;
|
||||
geom1a_.exterior_ring.emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
geom1a_.exterior_ring.emplace_back(point<double>(-97.79067993164062, 35.43941441533686));
|
||||
geom1a_.exterior_ring.emplace_back(point<double>(-97.60391235351562, 35.34425514918409));
|
||||
geom1a_.exterior_ring.emplace_back(point<double>(-97.42813110351562, 35.48191987272801));
|
||||
geom1a_.exterior_ring.emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
geom1a_.interior_rings.emplace_back();
|
||||
geom1a_.interior_rings.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
geom1a_.interior_rings.back().emplace_back(point<double>(-97.61489868164062, 35.54116627999813));
|
||||
geom1a_.interior_rings.back().emplace_back(point<double>(-97.53799438476562, 35.459551379037606));
|
||||
geom1a_.interior_rings.back().emplace_back(point<double>(-97.62451171875, 35.42598697382711));
|
||||
geom1a_.interior_rings.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
// exterior
|
||||
geom1a_.emplace_back();
|
||||
geom1a_.back().emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
geom1a_.back().emplace_back(point<double>(-97.79067993164062, 35.43941441533686));
|
||||
geom1a_.back().emplace_back(point<double>(-97.60391235351562, 35.34425514918409));
|
||||
geom1a_.back().emplace_back(point<double>(-97.42813110351562, 35.48191987272801));
|
||||
geom1a_.back().emplace_back(point<double>(-97.62588500976562, 35.62939577711732));
|
||||
// interior
|
||||
geom1a_.emplace_back();
|
||||
geom1a_.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
geom1a_.back().emplace_back(point<double>(-97.61489868164062, 35.54116627999813));
|
||||
geom1a_.back().emplace_back(point<double>(-97.53799438476562, 35.459551379037606));
|
||||
geom1a_.back().emplace_back(point<double>(-97.62451171875, 35.42598697382711));
|
||||
geom1a_.back().emplace_back(point<double>(-97.66571044921875, 35.46849952318069));
|
||||
geometry_collection<double> geom1_;
|
||||
geom1_.emplace_back(geometry<double>(geom1a_));
|
||||
polygon<double> geom2a_;
|
||||
geom2a_.exterior_ring.emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
geom2a_.exterior_ring.emplace_back(point<double>(-10886008.694318, 4223757.308982));
|
||||
geom2a_.exterior_ring.emplace_back(point<double>(-10865217.822625, 4210763.014174));
|
||||
geom2a_.exterior_ring.emplace_back(point<double>(-10845649.943384, 4229566.523132));
|
||||
geom2a_.exterior_ring.emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
geom2a_.interior_rings.emplace_back();
|
||||
geom2a_.interior_rings.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
geom2a_.interior_rings.back().emplace_back(point<double>(-10866440.815077, 4237668.848130));
|
||||
geom2a_.interior_rings.back().emplace_back(point<double>(-10857879.867909, 4226509.042001));
|
||||
geom2a_.interior_rings.back().emplace_back(point<double>(-10867510.933473, 4221922.820303));
|
||||
geom2a_.interior_rings.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
// exterior
|
||||
geom2a_.emplace_back();
|
||||
geom2a_.back().emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
geom2a_.back().emplace_back(point<double>(-10886008.694318, 4223757.308982));
|
||||
geom2a_.back().emplace_back(point<double>(-10865217.822625, 4210763.014174));
|
||||
geom2a_.back().emplace_back(point<double>(-10845649.943384, 4229566.523132));
|
||||
geom2a_.back().emplace_back(point<double>(-10867663.807530, 4249745.898599));
|
||||
// interior
|
||||
geom2a_.emplace_back();
|
||||
geom2a_.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
geom2a_.back().emplace_back(point<double>(-10866440.815077, 4237668.848130));
|
||||
geom2a_.back().emplace_back(point<double>(-10857879.867909, 4226509.042001));
|
||||
geom2a_.back().emplace_back(point<double>(-10867510.933473, 4221922.820303));
|
||||
geom2a_.back().emplace_back(point<double>(-10872097.155170, 4227732.034453));
|
||||
geometry_collection<double> geom2_;
|
||||
geom2_.emplace_back(geometry<double>(geom2a_));
|
||||
multi_polygon<double> geom0_;
|
||||
|
@ -1103,7 +1139,7 @@ SECTION("test_projection_4326_3857 - Geometry Collection Variant Object") {
|
|||
// Reprojecting empty poly will return a geometry_empty
|
||||
geometry<double> new_geom = reproject_copy(geom0, proj_trans1, err);
|
||||
REQUIRE(err == 0);
|
||||
REQUIRE(new_geom.is<geometry_empty>());
|
||||
REQUIRE(new_geom.is<geometry_empty<double>>());
|
||||
}
|
||||
{
|
||||
// Test Standard Transform
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include "catch.hpp"
|
||||
#include "geometry_equal.hpp"
|
||||
|
||||
|
@ -12,7 +11,6 @@
|
|||
#include <mapnik/view_strategy.hpp>
|
||||
|
||||
TEST_CASE("geometry strategy tests") {
|
||||
|
||||
SECTION("proj and view strategy") {
|
||||
using namespace mapnik::geometry;
|
||||
mapnik::box2d<double> e(-20037508.342789,-20037508.342789,20037508.342789,20037508.342789);
|
||||
|
@ -184,5 +182,4 @@ SECTION("scaling strategies - double to int64") {
|
|||
assert_g_equal(r, o);
|
||||
}
|
||||
} // END SECTION
|
||||
|
||||
} // END TEST CASE
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include "catch.hpp"
|
||||
|
||||
#include <mapnik/geometry_is_empty.hpp>
|
||||
|
@ -7,7 +6,7 @@ TEST_CASE("geometry has_empty") {
|
|||
|
||||
SECTION("empty geometry") {
|
||||
|
||||
mapnik::geometry::geometry_empty geom;
|
||||
mapnik::geometry::geometry_empty<double> geom;
|
||||
REQUIRE(!mapnik::geometry::has_empty(geom));
|
||||
}
|
||||
|
||||
|
@ -19,7 +18,7 @@ SECTION("geometry collection") {
|
|||
}
|
||||
{
|
||||
mapnik::geometry::geometry_collection<double> geom;
|
||||
mapnik::geometry::geometry_empty geom1;
|
||||
mapnik::geometry::geometry_empty<double> geom1;
|
||||
geom.emplace_back(std::move(geom1));
|
||||
REQUIRE(mapnik::geometry::has_empty(geom));
|
||||
}
|
||||
|
@ -35,7 +34,7 @@ SECTION("geometry collection") {
|
|||
mapnik::geometry::geometry_collection<double> geom;
|
||||
mapnik::geometry::multi_line_string<double> mls;
|
||||
mapnik::geometry::line_string<double> line;
|
||||
line.add_coord(0, 0);
|
||||
line.emplace_back(0, 0);
|
||||
mls.emplace_back(std::move(line));
|
||||
geom.emplace_back(std::move(mls));
|
||||
REQUIRE(!mapnik::geometry::has_empty(geom));
|
||||
|
@ -56,9 +55,9 @@ SECTION("linestring") {
|
|||
}
|
||||
{
|
||||
mapnik::geometry::line_string<double> line;
|
||||
line.add_coord(0, 0);
|
||||
line.add_coord(25, 25);
|
||||
line.add_coord(50, 50);
|
||||
line.emplace_back(0, 0);
|
||||
line.emplace_back(25, 25);
|
||||
line.emplace_back(50, 50);
|
||||
REQUIRE(!mapnik::geometry::has_empty(line));
|
||||
}
|
||||
}
|
||||
|
@ -72,18 +71,18 @@ SECTION("polygon") {
|
|||
{
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
poly.push_back(std::move(ring));
|
||||
REQUIRE(!mapnik::geometry::has_empty(poly));
|
||||
}
|
||||
{
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0, 0);
|
||||
ring.add_coord(1, 0);
|
||||
ring.add_coord(1, 1);
|
||||
ring.add_coord(0, 1);
|
||||
ring.add_coord(0, 0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0, 0);
|
||||
ring.emplace_back(1, 0);
|
||||
ring.emplace_back(1, 1);
|
||||
ring.emplace_back(0, 1);
|
||||
ring.emplace_back(0, 0);
|
||||
poly.push_back(std::move(ring));
|
||||
REQUIRE(!mapnik::geometry::has_empty(poly));
|
||||
}
|
||||
}
|
||||
|
@ -96,9 +95,9 @@ SECTION("multi-point") {
|
|||
}
|
||||
{
|
||||
mapnik::geometry::multi_point<double> geom;
|
||||
geom.add_coord(0, 0);
|
||||
geom.add_coord(25, 25);
|
||||
geom.add_coord(50, 50);
|
||||
geom.emplace_back(0, 0);
|
||||
geom.emplace_back(25, 25);
|
||||
geom.emplace_back(50, 50);
|
||||
REQUIRE(!mapnik::geometry::has_empty(geom));
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +117,7 @@ SECTION("multi-linestring") {
|
|||
{
|
||||
mapnik::geometry::multi_line_string<double> geom;
|
||||
mapnik::geometry::line_string<double> line;
|
||||
line.add_coord(0, 0);
|
||||
line.emplace_back(0, 0);
|
||||
geom.emplace_back(std::move(line));
|
||||
REQUIRE(!mapnik::geometry::has_empty(geom));
|
||||
}
|
||||
|
@ -134,7 +133,7 @@ SECTION("multi-polygon") {
|
|||
mapnik::geometry::multi_polygon<double> geom;
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
poly.push_back(std::move(ring));
|
||||
geom.emplace_back(std::move(poly));
|
||||
REQUIRE(mapnik::geometry::has_empty(geom));
|
||||
}
|
||||
|
@ -142,8 +141,8 @@ SECTION("multi-polygon") {
|
|||
mapnik::geometry::multi_polygon<double> geom;
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0, 0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0, 0);
|
||||
poly.push_back(std::move(ring));
|
||||
geom.emplace_back(std::move(poly));
|
||||
REQUIRE(!mapnik::geometry::has_empty(geom));
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include "catch.hpp"
|
||||
|
||||
#include <mapnik/geometry_is_empty.hpp>
|
||||
|
@ -7,7 +6,7 @@ TEST_CASE("geometry is_empty") {
|
|||
|
||||
SECTION("empty geometry") {
|
||||
|
||||
mapnik::geometry::geometry_empty geom;
|
||||
mapnik::geometry::geometry_empty<double> geom;
|
||||
REQUIRE(mapnik::geometry::is_empty(geom));
|
||||
}
|
||||
|
||||
|
@ -19,7 +18,7 @@ SECTION("geometry collection") {
|
|||
}
|
||||
{
|
||||
mapnik::geometry::geometry_collection<double> geom;
|
||||
mapnik::geometry::geometry_empty geom1;
|
||||
mapnik::geometry::geometry_empty<double> geom1;
|
||||
geom.emplace_back(std::move(geom1));
|
||||
REQUIRE(!mapnik::geometry::is_empty(geom));
|
||||
}
|
||||
|
@ -39,9 +38,9 @@ SECTION("linestring") {
|
|||
}
|
||||
{
|
||||
mapnik::geometry::line_string<double> line;
|
||||
line.add_coord(0, 0);
|
||||
line.add_coord(25, 25);
|
||||
line.add_coord(50, 50);
|
||||
line.emplace_back(0, 0);
|
||||
line.emplace_back(25, 25);
|
||||
line.emplace_back(50, 50);
|
||||
REQUIRE(!mapnik::geometry::is_empty(line));
|
||||
}
|
||||
}
|
||||
|
@ -55,18 +54,18 @@ SECTION("polygon") {
|
|||
{
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
poly.push_back(std::move(ring));
|
||||
REQUIRE(mapnik::geometry::is_empty(poly));
|
||||
}
|
||||
{
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0, 0);
|
||||
ring.add_coord(1, 0);
|
||||
ring.add_coord(1, 1);
|
||||
ring.add_coord(0, 1);
|
||||
ring.add_coord(0, 0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0, 0);
|
||||
ring.emplace_back(1, 0);
|
||||
ring.emplace_back(1, 1);
|
||||
ring.emplace_back(0, 1);
|
||||
ring.emplace_back(0, 0);
|
||||
poly.push_back(std::move(ring));
|
||||
REQUIRE(!mapnik::geometry::is_empty(poly));
|
||||
}
|
||||
}
|
||||
|
@ -79,9 +78,9 @@ SECTION("multi-point") {
|
|||
}
|
||||
{
|
||||
mapnik::geometry::multi_point<double> geom;
|
||||
geom.add_coord(0, 0);
|
||||
geom.add_coord(25, 25);
|
||||
geom.add_coord(50, 50);
|
||||
geom.emplace_back(0, 0);
|
||||
geom.emplace_back(25, 25);
|
||||
geom.emplace_back(50, 50);
|
||||
REQUIRE(!mapnik::geometry::is_empty(geom));
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +109,7 @@ SECTION("multi-polygon") {
|
|||
mapnik::geometry::multi_polygon<double> geom;
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
poly.push_back(std::move(ring));
|
||||
geom.emplace_back(std::move(poly));
|
||||
REQUIRE(!mapnik::geometry::is_empty(geom));
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include "catch.hpp"
|
||||
|
||||
#include <mapnik/geometry_remove_empty.hpp>
|
||||
|
@ -19,9 +18,9 @@ SECTION("multi-linestring") {
|
|||
using geom_type = mapnik::geometry::multi_line_string<double>;
|
||||
geom_type geom;
|
||||
mapnik::geometry::line_string<double> line;
|
||||
line.add_coord(0, 0);
|
||||
line.add_coord(0, 25);
|
||||
line.add_coord(0, 50);
|
||||
line.emplace_back(0, 0);
|
||||
line.emplace_back(0, 25);
|
||||
line.emplace_back(0, 50);
|
||||
geom.emplace_back(std::move(line));
|
||||
geom.emplace_back();
|
||||
|
||||
|
@ -37,18 +36,18 @@ SECTION("multi-polygon") {
|
|||
geom_type geom;
|
||||
mapnik::geometry::polygon<double> poly;
|
||||
mapnik::geometry::linear_ring<double> ring;
|
||||
ring.add_coord(0, 0);
|
||||
ring.add_coord(1, 0);
|
||||
ring.add_coord(1, 1);
|
||||
ring.add_coord(0, 1);
|
||||
ring.add_coord(0, 0);
|
||||
poly.set_exterior_ring(std::move(ring));
|
||||
ring.emplace_back(0, 0);
|
||||
ring.emplace_back(1, 0);
|
||||
ring.emplace_back(1, 1);
|
||||
ring.emplace_back(0, 1);
|
||||
ring.emplace_back(0, 0);
|
||||
poly.push_back(std::move(ring));
|
||||
geom.emplace_back(std::move(poly));
|
||||
geom.emplace_back();
|
||||
|
||||
//geom.back().emplace_back(); //add an empty exterior ring
|
||||
REQUIRE(geom.size() == 2);
|
||||
geom_type geom2 = mapnik::geometry::remove_empty(geom);
|
||||
REQUIRE(geom2.size() == 1);
|
||||
REQUIRE(geom2[0].exterior_ring.size() == 5);
|
||||
REQUIRE(geom2.front().front().size() == 5);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ SECTION("wkb") {
|
|||
geom = mapnik::geometry_utils::from_wkb((const char*)sp_invalid_blob,
|
||||
sizeof(sp_invalid_blob) / sizeof(sp_invalid_blob[0]),
|
||||
mapnik::wkbAuto);
|
||||
REQUIRE(geom.is<mapnik::geometry::geometry_empty>()); // returns geometry_empty
|
||||
REQUIRE(geom.is<mapnik::geometry::geometry_empty<double>>()); // returns geometry_empty
|
||||
|
||||
// sqlite generic wkb blob
|
||||
|
||||
|
@ -103,7 +103,7 @@ SECTION("wkb") {
|
|||
geom = mapnik::geometry_utils::from_wkb((const char*)sq_invalid_blob,
|
||||
sizeof(sq_invalid_blob) / sizeof(sq_invalid_blob[0]),
|
||||
mapnik::wkbGeneric);
|
||||
REQUIRE(geom.is<mapnik::geometry::geometry_empty>()); // returns geometry_empty
|
||||
REQUIRE(geom.is<mapnik::geometry::geometry_empty<double>>()); // returns geometry_empty
|
||||
|
||||
}
|
||||
catch (std::exception const& ex)
|
||||
|
|
|
@ -23,7 +23,7 @@ struct spatially_equal_visitor
|
|||
{
|
||||
using result_type = bool;
|
||||
|
||||
result_type operator() (mapnik::geometry::geometry_empty, mapnik::geometry::geometry_empty) const
|
||||
result_type operator() (mapnik::geometry::geometry_empty<double>, mapnik::geometry::geometry_empty<double>) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include "catch.hpp"
|
||||
|
||||
#include <mapnik/vertex_adapters.hpp>
|
||||
|
@ -8,10 +7,11 @@ TEST_CASE("vertex_adapters") {
|
|||
|
||||
SECTION("polygon") {
|
||||
mapnik::geometry::polygon<double> 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);
|
||||
g.emplace_back();
|
||||
g.back().emplace_back(1,1);
|
||||
g.back().emplace_back(2,2);
|
||||
g.back().emplace_back(100,100);
|
||||
g.back().emplace_back(1,1);
|
||||
|
||||
mapnik::geometry::polygon_vertex_adapter<double> va(g);
|
||||
double x,y;
|
||||
|
@ -47,27 +47,28 @@ SECTION("polygon") {
|
|||
|
||||
SECTION("polygon with hole") {
|
||||
mapnik::geometry::polygon<double> 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);
|
||||
g.emplace_back();
|
||||
g.back().emplace_back(0,0);
|
||||
g.back().emplace_back(-10,0);
|
||||
g.back().emplace_back(-10,10);
|
||||
g.back().emplace_back(0,10);
|
||||
g.back().emplace_back(0,0);
|
||||
std::vector<mapnik::geometry::linear_ring<double> > interior_rings;
|
||||
mapnik::geometry::linear_ring<double> 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);
|
||||
g.add_hole(std::move(hole));
|
||||
hole.emplace_back(-7,7);
|
||||
hole.emplace_back(-7,3);
|
||||
hole.emplace_back(-3,3);
|
||||
hole.emplace_back(-3,7);
|
||||
hole.emplace_back(-7,7);
|
||||
g.push_back(std::move(hole));
|
||||
|
||||
mapnik::geometry::linear_ring<double> hole_in_hole;
|
||||
hole_in_hole.add_coord(-6,4);
|
||||
hole_in_hole.add_coord(-6,6);
|
||||
hole_in_hole.add_coord(-4,6);
|
||||
hole_in_hole.add_coord(-4,4);
|
||||
hole_in_hole.add_coord(-6,4);
|
||||
g.add_hole(std::move(hole_in_hole));
|
||||
hole_in_hole.emplace_back(-6,4);
|
||||
hole_in_hole.emplace_back(-6,6);
|
||||
hole_in_hole.emplace_back(-4,6);
|
||||
hole_in_hole.emplace_back(-4,4);
|
||||
hole_in_hole.emplace_back(-6,4);
|
||||
g.push_back(std::move(hole_in_hole));
|
||||
|
||||
mapnik::geometry::polygon_vertex_adapter<double> va(g);
|
||||
double x,y;
|
||||
|
@ -100,7 +101,7 @@ SECTION("polygon with hole") {
|
|||
REQUIRE( y == 0 );
|
||||
|
||||
// exterior ring via ring_vertex_adapter
|
||||
mapnik::geometry::ring_vertex_adapter<double> va2(g.exterior_ring);
|
||||
mapnik::geometry::ring_vertex_adapter<double> va2(g.front());
|
||||
cmd = va2.vertex(&x,&y);
|
||||
REQUIRE( cmd == mapnik::SEG_MOVETO );
|
||||
REQUIRE( x == 0 );
|
||||
|
|
Loading…
Reference in a new issue