diff --git a/packages/clients/textLocator/CHANGELOG.md b/packages/clients/textLocator/CHANGELOG.md index 88f8d073b..1c5852fdf 100644 --- a/packages/clients/textLocator/CHANGELOG.md +++ b/packages/clients/textLocator/CHANGELOG.md @@ -4,6 +4,7 @@ - Breaking: Adapt client to new backend API. Previous versions are no longer runnable due the backend API change. - Feature: Implement document search, that is, the AddressSearch bar now also offers results for documents and clicking on one will retrieve a list of toponyms from the backend and resolve them against the gazetteer. Previously, we had a "get all documents regarding place" functionality. Now, a "get all places regarding document" feature is implemented. Additionally to the AddressSearch, this can be triggered on documents found in the previously implemented way; the "get all places regarding document" functionality is available from within the GeoSearch result display. +- Fix: Adjust heatmap feature to match the new data structure and have it working again. ## 1.0.0-alpha.0 diff --git a/packages/clients/textLocator/src/palettes.ts b/packages/clients/textLocator/src/palettes.ts index b9ec4889c..9a3fac9a7 100644 --- a/packages/clients/textLocator/src/palettes.ts +++ b/packages/clients/textLocator/src/palettes.ts @@ -30,7 +30,6 @@ export const pastelPalette = [ '#b3b3b3', ] -// TODO: Use later for text search result heatmaps export const heatPalette = [ '#fff5f0', '#fee2d5', diff --git a/packages/clients/textLocator/src/plugins/GeometrySearch/utils/vectorDisplay.ts b/packages/clients/textLocator/src/plugins/GeometrySearch/utils/vectorDisplay.ts index 283dafe20..b9cb21b7a 100644 --- a/packages/clients/textLocator/src/plugins/GeometrySearch/utils/vectorDisplay.ts +++ b/packages/clients/textLocator/src/plugins/GeometrySearch/utils/vectorDisplay.ts @@ -37,26 +37,14 @@ const getZoomFeatures = (features: OlFeature[], item: TreeViewItem | null) => const featHeat = ( olFeatures: OlFeature[], - titleLocationFrequency: TitleLocationFrequency + locationFrequency: TitleLocationFrequency['string']['location_frequency'] ) => { - // TODO change id from name to something id-worthy - const sums: Record = olFeatures.reduce( - (accumulator, current) => ({ - ...accumulator, - // sum occurrence of toponyms cross-document - [current.get('title')]: - (accumulator[current.get('title')] || 0) + - Object.values(titleLocationFrequency).reduce( - (perTitleAccumulator, toponymToAmount) => - perTitleAccumulator + (toponymToAmount[current.get('title')] || 0), - 0 - ), - }), - {} as Record - ) - const max = Math.max(...Object.values(sums)) + const max = Math.max(...Object.values(locationFrequency)) olFeatures.forEach((feature) => - feature.set('heat', Math.floor((sums[feature.get('title')] / max) * 9)) + feature.set( + 'heat', + Math.floor((locationFrequency[feature.getId() as string] / max) * 9) + ) ) } @@ -91,7 +79,7 @@ export const updateVectorLayer = ( preparedFeatures.forEach((feature) => feature.set('heat', undefined)) if (item?.children?.length && item.type === 'text') { - featHeat(zoomFeatures, titleLocationFrequency) + featHeat(zoomFeatures, titleLocationFrequency[item.id].location_frequency) } vectorSource.addFeatures(preparedFeatures) diff --git a/packages/clients/textLocator/src/utils/coastalGazetteer/makeRequestBody.ts b/packages/clients/textLocator/src/utils/coastalGazetteer/makeRequestBody.ts index ddb0c2fe2..6ba81bc05 100644 --- a/packages/clients/textLocator/src/utils/coastalGazetteer/makeRequestBody.ts +++ b/packages/clients/textLocator/src/utils/coastalGazetteer/makeRequestBody.ts @@ -23,9 +23,6 @@ const unify = (geometry: Geometry): Geometry => { // NOTE: never null, input from flatten merges as expected return (union(flatten(geometry)) as Feature).geometry } - console.warn( - `@polar/client-text-locator: Unexpected geometry in request body creation.` - ) return geometry }