Class: Underpass::QL::BoundingBox

Inherits:
Object
  • Object
show all
Defined in:
lib/underpass/ql/bounding_box.rb

Overview

Converts RGeo geometries and WKT strings into Overpass QL bounding box syntax.

Class Method Summary collapse

Class Method Details

.from_geometry(geometry) ⇒ String

Returns the Overpass QL bounding box string from an RGeo geometry.

Parameters:

  • geometry (RGeo::Feature::Geometry)

    an RGeo geometry

Returns:

  • (String)

    an Overpass QL bounding box (e.g. +“bbox:47.65,23.669,47.674,23.725”+)



21
22
23
24
# File 'lib/underpass/ql/bounding_box.rb', line 21

def from_geometry(geometry)
  r_bb = RGeo::Cartesian::BoundingBox.create_from_geometry(geometry)
  "bbox:#{r_bb.min_y},#{r_bb.min_x},#{r_bb.max_y},#{r_bb.max_x}"
end

.from_wkt(wkt) ⇒ String

Returns the Overpass QL bounding box string from a WKT string.

Parameters:

  • wkt (String)

    a Well Known Text geometry string

Returns:

  • (String)

    an Overpass QL bounding box (e.g. +“bbox:47.65,23.669,47.674,23.725”+)



12
13
14
15
# File 'lib/underpass/ql/bounding_box.rb', line 12

def from_wkt(wkt)
  geometry = RGeo::Geographic.spherical_factory.parse_wkt(wkt)
  from_geometry(geometry)
end