Closed missinglink closed 3 years ago
Response: This is exactly what we needed, great!
errors: I adjusted the error we return a bit to make the format simpler, but we could also return it as is from the API and add the rate limiting Info.
I think having a simpler error format might make sense for this library though. We don’t need to return a results section etc, we can extract the error info and return it in a bit of a more compact Form.
After my initial excitement I looked a the types more closely trying to implement them, but unfortunately the main section of a feature, its You already mentioned that in your comment, I’m sorry.properties
, are not typed at all and are just a map of string: any
, which we can just as well leave out in that case.
I’ll see that I use the other types as a base to define our result type. https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/geojson/index.d.ts#L145
This is what I have so far for an individual Feature
.
Are there other values for accuracy
possible? I tried a bunch of different API requests and could only get the two.
I’m not sure about addendum
, I think we could leave that as any
for now as I think there can be a lot of different properties coming from openstreetmap.
type Layers = 'address' |
'borough' |
'coarse' |
'country' |
'county' |
'localadmin' |
'locality' |
'macrocounty' |
'macroregion' |
'neighbourhood' |
'postalcode' |
'region' |
'street' |
'venue'
type Sources = 'openstreetmap' | 'openaddresses' | 'geonames' | 'whosonfirst'
type Feature = {
type: 'Feature'
geometry: {
type: 'Point'
coordinates: [number, number]
}
properties: {
id: string
gid: string
layer: Layers
source: Sources
source_id: string
label: string
name: string
accuracy: 'centroid' | 'point'
neighbourhood?: string
neighbourhood_gid?: string
borough?: string
borough_gid?: string
county?: string
county_a?: string
county_gid?: string
locality_gid?: string
locality?: string
localadmin?: string
localadmin_gid?: string
region?: string
region_a?: string
region_gid?: string
macroregion?: string
macroregion_gid?: string
country?: string
country_a?: string
country_gid?: string
continent?: string
continent_gid?: string
street?: string
housenumber?: string
postalcode?: string
addendum?: any
}
bbox?: [number, number, number, number] | [number, number, number, number, number, number]
}
Hmmm this is actually quite tricky, @orangejulius there's a lot of things to consider:
intersection
added, the work for this is already complete but it's not liveLineString
and Polygon
, this is not required for launch but it's worth considering what will happen if/when that happens.bbox
stuff from the spec, I'm not familiar with the 6 element version, that must be for 3D.point
and centroid
from looking at the codeid
and source_id
have come to mean the same thing, they will always have the same value 🤷 intersection
layer, do we return both street names?The response format documentation should be helpful here. There's definitely a lot of nuance in the details and some of the lesser-known fields like accuracy
and match_type
.
This is all super helpful, I’ll open a PR with an updated format soon so we can review it directly in there.
@mxlje would it be helpful for me to better define the JSON response format schema(s)?
Geocoding results
I found someone else has already defined the envelope format for GeoJSON: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/geojson/index.d.ts
Within that we can then define our application-specific fields:
geocoding
property with a bunch of sub-properties such asgeocoding.warnings
features[].properties.*
properties which are all application-specificErrors
The errors JSON format is actually different, it looks like this:
Is this something we want to tackle now or is it fine to leave it fairly generic?