parallel588_nominatim 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.rspec +2 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +15 -0
- data/Gemfile +8 -0
- data/Guardfile +13 -0
- data/LICENSE +22 -0
- data/README.md +90 -0
- data/Rakefile +11 -0
- data/lib/nominatim/address.rb +83 -0
- data/lib/nominatim/client.rb +41 -0
- data/lib/nominatim/configuration.rb +49 -0
- data/lib/nominatim/place.rb +93 -0
- data/lib/nominatim/point.rb +30 -0
- data/lib/nominatim/polygon.rb +13 -0
- data/lib/nominatim/response/parse_json.rb +16 -0
- data/lib/nominatim/reverse.rb +44 -0
- data/lib/nominatim/search.rb +99 -0
- data/lib/nominatim/version.rb +3 -0
- data/lib/nominatim.rb +36 -0
- data/nominatim.gemspec +26 -0
- data/spec/fixtures/reverse.json +1 -0
- data/spec/fixtures/search.json +1 -0
- data/spec/nominatim/address_spec.rb +209 -0
- data/spec/nominatim/client_spec.rb +23 -0
- data/spec/nominatim/place_spec.rb +172 -0
- data/spec/nominatim/point_spec.rb +53 -0
- data/spec/nominatim/polygon_spec.rb +19 -0
- data/spec/nominatim/reverse_spec.rb +68 -0
- data/spec/nominatim/search_spec.rb +140 -0
- data/spec/nominatim_spec.rb +66 -0
- data/spec/spec_helper.rb +38 -0
- metadata +185 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
module Nominatim
|
2
|
+
class Point
|
3
|
+
attr_reader :lat, :lon
|
4
|
+
alias latitude lat
|
5
|
+
alias longitude lon
|
6
|
+
|
7
|
+
# @param lat [Float]
|
8
|
+
# @param lon [Float]
|
9
|
+
def initialize(lat, lon)
|
10
|
+
@lat, @lon = lat.to_f, lon.to_f if lat && lon
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [Array]
|
14
|
+
def to_a
|
15
|
+
[lat, lon]
|
16
|
+
end
|
17
|
+
|
18
|
+
# Return a string representation of the point
|
19
|
+
#
|
20
|
+
# @return [String]
|
21
|
+
def to_s
|
22
|
+
to_a.to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [true, false]
|
26
|
+
def ==(other)
|
27
|
+
self.to_a == other.to_a
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Nominatim
|
2
|
+
class Polygon
|
3
|
+
attr_reader :coordinates
|
4
|
+
|
5
|
+
# @param coordinates [Array<Array<Float, String>>]
|
6
|
+
def initialize(coordinates)
|
7
|
+
@coordinates = []
|
8
|
+
coordinates.each do |c|
|
9
|
+
@coordinates.push(Nominatim::Point.new(c[0], c[1]))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module Nominatim
|
5
|
+
module Response
|
6
|
+
class ParseJson < Faraday::Response::Middleware
|
7
|
+
def on_complete(env)
|
8
|
+
if env[:body].empty?
|
9
|
+
env[:body] = nil
|
10
|
+
else
|
11
|
+
env[:body] = MultiJson.load(env[:body], symbolize_keys: true)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Nominatim
|
2
|
+
class Reverse < Client
|
3
|
+
attr_reader :criteria
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@criteria = {}
|
7
|
+
end
|
8
|
+
|
9
|
+
# Returns search result or nil if no results received.
|
10
|
+
def fetch
|
11
|
+
body = get(Nominatim.config.reverse_url, @criteria).body
|
12
|
+
return nil if body.empty?
|
13
|
+
Nominatim::Place.new(body)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Latitude string to search for.
|
17
|
+
#
|
18
|
+
# @param lat [String] Latitude
|
19
|
+
# @return [Nominatim::Reverse]
|
20
|
+
def lat(lat)
|
21
|
+
@criteria[:lat] = lat
|
22
|
+
self
|
23
|
+
end
|
24
|
+
|
25
|
+
# Longitude string to search for.
|
26
|
+
#
|
27
|
+
# @param lon [String] Longitude
|
28
|
+
# @return [Nominatim::Reverse]
|
29
|
+
def lon(lon)
|
30
|
+
@criteria[:lon] = lon
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
# Include a breakdown of the address into elements.
|
35
|
+
#
|
36
|
+
# @param bool [true, false]
|
37
|
+
# @return [Nominatim::Reverse]
|
38
|
+
def address_details(bool)
|
39
|
+
@criteria[:addressdetails] = bool ? 1 : 0
|
40
|
+
self
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Nominatim
|
2
|
+
class Search < Client
|
3
|
+
include Enumerable
|
4
|
+
attr_reader :criteria
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@criteria = {}
|
8
|
+
end
|
9
|
+
|
10
|
+
# Iterates over the search results.
|
11
|
+
def each(&block)
|
12
|
+
@results ||= get(Nominatim.config.search_url, @criteria).body.map! { |attrs| Nominatim::Place.new(attrs) }
|
13
|
+
@results.each(&block)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Query string to search for.
|
17
|
+
#
|
18
|
+
# @param q [String] Query string
|
19
|
+
# @return [Nominatim::Search]
|
20
|
+
def query(q)
|
21
|
+
@criteria[:q] = q
|
22
|
+
self
|
23
|
+
end
|
24
|
+
|
25
|
+
# Limit search results to a specific country (or a list of countries).
|
26
|
+
#
|
27
|
+
# @param codes [Array<String>, String]
|
28
|
+
# @see https://wiki.openstreetmap.org/wiki/Nominatim
|
29
|
+
# @return [Nominatim::Search]
|
30
|
+
def country_codes(codes)
|
31
|
+
if codes.instance_of? Array
|
32
|
+
@criteria[:countrycodes] = codes.join(',')
|
33
|
+
else
|
34
|
+
@criteria[:countrycodes] = codes
|
35
|
+
end
|
36
|
+
self
|
37
|
+
end
|
38
|
+
|
39
|
+
# The preferred area to find search results.
|
40
|
+
#
|
41
|
+
# @param viewbox [Array<String>]
|
42
|
+
# @return [Nominatim::Search]
|
43
|
+
def viewbox(viewbox)
|
44
|
+
@criteria[:viewbox] = viewbox.join(',')
|
45
|
+
self
|
46
|
+
end
|
47
|
+
|
48
|
+
# Restrict the results to only items contained with the bounding box.
|
49
|
+
#
|
50
|
+
# @param bool [true, false]
|
51
|
+
# @see https://wiki.openstreetmap.org/wiki/Nominatim
|
52
|
+
# @return [Nominatim::Search]
|
53
|
+
def bounded(bool)
|
54
|
+
@criteria[:bounded] = bool ? 1 : 0
|
55
|
+
self
|
56
|
+
end
|
57
|
+
|
58
|
+
# Output polygon outlines for items found.
|
59
|
+
#
|
60
|
+
# @param bool [true, false]
|
61
|
+
# @return [Nominatim::Search]
|
62
|
+
def polygon(bool)
|
63
|
+
@criteria[:polygon] = bool ? 1 : 0
|
64
|
+
self
|
65
|
+
end
|
66
|
+
|
67
|
+
# Include a breakdown of the address into elements.
|
68
|
+
#
|
69
|
+
# @param bool [true, false]
|
70
|
+
# @return [Nominatim::Search]
|
71
|
+
def address_details(bool)
|
72
|
+
@criteria[:addressdetails] = bool ? 1 : 0
|
73
|
+
self
|
74
|
+
end
|
75
|
+
|
76
|
+
# Exclude given place ids from the search result.
|
77
|
+
#
|
78
|
+
# @param ids [Array<String>, String] Place ids
|
79
|
+
# @return [Nominatim::Search]
|
80
|
+
def exclude_place_ids(ids)
|
81
|
+
if ids.instance_of? Array
|
82
|
+
@criteria[:exclude_place_ids] = ids.join(',')
|
83
|
+
else
|
84
|
+
@criteria[:exclude_place_ids] = ids
|
85
|
+
end
|
86
|
+
self
|
87
|
+
end
|
88
|
+
|
89
|
+
# Limit the number of returned results.
|
90
|
+
#
|
91
|
+
# @param limit [Integer]
|
92
|
+
# @return [Nominatim::Search]
|
93
|
+
def limit(limit)
|
94
|
+
@criteria[:limit] = limit
|
95
|
+
self
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
data/lib/nominatim.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require "nominatim/version"
|
2
|
+
require "nominatim/configuration"
|
3
|
+
require "nominatim/point"
|
4
|
+
require "nominatim/polygon"
|
5
|
+
require "nominatim/address"
|
6
|
+
require "nominatim/place"
|
7
|
+
require "nominatim/response/parse_json"
|
8
|
+
require "nominatim/client"
|
9
|
+
require "nominatim/search"
|
10
|
+
require "nominatim/reverse"
|
11
|
+
|
12
|
+
module Nominatim
|
13
|
+
|
14
|
+
# @return [Nominatim::Search]
|
15
|
+
def self.search(q = nil)
|
16
|
+
search = Nominatim::Search.new
|
17
|
+
search.query(q) if q
|
18
|
+
search
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [Nominatim::Reverse]
|
22
|
+
def self.reverse(lat = nil, lon = nil)
|
23
|
+
search = Nominatim::Reverse.new
|
24
|
+
search.lat(lat).lon(lon) if lat && lon
|
25
|
+
search
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [Nominatim::Configuration]
|
29
|
+
def self.config
|
30
|
+
@config ||= Configuration.new
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.configure(&block)
|
34
|
+
config.configure &block
|
35
|
+
end
|
36
|
+
end
|
data/nominatim.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/nominatim/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Jakub Svehla"]
|
6
|
+
gem.email = ["jakub.svehla@gmail.com"]
|
7
|
+
gem.description = %q{A Ruby wrapper for the Nominatim API.}
|
8
|
+
gem.summary = %q{A Ruby wrapper for the Nominatim API.}
|
9
|
+
gem.homepage = "https://github.com/jakubsvehla/nominatim"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "parallel588_nominatim"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Nominatim::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'faraday'
|
19
|
+
gem.add_dependency 'multi_json'
|
20
|
+
|
21
|
+
gem.add_development_dependency 'rake'
|
22
|
+
gem.add_development_dependency 'rspec', '~> 2.10'
|
23
|
+
gem.add_development_dependency 'webmock'
|
24
|
+
gem.add_development_dependency 'simplecov'
|
25
|
+
gem.add_development_dependency 'yard'
|
26
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"place_id":"13686660","licence":"Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.","osm_type":"node","osm_id":"1241690521","lat":"37.733976","lon":"-122.3912081","display_name":"4900, 3rd Street, San Francisco, California, 94124, United States of America","address":{"house_number":"4900","road":"3rd Street","city":"San Francisco","county":"San Francisco","state":"California","postcode":"94124","country":"United States of America","country_code":"us"}}
|
@@ -0,0 +1 @@
|
|
1
|
+
[{"place_id":"1595230","licence":"Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.","osm_type":"node","osm_id":"316944811","boundingbox":["34.086675872803","34.1066796875","-117.72968078613","-117.70967315674"],"polygonpoints":[["-117.7196785","34.1066764"],["-117.71952220822","34.106675178569"],["-117.71936595462","34.106671514576"],["-117.71920977738","34.106665408915"],["-117.71905371463","34.106656863077"],["-117.71889780451","34.106645879152"],["-117.7187420851","34.10663245982"],["-117.71858659445","34.106616608362"],["-117.71843137054","34.106598328648"],["-117.71827645128","34.106577625145"],["-117.71812187452","34.106554502911"],["-117.71796767802","34.106528967592"],["-117.71781389946","34.106501025429"],["-117.71766057639","34.106470683245"],["-117.71750774627","34.106437948455"],["-117.71735544643","34.106402829053"],["-117.71720371409","34.10636533362"],["-117.7170525863","34.106325471315"],["-117.71690209999","34.106283251876"],["-117.71675229191","34.106238685616"],["-117.71660319866","34.106191783422"],["-117.71645485667","34.106142556753"],["-117.71630730217","34.106091017633"],["-117.7161605712","34.106037178652"],["-117.71601469962","34.105981052963"],["-117.71586972305","34.105922654277"],["-117.71572567691","34.105861996859"],["-117.7155825964","34.105799095527"],["-117.71544051645","34.105733965647"],["-117.71529947179","34.10566662313"],["-117.71515949686","34.105597084426"],["-117.71502062586","34.105525366522"],["-117.71488289272","34.105451486939"],["-117.71474633107","34.105375463724"],["-117.71461097429","34.105297315449"],["-117.71447685543","34.105217061203"],["-117.71434400726","34.105134720593"],["-117.71421246224","34.105050313732"],["-117.71408225249","34.10496386124"],["-117.71395340983","34.104875384237"],["-117.71382596572","34.104784904335"],["-117.71369995131","34.104692443639"],["-117.71357539738","34.104598024734"],["-117.71345233435","34.104501670686"],["-117.71333079229","34.104403405034"],["-117.71321080088","34.104303251781"],["-117.71309238944","34.104201235394"],["-117.7129755869","34.104097380795"],["-117.71286042178","34.103991713353"],["-117.71274692223","34.103884258881"],["-117.71263511597","34.103775043629"],["-117.7125250303","34.103664094278"],["-117.71241669213","34.103551437929"],["-117.71231012792","34.103437102105"],["-117.7122053637","34.103321114734"],["-117.71210242507","34.103203504152"],["-117.71200133716","34.10308429909"],["-117.71190212468","34.102963528666"],["-117.71180481186","34.102841222384"],["-117.71170942247","34.102717410122"],["-117.71161597981","34.102592122124"],["-117.71152450672","34.102465388998"],["-117.71143502554","34.102337241702"],["-117.71134755812","34.102207711541"],["-117.71126212583","34.102076830158"],["-117.71117874955","34.101944629524"],["-117.71109744964","34.101811141935"],["-117.71101824596","34.1016764"],["-117.71094115786","34.101540436634"],["-117.71086620418","34.101403285052"],["-117.71079340321","34.101264978757"],["-117.71072277275","34.101125551536"],["-117.71065433005","34.100985037449"],["-117.71058809183","34.100843470822"],["-117.71052407427","34.100700886238"],["-117.710462293","34.100557318527"],["-117.71040276313","34.100412802761"],["-117.7103454992","34.100267374245"],["-117.71029051518","34.100121068503"],["-117.71023782452","34.099973921276"],["-117.71018744009","34.099825968511"],["-117.71013937419","34.09967724635"],["-117.71009363857","34.099527791124"],["-117.71005024439","34.099377639342"],["-117.71000920227","34.099226827686"],["-117.70997052222","34.099075392995"],["-117.70993421369","34.098923372263"],["-117.70990028556","34.098770802628"],["-117.70986874611","34.098617721359"],["-117.70983960305","34.098464165852"],["-117.70981286349","34.098310173618"],["-117.70978853397","34.098155782277"],["-117.70976662043","34.098001029542"],["-117.70974712823","34.09784595322"],["-117.70973006212","34.097690591191"],["-117.70971542628","34.09753498141"],["-117.70970322428","34.097379161889"],["-117.7096934591","34.097223170694"],["-117.70968613313","34.09706704593"],["-117.70968124815","34.096910825736"],["-117.70967880536","34.096754548276"],["-117.70967880536","34.096598251724"],["-117.70968124815","34.096441974264"],["-117.70968613313","34.09628575407"],["-117.7096934591","34.096129629306"],["-117.70970322428","34.095973638111"],["-117.70971542628","34.09581781859"],["-117.70973006212","34.095662208809"],["-117.70974712823","34.09550684678"],["-117.70976662043","34.095351770458"],["-117.70978853397","34.095197017723"],["-117.70981286349","34.095042626382"],["-117.70983960305","34.094888634148"],["-117.70986874611","34.094735078641"],["-117.70990028556","34.094581997372"],["-117.70993421369","34.094429427737"],["-117.70997052222","34.094277407005"],["-117.71000920227","34.094125972314"],["-117.71005024439","34.093975160658"],["-117.71009363857","34.093825008876"],["-117.71013937419","34.09367555365"],["-117.71018744009","34.093526831489"],["-117.71023782452","34.093378878724"],["-117.71029051518","34.093231731497"],["-117.7103454992","34.093085425755"],["-117.71040276313","34.092939997239"],["-117.710462293","34.092795481473"],["-117.71052407427","34.092651913762"],["-117.71058809183","34.092509329178"],["-117.71065433005","34.092367762551"],["-117.71072277275","34.092227248464"],["-117.71079340321","34.092087821243"],["-117.71086620418","34.091949514948"],["-117.71094115786","34.091812363366"],["-117.71101824596","34.0916764"],["-117.71109744964","34.091541658065"],["-117.71117874955","34.091408170476"],["-117.71126212583","34.091275969842"],["-117.71134755812","34.091145088459"],["-117.71143502554","34.091015558298"],["-117.71152450672","34.090887411002"],["-117.71161597981","34.090760677876"],["-117.71170942247","34.090635389878"],["-117.71180481186","34.090511577616"],["-117.71190212468","34.090389271334"],["-117.71200133716","34.09026850091"],["-117.71210242507","34.090149295848"],["-117.7122053637","34.090031685266"],["-117.71231012792","34.089915697895"],["-117.71241669213","34.089801362071"],["-117.7125250303","34.089688705722"],["-117.71263511597","34.089577756371"],["-117.71274692223","34.089468541119"],["-117.71286042178","34.089361086647"],["-117.7129755869","34.089255419205"],["-117.71309238944","34.089151564606"],["-117.71321080088","34.089049548219"],["-117.71333079229","34.088949394966"],["-117.71345233435","34.088851129314"],["-117.71357539738","34.088754775266"],["-117.71369995131","34.088660356361"],["-117.71382596572","34.088567895665"],["-117.71395340983","34.088477415763"],["-117.71408225249","34.08838893876"],["-117.71421246224","34.088302486268"],["-117.71434400726","34.088218079407"],["-117.71447685543","34.088135738797"],["-117.71461097429","34.088055484551"],["-117.71474633107","34.087977336276"],["-117.71488289272","34.087901313061"],["-117.71502062586","34.087827433478"],["-117.71515949686","34.087755715574"],["-117.71529947179","34.08768617687"],["-117.71544051645","34.087618834353"],["-117.7155825964","34.087553704473"],["-117.71572567691","34.087490803141"],["-117.71586972305","34.087430145723"],["-117.71601469962","34.087371747037"],["-117.7161605712","34.087315621348"],["-117.71630730217","34.087261782367"],["-117.71645485667","34.087210243247"],["-117.71660319866","34.087161016578"],["-117.71675229191","34.087114114384"],["-117.71690209999","34.087069548124"],["-117.7170525863","34.087027328685"],["-117.71720371409","34.08698746638"],["-117.71735544643","34.086949970947"],["-117.71750774627","34.086914851545"],["-117.71766057639","34.086882116755"],["-117.71781389946","34.086851774571"],["-117.71796767802","34.086823832408"],["-117.71812187452","34.086798297089"],["-117.71827645128","34.086775174855"],["-117.71843137054","34.086754471352"],["-117.71858659445","34.086736191638"],["-117.7187420851","34.08672034018"],["-117.71889780451","34.086706920848"],["-117.71905371463","34.086695936923"],["-117.71920977738","34.086687391085"],["-117.71936595462","34.086681285424"],["-117.71952220822","34.086677621431"],["-117.7196785","34.0866764"],["-117.71983479178","34.086677621431"],["-117.71999104538","34.086681285424"],["-117.72014722262","34.086687391085"],["-117.72030328537","34.086695936923"],["-117.72045919549","34.086706920848"],["-117.7206149149","34.08672034018"],["-117.72077040555","34.086736191638"],["-117.72092562946","34.086754471352"],["-117.72108054872","34.086775174855"],["-117.72123512548","34.086798297089"],["-117.72138932198","34.086823832408"],["-117.72154310054","34.086851774571"],["-117.72169642361","34.086882116755"],["-117.72184925373","34.086914851545"],["-117.72200155357","34.086949970947"],["-117.72215328591","34.08698746638"],["-117.7223044137","34.087027328685"],["-117.72245490001","34.087069548124"],["-117.72260470809","34.087114114384"],["-117.72275380134","34.087161016578"],["-117.72290214333","34.087210243247"],["-117.72304969783","34.087261782367"],["-117.7231964288","34.087315621348"],["-117.72334230038","34.087371747037"],["-117.72348727695","34.087430145723"],["-117.72363132309","34.087490803141"],["-117.7237744036","34.087553704473"],["-117.72391648355","34.087618834353"],["-117.72405752821","34.08768617687"],["-117.72419750314","34.087755715574"],["-117.72433637414","34.087827433478"],["-117.72447410728","34.087901313061"],["-117.72461066893","34.087977336276"],["-117.72474602571","34.088055484551"],["-117.72488014457","34.088135738797"],["-117.72501299274","34.088218079407"],["-117.72514453776","34.088302486268"],["-117.72527474751","34.08838893876"],["-117.72540359017","34.088477415763"],["-117.72553103428","34.088567895665"],["-117.72565704869","34.088660356361"],["-117.72578160262","34.088754775266"],["-117.72590466565","34.088851129314"],["-117.72602620771","34.088949394966"],["-117.72614619912","34.089049548219"],["-117.72626461056","34.089151564606"],["-117.7263814131","34.089255419205"],["-117.72649657822","34.089361086647"],["-117.72661007777","34.089468541119"],["-117.72672188403","34.089577756371"],["-117.7268319697","34.089688705722"],["-117.72694030787","34.089801362071"],["-117.72704687208","34.089915697895"],["-117.7271516363","34.090031685266"],["-117.72725457493","34.090149295848"],["-117.72735566284","34.09026850091"],["-117.72745487532","34.090389271334"],["-117.72755218814","34.090511577616"],["-117.72764757753","34.090635389878"],["-117.72774102019","34.090760677876"],["-117.72783249328","34.090887411002"],["-117.72792197446","34.091015558298"],["-117.72800944188","34.091145088459"],["-117.72809487417","34.091275969842"],["-117.72817825045","34.091408170476"],["-117.72825955036","34.091541658065"],["-117.72833875404","34.0916764"],["-117.72841584214","34.091812363366"],["-117.72849079582","34.091949514948"],["-117.72856359679","34.092087821243"],["-117.72863422725","34.092227248464"],["-117.72870266995","34.092367762551"],["-117.72876890817","34.092509329178"],["-117.72883292573","34.092651913762"],["-117.728894707","34.092795481473"],["-117.72895423687","34.092939997239"],["-117.7290115008","34.093085425755"],["-117.72906648482","34.093231731497"],["-117.72911917548","34.093378878724"],["-117.72916955991","34.093526831489"],["-117.72921762581","34.09367555365"],["-117.72926336143","34.093825008876"],["-117.72930675561","34.093975160658"],["-117.72934779773","34.094125972314"],["-117.72938647778","34.094277407005"],["-117.72942278631","34.094429427737"],["-117.72945671444","34.094581997372"],["-117.72948825389","34.094735078641"],["-117.72951739695","34.094888634148"],["-117.72954413651","34.095042626382"],["-117.72956846603","34.095197017723"],["-117.72959037957","34.095351770458"],["-117.72960987177","34.09550684678"],["-117.72962693788","34.095662208809"],["-117.72964157372","34.09581781859"],["-117.72965377572","34.095973638111"],["-117.7296635409","34.096129629306"],["-117.72967086687","34.09628575407"],["-117.72967575185","34.096441974264"],["-117.72967819464","34.096598251724"],["-117.72967819464","34.096754548276"],["-117.72967575185","34.096910825736"],["-117.72967086687","34.09706704593"],["-117.7296635409","34.097223170694"],["-117.72965377572","34.097379161889"],["-117.72964157372","34.09753498141"],["-117.72962693788","34.097690591191"],["-117.72960987177","34.09784595322"],["-117.72959037957","34.098001029542"],["-117.72956846603","34.098155782277"],["-117.72954413651","34.098310173618"],["-117.72951739695","34.098464165852"],["-117.72948825389","34.098617721359"],["-117.72945671444","34.098770802628"],["-117.72942278631","34.098923372263"],["-117.72938647778","34.099075392995"],["-117.72934779773","34.099226827686"],["-117.72930675561","34.099377639342"],["-117.72926336143","34.099527791124"],["-117.72921762581","34.09967724635"],["-117.72916955991","34.099825968511"],["-117.72911917548","34.099973921276"],["-117.72906648482","34.100121068503"],["-117.7290115008","34.100267374245"],["-117.72895423687","34.100412802761"],["-117.728894707","34.100557318527"],["-117.72883292573","34.100700886238"],["-117.72876890817","34.100843470822"],["-117.72870266995","34.100985037449"],["-117.72863422725","34.101125551536"],["-117.72856359679","34.101264978757"],["-117.72849079582","34.101403285052"],["-117.72841584214","34.101540436634"],["-117.72833875404","34.1016764"],["-117.72825955036","34.101811141935"],["-117.72817825045","34.101944629524"],["-117.72809487417","34.102076830158"],["-117.72800944188","34.102207711541"],["-117.72792197446","34.102337241702"],["-117.72783249328","34.102465388998"],["-117.72774102019","34.102592122124"],["-117.72764757753","34.102717410122"],["-117.72755218814","34.102841222384"],["-117.72745487532","34.102963528666"],["-117.72735566284","34.10308429909"],["-117.72725457493","34.103203504152"],["-117.7271516363","34.103321114734"],["-117.72704687208","34.103437102105"],["-117.72694030787","34.103551437929"],["-117.7268319697","34.103664094278"],["-117.72672188403","34.103775043629"],["-117.72661007777","34.103884258881"],["-117.72649657822","34.103991713353"],["-117.7263814131","34.104097380795"],["-117.72626461056","34.104201235394"],["-117.72614619912","34.104303251781"],["-117.72602620771","34.104403405034"],["-117.72590466565","34.104501670686"],["-117.72578160262","34.104598024734"],["-117.72565704869","34.104692443639"],["-117.72553103428","34.104784904335"],["-117.72540359017","34.104875384237"],["-117.72527474751","34.10496386124"],["-117.72514453776","34.105050313732"],["-117.72501299274","34.105134720593"],["-117.72488014457","34.105217061203"],["-117.72474602571","34.105297315449"],["-117.72461066893","34.105375463724"],["-117.72447410728","34.105451486939"],["-117.72433637414","34.105525366522"],["-117.72419750314","34.105597084426"],["-117.72405752821","34.10566662313"],["-117.72391648355","34.105733965647"],["-117.7237744036","34.105799095527"],["-117.72363132309","34.105861996859"],["-117.72348727695","34.105922654277"],["-117.72334230038","34.105981052963"],["-117.7231964288","34.106037178652"],["-117.72304969783","34.106091017633"],["-117.72290214333","34.106142556753"],["-117.72275380134","34.106191783422"],["-117.72260470809","34.106238685616"],["-117.72245490001","34.106283251876"],["-117.7223044137","34.106325471315"],["-117.72215328591","34.10636533362"],["-117.72200155357","34.106402829053"],["-117.72184925373","34.106437948455"],["-117.72169642361","34.106470683245"],["-117.72154310054","34.106501025429"],["-117.72138932198","34.106528967592"],["-117.72123512548","34.106554502911"],["-117.72108054872","34.106577625145"],["-117.72092562946","34.106598328648"],["-117.72077040555","34.106616608362"],["-117.7206149149","34.10663245982"],["-117.72045919549","34.106645879152"],["-117.72030328537","34.106656863077"],["-117.72014722262","34.106665408915"],["-117.71999104538","34.106671514576"],["-117.71983479178","34.106675178569"],["-117.7196785","34.1066764"]],"lat":"34.0966764","lon":"-117.7196785","display_name":"Los Angeles, California, United States of America","class":"place","type":"county","icon":"http://nominatim.openstreetmap.org/images/mapicons/poi_boundary_administrative.p.20.png","address":{"county":"Los Angeles","state":"California","country":"United States of America","country_code":"us"}}]
|
@@ -0,0 +1,209 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Nominatim::Address do
|
4
|
+
|
5
|
+
describe '#attraction' do
|
6
|
+
it 'returns a attraction when set with attraction' do
|
7
|
+
address = Nominatim::Address.new(attraction: 'Eiffel Tower')
|
8
|
+
address.attraction.should eq 'Eiffel Tower'
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'returns nil when not set' do
|
12
|
+
address = Nominatim::Address.new
|
13
|
+
address.attraction.should be_nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#clothes' do
|
18
|
+
it 'returns clothes when set with clothes' do
|
19
|
+
address = Nominatim::Address.new(clothes: 'XXI')
|
20
|
+
address.clothes.should eq 'XXI'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'returns nil when not set' do
|
24
|
+
address = Nominatim::Address.new
|
25
|
+
address.clothes.should be_nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#house_number' do
|
30
|
+
it 'returns a house number when set with house_number' do
|
31
|
+
address = Nominatim::Address.new(house_number: 1)
|
32
|
+
address.house_number.should eq 1
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns nil when not set' do
|
36
|
+
address = Nominatim::Address.new
|
37
|
+
address.house_number.should be_nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#road' do
|
42
|
+
it 'returns a road when set with road' do
|
43
|
+
address = Nominatim::Address.new(road: 'Infinite Loop')
|
44
|
+
address.road.should eq 'Infinite Loop'
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'returns nil when not set' do
|
48
|
+
address = Nominatim::Address.new
|
49
|
+
address.road.should be_nil
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#commercial' do
|
54
|
+
it 'returns a commercial when set with commercial' do
|
55
|
+
address = Nominatim::Address.new(commercial: 'Apple, Inc.')
|
56
|
+
address.commercial.should eq 'Apple, Inc.'
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'returns nil when not set' do
|
60
|
+
address = Nominatim::Address.new
|
61
|
+
address.commercial.should be_nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#pedestrian' do
|
66
|
+
it 'returns a pedestrian when set with pedestrian' do
|
67
|
+
address = Nominatim::Address.new(pedestrian: 'Avenue Pierre Loti')
|
68
|
+
address.pedestrian.should eq 'Avenue Pierre Loti'
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns nil when not set' do
|
72
|
+
address = Nominatim::Address.new
|
73
|
+
address.pedestrian.should be_nil
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe '#suburb' do
|
78
|
+
it 'returns a suburb when set with suburb' do
|
79
|
+
address = Nominatim::Address.new(suburb: 'Quartier du Gros Caillou')
|
80
|
+
address.suburb.should eq 'Quartier du Gros Caillou'
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'returns nil when not set' do
|
84
|
+
address = Nominatim::Address.new
|
85
|
+
address.suburb.should be_nil
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe '#city_district' do
|
90
|
+
it 'returns a city district when set with city_district' do
|
91
|
+
address = Nominatim::Address.new(city_district: '7th Arrondissement')
|
92
|
+
address.city_district.should eq '7th Arrondissement'
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'returns nil when not set' do
|
96
|
+
address = Nominatim::Address.new
|
97
|
+
address.city_district.should be_nil
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe '#city' do
|
102
|
+
it 'returns a city when set with city' do
|
103
|
+
address = Nominatim::Address.new(city: 'Santa Clara')
|
104
|
+
address.city.should eq 'Santa Clara'
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'returns nil when not set' do
|
108
|
+
address = Nominatim::Address.new
|
109
|
+
address.city.should be_nil
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe '#administrative' do
|
114
|
+
it 'returns a administrative when set with administrative' do
|
115
|
+
address = Nominatim::Address.new(administrative: 'Paris')
|
116
|
+
address.administrative.should eq 'Paris'
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'returns nil when not set' do
|
120
|
+
address = Nominatim::Address.new
|
121
|
+
address.administrative.should be_nil
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe '#county' do
|
126
|
+
it 'returns a county when set with county' do
|
127
|
+
address = Nominatim::Address.new(county: 'Santa Clara County')
|
128
|
+
address.county.should eq 'Santa Clara County'
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'returns nil when not set' do
|
132
|
+
address = Nominatim::Address.new
|
133
|
+
address.county.should be_nil
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe '#state_district' do
|
138
|
+
it 'returns a state disctrict when set with state_district' do
|
139
|
+
address = Nominatim::Address.new(state_district: 'West Midlands')
|
140
|
+
address.state_district.should eq 'West Midlands'
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'returns nil when not set' do
|
144
|
+
address = Nominatim::Address.new
|
145
|
+
address.state_district.should be_nil
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
describe '#state' do
|
150
|
+
it 'returns a state when set with state' do
|
151
|
+
address = Nominatim::Address.new(state: 'California')
|
152
|
+
address.state.should eq 'California'
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'returns nil when not set' do
|
156
|
+
address = Nominatim::Address.new
|
157
|
+
address.state.should be_nil
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
describe '#postcode' do
|
162
|
+
it 'returns a postcode when set with postcode' do
|
163
|
+
address = Nominatim::Address.new(postcode: '95014')
|
164
|
+
address.postcode.should eq '95014'
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'returns nil when not set' do
|
168
|
+
address = Nominatim::Address.new
|
169
|
+
address.postcode.should be_nil
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
describe '#country' do
|
174
|
+
it 'returns a country when set with country' do
|
175
|
+
address = Nominatim::Address.new(country: 'United States of America')
|
176
|
+
address.country.should eq 'United States of America'
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'returns nil when not set' do
|
180
|
+
address = Nominatim::Address.new
|
181
|
+
address.country.should be_nil
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
describe '#country_code' do
|
186
|
+
it 'returns a country code when set with country_code' do
|
187
|
+
address = Nominatim::Address.new(country_code: 'us')
|
188
|
+
address.country_code.should eq 'us'
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'returns nil when not set' do
|
192
|
+
address = Nominatim::Address.new
|
193
|
+
address.country_code.should be_nil
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
describe '#place' do
|
198
|
+
it 'returns a place when set with place' do
|
199
|
+
address = Nominatim::Address.new(place: 'Europe')
|
200
|
+
address.place.should eq 'Europe'
|
201
|
+
end
|
202
|
+
|
203
|
+
it 'returns nil when not set' do
|
204
|
+
address = Nominatim::Address.new
|
205
|
+
address.place.should be_nil
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|