Skip to content

Commit

Permalink
Merge pull request #660 from ibi-group/otp-geocoder-update
Browse files Browse the repository at this point in the history
Update Geocoder to match latest OTP API
  • Loading branch information
miles-grant-ibigroup authored Nov 13, 2023
2 parents 940b2d1 + 4b4c9d2 commit 824a68f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/geocoder/src/apis/otp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ type OTPGeocoderResponse = {
results: {
coordinate: {
lat: number,
lng: number,
lon: number,
},
code: string,
name: string,
id: string
id: string,
modes: string[]
}[]
} | undefined

Expand Down
4 changes: 2 additions & 2 deletions packages/geocoder/src/geocoders/otp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export default class OTPGeocoder extends Geocoder {
rewriteAutocompleteResponse(response: OTPGeocoderResponse): MultiGeocoderResponse {
return {
features: response?.results?.map(stop => ({
geometry: { type: "Point", coordinates: [stop.coordinate.lng, stop.coordinate.lat] },
geometry: { type: "Point", coordinates: [stop.coordinate.lon, stop.coordinate.lat] },
id: stop.id,
// TODO: if non-stops are supported, these need to be detected here and
// this layer property updated accordingly
properties: { layer: "stops", source: "otp", name: stop.name, label: stop.code },
properties: { layer: "stops", source: "otp", modes: stop.modes, name: stop.name, label: `${stop.name} (${stop.code})` },
type: "Feature"
})),
type: "FeatureCollection"
Expand Down

0 comments on commit 824a68f

Please sign in to comment.