Permalink
Browse files

+ update rendering code to work with new labeling methods

+ rename num_points() to size()
+ rename get_vertex() to vertex()
  • Loading branch information...
1 parent 9e1914a commit 7b10400be9b50872a785e34eaab4f5a5804598b5 @artemp artemp committed Jul 19, 2012
@@ -200,13 +200,13 @@ void MapWidget::mousePressEvent(QMouseEvent* e)
{
mapnik::geometry_type & geom = feat->get_geometry(i);
path_type path(t,geom,prj_trans);
- if (geom.num_points() > 0)
+ if (geom.size() > 0)
{
QPainterPath qpath;
double x,y;
path.vertex(&x,&y);
qpath.moveTo(x,y);
- for (unsigned j = 1; j < geom.num_points(); ++j)
+ for (unsigned j = 1; j < geom.size(); ++j)
{
path.vertex(&x,&y);
qpath.lineTo(x,y);
@@ -25,6 +25,9 @@
// mapnik
#include <mapnik/feature.hpp>
+#include <mapnik/geom_util.hpp>
+// boost
+#include <boost/foreach.hpp>
namespace mapnik {
class hit_test_filter
@@ -35,12 +38,11 @@ class hit_test_filter
y_(y),
tol_(tol) {}
- bool pass(Feature const& feature)
+ bool pass(Feature & feature)
{
- for (unsigned i=0;i<feature.num_geometries();++i)
+ BOOST_FOREACH(geometry_type & geom, feature.paths())
{
- geometry_type const& geom = feature.get_geometry(i);
- if (geom.hit_test(x_,y_,tol_))
+ if (hit_test(geom, x_,y_,tol_))
return true;
}
return false;
@@ -78,7 +78,7 @@ struct get_first
geometry_type::value_type const operator() (geometry_type const& geom) const
{
geometry_type::value_type coord;
- boost::get<0>(coord) = geom.get_vertex(0,&boost::get<1>(coord),&boost::get<2>(coord));
+ boost::get<0>(coord) = geom.vertex(0,&boost::get<1>(coord),&boost::get<2>(coord));
return coord;
}
};
@@ -66,7 +66,7 @@ namespace mapnik { namespace util {
geometry_type::value_type const operator() (geometry_type const& geom) const
{
geometry_type::value_type coord;
- boost::get<0>(coord) = geom.get_vertex(0,&boost::get<1>(coord),&boost::get<2>(coord));
+ boost::get<0>(coord) = geom.vertex(0,&boost::get<1>(coord),&boost::get<2>(coord));
return coord;
}
};
@@ -119,15 +119,15 @@ namespace mapnik { namespace util {
wkb_buffer_ptr to_point_wkb( geometry_type const& g, wkbByteOrder byte_order)
{
- assert(g.num_points() == 1);
+ assert(g.size() == 1);
std::size_t size = 1 + 4 + 8*2 ; // byteOrder + wkbType + Point
wkb_buffer_ptr wkb = boost::make_shared<wkb_buffer>(size);
boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary);
ss.write(reinterpret_cast<char*>(&byte_order),1);
int type = static_cast<int>(mapnik::Point);
write(ss,type,4,byte_order);
double x,y;
- g.get_vertex(0,&x,&y);
+ g.vertex(0,&x,&y);
write(ss,x,8,byte_order);
write(ss,y,8,byte_order);
assert(ss.good());
@@ -136,7 +136,7 @@ namespace mapnik { namespace util {
wkb_buffer_ptr to_line_string_wkb( geometry_type const& g, wkbByteOrder byte_order)
{
- unsigned num_points = g.num_points();
+ unsigned num_points = g.size();
assert(num_points > 1);
std::size_t size = 1 + 4 + 4 + 8*2*num_points ; // byteOrder + wkbType + numPoints + Point*numPoints
wkb_buffer_ptr wkb = boost::make_shared<wkb_buffer>(size);
@@ -148,7 +148,7 @@ namespace mapnik { namespace util {
double x,y;
for (unsigned i=0; i< num_points; ++i)
{
- g.get_vertex(i,&x,&y);
+ g.vertex(i,&x,&y);
write(ss,x,8,byte_order);
write(ss,y,8,byte_order);
}
@@ -158,7 +158,7 @@ namespace mapnik { namespace util {
wkb_buffer_ptr to_polygon_wkb( geometry_type const& g, wkbByteOrder byte_order)
{
- unsigned num_points = g.num_points();
+ unsigned num_points = g.size();
assert(num_points > 1);
typedef std::pair<double,double> point_type;
@@ -169,7 +169,7 @@ namespace mapnik { namespace util {
std::size_t size = 1 + 4 + 4 ; // byteOrder + wkbType + numRings
for (unsigned i=0; i< num_points; ++i)
{
- unsigned command = g.get_vertex(i,&x,&y);
+ unsigned command = g.vertex(i,&x,&y);
if (command == SEG_MOVETO)
{
rings.push_back(new linear_ring); // start new loop
@@ -79,7 +79,7 @@ namespace mapnik { namespace util {
geometry_type::value_type const operator() (geometry_type const& geom) const
{
geometry_type::value_type coord;
- boost::get<0>(coord) = geom.get_vertex(0,&boost::get<1>(coord),&boost::get<2>(coord));
+ boost::get<0>(coord) = geom.vertex(0,&boost::get<1>(coord),&boost::get<2>(coord));
return coord;
}
};
@@ -63,7 +63,7 @@ namespace mapnik { namespace util {
void increment()
{
- boost::get<0>(v_) = vertices_->get_vertex(pos_++, &boost::get<1>(v_), &boost::get<2>(v_));
+ boost::get<0>(v_) = vertices_->vertex(pos_++, &boost::get<1>(v_), &boost::get<2>(v_));
}
bool equal( vertex_iterator const& other) const
@@ -105,7 +105,7 @@ class vertex_vector : private boost::noncopyable
*vertex = y;
++pos_;
}
- unsigned get_vertex(unsigned pos,coord_type* x,coord_type* y) const
+ unsigned vertex(unsigned pos,coord_type* x,coord_type* y) const
{
if (pos >= pos_) return SEG_END;
unsigned block = pos >> block_shift;
@@ -77,7 +77,7 @@ void agg_renderer<T>::process(building_symbolizer const& sym,
for (unsigned i=0;i<feature.num_geometries();++i)
{
geometry_type const& geom = feature.get_geometry(i);
- if (geom.num_points() > 2)
+ if (geom.size() > 2)
{
boost::scoped_ptr<geometry_type> frame(new geometry_type(LineString));
boost::scoped_ptr<geometry_type> roof(new geometry_type(Polygon));
@@ -87,7 +87,7 @@ void agg_renderer<T>::process(building_symbolizer const& sym,
geom.rewind(0);
unsigned cm = geom.vertex(&x0,&y0);
- for (unsigned j=1;j<geom.num_points();++j)
+ for (unsigned j=1;j<geom.size();++j)
{
double x(0);
double y(0);
@@ -126,7 +126,7 @@ void agg_renderer<T>::process(building_symbolizer const& sym,
}
geom.rewind(0);
- for (unsigned j=0;j<geom.num_points();++j)
+ for (unsigned j=0;j<geom.size();++j)
{
double x,y;
unsigned cm = geom.vertex(&x,&y);
@@ -108,7 +108,7 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
BOOST_FOREACH(geometry_type & geom, feature.paths())
{
- if (geom.num_points() > 1)
+ if (geom.size() > 1)
{
converter.apply(geom);
}
@@ -109,7 +109,7 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
BOOST_FOREACH( geometry_type & geom, feature.paths())
{
- if (geom.num_points() > 1)
+ if (geom.size() > 1)
{
converter.apply(geom);
}
@@ -132,7 +132,7 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
BOOST_FOREACH( geometry_type & geom, feature.paths())
{
- if (geom.num_points() > 1)
+ if (geom.size() > 1)
{
converter.apply(geom);
}
@@ -23,6 +23,7 @@
// mapnik
#include <mapnik/agg_renderer.hpp>
#include <mapnik/agg_rasterizer.hpp>
+#include <mapnik/geom_util.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/metawriter.hpp>
#include <mapnik/marker.hpp>
@@ -81,9 +82,9 @@ void agg_renderer<T>::process(point_symbolizer const& sym,
double y;
double z=0;
if (sym.get_point_placement() == CENTROID_POINT_PLACEMENT)
- geom.label_position(&x, &y);
+ centroid(geom, x, y);
else
- geom.label_interior_position(&x, &y);
+ label_interior_position(geom ,x, y);
prj_trans.backward(x,y,z);
t_.forward(&x,&y);
@@ -151,7 +151,7 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
BOOST_FOREACH( geometry_type & geom, feature.paths())
{
- if (geom.num_points() > 2)
+ if (geom.size() > 2)
{
converter.apply(geom);
}
@@ -65,7 +65,7 @@ void agg_renderer<T>::process(polygon_symbolizer const& sym,
BOOST_FOREACH( geometry_type & geom, feature.paths())
{
- if (geom.num_points() > 2)
+ if (geom.size() > 2)
{
converter.apply(geom);
}
View
@@ -854,7 +854,7 @@ void cairo_renderer_base::process(polygon_symbolizer const& sym,
BOOST_FOREACH( geometry_type & geom, feature.paths())
{
- if (geom.num_points() > 2)
+ if (geom.size() > 2)
{
converter.apply(geom);
}
@@ -884,7 +884,7 @@ void cairo_renderer_base::process(building_symbolizer const& sym,
{
geometry_type const& geom = feature.get_geometry(i);
- if (geom.num_points() > 2)
+ if (geom.size() > 2)
{
boost::scoped_ptr<geometry_type> frame(new geometry_type(LineString));
boost::scoped_ptr<geometry_type> roof(new geometry_type(Polygon));
@@ -895,7 +895,7 @@ void cairo_renderer_base::process(building_symbolizer const& sym,
geom.rewind(0);
unsigned cm = geom.vertex(&x0, &y0);
- for (unsigned j = 1; j < geom.num_points(); ++j)
+ for (unsigned j = 1; j < geom.size(); ++j)
{
double x=0;
double y=0;
@@ -942,7 +942,7 @@ void cairo_renderer_base::process(building_symbolizer const& sym,
}
geom.rewind(0);
- for (unsigned j = 0; j < geom.num_points(); ++j)
+ for (unsigned j = 0; j < geom.size(); ++j)
{
double x, y;
unsigned cm = geom.vertex(&x, &y);
@@ -1008,7 +1008,7 @@ void cairo_renderer_base::process(line_symbolizer const& sym,
BOOST_FOREACH( geometry_type & geom, feature.paths())
{
- if (geom.num_points() > 1)
+ if (geom.size() > 1)
{
converter.apply(geom);
}
@@ -1158,9 +1158,9 @@ void cairo_renderer_base::process(point_symbolizer const& sym,
double z = 0;
if (sym.get_point_placement() == CENTROID_POINT_PLACEMENT)
- geom.label_position(&x, &y);
+ centroid(geom, x, y);
else
- geom.label_interior_position(&x, &y);
+ label_interior_position(geom, x, y);
prj_trans.backward(x, y, z);
t_.forward(&x, &y);
@@ -1236,7 +1236,7 @@ void cairo_renderer_base::process(line_pattern_symbolizer const& sym,
{
geometry_type & geom = feature.get_geometry(i);
- if (geom.num_points() > 1)
+ if (geom.size() > 1)
{
clipped_geometry_type clipped(geom);
clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy());
@@ -1316,7 +1316,7 @@ void cairo_renderer_base::process(polygon_pattern_symbolizer const& sym,
BOOST_FOREACH( geometry_type & geom, feature.paths())
{
- if (geom.num_points() > 2)
+ if (geom.size() > 2)
{
converter.apply(geom);
}
@@ -1433,12 +1433,12 @@ void cairo_renderer_base::process(markers_symbolizer const& sym,
{
geometry_type & geom = feature.get_geometry(i);
// TODO - merge this code with point_symbolizer rendering
- if (placement_method == MARKER_POINT_PLACEMENT || geom.num_points() <= 1)
+ if (placement_method == MARKER_POINT_PLACEMENT || geom.size() <= 1)
{
double x;
double y;
double z=0;
- geom.label_interior_position(&x, &y);
+ label_interior_position(geom, x, y);
prj_trans.backward(x,y,z);
t_.forward(&x,&y);
extent.re_center(x,y);
@@ -1448,9 +1448,8 @@ void cairo_renderer_base::process(markers_symbolizer const& sym,
{
render_marker(pixel_position(x - 0.5 * w, y - 0.5 * h) ,**mark, tr, sym.get_opacity());
- // TODO - impl this for markers?
- //if (!sym.get_ignore_placement())
- // detector_.insert(label_ext);
+ if (!sym.get_ignore_placement())
+ detector_.insert(extent);
}
}
else
@@ -70,15 +70,15 @@ void grid_renderer<T>::process(building_symbolizer const& sym,
for (unsigned i=0;i<feature.num_geometries();++i)
{
geometry_type & geom = feature.get_geometry(i);
- if (geom.num_points() > 2)
+ if (geom.size() > 2)
{
boost::scoped_ptr<geometry_type> frame(new geometry_type(LineString));
boost::scoped_ptr<geometry_type> roof(new geometry_type(Polygon));
std::deque<segment_t> face_segments;
double x0(0);
double y0(0);
unsigned cm = geom.vertex(&x0,&y0);
- for (unsigned j=1;j<geom.num_points();++j)
+ for (unsigned j=1;j<geom.size();++j)
{
double x(0);
double y(0);
@@ -117,7 +117,7 @@ void grid_renderer<T>::process(building_symbolizer const& sym,
}
geom.rewind(0);
- for (unsigned j=0;j<geom.num_points();++j)
+ for (unsigned j=0;j<geom.size();++j)
{
double x,y;
unsigned cm = geom.vertex(&x,&y);
@@ -64,7 +64,7 @@ void grid_renderer<T>::process(line_pattern_symbolizer const& sym,
for (unsigned i=0;i<feature.num_geometries();++i)
{
geometry_type & geom = feature.get_geometry(i);
- if (geom.num_points() > 1)
+ if (geom.size() > 1)
{
path_type path(t_,geom,prj_trans);
agg::conv_stroke<path_type> stroke(path);
@@ -84,7 +84,7 @@ void grid_renderer<T>::process(line_symbolizer const& sym,
BOOST_FOREACH( geometry_type & geom, feature.paths())
{
- if (geom.num_points() > 1)
+ if (geom.size() > 1)
{
converter.apply(geom);
}
@@ -123,12 +123,12 @@ void grid_renderer<T>::process(markers_symbolizer const& sym,
BOOST_FOREACH( geometry_type & geom, feature.paths())
{
// TODO - merge this code with point_symbolizer rendering
- if (placement_method == MARKER_POINT_PLACEMENT || geom.num_points() <= 1)
+ if (placement_method == MARKER_POINT_PLACEMENT || geom.size() <= 1)
{
double x;
double y;
double z=0;
- geom.label_interior_position(&x, &y);
+ label_interior_position(geom, x, y);
prj_trans.backward(x,y,z);
t_.forward(&x,&y);
geom_tr.transform(&x,&y);
Oops, something went wrong.

0 comments on commit 7b10400

Please sign in to comment.