From 510090ba05cdb2088f4cd9cb67cad684b76e822f Mon Sep 17 00:00:00 2001 From: Diana Shkolnikov Date: Wed, 10 May 2017 08:45:47 -0400 Subject: [PATCH] fix: remove gid from interpolated results --- helper/geojsonify_meta_data.js | 9 ++++++- test/unit/helper/geojsonify.js | 47 ++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/helper/geojsonify_meta_data.js b/helper/geojsonify_meta_data.js index 7fdf0394..8ddc5b4d 100644 --- a/helper/geojsonify_meta_data.js +++ b/helper/geojsonify_meta_data.js @@ -8,7 +8,14 @@ var Document = require('pelias-model').Document; */ function addMetaData(src, dst) { dst.id = src._id; - dst.gid = makeGid(src); + + // at this time the gid's of interpolated addresses are not usable in the place endpoint + // to avoid confusion they will be removed altogether for now and replaced in the future when we have determined + // the right format for these types of results + if (src.source !== 'mixed') { + dst.gid = makeGid(src); + } + dst.layer = lookupLayer(src); dst.source = lookupSource(src); dst.source_id = lookupSourceId(src); diff --git a/test/unit/helper/geojsonify.js b/test/unit/helper/geojsonify.js index 809b1ae9..25b421a0 100644 --- a/test/unit/helper/geojsonify.js +++ b/test/unit/helper/geojsonify.js @@ -459,6 +459,53 @@ module.exports.tests.categories = function (test, common) { }); }; + +module.exports.tests.interpolated_gids = function (test, common) { + test('do not set the gid for interpolated results', function (t) { + var input = [ + { + '_id': 'polyline:10439991', + 'source': 'mixed', + 'layer': 'address', + 'center_point': { + 'lon': -73.953698, + 'lat': 40.757667 + }, + 'name': { + 'default': '123 Main Street' + }, + 'source_id': 'polyline:10439991' + } + ]; + + var expected = { + 'type': 'FeatureCollection', + 'bbox': [-73.953698, 40.757667, -73.953698, 40.757667], + 'features': [ + { + 'type': 'Feature', + 'properties': { + 'id': 'polyline:10439991', + 'layer': 'address', + 'source': 'mixed', + 'source_id': 'polyline:10439991', + 'name': '123 Main Street' + }, + 'geometry': { + 'type': 'Point', + 'coordinates': [ -73.953698, 40.757667 ] + } + } + ] + }; + + var json = geojsonify( {}, input ); + + t.deepEqual(json, expected, 'gid is not defined'); + t.end(); + }); +}; + module.exports.all = function (tape, common) { function test(name, testFunction) {