From b669115b2c7ea87ac672bdfb39f61d24089f5ba3 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 17 Jun 2016 12:46:33 +0200 Subject: [PATCH] remove `coord` usage from box2d --- include/mapnik/box2d.hpp | 14 +- include/mapnik/box2d_impl.hpp | 174 +++++++++--------- include/mapnik/datasource.hpp | 2 +- include/mapnik/geom_util.hpp | 2 +- include/mapnik/marker_helpers.hpp | 2 +- .../process_point_symbolizer.hpp | 4 +- plugins/input/csv/csv_datasource.cpp | 2 +- plugins/input/geojson/geojson_datasource.cpp | 2 +- plugins/input/ogr/ogr_datasource.cpp | 2 +- .../input/topojson/topojson_datasource.cpp | 2 +- src/agg/agg_renderer.cpp | 2 +- src/cairo/cairo_renderer.cpp | 4 +- src/grid/grid_renderer.cpp | 4 +- src/map.cpp | 3 +- src/proj_transform.cpp | 44 ++--- .../render_markers_symbolizer.cpp | 2 +- src/renderer_common/render_pattern.cpp | 6 +- test/data-visual | 2 +- test/unit/core/box2d_test.cpp | 24 +-- test/unit/datasource/csv.cpp | 3 +- test/unit/datasource/geojson.cpp | 6 +- utils/svg2png/svg2png.cpp | 6 +- 22 files changed, 148 insertions(+), 164 deletions(-) diff --git a/include/mapnik/box2d.hpp b/include/mapnik/box2d.hpp index 267120111..7011a5c34 100644 --- a/include/mapnik/box2d.hpp +++ b/include/mapnik/box2d.hpp @@ -25,7 +25,7 @@ // mapnik #include -#include +#include #pragma GCC diagnostic push #include @@ -68,7 +68,7 @@ public: box2d(); box2d(T minx,T miny,T maxx,T maxy); - box2d(coord const& c0, coord const& c1); + box2d(geometry::point const& c0, geometry::point const& c1); box2d(box2d_type const& rhs); box2d(box2d_type const& rhs, agg::trans_affine const& tr); // move @@ -94,20 +94,20 @@ public: T height() const; void width(T w); void height(T h); - coord center() const; + geometry::point center() const; void expand_to_include(T x,T y); - void expand_to_include(coord const& c); + void expand_to_include(geometry::point const& c); void expand_to_include(box2d_type const& other); - bool contains(coord const& c) const; + bool contains(geometry::point const& c) const; bool contains(T x,T y) const; bool contains(box2d_type const& other) const; - bool intersects(coord const& c) const; + bool intersects(geometry::point const& c) const; bool intersects(T x,T y) const; bool intersects(box2d_type const& other) const; box2d_type intersect(box2d_type const& other) const; bool operator==(box2d_type const& other) const; void re_center(T cx,T cy); - void re_center(coord const& c); + void re_center(geometry::point const& c); void init(T x0,T y0,T x1,T y1); void init(T x, T y); void clip(box2d_type const& other); diff --git a/include/mapnik/box2d_impl.hpp b/include/mapnik/box2d_impl.hpp index 7f3e9d1e7..0d5ae7e2b 100644 --- a/include/mapnik/box2d_impl.hpp +++ b/include/mapnik/box2d_impl.hpp @@ -25,17 +25,17 @@ #include // stl -#include -#include #include +#include +#include #include #pragma GCC diagnostic push -#include #include #include #include +#include #pragma GCC diagnostic pop // agg @@ -44,28 +44,26 @@ BOOST_FUSION_ADAPT_TPL_ADT( (T), (mapnik::box2d)(T), - (T, T, obj.minx(), obj.set_minx(mapnik::safe_cast(val))) - (T, T, obj.miny(), obj.set_miny(mapnik::safe_cast(val))) - (T, T, obj.maxx(), obj.set_maxx(mapnik::safe_cast(val))) - (T, T, obj.maxy(), obj.set_maxy(mapnik::safe_cast(val)))) + (T, T, obj.minx(), obj.set_minx(mapnik::safe_cast(val)))(T, T, obj.miny(), obj.set_miny(mapnik::safe_cast(val)))(T, T, obj.maxx(), obj.set_maxx(mapnik::safe_cast(val)))(T, T, obj.maxy(), obj.set_maxy(mapnik::safe_cast(val)))) -namespace mapnik -{ +namespace mapnik { template box2d::box2d() - :minx_( std::numeric_limits::max()), - miny_( std::numeric_limits::max()), - maxx_(-std::numeric_limits::max()), - maxy_(-std::numeric_limits::max()) {} - -template -box2d::box2d(T minx,T miny,T maxx,T maxy) + : minx_(std::numeric_limits::max()), + miny_(std::numeric_limits::max()), + maxx_(-std::numeric_limits::max()), + maxy_(-std::numeric_limits::max()) { - init(minx,miny,maxx,maxy); } template -box2d::box2d(coord const& c0, coord const& c1) +box2d::box2d(T minx, T miny, T maxx, T maxy) +{ + init(minx, miny, maxx, maxy); +} + +template +box2d::box2d(geometry::point const& c0, geometry::point const& c1) { init(c0.x,c0.y,c1.x,c1.y); } @@ -75,14 +73,18 @@ box2d::box2d(box2d_type const& rhs) : minx_(rhs.minx_), miny_(rhs.miny_), maxx_(rhs.maxx_), - maxy_(rhs.maxy_) {} + maxy_(rhs.maxy_) +{ +} template -box2d::box2d(box2d_type && rhs) +box2d::box2d(box2d_type&& rhs) : minx_(std::move(rhs.minx_)), miny_(std::move(rhs.miny_)), maxx_(std::move(rhs.maxx_)), - maxy_(std::move(rhs.maxy_)) {} + maxy_(std::move(rhs.maxy_)) +{ +} template box2d& box2d::operator=(box2d_type other) @@ -111,10 +113,10 @@ box2d::box2d(box2d_type const& rhs, agg::trans_affine const& tr) template bool box2d::operator==(box2d const& other) const { - return minx_==other.minx_ && - miny_==other.miny_ && - maxx_==other.maxx_ && - maxy_==other.maxy_; + return minx_ == other.minx_ && + miny_ == other.miny_ && + maxx_ == other.maxx_ && + maxy_ == other.maxy_; } template @@ -141,25 +143,25 @@ T box2d::maxy() const return maxy_; } -template +template void box2d::set_minx(T v) { minx_ = v; } -template +template void box2d::set_miny(T v) { miny_ = v; } -template +template void box2d::set_maxx(T v) { maxx_ = v; } -template +template void box2d::set_maxy(T v) { maxy_ = v; @@ -168,100 +170,100 @@ void box2d::set_maxy(T v) template T box2d::width() const { - return maxx_-minx_; + return maxx_ - minx_; } template T box2d::height() const { - return maxy_-miny_; + return maxy_ - miny_; } template void box2d::width(T w) { - T cx=center().x; - minx_=static_cast(cx-w*0.5); - maxx_=static_cast(cx+w*0.5); + T cx = center().x; + minx_ = static_cast(cx - w * 0.5); + maxx_ = static_cast(cx + w * 0.5); } template void box2d::height(T h) { - T cy=center().y; - miny_=static_cast(cy-h*0.5); - maxy_=static_cast(cy+h*0.5); + T cy = center().y; + miny_ = static_cast(cy - h * 0.5); + maxy_ = static_cast(cy + h * 0.5); } template -coord box2d::center() const +geometry::point box2d::center() const { - return coord(static_cast(0.5*(minx_+maxx_)), - static_cast(0.5*(miny_+maxy_))); + return geometry::point(static_cast(0.5 * (minx_ + maxx_)), + static_cast(0.5 * (miny_ + maxy_))); } template -void box2d::expand_to_include(coord const& c) +void box2d::expand_to_include(geometry::point const& c) { - expand_to_include(c.x,c.y); + expand_to_include(c.x,c.y); } template -void box2d::expand_to_include(T x,T y) +void box2d::expand_to_include(T x, T y) { - if (xmaxx_) maxx_=x; - if (ymaxy_) maxy_=y; + if (x < minx_) minx_ = x; + if (x > maxx_) maxx_ = x; + if (y < miny_) miny_ = y; + if (y > maxy_) maxy_ = y; } template void box2d::expand_to_include(box2d const& other) { - if (other.minx_maxx_) maxx_=other.maxx_; - if (other.miny_maxy_) maxy_=other.maxy_; + if (other.minx_ < minx_) minx_ = other.minx_; + if (other.maxx_ > maxx_) maxx_ = other.maxx_; + if (other.miny_ < miny_) miny_ = other.miny_; + if (other.maxy_ > maxy_) maxy_ = other.maxy_; } template -bool box2d::contains(coord const& c) const +bool box2d::contains(geometry::point const& c) const { return contains(c.x,c.y); } template -bool box2d::contains(T x,T y) const +bool box2d::contains(T x, T y) const { - return x>=minx_ && x<=maxx_ && y>=miny_ && y<=maxy_; + return x >= minx_ && x <= maxx_ && y >= miny_ && y <= maxy_; } template bool box2d::contains(box2d const& other) const { - return other.minx_>=minx_ && - other.maxx_<=maxx_ && - other.miny_>=miny_ && - other.maxy_<=maxy_; + return other.minx_ >= minx_ && + other.maxx_ <= maxx_ && + other.miny_ >= miny_ && + other.maxy_ <= maxy_; } template -bool box2d::intersects(coord const& c) const +bool box2d::intersects(geometry::point const& c) const { - return intersects(c.x,c.y); + return intersects(c.x,c.y); } template -bool box2d::intersects(T x,T y) const +bool box2d::intersects(T x, T y) const { - return !(x>maxx_ || xmaxy_ || y maxx_ || x < minx_ || y > maxy_ || y < miny_); } template bool box2d::intersects(box2d const& other) const { - return !(other.minx_>maxx_ || other.maxx_maxy_ || other.maxy_ maxx_ || other.maxx_ < minx_ || + other.miny_ > maxy_ || other.maxy_ < miny_); } template @@ -269,11 +271,11 @@ box2d box2d::intersect(box2d_type const& other) const { if (intersects(other)) { - T x0=std::max(minx_,other.minx_); - T y0=std::max(miny_,other.miny_); - T x1=std::min(maxx_,other.maxx_); - T y1=std::min(maxy_,other.maxy_); - return box2d(x0,y0,x1,y1); + T x0 = std::max(minx_, other.minx_); + T y0 = std::max(miny_, other.miny_); + T x1 = std::min(maxx_, other.maxx_); + T y1 = std::min(maxy_, other.maxy_); + return box2d(x0, y0, x1, y1); } else { @@ -282,18 +284,18 @@ box2d box2d::intersect(box2d_type const& other) const } template -void box2d::re_center(T cx,T cy) +void box2d::re_center(T cx, T cy) { - T dx=cx-center().x; - T dy=cy-center().y; - minx_+=dx; - miny_+=dy; - maxx_+=dx; - maxy_+=dy; + T dx = cx - center().x; + T dy = cy - center().y; + minx_ += dx; + miny_ += dy; + maxx_ += dx; + maxy_ += dy; } template -void box2d::re_center(coord const& c) +void box2d::re_center(geometry::point const& c) { re_center(c.x,c.y); } @@ -364,7 +366,7 @@ bool box2d::from_string(std::string const& str) template bool box2d::valid() const { - return (minx_ <= maxx_ && miny_ <= maxy_) ; + return (minx_ <= maxx_ && miny_ <= maxy_); } template @@ -393,22 +395,21 @@ std::string box2d::to_string() const return s.str(); } - template -box2d& box2d::operator+=(box2d const& other) +box2d& box2d::operator+=(box2d const& other) { expand_to_include(other); return *this; } template -box2d box2d::operator+ (T other) const +box2d box2d::operator+(T other) const { return box2d(minx_ - other, miny_ - other, maxx_ + other, maxy_ + other); } template -box2d& box2d::operator+= (T other) +box2d& box2d::operator+=(T other) { minx_ -= other; miny_ -= other; @@ -417,11 +418,10 @@ box2d& box2d::operator+= (T other) return *this; } - template box2d& box2d::operator*=(T t) { - coord c = center(); + geometry::point c = center(); T sx = static_cast(0.5 * width() * t); T sy = static_cast(0.5 * height() * t); minx_ = c.x - sx; @@ -434,7 +434,7 @@ box2d& box2d::operator*=(T t) template box2d& box2d::operator/=(T t) { - coord c = center(); + geometry::point c = center(); T sx = static_cast(0.5 * width() / t); T sy = static_cast(0.5 * height() / t); minx_ = c.x - sx; @@ -445,9 +445,9 @@ box2d& box2d::operator/=(T t) } template -T box2d::operator[] (int index) const +T box2d::operator[](int index) const { - switch(index) + switch (index) { case 0: return minx_; diff --git a/include/mapnik/datasource.hpp b/include/mapnik/datasource.hpp index ec14a621c..23b99390a 100644 --- a/include/mapnik/datasource.hpp +++ b/include/mapnik/datasource.hpp @@ -33,7 +33,7 @@ #include #include #include - +#include // stl #include #include diff --git a/include/mapnik/geom_util.hpp b/include/mapnik/geom_util.hpp index 7dbe51ff4..30c9f778e 100644 --- a/include/mapnik/geom_util.hpp +++ b/include/mapnik/geom_util.hpp @@ -212,7 +212,7 @@ struct filter_at_point { box2d box_; 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); } diff --git a/include/mapnik/marker_helpers.hpp b/include/mapnik/marker_helpers.hpp index 8ba3c6f4b..bab011a3e 100644 --- a/include/mapnik/marker_helpers.hpp +++ b/include/mapnik/marker_helpers.hpp @@ -93,7 +93,7 @@ struct vector_markers_dispatch : util::noncopyable protected: 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); } diff --git a/include/mapnik/renderer_common/process_point_symbolizer.hpp b/include/mapnik/renderer_common/process_point_symbolizer.hpp index ef0863fd6..050f780ee 100644 --- a/include/mapnik/renderer_common/process_point_symbolizer.hpp +++ b/include/mapnik/renderer_common/process_point_symbolizer.hpp @@ -56,8 +56,8 @@ void render_point_symbolizer(point_symbolizer const &sym, value_bool ignore_placement = get(sym, feature, common.vars_); point_placement_enum placement= get(sym, feature, common.vars_); - box2d const& bbox = mark->bounding_box(); - coord2d center = bbox.center(); + auto const& bbox = mark->bounding_box(); + auto center = bbox.center(); agg::trans_affine tr; auto image_transform = get_optional(sym, keys::image_transform); diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index 6c1ff1014..36c10d7d0 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -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::box2d query_bbox(pt, pt); + mapnik::box2d query_bbox(pt.x, pt.y, pt.x, pt.y); query_bbox.pad(tol); mapnik::query q(query_bbox); std::vector const& desc = desc_.get_descriptors(); diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp index e9456f8e1..fa16cb7b5 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -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::box2d query_bbox(pt, pt); + mapnik::box2d query_bbox(pt.x, pt.y, pt.x, pt.y); query_bbox.pad(tol); mapnik::query q(query_bbox); for (auto const& attr_info : desc_.get_descriptors()) diff --git a/plugins/input/ogr/ogr_datasource.cpp b/plugins/input/ogr/ogr_datasource.cpp index dc0fc9bec..8bdb929b5 100644 --- a/plugins/input/ogr/ogr_datasource.cpp +++ b/plugins/input/ogr/ogr_datasource.cpp @@ -594,7 +594,7 @@ featureset_ptr ogr_datasource::features_at_point(coord2d const& pt, double tol) } else { - mapnik::box2d bbox(pt, pt); + mapnik::box2d bbox(pt.x, pt.y, pt.x, pt.y); bbox.pad(tol); return featureset_ptr(new ogr_featureset (ctx, *layer, diff --git a/plugins/input/topojson/topojson_datasource.cpp b/plugins/input/topojson/topojson_datasource.cpp index 502868562..842fd64e7 100644 --- a/plugins/input/topojson/topojson_datasource.cpp +++ b/plugins/input/topojson/topojson_datasource.cpp @@ -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::box2d query_bbox(pt, pt); + mapnik::box2d query_bbox(pt.x, pt.y, pt.x, pt.y); query_bbox.pad(tol); mapnik::query q(query_bbox); for (auto const& attr_info : desc_.get_descriptors()) diff --git a/src/agg/agg_renderer.cpp b/src/agg/agg_renderer.cpp index f144ceaad..7acb44e44 100644 --- a/src/agg/agg_renderer.cpp +++ b/src/agg/agg_renderer.cpp @@ -395,7 +395,7 @@ struct agg_render_marker_visitor renderer_base renb(pixf); box2d const& bbox = marker.get_data()->bounding_box(); - coord c = bbox.center(); + auto c = bbox.center(); // center the svg marker on '0,0' agg::trans_affine mtx = agg::trans_affine_translation(-c.x,-c.y); // apply symbol transformation to get to map space diff --git a/src/cairo/cairo_renderer.cpp b/src/cairo/cairo_renderer.cpp index 83e1208b1..035948abb 100644 --- a/src/cairo/cairo_renderer.cpp +++ b/src/cairo/cairo_renderer.cpp @@ -228,8 +228,8 @@ struct cairo_render_marker_visitor agg::trans_affine marker_tr = tr_; if (recenter_) { - coord c = bbox.center(); - marker_tr = agg::trans_affine_translation(-c.x,-c.y); + auto c = bbox.center(); + marker_tr = agg::trans_affine_translation(-c.x, -c.y); marker_tr *= tr_; } marker_tr *= agg::trans_affine_scaling(common_.scale_factor_); diff --git a/src/grid/grid_renderer.cpp b/src/grid/grid_renderer.cpp index fd970f580..057d477e3 100644 --- a/src/grid/grid_renderer.cpp +++ b/src/grid/grid_renderer.cpp @@ -163,8 +163,8 @@ struct grid_render_marker_visitor ras_ptr_->reset(); - box2d const& bbox = marker.get_data()->bounding_box(); - coord c = bbox.center(); + auto const& bbox = marker.get_data()->bounding_box(); + auto c = bbox.center(); // center the svg marker on '0,0' agg::trans_affine mtx = agg::trans_affine_translation(-c.x,-c.y); // apply symbol transformation to get to map space diff --git a/src/map.cpp b/src/map.cpp index 3aff557c4..2a9704936 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -41,6 +41,7 @@ #include #include #include +#include // stl #include @@ -499,7 +500,7 @@ void Map::set_base_path(std::string const& base) void Map::zoom(double factor) { - coord2d center = current_extent_.center(); + auto center = current_extent_.center(); double w = factor * current_extent_.width(); double h = factor * current_extent_.height(); current_extent_ = box2d(center.x - 0.5 * w, diff --git a/src/proj_transform.cpp b/src/proj_transform.cpp index 9c23d805a..6e5fe79c6 100644 --- a/src/proj_transform.cpp +++ b/src/proj_transform.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #ifdef MAPNIK_USE_PROJ4 @@ -335,7 +334,7 @@ bool proj_transform::backward (box2d & box) const } // Returns points in clockwise order. This allows us to do anti-meridian checks. -void envelope_points(std::vector< coord > & coords, box2d& env, int points) +void envelope_points(std::vector> & coords, box2d& env, int points) { double width = env.width(); double height = env.height(); @@ -353,21 +352,22 @@ void envelope_points(std::vector< coord > & coords, box2d& env double ystep = height / steps; coords.resize(points); - for (int i=0; iright - coords[i] = coord(env.minx() + i * xstep, env.maxy()); + coords[i] = geometry::point(env.minx() + i * xstep, env.maxy()); // right: top>bottom - coords[i + steps] = coord(env.maxx(), env.maxy() - i * ystep); + coords[i + steps] = geometry::point(env.maxx(), env.maxy() - i * ystep); // bottom: right>left - coords[i + steps * 2] = coord(env.maxx() - i * xstep, env.miny()); + coords[i + steps * 2] = geometry::point(env.maxx() - i * xstep, env.miny()); // left: bottom>top - coords[i + steps * 3] = coord(env.minx(), env.miny() + i * ystep); + coords[i + steps * 3] = geometry::point(env.minx(), env.miny() + i * ystep); } } -box2d calculate_bbox(std::vector > & points) { - std::vector >::iterator it = points.begin(); - std::vector >::iterator it_end = points.end(); +box2d calculate_bbox(std::vector > & points) { + std::vector >::iterator it = points.begin(); + std::vector >::iterator it_end = points.end(); box2d env(*it, *(++it)); for (; it!=it_end; ++it) { @@ -393,15 +393,13 @@ bool proj_transform::backward(box2d& env, int points) const return backward(env); } - std::vector > coords; + std::vector> coords; envelope_points(coords, env, points); // this is always clockwise - double z; - for (std::vector >::iterator it = coords.begin(); it!=coords.end(); ++it) { - z = 0; - if (!backward(it->x, it->y, z)) { - return false; - } + for (auto & pt : coords) + { + double z = 0; + if (!backward(pt.x, pt.y, z)) return false; } box2d result = calculate_bbox(coords); @@ -432,15 +430,13 @@ bool proj_transform::forward(box2d& env, int points) const return forward(env); } - std::vector > coords; + std::vector> coords; envelope_points(coords, env, points); // this is always clockwise - double z; - for (std::vector >::iterator it = coords.begin(); it!=coords.end(); ++it) { - z = 0; - if (!forward(it->x, it->y, z)) { - return false; - } + for (auto & pt : coords) + { + double z = 0; + if (!forward(pt.x, pt.y, z)) return false; } box2d result = calculate_bbox(coords); diff --git a/src/renderer_common/render_markers_symbolizer.cpp b/src/renderer_common/render_markers_symbolizer.cpp index 6706cb1cd..69e332447 100644 --- a/src/renderer_common/render_markers_symbolizer.cpp +++ b/src/renderer_common/render_markers_symbolizer.cpp @@ -187,7 +187,7 @@ struct render_marker_symbolizer_visitor box2d const& bbox = mark.bounding_box(); mapnik::image_rgba8 const& marker = mark.get_data(); // - 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 marker_trans = recenter * image_tr; raster_dispatch_type rasterizer_dispatch(marker, diff --git a/src/renderer_common/render_pattern.cpp b/src/renderer_common/render_pattern.cpp index 5e6f95820..f87c71832 100644 --- a/src/renderer_common/render_pattern.cpp +++ b/src/renderer_common/render_pattern.cpp @@ -52,9 +52,9 @@ void render_pattern(rasterizer & ras, using renderer_solid = agg::renderer_scanline_aa_solid; agg::scanline_u8 sl; - mapnik::box2d const& bbox = marker.bounding_box() * tr; - mapnik::coord c = bbox.center(); - agg::trans_affine mtx = agg::trans_affine_translation(-c.x,-c.y); + auto const& bbox = marker.bounding_box() * tr; + auto c = bbox.center(); + agg::trans_affine mtx = agg::trans_affine_translation(-c.x, -c.y); mtx.translate(0.5 * bbox.width(), 0.5 * bbox.height()); mtx = tr * mtx; diff --git a/test/data-visual b/test/data-visual index 5f0e6f866..047985797 160000 --- a/test/data-visual +++ b/test/data-visual @@ -1 +1 @@ -Subproject commit 5f0e6f86696a2a9a6733e42b1f400ba4ec2f8847 +Subproject commit 047985797ab11ea34ac97e469d0871b6220ea4d3 diff --git a/test/unit/core/box2d_test.cpp b/test/unit/core/box2d_test.cpp index 8385bba7c..c4a8c968f 100644 --- a/test/unit/core/box2d_test.cpp +++ b/test/unit/core/box2d_test.cpp @@ -1,25 +1,9 @@ - #include "catch.hpp" -#include #include #include "agg_trans_affine.h" 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") { auto e = mapnik::box2d(100, 100, 200, 200); @@ -171,9 +155,9 @@ SECTION("mapnik::box2d intersects") mapnik::box2d b2(100.001,100,200,200); CHECK(!b0.intersects(b2)); CHECK(!b2.intersects(b0)); - // coord - CHECK(b0.intersects(mapnik::coord(100,100))); - CHECK(!b0.intersects(mapnik::coord(100.001,100))); + // geometry::point + CHECK(b0.intersects(mapnik::geometry::point(100,100))); + CHECK(!b0.intersects(mapnik::geometry::point(100.001,100))); } SECTION("mapnik::box2d intersect") @@ -192,7 +176,7 @@ SECTION("mapnik::box2d re_center") mapnik::box2d b(0, 0, 100, 100); b.re_center(0, 0); CHECK(b == mapnik::box2d(-50, -50, 50, 50)); - b.re_center(mapnik::coord2d(50,50)); + b.re_center(mapnik::geometry::point(50,50)); CHECK(b == mapnik::box2d(0, 0, 100, 100)); } diff --git a/test/unit/datasource/csv.cpp b/test/unit/datasource/csv.cpp index 6142185ca..76490fe1a 100644 --- a/test/unit/datasource/csv.cpp +++ b/test/unit/datasource/csv.cpp @@ -283,7 +283,8 @@ TEST_CASE("csv") { CHECK(count_features(all_features(ds)) == 2); 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(pt.x, pt.y), 10000); REQUIRE(fs != nullptr); auto feature = fs->next(); auto feature2 = fs2->next(); diff --git a/test/unit/datasource/geojson.cpp b/test/unit/datasource/geojson.cpp index 1edeb4b55..f833ddfd3 100644 --- a/test/unit/datasource/geojson.cpp +++ b/test/unit/datasource/geojson.cpp @@ -284,7 +284,8 @@ TEST_CASE("geojson") { query.add_property_name(field.get_name()); } 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(pt.x, pt.y), 0); REQUIRE(features != nullptr); REQUIRE(features2 != nullptr); auto feature = features->next(); @@ -341,7 +342,8 @@ TEST_CASE("geojson") { query.add_property_name(field.get_name()); } 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(pt.x, pt.y), 10); auto bounding_box = ds->envelope(); mapnik::box2d bbox; mapnik::value_integer count = 0; diff --git a/utils/svg2png/svg2png.cpp b/utils/svg2png/svg2png.cpp index b78f53b16..4554d9693 100644 --- a/utils/svg2png/svg2png.cpp +++ b/utils/svg2png/svg2png.cpp @@ -86,10 +86,10 @@ struct main_marker_visitor pixfmt pixf(buf); renderer_base renb(pixf); - mapnik::box2d const& bbox = marker.get_data()->bounding_box(); - mapnik::coord c = bbox.center(); + auto const& bbox = marker.get_data()->bounding_box(); + auto c = bbox.center(); // 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 mtx.translate(0.5 * im.width(), 0.5 * im.height());