Skip to content

Commit

Permalink
feature ids must start at 1 to stay consistent with mapnik datasources
Browse files Browse the repository at this point in the history
  • Loading branch information
Dane Springmeyer committed Apr 29, 2011
1 parent 94389ad commit ce51462
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/mapnik_memory_datasource.cpp
Expand Up @@ -35,7 +35,7 @@ void MemoryDatasource::Initialize(Handle<Object> target) {
MemoryDatasource::MemoryDatasource() :
ObjectWrap(),
datasource_(),
count_(0),
feature_id_(1),
tr_(new mapnik::transcoder("utf8")) {}

MemoryDatasource::~MemoryDatasource()
Expand Down Expand Up @@ -232,7 +232,8 @@ Handle<Value> MemoryDatasource::add(const Arguments& args)
{
mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::Point);
pt->move_to(x->NumberValue(),y->NumberValue());
mapnik::feature_ptr feature(new mapnik::Feature(d->count_));
mapnik::feature_ptr feature(new mapnik::Feature(d->feature_id_));
++(d->feature_id_);
feature->add_geometry(pt);
if (obj->Has(String::New("properties")))
{
Expand Down Expand Up @@ -270,7 +271,6 @@ Handle<Value> MemoryDatasource::add(const Arguments& args)
}
mapnik::memory_datasource *cache = dynamic_cast<mapnik::memory_datasource *>(d->datasource_.get());
cache->push(feature);
++(d->count_);
}
}
return scope.Close(Boolean::New(false));
Expand Down
2 changes: 1 addition & 1 deletion src/mapnik_memory_datasource.hpp
Expand Up @@ -29,7 +29,7 @@ class MemoryDatasource: public node::ObjectWrap {
private:
~MemoryDatasource();
mapnik::datasource_ptr datasource_;
unsigned int count_;
unsigned int feature_id_;
boost::scoped_ptr<mapnik::transcoder> tr_;
};

Expand Down
8 changes: 4 additions & 4 deletions src/mem_datasource.hpp
Expand Up @@ -87,7 +87,7 @@ class js_featureset : public mapnik::Featureset, private boost::noncopyable
public:
js_featureset( const mapnik::query& q, const js_datasource* ds)
: q_(q),
count_(0),
feature_id_(1),
tr_(new mapnik::transcoder("utf-8")),
ds_(ds),
obj_(Object::New())
Expand Down Expand Up @@ -130,7 +130,8 @@ class js_featureset : public mapnik::Featureset, private boost::noncopyable
{
mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::Point);
pt->move_to(x->NumberValue(),y->NumberValue());
mapnik::feature_ptr feature(new mapnik::Feature(count_));
mapnik::feature_ptr feature(new mapnik::Feature(feature_id_));
++feature_id_;
feature->add_geometry(pt);
if (obj->Has(String::New("properties")))
{
Expand Down Expand Up @@ -164,7 +165,6 @@ class js_featureset : public mapnik::Featureset, private boost::noncopyable
}
}
}
++count_;
return feature;
}
}
Expand All @@ -177,7 +177,7 @@ class js_featureset : public mapnik::Featureset, private boost::noncopyable

private:
mapnik::query const& q_;
unsigned int count_;
unsigned int feature_id_;
boost::scoped_ptr<mapnik::transcoder> tr_;
const js_datasource* ds_;
Local<Object> obj_;
Expand Down

0 comments on commit ce51462

Please sign in to comment.