Skip to content

Instantly share code, notes, and snippets.

@lwu
Created August 19, 2008 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lwu/6150 to your computer and use it in GitHub Desktop.
Save lwu/6150 to your computer and use it in GitHub Desktop.
// This class implements a simple way of displaying point-based data in Mapnik
// (It has yet to be tested as Mapnik r729's memory_featureset is commented out now.)
//
class point_datasource : public mapnik::memory_datasource {
public:
point_datasource() : feat_id(0) {}
void add_point(double x, double y, const char* key, const char* value);
int type() const { return mapnik::datasource::Raster; }
private:
int feat_id;
};
void point_datasource::add_point(double x, double y,
const char* key, const char* value)
{
using namespace mapnik;
feature_ptr feature(feature_factory::create(feat_id++));
geometry2d * pt = new point_impl;
pt->move_to(x,y);
feature->add_geometry(pt);
transcoder tr("utf-8");
(*feature)[key] = tr.transcode(value);
this->push(feature);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment