From 2b9c3d79aa636400249cd43127f21670acd49d6d Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 23 Sep 2015 18:14:59 +0200 Subject: [PATCH 1/9] rename outputGenerator -> labelGenerator --- helper/geojsonify.js | 4 ++-- helper/{outputGenerator.js => labelGenerator.js} | 2 +- helper/{outputSchema.json => labelSchema.json} | 0 test/unit/helper/{outputSchema.js => labelSchema.js} | 2 +- test/unit/run.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename helper/{outputGenerator.js => labelGenerator.js} (94%) rename helper/{outputSchema.json => labelSchema.json} (100%) rename test/unit/helper/{outputSchema.js => labelSchema.js} (96%) diff --git a/helper/geojsonify.js b/helper/geojsonify.js index ca499613..d01b6f36 100644 --- a/helper/geojsonify.js +++ b/helper/geojsonify.js @@ -1,7 +1,7 @@ var GeoJSON = require('geojson'), extent = require('geojson-extent'), - outputGenerator = require('./outputGenerator'), + labelGenerator = require('./labelGenerator'), logger = require('pelias-logger').get('api'), type_mapping = require('./type_mapping'), _ = require('lodash'); @@ -116,7 +116,7 @@ function addDetails(src, dst) { * @param {object} dst */ function addLabel(src, dst) { - dst.label = outputGenerator(src); + dst.label = labelGenerator(src); } /** diff --git a/helper/outputGenerator.js b/helper/labelGenerator.js similarity index 94% rename from helper/outputGenerator.js rename to helper/labelGenerator.js index d8b47f0d..3269fcf2 100644 --- a/helper/outputGenerator.js +++ b/helper/labelGenerator.js @@ -1,5 +1,5 @@ -var schemas = require('./outputSchema.json'); +var schemas = require('./labelSchema.json'); module.exports = function( record ){ diff --git a/helper/outputSchema.json b/helper/labelSchema.json similarity index 100% rename from helper/outputSchema.json rename to helper/labelSchema.json diff --git a/test/unit/helper/outputSchema.js b/test/unit/helper/labelSchema.js similarity index 96% rename from test/unit/helper/outputSchema.js rename to test/unit/helper/labelSchema.js index cefd08da..f85c43aa 100644 --- a/test/unit/helper/outputSchema.js +++ b/test/unit/helper/labelSchema.js @@ -1,5 +1,5 @@ -var schemas = require('../../../helper/outputSchema.json'); +var schemas = require('../../../helper/labelSchema.json'); var alpha3 = require('../mock/alpha3.json'); module.exports.tests = {}; diff --git a/test/unit/run.js b/test/unit/run.js index 74202992..1f42b5b2 100644 --- a/test/unit/run.js +++ b/test/unit/run.js @@ -23,7 +23,7 @@ var tests = [ require('./query/defaults'), require('./helper/query_parser'), require('./helper/geojsonify'), - require('./helper/outputSchema'), + require('./helper/labelSchema'), require('./helper/types'), require('./helper/type_mapping'), require('./sanitiser/_geo_common'), From 3a54a8b32fc4b2df3c15b1d2ad3e571b14c10a56 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 23 Sep 2015 19:00:33 +0200 Subject: [PATCH 2/9] fix label issues --- helper/labelGenerator.js | 22 ++- helper/labelSchema.json | 2 +- test/unit/helper/labelGenerator.js | 235 +++++++++++++++++++++++++++++ test/unit/run.js | 1 + 4 files changed, 247 insertions(+), 13 deletions(-) create mode 100644 test/unit/helper/labelGenerator.js diff --git a/helper/labelGenerator.js b/helper/labelGenerator.js index 3269fcf2..1938232d 100644 --- a/helper/labelGenerator.js +++ b/helper/labelGenerator.js @@ -1,9 +1,11 @@ -var schemas = require('./labelSchema.json'); +var _ = require('lodash'), + check = require('check-types'), + schemas = require('./labelSchema.json'); module.exports = function( record ){ - var adminParts = []; + var labelParts = [ record.name.default ]; var schema = schemas.default; @@ -13,9 +15,9 @@ module.exports = function( record ){ var buildOutput = function(parts, schemaArr, record) { for (var i=0; i Date: Wed, 23 Sep 2015 19:23:45 +0200 Subject: [PATCH 3/9] flip lon values for boundary.rect --- query/search.js | 4 ++-- test/unit/fixture/search_linguistic_bbox.js | 4 ++-- test/unit/fixture/search_linguistic_focus_bbox.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/query/search.js b/query/search.js index bf95b76b..a3787535 100644 --- a/query/search.js +++ b/query/search.js @@ -85,9 +85,9 @@ function generateQuery( clean ){ check.number(clean['boundary.rect.min_lon']) && check.number(clean['boundary.rect.max_lon']) ){ vs.set({ - 'boundary:rect:top': clean['boundary.rect.min_lat'], + 'boundary:rect:top': clean['boundary.rect.max_lat'], 'boundary:rect:right': clean['boundary.rect.max_lon'], - 'boundary:rect:bottom': clean['boundary.rect.max_lat'], + 'boundary:rect:bottom': clean['boundary.rect.min_lat'], 'boundary:rect:left': clean['boundary.rect.min_lon'] }); } diff --git a/test/unit/fixture/search_linguistic_bbox.js b/test/unit/fixture/search_linguistic_bbox.js index 754421e0..6c98b010 100644 --- a/test/unit/fixture/search_linguistic_bbox.js +++ b/test/unit/fixture/search_linguistic_bbox.js @@ -73,9 +73,9 @@ module.exports = { 'must': [{ 'geo_bounding_box': { 'center_point': { - 'top': 47.47, + 'top': 11.51, 'right': -61.84, - 'bottom': 11.51, + 'bottom': 47.47, 'left': -103.16 }, '_cache': true, diff --git a/test/unit/fixture/search_linguistic_focus_bbox.js b/test/unit/fixture/search_linguistic_focus_bbox.js index 09262a0e..e6a04824 100644 --- a/test/unit/fixture/search_linguistic_focus_bbox.js +++ b/test/unit/fixture/search_linguistic_focus_bbox.js @@ -102,9 +102,9 @@ module.exports = { 'must': [{ 'geo_bounding_box': { 'center_point': { - 'top': 47.47, + 'top': 11.51, 'right': -61.84, - 'bottom': 11.51, + 'bottom': 47.47, 'left': -103.16 }, '_cache': true, From b23b52682eb55b3c00f8cc82d93a7256bee9d957 Mon Sep 17 00:00:00 2001 From: Riordan Date: Wed, 23 Sep 2015 14:08:00 -0400 Subject: [PATCH 4/9] :house: :copyright: :free: OpenAddresses added to attribution under CC0 --- public/attribution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/attribution.md b/public/attribution.md index db9c392e..2302c093 100644 --- a/public/attribution.md +++ b/public/attribution.md @@ -2,6 +2,6 @@ * Geocoding by [Pelias](https://mapzen.com/pelias) from [Mapzen](https://mapzen.com) * Data from * [OpenStreetMap](http://www.openstreetmap.org/copyright) © OpenStreetMap contributors under [ODbL](http://opendatacommons.org/licenses/odbl/) + * [OpenAddresses](http://openaddresses.io) under a [Creative Commons Zero](https://github.com/openaddresses/openaddresses/blob/master/sources/LICENSE) public domain designation * [Quattroshapes](https://github.com/foursquare/quattroshapes/blob/master/LICENSE.md) under [CC-BY-2.0](https://creativecommons.org/licenses/by/2.0/) * [GeoNames](http://www.geonames.org/) under [CC-BY-3.0](https://creativecommons.org/licenses/by/2.0/) - * and other sources From 84dfa0f45ed54ee6cdfeb087906d9f27f04cad4a Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 24 Sep 2015 17:05:47 +0200 Subject: [PATCH 5/9] add custom singapore schema, it is unusual as it is both a city and a country --- helper/labelSchema.json | 4 ++++ test/unit/helper/labelGenerator.js | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/helper/labelSchema.json b/helper/labelSchema.json index 86f01e00..49c96017 100644 --- a/helper/labelSchema.json +++ b/helper/labelSchema.json @@ -7,6 +7,10 @@ "local": ["neighbourhood", "county", "localadmin", "locality", "region"], "regional": ["county","country","region"] }, + "SGP": { + "local": ["neighbourhood", "region", "county", "localadmin", "locality"], + "regional": ["county","country","region"] + }, "default": { "local": ["localadmin", "locality", "neighbourhood", "county"], "regional": ["region_a", "region", "country"] diff --git a/test/unit/helper/labelGenerator.js b/test/unit/helper/labelGenerator.js index 87ba4814..c70f0e50 100644 --- a/test/unit/helper/labelGenerator.js +++ b/test/unit/helper/labelGenerator.js @@ -223,6 +223,21 @@ module.exports.tests.new_zealand = function(test, common) { }); }; +// SGP venue +module.exports.tests.singapore_mcdonalds = function(test, common) { + test('singapore_mcdonalds', function(t) { + var doc = { + 'name': { 'default': 'McDonald\'s' }, + 'country_a': 'SGP', + 'country': 'Singapore', + 'region': 'Central Singapore', + 'locality': 'Singapore' + }; + t.equal(generator(doc),'McDonald\'s, Central Singapore, Singapore'); + t.end(); + }); +}; + module.exports.all = function (tape, common) { function test(name, testFunction) { From 0918d3031f49ef0bde4fe063f3b02128ed347c68 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 25 Sep 2015 10:43:38 +0200 Subject: [PATCH 6/9] remove duplicate test --- test/unit/helper/labelGenerator.js | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/test/unit/helper/labelGenerator.js b/test/unit/helper/labelGenerator.js index c70f0e50..e1bf0da3 100644 --- a/test/unit/helper/labelGenerator.js +++ b/test/unit/helper/labelGenerator.js @@ -49,28 +49,6 @@ module.exports.tests.nyc_office = function(test, common) { }); }; -// USA venue -module.exports.tests.nyc_office = function(test, common) { - test('30 West 26th Street', function(t) { - var doc = { - 'name': { 'default': '30 West 26th Street' }, - 'housenumber': '30', - 'street': 'West 26th Street', - 'postalcode': '10010', - 'country_a': 'USA', - 'country': 'United States', - 'region': 'New York', - 'region_a': 'NY', - 'county': 'New York County', - 'localadmin': 'Manhattan', - 'locality': 'New York', - 'neighbourhood': 'Flatiron District' - }; - t.equal(generator(doc),'30 West 26th Street, Manhattan, NY'); - t.end(); - }); -}; - // AUS state module.exports.tests.new_south_wales = function(test, common) { test('new south wales', function(t) { From 3a5e6f781196e38ba8cb31311ce8958d0fb18b85 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 25 Sep 2015 18:42:17 +0200 Subject: [PATCH 7/9] tweak boost values --- query/defaults.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/query/defaults.js b/query/defaults.js index cf9422d0..38bafbbe 100644 --- a/query/defaults.js +++ b/query/defaults.js @@ -39,35 +39,35 @@ module.exports = extend( false, peliasQuery.defaults, { 'address:housenumber:analyzer': 'standard', 'address:housenumber:field': 'address.number', - 'address:housenumber:boost': 1, + 'address:housenumber:boost': 3, 'address:street:analyzer': 'standard', 'address:street:field': 'address.street', - 'address:street:boost': 1, + 'address:street:boost': 3, 'address:postcode:analyzer': 'standard', 'address:postcode:field': 'address.zip', - 'address:postcode:boost': 1, + 'address:postcode:boost': 3, 'admin:alpha3:analyzer': 'standard', 'admin:alpha3:field': 'alpha3', - 'admin:alpha3:boost': 1, + 'admin:alpha3:boost': 5, 'admin:admin0:analyzer': 'peliasAdmin', 'admin:admin0:field': 'admin0', - 'admin:admin0:boost': 1, + 'admin:admin0:boost': 4, 'admin:admin1:analyzer': 'peliasAdmin', 'admin:admin1:field': 'admin1', - 'admin:admin1:boost': 1, + 'admin:admin1:boost': 3, 'admin:admin1_abbr:analyzer': 'peliasAdmin', 'admin:admin1_abbr:field': 'admin1_abbr', - 'admin:admin1_abbr:boost': 1, + 'admin:admin1_abbr:boost': 3, 'admin:admin2:analyzer': 'peliasAdmin', 'admin:admin2:field': 'admin2', - 'admin:admin2:boost': 1, + 'admin:admin2:boost': 2, 'admin:local_admin:analyzer': 'peliasAdmin', 'admin:local_admin:field': 'local_admin', From c7a79c57b5bfd279e3ae73a5280dd771dfaf2e67 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 25 Sep 2015 19:01:27 +0200 Subject: [PATCH 8/9] reduce streetnumber boost --- query/defaults.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/query/defaults.js b/query/defaults.js index 38bafbbe..daea1ffd 100644 --- a/query/defaults.js +++ b/query/defaults.js @@ -43,7 +43,7 @@ module.exports = extend( false, peliasQuery.defaults, { 'address:street:analyzer': 'standard', 'address:street:field': 'address.street', - 'address:street:boost': 3, + 'address:street:boost': 2, 'address:postcode:analyzer': 'standard', 'address:postcode:field': 'address.zip', From 31ae318861297e340710f679dacf51c602bdd96e Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 25 Sep 2015 19:06:20 +0200 Subject: [PATCH 9/9] tweaks --- query/defaults.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/query/defaults.js b/query/defaults.js index daea1ffd..83ddb4d9 100644 --- a/query/defaults.js +++ b/query/defaults.js @@ -39,11 +39,11 @@ module.exports = extend( false, peliasQuery.defaults, { 'address:housenumber:analyzer': 'standard', 'address:housenumber:field': 'address.number', - 'address:housenumber:boost': 3, + 'address:housenumber:boost': 2, 'address:street:analyzer': 'standard', 'address:street:field': 'address.street', - 'address:street:boost': 2, + 'address:street:boost': 5, 'address:postcode:analyzer': 'standard', 'address:postcode:field': 'address.zip',