-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
draft zoom/heat/style, restructure store actions
- Loading branch information
1 parent
6987535
commit 3033174
Showing
15 changed files
with
385 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,8 @@ | ||
# TODO | ||
|
||
## MUSS | ||
|
||
* Liste ermittelter Orte | ||
* Liste ermittelter Texte mit Ortsbezug | ||
* Ortsbezüge eines Textes graphisch darstellen | ||
* Suchgeometrien: Rechtecke, Punkte | ||
* Suchgeometrien: Ortspolygone (Adresssuche?) | ||
* Kontextsuche: Filtern ermittelter Texte (???) | ||
* Relevanzbewertung von Ortsbezügen (UI nur Count?) | ||
|
||
## SOLL | ||
|
||
* Häufigkeit von Funden | ||
* Dataport-Geo-Design | ||
* Ortsbezüge von Texten als Ortsgebirge (?) | ||
* Zugriff auf weitere Geodaten (???) | ||
* Schreibweisen/Sprachen von Orten berücksichtigen | ||
* Historische Ortspolygone beachten | ||
* Suchgeometrien: Kreise, Vielecke | ||
* Ortssuche | ||
|
||
## KANN | ||
|
||
* 3D-Darstellung Ortsgebirge | ||
* Höhenlinien Ortsgebirge | ||
* Farbliche Markieren Ortsgebirge | ||
* Suchgeometrien: Ortspolygone (Ort => Alle bezüglichen Orte) | ||
* Schreibweisen/Sprachen von Orten berücksichtigen (=> Zusammenfassung in Übersicht?) | ||
* Historische Ortspolygone beachten (=> Zeitslot-Auswahl) | ||
* Ortsbezüge von Texten als Ortsgebirge (explorativ) | ||
* Mehrsprachigkeit (en/de) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/clients/textLocator/src/plugins/GeometrySearch/store/actions/setupDrawReaction.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { PolarActionHandler, PolarStore } from '@polar/lib-custom-types' | ||
import debounce from 'lodash.debounce' | ||
import { Feature } from 'ol' | ||
import VectorSource, { VectorSourceEvent } from 'ol/source/Vector' | ||
import { GeometrySearchGetters, GeometrySearchState } from '../../types' | ||
|
||
let debouncedSearchGeometry: PolarActionHandler< | ||
GeometrySearchState, | ||
GeometrySearchGetters | ||
> | ||
|
||
export function setupDrawReaction( | ||
this: PolarStore<GeometrySearchState, GeometrySearchGetters>, | ||
{ rootGetters, dispatch } | ||
) { | ||
// features added multiple times; avoid overly requesting | ||
debouncedSearchGeometry = debounce( | ||
(feature) => dispatch('searchGeometry', feature), | ||
20 | ||
).bind(this) | ||
|
||
// only keep a single feature in the draw tool | ||
const drawSource = rootGetters['plugin/draw/drawSource'] as VectorSource | ||
let lastFeature: Feature | undefined | ||
drawSource.on(['addfeature'], function (event) { | ||
const nextFeature = (event as VectorSourceEvent).feature | ||
if (nextFeature && lastFeature !== nextFeature) { | ||
lastFeature = nextFeature | ||
drawSource.clear() | ||
drawSource.addFeature(nextFeature) | ||
// @ts-expect-error | The function is bound and hence already has context. | ||
debouncedSearchGeometry(nextFeature) | ||
} | ||
}) | ||
} |
52 changes: 52 additions & 0 deletions
52
packages/clients/textLocator/src/plugins/GeometrySearch/store/actions/setupTooltip.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Tooltip, getTooltip } from '@polar/lib-tooltip' | ||
import { Feature, Overlay } from 'ol' | ||
import { vectorLayer } from '../../utils/vectorDisplay' | ||
|
||
export function setupTooltip({ rootGetters: { map } }) { | ||
let element: Tooltip['element'], unregister: Tooltip['unregister'] | ||
const overlay = new Overlay({ | ||
positioning: 'bottom-center', | ||
offset: [0, -5], | ||
}) | ||
map.addOverlay(overlay) | ||
map.on('pointermove', ({ pixel, dragging, originalEvent }) => { | ||
if (dragging || ['touch', 'pen'].includes(originalEvent.pointerType)) { | ||
return | ||
} | ||
let hasFeatureAtPixel = false | ||
const localeKeys: [string, string][] = [ | ||
['h2', 'plugins.geometrySearch.tooltip.title'], | ||
] | ||
// TODO do not list every name separately, | ||
map.forEachFeatureAtPixel( | ||
pixel, | ||
(feature) => { | ||
if (!(feature instanceof Feature)) { | ||
return false | ||
} | ||
if (!hasFeatureAtPixel) { | ||
hasFeatureAtPixel = true | ||
overlay.setPosition(map.getCoordinateFromPixel(pixel)) | ||
} | ||
localeKeys.push([ | ||
'ul', | ||
feature | ||
.get('names') | ||
.map((name) => `<li>${name.Name}</li>`) | ||
.join(''), | ||
]) | ||
}, | ||
{ | ||
layerFilter: (layer) => layer === vectorLayer, | ||
} | ||
) | ||
if (!hasFeatureAtPixel) { | ||
overlay.setPosition(undefined) | ||
} else { | ||
unregister?.() | ||
;({ element, unregister } = getTooltip({ localeKeys })) | ||
overlay.setElement(element) | ||
return true | ||
} | ||
}) | ||
} |
53 changes: 53 additions & 0 deletions
53
packages/clients/textLocator/src/plugins/GeometrySearch/store/actions/setupWatchers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { PolarStore } from '@polar/lib-custom-types' | ||
import { GeometrySearchGetters, GeometrySearchState } from '../../types' | ||
import { searchLiteratureByToponym } from '../../../../utils/literatureByToponym' | ||
|
||
export function setupWatchers( | ||
this: PolarStore<GeometrySearchState, GeometrySearchGetters>, | ||
{ commit, dispatch, rootGetters } | ||
) { | ||
// load titleLocationFrequency on each featureCollection update | ||
this.watch( | ||
() => rootGetters['plugin/geometrySearch/featureCollection'], | ||
async (featureCollection) => { | ||
if (!featureCollection.features.length) { | ||
dispatch( | ||
'plugin/toast/addToast', | ||
{ | ||
type: 'info', | ||
text: 'textLocator.info.noGeometriesFound', | ||
timeout: 10000, | ||
}, | ||
{ root: true } | ||
) | ||
commit('setTitleLocationFrequency', {}) | ||
return | ||
} | ||
const names: string[] = featureCollection.features | ||
.map((feature) => feature.properties?.names?.map((name) => name.Name)) | ||
.flat(1) | ||
.filter((x) => x) | ||
const titleLocationFrequency = await searchLiteratureByToponym( | ||
rootGetters.configuration.textLocatorBackendUrl, | ||
names | ||
) | ||
commit('setTitleLocationFrequency', titleLocationFrequency) | ||
if (Object.keys(titleLocationFrequency).length) { | ||
dispatch('plugin/iconMenu/openMenuById', 'geometrySearch', { | ||
root: true, | ||
}) | ||
} else { | ||
dispatch( | ||
'plugin/toast/addToast', | ||
{ | ||
type: 'info', | ||
text: 'textLocator.info.noLiteratureFound', | ||
timeout: 10000, | ||
}, | ||
{ root: true } | ||
) | ||
} | ||
dispatch('changeActiveData', null) | ||
} | ||
) | ||
} |
Oops, something went wrong.