nominatim 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +8 -0
- data/Guardfile +13 -0
- data/LICENSE +22 -0
- data/README.md +45 -0
- data/Rakefile +11 -0
- data/lib/nominatim.rb +26 -0
- data/lib/nominatim/address.rb +75 -0
- data/lib/nominatim/client.rb +32 -0
- data/lib/nominatim/configuration.rb +33 -0
- data/lib/nominatim/place.rb +57 -0
- data/lib/nominatim/response/parse_json.rb +16 -0
- data/lib/nominatim/search.rb +98 -0
- data/lib/nominatim/version.rb +3 -0
- data/nominatim.gemspec +25 -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 +199 -0
- data/spec/nominatim/search_spec.rb +140 -0
- data/spec/nominatim_spec.rb +54 -0
- data/spec/spec_helper.rb +36 -0
- metadata +174 -0
data/nominatim.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
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 = ""
|
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 = "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 'rspec', '~> 2.10'
|
22
|
+
gem.add_development_dependency 'webmock'
|
23
|
+
gem.add_development_dependency 'simplecov'
|
24
|
+
gem.add_development_dependency 'yard'
|
25
|
+
end
|
@@ -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
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Nominatim::Client do
|
4
|
+
after do
|
5
|
+
WebMock.reset!
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '#get' do
|
9
|
+
before do
|
10
|
+
stub_get('/search').to_return(body: "[]")
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'requests the correct resource' do
|
14
|
+
Nominatim::Client.new.get('/search')
|
15
|
+
a_get('/search').should have_been_requested
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'parses the body' do
|
19
|
+
response = Nominatim::Client.new.get('/search')
|
20
|
+
response.body.should eq []
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,199 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Nominatim::Place do
|
4
|
+
describe '#display_name' do
|
5
|
+
it 'returns a full name when set with display_name' do
|
6
|
+
place = Nominatim::Place.new(display_name: 'Los Angeles, California, United States of America')
|
7
|
+
place.display_name.should eq 'Los Angeles, California, United States of America'
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'returns nil when not set' do
|
11
|
+
place = Nominatim::Place.new
|
12
|
+
place.display_name.should be_nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#class' do
|
17
|
+
it 'returns a class when set with class' do
|
18
|
+
place = Nominatim::Place.new(class: 'place')
|
19
|
+
place.class.should eq 'place'
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns nil when not set' do
|
23
|
+
place = Nominatim::Place.new
|
24
|
+
place.class.should be_nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#type' do
|
29
|
+
it 'returns a type when set with type' do
|
30
|
+
place = Nominatim::Place.new(type: 'county')
|
31
|
+
place.type.should eq 'county'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'returns nil when not set' do
|
35
|
+
place = Nominatim::Place.new
|
36
|
+
place.type.should be_nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#address' do
|
41
|
+
it 'returns a Nominatim::Address when set' do
|
42
|
+
place = Nominatim::Place.new(address: {county: 'Los Angeles', state: 'California', country: 'United States of America'})
|
43
|
+
place.address.should be_a Nominatim::Address
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'returns nil when not set' do
|
47
|
+
place = Nominatim::Place.new
|
48
|
+
place.address.should be_nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#lat' do
|
53
|
+
it 'returns a latitude when set with lat' do
|
54
|
+
place = Nominatim::Place.new(lat: '52.5487969264788')
|
55
|
+
place.lat.should eq '52.5487969264788'
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'returns a latitude when set with latitude' do
|
59
|
+
place = Nominatim::Place.new(latitude: '52.5487969264788')
|
60
|
+
place.lat.should eq '52.5487969264788'
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'returns nil when not set' do
|
64
|
+
place = Nominatim::Place.new
|
65
|
+
place.lat.should be_nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#latitude' do
|
70
|
+
it 'returns a latitude when set with lat' do
|
71
|
+
place = Nominatim::Place.new(lat: '52.5487969264788')
|
72
|
+
place.latitude.should eq '52.5487969264788'
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'returns a latitude when set with latitude' do
|
76
|
+
place = Nominatim::Place.new(latitude: '52.5487969264788')
|
77
|
+
place.latitude.should eq '52.5487969264788'
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'returns nil when not set' do
|
81
|
+
place = Nominatim::Place.new
|
82
|
+
place.latitude.should be_nil
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '#lon' do
|
87
|
+
it 'returns a longitude when set with lon' do
|
88
|
+
place = Nominatim::Place.new(lon: '-1.81642935385411')
|
89
|
+
place.lon.should eq '-1.81642935385411'
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'returns a longitude when set with longitude' do
|
93
|
+
place = Nominatim::Place.new(longitude: '-1.81642935385411')
|
94
|
+
place.lon.should eq '-1.81642935385411'
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'returns nil when not set' do
|
98
|
+
place = Nominatim::Place.new
|
99
|
+
place.lon.should be_nil
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe '#longitude' do
|
104
|
+
it 'returns a longitude when set with lon' do
|
105
|
+
place = Nominatim::Place.new(lon: '-1.81642935385411')
|
106
|
+
place.longitude.should eq '-1.81642935385411'
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'returns a longitude when set with longitude' do
|
110
|
+
place = Nominatim::Place.new(longitude: '-1.81642935385411')
|
111
|
+
place.longitude.should eq '-1.81642935385411'
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'returns nil when not set' do
|
115
|
+
place = Nominatim::Place.new
|
116
|
+
place.longitude.should be_nil
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
# describe '#coordinates' do
|
121
|
+
# it 'returns coordinates when set with lat and lon' do
|
122
|
+
# place = Nominatim::Place.new(lat: '52.5487969264788', lon: '-1.81642935385411')
|
123
|
+
# place.coordinates.should eq ['52.5487969264788', '-1.81642935385411']
|
124
|
+
# end
|
125
|
+
# end
|
126
|
+
|
127
|
+
describe '#boundingbox' do
|
128
|
+
it 'returns a boundingbox when set with boundingbox' do
|
129
|
+
place = Nominatim::Place.new(boundingbox: ["52.5487442016602", "52.5488510131836", "-1.81651306152344", "-1.81634628772736"])
|
130
|
+
place.boundingbox.should eq ["52.5487442016602", "52.5488510131836", "-1.81651306152344", "-1.81634628772736"]
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'returns nil when not set' do
|
134
|
+
place = Nominatim::Place.new
|
135
|
+
place.boundingbox.should be_nil
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe '#bounding_box' do
|
140
|
+
it 'returns a bounding box when set with boundingbox' do
|
141
|
+
place = Nominatim::Place.new(boundingbox: ["52.5487442016602", "52.5488510131836", "-1.81651306152344", "-1.81634628772736"])
|
142
|
+
place.bounding_box.should eq ["52.5487442016602", "52.5488510131836", "-1.81651306152344", "-1.81634628772736"]
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'returns nil when not set' do
|
146
|
+
place = Nominatim::Place.new
|
147
|
+
place.bounding_box.should be_nil
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe '#polygonpoints' do
|
152
|
+
it 'returns polygon points when set with polygonpoints' do
|
153
|
+
place = Nominatim::Place.new(polygonpoints: [["-1.816513", "52.5487566"], ["-1.8164913", "52.548824"], ["-1.8164685", "52.5488213"]])
|
154
|
+
place.polygonpoints.should eq [["-1.816513", "52.5487566"], ["-1.8164913", "52.548824"], ["-1.8164685", "52.5488213"]]
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'returns nil when not set' do
|
158
|
+
place = Nominatim::Place.new
|
159
|
+
place.polygonpoints.should be_nil
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe '#place_id' do
|
164
|
+
it 'returns a place id when set with place_id' do
|
165
|
+
place = Nominatim::Place.new(place_id: '84327444')
|
166
|
+
place.place_id.should eq '84327444'
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'returns nil when not set' do
|
170
|
+
place = Nominatim::Place.new
|
171
|
+
place.place_id.should be_nil
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
describe '#osm_id' do
|
176
|
+
it 'returns a osm id when set with osm_id' do
|
177
|
+
place = Nominatim::Place.new(osm_id: '90394480')
|
178
|
+
place.osm_id.should eq '90394480'
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'returns nil when not set' do
|
182
|
+
place = Nominatim::Place.new
|
183
|
+
place.osm_id.should be_nil
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
describe '#osm_type' do
|
188
|
+
it 'returns a osm type when set with osm_type' do
|
189
|
+
place = Nominatim::Place.new(osm_type: 'way')
|
190
|
+
place.osm_type.should eq 'way'
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'returns nil when not set' do
|
194
|
+
place = Nominatim::Place.new
|
195
|
+
place.osm_type.should be_nil
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
end
|