Browse Source

Merge pull request #98 from pelias/add-layers

adding 'locality', 'local_admin' to the list of layers
pull/107/head
Harish Krishna 10 years ago
parent
commit
46f487d819
  1. 2
      helper/layers.js
  2. 2
      query/indeces.js
  3. 2
      test/unit/query/indeces.js
  4. 4
      test/unit/sanitiser/coarse.js
  5. 8
      test/unit/sanitiser/suggest.js

2
helper/layers.js

@ -13,7 +13,7 @@ module.exports = function(alias_layers) {
}; };
layers = expand_aliases('poi', layers, ['geoname','osmnode','osmway']); layers = expand_aliases('poi', layers, ['geoname','osmnode','osmway']);
layers = expand_aliases('admin', layers, ['admin0','admin1','admin2','neighborhood']); layers = expand_aliases('admin', layers, ['admin0','admin1','admin2','neighborhood','locality','local_admin']);
layers = expand_aliases('address', layers, ['osmaddress','openaddresses']); layers = expand_aliases('address', layers, ['osmaddress','openaddresses']);
// de-dupe // de-dupe

2
query/indeces.js

@ -9,6 +9,8 @@ module.exports = [
'admin1', 'admin1',
'admin2', 'admin2',
'neighborhood', 'neighborhood',
'locality',
'local_admin',
'osmaddress', 'osmaddress',
'openaddresses' 'openaddresses'
]; ];

2
test/unit/query/indeces.js

@ -6,7 +6,7 @@ module.exports.tests = {};
module.exports.tests.interface = function(test, common) { module.exports.tests.interface = function(test, common) {
test('valid interface', function(t) { test('valid interface', function(t) {
t.true(Array.isArray(indeces), 'valid array'); t.true(Array.isArray(indeces), 'valid array');
t.equal(indeces.length, 9, 'valid array'); t.equal(indeces.length, 11, 'valid array');
t.end(); t.end();
}); });
}; };

4
test/unit/sanitiser/coarse.js

@ -2,7 +2,7 @@
var coarse = require('../../../sanitiser/coarse'), var coarse = require('../../../sanitiser/coarse'),
_sanitize = coarse.sanitize, _sanitize = coarse.sanitize,
middleware = coarse.middleware, middleware = coarse.middleware,
valid_layers = [ 'admin0', 'admin1', 'admin2', 'neighborhood' ], valid_layers = [ 'admin0', 'admin1', 'admin2', 'neighborhood', 'locality', 'local_admin' ],
sanitize = function(query, cb) { _sanitize({'query':query}, cb); }; sanitize = function(query, cb) { _sanitize({'query':query}, cb); };
module.exports.tests = {}; module.exports.tests = {};
@ -51,7 +51,7 @@ module.exports.tests.middleware_success = function(test, common) {
var defaultClean = { var defaultClean = {
input: 'test', input: 'test',
size: 10, size: 10,
layers: [ 'admin0', 'admin1', 'admin2', 'neighborhood' ], layers: [ 'admin0', 'admin1', 'admin2', 'neighborhood', 'locality', 'local_admin' ],
lat: 0, lat: 0,
lon: 0 lon: 0
}; };

8
test/unit/sanitiser/suggest.js

@ -7,7 +7,7 @@ var suggest = require('../../../sanitiser/suggest'),
defaultClean = { input: 'test', defaultClean = { input: 'test',
lat:0, lat:0,
layers: [ 'geoname', 'osmnode', 'osmway', 'admin0', 'admin1', 'admin2', 'neighborhood', layers: [ 'geoname', 'osmnode', 'osmway', 'admin0', 'admin1', 'admin2', 'neighborhood',
'osmaddress', 'openaddresses' ], 'locality', 'local_admin', 'osmaddress', 'openaddresses' ],
lon: 0, lon: 0,
size: 10 size: 10
}, },
@ -258,7 +258,7 @@ module.exports.tests.sanitize_layers = function(test, common) {
}); });
}); });
test('admin (alias) layer', function(t) { test('admin (alias) layer', function(t) {
var admin_layers = ['admin0','admin1','admin2','neighborhood']; var admin_layers = ['admin0','admin1','admin2','neighborhood','locality','local_admin'];
sanitize({ layers: 'admin', input: 'test', lat: 0, lon: 0 }, function( err, clean ){ sanitize({ layers: 'admin', input: 'test', lat: 0, lon: 0 }, function( err, clean ){
t.deepEqual(clean.layers, admin_layers, 'admin layers set'); t.deepEqual(clean.layers, admin_layers, 'admin layers set');
t.end(); t.end();
@ -280,7 +280,7 @@ module.exports.tests.sanitize_layers = function(test, common) {
}); });
}); });
test('admin alias layer plus regular layers', function(t) { test('admin alias layer plus regular layers', function(t) {
var admin_layers = ['admin0','admin1','admin2','neighborhood']; var admin_layers = ['admin0','admin1','admin2','neighborhood','locality','local_admin'];
var reg_layers = ['geoname', 'osmway']; var reg_layers = ['geoname', 'osmway'];
sanitize({ layers: 'admin,geoname,osmway', input: 'test', lat: 0, lon: 0 }, function( err, clean ){ sanitize({ layers: 'admin,geoname,osmway', input: 'test', lat: 0, lon: 0 }, function( err, clean ){
t.deepEqual(clean.layers, reg_layers.concat(admin_layers), 'admin + regular layers set'); t.deepEqual(clean.layers, reg_layers.concat(admin_layers), 'admin + regular layers set');
@ -303,7 +303,7 @@ module.exports.tests.sanitize_layers = function(test, common) {
}); });
}); });
test('multiple alias layers (no duplicates)', function(t) { test('multiple alias layers (no duplicates)', function(t) {
var alias_layers = ['geoname','osmnode','osmway','admin0','admin1','admin2','neighborhood']; var alias_layers = ['geoname','osmnode','osmway','admin0','admin1','admin2','neighborhood','locality','local_admin'];
sanitize({ layers: 'poi,admin', input: 'test', lat: 0, lon: 0 }, function( err, clean ){ sanitize({ layers: 'poi,admin', input: 'test', lat: 0, lon: 0 }, function( err, clean ){
t.deepEqual(clean.layers, alias_layers, 'all layers found (no duplicates)'); t.deepEqual(clean.layers, alias_layers, 'all layers found (no duplicates)');
t.end(); t.end();

Loading…
Cancel
Save