Skip to content

Commit

Permalink
1. placement_finder.cpp
Browse files Browse the repository at this point in the history
    fixed 'for' loops to work correctly when geom->num_points() < 2
    always use prefix increment even for built-in types (good practice!)
    e.g ++i 

2. agg_renderer.cpp 
    check for number points in geometries when 
    applying text/shield_symbolizer.
  • Loading branch information
artemp committed Dec 5, 2006
1 parent 913b273 commit 00fd2a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/agg_renderer.cpp
Expand Up @@ -332,7 +332,7 @@ namespace mapnik
proj_transform const& prj_trans)
{
geometry_ptr const& geom=feature.get_geometry();
if (geom)
if (geom && geom->num_points() > 0)
{
std::wstring text = to_unicode(feature[sym.get_name()].to_string());
boost::shared_ptr<ImageData32> const& data = sym.get_data();
Expand Down Expand Up @@ -492,7 +492,7 @@ namespace mapnik
{
geometry_ptr const& geom=feature.get_geometry();

if (geom)
if (geom && geom->num_points() > 0)
{
std::wstring text = to_unicode(feature[sym.get_name()].to_string());
if (text.length() > 0)
Expand Down
14 changes: 8 additions & 6 deletions src/placement_finder.cpp
Expand Up @@ -75,7 +75,8 @@ namespace mapnik

shape_path.rewind(0);
shape_path.vertex(&new_x,&new_y);
for (unsigned i = 0; i < geom->num_points() - 1; i++)
unsigned num_points = geom->num_points();
for (unsigned i = 1; i < num_points; ++i)
{
double dx, dy;

Expand Down Expand Up @@ -113,13 +114,13 @@ namespace mapnik
shape_path.vertex(&old_x,&old_y);

total_distance_ = 0.0;

for (unsigned i = 0; i < geom->num_points() - 1; i++)

unsigned num_points = geom->num_points();
for (unsigned i = 1; i < num_points ; ++i)
{
double dx, dy;

shape_path.vertex(&new_x,&new_y);

dx = new_x - old_x;
dy = new_y - old_y;

Expand Down Expand Up @@ -330,7 +331,8 @@ namespace mapnik
p->shape_path.vertex(&new_x,&new_y);
old_x = new_x;
old_y = new_y;
for (unsigned i = 0; i < p->geom->num_points() - 1; i++)
unsigned num_points = geom->num_points();
for (unsigned i = 1; i < num_points; ++i)
{
double dx, dy;

Expand Down

0 comments on commit 00fd2a9

Please sign in to comment.