class Underpass::QL::Shape

Contains factories for various RGeo shapes from ways and nodes parsed with the Parser class

Public Class Methods

line_string_from_way(way, nodes) click to toggle source
# File lib/underpass/ql/shape.rb, line 17
def self.line_string_from_way(way, nodes)
  f = RGeo::Geographic.spherical_factory(srid: 4326)
  f.line_string(
    way[:nodes].map do |n|
      f.point(nodes[n][:lon], nodes[n][:lat])
    end
  )
end
open_way?(way) click to toggle source
# File lib/underpass/ql/shape.rb, line 8
def self.open_way?(way)
  way[:nodes].first == way[:nodes].last
end
point_from_node(node) click to toggle source
# File lib/underpass/ql/shape.rb, line 26
def self.point_from_node(node)
  f = RGeo::Geographic.spherical_factory(srid: 4326)
  f.point(node[:lon], node[:lat])
end
polygon_from_way(way, nodes) click to toggle source
# File lib/underpass/ql/shape.rb, line 12
def self.polygon_from_way(way, nodes)
  f = RGeo::Geographic.spherical_factory(srid: 4326)
  f.polygon(line_string_from_way(way, nodes))
end