Browse Source

Leave only geonames specific mapping in gejsonify helper

pull/292/head
Julian Simioni 9 years ago
parent
commit
b2f3b54f66
  1. 50
      helper/geojsonify.js

50
helper/geojsonify.js

@ -3,7 +3,8 @@ var GeoJSON = require('geojson'),
extent = require('geojson-extent'), extent = require('geojson-extent'),
outputGenerator = require('./outputGenerator'), outputGenerator = require('./outputGenerator'),
logger = require('pelias-logger').get('api'), logger = require('pelias-logger').get('api'),
type_mapping = require('./type_mapping'); type_mapping = require('./type_mapping'),
_ = require('lodash');
// Properties to be copied // Properties to be copied
var DETAILS_PROPS = [ var DETAILS_PROPS = [
@ -28,36 +29,25 @@ function lookupSource(src) {
return sources.hasOwnProperty(src._type) ? sources[src._type] : src._type; return sources.hasOwnProperty(src._type) ? sources[src._type] : src._type;
} }
/*
* Use the type to layer mapping, except for Geonames, where having a full
* Elasticsearch document source allows a more specific layer name to be chosen
*/
function lookupLayer(src) { function lookupLayer(src) {
switch(src._type) { if (src._type === 'geoname') {
case 'osmnode': if (src.category && src.category.indexOf('admin') !== -1) {
case 'osmway': if (src.category.indexOf('admin:city') !== -1) { return 'locality'; }
return 'venue'; if (src.category.indexOf('admin:admin1') !== -1) { return 'region'; }
case 'admin0': if (src.category.indexOf('admin:admin2') !== -1) { return 'county'; }
return 'country'; return 'neighbourhood'; // this could also be 'local_admin'
case 'admin1': }
return 'region';
case 'admin2': if (src.name) { return 'venue'; }
return 'county'; if (src.address) { return 'address'; }
case 'neighborhood': }
return 'neighbourhood';
case 'locality': if (_.contains(type_mapping.types_list, src._type)) {
return 'locality'; return type_mapping.type_to_layer[src._type];
case 'local_admin':
return 'localadmin';
case 'osmaddress':
case 'openaddresses':
return 'address';
case 'geoname':
if (src.category && src.category.indexOf('admin') !== -1) {
if (src.category.indexOf('admin:city') !== -1) { return 'locality'; }
if (src.category.indexOf('admin:admin1') !== -1) { return 'region'; }
if (src.category.indexOf('admin:admin2') !== -1) { return 'county'; }
return 'neighbourhood'; // this could also be 'local_admin'
}
if (src.name) { return 'venue'; }
if (src.address) { return 'address'; }
} }
logger.warn('[geojsonify]: could not map _type ', src._type); logger.warn('[geojsonify]: could not map _type ', src._type);

Loading…
Cancel
Save