Browse Source

Remove all references to non-existent zoom parameter

pull/230/head
Julian Simioni 9 years ago
parent
commit
fd3b12cfa9
  1. 3
      public/apiDoc.md
  2. 8
      sanitiser/_geo.js
  3. 21
      test/unit/sanitiser/search.js

3
public/apiDoc.md

@ -7,7 +7,6 @@ The full text search endpoint that matches the name of a place to points on the
#### Optional Parameters
* `lat`, `lon`: the latitude/longitude coordinates to bias search results towards (may increase relevancy)
* `zoom`: zoom level from which you wish to view the world
* `size` (default: `10`): the number of results to return
* `layers` (default: `poi,admin,address`): the comma-separated names of datasets you wish to query. Valid values are:
* aliases for multiple datasets like `poi`, `admin` or `address`
@ -48,7 +47,6 @@ results from around the provided lat/lon coordinates and also from precision lev
* `lat`/`lon` are currently **required** because of this [open issue](https://github.com/elasticsearch/elasticsearch/issues/6444)
#### Optional Parameters
* `zoom`: zoom level from which you wish to view the world
* `size` (default: `10`): number of results requested
* `layers` (default: `poi,admin,address`): datasets you wish to query
* `details` (default: `true`)
@ -84,7 +82,6 @@ The reverse geocoding endpoint; matches a point on the planet to the name of tha
* `lat`, `lon`: The coordinates of the point.
#### Optional Parameters
* `zoom`: zoom level from which you wish to view the world
* `layers` (default: `poi,admin,address`)
* `details` (default: `true`)

8
sanitiser/_geo.js

@ -17,7 +17,6 @@ module.exports = function sanitize( req, latlon_is_required ){
try {
sanitize_coord( 'lat', clean, params.lat, latlon_is_required );
sanitize_coord( 'lon', clean, params.lon, latlon_is_required );
sanitize_zoom_level(clean, params.zoom);
sanitize_bbox(clean, params.bbox);
}
catch (err) {
@ -82,10 +81,3 @@ function sanitize_coord( coord, clean, param, latlon_is_required ) {
throw new Error( util.format( 'missing param \'%s\'', coord ) );
}
}
function sanitize_zoom_level( clean, param ) {
var zoom = parseInt( param, 10 );
if( !isNaN( zoom ) ){
clean.zoom = Math.min( Math.max( zoom, 1 ), 18 ); // max
}
}

21
test/unit/sanitiser/search.js

@ -214,27 +214,6 @@ module.exports.tests.sanitize_bbox = function(test, common) {
});
};
module.exports.tests.sanitize_zoom = function(test, common) {
test('invalid zoom value', function(t) {
sanitize({ zoom: 'a', text: 'test', lat: 0, lon: 0 }, function( err, clean ){
t.equal(clean.zoom, undefined, 'zoom not set');
t.end();
});
});
test('below min zoom value', function(t) {
sanitize({ zoom: -100, text: 'test', lat: 0, lon: 0 }, function( err, clean ){
t.equal(clean.zoom, 1, 'min zoom set');
t.end();
});
});
test('above max zoom value', function(t) {
sanitize({ zoom: 9999, text: 'test', lat: 0, lon: 0 }, function( err, clean ){
t.equal(clean.zoom, 18, 'max zoom set');
t.end();
});
});
};
module.exports.tests.sanitize_size = function(test, common) {
test('invalid size value', function(t) {
sanitize({ size: 'a', text: 'test', lat: 0, lon: 0 }, function( err, clean ){

Loading…
Cancel
Save