class Road

Road/Street/Via/Autoban

Attributes

city[R]
geom[RW]
kind[R]
name[R]
nation[R]
region[R]
table[R]
zone[R]

Public Class Methods

new(keys, vals, nation = nil, city = nil) click to toggle source
# 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

Public Instance Methods

parse_geom(hex) click to toggle source
# 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) click to toggle source
# 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