Class: Underpass::QL::Shape

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

Overview

Contains factories for various shapes from ways and nodes.

Class Method Summary collapse

Class Method Details

.line_string_from_way(way, nodes) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/underpass/ql/shape.rb', line 12

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

.polygon_from_way(way, nodes) ⇒ Object



7
8
9
10
# File 'lib/underpass/ql/shape.rb', line 7

def self.polygon_from_way(way, nodes)
  f = RGeo::Geographic.spherical_factory(srid: 4326)
  f.polygon(line_string_from_way(way, nodes))
end