Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

+ update rendering code to work with new labeling methods

+ rename num_points() to size()
+ rename get_vertex() to vertex()
  • Loading branch information...
commit 7b10400be9b50872a785e34eaab4f5a5804598b5 1 parent 9e1914a
@artemp artemp authored
Showing with 60 additions and 57 deletions.
  1. +2 −2 demo/viewer/mapwidget.cpp
  2. +6 −4 include/mapnik/hit_test_filter.hpp
  3. +1 −1  include/mapnik/json/geometry_generator_grammar.hpp
  4. +1 −1  include/mapnik/util/geometry_svg_generator.hpp
  5. +6 −6 include/mapnik/util/geometry_to_wkb.hpp
  6. +1 −1  include/mapnik/util/geometry_wkt_generator.hpp
  7. +1 −1  include/mapnik/util/vertex_iterator.hpp
  8. +1 −1  include/mapnik/vertex_vector.hpp
  9. +3 −3 src/agg/process_building_symbolizer.cpp
  10. +1 −1  src/agg/process_line_pattern_symbolizer.cpp
  11. +2 −2 src/agg/process_line_symbolizer.cpp
  12. +3 −2 src/agg/process_point_symbolizer.cpp
  13. +1 −1  src/agg/process_polygon_pattern_symbolizer.cpp
  14. +1 −1  src/agg/process_polygon_symbolizer.cpp
  15. +13 −14 src/cairo_renderer.cpp
  16. +3 −3 src/grid/process_building_symbolizer.cpp
  17. +1 −1  src/grid/process_line_pattern_symbolizer.cpp
  18. +1 −1  src/grid/process_line_symbolizer.cpp
  19. +2 −2 src/grid/process_markers_symbolizer.cpp
  20. +3 −2 src/grid/process_point_symbolizer.cpp
  21. +1 −1  src/grid/process_polygon_pattern_symbolizer.cpp
  22. +1 −1  src/grid/process_polygon_symbolizer.cpp
  23. +1 −1  src/svg/process_symbolizers.cpp
  24. +4 −4 src/symbolizer_helpers.cpp
View
4 demo/viewer/mapwidget.cpp
@@ -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);
View
10 include/mapnik/hit_test_filter.hpp
@@ -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;
View
2  include/mapnik/json/geometry_generator_grammar.hpp
@@ -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;
}
};
View
2  include/mapnik/util/geometry_svg_generator.hpp
@@ -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;
}
};
View
12 include/mapnik/util/geometry_to_wkb.hpp
@@ -119,7 +119,7 @@ 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);
@@ -127,7 +127,7 @@ namespace mapnik { namespace util {
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
View
2  include/mapnik/util/geometry_wkt_generator.hpp
@@ -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;
}
};
View
2  include/mapnik/util/vertex_iterator.hpp
@@ -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
View
2  include/mapnik/vertex_vector.hpp
@@ -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;
View
6 src/agg/process_building_symbolizer.cpp
@@ -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);
View
2  src/agg/process_line_pattern_symbolizer.cpp
@@ -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);
}
View
4 src/agg/process_line_symbolizer.cpp
@@ -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);
}
View
5 src/agg/process_point_symbolizer.cpp
@@ -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);
View
2  src/agg/process_polygon_pattern_symbolizer.cpp
@@ -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);
}
View
2  src/agg/process_polygon_symbolizer.cpp
@@ -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
27 src/cairo_renderer.cpp
@@ -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
View
6 src/grid/process_building_symbolizer.cpp
@@ -70,7 +70,7 @@ 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));
@@ -78,7 +78,7 @@ void grid_renderer<T>::process(building_symbolizer const& sym,
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);
View
2  src/grid/process_line_pattern_symbolizer.cpp
@@ -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);
View
2  src/grid/process_line_symbolizer.cpp
@@ -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);
}
View
4 src/grid/process_markers_symbolizer.cpp
@@ -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);
View
5 src/grid/process_point_symbolizer.cpp
@@ -26,6 +26,7 @@
#include <mapnik/grid/grid_pixfmt.hpp>
#include <mapnik/grid/grid_pixel.hpp>
#include <mapnik/grid/grid.hpp>
+#include <mapnik/geom_util.hpp>
#include <mapnik/point_symbolizer.hpp>
#include <mapnik/expression_evaluator.hpp>
#include <mapnik/marker.hpp>
@@ -73,9 +74,9 @@ void grid_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);
View
2  src/grid/process_polygon_pattern_symbolizer.cpp
@@ -60,7 +60,7 @@ void grid_renderer<T>::process(polygon_pattern_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)
{
path_type path(t_,geom,prj_trans);
ras_ptr->add_path(path);
View
2  src/grid/process_polygon_symbolizer.cpp
@@ -68,7 +68,7 @@ void grid_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
2  src/svg/process_symbolizers.cpp
@@ -46,7 +46,7 @@ bool svg_renderer<OutputIterator>::process(rule::symbolizers const& syms,
for(unsigned i=0; i<feature.num_geometries(); ++i)
{
geometry_type const& geom = feature.get_geometry(i);
- if(geom.num_points() > 1)
+ if(geom.size() > 1)
{
path_type path(t_, geom, prj_trans);
generator_.generate_path(path, path_attributes_);
View
8 src/symbolizer_helpers.cpp
@@ -179,7 +179,7 @@ void text_symbolizer_helper<FaceManagerT, DetectorT>::initialize_geometries()
geometry_type const& geom = feature_.get_geometry(i);
// don't bother with empty geometries
- if (geom.num_points() == 0) continue;
+ if (geom.size() == 0) continue;
eGeomType type = geom.type();
if (type == Polygon)
{
@@ -232,7 +232,7 @@ void text_symbolizer_helper<FaceManagerT, DetectorT>::initialize_points()
if (how_placed == VERTEX_PLACEMENT)
{
geom.rewind(0);
- for(unsigned i = 0; i < geom.num_points(); i++)
+ for(unsigned i = 0; i < geom.size(); i++)
{
geom.vertex(&label_x, &label_y);
prj_trans_.backward(label_x, label_y, z);
@@ -244,11 +244,11 @@ void text_symbolizer_helper<FaceManagerT, DetectorT>::initialize_points()
{
if (how_placed == POINT_PLACEMENT)
{
- geom.label_position(&label_x, &label_y);
+ centroid(geom, label_x, label_y);
}
else if (how_placed == INTERIOR_PLACEMENT)
{
- geom.label_interior_position(&label_x, &label_y);
+ label_interior_position(geom, label_x, label_y);
}
else
{
Please sign in to comment.
Something went wrong with that request. Please try again.