diff --git a/app/geoapify.ts b/app/geoapify.ts index 4a72a20a112c3fc86507f331be8232ab6c214fac..0737a9c9c3775485c106dfeeab818a7b8cc828f2 100644 --- a/app/geoapify.ts +++ b/app/geoapify.ts @@ -25,6 +25,7 @@ const buildPlacesAutocompleteUrl = ( url.searchParams.append("limit", limit.toString()); url.searchParams.append("format", GeoapifyFilters.FORMAT); url.searchParams.append("lang", language); + url.searchParams.append("bias", GeoapifyFilters.BIAS); url.searchParams.append("apiKey", geoapifyApiKey); if (level) { @@ -41,6 +42,8 @@ export const transformAutocompleteResults = ( id: place.place_id, name: place.formatted, city: place.city, + state: place.state, + country: place.country, coordinates: { latitude: place.lat, longitude: place.lon, diff --git a/app/geoapify_api_types.ts b/app/geoapify_api_types.ts index 96018c5f1a316b02e4191ef5fed04fd841b14da1..27a71c14c6de82260e0d59286d05595d535f18e3 100644 --- a/app/geoapify_api_types.ts +++ b/app/geoapify_api_types.ts @@ -2,6 +2,8 @@ export type GeoapifyPlace = { place_id: string; formatted: string; city?: string; + state?: string; + country: string; lon: number; lat: number; }; @@ -30,4 +32,5 @@ export type GeoapifyPlaceDetailsResult = { export enum GeoapifyFilters { LIMIT = 3, FORMAT = "json", + BIAS = "countrycode:de", } diff --git a/app/geoapify_test.ts b/app/geoapify_test.ts index 3abbf1ec4eb2260891ea50755ee9ce70309dee88..b063f540d2bc770e34040e0050dac96cd5d0f9a1 100644 --- a/app/geoapify_test.ts +++ b/app/geoapify_test.ts @@ -37,6 +37,8 @@ const placeFragment = ` id name city + state + country coordinates { latitude longitude @@ -100,7 +102,7 @@ describe("places", () => { ); const expectedUrl = new URL( - `https://api.geoapify.com/v1/geocode/autocomplete?text=Munich&limit=3&format=json&lang=en&apiKey=${placesApiKey}`, + `https://api.geoapify.com/v1/geocode/autocomplete?text=Munich&limit=3&format=json&lang=en&bias=countrycode%3Ade&apiKey=${placesApiKey}`, ); assertSpyCall(fetchStub, 0, { args: [expectedUrl] }); }); diff --git a/app/geoapify_test_data.ts b/app/geoapify_test_data.ts index 490f44f9a445d92bbf80a7675bc6b59065ae9cff..04ed3dafebe2e429443763607edc48a20ac60445 100644 --- a/app/geoapify_test_data.ts +++ b/app/geoapify_test_data.ts @@ -94,6 +94,8 @@ export const expectedPlacesAutocompleteGqlResponse = [ id: "51ac66e77e9826274059f9426dc08c114840f00101f901dcf3000000000000c00208", name: "Munich, Bavaria, Germany", city: "Munich", + state: "Bavaria", + country: "Germany", coordinates: { latitude: 48.1371079, longitude: 11.5753822, @@ -103,6 +105,8 @@ export const expectedPlacesAutocompleteGqlResponse = [ id: "51b1a888d349b558c059b0aa5e7ea7554840f00101f90194c5020000000000c00208", name: "Munich, ND, United States of America", city: "Munich", + state: "North Dakota", + country: "United States", coordinates: { latitude: 48.669174, longitude: -98.832631, diff --git a/app/server.ts b/app/server.ts index db5202ffbb98698a6aa573ade0844c3136103f09..58d61ac04609b374f6619ae7549b4b03e307a960 100644 --- a/app/server.ts +++ b/app/server.ts @@ -23,6 +23,8 @@ const typeDefs = ` id: String! name: String! city: String + state: String + country: String! coordinates: Coordinates! } diff --git a/app/types.ts b/app/types.ts index fc98b8fc81ddd5fcbdd0e2598f0382fec30b0b46..ffe293042829f18a785f5e2e7ef43e00f00d53d7 100644 --- a/app/types.ts +++ b/app/types.ts @@ -9,6 +9,8 @@ export interface Place { id: string; name: string; city?: string; //This is a temporary field which will be used by the frontend when filtering for spaces + state?: string; + country: string; coordinates: Coordinates; }