Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions src/providers/openCageProvider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import AbstractProvider, {
BoundsTuple,
EndpointArgument,
LatLng,
ParseArgument,
Expand Down Expand Up @@ -94,16 +95,22 @@ export default class OpenCageProvider extends AbstractProvider<
}

parse(response: ParseArgument<RequestResult>): SearchResult<RawResult>[] {
return response.data.results.map((r) => ({
x: r.geometry.lng,
y: r.geometry.lat,
label: r.formatted,
bounds: [
[r.bounds.southwest.lat, r.bounds.southwest.lng], // s, w
[r.bounds.northeast.lat, r.bounds.northeast.lng], // n, e
],
raw: r,
}));
return response.data.results.map((r) => {
let bounds = null;
if (r.bounds) {
bounds = [
[r.bounds.southwest.lat, r.bounds.southwest.lng], // s, w
[r.bounds.northeast.lat, r.bounds.northeast.lng], // n, e
] as BoundsTuple;
}
return {
x: r.geometry.lng,
y: r.geometry.lat,
label: r.formatted,
bounds,
raw: r,
};
});
}

async search(options: SearchArgument): Promise<SearchResult<RawResult>[]> {
Expand Down
Loading