Class: Underpass::QL::Shape
- Inherits:
-
Object
- Object
- Underpass::QL::Shape
- Defined in:
- lib/underpass/ql/shape.rb
Overview
Contains factories for various RGeo shapes from ways and nodes parsed with the Parser class
Class Method Summary collapse
- .line_string_from_way(way, nodes) ⇒ Object
- .open_way?(way) ⇒ Boolean
- .point_from_node(node) ⇒ Object
- .polygon_from_way(way, nodes) ⇒ Object
Class Method Details
.line_string_from_way(way, nodes) ⇒ Object
17 18 19 20 21 22 23 24 |
# 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) ⇒ Boolean
8 9 10 |
# File 'lib/underpass/ql/shape.rb', line 8 def self.open_way?(way) way[:nodes].first == way[:nodes].last end |
.point_from_node(node) ⇒ Object
26 27 28 29 |
# 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) ⇒ Object
12 13 14 15 |
# 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 |