aub-graticule 0.2.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/.gitignore +4 -0
  2. data/CHANGELOG.txt +61 -0
  3. data/LICENSE.txt +30 -0
  4. data/Manifest.txt +84 -0
  5. data/README.txt +41 -0
  6. data/Rakefile +143 -0
  7. data/VERSION +1 -0
  8. data/bin/geocode +5 -0
  9. data/graticule.gemspec +143 -0
  10. data/init.rb +2 -0
  11. data/lib/graticule/cli.rb +64 -0
  12. data/lib/graticule/core_ext.rb +15 -0
  13. data/lib/graticule/distance/haversine.rb +40 -0
  14. data/lib/graticule/distance/spherical.rb +52 -0
  15. data/lib/graticule/distance/vincenty.rb +76 -0
  16. data/lib/graticule/distance.rb +18 -0
  17. data/lib/graticule/geocoder/base.rb +116 -0
  18. data/lib/graticule/geocoder/bogus.rb +15 -0
  19. data/lib/graticule/geocoder/geocoder_ca.rb +54 -0
  20. data/lib/graticule/geocoder/geocoder_us.rb +51 -0
  21. data/lib/graticule/geocoder/google.rb +100 -0
  22. data/lib/graticule/geocoder/host_ip.rb +41 -0
  23. data/lib/graticule/geocoder/local_search_maps.rb +44 -0
  24. data/lib/graticule/geocoder/mapquest.rb +96 -0
  25. data/lib/graticule/geocoder/meta_carta.rb +32 -0
  26. data/lib/graticule/geocoder/multi.rb +46 -0
  27. data/lib/graticule/geocoder/multimap.rb +73 -0
  28. data/lib/graticule/geocoder/postcode_anywhere.rb +63 -0
  29. data/lib/graticule/geocoder/rest.rb +18 -0
  30. data/lib/graticule/geocoder/yahoo.rb +84 -0
  31. data/lib/graticule/geocoder.rb +21 -0
  32. data/lib/graticule/location.rb +61 -0
  33. data/lib/graticule/version.rb +9 -0
  34. data/lib/graticule.rb +26 -0
  35. data/site/index.html +114 -0
  36. data/site/plugin.html +82 -0
  37. data/site/stylesheets/style.css +69 -0
  38. data/test/config.yml.default +36 -0
  39. data/test/fixtures/responses/geocoder_us/success.xml +18 -0
  40. data/test/fixtures/responses/geocoder_us/unknown.xml +1 -0
  41. data/test/fixtures/responses/google/badkey.xml +1 -0
  42. data/test/fixtures/responses/google/limit.xml +10 -0
  43. data/test/fixtures/responses/google/missing_address.xml +1 -0
  44. data/test/fixtures/responses/google/only_coordinates.xml +1 -0
  45. data/test/fixtures/responses/google/partial.xml +1 -0
  46. data/test/fixtures/responses/google/server_error.xml +10 -0
  47. data/test/fixtures/responses/google/success.xml +1 -0
  48. data/test/fixtures/responses/google/success_multiple_results.xml +88 -0
  49. data/test/fixtures/responses/google/unavailable.xml +1 -0
  50. data/test/fixtures/responses/google/unknown_address.xml +1 -0
  51. data/test/fixtures/responses/host_ip/private.txt +4 -0
  52. data/test/fixtures/responses/host_ip/success.txt +4 -0
  53. data/test/fixtures/responses/host_ip/unknown.txt +4 -0
  54. data/test/fixtures/responses/local_search_maps/empty.txt +1 -0
  55. data/test/fixtures/responses/local_search_maps/not_found.txt +1 -0
  56. data/test/fixtures/responses/local_search_maps/success.txt +1 -0
  57. data/test/fixtures/responses/mapquest/multi_result.xml +1 -0
  58. data/test/fixtures/responses/mapquest/success.xml +1 -0
  59. data/test/fixtures/responses/meta_carta/bad_address.xml +17 -0
  60. data/test/fixtures/responses/meta_carta/multiple.xml +33 -0
  61. data/test/fixtures/responses/meta_carta/success.xml +31 -0
  62. data/test/fixtures/responses/multimap/missing_params.xml +4 -0
  63. data/test/fixtures/responses/multimap/no_matches.xml +4 -0
  64. data/test/fixtures/responses/multimap/success.xml +19 -0
  65. data/test/fixtures/responses/postcode_anywhere/badkey.xml +9 -0
  66. data/test/fixtures/responses/postcode_anywhere/canada.xml +16 -0
  67. data/test/fixtures/responses/postcode_anywhere/empty.xml +16 -0
  68. data/test/fixtures/responses/postcode_anywhere/success.xml +16 -0
  69. data/test/fixtures/responses/postcode_anywhere/uk.xml +18 -0
  70. data/test/fixtures/responses/yahoo/success.xml +3 -0
  71. data/test/fixtures/responses/yahoo/unknown_address.xml +6 -0
  72. data/test/mocks/uri.rb +52 -0
  73. data/test/test_helper.rb +31 -0
  74. data/test/unit/graticule/distance_test.rb +58 -0
  75. data/test/unit/graticule/geocoder/geocoder_us_test.rb +43 -0
  76. data/test/unit/graticule/geocoder/geocoders.rb +56 -0
  77. data/test/unit/graticule/geocoder/google_test.rb +112 -0
  78. data/test/unit/graticule/geocoder/host_ip_test.rb +40 -0
  79. data/test/unit/graticule/geocoder/local_search_maps_test.rb +30 -0
  80. data/test/unit/graticule/geocoder/mapquest_test.rb +61 -0
  81. data/test/unit/graticule/geocoder/meta_carta_test.rb +44 -0
  82. data/test/unit/graticule/geocoder/multi_test.rb +43 -0
  83. data/test/unit/graticule/geocoder/multimap_test.rb +52 -0
  84. data/test/unit/graticule/geocoder/postcode_anywhere_test.rb +50 -0
  85. data/test/unit/graticule/geocoder/yahoo_test.rb +48 -0
  86. data/test/unit/graticule/geocoder_test.rb +27 -0
  87. data/test/unit/graticule/location_test.rb +73 -0
  88. metadata +166 -0
