Browse Source

fix: remove gid from interpolated results

pull/884/head
Diana Shkolnikov 8 years ago
parent
commit
510090ba05
  1. 9
      helper/geojsonify_meta_data.js
  2. 47
      test/unit/helper/geojsonify.js

9
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);

47
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) {

Loading…
Cancel
Save