Class: Road
- Inherits:
-
Object
- Object
- Road
- Defined in:
- lib/geonames_local/features/road.rb
Overview
Road/Street/Via/Autoban
Instance Attribute Summary collapse
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#geom ⇒ Object
Returns the value of attribute geom.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#nation ⇒ Object
readonly
Returns the value of attribute nation.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
-
#zone ⇒ Object
readonly
Returns the value of attribute zone.
Instance Method Summary collapse
-
#initialize(keys, vals, nation = nil, city = nil) ⇒ Road
constructor
A new instance of Road.
- #parse_geom(hex) ⇒ Object
- #parse_kind(k) ⇒ Object
Constructor Details
#initialize(keys, vals, nation = nil, city = nil) ⇒ Road
Returns a new instance of Road.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/geonames_local/features/road.rb', line 7 def initialize(keys, vals, nation = nil, city = nil) s = vals.split("\t") r = {} keys.each_with_index do |k, i| r[k] = s[i] end @name = r[:name] @zone = r[:zone] kind = r[:kind] || @name.split(' ')[0] @geom = parse_geom(r[:geom]) @kind = parse_kind(kind) @city = city @nation = nation @table = :roads end |
Instance Attribute Details
#city ⇒ Object (readonly)
Returns the value of attribute city.
5 6 7 |
# File 'lib/geonames_local/features/road.rb', line 5 def city @city end |
#geom ⇒ Object
Returns the value of attribute geom.
5 6 7 |
# File 'lib/geonames_local/features/road.rb', line 5 def geom @geom end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
5 6 7 |
# File 'lib/geonames_local/features/road.rb', line 5 def kind @kind end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/geonames_local/features/road.rb', line 5 def name @name end |
#nation ⇒ Object (readonly)
Returns the value of attribute nation.
5 6 7 |
# File 'lib/geonames_local/features/road.rb', line 5 def nation @nation end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
5 6 7 |
# File 'lib/geonames_local/features/road.rb', line 5 def region @region end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
5 6 7 |
# File 'lib/geonames_local/features/road.rb', line 5 def table @table end |
#zone ⇒ Object (readonly)
Returns the value of attribute zone.
5 6 7 |
# File 'lib/geonames_local/features/road.rb', line 5 def zone @zone end |
Instance Method Details
#parse_geom(hex) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/geonames_local/features/road.rb', line 23 def parse_geom(hex) if hex =~ /^SRID/ # PG 8.3 support hex = hex.split(';')[1] end GeoRuby::SimpleFeatures::Geometry.from_hex_ewkb(hex) end |
#parse_kind(k) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/geonames_local/features/road.rb', line 32 def parse_kind(k) case k when /^tun/i then :tunnel when /^av/i then :avenue when /^r/i then :street when /\d/ then :road else :unknown end end |