remove coord<T, int>
usage from box2d<T>
This commit is contained in:
parent
b17dae8381
commit
b669115b2c
22 changed files with 148 additions and 164 deletions
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/config.hpp>
|
#include <mapnik/config.hpp>
|
||||||
#include <mapnik/coord.hpp>
|
#include <mapnik/geometry.hpp>
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#include <mapnik/warning_ignore.hpp>
|
#include <mapnik/warning_ignore.hpp>
|
||||||
|
@ -68,7 +68,7 @@ public:
|
||||||
|
|
||||||
box2d();
|
box2d();
|
||||||
box2d(T minx,T miny,T maxx,T maxy);
|
box2d(T minx,T miny,T maxx,T maxy);
|
||||||
box2d(coord<T,2> const& c0, coord<T,2> const& c1);
|
box2d(geometry::point<T> const& c0, geometry::point<T> const& c1);
|
||||||
box2d(box2d_type const& rhs);
|
box2d(box2d_type const& rhs);
|
||||||
box2d(box2d_type const& rhs, agg::trans_affine const& tr);
|
box2d(box2d_type const& rhs, agg::trans_affine const& tr);
|
||||||
// move
|
// move
|
||||||
|
@ -94,20 +94,20 @@ public:
|
||||||
T height() const;
|
T height() const;
|
||||||
void width(T w);
|
void width(T w);
|
||||||
void height(T h);
|
void height(T h);
|
||||||
coord<T,2> center() const;
|
geometry::point<T> center() const;
|
||||||
void expand_to_include(T x,T y);
|
void expand_to_include(T x,T y);
|
||||||
void expand_to_include(coord<T,2> const& c);
|
void expand_to_include(geometry::point<T> const& c);
|
||||||
void expand_to_include(box2d_type const& other);
|
void expand_to_include(box2d_type const& other);
|
||||||
bool contains(coord<T,2> const& c) const;
|
bool contains(geometry::point<T> const& c) const;
|
||||||
bool contains(T x,T y) const;
|
bool contains(T x,T y) const;
|
||||||
bool contains(box2d_type const& other) const;
|
bool contains(box2d_type const& other) const;
|
||||||
bool intersects(coord<T,2> const& c) const;
|
bool intersects(geometry::point<T> const& c) const;
|
||||||
bool intersects(T x,T y) const;
|
bool intersects(T x,T y) const;
|
||||||
bool intersects(box2d_type const& other) const;
|
bool intersects(box2d_type const& other) const;
|
||||||
box2d_type intersect(box2d_type const& other) const;
|
box2d_type intersect(box2d_type const& other) const;
|
||||||
bool operator==(box2d_type const& other) const;
|
bool operator==(box2d_type const& other) const;
|
||||||
void re_center(T cx,T cy);
|
void re_center(T cx,T cy);
|
||||||
void re_center(coord<T,2> const& c);
|
void re_center(geometry::point<T> const& c);
|
||||||
void init(T x0,T y0,T x1,T y1);
|
void init(T x0,T y0,T x1,T y1);
|
||||||
void init(T x, T y);
|
void init(T x, T y);
|
||||||
void clip(box2d_type const& other);
|
void clip(box2d_type const& other);
|
||||||
|
|
|
@ -25,17 +25,17 @@
|
||||||
#include <mapnik/safe_cast.hpp>
|
#include <mapnik/safe_cast.hpp>
|
||||||
|
|
||||||
// stl
|
// stl
|
||||||
#include <stdexcept>
|
|
||||||
#include <sstream>
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <sstream>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
#include <mapnik/config.hpp>
|
#include <mapnik/config.hpp>
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#include <mapnik/warning_ignore.hpp>
|
|
||||||
#include <boost/fusion/include/adapt_adt.hpp>
|
#include <boost/fusion/include/adapt_adt.hpp>
|
||||||
#include <boost/spirit/include/qi.hpp>
|
#include <boost/spirit/include/qi.hpp>
|
||||||
#include <boost/spirit/include/support_adapt_adt_attributes.hpp>
|
#include <boost/spirit/include/support_adapt_adt_attributes.hpp>
|
||||||
|
#include <mapnik/warning_ignore.hpp>
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
// agg
|
// agg
|
||||||
|
@ -44,19 +44,17 @@
|
||||||
BOOST_FUSION_ADAPT_TPL_ADT(
|
BOOST_FUSION_ADAPT_TPL_ADT(
|
||||||
(T),
|
(T),
|
||||||
(mapnik::box2d)(T),
|
(mapnik::box2d)(T),
|
||||||
(T, T, obj.minx(), obj.set_minx(mapnik::safe_cast<T>(val)))
|
(T, T, obj.minx(), obj.set_minx(mapnik::safe_cast<T>(val)))(T, T, obj.miny(), obj.set_miny(mapnik::safe_cast<T>(val)))(T, T, obj.maxx(), obj.set_maxx(mapnik::safe_cast<T>(val)))(T, T, obj.maxy(), obj.set_maxy(mapnik::safe_cast<T>(val))))
|
||||||
(T, T, obj.miny(), obj.set_miny(mapnik::safe_cast<T>(val)))
|
|
||||||
(T, T, obj.maxx(), obj.set_maxx(mapnik::safe_cast<T>(val)))
|
|
||||||
(T, T, obj.maxy(), obj.set_maxy(mapnik::safe_cast<T>(val))))
|
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik {
|
||||||
{
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
box2d<T>::box2d()
|
box2d<T>::box2d()
|
||||||
: minx_(std::numeric_limits<T>::max()),
|
: minx_(std::numeric_limits<T>::max()),
|
||||||
miny_(std::numeric_limits<T>::max()),
|
miny_(std::numeric_limits<T>::max()),
|
||||||
maxx_(-std::numeric_limits<T>::max()),
|
maxx_(-std::numeric_limits<T>::max()),
|
||||||
maxy_(-std::numeric_limits<T>::max()) {}
|
maxy_(-std::numeric_limits<T>::max())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
box2d<T>::box2d(T minx, T miny, T maxx, T maxy)
|
box2d<T>::box2d(T minx, T miny, T maxx, T maxy)
|
||||||
|
@ -65,7 +63,7 @@ box2d<T>::box2d(T minx,T miny,T maxx,T maxy)
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
box2d<T>::box2d(coord<T,2> const& c0, coord<T,2> const& c1)
|
box2d<T>::box2d(geometry::point<T> const& c0, geometry::point<T> const& c1)
|
||||||
{
|
{
|
||||||
init(c0.x,c0.y,c1.x,c1.y);
|
init(c0.x,c0.y,c1.x,c1.y);
|
||||||
}
|
}
|
||||||
|
@ -75,14 +73,18 @@ box2d<T>::box2d(box2d_type const& rhs)
|
||||||
: minx_(rhs.minx_),
|
: minx_(rhs.minx_),
|
||||||
miny_(rhs.miny_),
|
miny_(rhs.miny_),
|
||||||
maxx_(rhs.maxx_),
|
maxx_(rhs.maxx_),
|
||||||
maxy_(rhs.maxy_) {}
|
maxy_(rhs.maxy_)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
box2d<T>::box2d(box2d_type&& rhs)
|
box2d<T>::box2d(box2d_type&& rhs)
|
||||||
: minx_(std::move(rhs.minx_)),
|
: minx_(std::move(rhs.minx_)),
|
||||||
miny_(std::move(rhs.miny_)),
|
miny_(std::move(rhs.miny_)),
|
||||||
maxx_(std::move(rhs.maxx_)),
|
maxx_(std::move(rhs.maxx_)),
|
||||||
maxy_(std::move(rhs.maxy_)) {}
|
maxy_(std::move(rhs.maxy_))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
box2d<T>& box2d<T>::operator=(box2d_type other)
|
box2d<T>& box2d<T>::operator=(box2d_type other)
|
||||||
|
@ -194,14 +196,14 @@ void box2d<T>::height(T h)
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
coord<T,2> box2d<T>::center() const
|
geometry::point<T> box2d<T>::center() const
|
||||||
{
|
{
|
||||||
return coord<T,2>(static_cast<T>(0.5*(minx_+maxx_)),
|
return geometry::point<T>(static_cast<T>(0.5 * (minx_ + maxx_)),
|
||||||
static_cast<T>(0.5 * (miny_ + maxy_)));
|
static_cast<T>(0.5 * (miny_ + maxy_)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void box2d<T>::expand_to_include(coord<T,2> const& c)
|
void box2d<T>::expand_to_include(geometry::point<T> const& c)
|
||||||
{
|
{
|
||||||
expand_to_include(c.x,c.y);
|
expand_to_include(c.x,c.y);
|
||||||
}
|
}
|
||||||
|
@ -225,7 +227,7 @@ void box2d<T>::expand_to_include(box2d<T> const& other)
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool box2d<T>::contains(coord<T,2> const& c) const
|
bool box2d<T>::contains(geometry::point<T> const& c) const
|
||||||
{
|
{
|
||||||
return contains(c.x,c.y);
|
return contains(c.x,c.y);
|
||||||
}
|
}
|
||||||
|
@ -246,7 +248,7 @@ bool box2d<T>::contains(box2d<T> const& other) const
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool box2d<T>::intersects(coord<T,2> const& c) const
|
bool box2d<T>::intersects(geometry::point<T> const& c) const
|
||||||
{
|
{
|
||||||
return intersects(c.x,c.y);
|
return intersects(c.x,c.y);
|
||||||
}
|
}
|
||||||
|
@ -293,7 +295,7 @@ void box2d<T>::re_center(T cx,T cy)
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void box2d<T>::re_center(coord<T,2> const& c)
|
void box2d<T>::re_center(geometry::point<T> const& c)
|
||||||
{
|
{
|
||||||
re_center(c.x,c.y);
|
re_center(c.x,c.y);
|
||||||
}
|
}
|
||||||
|
@ -393,7 +395,6 @@ std::string box2d<T>::to_string() const
|
||||||
return s.str();
|
return s.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
box2d<T>& box2d<T>::operator+=(box2d<T> const& other)
|
box2d<T>& box2d<T>::operator+=(box2d<T> const& other)
|
||||||
{
|
{
|
||||||
|
@ -417,11 +418,10 @@ box2d<T>& box2d<T>::operator+= (T other)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
box2d<T>& box2d<T>::operator*=(T t)
|
box2d<T>& box2d<T>::operator*=(T t)
|
||||||
{
|
{
|
||||||
coord<T,2> c = center();
|
geometry::point<T> c = center();
|
||||||
T sx = static_cast<T>(0.5 * width() * t);
|
T sx = static_cast<T>(0.5 * width() * t);
|
||||||
T sy = static_cast<T>(0.5 * height() * t);
|
T sy = static_cast<T>(0.5 * height() * t);
|
||||||
minx_ = c.x - sx;
|
minx_ = c.x - sx;
|
||||||
|
@ -434,7 +434,7 @@ box2d<T>& box2d<T>::operator*=(T t)
|
||||||
template <typename T>
|
template <typename T>
|
||||||
box2d<T>& box2d<T>::operator/=(T t)
|
box2d<T>& box2d<T>::operator/=(T t)
|
||||||
{
|
{
|
||||||
coord<T,2> c = center();
|
geometry::point<T> c = center();
|
||||||
T sx = static_cast<T>(0.5 * width() / t);
|
T sx = static_cast<T>(0.5 * width() / t);
|
||||||
T sy = static_cast<T>(0.5 * height() / t);
|
T sy = static_cast<T>(0.5 * height() / t);
|
||||||
minx_ = c.x - sx;
|
minx_ = c.x - sx;
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#include <mapnik/util/noncopyable.hpp>
|
#include <mapnik/util/noncopyable.hpp>
|
||||||
#include <mapnik/feature_style_processor_context.hpp>
|
#include <mapnik/feature_style_processor_context.hpp>
|
||||||
#include <mapnik/datasource_geometry_type.hpp>
|
#include <mapnik/datasource_geometry_type.hpp>
|
||||||
|
#include <mapnik/coord.hpp>
|
||||||
// stl
|
// stl
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
|
@ -212,7 +212,7 @@ struct filter_at_point
|
||||||
{
|
{
|
||||||
box2d<double> box_;
|
box2d<double> box_;
|
||||||
explicit filter_at_point(coord2d const& pt, double tol=0)
|
explicit filter_at_point(coord2d const& pt, double tol=0)
|
||||||
: box_(pt,pt)
|
: box_(pt.x,pt.y, pt.x, pt.y)
|
||||||
{
|
{
|
||||||
box_.pad(tol);
|
box_.pad(tol);
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ struct vector_markers_dispatch : util::noncopyable
|
||||||
protected:
|
protected:
|
||||||
static agg::trans_affine recenter(svg_path_ptr const& src)
|
static agg::trans_affine recenter(svg_path_ptr const& src)
|
||||||
{
|
{
|
||||||
coord2d center = src->bounding_box().center();
|
auto center = src->bounding_box().center();
|
||||||
return agg::trans_affine_translation(-center.x, -center.y);
|
return agg::trans_affine_translation(-center.x, -center.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,8 @@ void render_point_symbolizer(point_symbolizer const &sym,
|
||||||
value_bool ignore_placement = get<value_bool, keys::ignore_placement>(sym, feature, common.vars_);
|
value_bool ignore_placement = get<value_bool, keys::ignore_placement>(sym, feature, common.vars_);
|
||||||
point_placement_enum placement= get<point_placement_enum, keys::point_placement_type>(sym, feature, common.vars_);
|
point_placement_enum placement= get<point_placement_enum, keys::point_placement_type>(sym, feature, common.vars_);
|
||||||
|
|
||||||
box2d<double> const& bbox = mark->bounding_box();
|
auto const& bbox = mark->bounding_box();
|
||||||
coord2d center = bbox.center();
|
auto center = bbox.center();
|
||||||
|
|
||||||
agg::trans_affine tr;
|
agg::trans_affine tr;
|
||||||
auto image_transform = get_optional<transform_type>(sym, keys::image_transform);
|
auto image_transform = get_optional<transform_type>(sym, keys::image_transform);
|
||||||
|
|
|
@ -436,7 +436,7 @@ mapnik::featureset_ptr csv_datasource::features(mapnik::query const& q) const
|
||||||
|
|
||||||
mapnik::featureset_ptr csv_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const
|
mapnik::featureset_ptr csv_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const
|
||||||
{
|
{
|
||||||
mapnik::box2d<double> query_bbox(pt, pt);
|
mapnik::box2d<double> query_bbox(pt.x, pt.y, pt.x, pt.y);
|
||||||
query_bbox.pad(tol);
|
query_bbox.pad(tol);
|
||||||
mapnik::query q(query_bbox);
|
mapnik::query q(query_bbox);
|
||||||
std::vector<mapnik::attribute_descriptor> const& desc = desc_.get_descriptors();
|
std::vector<mapnik::attribute_descriptor> const& desc = desc_.get_descriptors();
|
||||||
|
|
|
@ -593,7 +593,7 @@ mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) cons
|
||||||
|
|
||||||
mapnik::featureset_ptr geojson_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const
|
mapnik::featureset_ptr geojson_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const
|
||||||
{
|
{
|
||||||
mapnik::box2d<double> query_bbox(pt, pt);
|
mapnik::box2d<double> query_bbox(pt.x, pt.y, pt.x, pt.y);
|
||||||
query_bbox.pad(tol);
|
query_bbox.pad(tol);
|
||||||
mapnik::query q(query_bbox);
|
mapnik::query q(query_bbox);
|
||||||
for (auto const& attr_info : desc_.get_descriptors())
|
for (auto const& attr_info : desc_.get_descriptors())
|
||||||
|
|
|
@ -594,7 +594,7 @@ featureset_ptr ogr_datasource::features_at_point(coord2d const& pt, double tol)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mapnik::box2d<double> bbox(pt, pt);
|
mapnik::box2d<double> bbox(pt.x, pt.y, pt.x, pt.y);
|
||||||
bbox.pad(tol);
|
bbox.pad(tol);
|
||||||
return featureset_ptr(new ogr_featureset (ctx,
|
return featureset_ptr(new ogr_featureset (ctx,
|
||||||
*layer,
|
*layer,
|
||||||
|
|
|
@ -289,7 +289,7 @@ mapnik::featureset_ptr topojson_datasource::features(mapnik::query const& q) con
|
||||||
|
|
||||||
mapnik::featureset_ptr topojson_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const
|
mapnik::featureset_ptr topojson_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const
|
||||||
{
|
{
|
||||||
mapnik::box2d<double> query_bbox(pt, pt);
|
mapnik::box2d<double> query_bbox(pt.x, pt.y, pt.x, pt.y);
|
||||||
query_bbox.pad(tol);
|
query_bbox.pad(tol);
|
||||||
mapnik::query q(query_bbox);
|
mapnik::query q(query_bbox);
|
||||||
for (auto const& attr_info : desc_.get_descriptors())
|
for (auto const& attr_info : desc_.get_descriptors())
|
||||||
|
|
|
@ -395,7 +395,7 @@ struct agg_render_marker_visitor
|
||||||
renderer_base renb(pixf);
|
renderer_base renb(pixf);
|
||||||
|
|
||||||
box2d<double> const& bbox = marker.get_data()->bounding_box();
|
box2d<double> const& bbox = marker.get_data()->bounding_box();
|
||||||
coord<double,2> c = bbox.center();
|
auto c = bbox.center();
|
||||||
// center the svg marker on '0,0'
|
// center the svg marker on '0,0'
|
||||||
agg::trans_affine mtx = agg::trans_affine_translation(-c.x,-c.y);
|
agg::trans_affine mtx = agg::trans_affine_translation(-c.x,-c.y);
|
||||||
// apply symbol transformation to get to map space
|
// apply symbol transformation to get to map space
|
||||||
|
|
|
@ -228,7 +228,7 @@ struct cairo_render_marker_visitor
|
||||||
agg::trans_affine marker_tr = tr_;
|
agg::trans_affine marker_tr = tr_;
|
||||||
if (recenter_)
|
if (recenter_)
|
||||||
{
|
{
|
||||||
coord<double,2> c = bbox.center();
|
auto c = bbox.center();
|
||||||
marker_tr = agg::trans_affine_translation(-c.x, -c.y);
|
marker_tr = agg::trans_affine_translation(-c.x, -c.y);
|
||||||
marker_tr *= tr_;
|
marker_tr *= tr_;
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,8 +163,8 @@ struct grid_render_marker_visitor
|
||||||
|
|
||||||
ras_ptr_->reset();
|
ras_ptr_->reset();
|
||||||
|
|
||||||
box2d<double> const& bbox = marker.get_data()->bounding_box();
|
auto const& bbox = marker.get_data()->bounding_box();
|
||||||
coord<double,2> c = bbox.center();
|
auto c = bbox.center();
|
||||||
// center the svg marker on '0,0'
|
// center the svg marker on '0,0'
|
||||||
agg::trans_affine mtx = agg::trans_affine_translation(-c.x,-c.y);
|
agg::trans_affine mtx = agg::trans_affine_translation(-c.x,-c.y);
|
||||||
// apply symbol transformation to get to map space
|
// apply symbol transformation to get to map space
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include <mapnik/text/font_library.hpp>
|
#include <mapnik/text/font_library.hpp>
|
||||||
#include <mapnik/util/file_io.hpp>
|
#include <mapnik/util/file_io.hpp>
|
||||||
#include <mapnik/font_engine_freetype.hpp>
|
#include <mapnik/font_engine_freetype.hpp>
|
||||||
|
#include <mapnik/geometry.hpp>
|
||||||
|
|
||||||
// stl
|
// stl
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
@ -499,7 +500,7 @@ void Map::set_base_path(std::string const& base)
|
||||||
|
|
||||||
void Map::zoom(double factor)
|
void Map::zoom(double factor)
|
||||||
{
|
{
|
||||||
coord2d center = current_extent_.center();
|
auto center = current_extent_.center();
|
||||||
double w = factor * current_extent_.width();
|
double w = factor * current_extent_.width();
|
||||||
double h = factor * current_extent_.height();
|
double h = factor * current_extent_.height();
|
||||||
current_extent_ = box2d<double>(center.x - 0.5 * w,
|
current_extent_ = box2d<double>(center.x - 0.5 * w,
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <mapnik/box2d.hpp>
|
#include <mapnik/box2d.hpp>
|
||||||
#include <mapnik/projection.hpp>
|
#include <mapnik/projection.hpp>
|
||||||
#include <mapnik/proj_transform.hpp>
|
#include <mapnik/proj_transform.hpp>
|
||||||
#include <mapnik/coord.hpp>
|
|
||||||
#include <mapnik/util/is_clockwise.hpp>
|
#include <mapnik/util/is_clockwise.hpp>
|
||||||
|
|
||||||
#ifdef MAPNIK_USE_PROJ4
|
#ifdef MAPNIK_USE_PROJ4
|
||||||
|
@ -335,7 +334,7 @@ bool proj_transform::backward (box2d<double> & box) const
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns points in clockwise order. This allows us to do anti-meridian checks.
|
// Returns points in clockwise order. This allows us to do anti-meridian checks.
|
||||||
void envelope_points(std::vector< coord<double,2> > & coords, box2d<double>& env, int points)
|
void envelope_points(std::vector<geometry::point<double>> & coords, box2d<double>& env, int points)
|
||||||
{
|
{
|
||||||
double width = env.width();
|
double width = env.width();
|
||||||
double height = env.height();
|
double height = env.height();
|
||||||
|
@ -353,21 +352,22 @@ void envelope_points(std::vector< coord<double,2> > & coords, box2d<double>& env
|
||||||
double ystep = height / steps;
|
double ystep = height / steps;
|
||||||
|
|
||||||
coords.resize(points);
|
coords.resize(points);
|
||||||
for (int i=0; i<steps; i++) {
|
for (int i = 0; i < steps; ++i)
|
||||||
|
{
|
||||||
// top: left>right
|
// top: left>right
|
||||||
coords[i] = coord<double, 2>(env.minx() + i * xstep, env.maxy());
|
coords[i] = geometry::point<double>(env.minx() + i * xstep, env.maxy());
|
||||||
// right: top>bottom
|
// right: top>bottom
|
||||||
coords[i + steps] = coord<double, 2>(env.maxx(), env.maxy() - i * ystep);
|
coords[i + steps] = geometry::point<double>(env.maxx(), env.maxy() - i * ystep);
|
||||||
// bottom: right>left
|
// bottom: right>left
|
||||||
coords[i + steps * 2] = coord<double, 2>(env.maxx() - i * xstep, env.miny());
|
coords[i + steps * 2] = geometry::point<double>(env.maxx() - i * xstep, env.miny());
|
||||||
// left: bottom>top
|
// left: bottom>top
|
||||||
coords[i + steps * 3] = coord<double, 2>(env.minx(), env.miny() + i * ystep);
|
coords[i + steps * 3] = geometry::point<double>(env.minx(), env.miny() + i * ystep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
box2d<double> calculate_bbox(std::vector<coord<double,2> > & points) {
|
box2d<double> calculate_bbox(std::vector<geometry::point<double> > & points) {
|
||||||
std::vector<coord<double,2> >::iterator it = points.begin();
|
std::vector<geometry::point<double> >::iterator it = points.begin();
|
||||||
std::vector<coord<double,2> >::iterator it_end = points.end();
|
std::vector<geometry::point<double> >::iterator it_end = points.end();
|
||||||
|
|
||||||
box2d<double> env(*it, *(++it));
|
box2d<double> env(*it, *(++it));
|
||||||
for (; it!=it_end; ++it) {
|
for (; it!=it_end; ++it) {
|
||||||
|
@ -393,15 +393,13 @@ bool proj_transform::backward(box2d<double>& env, int points) const
|
||||||
return backward(env);
|
return backward(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<coord<double,2> > coords;
|
std::vector<geometry::point<double>> coords;
|
||||||
envelope_points(coords, env, points); // this is always clockwise
|
envelope_points(coords, env, points); // this is always clockwise
|
||||||
|
|
||||||
double z;
|
for (auto & pt : coords)
|
||||||
for (std::vector<coord<double,2> >::iterator it = coords.begin(); it!=coords.end(); ++it) {
|
{
|
||||||
z = 0;
|
double z = 0;
|
||||||
if (!backward(it->x, it->y, z)) {
|
if (!backward(pt.x, pt.y, z)) return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
box2d<double> result = calculate_bbox(coords);
|
box2d<double> result = calculate_bbox(coords);
|
||||||
|
@ -432,15 +430,13 @@ bool proj_transform::forward(box2d<double>& env, int points) const
|
||||||
return forward(env);
|
return forward(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<coord<double,2> > coords;
|
std::vector<geometry::point<double>> coords;
|
||||||
envelope_points(coords, env, points); // this is always clockwise
|
envelope_points(coords, env, points); // this is always clockwise
|
||||||
|
|
||||||
double z;
|
for (auto & pt : coords)
|
||||||
for (std::vector<coord<double,2> >::iterator it = coords.begin(); it!=coords.end(); ++it) {
|
{
|
||||||
z = 0;
|
double z = 0;
|
||||||
if (!forward(it->x, it->y, z)) {
|
if (!forward(pt.x, pt.y, z)) return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
box2d<double> result = calculate_bbox(coords);
|
box2d<double> result = calculate_bbox(coords);
|
||||||
|
|
|
@ -187,7 +187,7 @@ struct render_marker_symbolizer_visitor
|
||||||
box2d<double> const& bbox = mark.bounding_box();
|
box2d<double> const& bbox = mark.bounding_box();
|
||||||
mapnik::image_rgba8 const& marker = mark.get_data();
|
mapnik::image_rgba8 const& marker = mark.get_data();
|
||||||
// - clamp sizes to > 4 pixels of interactivity
|
// - clamp sizes to > 4 pixels of interactivity
|
||||||
coord2d center = bbox.center();
|
auto center = bbox.center();
|
||||||
agg::trans_affine_translation recenter(-center.x, -center.y);
|
agg::trans_affine_translation recenter(-center.x, -center.y);
|
||||||
agg::trans_affine marker_trans = recenter * image_tr;
|
agg::trans_affine marker_trans = recenter * image_tr;
|
||||||
raster_dispatch_type rasterizer_dispatch(marker,
|
raster_dispatch_type rasterizer_dispatch(marker,
|
||||||
|
|
|
@ -52,8 +52,8 @@ void render_pattern<image_rgba8>(rasterizer & ras,
|
||||||
using renderer_solid = agg::renderer_scanline_aa_solid<renderer_base>;
|
using renderer_solid = agg::renderer_scanline_aa_solid<renderer_base>;
|
||||||
agg::scanline_u8 sl;
|
agg::scanline_u8 sl;
|
||||||
|
|
||||||
mapnik::box2d<double> const& bbox = marker.bounding_box() * tr;
|
auto const& bbox = marker.bounding_box() * tr;
|
||||||
mapnik::coord<double,2> c = bbox.center();
|
auto c = bbox.center();
|
||||||
agg::trans_affine mtx = agg::trans_affine_translation(-c.x, -c.y);
|
agg::trans_affine mtx = agg::trans_affine_translation(-c.x, -c.y);
|
||||||
mtx.translate(0.5 * bbox.width(), 0.5 * bbox.height());
|
mtx.translate(0.5 * bbox.width(), 0.5 * bbox.height());
|
||||||
mtx = tr * mtx;
|
mtx = tr * mtx;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 5f0e6f86696a2a9a6733e42b1f400ba4ec2f8847
|
Subproject commit 047985797ab11ea34ac97e469d0871b6220ea4d3
|
|
@ -1,25 +1,9 @@
|
||||||
|
|
||||||
#include "catch.hpp"
|
#include "catch.hpp"
|
||||||
|
|
||||||
#include <mapnik/coord.hpp>
|
|
||||||
#include <mapnik/box2d.hpp>
|
#include <mapnik/box2d.hpp>
|
||||||
#include "agg_trans_affine.h"
|
#include "agg_trans_affine.h"
|
||||||
|
|
||||||
TEST_CASE("box2d") {
|
TEST_CASE("box2d") {
|
||||||
SECTION("coord init") {
|
|
||||||
auto c = mapnik::coord2d(100, 100);
|
|
||||||
|
|
||||||
REQUIRE(c.x == 100);
|
|
||||||
REQUIRE(c.y == 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("coord multiplication") {
|
|
||||||
auto c = mapnik::coord2d(100, 100);
|
|
||||||
c *= 2;
|
|
||||||
|
|
||||||
REQUIRE(c.x == 200);
|
|
||||||
REQUIRE(c.y == 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("envelope init") {
|
SECTION("envelope init") {
|
||||||
auto e = mapnik::box2d<double>(100, 100, 200, 200);
|
auto e = mapnik::box2d<double>(100, 100, 200, 200);
|
||||||
|
@ -171,9 +155,9 @@ SECTION("mapnik::box2d intersects")
|
||||||
mapnik::box2d<double> b2(100.001,100,200,200);
|
mapnik::box2d<double> b2(100.001,100,200,200);
|
||||||
CHECK(!b0.intersects(b2));
|
CHECK(!b0.intersects(b2));
|
||||||
CHECK(!b2.intersects(b0));
|
CHECK(!b2.intersects(b0));
|
||||||
// coord
|
// geometry::point<T>
|
||||||
CHECK(b0.intersects(mapnik::coord<double,2>(100,100)));
|
CHECK(b0.intersects(mapnik::geometry::point<double>(100,100)));
|
||||||
CHECK(!b0.intersects(mapnik::coord<double,2>(100.001,100)));
|
CHECK(!b0.intersects(mapnik::geometry::point<double>(100.001,100)));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("mapnik::box2d intersect")
|
SECTION("mapnik::box2d intersect")
|
||||||
|
@ -192,7 +176,7 @@ SECTION("mapnik::box2d re_center")
|
||||||
mapnik::box2d<double> b(0, 0, 100, 100);
|
mapnik::box2d<double> b(0, 0, 100, 100);
|
||||||
b.re_center(0, 0);
|
b.re_center(0, 0);
|
||||||
CHECK(b == mapnik::box2d<double>(-50, -50, 50, 50));
|
CHECK(b == mapnik::box2d<double>(-50, -50, 50, 50));
|
||||||
b.re_center(mapnik::coord2d(50,50));
|
b.re_center(mapnik::geometry::point<double>(50,50));
|
||||||
CHECK(b == mapnik::box2d<double>(0, 0, 100, 100));
|
CHECK(b == mapnik::box2d<double>(0, 0, 100, 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -283,7 +283,8 @@ TEST_CASE("csv") {
|
||||||
CHECK(count_features(all_features(ds)) == 2);
|
CHECK(count_features(all_features(ds)) == 2);
|
||||||
|
|
||||||
auto fs = all_features(ds);
|
auto fs = all_features(ds);
|
||||||
auto fs2 = ds->features_at_point(ds->envelope().center(),10000);
|
auto pt = ds->envelope().center();
|
||||||
|
auto fs2 = ds->features_at_point(mapnik::coord<double, 2>(pt.x, pt.y), 10000);
|
||||||
REQUIRE(fs != nullptr);
|
REQUIRE(fs != nullptr);
|
||||||
auto feature = fs->next();
|
auto feature = fs->next();
|
||||||
auto feature2 = fs2->next();
|
auto feature2 = fs2->next();
|
||||||
|
|
|
@ -284,7 +284,8 @@ TEST_CASE("geojson") {
|
||||||
query.add_property_name(field.get_name());
|
query.add_property_name(field.get_name());
|
||||||
}
|
}
|
||||||
auto features = ds->features(query);
|
auto features = ds->features(query);
|
||||||
auto features2 = ds->features_at_point(ds->envelope().center(),0);
|
auto pt = ds->envelope().center();
|
||||||
|
auto features2 = ds->features_at_point(mapnik::coord<double, 2>(pt.x, pt.y), 0);
|
||||||
REQUIRE(features != nullptr);
|
REQUIRE(features != nullptr);
|
||||||
REQUIRE(features2 != nullptr);
|
REQUIRE(features2 != nullptr);
|
||||||
auto feature = features->next();
|
auto feature = features->next();
|
||||||
|
@ -341,7 +342,8 @@ TEST_CASE("geojson") {
|
||||||
query.add_property_name(field.get_name());
|
query.add_property_name(field.get_name());
|
||||||
}
|
}
|
||||||
auto features = ds->features(query);
|
auto features = ds->features(query);
|
||||||
auto features2 = ds->features_at_point(ds->envelope().center(),10);
|
auto pt = ds->envelope().center();
|
||||||
|
auto features2 = ds->features_at_point(mapnik::coord<double, 2>(pt.x, pt.y), 10);
|
||||||
auto bounding_box = ds->envelope();
|
auto bounding_box = ds->envelope();
|
||||||
mapnik::box2d<double> bbox;
|
mapnik::box2d<double> bbox;
|
||||||
mapnik::value_integer count = 0;
|
mapnik::value_integer count = 0;
|
||||||
|
|
|
@ -86,8 +86,8 @@ struct main_marker_visitor
|
||||||
pixfmt pixf(buf);
|
pixfmt pixf(buf);
|
||||||
renderer_base renb(pixf);
|
renderer_base renb(pixf);
|
||||||
|
|
||||||
mapnik::box2d<double> const& bbox = marker.get_data()->bounding_box();
|
auto const& bbox = marker.get_data()->bounding_box();
|
||||||
mapnik::coord<double,2> c = bbox.center();
|
auto c = bbox.center();
|
||||||
// center the svg marker on '0,0'
|
// center the svg marker on '0,0'
|
||||||
agg::trans_affine mtx = agg::trans_affine_translation(-c.x, -c.y);
|
agg::trans_affine mtx = agg::trans_affine_translation(-c.x, -c.y);
|
||||||
// render the marker at the center of the marker box
|
// render the marker at the center of the marker box
|
||||||
|
|
Loading…
Reference in a new issue