2010-10-24 10:04:16 +02:00
|
|
|
#include "hello_featureset.hpp"
|
2010-11-03 17:26:30 +01:00
|
|
|
#include <mapnik/geometry.hpp>
|
2010-10-24 10:04:16 +02:00
|
|
|
|
|
|
|
hello_featureset::hello_featureset(mapnik::box2d<double> const& box, std::string const& encoding)
|
|
|
|
: box_(box),
|
|
|
|
count_(0),
|
|
|
|
tr_(new mapnik::transcoder(encoding)) { }
|
|
|
|
|
|
|
|
hello_featureset::~hello_featureset() { }
|
|
|
|
|
|
|
|
mapnik::feature_ptr hello_featureset::next()
|
|
|
|
{
|
|
|
|
if (!count_)
|
|
|
|
{
|
|
|
|
// create a new feature
|
|
|
|
mapnik::feature_ptr feature(new mapnik::Feature(count_));
|
|
|
|
|
|
|
|
// create an attribute pair of key:value
|
|
|
|
UnicodeString ustr = tr_->transcode("hello world!");
|
|
|
|
boost::put(*feature,"key",ustr);
|
|
|
|
|
|
|
|
// we need a geometry to display so just for fun here
|
|
|
|
// we take the center of the bbox that was used to query
|
|
|
|
// since we don't actually have any data to pull from...
|
|
|
|
mapnik::coord2d center = box_.center();
|
|
|
|
|
2010-11-03 17:26:30 +01:00
|
|
|
// create a new point geometry
|
|
|
|
mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::Point);
|
2010-10-24 10:04:16 +02:00
|
|
|
|
|
|
|
// we use path type geometries in Mapnik to fit nicely with AGG and Cairo
|
2010-11-03 17:26:30 +01:00
|
|
|
// here we stick an x,y pair into the geometry using move_to()
|
|
|
|
pt->move_to(center.x,center.y);
|
2010-10-24 10:04:16 +02:00
|
|
|
|
|
|
|
// add the geometry to the feature
|
2010-11-03 17:26:30 +01:00
|
|
|
feature->add_geometry(pt);
|
2010-10-24 10:04:16 +02:00
|
|
|
|
2011-01-13 19:51:20 +01:00
|
|
|
// increment the count so that we only return one feature
|
2010-10-24 10:04:16 +02:00
|
|
|
++count_;
|
|
|
|
|
|
|
|
// return the feature!
|
|
|
|
return feature;
|
|
|
|
}
|
|
|
|
|
2011-01-13 19:51:20 +01:00
|
|
|
// otherwise return an empty feature
|
2010-10-24 10:04:16 +02:00
|
|
|
return mapnik::feature_ptr();
|
|
|
|
}
|
|
|
|
|