Skip to content

Commit 8143fce

Browse files
authored
Merge pull request #1700 from czycha/czycha/update-geoapify
Update Result::Geoapify to handle state_code
2 parents 0347fd7 + 176ff06 commit 8143fce

File tree

4 files changed

+204
-142
lines changed

4 files changed

+204
-142
lines changed

lib/geocoder/results/geoapify.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ def state
5050
properties['state']
5151
end
5252

53-
# Not currently available in the API
5453
def state_code
55-
''
54+
return '' unless properties['state_code']
55+
56+
properties['state_code'].upcase
5657
end
5758

5859
def country
Lines changed: 74 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,85 @@
11
{
2-
"type":"FeatureCollection",
3-
"features":[
2+
"type": "FeatureCollection",
3+
"features": [
44
{
5-
"type":"Feature",
6-
"geometry":{
7-
"type":"Point",
8-
"coordinates":[
9-
-73.993368,
10-
40.750487
11-
]
12-
},
13-
"properties":{
14-
"housenumber":"4",
15-
"street":"Pennsylvania Plaza",
16-
"country":"United States",
17-
"county":"New York County",
18-
"datasource":{
19-
"sourcename":"openstreetmap",
20-
"wheelchair":"limited",
21-
"wikidata":"Q186125",
22-
"wikipedia":"en:Madison Square Garden",
23-
"website":"http://www.thegarden.com/",
24-
"phone":"12124656741",
25-
"osm_type":"W",
26-
"osm_id":138141251,
27-
"continent":"North America"
5+
"type": "Feature",
6+
"properties": {
7+
"datasource": {
8+
"sourcename": "openstreetmap",
9+
"attribution": "© OpenStreetMap contributors",
10+
"license": "Open Database License",
11+
"url": "https://www.openstreetmap.org/copyright"
12+
},
13+
"name": "Madison Square Garden",
14+
"other_names": {
15+
"name:ja": "マディソン・スクエア・ガーデン",
16+
"name:ru": "Медисон-сквер-гарден",
17+
"name:uk": "Медісон-сквер-гарден",
18+
"name:zh": "麦迪逊广场花园",
19+
"alt_name": "The Garden",
20+
"short_name": "MSG"
21+
},
22+
"country": "United States",
23+
"country_code": "us",
24+
"state": "New York",
25+
"county": "New York County",
26+
"city": "New York",
27+
"postcode": "10001",
28+
"district": "Manhattan",
29+
"neighbourhood": "Garment District",
30+
"street": "Pennsylvania Plaza",
31+
"housenumber": "4",
32+
"iso3166_2": "US-NY",
33+
"lon": -73.99351594545152,
34+
"lat": 40.750512900000004,
35+
"state_code": "NY",
36+
"result_type": "amenity",
37+
"formatted": "Madison Square Garden, 4 Pennsylvania Plaza, New York, NY 10001, United States of America",
38+
"address_line1": "Madison Square Garden",
39+
"address_line2": "4 Pennsylvania Plaza, New York, NY 10001, United States of America",
40+
"category": "tourism.attraction",
41+
"timezone": {
42+
"name": "America/New_York",
43+
"offset_STD": "-05:00",
44+
"offset_STD_seconds": -18000,
45+
"offset_DST": "-04:00",
46+
"offset_DST_seconds": -14400,
47+
"abbreviation_STD": "EST",
48+
"abbreviation_DST": "EDT"
2849
},
29-
"country_code":"us",
30-
"postcode":"10001",
31-
"state":"New York",
32-
"city":"New York",
33-
"district":"Manhattan",
34-
"suburb":"Chelsea",
35-
"lon":-73.993368,
36-
"lat":40.750487,
37-
"formatted":"4 Pennsylvania Plaza, New York, NY 10001, United States of America",
38-
"address_line1":"4 Pennsylvania Plaza",
39-
"address_line2":"New York, NY 10001, United States of America",
40-
"result_type":"building",
41-
"rank":{
42-
"popularity":8.615793062435909,
43-
"confidence":1,
44-
"match_type":"full_match"
45-
}
50+
"plus_code": "87G8Q224+6H",
51+
"plus_code_short": "Q224+6H New York, New York County, United States",
52+
"rank": {
53+
"importance": 0.6456870542995358,
54+
"popularity": 8.615793062435909,
55+
"confidence": 1,
56+
"confidence_city_level": 1,
57+
"match_type": "full_match"
58+
},
59+
"place_id": "513471e7c3957f52c059f25c84ce10604440f00102f90143de3b0800000000c002019203154d616469736f6e205371756172652047617264656e"
60+
},
61+
"geometry": {
62+
"type": "Point",
63+
"coordinates": [
64+
-73.99351594545152,
65+
40.750512900000004
66+
]
4667
},
47-
"bbox":[
48-
-73.9944446,
49-
40.7498531,
68+
"bbox": [
69+
-73.9944193,
70+
40.7498726,
5071
-73.9925924,
51-
40.751161
72+
40.7511643
5273
]
5374
}
5475
],
55-
"query":{
56-
"text":"Madison Square Garden, New York, NY",
57-
"parsed":{
58-
"house":"madison square garden",
59-
"city":"new york",
60-
"state":"ny",
61-
"expected_type":"amenity"
76+
"query": {
77+
"text": "Madison Square Garden, New York, NY",
78+
"parsed": {
79+
"house": "madison square garden",
80+
"city": "new york",
81+
"state": "ny",
82+
"expected_type": "amenity"
6283
}
6384
}
6485
}

test/fixtures/geoapify_reverse

Lines changed: 62 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,69 @@
11
{
2-
"type":"FeatureCollection",
3-
"features":[
2+
"type": "FeatureCollection",
3+
"features": [
44
{
5-
"type":"Feature",
6-
"geometry":{
7-
"type":"Point",
8-
"coordinates":[
9-
-73.993368,
10-
40.750487
11-
]
12-
},
13-
"properties":{
14-
"name":"Madison Square Garden",
15-
"housenumber":"4",
16-
"street":"Pennsylvania Plaza",
17-
"distance":14.791104652930729,
18-
"country":"United States",
19-
"county":"New York County",
20-
"datasource":{
21-
"sourcename":"openstreetmap",
22-
"wheelchair":"limited",
23-
"wikidata":"Q186125",
24-
"wikipedia":"en:Madison Square Garden",
25-
"website":"http://www.thegarden.com/",
26-
"phone":"12124656741",
27-
"osm_type":"W",
28-
"osm_id":138141251,
29-
"continent":"North America"
5+
"type": "Feature",
6+
"properties": {
7+
"datasource": {
8+
"sourcename": "openstreetmap",
9+
"attribution": "© OpenStreetMap contributors",
10+
"license": "Open Database License",
11+
"url": "https://www.openstreetmap.org/copyright"
12+
},
13+
"country": "United States",
14+
"country_code": "us",
15+
"state": "New York",
16+
"county": "New York County",
17+
"city": "New York",
18+
"postcode": "10001",
19+
"district": "Manhattan",
20+
"neighbourhood": "Garment District",
21+
"street": "Pennsylvania Plaza",
22+
"housenumber": "4",
23+
"iso3166_2": "US-NY",
24+
"lon": -73.9935443,
25+
"lat": 40.7505085,
26+
"state_code": "NY",
27+
"distance": 2.438092698242724,
28+
"result_type": "building",
29+
"formatted": "4 Pennsylvania Plaza, New York, NY 10001, United States of America",
30+
"address_line1": "4 Pennsylvania Plaza",
31+
"address_line2": "New York, NY 10001, United States of America",
32+
"timezone": {
33+
"name": "America/New_York",
34+
"offset_STD": "-05:00",
35+
"offset_STD_seconds": -18000,
36+
"offset_DST": "-04:00",
37+
"offset_DST_seconds": -14400,
38+
"abbreviation_STD": "EST",
39+
"abbreviation_DST": "EDT"
3040
},
31-
"country_code":"us",
32-
"postcode":"10001",
33-
"state":"New York",
34-
"city":"New York",
35-
"district":"Manhattan",
36-
"suburb":"Chelsea",
37-
"lon":-73.993368,
38-
"lat":40.750487,
39-
"result_type":"amenity",
40-
"formatted":"Madison Square Garden, 4 Pennsylvania Plaza, New York, NY 10001, United States of America",
41-
"address_line1":"Madison Square Garden",
42-
"address_line2":"4 Pennsylvania Plaza, New York, NY 10001, United States of America",
43-
"rank":{
44-
"popularity":8.615793062435909
45-
}
41+
"plus_code": "87G8Q224+6H",
42+
"plus_code_short": "Q224+6H New York, New York County, United States",
43+
"rank": {
44+
"importance": 0.00000999999999995449,
45+
"popularity": 8.615793062435909
46+
},
47+
"place_id": "5124e8d43a967f52c0595d6f9ba910604440f00103f9015e9864c302000000c00203"
48+
},
49+
"geometry": {
50+
"type": "Point",
51+
"coordinates": [
52+
-73.9935443,
53+
40.7505085
54+
]
4655
},
47-
"bbox":[
48-
-73.9944446,
49-
40.7498531,
50-
-73.9925924,
51-
40.751161
56+
"bbox": [
57+
-73.9935943,
58+
40.7504585,
59+
-73.9934943,
60+
40.7505585
5261
]
5362
}
54-
]
63+
],
64+
"query": {
65+
"lat": 40.750512900000004,
66+
"lon": -73.99351594545152,
67+
"plus_code": "87G8Q224+6H"
68+
}
5569
}

0 commit comments

Comments
 (0)