Skip to content
This repository was archived by the owner on Aug 20, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ruby-geonames.gemspec → geonames.gemspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Gem::Specification.new do |s|
s.name = "ruby-geonames"
s.name = "geonames"
s.version = "0.2.9"
s.authors = [ "Adam Wisniewski", "Rahul Ghose" ]
s.email = "adamw@tbcn.ca"
Expand Down
1 change: 1 addition & 0 deletions lib/geonames.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
require_relative 'country_subdivision'
require_relative 'wikipedia_article'
require_relative 'intersection'
require_relative 'bounding_box'

module Geonames
autoload :Config, 'geonames/config'
Expand Down
2 changes: 2 additions & 0 deletions lib/toponym.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ class Toponym
attr :admin_code_2
attr :admin_name_1
attr :admin_name_2
attr :bbox

attr_writer :geoname_id, :name, :alternate_names, :country_code
attr_writer :country_name, :population, :elevation, :feature_class
attr_writer :feature_class_name, :feature_code,:feature_code_name
attr_writer :latitude, :longitude, :distance
attr_writer :admin_code_1, :admin_code_2, :admin_name_1, :admin_name_2
attr_writer :bbox

end
end
Expand Down
11 changes: 11 additions & 0 deletions lib/web_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ def WebService.get_element_child_int( element, child )
end
end

def WebService.element_to_bbox( element, child )
element = element.elements[child]
north = WebService::get_element_child_float( element, 'north' )
south = WebService::get_element_child_float( element, 'south' )
east = WebService::get_element_child_float( element, 'east' )
west = WebService::get_element_child_float( element, 'west' )

bbox = Geonames::BoundingBox.new north, south, east, west
end

def WebService.element_to_postal_code ( element )
postal_code = Geonames::PostalCode.new

Expand Down Expand Up @@ -95,6 +105,7 @@ def WebService.element_to_toponym ( element )
toponym.admin_code_2 = WebService::get_element_child_text( element, 'adminCode2' )
toponym.admin_name_1 = WebService::get_element_child_text( element, 'adminName1' )
toponym.admin_name_2 = WebService::get_element_child_text( element, 'adminName2' )
toponym.bbox = WebService::element_to_bbox( element, 'bbox' )

return toponym

Expand Down