From e70a668056e3ed85266784f4e400c59aacad5eaa Mon Sep 17 00:00:00 2001 From: Stephen Hess Date: Fri, 8 Sep 2017 16:15:45 -0400 Subject: [PATCH] added support for continent, ocean, and marinearea placetypes `coarse` now maps to these as well --- controller/coarse_reverse.js | 5 ++- helper/type_mapping.js | 6 ++-- test/unit/controller/coarse_reverse.js | 35 ++++++++++++++++++- .../predicates/is_coarse_reverse.js | 4 ++- test/unit/helper/type_mapping.js | 3 +- test/unit/sanitizer/_layers.js | 14 ++++---- 6 files changed, 55 insertions(+), 12 deletions(-) diff --git a/controller/coarse_reverse.js b/controller/coarse_reverse.js index 2c7b370b..ce3ad52a 100644 --- a/controller/coarse_reverse.js +++ b/controller/coarse_reverse.js @@ -15,7 +15,10 @@ const coarse_granularities = [ 'region', 'macroregion', 'dependency', - 'country' + 'country', + 'continent', + 'ocean', + 'marinearea' ]; // remove non-coarse layers and return what's left (or all if empty) diff --git a/helper/type_mapping.js b/helper/type_mapping.js index 7b9de5a0..d17fd058 100644 --- a/helper/type_mapping.js +++ b/helper/type_mapping.js @@ -51,7 +51,8 @@ var LAYERS_BY_SOURCE = { 'locality','borough', 'neighbourhood', 'venue' ], whosonfirst: [ 'continent', 'country', 'dependency', 'macroregion', 'region', 'locality', 'localadmin', 'macrocounty', 'county', 'macrohood', 'borough', - 'neighbourhood', 'microhood', 'disputed', 'venue', 'postalcode'] + 'neighbourhood', 'microhood', 'disputed', 'venue', 'postalcode', + 'continent', 'ocean', 'marinearea'] }; /* @@ -62,7 +63,8 @@ var LAYERS_BY_SOURCE = { var LAYER_ALIASES = { 'coarse': [ 'continent', 'country', 'dependency', 'macroregion', 'region', 'locality', 'localadmin', 'macrocounty', 'county', 'macrohood', 'borough', - 'neighbourhood', 'microhood', 'disputed', 'postalcode' ] + 'neighbourhood', 'microhood', 'disputed', 'postalcode', + 'continent', 'ocean', 'marinearea'] }; // create a list of all layers by combining each entry from LAYERS_BY_SOURCE diff --git a/test/unit/controller/coarse_reverse.js b/test/unit/controller/coarse_reverse.js index f9e3709f..403e5875 100644 --- a/test/unit/controller/coarse_reverse.js +++ b/test/unit/controller/coarse_reverse.js @@ -210,6 +210,18 @@ module.exports.tests.success_conditions = (test, common) => { country: [ { id: 100, name: 'country name', abbr: 'xyz'}, { id: 101, name: 'country name 2'} + ], + continent: [ + { id: 110, name: 'continent name', abbr: 'continent abbr'}, + { id: 111, name: 'continent name 2'} + ], + ocean: [ + { id: 120, name: 'ocean name', abbr: 'ocean abbr'}, + { id: 121, name: 'ocean name 2'} + ], + marinearea: [ + { id: 130, name: 'marinearea name', abbr: 'marinearea abbr'}, + { id: 131, name: 'marinearea name 2'} ] }; @@ -282,7 +294,16 @@ module.exports.tests.success_conditions = (test, common) => { dependency_a: ['dependency abbr'], country: ['country name'], country_id: ['100'], - country_a: ['xyz'] + country_a: ['xyz'], + continent: ['continent name'], + continent_id: ['110'], + continent_a: ['continent abbr'], + ocean: ['ocean name'], + ocean_id: ['120'], + ocean_a: ['ocean abbr'], + marinearea: ['marinearea name'], + marinearea_id: ['130'], + marinearea_a: ['marinearea abbr'], }, center_point: { lat: 12.121212, @@ -822,6 +843,18 @@ module.exports.tests.failure_conditions = (test, common) => { country: [ { id: 100, name: 'country name', abbr: 'xyz'}, { id: 101, name: 'country name 2'} + ], + continent: [ + { id: 110, name: 'continent name', abbr: 'continent abbr'}, + { id: 111, name: 'continent name 2'} + ], + ocean: [ + { id: 120, name: 'ocean name', abbr: 'ocean abbr'}, + { id: 121, name: 'ocean name 2'} + ], + marinearea: [ + { id: 130, name: 'marinearea name', abbr: 'marinearea abbr'}, + { id: 131, name: 'marinearea name 2'} ] }; diff --git a/test/unit/controller/predicates/is_coarse_reverse.js b/test/unit/controller/predicates/is_coarse_reverse.js index 2a38e401..33b0611d 100644 --- a/test/unit/controller/predicates/is_coarse_reverse.js +++ b/test/unit/controller/predicates/is_coarse_reverse.js @@ -17,7 +17,9 @@ const coarse_layers = [ 'borough', 'neighbourhood', 'microhood', - 'disputed' + 'disputed', + 'ocean', + 'marinearea' ]; module.exports.tests = {}; diff --git a/test/unit/helper/type_mapping.js b/test/unit/helper/type_mapping.js index d67218c5..2ec86e40 100644 --- a/test/unit/helper/type_mapping.js +++ b/test/unit/helper/type_mapping.js @@ -14,7 +14,8 @@ module.exports.tests.interfaces = function(test, common) { t.deepEquals(type_mapping.layer_mapping.coarse, [ 'continent', 'country', 'dependency', 'macroregion', 'region', 'locality', 'localadmin', 'macrocounty', 'county', 'macrohood', - 'borough', 'neighbourhood', 'microhood', 'disputed', 'postalcode' ]); + 'borough', 'neighbourhood', 'microhood', 'disputed', 'postalcode', + 'continent', 'ocean', 'marinearea']); t.end(); }); diff --git a/test/unit/sanitizer/_layers.js b/test/unit/sanitizer/_layers.js index 11c618c8..adcffcc2 100644 --- a/test/unit/sanitizer/_layers.js +++ b/test/unit/sanitizer/_layers.js @@ -34,16 +34,17 @@ module.exports.tests.sanitize_layers = function(test, common) { t.deepEqual(clean.layers, venue_layers, 'venue layers set'); t.end(); }); - + test('coarse (alias) layer', function(t) { var raw = { layers: 'coarse' }; var clean = {}; sanitizer.sanitize(raw, clean); - var admin_layers = [ 'continent', 'country', 'dependency', - 'macroregion', 'region', 'locality', 'localadmin', 'macrocounty', 'county', - 'macrohood', 'borough', 'neighbourhood', 'microhood', 'disputed', 'postalcode' ]; + var admin_layers = [ 'continent', 'country', 'dependency', 'macroregion', + 'region', 'locality', 'localadmin', 'macrocounty', 'county', 'macrohood', + 'borough', 'neighbourhood', 'microhood', 'disputed', 'postalcode', 'ocean', + 'marinearea' ]; t.deepEqual(clean.layers, admin_layers, 'coarse layers set'); t.end(); @@ -78,7 +79,8 @@ module.exports.tests.sanitize_layers = function(test, common) { var expected_layers = [ 'continent', 'country', 'dependency', 'macroregion', 'region', 'locality', 'localadmin', 'macrocounty', 'county', - 'macrohood', 'borough', 'neighbourhood', 'microhood', 'disputed', 'postalcode' ]; + 'macrohood', 'borough', 'neighbourhood', 'microhood', 'disputed', 'postalcode', + 'ocean', 'marinearea']; t.deepEqual(clean.layers, expected_layers, 'coarse + regular layers set'); t.end(); @@ -115,7 +117,7 @@ module.exports.tests.sanitize_layers = function(test, common) { var coarse_layers = [ 'continent', 'country', 'dependency', 'macroregion', 'region', 'locality', 'localadmin', 'macrocounty', 'county', 'macrohood', 'borough', 'neighbourhood', 'microhood', - 'disputed', 'postalcode' ]; + 'disputed', 'postalcode', 'ocean', 'marinearea' ]; var venue_layers = [ 'venue' ]; var expected_layers = venue_layers.concat(coarse_layers);