Browse Source

Send 3 part gid (source, layer, id) in GeoJSON responses

pull/292/head
Julian Simioni 9 years ago
parent
commit
dc623d5af7
  1. 11
      helper/geojsonify.js
  2. 3
      test/unit/helper/geojsonify.js

11
helper/geojsonify.js

@ -177,6 +177,16 @@ function copyProperties( source, props, dst ) {
});
}
/**
* Create a gid from a document
* @TODO modify all importers to create separate source and layer fields to remove mapping
*
* @param {object} src
*/
function makeGid(src) {
return lookupSource(src) + ':' + lookupLayer(src) + ':' + src._id;
}
/**
* Determine and set place id, type, and source
*
@ -185,6 +195,7 @@ function copyProperties( source, props, dst ) {
*/
function addMetaData(src, dst) {
dst.id = src._id;
dst.gid = makeGid(src);
dst.layer = lookupLayer(src);
dst.source = lookupSource(src);
}

3
test/unit/helper/geojsonify.js

@ -141,6 +141,7 @@ module.exports.tests.search = function(test, common) {
},
'properties': {
'id': 'id1',
'gid': 'type1:type1:id1',
'layer': 'type1',
'source': 'type1',
'label': '\'Round Midnight Jazz and Blues Bar, test3, Angel',
@ -169,6 +170,7 @@ module.exports.tests.search = function(test, common) {
},
'properties': {
'id': 'id2',
'gid': 'type2:type2:id2',
'layer': 'type2',
'source': 'type2',
'label': 'Blues Cafe, test3, Smithfield',
@ -194,6 +196,7 @@ module.exports.tests.search = function(test, common) {
},
'properties': {
'id': '34633854',
'gid': 'osm:venue:34633854',
'layer': 'venue',
'source': 'osm',
'label': 'Empire State Building, Manhattan, NY',

Loading…
Cancel
Save