diff --git a/helper/geojsonify.js b/helper/geojsonify.js index d77792ee..b415b18f 100644 --- a/helper/geojsonify.js +++ b/helper/geojsonify.js @@ -25,8 +25,7 @@ var DETAILS_PROPS = [ function lookupSource(src) { - var sources = type_mapping.type_to_source; - return sources.hasOwnProperty(src._type) ? sources[src._type] : src._type; + return src.source; } /* @@ -34,24 +33,6 @@ function lookupSource(src) { * Elasticsearch document source allows a more specific layer name to be chosen */ function lookupLayer(src) { - if (src._type === 'geoname') { - if (_.includes(src.category, 'admin')) { - if (_.includes(src.category, 'admin:city')) { return 'locality'; } - if (_.includes(src.category, 'admin:admin1')) { return 'region'; } - if (_.includes(src.category, 'admin:admin2')) { return 'county'; } - return 'neighbourhood'; // this could also be 'local_admin' - } - - if (src.name) { return 'venue'; } - if (src.address) { return 'address'; } - } - - if (_.includes(type_mapping.types, src._type)) { - return type_mapping.type_to_layer[src._type]; - } - - logger.warn('[geojsonify]: could not map _type ', src._type); - return src._type; } diff --git a/test/unit/helper/geojsonify.js b/test/unit/helper/geojsonify.js index 3c969302..a5311050 100644 --- a/test/unit/helper/geojsonify.js +++ b/test/unit/helper/geojsonify.js @@ -40,7 +40,8 @@ module.exports.tests.search = function(test, common) { var input = [ { '_id': 'id1', - '_type': 'type1', + '_type': 'layer1', + 'source': 'source1', 'center_point': { 'lat': 51.5337144, 'lon': -0.1069716 @@ -72,7 +73,8 @@ module.exports.tests.search = function(test, common) { }, { '_id': 'id2', - '_type': 'type2', + '_type': 'layer2', + 'source': 'source2', 'name': { 'default': 'Blues Cafe' }, @@ -97,7 +99,8 @@ module.exports.tests.search = function(test, common) { }, { '_id': '34633854', - '_type': 'osmway', + '_type': 'way', + 'source': 'osm', 'name': { 'default': 'Empire State Building' }, @@ -141,9 +144,9 @@ module.exports.tests.search = function(test, common) { }, 'properties': { 'id': 'id1', - 'gid': 'type1:type1:id1', - 'layer': 'type1', - 'source': 'type1', + 'gid': 'source1:layer1:id1', + 'layer': 'layer1', + 'source': 'source1', 'label': '\'Round Midnight Jazz and Blues Bar, test3, Angel', 'name': '\'Round Midnight Jazz and Blues Bar', 'country_a': 'GBR', @@ -170,9 +173,9 @@ module.exports.tests.search = function(test, common) { }, 'properties': { 'id': 'id2', - 'gid': 'type2:type2:id2', - 'layer': 'type2', - 'source': 'type2', + 'gid': 'source2:layer2:id2', + 'layer': 'layer2', + 'source': 'source2', 'label': 'Blues Cafe, test3, Smithfield', 'name': 'Blues Cafe', 'country_a': 'GBR', @@ -196,8 +199,8 @@ module.exports.tests.search = function(test, common) { }, 'properties': { 'id': '34633854', - 'gid': 'osm:venue:34633854', - 'layer': 'venue', + 'gid': 'osm:way:34633854', + 'layer': 'way', 'source': 'osm', 'label': 'Empire State Building, Manhattan, NY, USA', 'name': 'Empire State Building',