Skip to content

Commit

Permalink
+ put labeling routines into its owm 'label' namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
artemp committed Jul 20, 2012
1 parent 40d1e5c commit fd209b2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
8 changes: 5 additions & 3 deletions include/mapnik/geom_util.hpp
Expand Up @@ -263,6 +263,8 @@ bool middle_point(PathType & path, double & x, double & y)
return true; return true;
} }


namespace label {

template <typename PathType> template <typename PathType>
bool centroid(PathType & path, double & x, double & y) bool centroid(PathType & path, double & x, double & y)
{ {
Expand Down Expand Up @@ -347,10 +349,10 @@ bool hit_test(PathType & path, double x, double y, double tol)
} }


template <typename PathType> template <typename PathType>
void label_interior_position(PathType & path, double & x, double & y) void interior_position(PathType & path, double & x, double & y)
{ {
// start with the centroid // start with the centroid
centroid(path, x,y); label::centroid(path, x,y);


// if we are not a polygon, or the default is within the polygon we are done // if we are not a polygon, or the default is within the polygon we are done
if (hit_test(path,x,y,0.001)) if (hit_test(path,x,y,0.001))
Expand Down Expand Up @@ -417,6 +419,6 @@ void label_interior_position(PathType & path, double & x, double & y)
} }
} }


} }}


#endif // MAPNIK_GEOM_UTIL_HPP #endif // MAPNIK_GEOM_UTIL_HPP
3 changes: 1 addition & 2 deletions src/agg/process_point_symbolizer.cpp
Expand Up @@ -82,7 +82,7 @@ void agg_renderer<T>::process(point_symbolizer const& sym,
double y; double y;
double z=0; double z=0;
if (sym.get_point_placement() == CENTROID_POINT_PLACEMENT) if (sym.get_point_placement() == CENTROID_POINT_PLACEMENT)
centroid(geom, x, y); label::centroid(geom, x, y);
else else
label_interior_position(geom ,x, y); label_interior_position(geom ,x, y);


Expand Down Expand Up @@ -119,4 +119,3 @@ template void agg_renderer<image_32>::process(point_symbolizer const&,
proj_transform const&); proj_transform const&);


} }

2 changes: 1 addition & 1 deletion src/cairo_renderer.cpp
Expand Up @@ -1158,7 +1158,7 @@ void cairo_renderer_base::process(point_symbolizer const& sym,
double z = 0; double z = 0;


if (sym.get_point_placement() == CENTROID_POINT_PLACEMENT) if (sym.get_point_placement() == CENTROID_POINT_PLACEMENT)
centroid(geom, x, y); label::centroid(geom, x, y);
else else
label_interior_position(geom, x, y); label_interior_position(geom, x, y);


Expand Down
3 changes: 1 addition & 2 deletions src/grid/process_point_symbolizer.cpp
Expand Up @@ -74,7 +74,7 @@ void grid_renderer<T>::process(point_symbolizer const& sym,
double y; double y;
double z=0; double z=0;
if (sym.get_point_placement() == CENTROID_POINT_PLACEMENT) if (sym.get_point_placement() == CENTROID_POINT_PLACEMENT)
centroid(geom, x, y); label::centroid(geom, x, y);
else else
label_interior_position(geom, x, y); label_interior_position(geom, x, y);


Expand Down Expand Up @@ -105,4 +105,3 @@ template void grid_renderer<grid>::process(point_symbolizer const&,
proj_transform const&); proj_transform const&);


} }

4 changes: 2 additions & 2 deletions src/symbolizer_helpers.cpp
Expand Up @@ -244,11 +244,11 @@ void text_symbolizer_helper<FaceManagerT, DetectorT>::initialize_points()
{ {
if (how_placed == POINT_PLACEMENT) if (how_placed == POINT_PLACEMENT)
{ {
centroid(geom, label_x, label_y); label::centroid(geom, label_x, label_y);
} }
else if (how_placed == INTERIOR_PLACEMENT) else if (how_placed == INTERIOR_PLACEMENT)
{ {
label_interior_position(geom, label_x, label_y); label::interior_position(geom, label_x, label_y);
} }
else else
{ {
Expand Down

0 comments on commit fd209b2

Please sign in to comment.