Browse Source

Add new parent properties and take the first one in each property if it is an array

pull/426/head
Diana Shkolnikov 9 years ago committed by Julian Simioni
parent
commit
4219cefd56
  1. 34
      helper/geojsonify.js

34
helper/geojsonify.js

@ -11,16 +11,25 @@ var DETAILS_PROPS = [
'housenumber', 'housenumber',
'street', 'street',
'postalcode', 'postalcode',
'country_a', 'confidence',
'distance',
'country', 'country',
'country_id',
'country_a',
'region', 'region',
'region_id',
'region_a', 'region_a',
'county', 'county',
'county_id',
'county_a',
'localadmin', 'localadmin',
'localadmin_id',
'localadmin_a',
'locality', 'locality',
'locality_id',
'locality_a',
'neighbourhood', 'neighbourhood',
'confidence', 'neighbourhood_id'
'distance'
]; ];
@ -93,7 +102,7 @@ function addDetails(src, dst) {
* @param {object} dst * @param {object} dst
*/ */
function addLabel(src, dst) { function addLabel(src, dst) {
dst.label = labelGenerator(src); dst.label = labelGenerator(dst);
} }
/** /**
@ -126,8 +135,23 @@ function computeBBox(geojson) {
*/ */
function copyProperties( source, props, dst ) { function copyProperties( source, props, dst ) {
props.forEach( function ( prop ) { props.forEach( function ( prop ) {
if ( source.hasOwnProperty( prop ) ) { if ( source.hasOwnProperty( prop ) ) {
dst[prop] = source[prop];
// array value, take first item in array (at this time only used for admin values)
if (source[prop] instanceof Array) {
if (source[prop].length === 0) {
return;
}
if (source[prop][0]) {
dst[prop] = source[prop][0];
}
}
// simple value
else {
dst[prop] = source[prop];
}
} }
}); });
} }

Loading…
Cancel
Save