Class: Nominatim::Place

Inherits:
Object
  • Object
show all
Defined in:
lib/nominatim/place.rb

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Place

attr_reader :attrs alias to_hash attrs


6
7
8
# File 'lib/nominatim/place.rb', line 6

def initialize(attrs = {})
  @attrs = attrs
end

Instance Method Details

#addressNominatim::Address

Return an address

Returns:


34
35
36
# File 'lib/nominatim/place.rb', line 34

def address
  @address ||= Nominatim::Address.new(@attrs[:address]) if @attrs[:address]
end

#boundingboxObject Also known as: bounding_box


54
55
56
# File 'lib/nominatim/place.rb', line 54

def boundingbox
  @boundingbox ||= @attrs[:boundingbox]
end

#classString

Return a class

Returns:

  • (String)

20
21
22
# File 'lib/nominatim/place.rb', line 20

def class
  @class ||= @attrs[:class]
end

#display_nameString

Return display name

Returns:

  • (String)

13
14
15
# File 'lib/nominatim/place.rb', line 13

def display_name
  @display_name ||= @attrs[:display_name]
end

#latFloat Also known as: latitude

Return a latitude

Returns:

  • (Float)

41
42
43
# File 'lib/nominatim/place.rb', line 41

def lat
  point.lat
end

#lonFloat Also known as: longitude

Return a longitude

Returns:

  • (Float)

49
50
51
# File 'lib/nominatim/place.rb', line 49

def lon
  point.lon
end

#osm_idInteger

Return an OSM id

Returns:

  • (Integer)

76
77
78
# File 'lib/nominatim/place.rb', line 76

def osm_id
  @osm_id ||= @attrs[:osm_id].to_i if @attrs[:osm_id]
end

#osm_typeString

Return an OSM type

Returns:

  • (String)

83
84
85
# File 'lib/nominatim/place.rb', line 83

def osm_type
  @osm_type ||= @attrs[:osm_type]
end

#place_idInteger

Return a place id

Returns:

  • (Integer)

69
70
71
# File 'lib/nominatim/place.rb', line 69

def place_id
  @place_id ||= @attrs[:place_id].to_i if @attrs[:place_id]
end

#polygonpointsNominatim::Polygon

Return a polygon

Returns:


62
63
64
# File 'lib/nominatim/place.rb', line 62

def polygonpoints
  @polygonpoints ||= Nominatim::Polygon.new(@attrs[:polygonpoints]) if @attrs[:polygonpoints]
end

#typeString

Return a type

Returns:

  • (String)

27
28
29
# File 'lib/nominatim/place.rb', line 27

def type
  @type ||= @attrs[:type]
end