geocoder2 0.1.0
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 +5 -0
- data/.travis.yml +27 -0
- data/CHANGELOG.md +329 -0
- data/LICENSE +20 -0
- data/README.md +796 -0
- data/Rakefile +25 -0
- data/bin/geocode2 +5 -0
- data/examples/autoexpire_cache_dalli.rb +62 -0
- data/examples/autoexpire_cache_redis.rb +28 -0
- data/examples/cache_bypass.rb +48 -0
- data/gemfiles/Gemfile.mongoid-2.4.x +15 -0
- data/json?address=26+leonard+street%2C+Belmont&key=AIzaSyDoltU6YL8XeIQrSLFGk6ZfpKaWkPukwYQ&language=en +68 -0
- data/lib/generators/geocoder2/config/config_generator.rb +14 -0
- data/lib/generators/geocoder2/config/templates/initializer.rb +21 -0
- data/lib/geocoder2/cache.rb +89 -0
- data/lib/geocoder2/calculations.rb +389 -0
- data/lib/geocoder2/cli.rb +121 -0
- data/lib/geocoder2/configuration.rb +130 -0
- data/lib/geocoder2/configuration_hash.rb +11 -0
- data/lib/geocoder2/exceptions.rb +21 -0
- data/lib/geocoder2/lookup.rb +86 -0
- data/lib/geocoder2/lookups/baidu.rb +54 -0
- data/lib/geocoder2/lookups/base.rb +266 -0
- data/lib/geocoder2/lookups/bing.rb +47 -0
- data/lib/geocoder2/lookups/dstk.rb +20 -0
- data/lib/geocoder2/lookups/esri.rb +48 -0
- data/lib/geocoder2/lookups/freegeoip.rb +43 -0
- data/lib/geocoder2/lookups/geocoder_ca.rb +54 -0
- data/lib/geocoder2/lookups/geocoder_us.rb +39 -0
- data/lib/geocoder2/lookups/google.rb +69 -0
- data/lib/geocoder2/lookups/google_premier.rb +47 -0
- data/lib/geocoder2/lookups/mapquest.rb +59 -0
- data/lib/geocoder2/lookups/maxmind.rb +88 -0
- data/lib/geocoder2/lookups/nominatim.rb +44 -0
- data/lib/geocoder2/lookups/ovi.rb +62 -0
- data/lib/geocoder2/lookups/test.rb +44 -0
- data/lib/geocoder2/lookups/yahoo.rb +86 -0
- data/lib/geocoder2/lookups/yandex.rb +54 -0
- data/lib/geocoder2/models/active_record.rb +46 -0
- data/lib/geocoder2/models/base.rb +42 -0
- data/lib/geocoder2/models/mongo_base.rb +60 -0
- data/lib/geocoder2/models/mongo_mapper.rb +26 -0
- data/lib/geocoder2/models/mongoid.rb +32 -0
- data/lib/geocoder2/query.rb +107 -0
- data/lib/geocoder2/railtie.rb +26 -0
- data/lib/geocoder2/request.rb +23 -0
- data/lib/geocoder2/results/baidu.rb +79 -0
- data/lib/geocoder2/results/base.rb +67 -0
- data/lib/geocoder2/results/bing.rb +48 -0
- data/lib/geocoder2/results/dstk.rb +6 -0
- data/lib/geocoder2/results/esri.rb +51 -0
- data/lib/geocoder2/results/freegeoip.rb +45 -0
- data/lib/geocoder2/results/geocoder_ca.rb +60 -0
- data/lib/geocoder2/results/geocoder_us.rb +39 -0
- data/lib/geocoder2/results/google.rb +124 -0
- data/lib/geocoder2/results/google_premier.rb +6 -0
- data/lib/geocoder2/results/mapquest.rb +51 -0
- data/lib/geocoder2/results/maxmind.rb +135 -0
- data/lib/geocoder2/results/nominatim.rb +94 -0
- data/lib/geocoder2/results/ovi.rb +62 -0
- data/lib/geocoder2/results/test.rb +16 -0
- data/lib/geocoder2/results/yahoo.rb +55 -0
- data/lib/geocoder2/results/yandex.rb +80 -0
- data/lib/geocoder2/sql.rb +106 -0
- data/lib/geocoder2/stores/active_record.rb +272 -0
- data/lib/geocoder2/stores/base.rb +120 -0
- data/lib/geocoder2/stores/mongo_base.rb +89 -0
- data/lib/geocoder2/stores/mongo_mapper.rb +13 -0
- data/lib/geocoder2/stores/mongoid.rb +13 -0
- data/lib/geocoder2/version.rb +3 -0
- data/lib/geocoder2.rb +55 -0
- data/lib/hash_recursive_merge.rb +74 -0
- data/lib/oauth_util.rb +112 -0
- data/lib/tasks/geocoder2.rake +27 -0
- data/test/active_record_test.rb +15 -0
- data/test/cache_test.rb +35 -0
- data/test/calculations_test.rb +211 -0
- data/test/configuration_test.rb +78 -0
- data/test/custom_block_test.rb +32 -0
- data/test/error_handling_test.rb +43 -0
- data/test/fixtures/baidu_invalid_key +1 -0
- data/test/fixtures/baidu_no_results +1 -0
- data/test/fixtures/baidu_reverse +1 -0
- data/test/fixtures/baidu_shanghai_pearl_tower +12 -0
- data/test/fixtures/bing_invalid_key +1 -0
- data/test/fixtures/bing_madison_square_garden +40 -0
- data/test/fixtures/bing_no_results +16 -0
- data/test/fixtures/bing_reverse +42 -0
- data/test/fixtures/esri_madison_square_garden +59 -0
- data/test/fixtures/esri_no_results +8 -0
- data/test/fixtures/esri_reverse +21 -0
- data/test/fixtures/freegeoip_74_200_247_59 +12 -0
- data/test/fixtures/freegeoip_no_results +1 -0
- data/test/fixtures/geocoder_ca_madison_square_garden +1 -0
- data/test/fixtures/geocoder_ca_no_results +1 -0
- data/test/fixtures/geocoder_ca_reverse +34 -0
- data/test/fixtures/geocoder_us_madison_square_garden +1 -0
- data/test/fixtures/geocoder_us_no_results +1 -0
- data/test/fixtures/google_garbage +456 -0
- data/test/fixtures/google_madison_square_garden +57 -0
- data/test/fixtures/google_no_city_data +44 -0
- data/test/fixtures/google_no_locality +51 -0
- data/test/fixtures/google_no_results +4 -0
- data/test/fixtures/google_over_limit +4 -0
- data/test/fixtures/mapquest_error +16 -0
- data/test/fixtures/mapquest_invalid_api_key +16 -0
- data/test/fixtures/mapquest_invalid_request +16 -0
- data/test/fixtures/mapquest_madison_square_garden +52 -0
- data/test/fixtures/mapquest_no_results +16 -0
- data/test/fixtures/maxmind_24_24_24_21 +1 -0
- data/test/fixtures/maxmind_24_24_24_22 +1 -0
- data/test/fixtures/maxmind_24_24_24_23 +1 -0
- data/test/fixtures/maxmind_24_24_24_24 +1 -0
- data/test/fixtures/maxmind_74_200_247_59 +1 -0
- data/test/fixtures/maxmind_invalid_key +1 -0
- data/test/fixtures/maxmind_no_results +1 -0
- data/test/fixtures/nominatim_madison_square_garden +150 -0
- data/test/fixtures/nominatim_no_results +1 -0
- data/test/fixtures/ovi_madison_square_garden +72 -0
- data/test/fixtures/ovi_no_results +8 -0
- data/test/fixtures/yahoo_error +1 -0
- data/test/fixtures/yahoo_invalid_key +2 -0
- data/test/fixtures/yahoo_madison_square_garden +52 -0
- data/test/fixtures/yahoo_no_results +10 -0
- data/test/fixtures/yahoo_over_limit +2 -0
- data/test/fixtures/yandex_invalid_key +1 -0
- data/test/fixtures/yandex_kremlin +48 -0
- data/test/fixtures/yandex_no_city_and_town +112 -0
- data/test/fixtures/yandex_no_results +16 -0
- data/test/geocoder_test.rb +59 -0
- data/test/https_test.rb +16 -0
- data/test/integration/smoke_test.rb +26 -0
- data/test/lookup_test.rb +117 -0
- data/test/method_aliases_test.rb +25 -0
- data/test/mongoid_test.rb +46 -0
- data/test/mongoid_test_helper.rb +43 -0
- data/test/near_test.rb +61 -0
- data/test/oauth_util_test.rb +30 -0
- data/test/proxy_test.rb +36 -0
- data/test/query_test.rb +52 -0
- data/test/request_test.rb +29 -0
- data/test/result_test.rb +42 -0
- data/test/services_test.rb +393 -0
- data/test/test_helper.rb +289 -0
- data/test/test_mode_test.rb +59 -0
- metadata +213 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"results": [
|
|
3
|
+
{
|
|
4
|
+
"locations": [
|
|
5
|
+
{
|
|
6
|
+
"latLng": {
|
|
7
|
+
"lng": -73.994637,
|
|
8
|
+
"lat": 40.720409
|
|
9
|
+
},
|
|
10
|
+
"adminArea4": "New York County",
|
|
11
|
+
"adminArea5Type": "City",
|
|
12
|
+
"adminArea4Type": "County",
|
|
13
|
+
"adminArea5": "New York",
|
|
14
|
+
"street": "46 West 31st Street",
|
|
15
|
+
"adminArea1": "US",
|
|
16
|
+
"adminArea3": "NY",
|
|
17
|
+
"type": "s",
|
|
18
|
+
"displayLatLng": {
|
|
19
|
+
"lng": -73.994637,
|
|
20
|
+
"lat": 40.720409
|
|
21
|
+
},
|
|
22
|
+
"linkId": 0,
|
|
23
|
+
"postalCode": "10001",
|
|
24
|
+
"sideOfStreet": "N",
|
|
25
|
+
"dragPoint": false,
|
|
26
|
+
"adminArea1Type": "Country",
|
|
27
|
+
"geocodeQuality": "CITY",
|
|
28
|
+
"geocodeQualityCode": "A5XAX",
|
|
29
|
+
"mapUrl": "http://www.mapquestapi.com/staticmap/v3/getmap?type=map&size=225,160&pois=purple-1,40.720409,-73.994637,0,0|¢er=40.720409,-73.994637&zoom=9&key=Gmjtd|luua2hu2nd,7x=o5-lz8lg&rand=604519389",
|
|
30
|
+
"adminArea3Type": "State"
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"providedLocation": {
|
|
34
|
+
"location": "Madison Square Garden, New York, NY"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"options": {
|
|
39
|
+
"ignoreLatLngInput": false,
|
|
40
|
+
"maxResults": -1,
|
|
41
|
+
"thumbMaps": true
|
|
42
|
+
},
|
|
43
|
+
"info": {
|
|
44
|
+
"copyright": {
|
|
45
|
+
"text": "© 2012 MapQuest, Inc.",
|
|
46
|
+
"imageUrl": "http://api.mqcdn.com/res/mqlogo.gif",
|
|
47
|
+
"imageAltText": "© 2012 MapQuest, Inc."
|
|
48
|
+
},
|
|
49
|
+
"statuscode": 0,
|
|
50
|
+
"messages": []
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"results": [
|
|
3
|
+
{
|
|
4
|
+
"locations": []
|
|
5
|
+
}
|
|
6
|
+
],
|
|
7
|
+
"info": {
|
|
8
|
+
"copyright": {
|
|
9
|
+
"text": "© 2012 MapQuest, Inc.",
|
|
10
|
+
"imageUrl": "http://api.mqcdn.com/res/mqlogo.gif",
|
|
11
|
+
"imageAltText": "© 2012 MapQuest, Inc."
|
|
12
|
+
},
|
|
13
|
+
"statuscode": 0,
|
|
14
|
+
"messages": []
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
US
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
US,NY,Jamaica,40.6915,-73.8057
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
US,NY,Jamaica,,40.6915,-73.8057,501,718,"Road Runner","Road Runner"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
US,"United States",NY,"New York",Jamaica,40.6915,-73.8057,501,718,America/New_York,NA,,"Road Runner","Road Runner",rr.com,"AS11351 Road Runner HoldCo LLC",Cable/DSL,residential,779,99,37,76,35
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
US,TX,Plano,75093,33.034698,-96.813400,623,972,"Layered Technologies , US","Layered Technologies , US",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
,,,,,,,,,,INVALID_LICENSE_KEY
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
,,,,,,,,,,IP_NOT_FOUND
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
[
|
|
2
|
+
|
|
3
|
+
{
|
|
4
|
+
"place_id": "30632629",
|
|
5
|
+
"licence": "Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.",
|
|
6
|
+
"osm_type": "way",
|
|
7
|
+
"osm_id": "24801588",
|
|
8
|
+
"boundingbox": [
|
|
9
|
+
"40.749828338623",
|
|
10
|
+
"40.7511596679688",
|
|
11
|
+
"-73.9943389892578",
|
|
12
|
+
"-73.9926528930664"
|
|
13
|
+
],
|
|
14
|
+
"polygonpoints": [
|
|
15
|
+
[
|
|
16
|
+
"-73.9943346",
|
|
17
|
+
"40.7503638"
|
|
18
|
+
],
|
|
19
|
+
[
|
|
20
|
+
"-73.9942745",
|
|
21
|
+
"40.7504158"
|
|
22
|
+
],
|
|
23
|
+
[
|
|
24
|
+
"-73.9942593",
|
|
25
|
+
"40.750629"
|
|
26
|
+
],
|
|
27
|
+
[
|
|
28
|
+
"-73.9941343",
|
|
29
|
+
"40.7508432"
|
|
30
|
+
],
|
|
31
|
+
[
|
|
32
|
+
"-73.9939794",
|
|
33
|
+
"40.7509703"
|
|
34
|
+
],
|
|
35
|
+
[
|
|
36
|
+
"-73.9938042",
|
|
37
|
+
"40.7510532"
|
|
38
|
+
],
|
|
39
|
+
[
|
|
40
|
+
"-73.9938025",
|
|
41
|
+
"40.7511311"
|
|
42
|
+
],
|
|
43
|
+
[
|
|
44
|
+
"-73.9936051",
|
|
45
|
+
"40.7511571"
|
|
46
|
+
],
|
|
47
|
+
[
|
|
48
|
+
"-73.9935673",
|
|
49
|
+
"40.751105"
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
"-73.9934095",
|
|
53
|
+
"40.7511089"
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
"-73.9931235",
|
|
57
|
+
"40.7510548"
|
|
58
|
+
],
|
|
59
|
+
[
|
|
60
|
+
"-73.9928863",
|
|
61
|
+
"40.7509311"
|
|
62
|
+
],
|
|
63
|
+
[
|
|
64
|
+
"-73.9928068",
|
|
65
|
+
"40.750949"
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
"-73.992721",
|
|
69
|
+
"40.7508515"
|
|
70
|
+
],
|
|
71
|
+
[
|
|
72
|
+
"-73.9927444",
|
|
73
|
+
"40.7507889"
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
"-73.9926693",
|
|
77
|
+
"40.7506457"
|
|
78
|
+
],
|
|
79
|
+
[
|
|
80
|
+
"-73.9926597",
|
|
81
|
+
"40.7503657"
|
|
82
|
+
],
|
|
83
|
+
[
|
|
84
|
+
"-73.9928305",
|
|
85
|
+
"40.7500953"
|
|
86
|
+
],
|
|
87
|
+
[
|
|
88
|
+
"-73.9929757",
|
|
89
|
+
"40.7499911"
|
|
90
|
+
],
|
|
91
|
+
[
|
|
92
|
+
"-73.9931281",
|
|
93
|
+
"40.7499238"
|
|
94
|
+
],
|
|
95
|
+
[
|
|
96
|
+
"-73.993133",
|
|
97
|
+
"40.7498631"
|
|
98
|
+
],
|
|
99
|
+
[
|
|
100
|
+
"-73.9932961",
|
|
101
|
+
"40.7498306"
|
|
102
|
+
],
|
|
103
|
+
[
|
|
104
|
+
"-73.9933664",
|
|
105
|
+
"40.7498742"
|
|
106
|
+
],
|
|
107
|
+
[
|
|
108
|
+
"-73.993471",
|
|
109
|
+
"40.7498701"
|
|
110
|
+
],
|
|
111
|
+
[
|
|
112
|
+
"-73.9938023",
|
|
113
|
+
"40.7499263"
|
|
114
|
+
],
|
|
115
|
+
[
|
|
116
|
+
"-73.9940703",
|
|
117
|
+
"40.7500756"
|
|
118
|
+
],
|
|
119
|
+
[
|
|
120
|
+
"-73.9941876",
|
|
121
|
+
"40.7502038"
|
|
122
|
+
],
|
|
123
|
+
[
|
|
124
|
+
"-73.9942831",
|
|
125
|
+
"40.7502142"
|
|
126
|
+
],
|
|
127
|
+
[
|
|
128
|
+
"-73.9943346",
|
|
129
|
+
"40.7503638"
|
|
130
|
+
]
|
|
131
|
+
],
|
|
132
|
+
"lat": "40.7504928941818",
|
|
133
|
+
"lon": "-73.993466492276",
|
|
134
|
+
"display_name": "Madison Square Garden, West 31st Street, Long Island City, New York City, New York, 10001, United States of America",
|
|
135
|
+
"class": "leisure",
|
|
136
|
+
"type": "stadium",
|
|
137
|
+
"address": {
|
|
138
|
+
"stadium": "Madison Square Garden",
|
|
139
|
+
"road": "West 31st Street",
|
|
140
|
+
"suburb": "Long Island City",
|
|
141
|
+
"city": "New York City",
|
|
142
|
+
"county": "New York",
|
|
143
|
+
"state": "New York",
|
|
144
|
+
"postcode": "10001",
|
|
145
|
+
"country": "United States of America",
|
|
146
|
+
"country_code": "us"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[ ]
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Response": {
|
|
3
|
+
"MetaInfo": {
|
|
4
|
+
"Timestamp": "2013-02-08T16:26:39.382+0000"
|
|
5
|
+
},
|
|
6
|
+
"View": [
|
|
7
|
+
{
|
|
8
|
+
"_type": "SearchResultsViewType",
|
|
9
|
+
"ViewId": 0,
|
|
10
|
+
"Result": [
|
|
11
|
+
{
|
|
12
|
+
"Relevance": 1.0,
|
|
13
|
+
"MatchLevel": "houseNumber",
|
|
14
|
+
"MatchQuality": {
|
|
15
|
+
"State": 1.0,
|
|
16
|
+
"City": 1.0,
|
|
17
|
+
"Street": [
|
|
18
|
+
1.0
|
|
19
|
+
],
|
|
20
|
+
"HouseNumber": 1.0
|
|
21
|
+
},
|
|
22
|
+
"MatchType": "pointAddress",
|
|
23
|
+
"Location": {
|
|
24
|
+
"LocationId": "NT_ArsGdYbpo6dqjPQel9gTID_4",
|
|
25
|
+
"LocationType": "point",
|
|
26
|
+
"DisplayPosition": {
|
|
27
|
+
"Latitude": 40.7504692,
|
|
28
|
+
"Longitude": -73.9933777
|
|
29
|
+
},
|
|
30
|
+
"NavigationPosition": [
|
|
31
|
+
{
|
|
32
|
+
"Latitude": 40.7500305,
|
|
33
|
+
"Longitude": -73.9942398
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"MapView": {
|
|
37
|
+
"TopLeft": {
|
|
38
|
+
"Latitude": 40.7515934,
|
|
39
|
+
"Longitude": -73.9948616
|
|
40
|
+
},
|
|
41
|
+
"BottomRight": {
|
|
42
|
+
"Latitude": 40.7493451,
|
|
43
|
+
"Longitude": -73.9918938
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"Address": {
|
|
47
|
+
"Label": "4 Penn Plz, New York, NY 10001, United States",
|
|
48
|
+
"Country": "USA",
|
|
49
|
+
"State": "NY",
|
|
50
|
+
"County": "New York",
|
|
51
|
+
"City": "New York",
|
|
52
|
+
"Street": "Penn Plz",
|
|
53
|
+
"HouseNumber": "4",
|
|
54
|
+
"PostalCode": "10001",
|
|
55
|
+
"AdditionalData": [
|
|
56
|
+
{
|
|
57
|
+
"value": "United States",
|
|
58
|
+
"key": "CountryName"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"value": "New York",
|
|
62
|
+
"key": "StateName"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"bossresponse":{"responsecode":"6000","reason":"internal error"}}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"bossresponse": {
|
|
3
|
+
"responsecode": "200",
|
|
4
|
+
"placefinder": {
|
|
5
|
+
"start": "0",
|
|
6
|
+
"count": "1",
|
|
7
|
+
"request": "flags=JXTSR&location=Madison%20Square%20Garden%2C%20NY%2C%20NY&%unsafe%appid=%5B%22dj0yJmk9ZmZ5NXFrNGhNcEthJmQ9WVdrOVFUSlhPV2x1TjJVbWNHbzlORE0wT0RFME9UWXkmcz1jb25zdW1lcnNlY3JldCZ4PTAy%22%2C%20%22b57b1b98eb21f171231f5b441cba505261d6c9bb%22%5D&gflags=AC&locale=en_US",
|
|
8
|
+
"results": [
|
|
9
|
+
{
|
|
10
|
+
"quality": "90",
|
|
11
|
+
"latitude": "40.750381",
|
|
12
|
+
"longitude": "-73.993988",
|
|
13
|
+
"offsetlat": "40.750381",
|
|
14
|
+
"offsetlon": "-73.993988",
|
|
15
|
+
"radius": "400",
|
|
16
|
+
"boundingbox": {
|
|
17
|
+
"north": "40.750832",
|
|
18
|
+
"south": "40.749931",
|
|
19
|
+
"east": "-73.993393",
|
|
20
|
+
"west": "-73.994591"
|
|
21
|
+
},
|
|
22
|
+
"name": "Madison Square Garden",
|
|
23
|
+
"line1": "Madison Square Garden",
|
|
24
|
+
"line2": "New York, NY 10001",
|
|
25
|
+
"line3": "",
|
|
26
|
+
"line4": "United States",
|
|
27
|
+
"cross": "",
|
|
28
|
+
"house": "",
|
|
29
|
+
"street": "",
|
|
30
|
+
"xstreet": "",
|
|
31
|
+
"unittype": "",
|
|
32
|
+
"unit": "",
|
|
33
|
+
"postal": "10001",
|
|
34
|
+
"neighborhood": "Garment District|Midtown|Midtown West|Manhattan",
|
|
35
|
+
"city": "New York",
|
|
36
|
+
"county": "New York County",
|
|
37
|
+
"state": "New York",
|
|
38
|
+
"country": "United States",
|
|
39
|
+
"countrycode": "US",
|
|
40
|
+
"statecode": "NY",
|
|
41
|
+
"countycode": "",
|
|
42
|
+
"timezone": "America/New_York",
|
|
43
|
+
"areacode": "212",
|
|
44
|
+
"uzip": "10001",
|
|
45
|
+
"hash": "",
|
|
46
|
+
"woeid": "23617041",
|
|
47
|
+
"woetype": "20"
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"bossresponse": {
|
|
3
|
+
"responsecode": "200",
|
|
4
|
+
"placefinder": {
|
|
5
|
+
"start": "0",
|
|
6
|
+
"count": "0",
|
|
7
|
+
"request": "flags=JXTSR&location=asdfasdf28394782sdfj2983&%unsafe%appid=%5B%22dj0yJmk9ZmZ5NXFrNGhNcEthJmQ9WVdrOVFUSlhPV2x1TjJVbWNHbzlORE0wT0RFME9UWXkmcz1jb25zdW1lcnNlY3JldCZ4PTAy%22%2C%20%22b57b1b98eb21f171231f5b441cba505261d6c9bb%22%5D&gflags=AC&locale=en_US"
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?> <yahoo:error xmlns:yahoo="http://yahooapis.com/v1/base.rng\ <http://yahooapis.com/v1/base.rng%5C>" xml:lang="en-US">
|
|
2
|
+
<yahoo:description>Rate Limit Exceeded</yahoo:description> <yahoo:detail>Key has exceeded its configured rate limit.</yahoo:detail> </yahoo:error>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"error":{"status":401,"message":"invalid key"}}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"response": {
|
|
3
|
+
"GeoObjectCollection": {
|
|
4
|
+
"metaDataProperty": {
|
|
5
|
+
"Geocoder2ResponseMetaData": {
|
|
6
|
+
"request": "Кремль, Moscow, Russia",
|
|
7
|
+
"found": "1",
|
|
8
|
+
"results": "10"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"featureMember": [
|
|
12
|
+
{
|
|
13
|
+
"GeoObject": {
|
|
14
|
+
"metaDataProperty": {
|
|
15
|
+
"Geocoder2MetaData": {
|
|
16
|
+
"kind": "vegetation",
|
|
17
|
+
"text": "Россия, Москва, Московский Кремль",
|
|
18
|
+
"precision": "other",
|
|
19
|
+
"AddressDetails": {
|
|
20
|
+
"Country": {
|
|
21
|
+
"CountryNameCode": "RU",
|
|
22
|
+
"CountryName": "Россия",
|
|
23
|
+
"Locality": {
|
|
24
|
+
"LocalityName": "Москва",
|
|
25
|
+
"Premise": {
|
|
26
|
+
"PremiseName": "Московский Кремль"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"name": "Московский Кремль",
|
|
34
|
+
"boundedBy": {
|
|
35
|
+
"Envelope": {
|
|
36
|
+
"lowerCorner": "37.584182 55.733361",
|
|
37
|
+
"upperCorner": "37.650064 55.770517"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"Point": {
|
|
41
|
+
"pos": "37.617123 55.751943"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
{
|
|
2
|
+
"response":{
|
|
3
|
+
"GeoObjectCollection":{
|
|
4
|
+
"metaDataProperty":{
|
|
5
|
+
"Geocoder2ResponseMetaData":{
|
|
6
|
+
"request":"57.423359,55.892596",
|
|
7
|
+
"found":"3",
|
|
8
|
+
"results":"10",
|
|
9
|
+
"Point":{
|
|
10
|
+
"pos":"57.423359 55.892596"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"featureMember":[
|
|
15
|
+
{
|
|
16
|
+
"GeoObject":{
|
|
17
|
+
"metaDataProperty":{
|
|
18
|
+
"Geocoder2MetaData":{
|
|
19
|
+
"kind":"area",
|
|
20
|
+
"text":"Россия, республика Башкортостан, Караидельский район",
|
|
21
|
+
"precision":"other",
|
|
22
|
+
"AddressDetails":{
|
|
23
|
+
"Country":{
|
|
24
|
+
"AddressLine":"республика Башкортостан, Караидельский район",
|
|
25
|
+
"CountryNameCode":"RU",
|
|
26
|
+
"CountryName":"Россия",
|
|
27
|
+
"AdministrativeArea":{
|
|
28
|
+
"AdministrativeAreaName":"республика Башкортостан",
|
|
29
|
+
"SubAdministrativeArea":{
|
|
30
|
+
"SubAdministrativeAreaName":"Караидельский район"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"description":"республика Башкортостан, Россия",
|
|
38
|
+
"name":"Караидельский район",
|
|
39
|
+
"boundedBy":{
|
|
40
|
+
"Envelope":{
|
|
41
|
+
"lowerCorner":"56.231384 55.462814",
|
|
42
|
+
"upperCorner":"57.705348 56.076117"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"Point":{
|
|
46
|
+
"pos":"57.423359 55.892596"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"GeoObject":{
|
|
52
|
+
"metaDataProperty":{
|
|
53
|
+
"Geocoder2MetaData":{
|
|
54
|
+
"kind":"province",
|
|
55
|
+
"text":"Россия, республика Башкортостан",
|
|
56
|
+
"precision":"other",
|
|
57
|
+
"AddressDetails":{
|
|
58
|
+
"Country":{
|
|
59
|
+
"AddressLine":"республика Башкортостан",
|
|
60
|
+
"CountryNameCode":"RU",
|
|
61
|
+
"CountryName":"Россия",
|
|
62
|
+
"AdministrativeArea":{
|
|
63
|
+
"AdministrativeAreaName":"республика Башкортостан"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"description":"Россия",
|
|
70
|
+
"name":"республика Башкортостан",
|
|
71
|
+
"boundedBy":{
|
|
72
|
+
"Envelope":{
|
|
73
|
+
"lowerCorner":"53.157475 51.571991",
|
|
74
|
+
"upperCorner":"60.001577 56.533651"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"Point":{
|
|
78
|
+
"pos":"56.579526 54.127354"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"GeoObject":{
|
|
84
|
+
"metaDataProperty":{
|
|
85
|
+
"Geocoder2MetaData":{
|
|
86
|
+
"kind":"country",
|
|
87
|
+
"text":"Россия",
|
|
88
|
+
"precision":"other",
|
|
89
|
+
"AddressDetails":{
|
|
90
|
+
"Country":{
|
|
91
|
+
"CountryNameCode":"RU",
|
|
92
|
+
"CountryName":"Россия"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"name":"Россия",
|
|
98
|
+
"boundedBy":{
|
|
99
|
+
"Envelope":{
|
|
100
|
+
"lowerCorner":"19.641673 36.84312",
|
|
101
|
+
"upperCorner":"179.999997 81.848739"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"Point":{
|
|
105
|
+
"pos":"37.617761 55.755773"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require 'test_helper'
|
|
3
|
+
|
|
4
|
+
class Geocoder2Test < Test::Unit::TestCase
|
|
5
|
+
|
|
6
|
+
def test_distance_to_returns_float
|
|
7
|
+
v = Venue.new(*venue_params(:msg))
|
|
8
|
+
v.latitude, v.longitude = [40.750354, -73.993371]
|
|
9
|
+
assert (d = v.distance_to([30, -94])).is_a?(Float)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_coordinates_method_returns_array
|
|
13
|
+
assert Geocoder2.coordinates("Madison Square Garden, New York, NY").is_a?(Array)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_address_method_returns_string
|
|
17
|
+
assert Geocoder2.address([40.750354, -73.993371]).is_a?(String)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_geographic_center_doesnt_overwrite_argument_value
|
|
21
|
+
# test for the presence of a bug that was introduced in version 0.9.11
|
|
22
|
+
orig_points = [[52,8], [46,9], [42,5]]
|
|
23
|
+
points = orig_points.clone
|
|
24
|
+
Geocoder2::Calculations.geographic_center(points)
|
|
25
|
+
assert_equal orig_points, points
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_geocode_assigns_and_returns_coordinates
|
|
29
|
+
v = Venue.new(*venue_params(:msg))
|
|
30
|
+
coords = [40.750354, -73.993371]
|
|
31
|
+
assert_equal coords, v.geocode
|
|
32
|
+
assert_equal coords, [v.latitude, v.longitude]
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_geocode_block_executed_when_no_results
|
|
36
|
+
v = Event.new("Nowhere", "no results")
|
|
37
|
+
v.geocode
|
|
38
|
+
assert_equal "NOT FOUND", v.coords_string
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_reverse_geocode_assigns_and_returns_address
|
|
42
|
+
v = Landmark.new(*landmark_params(:msg))
|
|
43
|
+
address = "4 Penn Plaza, New York, NY 10001, USA"
|
|
44
|
+
assert_equal address, v.reverse_geocode
|
|
45
|
+
assert_equal address, v.address
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_forward_and_reverse_geocoding_on_same_model_works
|
|
49
|
+
g = GasStation.new("Exxon")
|
|
50
|
+
g.address = "404 New St, Middletown, CT"
|
|
51
|
+
g.geocode
|
|
52
|
+
assert_not_nil g.lat
|
|
53
|
+
assert_not_nil g.lon
|
|
54
|
+
|
|
55
|
+
assert_nil g.location
|
|
56
|
+
g.reverse_geocode
|
|
57
|
+
assert_not_nil g.location
|
|
58
|
+
end
|
|
59
|
+
end
|
data/test/https_test.rb
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require 'test_helper'
|
|
3
|
+
|
|
4
|
+
class HttpsTest < Test::Unit::TestCase
|
|
5
|
+
|
|
6
|
+
def test_uses_https_for_secure_query
|
|
7
|
+
Geocoder2.configure(:use_https => true)
|
|
8
|
+
g = Geocoder2::Lookup::Google.new
|
|
9
|
+
assert_match /^https:/, g.query_url(Geocoder2::Query.new("test"))
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_uses_http_by_default
|
|
13
|
+
g = Geocoder2::Lookup::Google.new
|
|
14
|
+
assert_match /^http:/, g.query_url(Geocoder2::Query.new("test"))
|
|
15
|
+
end
|
|
16
|
+
end
|