artemp/mapnik — Issue #560: Regression introduced in [1791]
Author: artemp
Created: 2011-10-11 16:25:36+00:00
State: open
Labels: Core_Library

Hello!

The changes introduced in [1791] have caused a regression in the "query_point" functionality of the gdal plugin causing test_dataraster_query_point to fail (see: [source:trunk/tests/python_tests/raster_symbolizer_test.py]).

Apparently this is caused because {{{point<....>::hit_test}}} is never called since the point_impl (as well as linestring_impl) typedefs are now equivalent to a polygon_impl (hence {{{polygon<....>::hit_test}}}) is called instead.

The following diff fixes it:

{{{
#!diff
Index: include/mapnik/geometry.hpp
===================================================================
--- include/mapnik/geometry.hpp (revision 1844)
+++ include/mapnik/geometry.hpp (working copy)
@@ -276,9 +276,16 @@
itr_=0;
}

- bool hit_test(value_type x,value_type y, double) const
+ bool hit_test(value_type x,value_type y, double tol) const
{
- return point_inside_path(x,y,cont_.begin(),cont_.end());
+ if (cont_.size() > 1) {
+ return point_inside_path(x,y,cont_.begin(),cont_.end());
+ } else if (cont_.size() == 1) {
+ // Handle points
+ double x0=boost::get<0>(*cont_.begin());
+ double y0=boost::get<1>(*cont_.begin());
+ return distance(x, y, x0, y0) <= abs(tol);
+ }
}

void set_capacity(size_t size)
}}}

But I havent' committed it since I'm no way near being sure it is the right approach since I don't know where geometry.hpp is heading to. perhaps point and linestring are being deprecated in favor of polygons?

Alberto