Skip to content

Commit

Permalink
expose mapnik::geometry::is_valid
Browse files Browse the repository at this point in the history
  • Loading branch information
wilhelmberg committed Oct 8, 2015
1 parent 5892398 commit 8ba51a0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/mapnik_geometry.cpp
Expand Up @@ -4,6 +4,7 @@

#include <mapnik/datasource.hpp>
#include <mapnik/geometry_reprojection.hpp>
#include <mapnik/geometry_is_valid.hpp>
#include <mapnik/util/geometry_to_geojson.hpp>
#include <mapnik/util/geometry_to_wkt.hpp>
#include <mapnik/util/geometry_to_wkb.hpp>
Expand Down Expand Up @@ -31,6 +32,7 @@ void Geometry::Initialize(v8::Local<v8::Object> target) {
lcons->SetClassName(Nan::New("Geometry").ToLocalChecked());

Nan::SetPrototypeMethod(lcons, "extent", extent);
Nan::SetPrototypeMethod(lcons, "isValid", isValid);
Nan::SetPrototypeMethod(lcons, "toWKB", toWKB);
Nan::SetPrototypeMethod(lcons, "toWKT", toWKT);
Nan::SetPrototypeMethod(lcons, "toJSON", toJSON);
Expand Down Expand Up @@ -309,6 +311,22 @@ NAN_METHOD(Geometry::extent)
info.GetReturnValue().Set(a);
}

NAN_METHOD(Geometry::isValid) {
info.GetReturnValue().Set(_isValid(info));
}

v8::Local<v8::Value> Geometry::_isValid(Nan::NAN_METHOD_ARGS_TYPE info) {
Nan::EscapableHandleScope scope;
Geometry* g = Nan::ObjectWrap::Unwrap<Geometry>(info.Holder());
//std::string message;
if (mapnik::geometry::is_valid(g->feat_->get_geometry())) {
return scope.Escape(Nan::True());
}
else {
return scope.Escape(Nan::False());
}
}

/**
* Get the geometry's representation as [Well-Known Text](http://en.wikipedia.org/wiki/Well-known_text)
*
Expand Down
2 changes: 2 additions & 0 deletions src/mapnik_geometry.hpp
Expand Up @@ -19,6 +19,8 @@ class Geometry: public Nan::ObjectWrap {
static NAN_METHOD(New);
static v8::Local<v8::Value> NewInstance(mapnik::feature_ptr f);
static NAN_METHOD(extent);
static NAN_METHOD(isValid);
static v8::Local<v8::Value> _isValid(Nan::NAN_METHOD_ARGS_TYPE info);
static NAN_METHOD(toWKB);
static NAN_METHOD(toWKT);
static v8::Local<v8::Value> _toJSONSync(Nan::NAN_METHOD_ARGS_TYPE info);
Expand Down

0 comments on commit 8ba51a0

Please sign in to comment.