Permalink
Browse files

Finish tweaking the GeoJSON output and update the docs.

  • Loading branch information...
1 parent 8859b41 commit b800a57d28214bbf157e34c355179d88db521d7c Schuyler Erle committed with ieure Aug 20, 2010
Showing with 28 additions and 25 deletions.
  1. +25 −23 REST.rdoc
  2. +3 −2 lib/geocoder/us/rest.rb
View
@@ -15,28 +15,35 @@ Parameters:
q = a string containing a US street address.
-Returns:
+Returns a GeoJSON feature collection:
{
- 'address': '41 Decatur St 94103',
- 'results': [
- { 'number': '41',
- 'street': 'Decatur St',
- 'city': 'San Francisco',
- 'state': 'CA',
- 'zip': '94103',
- 'fips_county': '06075',
- 'lat': 37.772502,
- 'lon': -122.406032,
- 'precision': 'range',
- 'score': 0.812 }
- ]
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "properties": {
+ "number": "41",
+ "street": "Decatur St",
+ "city": "San Francisco",
+ "state": "CA",
+ "zip": "94103",
+ "fips_county": "06075",
+ "score": 1.0,
+ "precision":"range"
+ },
+ "geometry": {
+ "type": "Point",
+ "coordinates": [-122.406032, 37.772502]
+ }
+ }
+ ],
+ "address":"41 Decatur St, San Francisco CA 94103"
}
-The 'results' list in the returned JSON object contains zero or more addresses
-that most closely match the provided string, along with their interpolated
-coordinates. Each address result in the list contains the following key/value
-pairs:
+
+Each address match in the feature collection contains some combination of the
+following properties:
number
The building number of the address. When a building number is not
@@ -86,8 +93,3 @@ pairs:
result, expressed as a float between 0 and 1. A higher score indicates
a closer match. Results with a score below 0.5 should be regarded with
care.
-
- lat / lon
- The approximate latitude and longitude of the geocoded address or
- intersection, given as floating point numbers.
-
View
@@ -15,12 +15,13 @@
:properties => result,
:geometry => {
:type => "Point",
- :coordinates => [result[:lon], result[:lat]]
+ :coordinates => coords
}
}
end
{
- :type => "FeatureCollection"
+ :type => "FeatureCollection",
+ :address => params[:q],
:features => features
}.to_json
else

0 comments on commit b800a57

Please sign in to comment.