@geogirafe/lib-geoportal 1.3.0-dev.3046054236 → 1.3.0-dev.3060317043
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/LICENSE +1 -0
- package/README.md +3 -2
- package/api/apigeogirafeapp.js +3 -1
- package/assets/i18n/de.json +34 -3
- package/assets/i18n/en.json +33 -2
- package/assets/i18n/fr.json +35 -4
- package/assets/i18n/it.json +37 -6
- package/assets/icons/edit.svg +1 -1
- package/assets/icons/lock.svg +1 -0
- package/assets/icons/streetview-marker-mapillary.svg +1 -0
- package/components/cross-section/cross-section-settings/component.js +1 -1
- package/components/edit/component.d.ts +52 -36
- package/components/edit/component.js +340 -292
- package/components/edit/editcomponentstate.d.ts +1 -0
- package/components/edit/editcomponentstate.js +1 -0
- package/components/edit/editform/component.d.ts +34 -4
- package/components/edit/editform/component.js +224 -37
- package/components/edit/editform/style.css +51 -16
- package/components/edit/geometryedithelper.d.ts +47 -0
- package/components/edit/geometryedithelper.js +324 -0
- package/components/edit/style.css +71 -28
- package/components/layout/component.d.ts +5 -0
- package/components/main.d.ts +1 -1
- package/components/main.js +1 -1
- package/components/map-grid/component.d.ts +4 -0
- package/components/map-grid/component.js +6 -0
- package/components/print/component.d.ts +1 -1
- package/components/streetview/component.d.ts +9 -2
- package/components/streetview/component.js +20 -8
- package/components/streetview/google.js +1 -1
- package/components/streetview/mapillary.d.ts +8 -0
- package/components/streetview/mapillary.js +20 -0
- package/components/streetview/style.css +16 -0
- package/components/streetview/tools/googleprovider.js +9 -2
- package/components/streetview/tools/mapillaryprovider.d.ts +70 -0
- package/components/streetview/tools/mapillaryprovider.js +150 -0
- package/components/treeview/tools/treeviewelement.d.ts +1 -0
- package/components/treeview/tools/treeviewelement.js +22 -0
- package/components/treeview/treeviewitem/component.js +7 -1
- package/models/gmf.d.ts +18 -2
- package/models/gmf.js +3 -1
- package/models/layers/editablelayer.d.ts +7 -0
- package/models/layers/editablelayer.js +7 -0
- package/models/layers/layerwms.d.ts +1 -2
- package/models/layers/layerwms.js +4 -8
- package/models/main.d.ts +9 -4
- package/models/main.js +6 -2
- package/models/oapiflayer.d.ts +25 -0
- package/models/oapiflayer.js +36 -0
- package/models/oapiftypes.d.ts +71 -0
- package/models/oapiftypes.js +29 -0
- package/models/serverogc.d.ts +5 -3
- package/models/serverogc.js +19 -6
- package/models/serverogcapi.d.ts +2 -0
- package/models/serverogcapi.js +2 -0
- package/models/serverogcapifeatures.d.ts +5 -62
- package/models/serverogcapifeatures.js +8 -4
- package/package.json +1 -1
- package/templates/iframe.html +1 -0
- package/templates/index.html +2 -0
- package/templates/mobile.html +1 -0
- package/templates/public/about.json +1 -1
- package/tools/app/geogirafeapp-mobile.js +2 -0
- package/tools/app/geogirafeapp.js +4 -2
- package/tools/configuration/girafeconfig.js +1 -8
- package/tools/configuration/streetviewconfig.d.ts +12 -1
- package/tools/configuration/streetviewconfig.js +26 -4
- package/tools/drawing/olDrawing.js +2 -22
- package/tools/drawing/shapeConstraints.d.ts +2 -1
- package/tools/drawing/shapeConstraints.js +18 -2
- package/tools/main.d.ts +9 -7
- package/tools/main.js +8 -6
- package/tools/ogcapi/ogcapiclient.d.ts +7 -3
- package/tools/ogcapi/ogcapiclient.js +49 -4
- package/tools/ogcapi/ogcapiconformance.d.ts +2 -2
- package/tools/ogcapi/ogcapiconformance.js +7 -13
- package/tools/ogcapi/ogcapifeaturesclient.d.ts +65 -30
- package/tools/ogcapi/ogcapifeaturesclient.js +265 -139
- package/tools/ogcapi/ogcapifeaturesclientgeorama.d.ts +0 -5
- package/tools/ogcapi/ogcapifeaturesclientgeorama.js +0 -11
- package/tools/ogcapi/ogcapifeaturesclientqgis.d.ts +8 -0
- package/tools/ogcapi/ogcapifeaturesclientqgis.js +13 -0
- package/tools/ogcapi/ogcapifeaturesmanager.d.ts +61 -8
- package/tools/ogcapi/ogcapifeaturesmanager.js +179 -30
- package/tools/ogcapi/ogcapifeaturesschema.d.ts +31 -13
- package/tools/ogcapi/ogcapifeaturesschema.js +69 -39
- package/tools/ogcapi/ogcapifeaturesschemaproperty.d.ts +44 -0
- package/tools/ogcapi/ogcapifeaturesschemaproperty.js +137 -0
- package/tools/ogcapi/ogcapifeaturesschemavalidator.d.ts +22 -0
- package/tools/ogcapi/ogcapifeaturesschemavalidator.js +121 -0
- package/tools/state/layout.d.ts +5 -0
- package/tools/state/layout.js +2 -1
- package/tools/state/state.d.ts +6 -0
- package/tools/state/state.js +4 -0
- package/tools/state/streetview.d.ts +1 -1
- package/tools/state/streetview.js +1 -1
- package/tools/themes/themesmanager.d.ts +10 -3
- package/tools/themes/themesmanager.js +29 -9
- package/tools/time/layertimeformatter.d.ts +0 -5
- package/tools/time/layertimeformatter.js +10 -19
- package/tools/utils/dateutils.d.ts +40 -0
- package/tools/utils/dateutils.js +111 -0
- package/tools/utils/utils.d.ts +4 -0
- package/tools/utils/utils.js +12 -0
- package/tools/wfs/wfsmanager.js +3 -0
- package/tools/wms/wmsclient.d.ts +1 -0
- package/tools/wms/wmsclient.js +4 -0
- package/tools/ogcapi/demolayers.d.ts +0 -1
- package/tools/ogcapi/demolayers.js +0 -99
- package/tools/ogcapi/ogcapifeaturesclientgmf.d.ts +0 -13
- package/tools/ogcapi/ogcapifeaturesclientgmf.js +0 -30
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Feature } from 'ol';
|
|
2
2
|
import { Geometry } from 'ol/geom.js';
|
|
3
3
|
import OgcApiFeaturesClient from './ogcapifeaturesclient.js';
|
|
4
|
-
import
|
|
5
|
-
import ServerOgcApiFeatures, { OapifCollection, OapifLayer } from '../../models/serverogcapifeatures.js';
|
|
6
|
-
import OgcApiFeaturesSchema from './ogcapifeaturesschema.js';
|
|
4
|
+
import ServerOgcApiFeatures from '../../models/serverogcapifeatures.js';
|
|
7
5
|
import ServerOgc from '../../models/serverogc.js';
|
|
6
|
+
import { OapifLayer } from '../../models/oapiflayer.js';
|
|
8
7
|
import VendorSpecificOgcServerManager from '../vendorspecificogcservermanager.js';
|
|
9
8
|
import { OgcApiClientOptions } from './ogcapiclient.js';
|
|
9
|
+
import { OapifCollection } from '../../models/oapiftypes.js';
|
|
10
|
+
import { EditableLayer } from '../../models/layers/editablelayer.js';
|
|
10
11
|
/**
|
|
11
12
|
* Manages interaction between the GG and an OGC API Features client (OAPIF).
|
|
12
13
|
*/
|
|
@@ -14,13 +15,65 @@ export default class OgcApiFeaturesManager extends VendorSpecificOgcServerManage
|
|
|
14
15
|
protected get state(): import("../main.js").State;
|
|
15
16
|
getClientId(ogcServer: ServerOgc): string;
|
|
16
17
|
initializeSingleton(): Promise<void>;
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Creates a map of all available editable layers. Note that the OapifLayer object might not be complete
|
|
20
|
+
* because the `collections` endpoint returns a subset of all available collection properties.
|
|
21
|
+
*/
|
|
22
|
+
collectEditableLayers(): Promise<Map<string, OapifLayer>>;
|
|
23
|
+
/**
|
|
24
|
+
* Checks if a layer is editable by determining whether it is associated with any OAPIF collections.
|
|
25
|
+
* The matching is based on the identifiers specified in the WMS layer's `layers` property, not the layer's ID or name.
|
|
26
|
+
* This follows the same pattern as matching WMS layers with WFS feature types when querying.
|
|
27
|
+
*/
|
|
28
|
+
getEditableLayerNames(layer: EditableLayer): Promise<string[] | undefined>;
|
|
29
|
+
/**
|
|
30
|
+
* Enriches an OapifLayer object with additional information needed for editing purposes:
|
|
31
|
+
* Schema, GeometryType, GeometryLayout, StorageCrs.
|
|
32
|
+
* If unsuccessful, shows a blocking alert message.
|
|
33
|
+
*/
|
|
34
|
+
analyseLayerForEditing(layer: OapifLayer): Promise<OapifLayer>;
|
|
35
|
+
private getSchema;
|
|
36
|
+
/**
|
|
37
|
+
* Collect data used as references, for example, a list of foreign keys or a value map in another collection.
|
|
38
|
+
*/
|
|
39
|
+
private collectReferenceData;
|
|
40
|
+
/**
|
|
41
|
+
* Get single collection. If unsuccessful, shows a non-blocking error message.
|
|
42
|
+
*/
|
|
43
|
+
getCollection(layer: OapifLayer): Promise<OapifCollection | undefined>;
|
|
44
|
+
/**
|
|
45
|
+
* Get items. If unsuccessful, shows a non-blocking error message.
|
|
46
|
+
*/
|
|
47
|
+
getItems(layer: OapifLayer, options?: {
|
|
48
|
+
crsCode?: string;
|
|
49
|
+
bbox?: number[];
|
|
50
|
+
limit?: number;
|
|
51
|
+
}): Promise<Feature<Geometry>[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Get single item. If unsuccessful, shows a non-blocking error message.
|
|
54
|
+
*/
|
|
19
55
|
getItem(layer: OapifLayer, featureId: string): Promise<Feature<Geometry> | undefined>;
|
|
56
|
+
/**
|
|
57
|
+
* Create item. If unsuccessful, shows a blocking alert message.
|
|
58
|
+
*/
|
|
20
59
|
createItem(layer: OapifLayer, feature: Feature<Geometry>): Promise<boolean>;
|
|
21
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Replace item. If unsuccessful, shows a blocking alert message.
|
|
62
|
+
*/
|
|
63
|
+
replaceItem(layer: OapifLayer, featureId: string, feature: Feature<Geometry>): Promise<boolean>;
|
|
64
|
+
/**
|
|
65
|
+
* Delete item. If unsuccessful, shows a blocking alert message.
|
|
66
|
+
*/
|
|
22
67
|
deleteItem(layer: OapifLayer, featureId: string): Promise<boolean>;
|
|
23
68
|
getServer(ogcServer: ServerOgc): Promise<ServerOgcApiFeatures>;
|
|
24
|
-
getServer(layer:
|
|
25
|
-
|
|
69
|
+
getServer(layer: EditableLayer): Promise<ServerOgcApiFeatures>;
|
|
70
|
+
/**
|
|
71
|
+
* Tries to get the OAPIF server used for editing.
|
|
72
|
+
*/
|
|
73
|
+
tryGetServer(ogcServer: ServerOgc): Promise<ServerOgcApiFeatures | undefined>;
|
|
74
|
+
/**
|
|
75
|
+
* Fetches a list of foreign keys from a specified collection in a given server.
|
|
76
|
+
*/
|
|
77
|
+
private fetchForeignKeyList;
|
|
78
|
+
private i18n;
|
|
26
79
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import OgcApiFeaturesClient from './ogcapifeaturesclient.js';
|
|
2
2
|
import OgcApiFeaturesClientGeorama from './ogcapifeaturesclientgeorama.js';
|
|
3
|
-
import
|
|
4
|
-
import LayerWms from '../../models/layers/layerwms.js';
|
|
3
|
+
import OgcApiFeaturesClientQgis from './ogcapifeaturesclientqgis.js';
|
|
5
4
|
import OgcApiFeaturesSchema from './ogcapifeaturesschema.js';
|
|
5
|
+
import ServerOgc from '../../models/serverogc.js';
|
|
6
|
+
import { OapifLayer } from '../../models/oapiflayer.js';
|
|
6
7
|
import VendorSpecificOgcServerManager from '../vendorspecificogcservermanager.js';
|
|
7
8
|
/**
|
|
8
9
|
* Manages interaction between the GG and an OGC API Features client (OAPIF).
|
|
@@ -12,97 +13,245 @@ export default class OgcApiFeaturesManager extends VendorSpecificOgcServerManage
|
|
|
12
13
|
return this.context.stateManager.state;
|
|
13
14
|
}
|
|
14
15
|
getClientId(ogcServer) {
|
|
15
|
-
return ogcServer.
|
|
16
|
+
return ogcServer.services.edit?.url ?? '';
|
|
16
17
|
}
|
|
17
18
|
async initializeSingleton() {
|
|
18
19
|
// Register the clients
|
|
19
20
|
this.registerClientClass('default', OgcApiFeaturesClient);
|
|
20
21
|
this.registerClientClass('georama', OgcApiFeaturesClientGeorama);
|
|
21
|
-
this.registerClientClass('
|
|
22
|
+
this.registerClientClass('qgisserver', OgcApiFeaturesClientQgis);
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Creates a map of all available editable layers. Note that the OapifLayer object might not be complete
|
|
26
|
+
* because the `collections` endpoint returns a subset of all available collection properties.
|
|
27
|
+
*/
|
|
28
|
+
async collectEditableLayers() {
|
|
29
|
+
const editableLayersList = new Map();
|
|
30
|
+
const editServers = Object.values(this.state.ogcServers).filter((server) => server.hasEditService);
|
|
31
|
+
const serverResults = await Promise.all(editServers.map(async (server) => {
|
|
32
|
+
try {
|
|
33
|
+
const serverDetails = await this.getServer(server);
|
|
34
|
+
return { server, serverDetails };
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
40
|
+
for (const result of serverResults) {
|
|
41
|
+
if (!result)
|
|
42
|
+
continue;
|
|
43
|
+
for (const collection of result.serverDetails.collections.values()) {
|
|
44
|
+
const oapifLayer = new OapifLayer(result.server, collection);
|
|
45
|
+
editableLayersList.set(result.server.getUniqueLayerName(oapifLayer.id), oapifLayer);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return editableLayersList;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Checks if a layer is editable by determining whether it is associated with any OAPIF collections.
|
|
52
|
+
* The matching is based on the identifiers specified in the WMS layer's `layers` property, not the layer's ID or name.
|
|
53
|
+
* This follows the same pattern as matching WMS layers with WFS feature types when querying.
|
|
54
|
+
*/
|
|
55
|
+
async getEditableLayerNames(layer) {
|
|
56
|
+
const queryAndEditLayers = layer.layers?.split(',');
|
|
57
|
+
if (!queryAndEditLayers?.length)
|
|
58
|
+
return undefined;
|
|
59
|
+
const server = await this.tryGetServer(layer.ogcServer);
|
|
60
|
+
if (!server)
|
|
61
|
+
return undefined;
|
|
62
|
+
const editLayerNames = queryAndEditLayers
|
|
63
|
+
.filter((editLayerName) => server.collections.has(editLayerName))
|
|
64
|
+
// Add a server name prefix to the editable layer name for uniqueness
|
|
65
|
+
.map((editLayerName) => layer.ogcServer.getUniqueLayerName(editLayerName));
|
|
66
|
+
return editLayerNames.length ? editLayerNames : undefined;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Enriches an OapifLayer object with additional information needed for editing purposes:
|
|
70
|
+
* Schema, GeometryType, GeometryLayout, StorageCrs.
|
|
71
|
+
* If unsuccessful, shows a blocking alert message.
|
|
72
|
+
*/
|
|
73
|
+
async analyseLayerForEditing(layer) {
|
|
25
74
|
try {
|
|
26
|
-
const
|
|
27
|
-
|
|
75
|
+
const client = this.getClient(layer.server);
|
|
76
|
+
layer.schema = await this.getSchema(layer);
|
|
77
|
+
layer.permissions = await client.checkCRUDPermissions(layer.id);
|
|
78
|
+
layer.geometryLayout = (await client.getGeometryLayout(layer.id)) ?? 'XY';
|
|
79
|
+
if (!layer.storageCrs) {
|
|
80
|
+
layer.storageCrs = await client.getCollectionStorageCrsCode(layer.id);
|
|
81
|
+
}
|
|
28
82
|
}
|
|
29
83
|
catch (e) {
|
|
30
|
-
|
|
84
|
+
void window.gAlert(`${this.i18n('The layer is not set up correctly for editing')}:<br>${e}`, 'Error');
|
|
85
|
+
}
|
|
86
|
+
return layer;
|
|
87
|
+
}
|
|
88
|
+
async getSchema(layer, fetchReferences = true) {
|
|
89
|
+
this.state.loading = true;
|
|
90
|
+
try {
|
|
91
|
+
const schemaResponse = await this.getClient(layer.server).getSchema(layer.id);
|
|
92
|
+
const schema = new OgcApiFeaturesSchema(schemaResponse);
|
|
93
|
+
if (fetchReferences) {
|
|
94
|
+
await this.collectReferenceData(layer, schema);
|
|
95
|
+
}
|
|
96
|
+
return schema;
|
|
31
97
|
}
|
|
32
98
|
finally {
|
|
33
99
|
this.state.loading = false;
|
|
34
100
|
}
|
|
35
101
|
}
|
|
36
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Collect data used as references, for example, a list of foreign keys or a value map in another collection.
|
|
104
|
+
*/
|
|
105
|
+
async collectReferenceData(layer, schema) {
|
|
106
|
+
await Promise.all(schema.propertiesWithReference.map(async (referenceProperty) => {
|
|
107
|
+
const referenceCollectionId = referenceProperty.internalReference;
|
|
108
|
+
const referenceList = referenceCollectionId
|
|
109
|
+
? await this.fetchForeignKeyList(layer.server, referenceCollectionId)
|
|
110
|
+
: [];
|
|
111
|
+
referenceProperty.setReferenceList(referenceList);
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get single collection. If unsuccessful, shows a non-blocking error message.
|
|
116
|
+
*/
|
|
117
|
+
async getCollection(layer) {
|
|
118
|
+
try {
|
|
119
|
+
this.state.loading = true;
|
|
120
|
+
return await this.getClient(layer.server).getCollection(layer.id);
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
this.context.errorManager.pushMessage('oapif-get-collection', 'Failed to load layer data', 'error');
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
finally {
|
|
127
|
+
this.state.loading = false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Get items. If unsuccessful, shows a non-blocking error message.
|
|
132
|
+
*/
|
|
133
|
+
async getItems(layer, options = {}) {
|
|
37
134
|
this.state.loading = true;
|
|
38
135
|
try {
|
|
39
|
-
return await this.getClient(layer.server).getItems(layer.
|
|
136
|
+
return await this.getClient(layer.server).getItems(layer.id, options);
|
|
40
137
|
}
|
|
41
138
|
catch {
|
|
139
|
+
this.context.errorManager.pushMessage('oapif-get-items', 'Failed to load items', 'error');
|
|
42
140
|
return [];
|
|
43
141
|
}
|
|
44
142
|
finally {
|
|
45
143
|
this.state.loading = false;
|
|
46
144
|
}
|
|
47
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Get single item. If unsuccessful, shows a non-blocking error message.
|
|
148
|
+
*/
|
|
48
149
|
async getItem(layer, featureId) {
|
|
49
150
|
this.state.loading = true;
|
|
50
151
|
try {
|
|
51
|
-
return await this.getClient(layer.server).getItem(layer.
|
|
152
|
+
return await this.getClient(layer.server).getItem(layer.id, featureId, this.state.projection);
|
|
52
153
|
}
|
|
53
154
|
catch {
|
|
54
|
-
|
|
155
|
+
this.context.errorManager.pushMessage('oapif-get-items', 'Failed to load items', 'error');
|
|
55
156
|
}
|
|
56
157
|
finally {
|
|
57
158
|
this.state.loading = false;
|
|
58
159
|
}
|
|
59
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Create item. If unsuccessful, shows a blocking alert message.
|
|
163
|
+
*/
|
|
60
164
|
async createItem(layer, feature) {
|
|
61
165
|
this.state.loading = true;
|
|
62
166
|
try {
|
|
63
|
-
return await this.getClient(layer.server).createItem(layer.
|
|
167
|
+
return await this.getClient(layer.server).createItem(layer.id, feature, this.state.projection);
|
|
64
168
|
}
|
|
65
|
-
catch {
|
|
66
|
-
void window.gAlert('Failed to create feature'
|
|
67
|
-
return false;
|
|
169
|
+
catch (e) {
|
|
170
|
+
void window.gAlert(`${this.i18n('Failed to create feature')}:<br>${e}`, 'Error');
|
|
68
171
|
}
|
|
69
172
|
finally {
|
|
70
173
|
this.state.loading = false;
|
|
71
174
|
}
|
|
175
|
+
return false;
|
|
72
176
|
}
|
|
73
|
-
|
|
177
|
+
/**
|
|
178
|
+
* Replace item. If unsuccessful, shows a blocking alert message.
|
|
179
|
+
*/
|
|
180
|
+
async replaceItem(layer, featureId, feature) {
|
|
74
181
|
this.state.loading = true;
|
|
75
182
|
try {
|
|
76
|
-
return await this.getClient(layer.server).
|
|
183
|
+
return await this.getClient(layer.server).replaceItem(layer.id, featureId, feature, this.state.projection);
|
|
77
184
|
}
|
|
78
|
-
catch {
|
|
79
|
-
void window.gAlert('Failed to update feature'
|
|
80
|
-
return false;
|
|
185
|
+
catch (e) {
|
|
186
|
+
void window.gAlert(`${this.i18n('Failed to update feature')}:<br>${e}`, 'Error');
|
|
81
187
|
}
|
|
82
188
|
finally {
|
|
83
189
|
this.state.loading = false;
|
|
84
190
|
}
|
|
191
|
+
return false;
|
|
85
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* Delete item. If unsuccessful, shows a blocking alert message.
|
|
195
|
+
*/
|
|
86
196
|
async deleteItem(layer, featureId) {
|
|
87
197
|
this.state.loading = true;
|
|
88
198
|
try {
|
|
89
|
-
return await this.getClient(layer.server).deleteItem(layer.
|
|
199
|
+
return await this.getClient(layer.server).deleteItem(layer.id, featureId);
|
|
90
200
|
}
|
|
91
|
-
catch {
|
|
92
|
-
void window.gAlert('Failed to delete feature'
|
|
93
|
-
return false;
|
|
201
|
+
catch (e) {
|
|
202
|
+
void window.gAlert(`${this.i18n('Failed to delete feature')}:<br>${e}`, 'Error');
|
|
94
203
|
}
|
|
95
204
|
finally {
|
|
96
205
|
this.state.loading = false;
|
|
97
206
|
}
|
|
207
|
+
return false;
|
|
98
208
|
}
|
|
99
209
|
async getServer(object) {
|
|
100
|
-
const ogcServer = object instanceof
|
|
210
|
+
const ogcServer = object instanceof ServerOgc ? object : object.ogcServer;
|
|
101
211
|
const client = this.getClient(ogcServer);
|
|
102
212
|
return client.getServer();
|
|
103
213
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
214
|
+
/**
|
|
215
|
+
* Tries to get the OAPIF server used for editing.
|
|
216
|
+
*/
|
|
217
|
+
async tryGetServer(ogcServer) {
|
|
218
|
+
try {
|
|
219
|
+
return await this.getServer(ogcServer);
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
console.error(`OAPIF server ${ogcServer.name} could not be loaded:`, error);
|
|
223
|
+
const message = this.i18n('The edit service of the OGC server _server_ could not be loaded').replace('_server_', ogcServer.name);
|
|
224
|
+
this.context.errorManager.pushMessage(`oapif-server-${ogcServer.name}`, message, 'error');
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Fetches a list of foreign keys from a specified collection in a given server.
|
|
230
|
+
*/
|
|
231
|
+
async fetchForeignKeyList(server, referenceCollectionId) {
|
|
232
|
+
try {
|
|
233
|
+
const client = this.getClient(server);
|
|
234
|
+
const items = await client.getItems(referenceCollectionId);
|
|
235
|
+
const schemaResponse = await client.getSchema(referenceCollectionId);
|
|
236
|
+
const schema = new OgcApiFeaturesSchema(schemaResponse);
|
|
237
|
+
return items
|
|
238
|
+
.filter((item) => !!item.getId())
|
|
239
|
+
.map((item) => {
|
|
240
|
+
const title = schema.titlePropertyNameCandidate
|
|
241
|
+
? item.getProperties()[schema.titlePropertyNameCandidate]
|
|
242
|
+
: undefined;
|
|
243
|
+
return {
|
|
244
|
+
value: item.getId(),
|
|
245
|
+
title: title ? `${item.getId()}: ${title}` : `${item.getId()}`
|
|
246
|
+
};
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
catch (error) {
|
|
250
|
+
console.warn(`Error fetching data from referenced collection ${referenceCollectionId}. ${error}`);
|
|
251
|
+
return [];
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
i18n(key) {
|
|
255
|
+
return this.context.i18nManager.getTranslation(key);
|
|
107
256
|
}
|
|
108
257
|
}
|
|
@@ -1,22 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OgcApiFeaturesSchemaProperty } from './ogcapifeaturesschemaproperty.js';
|
|
2
|
+
import { OapifSchemaResponse } from '../../models/oapiftypes.js';
|
|
3
|
+
import { Type as olGeometryType } from 'ol/geom/Geometry.js';
|
|
2
4
|
/**
|
|
3
5
|
* Represents the schema for an OGC API collection feature.
|
|
4
6
|
*/
|
|
5
7
|
export default class OgcApiFeaturesSchema {
|
|
8
|
+
readonly id: string;
|
|
6
9
|
private readonly schema;
|
|
7
|
-
|
|
10
|
+
properties: OgcApiFeaturesSchemaProperty[];
|
|
8
11
|
constructor(schema: OapifSchemaResponse);
|
|
9
12
|
/**
|
|
10
|
-
*
|
|
13
|
+
* Returns the properties that should be included in the form.
|
|
11
14
|
*/
|
|
12
|
-
get
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
get formProperties(): OgcApiFeaturesSchemaProperty[];
|
|
16
|
+
/**
|
|
17
|
+
* Generates a template object based on the schema's properties, excluding properties that don't belong in the form.
|
|
18
|
+
*/
|
|
19
|
+
get formDataTemplate(): Record<string, number | string | boolean | null>;
|
|
20
|
+
get pkPropertyName(): string;
|
|
21
|
+
/**
|
|
22
|
+
* Retrieves the name of the geometry property.
|
|
23
|
+
* Falls back to the first geometry property if no primary geometry is defined.
|
|
24
|
+
*/
|
|
25
|
+
get geometryPropertyName(): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves the geometry type of the primary geometry.
|
|
28
|
+
* Throws an error if the geometry type is missing or not supported.
|
|
29
|
+
*/
|
|
30
|
+
get geometryType(): olGeometryType | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Get properties that point to a reference.
|
|
33
|
+
*/
|
|
34
|
+
get propertiesWithReference(): OgcApiFeaturesSchemaProperty[];
|
|
35
|
+
/**
|
|
36
|
+
* Tries to guess the attribute that can be used as a human-readable and identifiable name. Returns the first
|
|
37
|
+
* editable text attribute that isn't the primary key or undefined.
|
|
38
|
+
*/
|
|
39
|
+
get titlePropertyNameCandidate(): string | undefined;
|
|
22
40
|
}
|
|
@@ -1,62 +1,92 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
import {
|
|
2
|
+
import { OgcApiFeaturesSchemaProperty } from './ogcapifeaturesschemaproperty.js';
|
|
3
|
+
import { supportedGeometryTypesForEditing } from '../../models/oapiftypes.js';
|
|
3
4
|
/**
|
|
4
5
|
* Represents the schema for an OGC API collection feature.
|
|
5
6
|
*/
|
|
6
7
|
export default class OgcApiFeaturesSchema {
|
|
8
|
+
id;
|
|
7
9
|
schema;
|
|
8
|
-
|
|
10
|
+
properties = [];
|
|
9
11
|
constructor(schema) {
|
|
12
|
+
this.id = schema.$id;
|
|
10
13
|
this.schema = schema;
|
|
11
|
-
// Extract all attributes that can be edited in a form
|
|
12
14
|
for (const [key, properties] of Object.entries(this.schema.properties)) {
|
|
13
|
-
|
|
14
|
-
continue;
|
|
15
|
-
this.formAttributes.push([key, this.setDefaults(key, properties)]);
|
|
15
|
+
this.properties.push(new OgcApiFeaturesSchemaProperty(key, properties, this.schema.required?.includes(key)));
|
|
16
16
|
}
|
|
17
17
|
// Sort the attributes according to sequence information (if present)
|
|
18
|
-
this.
|
|
18
|
+
this.properties.sort((a, b) => {
|
|
19
|
+
if (a.sortOrder === null && b.sortOrder === null)
|
|
20
|
+
return 0;
|
|
21
|
+
if (a.sortOrder === null)
|
|
22
|
+
return 1;
|
|
23
|
+
if (b.sortOrder === null)
|
|
24
|
+
return -1;
|
|
25
|
+
return a.sortOrder - b.sortOrder;
|
|
26
|
+
});
|
|
19
27
|
}
|
|
20
28
|
/**
|
|
21
|
-
*
|
|
29
|
+
* Returns the properties that should be included in the form.
|
|
22
30
|
*/
|
|
23
|
-
get
|
|
24
|
-
return
|
|
25
|
-
.filter(([_, properties]) => !this.isGeometry(properties) && !this.isPrimaryKey(properties))
|
|
26
|
-
.map(([key, _]) => [key, null]));
|
|
31
|
+
get formProperties() {
|
|
32
|
+
return this.properties.filter((property) => property.isFormProperty);
|
|
27
33
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Generates a template object based on the schema's properties, excluding properties that don't belong in the form.
|
|
36
|
+
*/
|
|
37
|
+
get formDataTemplate() {
|
|
38
|
+
return Object.fromEntries(this.formProperties.map((property) => [property.name, null]));
|
|
31
39
|
}
|
|
32
|
-
get
|
|
33
|
-
const
|
|
40
|
+
get pkPropertyName() {
|
|
41
|
+
const property = this.properties.find((property) => property.isPrimaryKey);
|
|
42
|
+
if (!property) {
|
|
43
|
+
console.warn('OGC API Features Schema: The primary key property is not defined, falling back to `id`');
|
|
44
|
+
}
|
|
45
|
+
return property ? property.name : 'id';
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves the name of the geometry property.
|
|
49
|
+
* Falls back to the first geometry property if no primary geometry is defined.
|
|
50
|
+
*/
|
|
51
|
+
get geometryPropertyName() {
|
|
52
|
+
const geometryAttributes = this.properties.filter((property) => property.isGeometry);
|
|
34
53
|
if (geometryAttributes.length === 0)
|
|
35
54
|
return undefined;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const primaryGeometry = geometryAttributes.find(([_, properties]) => properties['x-ogc-role'] === 'primary-geometry');
|
|
39
|
-
return primaryGeometry ? primaryGeometry[0] : undefined;
|
|
40
|
-
}
|
|
41
|
-
getProperties(attributeName) {
|
|
42
|
-
return this.schema.properties[attributeName];
|
|
43
|
-
}
|
|
44
|
-
isTextProperty(attributeName) {
|
|
45
|
-
return oapifTextTypes.includes(this.getProperties(attributeName).type ?? '');
|
|
46
|
-
}
|
|
47
|
-
isNumericProperty(attributeName) {
|
|
48
|
-
return oapifNumericTypes.includes(this.getProperties(attributeName).type ?? '');
|
|
49
|
-
}
|
|
50
|
-
isTemporalProperty(attributeName) {
|
|
51
|
-
return oapifTemporalTypes.includes(this.getProperties(attributeName).type ?? '');
|
|
55
|
+
const primaryGeometry = geometryAttributes.find((property) => property.isPrimaryGeometry);
|
|
56
|
+
return primaryGeometry?.name ?? geometryAttributes[0].name;
|
|
52
57
|
}
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Retrieves the geometry type of the primary geometry.
|
|
60
|
+
* Throws an error if the geometry type is missing or not supported.
|
|
61
|
+
*/
|
|
62
|
+
get geometryType() {
|
|
63
|
+
const geomFormat = this.properties.find((prop) => prop.name === this.geometryPropertyName)?.format;
|
|
64
|
+
if (!geomFormat) {
|
|
65
|
+
console.error(`The schema does not define a geometry property.`);
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
const geomType = geomFormat.split('-')[1] ?? '';
|
|
69
|
+
if (geomType.toLowerCase() === 'any') {
|
|
70
|
+
// If there is no specific geometry type specified, fallback to point for now
|
|
71
|
+
return 'Point';
|
|
72
|
+
}
|
|
73
|
+
const supportedGeomType = supportedGeometryTypesForEditing.find((sgt) => sgt.toLowerCase() === geomType.toLowerCase());
|
|
74
|
+
if (!supportedGeomType) {
|
|
75
|
+
console.error(`Unsupported geometry type "${geomFormat}"`);
|
|
76
|
+
}
|
|
77
|
+
return supportedGeomType;
|
|
55
78
|
}
|
|
56
|
-
|
|
57
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Get properties that point to a reference.
|
|
81
|
+
*/
|
|
82
|
+
get propertiesWithReference() {
|
|
83
|
+
return this.properties.filter((property) => property.hasReference);
|
|
58
84
|
}
|
|
59
|
-
|
|
60
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Tries to guess the attribute that can be used as a human-readable and identifiable name. Returns the first
|
|
87
|
+
* editable text attribute that isn't the primary key or undefined.
|
|
88
|
+
*/
|
|
89
|
+
get titlePropertyNameCandidate() {
|
|
90
|
+
return (this.properties.find((attr) => attr.isTextProperty && !attr.isPrimaryKey && !attr.isReadOnly)?.name ?? undefined);
|
|
61
91
|
}
|
|
62
92
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { OapifReferenceList, OapifSchemaPropertyOptions } from '../../models/oapiftypes.js';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a schema property in the context of an OGC API Features implementation.
|
|
4
|
+
* This class defines characteristics and metadata for a property, including type, role, and other attributes.
|
|
5
|
+
*/
|
|
6
|
+
export declare class OgcApiFeaturesSchemaProperty {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly isRequired: boolean;
|
|
9
|
+
private readonly options;
|
|
10
|
+
private referenceList;
|
|
11
|
+
constructor(name: string, options: OapifSchemaPropertyOptions, required?: boolean);
|
|
12
|
+
get title(): string;
|
|
13
|
+
get description(): string | undefined;
|
|
14
|
+
get propertyType(): string | undefined;
|
|
15
|
+
get format(): string | undefined;
|
|
16
|
+
get minLength(): number | undefined;
|
|
17
|
+
get maxLength(): number | undefined;
|
|
18
|
+
get pattern(): string | undefined;
|
|
19
|
+
get minimum(): number | undefined;
|
|
20
|
+
get maximum(): number | undefined;
|
|
21
|
+
get exclusiveMinimum(): number | undefined;
|
|
22
|
+
get exclusiveMaximum(): number | undefined;
|
|
23
|
+
get isTextProperty(): boolean;
|
|
24
|
+
get isNumericProperty(): boolean;
|
|
25
|
+
isIntegerProperty(): boolean;
|
|
26
|
+
get isBooleanProperty(): boolean;
|
|
27
|
+
get isTemporalProperty(): boolean;
|
|
28
|
+
get isValueListProperty(): boolean;
|
|
29
|
+
get isFormProperty(): boolean;
|
|
30
|
+
get sortOrder(): number | null;
|
|
31
|
+
get isGeometry(): boolean;
|
|
32
|
+
get isPrimaryGeometry(): boolean;
|
|
33
|
+
get isPrimaryKey(): boolean;
|
|
34
|
+
get isReadOnly(): boolean;
|
|
35
|
+
get valueListEntries(): {
|
|
36
|
+
value: string | number;
|
|
37
|
+
title: string;
|
|
38
|
+
}[] | undefined;
|
|
39
|
+
get hasReference(): boolean;
|
|
40
|
+
get internalReference(): string | undefined;
|
|
41
|
+
isNullValue(value: string | number | boolean | null | undefined): boolean;
|
|
42
|
+
setReferenceList(referenceList: OapifReferenceList[] | string[] | number[]): void;
|
|
43
|
+
private parseNumber;
|
|
44
|
+
}
|