From a66167d63118ba13689e3ed2f43e2d19f04f0111 Mon Sep 17 00:00:00 2001 From: Javier Torres Date: Wed, 5 Apr 2017 14:52:46 +0200 Subject: [PATCH] Make `BoundingBoxHelper::parse_bbox_parameters` It's used by `VisualizationQueryBuilder` for searches by BBOX --- .../carto/api/visualization_searcher.rb | 2 +- lib/carto/bounding_box_helper.rb | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/carto/api/visualization_searcher.rb b/app/controllers/carto/api/visualization_searcher.rb index bf80c517e2..74d45dff1e 100644 --- a/app/controllers/carto/api/visualization_searcher.rb +++ b/app/controllers/carto/api/visualization_searcher.rb @@ -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 diff --git a/lib/carto/bounding_box_helper.rb b/lib/carto/bounding_box_helper.rb index ae5e204f30..f458a8af9d 100644 --- a/lib/carto/bounding_box_helper.rb +++ b/lib/carto/bounding_box_helper.rb @@ -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