Browse Source

added support for continent, ocean, and marinearea placetypes

`coarse` now maps to these as well
pull/1002/head
Stephen Hess 7 years ago
parent
commit
e70a668056
  1. 5
      controller/coarse_reverse.js
  2. 6
      helper/type_mapping.js
  3. 35
      test/unit/controller/coarse_reverse.js
  4. 4
      test/unit/controller/predicates/is_coarse_reverse.js
  5. 3
      test/unit/helper/type_mapping.js
  6. 12
      test/unit/sanitizer/_layers.js

5
controller/coarse_reverse.js

@ -15,7 +15,10 @@ const coarse_granularities = [
'region', 'region',
'macroregion', 'macroregion',
'dependency', 'dependency',
'country' 'country',
'continent',
'ocean',
'marinearea'
]; ];
// remove non-coarse layers and return what's left (or all if empty) // remove non-coarse layers and return what's left (or all if empty)

6
helper/type_mapping.js

@ -51,7 +51,8 @@ var LAYERS_BY_SOURCE = {
'locality','borough', 'neighbourhood', 'venue' ], 'locality','borough', 'neighbourhood', 'venue' ],
whosonfirst: [ 'continent', 'country', 'dependency', 'macroregion', 'region', whosonfirst: [ 'continent', 'country', 'dependency', 'macroregion', 'region',
'locality', 'localadmin', 'macrocounty', 'county', 'macrohood', 'borough', '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 = { var LAYER_ALIASES = {
'coarse': [ 'continent', 'country', 'dependency', 'macroregion', 'region', 'coarse': [ 'continent', 'country', 'dependency', 'macroregion', 'region',
'locality', 'localadmin', 'macrocounty', 'county', 'macrohood', 'borough', '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 // create a list of all layers by combining each entry from LAYERS_BY_SOURCE

35
test/unit/controller/coarse_reverse.js

@ -210,6 +210,18 @@ module.exports.tests.success_conditions = (test, common) => {
country: [ country: [
{ id: 100, name: 'country name', abbr: 'xyz'}, { id: 100, name: 'country name', abbr: 'xyz'},
{ id: 101, name: 'country name 2'} { 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'], dependency_a: ['dependency abbr'],
country: ['country name'], country: ['country name'],
country_id: ['100'], 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: { center_point: {
lat: 12.121212, lat: 12.121212,
@ -822,6 +843,18 @@ module.exports.tests.failure_conditions = (test, common) => {
country: [ country: [
{ id: 100, name: 'country name', abbr: 'xyz'}, { id: 100, name: 'country name', abbr: 'xyz'},
{ id: 101, name: 'country name 2'} { 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'}
] ]
}; };

4
test/unit/controller/predicates/is_coarse_reverse.js

@ -17,7 +17,9 @@ const coarse_layers = [
'borough', 'borough',
'neighbourhood', 'neighbourhood',
'microhood', 'microhood',
'disputed' 'disputed',
'ocean',
'marinearea'
]; ];
module.exports.tests = {}; module.exports.tests = {};

3
test/unit/helper/type_mapping.js

@ -14,7 +14,8 @@ module.exports.tests.interfaces = function(test, common) {
t.deepEquals(type_mapping.layer_mapping.coarse, t.deepEquals(type_mapping.layer_mapping.coarse,
[ 'continent', 'country', 'dependency', 'macroregion', [ 'continent', 'country', 'dependency', 'macroregion',
'region', 'locality', 'localadmin', 'macrocounty', 'county', 'macrohood', 'region', 'locality', 'localadmin', 'macrocounty', 'county', 'macrohood',
'borough', 'neighbourhood', 'microhood', 'disputed', 'postalcode' ]); 'borough', 'neighbourhood', 'microhood', 'disputed', 'postalcode',
'continent', 'ocean', 'marinearea']);
t.end(); t.end();
}); });

12
test/unit/sanitizer/_layers.js

@ -41,9 +41,10 @@ module.exports.tests.sanitize_layers = function(test, common) {
sanitizer.sanitize(raw, clean); sanitizer.sanitize(raw, clean);
var admin_layers = [ 'continent', 'country', 'dependency', var admin_layers = [ 'continent', 'country', 'dependency', 'macroregion',
'macroregion', 'region', 'locality', 'localadmin', 'macrocounty', 'county', 'region', 'locality', 'localadmin', 'macrocounty', 'county', 'macrohood',
'macrohood', 'borough', 'neighbourhood', 'microhood', 'disputed', 'postalcode' ]; 'borough', 'neighbourhood', 'microhood', 'disputed', 'postalcode', 'ocean',
'marinearea' ];
t.deepEqual(clean.layers, admin_layers, 'coarse layers set'); t.deepEqual(clean.layers, admin_layers, 'coarse layers set');
t.end(); t.end();
@ -78,7 +79,8 @@ module.exports.tests.sanitize_layers = function(test, common) {
var expected_layers = [ 'continent', 'country', 'dependency', var expected_layers = [ 'continent', 'country', 'dependency',
'macroregion', 'region', 'locality', 'localadmin', 'macrocounty', 'county', '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.deepEqual(clean.layers, expected_layers, 'coarse + regular layers set');
t.end(); t.end();
@ -115,7 +117,7 @@ module.exports.tests.sanitize_layers = function(test, common) {
var coarse_layers = [ 'continent', var coarse_layers = [ 'continent',
'country', 'dependency', 'macroregion', 'region', 'locality', 'localadmin', 'country', 'dependency', 'macroregion', 'region', 'locality', 'localadmin',
'macrocounty', 'county', 'macrohood', 'borough', 'neighbourhood', 'microhood', 'macrocounty', 'county', 'macrohood', 'borough', 'neighbourhood', 'microhood',
'disputed', 'postalcode' ]; 'disputed', 'postalcode', 'ocean', 'marinearea' ];
var venue_layers = [ 'venue' ]; var venue_layers = [ 'venue' ];
var expected_layers = venue_layers.concat(coarse_layers); var expected_layers = venue_layers.concat(coarse_layers);

Loading…
Cancel
Save