diff --git a/packages/lib/getFeatures/CHANGELOG.md b/packages/lib/getFeatures/CHANGELOG.md index 594fe1e43..cb1865939 100644 --- a/packages/lib/getFeatures/CHANGELOG.md +++ b/packages/lib/getFeatures/CHANGELOG.md @@ -3,6 +3,7 @@ ## unpublished - Breaking: Upgrade peerDependency of `ol` from `^7.1.0` to `^9.2.4`. +- Breaking: `getGazetteerFeatures` has been removed. All uses within POLAR have been deprecated and replaced. If you still need this function, please refer to the masterportalApi implementation that features it as root export `search`. - Breaking: `getWfsFeatures` now throws errors if required parameters on the wfs configuration are missing instead of only printing error messages on the console. - Feature: `getWfsFeatures` now offers the possibility to set custom attributes for the `PropertyIsLike` operator. - Fix: Properly extend interface `WfsParameters` from `QueryParameters` to reflect actual usage. diff --git a/packages/lib/getFeatures/gazetteer/index.ts b/packages/lib/getFeatures/gazetteer/index.ts deleted file mode 100644 index edd687644..000000000 --- a/packages/lib/getFeatures/gazetteer/index.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { FeatureCollection } from 'geojson' -import { MemberSuffix } from '@polar/lib-custom-types' -import { AdditionalSearchOptions, SearchParameters, WFSVersion } from '../types' -import { errorCheck } from '../utils/errorCheck' -import { parseGazetteerResponse } from './parse' - -/** - * Sends a GetFeature request to a WFS-service and parses the response. - * - * @param signal - {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal} - * @param url - Base url. - * @param input - {@link SearchParameters} - * @param version - {@link WFSVersion} - * @param memberSuffix - {@link MemberSuffix} - * @param namespaces - The namespaces of the features of the WFS-G service. - * @param epsg - The projection code of the map. - * @param options - {@link AdditionalSearchOptions} - */ -export function getGazetteerFeatures( - signal: AbortSignal, - url: string, - input: SearchParameters, - version: WFSVersion, - memberSuffix: MemberSuffix, - namespaces: string[], - epsg: `EPSG:${string}`, - options: AdditionalSearchOptions = {} -): Promise { - let requestUrl = Object.entries(input).reduce( - (acc, curr) => `${acc}&${curr[0]}=${curr[1]}`, - `${url}?service=WFS&request=GetFeature&version=${version}` - ) - requestUrl += !options.maxFeatures - ? '' - : `&${version === '2.0.0' ? 'count' : 'maxFeatures'}=${options.maxFeatures}` - requestUrl += options.storedQueryId - ? `&StoredQuery_ID=${options.storedQueryId}` - : '' - - return fetch(encodeURI(requestUrl), { signal }).then((response: Response) => { - errorCheck(response) - return parseGazetteerResponse( - response, - memberSuffix, - namespaces, - epsg, - options?.title - ) - }) -} diff --git a/packages/lib/getFeatures/gazetteer/parse.ts b/packages/lib/getFeatures/gazetteer/parse.ts deleted file mode 100644 index 05011e428..000000000 --- a/packages/lib/getFeatures/gazetteer/parse.ts +++ /dev/null @@ -1,124 +0,0 @@ -import { transform as transformCoordinates } from 'ol/proj' -import { MemberSuffix } from '@polar/lib-custom-types' -import { FeatureCollection, GeoJsonProperties, Point } from 'geojson' -import { PolarGeoJsonFeature } from '../types' - -/** - * Parses the response from a GetRequest to a WFS-G. - * - * @param response - Response from the fetch request. - * @param memberSuffix - {@link MemberSuffix} - * @param namespaces - The namespaces of the features of the WFS service. - * @param epsg - The projection code of the map. - * @param title - {@link AdditionalSearchOptions.title} - */ -export function parseGazetteerResponse( - response: Response, - memberSuffix: MemberSuffix, - namespaces: string[], - epsg: `EPSG:${string}`, - title?: string | string[] -): Promise { - return response.text().then((text) => { - const features: PolarGeoJsonFeature[] = [] - const gmlFeatures = new DOMParser() - .parseFromString(text, 'application/xml') - .getElementsByTagName(`wfs:${memberSuffix}`) - const featureCollection: FeatureCollection = { - type: 'FeatureCollection', - features, - } - let geometry: Point - - if (gmlFeatures.length === 0) { - return featureCollection - } - - const gmlFeatureArray = Array.from(gmlFeatures) - const featureEPSG = - gmlFeatureArray[0].getElementsByTagName('iso19112:position').length > 0 - ? `EPSG:${ - // @ts-expect-error | The TS compiler says 'TS2531: Object is possibly 'null'.' which is valid, but not the case with this document - gmlFeatureArray[0] - .getElementsByTagName('iso19112:position')[0] - .getElementsByTagName('gml:Point')[0] - .attributes[1].textContent.split('::')[1] - }` - : epsg - - gmlFeatureArray.forEach((feature) => { - const properties: GeoJsonProperties = Object.values( - // @ts-expect-error | The TS compiler says 'TS2556: A spread argument must either have a tuple type or be passed to a rest parameter.' which might be true, but this works as intended - ...namespaces.map((namespace) => - feature.getElementsByTagNameNS(namespace, '*') - ) - ).reduce( - (acc, curr) => ({ ...acc, [curr.localName]: curr.textContent }), - {} - ) - if (feature.getElementsByTagName('iso19112:position').length > 0) { - const coordinates = - // @ts-expect-error | The TS compiler says 'TS2531: Object is possibly 'null'.' which is valid, but not the case with this document - feature - .getElementsByTagName('iso19112:position')[0] - .getElementsByTagName('gml:pos')[0] - .textContent.split(' ') - .map((coordinate) => parseFloat(coordinate)) - geometry = { - type: 'Point', - coordinates: - featureEPSG === epsg - ? coordinates - : transformCoordinates(coordinates, featureEPSG, epsg), - } - } - if ( - feature.getElementsByTagName('iso19112:geographicExtent').length > 0 - ) { - const coordinates = - // @ts-expect-error | The TS compiler says 'TS2531: Object is possibly 'null'.' which is valid, but not the case with this document - feature - .getElementsByTagName('iso19112:geographicExtent')[0] - .getElementsByTagName('gml:posList')[0] - .textContent.split(' ') - .map((coordinate) => parseFloat(coordinate)) - .reduce( - (accumulator, _, index, array) => - index % 2 === 0 - ? [...accumulator, [array[index], array[index + 1]]] - : accumulator, - [] - ) - properties.geographicExtent = { - type: 'Polygon', - coordinates: [ - featureEPSG === epsg - ? coordinates - : coordinates.map((coordinate) => - transformCoordinates(coordinate, featureEPSG, epsg) - ), - ], - } - } - const geoFeature: PolarGeoJsonFeature = { - epsg, - type: 'Feature', - geometry, - properties, - } - if (title && title.length > 0) { - geoFeature.title = Array.isArray(title) - ? title - .reduce( - (previous, current) => previous + properties[current] + ' ', - '' - ) - .slice(0, -1) - : properties[title] - } - features.push(geoFeature) - }) - - return featureCollection - }) -} diff --git a/packages/lib/getFeatures/index.ts b/packages/lib/getFeatures/index.ts index a4220bb8f..a7307b6ae 100644 --- a/packages/lib/getFeatures/index.ts +++ b/packages/lib/getFeatures/index.ts @@ -1,3 +1,2 @@ export * from './types' -export { getGazetteerFeatures } from './gazetteer' export { getWfsFeatures } from './wfs' diff --git a/packages/plugins/AddressSearch/CHANGELOG.md b/packages/plugins/AddressSearch/CHANGELOG.md index 2f6231781..f11705b23 100644 --- a/packages/plugins/AddressSearch/CHANGELOG.md +++ b/packages/plugins/AddressSearch/CHANGELOG.md @@ -9,6 +9,7 @@ - Feature: There is now a new optional configuration parameter `searchMethods.queryParameters.likeFilterAttributes` for the WfsSearch that allows to add custom key/value pairs which are mapped to attributes of the like filter operator. - Feature: `AddressSearchState`, `AddressSearchGetters`, and `MpApiParameters` types have been additionally exposed as root export since using packages frequently rely on them. - Feature: When using the search type `mpapi`, a second search using a wildcard is now being triggered when the first search yielded no results. +- Feature: When navigating through the search results by keyboard, pressing `Escape` will now result in closing the available results. Browser interactions on `Escape` may take precedence (i.e. in fullscreen mode, the browser will exit fullscreen mode instead of letting us use the input). - Fix: Adjust documentation and types to properly describe optionality of configuration parameters. - Fix: Use correct getter for `minLength`. - Fix: `SearchResultSymbols` has been additionally exposed as root export since using packages frequently rely on it. diff --git a/packages/plugins/AddressSearch/README.md b/packages/plugins/AddressSearch/README.md index e4e8c4fb0..499c3f6f7 100644 --- a/packages/plugins/AddressSearch/README.md +++ b/packages/plugins/AddressSearch/README.md @@ -10,7 +10,7 @@ Currently supported services: - BKG - WFS -- Some gazetteers/WFS-G (please request a check or try yourself, not 100% done) +- Hamburg WFS-G (`mpapi`), may fit some WFS-G outside HH, test advised ## Configuration diff --git a/packages/plugins/AddressSearch/src/components/Results.vue b/packages/plugins/AddressSearch/src/components/Results.vue index 1ab83a419..98efc708f 100644 --- a/packages/plugins/AddressSearch/src/components/Results.vue +++ b/packages/plugins/AddressSearch/src/components/Results.vue @@ -7,6 +7,7 @@ :max-height="maxHeight" :ripple="false" tabindex="-1" + @keydown.escape.prevent.stop="escapeSelection" >