Browse Source

Change boundary.circle params to flat string structure

pull/271/head
Julian Simioni 9 years ago
parent
commit
4260442f59
  1. 4
      query/reverse.js
  2. 4
      query/search.js
  3. 6
      sanitiser/_geo_common.js
  4. 6
      test/unit/query/reverse.js
  5. 2
      test/unit/query/search.js
  6. 9
      test/unit/sanitiser/_geo_common.js

4
query/reverse.js

@ -33,8 +33,8 @@ function generateQuery( clean ){
// set radius, default to 500km if not specified in request
var radius = 500;
if (clean.hasOwnProperty('boundary_circle_radius')) {
radius = clean.boundary_circle_radius;
if (clean.hasOwnProperty('boundary.circle.radius')) {
radius = clean['boundary.circle.radius'];
}
// focus point centroid

4
query/search.js

@ -97,9 +97,9 @@ function generateQuery( clean ){
}
// boundary country
if( clean.boundary && clean.boundary.country ){
if( clean['boundary.country'] ){
vs.set({
'boundary:country': clean.boundary.country
'boundary:country': clean['boundary.country']
});
}

6
sanitiser/_geo_common.js

@ -64,9 +64,9 @@ function sanitize_coord( coord, clean, param, latlon_is_required ) {
*/
function sanitize_boundary_circle( clean, params, is_required, all_required ) {
var props = {
lat: 'boundary_circle_lat',
lon: 'boundary_circle_lon',
rad: 'boundary_circle_radius'
lat: 'boundary.circle.lat',
lon: 'boundary.circle.lon',
rad: 'boundary.circle.radius'
};
// get values for each property

6
test/unit/query/reverse.js

@ -24,7 +24,7 @@ module.exports.tests.query = function(test, common) {
test('valid query with radius', function(t) {
var query = generate({
lat: 29.49136, lon: -82.50622, boundary_circle_radius: 123
lat: 29.49136, lon: -82.50622, 'boundary.circle.radius': 123
});
var compiled = JSON.parse( JSON.stringify( query )).query.filtered.filter.bool.must[0].geo_distance.distance;
@ -38,8 +38,8 @@ module.exports.tests.query = function(test, common) {
var clean = {
lat: 29.49136,
lon: -82.50622,
boundary_circle_lat: 111,
boundary_circle_long: 333
'boundary.circle.lat': 111,
'boundary.circle.long': 333
};
var query = generate(clean);

2
test/unit/query/search.js

@ -138,7 +138,7 @@ module.exports.tests.query = function(test, common) {
var query = generate({
text: 'test', size: 10,
layers: ['test'],
boundary: { country: 'ABC' }
'boundary.country': 'ABC'
});
var compiled = JSON.parse( JSON.stringify( query ) );

9
test/unit/sanitiser/_geo_common.js

@ -23,11 +23,12 @@ module.exports.tests.sanitize = function(test, common) {
var all_required = true;
sanitize.sanitize_boundary_circle(clean, params, is_required, all_required);
t.equal(clean.boundary_circle_lat, params['boundary.circle.lat'], 'lat approved');
t.equal(clean.boundary_circle_lon, params['boundary.circle.lon'], 'lon approved');
t.equal(clean.boundary_circle_radius, params['boundary.circle.radius'], 'radius approved');
t.equal(clean['boundary.circle.lat'], params['boundary.circle.lat'], 'lat approved');
t.equal(clean['boundary.circle.lon'], params['boundary.circle.lon'], 'lon approved');
t.equal(clean['boundary.circle.radius'], params['boundary.circle.radius'], 'radius approved');
t.end();
});
test('valid circle, radius only, all not required', function (t) {
var clean = {};
var params = {
@ -37,7 +38,7 @@ module.exports.tests.sanitize = function(test, common) {
var all_required = false;
sanitize.sanitize_boundary_circle(clean, params, is_required, all_required);
t.equal(clean.boundary_circle_radius, params['boundary.circle.radius'], 'radius approved');
t.equal(clean['boundary.circle.radius'], params['boundary.circle.radius'], 'radius approved');
t.end();
});
};

Loading…
Cancel
Save