geonetwork-ui 2.10.3-dev.4154db07d → 2.11.0-dev.0ddf1324b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/geonetwork-ui.mjs +1661 -986
- package/fesm2022/geonetwork-ui.mjs.map +1 -1
- package/index.d.ts +298 -128
- package/index.d.ts.map +1 -1
- package/package.json +9 -8
- package/src/libs/api/metadata-converter/src/lib/fixtures/generic.records.ts +5 -5
- package/src/libs/api/metadata-converter/src/lib/fixtures/metawal.records.ts +5 -5
- package/src/libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.ts +43 -13
- package/src/libs/api/metadata-converter/src/lib/gn4/types/elasticsearch.model.ts +13 -1
- package/src/libs/api/metadata-converter/src/lib/iso19115-3/write-parts.ts +2 -2
- package/src/libs/api/metadata-converter/src/lib/iso19139/read-parts.ts +9 -5
- package/src/libs/api/metadata-converter/src/lib/iso19139/utils/association-type.mapper.ts +12 -0
- package/src/libs/api/metadata-converter/src/lib/iso19139/write-parts.ts +2 -2
- package/src/libs/api/repository/src/lib/gn4/elasticsearch/elasticsearch.service.ts +130 -37
- package/src/libs/api/repository/src/lib/gn4/gn4-repository.ts +40 -16
- package/src/libs/common/domain/src/lib/model/record/metadata.model.ts +40 -2
- package/src/libs/common/domain/src/lib/model/search/filter.model.ts +20 -1
- package/src/libs/common/domain/src/lib/model/search/sort-by.model.ts +1 -5
- package/src/libs/common/domain/src/lib/repository/records-repository.interface.ts +2 -2
- package/src/libs/feature/dataviz/src/lib/chart-view/chart-view.component.ts +3 -2
- package/src/libs/feature/dataviz/src/lib/geo-table-view/geo-table-view.component.ts +2 -1
- package/src/libs/feature/dataviz/src/lib/service/data.service.ts +22 -22
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-associated-records/form-field-associated-records.component.html +33 -0
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-associated-records/form-field-associated-records.component.ts +94 -0
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-temporal-extents/form-field-temporal-extents.component.html +16 -12
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html +6 -0
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.ts +6 -0
- package/src/libs/feature/editor/src/lib/fields.config.ts +5 -0
- package/src/libs/feature/map/src/index.ts +0 -1
- package/src/libs/feature/map/src/lib/add-layer-from-file/add-layer-from-file.component.html +1 -0
- package/src/libs/feature/map/src/lib/feature-map.module.ts +1 -8
- package/src/libs/feature/notifications/src/lib/notifications.service.ts +6 -4
- package/src/libs/feature/record/src/lib/state/mdview.actions.ts +4 -8
- package/src/libs/feature/record/src/lib/state/mdview.effects.ts +7 -16
- package/src/libs/feature/record/src/lib/state/mdview.facade.ts +1 -3
- package/src/libs/feature/record/src/lib/state/mdview.reducer.ts +4 -9
- package/src/libs/feature/record/src/lib/state/mdview.selectors.ts +2 -7
- package/src/libs/feature/router/src/lib/default/router.service.ts +1 -1
- package/src/libs/feature/router/src/lib/default/state/query-params.utils.ts +1 -1
- package/src/libs/feature/search/src/index.ts +2 -0
- package/src/libs/feature/search/src/lib/filter-dropdown/filter-dropdown.component.html +12 -4
- package/src/libs/feature/search/src/lib/filter-dropdown/filter-dropdown.component.ts +58 -19
- package/src/libs/feature/{map/src/lib → search/src/lib/geocoding}/geocoding.service.ts +5 -1
- package/src/libs/feature/search/src/lib/location-search/location-search.component.html +8 -0
- package/src/libs/feature/search/src/lib/location-search/location-search.component.ts +40 -0
- package/src/libs/feature/search/src/lib/search-filters-summary-item/search-filters-summary-item.component.ts +18 -8
- package/src/libs/feature/search/src/lib/sort-by/sort-by.component.ts +1 -1
- package/src/libs/feature/search/src/lib/utils/service/fields.service.ts +9 -1
- package/src/libs/feature/search/src/lib/utils/service/fields.ts +61 -2
- package/src/libs/ui/dataviz/src/lib/data-table/data-table.component.html +6 -7
- package/src/libs/ui/dataviz/src/lib/data-table/data-table.component.ts +31 -19
- package/src/libs/ui/dataviz/src/lib/data-table/data-table.fixtures.ts +2 -2
- package/src/libs/ui/elements/src/lib/service-capabilities/service-capabilities.component.ts +2 -1
- package/src/libs/ui/inputs/src/index.ts +2 -0
- package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.html +10 -1
- package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.ts +8 -0
- package/src/libs/ui/inputs/src/lib/date-adapter.providers.ts +30 -0
- package/src/libs/ui/inputs/src/lib/date-picker/date-picker.component.ts +3 -24
- package/src/libs/ui/inputs/src/lib/date-range-dropdown/date-range-dropdown.component.css +37 -3
- package/src/libs/ui/inputs/src/lib/date-range-dropdown/date-range-dropdown.component.html +135 -16
- package/src/libs/ui/inputs/src/lib/date-range-dropdown/date-range-dropdown.component.ts +166 -29
- package/src/libs/ui/inputs/src/lib/date-range-picker/date-range-picker.component.ts +3 -7
- package/src/libs/ui/inputs/src/lib/drag-and-drop-file-input/drag-and-drop-file-input.component.css +1 -0
- package/src/libs/ui/inputs/src/lib/drag-and-drop-file-input/drag-and-drop-file-input.component.html +20 -7
- package/src/libs/ui/inputs/src/lib/drag-and-drop-file-input/drag-and-drop-file-input.component.ts +46 -5
- package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.component.html +7 -4
- package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.component.ts +12 -9
- package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.model.ts +2 -2
- package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.css +0 -0
- package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.html +111 -0
- package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.ts +215 -0
- package/src/libs/util/app-config/src/lib/app-config.ts +3 -0
- package/src/libs/util/app-config/src/lib/model.ts +1 -0
- package/src/libs/util/data-fetcher/src/lib/data-fetcher.ts +19 -22
- package/src/libs/util/data-fetcher/src/lib/engine/duckdb.ts +185 -0
- package/src/libs/util/data-fetcher/src/lib/engine/results.ts +63 -0
- package/src/libs/util/data-fetcher/src/lib/{sql-utils.ts → engine/sql-utils.ts} +28 -13
- package/src/libs/util/data-fetcher/src/lib/model.ts +2 -1
- package/src/libs/util/data-fetcher/src/lib/readers/base-file.ts +53 -38
- package/src/libs/util/data-fetcher/src/lib/readers/base.ts +11 -0
- package/src/libs/util/data-fetcher/src/lib/readers/csv.ts +9 -47
- package/src/libs/util/data-fetcher/src/lib/readers/excel.ts +27 -27
- package/src/libs/util/data-fetcher/src/lib/readers/geojson.ts +5 -24
- package/src/libs/util/data-fetcher/src/lib/readers/gml.ts +5 -49
- package/src/libs/util/data-fetcher/src/lib/readers/json.ts +5 -23
- package/src/libs/util/data-fetcher/src/lib/readers/wfs.ts +184 -128
- package/src/libs/util/data-fetcher/src/lib/utils.ts +0 -143
- package/src/libs/util/shared/src/index.ts +1 -0
- package/src/libs/util/shared/src/lib/autofocus.directive.ts +26 -0
- package/src/libs/util/shared/src/lib/gn-ui-version.ts +1 -1
- package/src/libs/util/shared/src/lib/links/link-utils.ts +19 -10
- package/src/libs/util/shared/src/lib/services/date.service.ts +3 -3
- package/src/libs/util/shared/src/lib/utils/file.ts +15 -0
- package/src/libs/util/shared/src/lib/utils/geojson.ts +8 -0
- package/src/libs/util/shared/src/lib/utils/index.ts +1 -0
- package/tailwind.base.css +5 -0
- package/translations/de.json +30 -4
- package/translations/en.json +29 -3
- package/translations/es.json +27 -1
- package/translations/fr.json +30 -4
- package/translations/it.json +28 -2
- package/translations/nl.json +27 -1
- package/translations/pt.json +27 -1
- package/translations/sk.json +28 -2
- package/src/libs/feature/map/src/lib/geocoding/geocoding.component.html +0 -41
- package/src/libs/feature/map/src/lib/geocoding/geocoding.component.ts +0 -112
- package/src/libs/util/data-fetcher/src/lib/readers/base-cache.ts +0 -14
- /package/src/libs/feature/{map/src/lib/geocoding/geocoding.component.css → editor/src/lib/components/record-form/form-field/form-field-associated-records/form-field-associated-records.component.css} +0 -0
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
propagateToDocumentOnly,
|
|
25
25
|
} from '../../../../../../libs/util/shared/src'
|
|
26
26
|
import { ButtonComponent } from '../button/button.component'
|
|
27
|
-
import { NgIcon, provideIcons } from '@ng-icons/core'
|
|
27
|
+
import { NgIcon, provideIcons, provideNgIconsConfig } from '@ng-icons/core'
|
|
28
28
|
import { FormsModule } from '@angular/forms'
|
|
29
29
|
import { TranslatePipe } from '@ngx-translate/core'
|
|
30
30
|
|
|
@@ -46,19 +46,22 @@ import {
|
|
|
46
46
|
matExpandMore,
|
|
47
47
|
matExpandLess,
|
|
48
48
|
}),
|
|
49
|
+
provideNgIconsConfig({
|
|
50
|
+
size: '1.5rem',
|
|
51
|
+
}),
|
|
49
52
|
],
|
|
50
53
|
standalone: true,
|
|
51
54
|
})
|
|
52
|
-
export class DropdownMultiselectComponent {
|
|
55
|
+
export class DropdownMultiselectComponent<T = unknown> {
|
|
53
56
|
private scrollStrategies = inject(ScrollStrategyOptions)
|
|
54
57
|
|
|
55
58
|
@Input() title: string
|
|
56
|
-
@Input() choices: Choice[]
|
|
57
|
-
@Input() selected:
|
|
59
|
+
@Input() choices: Choice<T>[]
|
|
60
|
+
@Input() selected: T[] = []
|
|
58
61
|
@Input() allowSearch = true
|
|
59
62
|
@Input() maxRows: number
|
|
60
63
|
@Input() searchInputValue = ''
|
|
61
|
-
@Output() selectValues = new EventEmitter<
|
|
64
|
+
@Output() selectValues = new EventEmitter<T[]>()
|
|
62
65
|
@ViewChild('overlayOrigin') overlayOrigin: CdkOverlayOrigin
|
|
63
66
|
@ViewChild(CdkConnectedOverlay) overlay: CdkConnectedOverlay
|
|
64
67
|
@ViewChild('overlayContainer', { read: ElementRef })
|
|
@@ -115,7 +118,7 @@ export class DropdownMultiselectComponent {
|
|
|
115
118
|
|
|
116
119
|
private setFocus() {
|
|
117
120
|
setTimeout(() => {
|
|
118
|
-
this.searchFieldInput
|
|
121
|
+
this.searchFieldInput?.nativeElement.focus()
|
|
119
122
|
}, 0)
|
|
120
123
|
}
|
|
121
124
|
|
|
@@ -194,18 +197,18 @@ export class DropdownMultiselectComponent {
|
|
|
194
197
|
this.checkboxes.get(newIndex).nativeElement.focus()
|
|
195
198
|
}
|
|
196
199
|
|
|
197
|
-
isSelected(choice: Choice) {
|
|
200
|
+
isSelected(choice: Choice<T>) {
|
|
198
201
|
return this.selected.indexOf(choice.value) > -1
|
|
199
202
|
}
|
|
200
203
|
|
|
201
|
-
select(choice: Choice
|
|
204
|
+
select(choice: Choice<T>, selected: boolean) {
|
|
202
205
|
this.selected = selected
|
|
203
206
|
? [...this.selected.filter((v) => v !== choice.value), choice.value]
|
|
204
207
|
: this.selected.filter((v) => v !== choice.value)
|
|
205
208
|
this.selectValues.emit(this.selected)
|
|
206
209
|
}
|
|
207
210
|
|
|
208
|
-
toggle(choice: Choice) {
|
|
211
|
+
toggle(choice: Choice<T>) {
|
|
209
212
|
this.select(choice, !this.isSelected(choice))
|
|
210
213
|
}
|
|
211
214
|
|
package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.css
ADDED
|
File without changes
|
package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.html
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<gn-ui-button
|
|
2
|
+
type="outline"
|
|
3
|
+
extraClass="bg-background w-full !p-[8px] !pl-[16px]"
|
|
4
|
+
[title]="title"
|
|
5
|
+
(buttonClick)="toggleOverlay()"
|
|
6
|
+
cdkOverlayOrigin
|
|
7
|
+
#overlayOrigin="cdkOverlayOrigin"
|
|
8
|
+
>
|
|
9
|
+
<div class="grow flex items-center mr-2 gap-2 overflow-hidden">
|
|
10
|
+
<div class="text-left font-medium truncate py-1">
|
|
11
|
+
{{ title }}
|
|
12
|
+
</div>
|
|
13
|
+
@if (hasSelection) {
|
|
14
|
+
<div
|
|
15
|
+
class="bg-primary-lighter text-white shrink-0 rounded-full font-bold text-[12px] w-[22px] h-[22px] flex items-center justify-center"
|
|
16
|
+
>
|
|
17
|
+
1
|
|
18
|
+
</div>
|
|
19
|
+
}
|
|
20
|
+
</div>
|
|
21
|
+
<button class="h-6 w-6 flex items-center" data-cy="clearSelection">
|
|
22
|
+
@if (hasSelection && !overlayOpen) {
|
|
23
|
+
<ng-icon
|
|
24
|
+
class="shrink-0 opacity-40 mr-1.5 hover:opacity-80 transition-colors clear-btn"
|
|
25
|
+
(click)="removeSelection($event)"
|
|
26
|
+
name="matClose"
|
|
27
|
+
></ng-icon>
|
|
28
|
+
}
|
|
29
|
+
</button>
|
|
30
|
+
<ng-icon
|
|
31
|
+
[name]="overlayOpen ? 'matExpandLess' : 'matExpandMore'"
|
|
32
|
+
class="shrink-0 opacity-40"
|
|
33
|
+
>
|
|
34
|
+
</ng-icon>
|
|
35
|
+
</gn-ui-button>
|
|
36
|
+
|
|
37
|
+
<ng-template
|
|
38
|
+
cdkConnectedOverlay
|
|
39
|
+
cdkConnectedOverlayHasBackdrop
|
|
40
|
+
cdkConnectedOverlayBackdropClass="cdk-overlay-transparent-backdrop"
|
|
41
|
+
[cdkConnectedOverlayOrigin]="overlayOrigin"
|
|
42
|
+
[cdkConnectedOverlayOpen]="overlayOpen"
|
|
43
|
+
[cdkConnectedOverlayPositions]="overlayPositions"
|
|
44
|
+
[cdkConnectedOverlayScrollStrategy]="scrollStrategy"
|
|
45
|
+
[cdkConnectedOverlayFlexibleDimensions]="true"
|
|
46
|
+
(overlayOutsideClick)="closeOverlay()"
|
|
47
|
+
(detach)="closeOverlay()"
|
|
48
|
+
>
|
|
49
|
+
<div
|
|
50
|
+
class="bg-white border border-gray-400 rounded shadow-lg pt-[12px] px-[16px] overlay-container w-[280px] flex flex-col gap-2"
|
|
51
|
+
[style.min-width]="overlayMinWidth"
|
|
52
|
+
>
|
|
53
|
+
<div class="text-xs text-black">
|
|
54
|
+
{{ 'search.filters.spatialExtent.helpText' | translate }}
|
|
55
|
+
</div>
|
|
56
|
+
|
|
57
|
+
<div
|
|
58
|
+
[class]="
|
|
59
|
+
(hasSelection
|
|
60
|
+
? 'border-b-[1px] border-gray-400 pb-[20px]'
|
|
61
|
+
: 'pb-[8px]') + ' text-black'
|
|
62
|
+
"
|
|
63
|
+
>
|
|
64
|
+
<gn-ui-drag-and-drop-file-input
|
|
65
|
+
accept=".json,.geojson"
|
|
66
|
+
[placeholder]="'search.filters.spatialExtent.import' | translate"
|
|
67
|
+
[maxFileSizeMb]="maxFileSizeMb"
|
|
68
|
+
[showFileName]="false"
|
|
69
|
+
textClass="text-black truncate"
|
|
70
|
+
dropzoneBackgroundColor="transparent"
|
|
71
|
+
icon="iconoirImport"
|
|
72
|
+
extraClass="gn-ui-gray-outline-input w-full !h-[32px] px-[8px] py-[4px] justify-between"
|
|
73
|
+
(fileChange)="handleFileSelected($event)"
|
|
74
|
+
(errorChange)="handleFileError($event)"
|
|
75
|
+
data-cy="importGeojson"
|
|
76
|
+
></gn-ui-drag-and-drop-file-input>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
@if (hasSelection) {
|
|
80
|
+
<gn-ui-button
|
|
81
|
+
[type]="'primary-light'"
|
|
82
|
+
[title]="selectionDeleteLabelKey | translate: selectionLabelParams"
|
|
83
|
+
(buttonClick)="removeSelection($event)"
|
|
84
|
+
extraClass="group gap-x-2 w-full h-[28px] px-[8px] py-[4px] mb-[12px] bg-primary-lighter text-white"
|
|
85
|
+
data-test="spatial-extent-selected-item"
|
|
86
|
+
>
|
|
87
|
+
<ng-icon
|
|
88
|
+
name="iconoirSquareDashed"
|
|
89
|
+
class="shrink-0"
|
|
90
|
+
size="15px"
|
|
91
|
+
></ng-icon>
|
|
92
|
+
<span class="group-hover:hidden truncate text-sm m-auto">
|
|
93
|
+
{{ selectionLabelKey | translate: selectionLabelParams }}
|
|
94
|
+
</span>
|
|
95
|
+
<span class="hidden group-hover:block truncate text-sm m-auto">
|
|
96
|
+
{{ selectionDeleteLabelKey | translate: selectionLabelParams }}
|
|
97
|
+
</span>
|
|
98
|
+
<ng-icon
|
|
99
|
+
name="iconoirCheckCircle"
|
|
100
|
+
class="group-hover:hidden shrink-0"
|
|
101
|
+
size="14px"
|
|
102
|
+
></ng-icon>
|
|
103
|
+
<ng-icon
|
|
104
|
+
name="iconoirTrash"
|
|
105
|
+
class="!hidden group-hover:!block shrink-0"
|
|
106
|
+
size="15px"
|
|
107
|
+
></ng-icon>
|
|
108
|
+
</gn-ui-button>
|
|
109
|
+
}
|
|
110
|
+
</div>
|
|
111
|
+
</ng-template>
|
package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.ts
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
ChangeDetectorRef,
|
|
4
|
+
Component,
|
|
5
|
+
EventEmitter,
|
|
6
|
+
Input,
|
|
7
|
+
Output,
|
|
8
|
+
ViewChild,
|
|
9
|
+
inject,
|
|
10
|
+
} from '@angular/core'
|
|
11
|
+
import {
|
|
12
|
+
CdkConnectedOverlay,
|
|
13
|
+
CdkOverlayOrigin,
|
|
14
|
+
ConnectedPosition,
|
|
15
|
+
OverlayModule,
|
|
16
|
+
ScrollStrategyOptions,
|
|
17
|
+
} from '@angular/cdk/overlay'
|
|
18
|
+
|
|
19
|
+
import { ButtonComponent } from '../button/button.component'
|
|
20
|
+
import { NgIcon, provideIcons } from '@ng-icons/core'
|
|
21
|
+
import {
|
|
22
|
+
iconoirCheckCircle,
|
|
23
|
+
iconoirImport,
|
|
24
|
+
iconoirSquareDashed,
|
|
25
|
+
iconoirTrash,
|
|
26
|
+
} from '@ng-icons/iconoir'
|
|
27
|
+
import {
|
|
28
|
+
matClose,
|
|
29
|
+
matExpandLess,
|
|
30
|
+
matExpandMore,
|
|
31
|
+
} from '@ng-icons/material-icons/baseline'
|
|
32
|
+
import { TranslatePipe } from '@ngx-translate/core'
|
|
33
|
+
import { marker } from '@biesbjerg/ngx-translate-extract-marker'
|
|
34
|
+
import {
|
|
35
|
+
BoundingBox,
|
|
36
|
+
getGeometryBoundingBox,
|
|
37
|
+
getGeometryFromGeoJSON,
|
|
38
|
+
propagateToDocumentOnly,
|
|
39
|
+
readFileAsText,
|
|
40
|
+
} from '../../../../../../libs/util/shared/src'
|
|
41
|
+
import {
|
|
42
|
+
DragAndDropFileInputComponent,
|
|
43
|
+
DragAndDropFileInputError,
|
|
44
|
+
} from '../drag-and-drop-file-input/drag-and-drop-file-input.component'
|
|
45
|
+
|
|
46
|
+
marker('search.filters.spatialExtent.import')
|
|
47
|
+
marker('search.filters.spatialExtent.helpText')
|
|
48
|
+
marker('search.filters.spatialExtent.error.title')
|
|
49
|
+
|
|
50
|
+
const LABEL_FROM_FILE = marker('search.filters.spatialExtent.bboxFromFile')
|
|
51
|
+
const LABEL_FROM_FILE_DELETE = marker(
|
|
52
|
+
'search.filters.spatialExtent.bboxFromFileDelete'
|
|
53
|
+
)
|
|
54
|
+
const LABEL_INITIAL = marker('search.filters.spatialExtent.bboxInitial')
|
|
55
|
+
const LABEL_INITIAL_DELETE = marker(
|
|
56
|
+
'search.filters.spatialExtent.bboxInitialDelete'
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
export interface SpatialExtentDropdownError {
|
|
60
|
+
key: string
|
|
61
|
+
params?: Record<string, string | number>
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@Component({
|
|
65
|
+
selector: 'gn-ui-spatial-extent-dropdown',
|
|
66
|
+
standalone: true,
|
|
67
|
+
imports: [
|
|
68
|
+
ButtonComponent,
|
|
69
|
+
NgIcon,
|
|
70
|
+
OverlayModule,
|
|
71
|
+
TranslatePipe,
|
|
72
|
+
DragAndDropFileInputComponent,
|
|
73
|
+
],
|
|
74
|
+
providers: [
|
|
75
|
+
provideIcons({
|
|
76
|
+
iconoirCheckCircle,
|
|
77
|
+
iconoirImport,
|
|
78
|
+
iconoirSquareDashed,
|
|
79
|
+
iconoirTrash,
|
|
80
|
+
matClose,
|
|
81
|
+
matExpandLess,
|
|
82
|
+
matExpandMore,
|
|
83
|
+
}),
|
|
84
|
+
],
|
|
85
|
+
templateUrl: './spatial-extent-dropdown.component.html',
|
|
86
|
+
styleUrls: ['./spatial-extent-dropdown.component.css'],
|
|
87
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
88
|
+
})
|
|
89
|
+
export class SpatialExtentDropdownComponent {
|
|
90
|
+
private cd = inject(ChangeDetectorRef)
|
|
91
|
+
private scrollStrategies = inject(ScrollStrategyOptions)
|
|
92
|
+
|
|
93
|
+
@Input() title: string
|
|
94
|
+
@Input() maxFileSizeMb: number | null = null
|
|
95
|
+
@Input() set initialBbox(value: BoundingBox | null) {
|
|
96
|
+
if (!this.bbox && value) {
|
|
97
|
+
this.bbox = value
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@Output() bboxChange = new EventEmitter<BoundingBox | null>()
|
|
102
|
+
@Output() errorChange = new EventEmitter<SpatialExtentDropdownError>()
|
|
103
|
+
|
|
104
|
+
bbox: BoundingBox | null = null
|
|
105
|
+
fileName = ''
|
|
106
|
+
|
|
107
|
+
@ViewChild('overlayOrigin') overlayOrigin: CdkOverlayOrigin
|
|
108
|
+
@ViewChild(CdkConnectedOverlay) overlay: CdkConnectedOverlay
|
|
109
|
+
@ViewChild(DragAndDropFileInputComponent)
|
|
110
|
+
fileInput: DragAndDropFileInputComponent
|
|
111
|
+
|
|
112
|
+
overlayPositions: ConnectedPosition[] = [
|
|
113
|
+
{
|
|
114
|
+
originX: 'start',
|
|
115
|
+
originY: 'bottom',
|
|
116
|
+
overlayX: 'start',
|
|
117
|
+
overlayY: 'top',
|
|
118
|
+
offsetY: 8,
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
originX: 'start',
|
|
122
|
+
originY: 'top',
|
|
123
|
+
overlayX: 'start',
|
|
124
|
+
overlayY: 'bottom',
|
|
125
|
+
offsetY: -8,
|
|
126
|
+
},
|
|
127
|
+
]
|
|
128
|
+
scrollStrategy = this.scrollStrategies.reposition()
|
|
129
|
+
overlayOpen = false
|
|
130
|
+
overlayMinWidth = 'none'
|
|
131
|
+
|
|
132
|
+
errorKey: string | null = null
|
|
133
|
+
|
|
134
|
+
get hasSelection() {
|
|
135
|
+
return !!this.bbox
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
get selectionLabelKey() {
|
|
139
|
+
return this.fileName ? LABEL_FROM_FILE : LABEL_INITIAL
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
get selectionDeleteLabelKey() {
|
|
143
|
+
return this.fileName ? LABEL_FROM_FILE_DELETE : LABEL_INITIAL_DELETE
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
get selectionLabelParams() {
|
|
147
|
+
return { fileName: this.fileName }
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
openOverlay() {
|
|
151
|
+
this.overlayMinWidth =
|
|
152
|
+
this.overlayOrigin.elementRef.nativeElement.getBoundingClientRect()
|
|
153
|
+
.width + 'px'
|
|
154
|
+
this.overlayOpen = true
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
closeOverlay() {
|
|
158
|
+
this.overlayOpen = false
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
toggleOverlay() {
|
|
162
|
+
if (this.overlayOpen) {
|
|
163
|
+
this.closeOverlay()
|
|
164
|
+
} else {
|
|
165
|
+
this.openOverlay()
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
async handleFileSelected(file: File) {
|
|
170
|
+
this.errorKey = null
|
|
171
|
+
let content: string
|
|
172
|
+
try {
|
|
173
|
+
content = await readFileAsText(file)
|
|
174
|
+
const parsed = JSON.parse(content)
|
|
175
|
+
const geometry = getGeometryFromGeoJSON(parsed)
|
|
176
|
+
if (!geometry) {
|
|
177
|
+
this.setError(marker('search.filters.spatialExtent.error.noGeometry'))
|
|
178
|
+
return
|
|
179
|
+
}
|
|
180
|
+
const bbox = getGeometryBoundingBox(geometry)
|
|
181
|
+
this.bbox = bbox
|
|
182
|
+
this.fileName = file.name
|
|
183
|
+
this.bboxChange.emit(bbox)
|
|
184
|
+
this.cd.markForCheck()
|
|
185
|
+
} catch {
|
|
186
|
+
this.setError(marker('search.filters.spatialExtent.error.invalidFormat'))
|
|
187
|
+
return
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
handleFileError(error: DragAndDropFileInputError) {
|
|
192
|
+
if (error === 'file-too-large') {
|
|
193
|
+
this.setError(marker('search.filters.spatialExtent.error.fileTooLarge'), {
|
|
194
|
+
maxSize: this.maxFileSizeMb,
|
|
195
|
+
})
|
|
196
|
+
} else {
|
|
197
|
+
this.setError(marker('search.filters.spatialExtent.error.invalidFormat'))
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
private setError(errorKey: string, params?: Record<string, string | number>) {
|
|
202
|
+
this.errorKey = errorKey
|
|
203
|
+
this.errorChange.emit({ key: errorKey, params })
|
|
204
|
+
this.cd.markForCheck()
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
removeSelection(event: Event) {
|
|
208
|
+
this.bbox = null
|
|
209
|
+
this.fileName = ''
|
|
210
|
+
this.errorKey = null
|
|
211
|
+
this.fileInput?.clear()
|
|
212
|
+
this.bboxChange.emit(null)
|
|
213
|
+
propagateToDocumentOnly(event)
|
|
214
|
+
}
|
|
215
|
+
}
|
|
@@ -252,6 +252,7 @@ export function loadAppConfig(configUrl = 'assets/configuration/default.toml') {
|
|
|
252
252
|
'search_preset',
|
|
253
253
|
'advanced_filters',
|
|
254
254
|
'limit',
|
|
255
|
+
'spatial_extent_max_file_size',
|
|
255
256
|
],
|
|
256
257
|
warnings,
|
|
257
258
|
errors
|
|
@@ -281,6 +282,8 @@ export function loadAppConfig(configUrl = 'assets/configuration/default.toml') {
|
|
|
281
282
|
})),
|
|
282
283
|
ADVANCED_FILTERS: parsedSearchSection.advanced_filters,
|
|
283
284
|
LIMIT: parsedSearchSection.limit,
|
|
285
|
+
SPATIAL_EXTENT_MAX_FILE_SIZE:
|
|
286
|
+
parsedSearchSection.spatial_extent_max_file_size,
|
|
284
287
|
} as SearchConfig)
|
|
285
288
|
|
|
286
289
|
const parsedMetadataQualitySection = parseConfigSection(
|
|
@@ -7,20 +7,19 @@ import { DataItem, DatasetHeaders, FetchError, SupportedType } from './model'
|
|
|
7
7
|
import { inferDatasetType } from './utils'
|
|
8
8
|
import { BaseReader } from './readers/base'
|
|
9
9
|
import { GmlReader } from './readers/gml'
|
|
10
|
-
import { WfsVersion } from '@camptocamp/ogc-client'
|
|
11
10
|
import { WfsReader } from './readers/wfs'
|
|
12
11
|
|
|
12
|
+
interface OpenDatasetOptions {
|
|
13
|
+
typeHint?: SupportedType
|
|
14
|
+
wfsFeatureType?: string
|
|
15
|
+
enableCache?: boolean // by default cache will be used if this is not set to false
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
export async function openDataset(
|
|
14
19
|
url: string,
|
|
15
|
-
|
|
16
|
-
options?: {
|
|
17
|
-
namespace?: string
|
|
18
|
-
wfsVersion?: WfsVersion
|
|
19
|
-
wfsFeatureType?: string
|
|
20
|
-
},
|
|
21
|
-
cacheActive?: boolean
|
|
20
|
+
options?: OpenDatasetOptions
|
|
22
21
|
): Promise<BaseReader> {
|
|
23
|
-
const fileType = await inferDatasetType(url, typeHint)
|
|
22
|
+
const fileType = await inferDatasetType(url, options?.typeHint)
|
|
24
23
|
let reader:
|
|
25
24
|
| CsvReader
|
|
26
25
|
| JsonReader
|
|
@@ -43,19 +42,19 @@ export async function openDataset(
|
|
|
43
42
|
reader = new ExcelReader(url)
|
|
44
43
|
break
|
|
45
44
|
case 'gml':
|
|
46
|
-
reader = new GmlReader(url
|
|
45
|
+
reader = new GmlReader(url)
|
|
47
46
|
break
|
|
48
47
|
case 'wfs':
|
|
49
|
-
reader =
|
|
48
|
+
reader = new WfsReader(url, options?.wfsFeatureType)
|
|
50
49
|
break
|
|
51
50
|
}
|
|
52
|
-
reader.
|
|
51
|
+
reader.enableCache(options?.enableCache ?? true)
|
|
53
52
|
reader.load()
|
|
54
53
|
return reader
|
|
55
|
-
} catch (e:
|
|
56
|
-
//WfsReader may already raise a FetchError
|
|
54
|
+
} catch (e: unknown) {
|
|
55
|
+
// WfsReader may already raise a FetchError
|
|
57
56
|
if (e instanceof FetchError) throw e
|
|
58
|
-
else throw FetchError.parsingFailed(e.message)
|
|
57
|
+
else throw FetchError.parsingFailed((e as Error).message)
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
60
|
|
|
@@ -63,22 +62,20 @@ export async function openDataset(
|
|
|
63
62
|
* This fetches the full dataset at the given URL and parses it according to its mime type.
|
|
64
63
|
* All items in the dataset are converted to GeoJSON features, even if they do not bear any spatial geometry.
|
|
65
64
|
* File type can be either inferred (from the HTTP headers or the URL), or hinted using the 2nd argument
|
|
66
|
-
* File type is determined
|
|
65
|
+
* File type is determined like so:
|
|
67
66
|
* 1. if a type hint is given, use it
|
|
68
67
|
* 2. otherwise, look for a Content-Type header in the response with a supported mime type
|
|
69
68
|
* 3. if no valid mime type was found, look for an explicit file extension in the url (.csv, .geojson etc.)
|
|
70
69
|
*/
|
|
71
70
|
export async function readDataset(
|
|
72
71
|
url: string,
|
|
73
|
-
|
|
74
|
-
options?: any,
|
|
75
|
-
cacheActive = true
|
|
72
|
+
options?: OpenDatasetOptions
|
|
76
73
|
): Promise<DataItem[]> {
|
|
77
|
-
const reader = await openDataset(url,
|
|
74
|
+
const reader = await openDataset(url, options)
|
|
78
75
|
try {
|
|
79
76
|
return await reader.read()
|
|
80
|
-
} catch (e:
|
|
81
|
-
throw FetchError.parsingFailed(e.message)
|
|
77
|
+
} catch (e: unknown) {
|
|
78
|
+
throw FetchError.parsingFailed((e as Error).message)
|
|
82
79
|
}
|
|
83
80
|
}
|
|
84
81
|
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import * as duckdb from '@duckdb/duckdb-wasm'
|
|
2
|
+
import { DataItem, FetchError, PropertyInfo } from '../model'
|
|
3
|
+
import { arrowTableToDataItems } from './results'
|
|
4
|
+
import { Table } from 'apache-arrow'
|
|
5
|
+
|
|
6
|
+
// init code taken from https://github.com/duckdb/duckdb-wasm/blob/main/packages/duckdb-wasm/README.md
|
|
7
|
+
const JSDELIVR_BUNDLES = duckdb.getJsDelivrBundles()
|
|
8
|
+
|
|
9
|
+
// from https://duckdb.org/docs/current/sql/data_types/overview
|
|
10
|
+
const typesMapping: Record<string, PropertyInfo['type']> = {
|
|
11
|
+
INTEGER: 'number',
|
|
12
|
+
SMALLINT: 'number',
|
|
13
|
+
TINYINT: 'number',
|
|
14
|
+
BIGINT: 'number',
|
|
15
|
+
HUGEINT: 'number',
|
|
16
|
+
UINTEGER: 'number',
|
|
17
|
+
USMALLINT: 'number',
|
|
18
|
+
UTINYINT: 'number',
|
|
19
|
+
UBIGINT: 'number',
|
|
20
|
+
UHUGEINT: 'number',
|
|
21
|
+
DOUBLE: 'number',
|
|
22
|
+
BIGNUM: 'number',
|
|
23
|
+
DECIMAL: 'number',
|
|
24
|
+
NUMERIC: 'number',
|
|
25
|
+
FLOAT: 'number',
|
|
26
|
+
REAL: 'number',
|
|
27
|
+
'TIMESTAMP WITH TIME ZONE': 'date',
|
|
28
|
+
TIMESTAMP: 'date',
|
|
29
|
+
DATE: 'date',
|
|
30
|
+
CHAR: 'string',
|
|
31
|
+
VARCHAR: 'string',
|
|
32
|
+
TEXT: 'string',
|
|
33
|
+
UUID: 'string',
|
|
34
|
+
BLOB: 'string',
|
|
35
|
+
BIT: 'string',
|
|
36
|
+
INTERVAL: 'string',
|
|
37
|
+
LIST: 'string',
|
|
38
|
+
BOOLEAN: 'boolean',
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export class Engine {
|
|
42
|
+
private db: duckdb.AsyncDuckDB
|
|
43
|
+
private init_: Promise<Engine>
|
|
44
|
+
|
|
45
|
+
private async makeInit(): Promise<Engine> {
|
|
46
|
+
const bundle = await duckdb.selectBundle(JSDELIVR_BUNDLES)
|
|
47
|
+
let worker_url = bundle.mainWorker
|
|
48
|
+
|
|
49
|
+
// this is necessary to let browsers execute WASM code coming from a cross-origin host
|
|
50
|
+
if (worker_url.startsWith('https://')) {
|
|
51
|
+
worker_url = URL.createObjectURL(
|
|
52
|
+
new Blob([`importScripts("${worker_url}");`], {
|
|
53
|
+
type: 'text/javascript',
|
|
54
|
+
})
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
const worker = new Worker(worker_url)
|
|
58
|
+
const logger = new duckdb.ConsoleLogger(duckdb.LogLevel.WARNING)
|
|
59
|
+
this.db = new duckdb.AsyncDuckDB(logger, worker)
|
|
60
|
+
await this.db.instantiate(bundle.mainModule, bundle.pthreadWorker)
|
|
61
|
+
|
|
62
|
+
// setup duckdb options
|
|
63
|
+
const conn = await this.db.connect()
|
|
64
|
+
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
65
|
+
await conn.query(`INSTALL spatial; LOAD spatial;`)
|
|
66
|
+
await conn.query(`SET TimeZone = '${timezone}';`)
|
|
67
|
+
await conn.query(`SET threads = 1;`)
|
|
68
|
+
// await conn.query(`SET memory_limit = '2GB';`) // used for experimenting when we encounter memory issues
|
|
69
|
+
await conn.query(`SET preserve_insertion_order = false;`) // this reduces memory usage when loading a dataset
|
|
70
|
+
conn.close()
|
|
71
|
+
return this
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
isReady(): Promise<Engine> {
|
|
75
|
+
if (!this.init_) {
|
|
76
|
+
this.init_ = this.makeInit()
|
|
77
|
+
}
|
|
78
|
+
return this.init_
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Returns information about a dataset once it's loaded:
|
|
83
|
+
* - a list of properties description
|
|
84
|
+
* - the name of the dataset geometry column (null if no geometry present)
|
|
85
|
+
* @param datasetId name of the table under which the dataset will be stored
|
|
86
|
+
* @param loadQuery duckdb-specific query for creating a table out of the data
|
|
87
|
+
* @param forceReload if true, any existing data will be dropped and redownloaded
|
|
88
|
+
*/
|
|
89
|
+
async loadFile(
|
|
90
|
+
datasetId: string,
|
|
91
|
+
loadQuery: string,
|
|
92
|
+
forceReload = false
|
|
93
|
+
): Promise<{
|
|
94
|
+
properties: PropertyInfo[]
|
|
95
|
+
geometryColumn: string | null
|
|
96
|
+
rowsCount: number
|
|
97
|
+
}> {
|
|
98
|
+
const conn = await this.db.connect()
|
|
99
|
+
let results: Table
|
|
100
|
+
|
|
101
|
+
// either we want to recreate the table, or we keep it if it already exists
|
|
102
|
+
const safeLoadQuery = forceReload
|
|
103
|
+
? `DROP TABLE IF EXISTS ${datasetId};
|
|
104
|
+
${loadQuery}`
|
|
105
|
+
: loadQuery.replace(
|
|
106
|
+
/CREATE TABLE(?! IF NOT EXISTS)/gi,
|
|
107
|
+
'CREATE TABLE IF NOT EXISTS'
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
// create the table
|
|
111
|
+
try {
|
|
112
|
+
results = await conn.query(safeLoadQuery)
|
|
113
|
+
} catch (e: unknown) {
|
|
114
|
+
throw new FetchError(
|
|
115
|
+
'parse',
|
|
116
|
+
`DuckDB encountered an error when loading the data: ${(e as Error).message}`
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// read rows count
|
|
121
|
+
results = await conn.query(`SELECT count(*) FROM ${datasetId}`)
|
|
122
|
+
const { 'count_star()': recordsCount } = results.toArray()[0].toJSON()
|
|
123
|
+
|
|
124
|
+
// read columns
|
|
125
|
+
results = await conn.query(
|
|
126
|
+
`SELECT * FROM information_schema.columns WHERE table_name = '${datasetId}';`
|
|
127
|
+
)
|
|
128
|
+
let geometryColumn: string | null = null
|
|
129
|
+
|
|
130
|
+
const properties = results
|
|
131
|
+
.toArray()
|
|
132
|
+
.map((row) => {
|
|
133
|
+
const rowObj = row.toJSON()
|
|
134
|
+
if (rowObj['data_type'] === 'GEOMETRY') {
|
|
135
|
+
// the geometry is not part of the properties
|
|
136
|
+
// note: right now we only keep one geometry column name, but if there are multiple they will
|
|
137
|
+
// all get discarded
|
|
138
|
+
geometryColumn = rowObj['column_name']
|
|
139
|
+
return null
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
name: rowObj['column_name'],
|
|
143
|
+
label: rowObj['column_name'],
|
|
144
|
+
type: typesMapping[rowObj['data_type']] ?? 'other',
|
|
145
|
+
} as PropertyInfo
|
|
146
|
+
})
|
|
147
|
+
.filter((prop) => prop !== null)
|
|
148
|
+
|
|
149
|
+
conn.close()
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
properties,
|
|
153
|
+
geometryColumn,
|
|
154
|
+
rowsCount: Number(recordsCount),
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// register a Uint8 buffer using a handle in the duckdb instance
|
|
159
|
+
async registerData(name: string, buffer: Uint8Array) {
|
|
160
|
+
return this.db.registerFileBuffer(name, buffer)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @param query duckdb-specific query for fetching items
|
|
165
|
+
*/
|
|
166
|
+
async queryItems(query: string): Promise<DataItem[]> {
|
|
167
|
+
const conn = await this.db.connect()
|
|
168
|
+
const results = await conn.query(query)
|
|
169
|
+
conn.close()
|
|
170
|
+
return arrowTableToDataItems(results)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
close() {
|
|
174
|
+
this.db?.terminate()
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
let engine: Engine | null = null
|
|
179
|
+
|
|
180
|
+
export async function getEngine(): Promise<Engine> {
|
|
181
|
+
if (!engine) {
|
|
182
|
+
engine = new Engine()
|
|
183
|
+
}
|
|
184
|
+
return engine.isReady()
|
|
185
|
+
}
|