Browse Source

Move bbox min/max check to its own function

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

17
sanitizer/_geo_common.js

@ -33,7 +33,17 @@ function sanitize_rect( key_prefix, clean, raw, bbox_is_required ) {
// and not present
if (!bbox_present) { return; }
sanitize_bbox_min_max(raw, key_prefix);
sanitize_bbox_bounds(raw, key_prefix);
// use sanitize_coord to set values in `clean`
properties.forEach(function(prop) {
sanitize_coord(prop, clean, raw, true);
});
}
// validate max is greater than min for lat and lon
function sanitize_bbox_min_max(raw, key_prefix) {
['lat', 'lon'].forEach(function(dimension) {
const max = parseFloat(raw[`${key_prefix}.max_${dimension}`]);
const min = parseFloat(raw[`${key_prefix}.min_${dimension}`]);
@ -42,13 +52,6 @@ function sanitize_rect( key_prefix, clean, raw, bbox_is_required ) {
throw new Error(`min_${dimension} is larger than max_${dimension} in ${key_prefix}`);
}
});
sanitize_bbox_bounds(raw, key_prefix);
// use sanitize_coord to set values in `clean`
properties.forEach(function(prop) {
sanitize_coord(prop, clean, raw, true);
});
}
// validate lat/lon values are within bounds

Loading…
Cancel
Save