Browse Source

Add source_id property

pull/543/head
Diana Shkolnikov 9 years ago
parent
commit
1435de906d
  1. 5
      helper/geojsonify.js
  2. 9
      test/unit/helper/geojsonify.js

5
helper/geojsonify.js

@ -48,6 +48,10 @@ function lookupSource(src) {
return src.source; return src.source;
} }
function lookupSourceId(src) {
return src.source_id;
}
function lookupLayer(src) { function lookupLayer(src) {
return src.layer; return src.layer;
} }
@ -255,6 +259,7 @@ function addMetaData(src, dst) {
dst.gid = makeGid(src); dst.gid = makeGid(src);
dst.layer = lookupLayer(src); dst.layer = lookupLayer(src);
dst.source = lookupSource(src); dst.source = lookupSource(src);
dst.source_id = lookupSourceId(src);
if (src.hasOwnProperty('bounding_box')) { if (src.hasOwnProperty('bounding_box')) {
dst.bounding_box = src.bounding_box; dst.bounding_box = src.bounding_box;
} }

9
test/unit/helper/geojsonify.js

@ -44,6 +44,7 @@ module.exports.tests.search = function(test, common) {
'_id': 'id1', '_id': 'id1',
'_type': 'layer1', '_type': 'layer1',
'source': 'source1', 'source': 'source1',
'source_id': 'source_id_1',
'layer': 'layer1', 'layer': 'layer1',
'center_point': { 'center_point': {
'lat': 51.5337144, 'lat': 51.5337144,
@ -73,6 +74,7 @@ module.exports.tests.search = function(test, common) {
'_id': 'id2', '_id': 'id2',
'_type': 'layer2', '_type': 'layer2',
'source': 'source2', 'source': 'source2',
'source_id': 'source_id_2',
'layer': 'layer2', 'layer': 'layer2',
'name': { 'name': {
'default': 'Blues Cafe' 'default': 'Blues Cafe'
@ -89,12 +91,13 @@ module.exports.tests.search = function(test, common) {
'county': 'Smithfield', 'county': 'Smithfield',
'localadmin': 'test1', 'localadmin': 'test1',
'locality': 'test2', 'locality': 'test2',
'neighbourhood': 'test3', 'neighbourhood': 'test3'
}, },
{ {
'_id': 'node:34633854', '_id': 'node:34633854',
'_type': 'venue', '_type': 'venue',
'source': 'openstreetmap', 'source': 'openstreetmap',
'source_id': 'source_id_3',
'layer': 'venue', 'layer': 'venue',
'name': { 'name': {
'default': 'Empire State Building' 'default': 'Empire State Building'
@ -136,6 +139,7 @@ module.exports.tests.search = function(test, common) {
'gid': 'source1:layer1:id1', 'gid': 'source1:layer1:id1',
'layer': 'layer1', 'layer': 'layer1',
'source': 'source1', 'source': 'source1',
'source_id': 'source_id_1',
'label': '\'Round Midnight Jazz and Blues Bar, test2, England, United Kingdom', 'label': '\'Round Midnight Jazz and Blues Bar, test2, England, United Kingdom',
'name': '\'Round Midnight Jazz and Blues Bar', 'name': '\'Round Midnight Jazz and Blues Bar',
'country_a': 'GBR', 'country_a': 'GBR',
@ -166,6 +170,7 @@ module.exports.tests.search = function(test, common) {
'gid': 'source2:layer2:id2', 'gid': 'source2:layer2:id2',
'layer': 'layer2', 'layer': 'layer2',
'source': 'source2', 'source': 'source2',
'source_id': 'source_id_2',
'label': 'Blues Cafe, test2, England, United Kingdom', 'label': 'Blues Cafe, test2, England, United Kingdom',
'name': 'Blues Cafe', 'name': 'Blues Cafe',
'country_a': 'GBR', 'country_a': 'GBR',
@ -193,6 +198,7 @@ module.exports.tests.search = function(test, common) {
'gid': 'openstreetmap:venue:node:34633854', 'gid': 'openstreetmap:venue:node:34633854',
'layer': 'venue', 'layer': 'venue',
'source': 'openstreetmap', 'source': 'openstreetmap',
'source_id': 'source_id_3',
'label': 'Empire State Building, Manhattan, New York, NY, USA', 'label': 'Empire State Building, Manhattan, New York, NY, USA',
'name': 'Empire State Building', 'name': 'Empire State Building',
'country_a': 'USA', 'country_a': 'USA',
@ -320,6 +326,7 @@ module.exports.tests.search = function(test, common) {
'gid': 'whosonfirst:neighbourhood:85816607', 'gid': 'whosonfirst:neighbourhood:85816607',
'layer': 'neighbourhood', 'layer': 'neighbourhood',
'source': 'whosonfirst', 'source': 'whosonfirst',
'source_id': '85816607',
'name': 'East New York', 'name': 'East New York',
'confidence': 0.888, 'confidence': 0.888,
'country': 'United States', 'country': 'United States',

Loading…
Cancel
Save