feat(server): reverse geocoding endpoint (#11430)

* feat(server): reverse geocoding endpoint

* chore: rename error message
This commit is contained in:
Jason Rasmussen
2024-07-29 18:17:26 -04:00
committed by GitHub
parent a70cd368af
commit ebc71e428d
12 changed files with 443 additions and 42 deletions

View File

@@ -3109,6 +3109,60 @@
]
}
},
"/map/reverse-geocode": {
"get": {
"operationId": "reverseGeocode",
"parameters": [
{
"name": "lat",
"required": true,
"in": "query",
"schema": {
"format": "double",
"type": "number"
}
},
{
"name": "lon",
"required": true,
"in": "query",
"schema": {
"format": "double",
"type": "number"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/MapReverseGeocodeResponseDto"
},
"type": "array"
}
}
},
"description": ""
}
},
"security": [
{
"bearer": []
},
{
"cookie": []
},
{
"api_key": []
}
],
"tags": [
"Map"
]
}
},
"/map/style.json": {
"get": {
"operationId": "getMapStyle",
@@ -9128,6 +9182,28 @@
],
"type": "object"
},
"MapReverseGeocodeResponseDto": {
"properties": {
"city": {
"nullable": true,
"type": "string"
},
"country": {
"nullable": true,
"type": "string"
},
"state": {
"nullable": true,
"type": "string"
}
},
"required": [
"city",
"country",
"state"
],
"type": "object"
},
"MapTheme": {
"enum": [
"light",

View File

@@ -554,6 +554,11 @@ export type MapMarkerResponseDto = {
lon: number;
state: string | null;
};
export type MapReverseGeocodeResponseDto = {
city: string | null;
country: string | null;
state: string | null;
};
export type OnThisDayDto = {
year: number;
};
@@ -1991,6 +1996,20 @@ export function getMapMarkers({ fileCreatedAfter, fileCreatedBefore, isArchived,
...opts
}));
}
export function reverseGeocode({ lat, lon }: {
lat: number;
lon: number;
}, opts?: Oazapfts.RequestOpts) {
return oazapfts.ok(oazapfts.fetchJson<{
status: 200;
data: MapReverseGeocodeResponseDto[];
}>(`/map/reverse-geocode${QS.query(QS.explode({
lat,
lon
}))}`, {
...opts
}));
}
export function getMapStyle({ key, theme }: {
key?: string;
theme: MapTheme;