Skip to content

Commit

Permalink
throw when an invalid join_field is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
Dane Springmeyer committed Feb 23, 2011
1 parent 897a960 commit 8fd4c6a
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/mapnik_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,8 @@ int Map::EIO_RenderGrid(eio_req *req)
mapnik::query q(bbox,1.0,1.0);
#endif

bool matched_join_field = false;

if (closure->include_features) {
mapnik::layer_descriptor ld = ds->get_descriptor();
std::vector<mapnik::attribute_descriptor> const& desc = ld.get_descriptors();
Expand All @@ -1085,6 +1087,9 @@ int Map::EIO_RenderGrid(eio_req *req)
unsigned size=0;
while (itr != end)
{
std::string name = itr->get_name();
if (name == join_field)
matched_join_field = true;
q.add_property_name(itr->get_name());
++itr;
++size;
Expand All @@ -1095,6 +1100,14 @@ int Map::EIO_RenderGrid(eio_req *req)
q.add_property_name(join_field);
}

if (!matched_join_field) {
closure->error = true;
std::ostringstream s("");
s << "join_field: '" << join_field << "' is not a valid attribute name";
closure->error_name = s.str();
return 0;
}

mapnik::featureset_ptr fs = ds->features(q);
typedef mapnik::coord_transform2<mapnik::CoordTransform,mapnik::geometry_type> path_type;

Expand All @@ -1119,10 +1132,11 @@ int Map::EIO_RenderGrid(eio_req *req)
{
ras_grid.reset();
++feature_id;

for (unsigned i=0;i<feature->num_geometries();++i)
{
mapnik::geometry_type const& geom=feature->get_geometry(i);
mapnik::eGeomType g_type = geom.type();
if (geom.num_points() == 1)
{

Expand All @@ -1145,8 +1159,14 @@ int Map::EIO_RenderGrid(eio_req *req)
}
else
{
path_type path(tr,geom,prj_trans);
ras_grid.add_path(path);
if (g_type == mapnik::LineString) {
path_type path(tr,geom,prj_trans);
ras_grid.add_path(path);
}
else {
path_type path(tr,geom,prj_trans);
ras_grid.add_path(path);
}
}
}

Expand Down

0 comments on commit 8fd4c6a

Please sign in to comment.