From 3a4d26077a0d1918a4b353bbcd1c31b935371247 Mon Sep 17 00:00:00 2001 From: missinglink Date: Tue, 17 Jan 2017 16:20:06 +0100 Subject: [PATCH] interpolation: fix: source_id mapping --- middleware/interpolate.js | 5 +++-- test/unit/middleware/interpolate.js | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/middleware/interpolate.js b/middleware/interpolate.js index eaff913d..a6d69649 100644 --- a/middleware/interpolate.js +++ b/middleware/interpolate.js @@ -105,8 +105,9 @@ function interpolate( parsed_text, hit, cb ){ // -- source_id -- // note: interpolated values have no source_id - if( hit.hasOwnProperty( 'source_id' ) ){ - hit.source_id = hit.source_id; + delete hit.source_id; // remove original street source_id + if( data.properties.hasOwnProperty( 'source_id' ) ){ + hit.source_id = data.properties.source_id; } // -- address_parts -- diff --git a/test/unit/middleware/interpolate.js b/test/unit/middleware/interpolate.js index 6560bef4..26bf1e52 100644 --- a/test/unit/middleware/interpolate.js +++ b/test/unit/middleware/interpolate.js @@ -149,7 +149,8 @@ module.exports.tests.hit = function(test, common) { layer: 'street', center_point: { lat: 1, lon: 1 }, address_parts: { street: 'sesame rd' }, - name: { default: 'street name' } + name: { default: 'street name' }, + source_id: '123456' } ]}; @@ -180,7 +181,8 @@ module.exports.tests.hit = function(test, common) { center_point: { lat: 22.2, lon: -33.3 }, address_parts: { street: 'sesame rd', number: '100A' }, name: { default: '100A street name' }, - source: 'openstreetmap' + source: 'openstreetmap', + source_id: 'way:111111' } ]}); t.end();