@@ -0,0 +1,69 @@
1
+ body {
2
+ font-family: "Lucida Grande", Helvetica, Arial, sans-serif;
3
+ font-size: 76%;
4
+ background: #2A2A2A;
5
+ margin: 0;
6
+ padding: 0;
7
+ }
8
+
9
+ #collectiveidea {
10
+ border-bottom: 1px solid #444;
11
+ }
12
+
13
+ a {
14
+ color: #2D5385;
15
+ }
16
+
17
+ #main {
18
+ background-color: #FFF;
19
+ width: 700px;
20
+ margin: 0 auto;
21
+ border: 5px #CCC;
22
+ border-left-style: solid;
23
+ border-right-style: solid;
24
+ padding: 0 1em;
25
+ }
26
+
27
+ #header {
28
+ position: relative;
29
+ }
30
+
31
+ #header h1 {
32
+ margin: 0;
33
+ padding: 0.5em 0;
34
+ color: #2D5385;
35
+ border-bottom: 1px solid #999;
36
+ }
37
+
38
+ #header h1 a {
39
+ text-decoration: none;
40
+ }
41
+
42
+ #nav {
43
+ list-style: none;
44
+ position: absolute;
45
+ right: 0;
46
+ top: 0.6em;
47
+ }
48
+ #nav li {
49
+ display: inline;
50
+ padding: 0 0.5em;
51
+ }
52
+
53
+ #content {
54
+ padding: 1em 0;
55
+ }
56
+
57
+ dl {
58
+ background-color: #DDD;
59
+ padding: 1em;
60
+ border: 1px solid #CCC;
61
+ }
62
+ dl .pronunciation {
63
+ color: #C00;
64
+ }
65
+ dl .description {
66
+ text-transform: uppercase;
67
+ font-size: 0.8em;
68
+ font-family: fixed;
69
+ }
@@ -0,0 +1,36 @@
1
+ google:
2
+ key: PUT YOUR KEY HERE
3
+ responses:
4
+ success.xml: http://maps.google.com/maps/geo?q=1600+amphitheatre+mtn+view+ca&output=xml&key=:key
5
+ badkey.xml: http://maps.google.com/maps/geo?q=1600+amphitheatre+mtn+view+ca&output=xml&key=this_is_a_bad_key
6
+ missing_address.xml: http://maps.google.com/maps/geo?output=xml&key=:key
7
+ unavailable.xml: http://maps.google.com/maps/geo?q=42-44+Hanway+Street,+London&output=xml&key=:key
8
+ unknown_address.xml: http://maps.google.com/maps/geo?q=1600&output=xml&key=:key
9
+ partial.xml: http://maps.google.com/maps/geo?q=sf+ca&output=xml&key=:key
10
+ #limit.xml: no way to reproduce this
11
+ #server_error.xml: no way to reproduce this
12
+ geocoder_us:
13
+ responses:
14
+ success.xml: http://rpc.geocoder.us/service/rest/geocode?address=1600%20Pennsylvania%20Ave%20NW,%20Washington%20DC
15
+ unknown.xml: http://rpc.geocoder.us/service/rest/geocode?address=1600
16
+ host_ip:
17
+ responses:
18
+ private.txt: http://api.hostip.info/get_html.php?ip=192.168.0.1&position=true
19
+ success.txt: http://api.hostip.info/get_html.php?ip=64.233.167.99&position=true
20
+ unknown.txt: http://api.hostip.info/get_html.php?ip=254.254.254.254&position=true
21
+ local_search_maps:
22
+ responses:
23
+ success.txt: http://geo.localsearchmaps.com/?street=48+Leicester+Square&city=London&country=UK
24
+ empty.txt: http://geo.localsearchmaps.com/
25
+ not_found.txt: http://geo.localsearchmaps.com/?street=48
26
+ meta_carta:
27
+ responses:
28
+ bad_address.xml: http://labs.metacarta.com/GeoParser/?q=aoeueou&output=locations
29
+ # doesn't work
30
+ #multiple.xml: http://labs.metacarta.com/GeoParser/?q=seattle&output=locations
31
+ success.xml: http://labs.metacarta.com/GeoParser/?q=baghdad&output=locations
32
+ yahoo:
33
+ key: PUT YOUR KEY HERE
34
+ responses:
35
+ success.xml: http://api.local.yahoo.com/MapsService/V1/geocode?location=701%20First%20Street,%20Sunnyvale,%20CA&output=xml&appid=:key
36
+ unknown_address.xml: http://api.local.yahoo.com/MapsService/V1/geocode?location=thisprobablycantbefound&output=xml&appid=:key
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0"?>
2
+ <rdf:RDF
3
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
4
+ xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
5
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
6
+ >
7
+
8
+ <geo:Point rdf:nodeID="aid15626963">
9
+
10
+ <dc:description>1600 Pennsylvania Ave NW, Washington DC 20502</dc:description>
11
+ <geo:long>-77.037684</geo:long>
12
+ <geo:lat>38.898748</geo:lat>
13
+
14
+ </geo:Point>
15
+
16
+
17
+ </rdf:RDF>
18
+
@@ -0,0 +1 @@
1
+ couldn't find this address! sorry
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://earth.google.com/kml/2.1"><Response><name>1600 amphitheatre mtn view ca</name><Status><code>610</code><request>geocode</request></Status></Response></kml>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <kml xmlns="http://earth.google.com/kml/2.0">
3
+ <Response>
4
+ <name>1600 Amphitheater Pkwy, Mountain View, CA</name>
5
+ <Status>
6
+ <code>620</code>
7
+ <request>geocode</request>
8
+ </Status>
9
+ </Response>
10
+ </kml>
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://earth.google.com/kml/2.1"><Response><name></name><Status><code>601</code><request>geocode</request></Status></Response></kml>
@@ -0,0 +1 @@
1
+ <?xml version='1.0' encoding='UTF-8'?><kml xmlns='http://earth.google.com/kml/2.0'><Response><name>15-17 </name><Status><code>200</code><request>geocode</request></Status><Placemark id='p1'><Point><coordinates>-17.000000,15.000000,0</coordinates></Point></Placemark></Response></kml>
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://earth.google.com/kml/2.1"><Response><name>sf ca</name><Status><code>200</code><request>geocode</request></Status><Placemark><address>San Francisco, CA, USA</address><AddressDetails Accuracy="4" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"><Country><CountryNameCode>US</CountryNameCode><AdministrativeArea><AdministrativeAreaName>CA</AdministrativeAreaName><Locality><LocalityName>San Francisco</LocalityName></Locality></AdministrativeArea></Country></AddressDetails><Point><coordinates>-122.418333,37.775000,0</coordinates></Point></Placemark></Response></kml>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <kml xmlns="http://earth.google.com/kml/2.0">
3
+ <Response>
4
+ <name>1600 Amphitheater Pkwy, Mountain View, CA</name>
5
+ <Status>
6
+ <code>500</code>
7
+ <request>geocode</request>
8
+ </Status>
9
+ </Response>
10
+ </kml>
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://earth.google.com/kml/2.1"><Response><name>1600 amphitheatre mtn view ca</name><Status><code>200</code><request>geocode</request></Status><Placemark><address>1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA</address><AddressDetails Accuracy="8" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"><Country><CountryNameCode>US</CountryNameCode><AdministrativeArea><AdministrativeAreaName>CA</AdministrativeAreaName><SubAdministrativeArea><SubAdministrativeAreaName>Santa Clara</SubAdministrativeAreaName><Locality><LocalityName>Mountain View</LocalityName><Thoroughfare><ThoroughfareName>1600 Amphitheatre Pkwy</ThoroughfareName></Thoroughfare><PostalCode><PostalCodeNumber>94043</PostalCodeNumber></PostalCode></Locality></SubAdministrativeArea></AdministrativeArea></Country></AddressDetails><Point><coordinates>-122.083739,37.423021,0</coordinates></Point></Placemark></Response></kml>
@@ -0,0 +1,88 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <kml xmlns='http://earth.google.com/kml/2.0'><Response>
3
+ <name>Queen St West</name>
4
+ <Status>
5
+ <code>200</code>
6
+ <request>geocode</request>
7
+ </Status>
8
+ <Placemark id='p1'>
9
+ <address>Queen St W, Toronto, ON, Canada</address>
10
+ <AddressDetails Accuracy='6' xmlns='urn:oasis:names:tc:ciq:xsdschema:xAL:2.0'><Country><CountryNameCode>CA</CountryNameCode><CountryName>Canada</CountryName><AdministrativeArea><AdministrativeAreaName>ON</AdministrativeAreaName><Locality><LocalityName>Toronto</LocalityName><Thoroughfare><ThoroughfareName>Queen St W</ThoroughfareName></Thoroughfare></Locality></AdministrativeArea></Country></AddressDetails>
11
+ <ExtendedData>
12
+ <LatLonBox east='-79.3792510' south='43.6387420' west='-79.4460830' north='43.6524210'/>
13
+ </ExtendedData>
14
+ <Point><coordinates>-79.4125590,43.6455030,0</coordinates></Point>
15
+ </Placemark>
16
+ <Placemark id='p2'>
17
+ <address>Queen St W, Brampton, ON, Canada</address>
18
+ <AddressDetails Accuracy='6' xmlns='urn:oasis:names:tc:ciq:xsdschema:xAL:2.0'><Country><CountryNameCode>CA</CountryNameCode><CountryName>Canada</CountryName><AdministrativeArea><AdministrativeAreaName>ON</AdministrativeAreaName><Locality><LocalityName>Brampton</LocalityName><Thoroughfare><ThoroughfareName>Queen St W</ThoroughfareName></Thoroughfare></Locality></AdministrativeArea></Country></AddressDetails>
19
+ <ExtendedData>
20
+ <LatLonBox east='-79.7599410' south='43.6477210' west='-79.8030440' north='43.6859000'/>
21
+ </ExtendedData>
22
+ <Point><coordinates>-79.7814960,43.6665410,0</coordinates></Point>
23
+ </Placemark>
24
+ <Placemark id='p3'>
25
+ <address>Queen St W, Levin, 5510, New Zealand</address>
26
+ <AddressDetails Accuracy='6' xmlns='urn:oasis:names:tc:ciq:xsdschema:xAL:2.0'><Country><CountryNameCode>NZ</CountryNameCode><CountryName>New Zealand</CountryName><Locality><LocalityName>Levin</LocalityName><Thoroughfare><ThoroughfareName>Queen St W</ThoroughfareName></Thoroughfare><PostalCode><PostalCodeNumber>5510</PostalCodeNumber></PostalCode></Locality></Country></AddressDetails>
27
+ <ExtendedData>
28
+ <LatLonBox east='175.2872230' south='-40.6221080' west='175.2645080' north='-40.6111560'/>
29
+ </ExtendedData>
30
+ <Point><coordinates>175.2753040,-40.6170160,0</coordinates></Point>
31
+ </Placemark>
32
+ <Placemark id='p4'>
33
+ <address>Queen St W, Mt Forest, ON, Canada</address>
34
+ <AddressDetails Accuracy='6' xmlns='urn:oasis:names:tc:ciq:xsdschema:xAL:2.0'><Country><CountryNameCode>CA</CountryNameCode><CountryName>Canada</CountryName><AdministrativeArea><AdministrativeAreaName>ON</AdministrativeAreaName><Locality><LocalityName>Mt Forest</LocalityName><Thoroughfare><ThoroughfareName>Queen St W</ThoroughfareName></Thoroughfare><PostalCode><PostalCodeNumber>N0G</PostalCodeNumber></PostalCode></Locality></AdministrativeArea></Country></AddressDetails>
35
+ <ExtendedData>
36
+ <LatLonBox east='-80.7320620' south='43.9748569' west='-80.7542680' north='43.9811521'/>
37
+ </ExtendedData>
38
+ <Point><coordinates>-80.7434380,43.9779890,0</coordinates></Point>
39
+ </Placemark>
40
+ <Placemark id='p5'>
41
+ <address>Queen St W, St Marys, ON, Canada</address>
42
+ <AddressDetails Accuracy='6' xmlns='urn:oasis:names:tc:ciq:xsdschema:xAL:2.0'><Country><CountryNameCode>CA</CountryNameCode><CountryName>Canada</CountryName><AdministrativeArea><AdministrativeAreaName>ON</AdministrativeAreaName><Locality><LocalityName>St Marys</LocalityName><Thoroughfare><ThoroughfareName>Queen St W</ThoroughfareName></Thoroughfare><PostalCode><PostalCodeNumber>N4X</PostalCodeNumber></PostalCode></Locality></AdministrativeArea></Country></AddressDetails>
43
+ <ExtendedData>
44
+ <LatLonBox east='-81.1442510' south='43.2548039' west='-81.1674090' north='43.2610991'/>
45
+ </ExtendedData>
46
+ <Point><coordinates>-81.1556430,43.2579490,0</coordinates></Point>
47
+ </Placemark>
48
+ <Placemark id='p6'>
49
+ <address>Queen St W, Barrie, ON, Canada</address>
50
+ <AddressDetails Accuracy='6' xmlns='urn:oasis:names:tc:ciq:xsdschema:xAL:2.0'><Country><CountryNameCode>CA</CountryNameCode><CountryName>Canada</CountryName><AdministrativeArea><AdministrativeAreaName>ON</AdministrativeAreaName><Locality><LocalityName>Barrie</LocalityName><Thoroughfare><ThoroughfareName>Queen St W</ThoroughfareName></Thoroughfare><PostalCode><PostalCodeNumber>L0L</PostalCodeNumber></PostalCode></Locality></AdministrativeArea></Country></AddressDetails>
51
+ <ExtendedData>
52
+ <LatLonBox east='-79.8661300' south='44.5748470' west='-79.8859520' north='44.5835790'/>
53
+ </ExtendedData>
54
+ <Point><coordinates>-79.8762460,44.5791840,0</coordinates></Point>
55
+ </Placemark>
56
+ <Placemark id='p7'>
57
+ <address>Queen St W, Owen Sound, ON, Canada</address>
58
+ <AddressDetails Accuracy='6' xmlns='urn:oasis:names:tc:ciq:xsdschema:xAL:2.0'><Country><CountryNameCode>CA</CountryNameCode><CountryName>Canada</CountryName><AdministrativeArea><AdministrativeAreaName>ON</AdministrativeAreaName><Locality><LocalityName>Owen Sound</LocalityName><Thoroughfare><ThoroughfareName>Queen St W</ThoroughfareName></Thoroughfare><PostalCode><PostalCodeNumber>N0H</PostalCodeNumber></PostalCode></Locality></AdministrativeArea></Country></AddressDetails>
59
+ <ExtendedData>
60
+ <LatLonBox east='-81.1333070' south='44.6303544' west='-81.1489540' north='44.6366496'/>
61
+ </ExtendedData>
62
+ <Point><coordinates>-81.1428830,44.6334130,0</coordinates></Point>
63
+ </Placemark>
64
+ <Placemark id='p8'>
65
+ <address>Queen St W, Mississauga, ON, Canada</address>
66
+ <AddressDetails Accuracy='6' xmlns='urn:oasis:names:tc:ciq:xsdschema:xAL:2.0'><Country><CountryNameCode>CA</CountryNameCode><CountryName>Canada</CountryName><AdministrativeArea><AdministrativeAreaName>ON</AdministrativeAreaName><Locality><LocalityName>Mississauga</LocalityName><Thoroughfare><ThoroughfareName>Queen St W</ThoroughfareName></Thoroughfare><PostalCode><PostalCodeNumber>L5H</PostalCodeNumber></PostalCode></Locality></AdministrativeArea></Country></AddressDetails>
67
+ <ExtendedData>
68
+ <LatLonBox east='-79.5927510' south='43.5315270' west='-79.6117140' north='43.5498140'/>
69
+ </ExtendedData>
70
+ <Point><coordinates>-79.6023990,43.5407460,0</coordinates></Point>
71
+ </Placemark>
72
+ <Placemark id='p9'>
73
+ <address>Queen St W, Cambridge, ON, Canada</address>
74
+ <AddressDetails Accuracy='6' xmlns='urn:oasis:names:tc:ciq:xsdschema:xAL:2.0'><Country><CountryNameCode>CA</CountryNameCode><CountryName>Canada</CountryName><AdministrativeArea><AdministrativeAreaName>ON</AdministrativeAreaName><Locality><LocalityName>Cambridge</LocalityName><Thoroughfare><ThoroughfareName>Queen St W</ThoroughfareName></Thoroughfare><PostalCode><PostalCodeNumber>N3C</PostalCodeNumber></PostalCode></Locality></AdministrativeArea></Country></AddressDetails>
75
+ <ExtendedData>
76
+ <LatLonBox east='-80.3108330' south='43.4202100' west='-80.3287680' north='43.4312910'/>
77
+ </ExtendedData>
78
+ <Point><coordinates>-80.3202040,43.4267810,0</coordinates></Point>
79
+ </Placemark>
80
+ <Placemark id='p10'>
81
+ <address>Queen St W, Sault Ste. Marie, ON, Canada</address>
82
+ <AddressDetails Accuracy='6' xmlns='urn:oasis:names:tc:ciq:xsdschema:xAL:2.0'><Country><CountryNameCode>CA</CountryNameCode><CountryName>Canada</CountryName><AdministrativeArea><AdministrativeAreaName>ON</AdministrativeAreaName><Locality><LocalityName>Sault Ste. Marie</LocalityName><Thoroughfare><ThoroughfareName>Queen St W</ThoroughfareName></Thoroughfare><PostalCode><PostalCodeNumber>P6A</PostalCodeNumber></PostalCode></Locality></AdministrativeArea></Country></AddressDetails>
83
+ <ExtendedData>
84
+ <LatLonBox east='-84.3411900' south='46.5155194' west='-84.3592850' north='46.5218146'/>
85
+ </ExtendedData>
86
+ <Point><coordinates>-84.3506780,46.5187300,0</coordinates></Point>
87
+ </Placemark>
88
+ </Response></kml>
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://earth.google.com/kml/2.1"><Response><name>42-44 Hanway Street, London</name><Status><code>602</code><request>geocode</request></Status></Response></kml>
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://earth.google.com/kml/2.1"><Response><name>1600</name><Status><code>602</code><request>geocode</request></Status></Response></kml>
@@ -0,0 +1,4 @@
1
+ Country: (Private Address) (XX)
2
+ City: (Private Address)
3
+ Latitude:
4
+ Longitude:
@@ -0,0 +1,4 @@
1
+ Country: UNITED STATES (US)
2
+ City: Mountain View, CA
3
+ Latitude: 37.402
4
+ Longitude: -122.078
@@ -0,0 +1,4 @@
1
+ Country: (Unknown Country?) (XX)
2
+ City: (Unknown City?)
3
+ Latitude:
4
+ Longitude:
@@ -0,0 +1 @@
1
+ alert('Please provide a location');
@@ -0,0 +1 @@
1
+ alert('location not found');
@@ -0,0 +1 @@
1
+ map.centerAndZoom(new GPoint(-0.130427, 51.510036), 4);
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1"?><GeocodeResponse><LocationCollection Count="10"><GeoAddress><AdminArea1>US</AdminArea1><AdminArea3>NY</AdminArea3><AdminArea4>Suffolk County</AdminArea4><AdminArea5>Stony Brook</AdminArea5><LatLng><Lat>40.925598</Lat><Lng>-73.141403</Lng></LatLng><ResultCode>A5XCX</ResultCode><SourceId>gaz_us</SourceId></GeoAddress><GeoAddress><AdminArea1>US</AdminArea1><AdminArea3>NY</AdminArea3><AdminArea4>Rockland County</AdminArea4><AdminArea5>Stony Point</AdminArea5><LatLng><Lat>41.229401</Lat><Lng>-73.987503</Lng></LatLng><ResultCode>A5XCX</ResultCode><SourceId>gaz_us</SourceId></GeoAddress></LocationCollection></GeocodeResponse>
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1"?><GeocodeResponse><LocationCollection Count="1"><GeoAddress><AdminArea1>US</AdminArea1><AdminArea3>ME</AdminArea3><AdminArea4>Oxford County</AdminArea4><AdminArea5>Lovell</AdminArea5><PostalCode>04051-3919</PostalCode><Street>44 Allen Rd</Street><LatLng><Lat>44.152019</Lat><Lng>-70.892706</Lng></LatLng><ResultCode>L1AAA</ResultCode><SourceId>navt</SourceId></GeoAddress></LocationCollection></GeocodeResponse>
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+
3
+ <!DOCTYPE Locations SYSTEM "Locations.dtd">
4
+
5
+ <Locations
6
+ xmlns:gml="http://www.opengis.net/gml"
7
+ CreatedBy="MetaCarta GeoParser v3.7.0-labs"
8
+ CreatedOn="Wed Apr 25 22:12:33 2007"
9
+ ConvertedFromBinaryFormat="0"
10
+ InputByteLength="0">
11
+ <ViewBox>
12
+
13
+ <gml:Box srsName="epsg:4326">
14
+ <gml:coordinates>-180.000000,-90.000000 180.000000,90.000000</gml:coordinates>
15
+ </gml:Box>
16
+ </ViewBox>
17
+ </Locations>
@@ -0,0 +1,33 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE Locations SYSTEM "Locations.dtd">
3
+ <Locations xmlns:gml="http://www.opengis.net/gml" CreatedBy="MetaCarta GeoParser v3.5.0-labs-alpha" CreatedOn="Sat Jun 17 02:14:05 2006" ConvertedFromBinaryFormat="False" InputByteLength="1">
4
+ <ViewBox>
5
+ <gml:Box srsName="epsg:4326">
6
+ <gml:coordinates>43.800000,-126.133333 51.406390,-118.530830</gml:coordinates>
7
+ </gml:Box>
8
+ </ViewBox>
9
+ <Location Name="Seattle" Type="PPL" Population="563374" Hierarchy="United States/Washington/King/Seattle">
10
+ <ViewBox>
11
+ <gml:Box srsName="epsg:4326">
12
+ <gml:coordinates>43.806390,-126.130830 51.406390,-118.530830</gml:coordinates>
13
+ </gml:Box>
14
+ </ViewBox>
15
+ <Centroid>
16
+ <gml:Point>
17
+ <gml:coordinates>-122.330830000000006,47.606389999999998</gml:coordinates>
18
+ </gml:Point>
19
+ </Centroid>
20
+ </Location>
21
+ <Location Name="Seattle" Type="PRT" Population="-1" Hierarchy="United States/Seattle">
22
+ <ViewBox>
23
+ <gml:Box srsName="epsg:4326">
24
+ <gml:coordinates>43.800000,-126.133333 51.400000,-118.533333</gml:coordinates>
25
+ </gml:Box>
26
+ </ViewBox>
27
+ <Centroid>
28
+ <gml:Point>
29
+ <gml:coordinates>-122.333332999999996,47.6</gml:coordinates>
30
+ </gml:Point>
31
+ </Centroid>
32
+ </Location>
33
+ </Locations>
@@ -0,0 +1,31 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+
3
+ <!DOCTYPE Locations SYSTEM "Locations.dtd">
4
+
5
+ <Locations
6
+ xmlns:gml="http://www.opengis.net/gml"
7
+ CreatedBy="MetaCarta GeoParser v3.7.0-labs"
8
+ CreatedOn="Wed Apr 25 22:12:33 2007"
9
+ ConvertedFromBinaryFormat="0"
10
+ InputByteLength="0">
11
+ <ViewBox>
12
+
13
+ <gml:Box srsName="epsg:4326">
14
+ <gml:coordinates>43.593900,32.538600 45.193900,34.138600</gml:coordinates>
15
+ </gml:Box>
16
+ </ViewBox>
17
+ <Location
18
+
19
+ Name="Baghdad"
20
+ Type=""
21
+ Population="-1"
22
+ Hierarchy="">
23
+ <ViewBox>
24
+ <gml:Box srsName="epsg:4326">
25
+ <gml:coordinates>43.593900,32.538600 45.193900,34.138600</gml:coordinates>
26
+ </gml:Box>
27
+ </ViewBox>
28
+ <RemainingQuery></RemainingQuery>
29
+ <Confidence>0.566875</Confidence> <Centroid><gml:Point><gml:coordinates>44.393900000000002,33.3386</gml:coordinates></gml:Point></Centroid>
30
+ </Location>
31
+ </Locations>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <Results xmlns="http://clients.multimap.com/API" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+ xsi:schemaLocation="http://clients.multimap.com/API http://clients.multimap.com/Schema/geocode_1.2.xsd"
4
+ errorCode="MM_GEOCODE_REQUIRED_PARAMETERS_MISSING" locationCount="0" />
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <Results xmlns="http://clients.multimap.com/API" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+ xsi:schemaLocation="http://clients.multimap.com/API http://clients.multimap.com/Schema/geocode_1.2.xsd"
4
+ errorCode="MM_GEOCODE_NO_MATCHES" locationCount="0" />
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <Results xmlns="http://clients.multimap.com/API" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+ xsi:schemaLocation="http://clients.multimap.com/API http://clients.multimap.com/Schema/geocode_1.2.xsd" locationCount="1">
4
+ <Location geocodeQuality="1">
5
+ <Address>
6
+ <Street>Oxford Street</Street>
7
+ <Areas>
8
+ <Area>LONDON</Area>
9
+ </Areas>
10
+ <PostalCode>W1</PostalCode>
11
+ <DisplayName>Oxford Street, LONDON, W1</DisplayName>
12
+ <CountryCode>GB</CountryCode>
13
+ </Address>
14
+ <Point>
15
+ <Lat>51.51452</Lat>
16
+ <Lon>-0.14839</Lon>
17
+ </Point>
18
+ </Location>
19
+ </Results>
@@ -0,0 +1,9 @@
1
+ <PostcodeAnywhere Server="WS12" Version="3.0" Date="12/03/2007 15:43:33" Duration="0.016s">
2
+ <Schema Items="2">
3
+ <Field Name="error_number"/>
4
+ <Field Name="message"/>
5
+ </Schema>
6
+ <Data Items="1">
7
+ <Item error_number="6" message="License key was not recognised"/>
8
+ </Data>
9
+ </PostcodeAnywhere>
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <PostcodeAnywhere Server="WS12" Version="3.0" Date="17/03/2007 19:01:05" Duration="1.109s">
3
+ <Schema Items="8">
4
+ <Field Name="line1"/>
5
+ <Field Name="line2"/>
6
+ <Field Name="city"/>
7
+ <Field Name="state"/>
8
+ <Field Name="postal_code"/>
9
+ <Field Name="country"/>
10
+ <Field Name="longitude"/>
11
+ <Field Name="latitude"/>
12
+ </Schema>
13
+ <Data Items="1">
14
+ <Item line1="204 Campbell Ave" city="Revelstoke" state="BC" postal_code="V0E" country="Canada" longitude="-118.196970002204" latitude="50.9997350418267"/>
15
+ </Data>
16
+ </PostcodeAnywhere>
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <PostcodeAnywhere Version="3.0" Server="WS03" Date="17/03/2007 19:26:33" Duration="0.016s">
3
+ <Schema Items="10">
4
+ <Field Name="id"/>
5
+ <Field Name="seq"/>
6
+ <Field Name="location"/>
7
+ <Field Name="grid_east_m"/>
8
+ <Field Name="grid_north_m"/>
9
+ <Field Name="longitude"/>
10
+ <Field Name="latitude"/>
11
+ <Field Name="os_reference"/>
12
+ <Field Name="wgs84_longitude"/>
13
+ <Field Name="wgs84_latitude"/>
14
+ </Schema>
15
+ <Data Items="0"/>
16
+ </PostcodeAnywhere>
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <PostcodeAnywhere Server="WS11" Version="3.0" Date="17/03/2007 18:12:11" Duration="1.703s">
3
+ <Schema Items="8">
4
+ <Field Name="line1"/>
5
+ <Field Name="line2"/>
6
+ <Field Name="city"/>
7
+ <Field Name="state"/>
8
+ <Field Name="postal_code"/>
9
+ <Field Name="country"/>
10
+ <Field Name="longitude"/>
11
+ <Field Name="latitude"/>
12
+ </Schema>
13
+ <Data Items="1">
14
+ <Item line1="204 Campbell Ave" city="Revelstoke" state="BC" postal_code="V0E" country="Canada" longitude="-118.196970002204" latitude="50.9997350418267"/>
15
+ </Data>
16
+ </PostcodeAnywhere>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <PostcodeAnywhere Server="WS12" Version="3.0" Date="17/03/2007 19:01:39" Duration="2.422s">
3
+ <Schema Items="10">
4
+ <Field Name="id"/>
5
+ <Field Name="seq"/>
6
+ <Field Name="location"/>
7
+ <Field Name="grid_east_m"/>
8
+ <Field Name="grid_north_m"/>
9
+ <Field Name="longitude"/>
10
+ <Field Name="latitude"/>
11
+ <Field Name="os_reference"/>
12
+ <Field Name="wgs84_longitude"/>
13
+ <Field Name="wgs84_latitude"/>
14
+ </Schema>
15
+ <Data Items="1">
16
+ <Item id="17783983.00" seq="0" location="80 Wood Lane London NW9" grid_east_m="521000" grid_north_m="187500" longitude="-0.253788666693255" latitude="51.5728910186362" os_reference="TQ 21000 87500" wgs84_longitude="-0.255365891581496" wgs84_latitude="51.5733397173092"/>
17
+ </Data>
18
+ </PostcodeAnywhere>
@@ -0,0 +1,3 @@
1
+ <?xml version="1.0"?>
2
+ <ResultSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:yahoo:maps" xsi:schemaLocation="urn:yahoo:maps http://api.local.yahoo.com/MapsService/V1/GeocodeResponse.xsd"><Result precision="address" warning="The exact location could not be found, here is the closest match: 701 First Ave, Sunnyvale, CA 94089"><Latitude>37.416384</Latitude><Longitude>-122.024853</Longitude><Address>701 FIRST AVE</Address><City>SUNNYVALE</City><State>CA</State><Zip>94089-1019</Zip><Country>US</Country></Result></ResultSet>
3
+ <!-- ws06.search.re2.yahoo.com uncompressed/chunked Wed Apr 25 15:13:01 PDT 2007 -->
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Error xmlns="urn:yahoo:api">
3
+ The following errors were detected:
4
+ <Message>unable to parse location</Message>
5
+ </Error>
6
+ <!-- ws05.search.re2.yahoo.com uncompressed/chunked Wed Apr 25 15:13:01 PDT 2007 -->
data/test/mocks/uri.rb ADDED
@@ -0,0 +1,52 @@
1
+ require 'uri/http'
2
+ require 'open-uri'
3
+
4
+ ##
5
+ # This stub overrides OpenURI's open method to allow programs that use OpenURI
6
+ # to be easily tested.
7
+ #
8
+ # == Usage
9
+ #
10
+ # require 'rc_rest/uri_stub'
11
+ #
12
+ # class TestMyClass < Test::Unit::TestCase
13
+ #
14
+ # def setup
15
+ # URI::HTTP.responses = []
16
+ # URI::HTTP.uris = []
17
+ #
18
+ # @obj = MyClass.new
19
+ # end
20
+ #
21
+ # def test_my_method
22
+ # URI::HTTP.responses << 'some text open would ordinarily return'
23
+ #
24
+ # result = @obj.my_method
25
+ #
26
+ # assert_equal :something_meaninfgul, result
27
+ #
28
+ # assert_equal true, URI::HTTP.responses.empty?
29
+ # assert_equal 1, URI::HTTP.uris.length
30
+ # assert_equal 'http://example.com/path', URI::HTTP.uris.first
31
+ # end
32
+ #
33
+ # end
34
+
35
+ class URI::HTTP # :nodoc:
36
+
37
+ class << self
38
+ attr_accessor :responses, :uris
39
+ end
40
+
41
+ alias original_open open
42
+
43
+ def open(*args)
44
+ self.class.uris << self.to_s
45
+ io = StringIO.new(self.class.responses.shift)
46
+ OpenURI::Meta.init(io)
47
+ yield io if block_given?
48
+ io
49
+ end
50
+
51
+ end
52
+
@@ -0,0 +1,31 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
2
+ $:.unshift(File.dirname(__FILE__) + '/mocks')
3
+
4
+ require 'rubygems'
5
+ require 'yaml'
6
+ require 'test/unit'
7
+ require 'graticule'
8
+ require 'mocha'
9
+
10
+ TEST_RESPONSE_PATH = File.dirname(__FILE__) + '/fixtures/responses'
11
+
12
+ module Test
13
+ module Unit
14
+ module Assertions
15
+
16
+ private
17
+ def response(geocoder, response, extension = 'xml')
18
+ clean_backtrace do
19
+ File.read(File.dirname(__FILE__) + "/fixtures/responses/#{geocoder}/#{response}.#{extension}")
20
+ end
21
+ end
22
+
23
+ def clean_backtrace(&block)
24
+ yield
25
+ rescue AssertionFailedError => e
26
+ path = File.expand_path(__FILE__)
27
+ raise AssertionFailedError, e.message, e.backtrace.reject { |line| File.expand_path(line) =~ /#{path}/ }
28
+ end
29
+ end
30
+ end
31
+ end