Browse Source

Remove latitude restrictions

pull/178/head
Julian Simioni 10 years ago
parent
commit
b547111d52
  1. 10
      sanitiser/_geo.js
  2. 4
      test/unit/sanitiser/reverse.js
  3. 4
      test/unit/sanitiser/search.js
  4. 4
      test/unit/sanitiser/suggest.js

10
sanitiser/_geo.js

@ -76,9 +76,6 @@ function sanitize_bbox( clean, param ) {
function sanitize_coord( coord, clean, param, latlon_is_required ) {
var value = parseFloat( param );
if ( !isNaN( value ) ) {
if( coord === 'lat' && check_lat.is_invalid( value ) ){
throw new Error( 'invalid ' + check_lat.error_msg );
}
clean[coord] = value;
}
else if (latlon_is_required) {
@ -92,10 +89,3 @@ function sanitize_zoom_level( clean, param ) {
clean.zoom = Math.min( Math.max( zoom, 1 ), 18 ); // max
}
}
var check_lat = {
is_invalid: function is_invalid_lat( lat ){
return isNaN( lat ) || lat < -90 || lat > 90;
},
error_msg: 'param \'lat\': must be >-90 and <90'
};

4
test/unit/sanitiser/reverse.js

@ -32,8 +32,8 @@ module.exports.tests.interface = function(test, common) {
module.exports.tests.sanitize_lat = function(test, common) {
var lats = {
invalid: [ -181, -120, -91, 91, 120, 181 ],
valid: [ 0, 45, 90, -0, '0', '45', '90' ],
invalid: [],
valid: [ 0, 45, 90, -0, '0', '45', '90', -181, -120, -91, 91, 120, 181 ],
missing: ['', undefined, null]
};
test('invalid lat', function(t) {

4
test/unit/sanitiser/search.js

@ -84,8 +84,8 @@ module.exports.tests.sanitize_input_with_delim = function(test, common) {
module.exports.tests.sanitize_lat = function(test, common) {
var lats = {
invalid: [ -181, -120, -91, 91, 120, 181 ],
valid: [ 0, 45, 90, -0, '0', '45', '90' ]
invalid: [],
valid: [ 0, 45, 90, -0, '0', '45', '90', -181, -120, -91, 91, 120, 181 ]
};
test('invalid lat', function(t) {
lats.invalid.forEach( function( lat ){

4
test/unit/sanitiser/suggest.js

@ -82,8 +82,8 @@ module.exports.tests.sanitize_input_with_delim = function(test, common) {
module.exports.tests.sanitize_lat = function(test, common) {
var lats = {
invalid: [ -181, -120, -91, 91, 120, 181 ],
valid: [ 0, 45, 90, -0, '0', '45', '90' ]
invalid: [],
valid: [ 0, 45, 90, -0, '0', '45', '90', -181, -120, -91, 91, 120, 181 ]
};
test('invalid lat', function(t) {
lats.invalid.forEach( function( lat ){

Loading…
Cancel
Save