Skip to content

Commit

Permalink
isvalid: return error message. it's a HACK: reverse logic if(isValid)…
Browse files Browse the repository at this point in the history
… returns msg
  • Loading branch information
wilhelmberg committed Oct 9, 2015
1 parent 8ba51a0 commit 71a6248
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/mapnik_geometry.cpp
Expand Up @@ -312,21 +312,18 @@ NAN_METHOD(Geometry::extent)
}

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());
std::string message;
if (!mapnik::geometry::is_valid(g->feat_->get_geometry(), message)) {
info.GetReturnValue().Set(Nan::New<v8::String>(message).ToLocalChecked());
}
else {
return scope.Escape(Nan::False());
info.GetReturnValue().Set(scope.Escape(Nan::Undefined()));
}
}


/**
* Get the geometry's representation as [Well-Known Text](http://en.wikipedia.org/wiki/Well-known_text)
*
Expand Down
1 change: 0 additions & 1 deletion src/mapnik_geometry.hpp
Expand Up @@ -20,7 +20,6 @@ class Geometry: public Nan::ObjectWrap {
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 71a6248

Please sign in to comment.