Browse Source

chore(geo_common): only set bbox coords if it validates

pull/1207/head
Julian Simioni 6 years ago
parent
commit
3c33b98f8a
No known key found for this signature in database
GPG Key ID: B9EEB0C6EE0910A1
  1. 11
      sanitizer/_geo_common.js

11
sanitizer/_geo_common.js

@ -34,12 +34,6 @@ function sanitize_rect( key_prefix, clean, raw, bbox_is_required ) {
// and not present // and not present
if (!bbox_present) { return; } if (!bbox_present) { return; }
// check each property individually. now that it is known a bbox is present,
// all properties must exist, so pass the true flag for coord_is_required
properties.forEach(function(prop) {
sanitize_coord(prop, clean, raw, true);
});
var min_lat = parseFloat( raw[key_prefix + '.' + 'min_lat'] ); var min_lat = parseFloat( raw[key_prefix + '.' + 'min_lat'] );
var max_lat = parseFloat( raw[key_prefix + '.' + 'max_lat'] ); var max_lat = parseFloat( raw[key_prefix + '.' + 'max_lat'] );
if (min_lat > max_lat) { if (min_lat > max_lat) {
@ -51,6 +45,11 @@ function sanitize_rect( key_prefix, clean, raw, bbox_is_required ) {
if (min_lon > max_lon) { if (min_lon > max_lon) {
throw new Error( util.format( 'min_lon is larger than max_lon in \'%s\'', key_prefix ) ); throw new Error( util.format( 'min_lon is larger than max_lon in \'%s\'', key_prefix ) );
} }
// use sanitize_coord to set values in `clean`
properties.forEach(function(prop) {
sanitize_coord(prop, clean, raw, true);
});
} }
/** /**

Loading…
Cancel
Save