mapnik-geometry - add 'geometry_empty' type to support unintialised geometries
This commit is contained in:
parent
9aa3542680
commit
163da958f4
13 changed files with 49 additions and 11 deletions
|
@ -58,11 +58,6 @@ using mapnik::context_type;
|
|||
using mapnik::context_ptr;
|
||||
using mapnik::feature_kv_iterator;
|
||||
|
||||
void set_geometry_impl( mapnik::feature_impl & feature, mapnik::new_geometry::geometry const& geom)
|
||||
{
|
||||
feature.set_geometry_copy(geom);
|
||||
}
|
||||
|
||||
mapnik::feature_ptr from_geojson_impl(std::string const& json, mapnik::context_ptr const& ctx)
|
||||
{
|
||||
mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx,1));
|
||||
|
|
|
@ -69,6 +69,7 @@ public:
|
|||
};
|
||||
|
||||
enum geometry_t : std::uint8_t {
|
||||
Unknown = 0,
|
||||
Point = 1,
|
||||
LineString = 2,
|
||||
Polygon = 3,
|
||||
|
|
|
@ -105,7 +105,7 @@ public:
|
|||
: id_(id),
|
||||
ctx_(ctx),
|
||||
data_(ctx_->mapping_.size()),
|
||||
geom_(mapnik::util::no_init()),
|
||||
geom_(new_geometry::geometry_empty()),
|
||||
raster_() {}
|
||||
|
||||
inline mapnik::value_integer id() const { return id_;}
|
||||
|
|
|
@ -42,7 +42,10 @@ struct geometry_centroid
|
|||
{
|
||||
return mapnik::util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
result_type operator() (geometry_empty const&) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
result_type operator() (geometry_collection const& collection) const
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -39,6 +39,11 @@ struct geometry_envelope
|
|||
return mapnik::util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
bbox_type operator() (mapnik::new_geometry::geometry_empty const&) const
|
||||
{
|
||||
return mapnik::box2d<double>();
|
||||
}
|
||||
|
||||
bbox_type operator() (mapnik::new_geometry::point const& pt) const
|
||||
{
|
||||
return mapnik::box2d<double>(pt.x, pt.y, pt.x, pt.y);
|
||||
|
|
|
@ -103,8 +103,9 @@ struct multi_point : line_string {};
|
|||
struct multi_line_string : std::vector<line_string> {};
|
||||
struct multi_polygon : std::vector<polygon> {};
|
||||
struct geometry_collection;
|
||||
|
||||
using geometry = mapnik::util::variant<point,
|
||||
struct geometry_empty {};
|
||||
using geometry = mapnik::util::variant<geometry_empty,
|
||||
point,
|
||||
line_string,
|
||||
polygon,
|
||||
multi_point,
|
||||
|
|
|
@ -40,6 +40,11 @@ struct geometry_is_simple
|
|||
return mapnik::util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
result_type operator() (geometry_empty const& ) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
result_type operator() (geometry_collection const& collection) const
|
||||
{
|
||||
for (auto const& geom : collection)
|
||||
|
|
|
@ -40,6 +40,11 @@ struct geometry_is_valid
|
|||
return mapnik::util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
result_type operator() (geometry_empty const& ) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
result_type operator() (geometry_collection const& collection) const
|
||||
{
|
||||
for (auto const& geom : collection)
|
||||
|
|
|
@ -33,8 +33,12 @@ struct geometry_type
|
|||
{
|
||||
mapnik::new_geometry::geometry_types operator () (mapnik::new_geometry::geometry const& geom) const
|
||||
{
|
||||
// check geometry variant is initialised (valid)
|
||||
return geom.valid() ? mapnik::util::apply_visitor(*this, geom) : mapnik::new_geometry::geometry_types::Unknown;
|
||||
return mapnik::util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
mapnik::new_geometry::geometry_types operator() (geometry_empty const& ) const
|
||||
{
|
||||
return mapnik::new_geometry::geometry_types::Unknown;
|
||||
}
|
||||
|
||||
mapnik::new_geometry::geometry_types operator () (mapnik::new_geometry::point const&) const
|
||||
|
|
|
@ -49,6 +49,11 @@ struct hit_test_visitor
|
|||
y_(y),
|
||||
tol_(tol) {}
|
||||
|
||||
bool operator() (new_geometry::geometry_empty const& ) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator() (new_geometry::point const& geom) const
|
||||
{
|
||||
return distance(geom.x, geom.y, x_, y_) <= tol_;
|
||||
|
|
|
@ -37,6 +37,11 @@ namespace detail {
|
|||
|
||||
struct datasource_geometry_type
|
||||
{
|
||||
mapnik::datasource::geometry_t operator () (mapnik::new_geometry::geometry_empty const&) const
|
||||
{
|
||||
return mapnik::datasource::Unknown;
|
||||
}
|
||||
|
||||
mapnik::datasource::geometry_t operator () (mapnik::new_geometry::point const&) const
|
||||
{
|
||||
return mapnik::datasource::Point;
|
||||
|
|
|
@ -237,6 +237,11 @@ struct geometry_to_wkb
|
|||
return util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
result_type operator() (new_geometry::geometry_empty const&) const
|
||||
{
|
||||
return result_type();
|
||||
}
|
||||
|
||||
result_type operator() (new_geometry::point const& pt) const
|
||||
{
|
||||
return point_wkb(pt, byte_order_);
|
||||
|
|
|
@ -38,6 +38,10 @@ struct vertex_processor
|
|||
{
|
||||
util::apply_visitor(*this, geom);
|
||||
}
|
||||
void operator() (geometry_empty const&)
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
void operator() (point const& pt)
|
||||
{
|
||||
point_vertex_adapter va(pt);
|
||||
|
|
Loading…
Reference in a new issue