From 5837ba1ad3cd84954711c6d42ccc1358da8a09d3 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 6 May 2016 11:12:41 -0700 Subject: [PATCH] [node] Fix conversion of geometry collections to GeoJSON They should have a "geometries" member, not a "coordinates" member. --- platform/node/src/node_feature.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/platform/node/src/node_feature.cpp b/platform/node/src/node_feature.cpp index 2f0541dd5..eb4b48bf3 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; using Properties = mbgl::Feature::property_map; template @@ -48,7 +49,7 @@ private: }; template -struct ToCoordinates { +struct ToCoordinatesOrGeometries { public: // Handles line_string, polygon, multi_point, multi_line_string, multi_polygon, and geometry_collection. template @@ -117,8 +118,13 @@ v8::Local toJS(const Geometry& geometry) { v8::Local result = Nan::New(); - Nan::Set(result, Nan::New("type").ToLocalChecked(), Geometry::visit(geometry, ToType())); - Nan::Set(result, Nan::New("coordinates").ToLocalChecked(), Geometry::visit(geometry, ToCoordinates())); + Nan::Set(result, + Nan::New("type").ToLocalChecked(), + Geometry::visit(geometry, ToType())); + + Nan::Set(result, + Nan::New(geometry.is() ? "geometries" : "coordinates").ToLocalChecked(), + Geometry::visit(geometry, ToCoordinatesOrGeometries())); return scope.Escape(result); }