@ -5,8 +5,10 @@ var suggest = require('../../../sanitiser/reverse'),
delim = ',' ,
defaultError = 'missing param \'lat\'' ,
defaultClean = { lat : 0 ,
layers : [ 'geoname' , 'osmnode' , 'osmway' , 'admin0' , 'admin1' , 'admin2' , 'neighborhood' ,
'locality' , 'local_admin' , 'osmaddress' , 'openaddresses' ] ,
types : {
from _layers : [ 'geoname' , 'osmnode' , 'osmway' , 'admin0' , 'admin1' , 'admin2' , 'neighborhood' ,
'locality' , 'local_admin' , 'osmaddress' , 'openaddresses' ] ,
} ,
lon : 0 ,
size : 10 ,
details : true ,
@ -158,7 +160,7 @@ module.exports.tests.sanitize_details = function(test, common) {
module . exports . tests . sanitize _layers = function ( test , common ) {
test ( 'unspecified' , function ( t ) {
sanitize ( { layers : undefined , input : 'test' , lat : 0 , lon : 0 } , function ( err , clean ) {
t . deepEqual ( clean . layers , defaultClean . layers , 'default layers set' ) ;
t . deepEqual ( clean . types . from _ layers, defaultClean . types . from _ layers, 'default layers set' ) ;
t . end ( ) ;
} ) ;
} ) ;
@ -173,21 +175,21 @@ module.exports.tests.sanitize_layers = function(test, common) {
test ( 'poi (alias) layer' , function ( t ) {
var poi _layers = [ 'geoname' , 'osmnode' , 'osmway' ] ;
sanitize ( { layers : 'poi' , input : 'test' , lat : 0 , lon : 0 } , function ( err , clean ) {
t . deepEqual ( clean . layers , poi _layers , 'poi layers set' ) ;
t . deepEqual ( clean . types . from _ layers, poi _layers , 'poi layers set' ) ;
t . end ( ) ;
} ) ;
} ) ;
test ( 'admin (alias) layer' , function ( t ) {
var admin _layers = [ 'admin0' , 'admin1' , 'admin2' , 'neighborhood' , 'locality' , 'local_admin' ] ;
sanitize ( { layers : 'admin' , input : 'test' , lat : 0 , lon : 0 } , function ( err , clean ) {
t . deepEqual ( clean . layers , admin _layers , 'admin layers set' ) ;
t . deepEqual ( clean . types . from _ layers, admin _layers , 'admin layers set' ) ;
t . end ( ) ;
} ) ;
} ) ;
test ( 'address (alias) layer' , function ( t ) {
var address _layers = [ 'osmaddress' , 'openaddresses' ] ;
sanitize ( { layers : 'address' , input : 'test' , lat : 0 , lon : 0 } , function ( err , clean ) {
t . deepEqual ( clean . layers , address _layers , 'address layers set' ) ;
t . deepEqual ( clean . types . from _ layers, address _layers , 'address layers set' ) ;
t . end ( ) ;
} ) ;
} ) ;
@ -195,7 +197,7 @@ module.exports.tests.sanitize_layers = function(test, common) {
var poi _layers = [ 'geoname' , 'osmnode' , 'osmway' ] ;
var reg _layers = [ 'admin0' , 'admin1' ] ;
sanitize ( { layers : 'poi,admin0,admin1' , input : 'test' , lat : 0 , lon : 0 } , function ( err , clean ) {
t . deepEqual ( clean . layers , reg _layers . concat ( poi _layers ) , 'poi + regular layers' ) ;
t . deepEqual ( clean . types . from _ layers, reg _layers . concat ( poi _layers ) , 'poi + regular layers' ) ;
t . end ( ) ;
} ) ;
} ) ;
@ -203,7 +205,7 @@ module.exports.tests.sanitize_layers = function(test, common) {
var admin _layers = [ 'admin0' , 'admin1' , 'admin2' , 'neighborhood' , 'locality' , 'local_admin' ] ;
var reg _layers = [ 'geoname' , 'osmway' ] ;
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 . types . from _ layers, reg _layers . concat ( admin _layers ) , 'admin + regular layers set' ) ;
t . end ( ) ;
} ) ;
} ) ;
@ -211,21 +213,21 @@ module.exports.tests.sanitize_layers = function(test, common) {
var address _layers = [ 'osmaddress' , 'openaddresses' ] ;
var reg _layers = [ 'geoname' , 'osmway' ] ;
sanitize ( { layers : 'address,geoname,osmway' , input : 'test' , lat : 0 , lon : 0 } , function ( err , clean ) {
t . deepEqual ( clean . layers , reg _layers . concat ( address _layers ) , 'address + regular layers set' ) ;
t . deepEqual ( clean . types . from _ layers, reg _layers . concat ( address _layers ) , 'address + regular layers set' ) ;
t . end ( ) ;
} ) ;
} ) ;
test ( 'alias layer plus regular layers (no duplicates)' , function ( t ) {
var poi _layers = [ 'geoname' , 'osmnode' , 'osmway' ] ;
sanitize ( { layers : 'poi,geoname,osmnode' , input : 'test' , lat : 0 , lon : 0 } , function ( err , clean ) {
t . deepEqual ( clean . layers , poi _layers , 'poi layers found (no duplicates)' ) ;
t . deepEqual ( clean . types . from _ layers, poi _layers , 'poi layers found (no duplicates)' ) ;
t . end ( ) ;
} ) ;
} ) ;
test ( 'multiple alias layers (no duplicates)' , function ( t ) {
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 ) {
t . deepEqual ( clean . layers , alias _layers , 'all layers found (no duplicates)' ) ;
t . deepEqual ( clean . types . from _ layers, alias _layers , 'all layers found (no duplicates)' ) ;
t . end ( ) ;
} ) ;
} ) ;