Skip to content

Commit 6eaf0f3

Browse files
committed
implement rough GeometrySearch draft
1 parent 0629de3 commit 6eaf0f3

File tree

14 files changed

+574
-148
lines changed

14 files changed

+574
-148
lines changed

packages/clients/textLocator/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"@polar/plugin-scale": "^1.1.0",
3232
"@polar/plugin-toast": "^1.1.0",
3333
"@polar/plugin-zoom": "^1.2.0",
34-
"js-levenshtein": "^1.1.6"
34+
"js-levenshtein": "^1.1.6",
35+
"lodash.debounce": "^4.0.8"
3536
}
3637
}

packages/clients/textLocator/src/addPlugins.ts

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import Zoom from '@polar/plugin-zoom'
1212

1313
import Header from './plugins/Header'
1414
import GeometrySearch from './plugins/GeometrySearch'
15-
import { searchCoastalGazetteerByToponym } from './utils/coastalGazetteer/searchToponym'
15+
import {
16+
searchCoastalGazetteerByToponym,
17+
selectResult,
18+
} from './utils/coastalGazetteer/searchToponym'
1619
import { idRegister } from './services'
1720

1821
// this is fine for list-like setup functions
@@ -25,6 +28,23 @@ export const addPlugins = (core) => {
2528
displayComponent: true,
2629
layoutTag: NineLayoutTag.TOP_LEFT,
2730
}),
31+
Draw({
32+
displayComponent: false,
33+
selectableDrawModes: ['Point', 'LineString', 'Circle', 'Polygon'],
34+
style: {
35+
fill: {
36+
color: 'rgba(255, 255, 255, 0.5)',
37+
},
38+
stroke: {
39+
color: '#e51313',
40+
width: 2,
41+
},
42+
circle: {
43+
radius: 7,
44+
fillColor: '#e51313',
45+
},
46+
},
47+
}),
2848
IconMenu({
2949
displayComponent: true,
3050
// TODO fix, it's broken ...
@@ -61,24 +81,9 @@ export const addPlugins = (core) => {
6181
coastalGazetteer: searchCoastalGazetteerByToponym,
6282
},
6383
customSelectResult: {
64-
/* categoryDenkmalsucheAutocomplete: selectResult */
65-
},
66-
}),
67-
Draw({
68-
displayComponent: false,
69-
selectableDrawModes: ['Point', 'LineString', 'Circle', 'Polygon'],
70-
style: {
71-
fill: {
72-
color: 'rgba(255, 255, 255, 0.5)',
73-
},
74-
stroke: {
75-
color: '#e51313',
76-
width: 2,
77-
},
78-
circle: {
79-
radius: 7,
80-
fillColor: '#e51313',
81-
},
84+
// it's defined like that
85+
// eslint-disable-next-line @typescript-eslint/naming-convention
86+
'': selectResult,
8287
},
8388
}),
8489
Attributions({

packages/clients/textLocator/src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
initializeClient({
2929
urls: {
30-
textLocatorBackend: 'https://textlocator.ai.dataport.de/api/',
30+
textLocatorBackend: 'https://textlocator.ai.dataport.de/api',
3131
gazetteerClient: 'https://mdi-de-dienste.org/GazetteerClient/search'
3232
}
3333
}).then(console.info.bind(null, 'Map client instance:'))
Lines changed: 111 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,124 @@
11
<template>
2-
<v-card>test</v-card>
2+
<v-card class="text-locator-search-card">
3+
<v-card-title class="text-locator-card-collapse">
4+
{{ $t('common:plugins.geometrySearch.draw.title') }}
5+
</v-card-title>
6+
<v-card-text class="text-locator-card-collapse">
7+
<v-radio-group v-model="_draw" dense hide-details>
8+
<v-radio
9+
:label="$t('common:plugins.draw.drawMode.point')"
10+
value="Point"
11+
></v-radio>
12+
<v-radio
13+
:label="$t('common:plugins.draw.drawMode.polygon')"
14+
value="Polygon"
15+
></v-radio>
16+
</v-radio-group>
17+
</v-card-text>
18+
<v-card-text v-if="tipVisibility[_draw]" class="text-locator-card-collapse">
19+
<v-alert
20+
v-model="tipVisibility[_draw]"
21+
type="info"
22+
prominent
23+
dense
24+
colored-border
25+
border="left"
26+
:icon="_draw === 'Point' ? 'fa-location-dot' : 'fa-draw-polygon'"
27+
dismissible
28+
elevation="4"
29+
>{{
30+
$t(`common:plugins.geometrySearch.draw.description.${_draw}`)
31+
}}</v-alert
32+
>
33+
</v-card-text>
34+
<v-card-title class="text-locator-card-collapse">
35+
{{ $t('common:plugins.geometrySearch.results.title') }}
36+
</v-card-title>
37+
<v-card-text>
38+
<v-btn-toggle v-model="_byCategory" dense>
39+
<v-btn class="text-locator-btn-group-button" value="text">
40+
<v-icon small>fa-book-open</v-icon>&nbsp;
41+
{{ $t('common:plugins.geometrySearch.results.byText') }}
42+
</v-btn>
43+
<v-btn class="text-locator-btn-group-button" value="toponym">
44+
<v-icon small>fa-location-pin</v-icon>&nbsp;
45+
{{ $t('common:plugins.geometrySearch.results.byLocation') }}
46+
</v-btn>
47+
</v-btn-toggle>
48+
<v-treeview
49+
v-if="treeViewItems.length"
50+
dense
51+
hoverable
52+
activatable
53+
:items="treeViewItems"
54+
>
55+
<template #prepend="{ item }"> {{ item.count }} </template>
56+
</v-treeview>
57+
<v-card-text v-else>
58+
{{ $t('common:plugins.geometrySearch.results.none') }}
59+
</v-card-text>
60+
</v-card-text>
61+
</v-card>
362
</template>
463

564
<script lang="ts">
665
import Vue from 'vue'
7-
import { mapGetters } from 'vuex'
66+
import { mapGetters, mapActions, mapMutations } from 'vuex'
67+
import { TextLocatorCategories, TextLocatorDrawModes } from '../types'
868
969
export default Vue.extend({
1070
name: 'GeometrySearchPlugin',
71+
data: () => ({
72+
tipVisibility: {
73+
Point: true,
74+
Polygon: true,
75+
},
76+
}),
1177
computed: {
12-
...mapGetters(['clientWidth', 'hasSmallWidth', 'hasWindowSize']),
78+
...mapGetters('plugin/geometrySearch', [
79+
'draw',
80+
'byCategory',
81+
'treeViewItems',
82+
]),
83+
_byCategory: {
84+
get() {
85+
return this.byCategory
86+
},
87+
set(byCategory: TextLocatorCategories) {
88+
this.setByCategory(byCategory)
89+
},
90+
},
91+
_draw: {
92+
get() {
93+
return this.draw
94+
},
95+
set(drawMode: TextLocatorDrawModes) {
96+
this.setDrawMode(drawMode)
97+
},
98+
},
99+
},
100+
methods: {
101+
...mapActions('plugin/geometrySearch', ['setDrawMode']),
102+
...mapMutations('plugin/geometrySearch', ['setByCategory']),
13103
},
14104
})
15105
</script>
16106

17-
<style lang="scss" scoped></style>
107+
<style lang="scss" scoped>
108+
.text-locator-search-card {
109+
overflow-y: auto;
110+
overflow-x: hidden;
111+
scrollbar-gutter: stable;
112+
pointer-events: all;
113+
min-width: 400px;
114+
white-space: normal;
115+
116+
.text-locator-card-collapse {
117+
padding-bottom: 0;
118+
}
119+
120+
.text-locator-btn-group-button {
121+
text-transform: unset;
122+
}
123+
}
124+
</style>

packages/clients/textLocator/src/plugins/GeometrySearch/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import language from './language'
55
import { makeStoreModule } from './store'
66

77
interface GeometrySearchConfiguration extends PluginOptions {
8-
thing: string
8+
url: string
99
}
1010

1111
export default (options: GeometrySearchConfiguration) => (instance: Vue) =>

packages/clients/textLocator/src/plugins/GeometrySearch/language.ts

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// other names required
2+
/* eslint-disable @typescript-eslint/naming-convention */
13
import { LanguageOption } from '@polar/lib-custom-types'
24

35
const language: LanguageOption[] = [
@@ -10,7 +12,24 @@ const language: LanguageOption[] = [
1012
geometrySearch: 'Geometriesuche',
1113
},
1214
},
13-
geometrySearch: {},
15+
geometrySearch: {
16+
draw: {
17+
title: 'Zeichenmodus',
18+
description: {
19+
Point:
20+
'Klicken Sie in die Karte, um Ortsnamen und Literatur zu einer Punktkoordinate abzufragen. $t(plugins.geometrySearch.draw.description.Common)',
21+
Polygon:
22+
'Klicken Sie wiederholt in die Karte, um eine Fläche zu zeichnen, zu der Ortsnamen und Literatur abgefragt werden. Doppelklick beendet eine Zeichnung. $t(plugins.geometrySearch.draw.description.Common)',
23+
Common: 'Neue Zeichnungen verwerfen vorangehende Ergebnisse.',
24+
},
25+
},
26+
results: {
27+
title: 'Funde',
28+
byLocation: 'Ort',
29+
byText: 'Text',
30+
none: 'Keine Suchergebnisse',
31+
},
32+
},
1433
},
1534
},
1635
},
@@ -23,7 +42,24 @@ const language: LanguageOption[] = [
2342
geometrySearch: 'Geometry search',
2443
},
2544
},
26-
geometrySearch: {},
45+
geometrySearch: {
46+
draw: {
47+
title: 'Draw mode',
48+
description: {
49+
Point:
50+
'Click somewhere in the map to request location names and literature to a point coordinate. $t(plugins.geometrySearch.draw.description.Common)',
51+
Polygon:
52+
'Click repeatedly in the map to draw an area to request location names and literature to. Double click finished an area. $t(plugins.geometrySearch.draw.description.Common)',
53+
Common: 'New drawings discard previous results.',
54+
},
55+
},
56+
results: {
57+
title: 'Findings',
58+
byLocation: 'Place',
59+
byText: 'Text',
60+
none: 'No search results',
61+
},
62+
},
2763
},
2864
},
2965
},

0 commit comments

Comments
 (0)