Make `BoundingBoxHelper::parse_bbox_parameters`

It's used by `VisualizationQueryBuilder` for searches by BBOX
pull/11922/head
Javier Torres 8 years ago
parent a0548e9a33
commit a66167d631

@ -40,7 +40,7 @@ module Carto
.with_tags(tags)
if !bbox_parameter.blank?
vqb.with_bounding_box(BoundingBoxHelper.parse_bbox_parameters(bbox_parameter))
vqb.with_bounding_box(BoundingBoxHelper.new.parse_bbox_parameters(bbox_parameter))
end
# FIXME Patch to exclude legacy visualization from data-library #5097

@ -22,6 +22,14 @@ class Carto::BoundingBoxHelper
} if result
end
def parse_bbox_parameters(bounding_box)
bbox_coords = bounding_box.split(',').map { |coord| Float(coord) rescue nil }.compact
if bbox_coords.length != 4
raise CartoDB::BoundingBoxError.new('bounding box must have 4 coordinates: minx, miny, maxx, maxy')
end
{ minx: bbox_coords[0], miny: bbox_coords[1], maxx: bbox_coords[2], maxy: bbox_coords[3] }
end
private
# Postgis stats-based calculation of bounds. Much faster but not always present, so needs a fallback
@ -79,12 +87,4 @@ class Carto::BoundingBoxHelper
result
end
def parse_bbox_parameters(bounding_box)
bbox_coords = bounding_box.split(',').map { |coord| Float(coord) rescue nil }.compact
if bbox_coords.length != 4
raise CartoDB::BoundingBoxError.new('bounding box must have 4 coordinates: minx, miny, maxx, maxy')
end
{ minx: bbox_coords[0], miny: bbox_coords[1], maxx: bbox_coords[2], maxy: bbox_coords[3] }
end
end

Loading…
Cancel
Save