diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-05-06 11:12:41 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-05-06 11:59:29 -0700 |
commit | 5837ba1ad3cd84954711c6d42ccc1358da8a09d3 (patch) | |
tree | 07b51b5eebe69208981c8b265ed8f142f3b1aec3 /platform/node | |
parent | 771e79a76988acadf4255d794c94b5688151c7e7 (diff) | |
download | qtlocation-mapboxgl-5837ba1ad3cd84954711c6d42ccc1358da8a09d3.tar.gz |
[node] Fix conversion of geometry collections to GeoJSON
They should have a "geometries" member, not a "coordinates" member.
Diffstat (limited to 'platform/node')
-rw-r--r-- | platform/node/src/node_feature.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/platform/node/src/node_feature.cpp b/platform/node/src/node_feature.cpp index 2f0541dd59..eb4b48bf35 100644 --- a/platform/node/src/node_feature.cpp +++ b/platform/node/src/node_feature.cpp @@ -7,6 +7,7 @@ using namespace mapbox::geometry; using Value = mbgl::Value; using Feature = mbgl::Feature; using Geometry = mbgl::Feature::geometry_type; +using GeometryCollection = mapbox::geometry::geometry_collection<double>; using Properties = mbgl::Feature::property_map; template <class T> @@ -48,7 +49,7 @@ private: }; template <class T> -struct ToCoordinates { +struct ToCoordinatesOrGeometries { public: // Handles line_string, polygon, multi_point, multi_line_string, multi_polygon, and geometry_collection. template <class E> @@ -117,8 +118,13 @@ v8::Local<v8::Object> toJS(const Geometry& geometry) { v8::Local<v8::Object> result = Nan::New<v8::Object>(); - Nan::Set(result, Nan::New("type").ToLocalChecked(), Geometry::visit(geometry, ToType<double>())); - Nan::Set(result, Nan::New("coordinates").ToLocalChecked(), Geometry::visit(geometry, ToCoordinates<double>())); + Nan::Set(result, + Nan::New("type").ToLocalChecked(), + Geometry::visit(geometry, ToType<double>())); + + Nan::Set(result, + Nan::New(geometry.is<GeometryCollection>() ? "geometries" : "coordinates").ToLocalChecked(), + Geometry::visit(geometry, ToCoordinatesOrGeometries<double>())); return scope.Escape(result); } |