Skip to content

Commit b800a57

Browse files
Schuyler Erleieure
Schuyler Erle
authored andcommitted
Finish tweaking the GeoJSON output and update the docs.
1 parent 8859b41 commit b800a57

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

REST.rdoc

+25-23
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,35 @@ Parameters:
1515

1616
q = a string containing a US street address.
1717

18-
Returns:
18+
Returns a GeoJSON feature collection:
1919

2020
{
21-
'address': '41 Decatur St 94103',
22-
'results': [
23-
{ 'number': '41',
24-
'street': 'Decatur St',
25-
'city': 'San Francisco',
26-
'state': 'CA',
27-
'zip': '94103',
28-
'fips_county': '06075',
29-
'lat': 37.772502,
30-
'lon': -122.406032,
31-
'precision': 'range',
32-
'score': 0.812 }
33-
]
21+
"type": "FeatureCollection",
22+
"features": [
23+
{
24+
"type": "Feature",
25+
"properties": {
26+
"number": "41",
27+
"street": "Decatur St",
28+
"city": "San Francisco",
29+
"state": "CA",
30+
"zip": "94103",
31+
"fips_county": "06075",
32+
"score": 1.0,
33+
"precision":"range"
34+
},
35+
"geometry": {
36+
"type": "Point",
37+
"coordinates": [-122.406032, 37.772502]
38+
}
39+
}
40+
],
41+
"address":"41 Decatur St, San Francisco CA 94103"
3442
}
3543

36-
The 'results' list in the returned JSON object contains zero or more addresses
37-
that most closely match the provided string, along with their interpolated
38-
coordinates. Each address result in the list contains the following key/value
39-
pairs:
44+
45+
Each address match in the feature collection contains some combination of the
46+
following properties:
4047

4148
number
4249
The building number of the address. When a building number is not
@@ -86,8 +93,3 @@ pairs:
8693
result, expressed as a float between 0 and 1. A higher score indicates
8794
a closer match. Results with a score below 0.5 should be regarded with
8895
care.
89-
90-
lat / lon
91-
The approximate latitude and longitude of the geocoded address or
92-
intersection, given as floating point numbers.
93-

lib/geocoder/us/rest.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
:properties => result,
1616
:geometry => {
1717
:type => "Point",
18-
:coordinates => [result[:lon], result[:lat]]
18+
:coordinates => coords
1919
}
2020
}
2121
end
2222
{
23-
:type => "FeatureCollection"
23+
:type => "FeatureCollection",
24+
:address => params[:q],
2425
:features => features
2526
}.to_json
2627
else

0 commit comments

Comments
 (0)