Skip to content

Commit 99398b4

Browse files
committed
Add option to base configuration for specifying the name of the geometry ID field in the WFS
1 parent 3e97ee1 commit 99398b4

3 files changed

Lines changed: 28 additions & 8 deletions

File tree

l10n/custom-data-type-nfis-geometry.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ server.config.parameter.system.nfisGeoservices.geoserver_read_username.label,Geo
3232
server.config.parameter.system.nfisGeoservices.geoserver_read_password.label,Geoserver-Account (nur Leserechte): Passwort,Geoserver account (read only): Password
3333
server.config.parameter.system.nfisGeoservices.geoserver_write_username.label,Geoserver-Account (Schreibrechte): Username,Geoserver account (write permissions): User name
3434
server.config.parameter.system.nfisGeoservices.geoserver_write_password.label,Geoserver-Account (Schreibrechte): Passwort,Geoserver account (write permissions): Password
35+
server.config.parameter.system.nfisGeoservices.wfs_geometry_id_field_name.label,Name des Geometrie-ID-Feldes im WFS,Name of the geometry ID field in the WFS
3536
server.config.parameter.system.nfisGeoservices.wfs_configuration.label,Objekttypen,Object types
3637
server.config.parameter.system.nfisGeoservices.wfs_configuration.object_type.label,Name des Objekttyps,Object type name
3738
server.config.parameter.system.nfisGeoservices.wfs_configuration.geometry_fields.label,Geometrie-Felder,Geometry fields

manifest.master.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ base_config:
5353
geoserver_write_password:
5454
type: secret
5555
position: 5
56+
wfs_geometry_id_field_name:
57+
type: text
58+
position: 6
5659
wfs_configuration:
5760
type: table
5861
fields:
@@ -136,7 +139,7 @@ base_config:
136139
position: 0
137140
position: 14
138141
position: 1
139-
position: 6
142+
position: 7
140143
masterportal_configurations:
141144
type: table
142145
fields:
@@ -149,7 +152,7 @@ base_config:
149152
- name: file_name
150153
type: text
151154
position: 2
152-
position: 7
155+
position: 8
153156

154157
callbacks:
155158
db_pre_save:

src/webfrontend/js/customDataType/contentLoader.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ export function load(contentElement, cdata, objectType, fieldPath, isMultiSelect
2020
const fieldConfiguration = getFieldConfiguration(objectType, fieldPath);
2121
if (!fieldConfiguration) return console.error('No configuration found for field path "' + fieldPath + '"');
2222

23-
const settings = { isMultiSelect, fieldConfiguration };
23+
const settings = {
24+
isMultiSelect,
25+
fieldConfiguration,
26+
geometryIdFieldName: getGeometryIdFieldName()
27+
};
28+
2429
loadWFSData(settings, cdata.geometry_ids).then(
2530
wfsData => renderContent(contentElement, cdata, settings, mode, wfsData),
2631
error => console.error(error)
@@ -161,7 +166,10 @@ function createLinkExistingGeometryButton(contentElement, cdata, settings) {
161166
}
162167

163168
function editGeometry(contentElement, cdata, settings, wfsData, uuid) {
164-
const extent = wfsData?.features.find(feature => feature.properties.ouuid === uuid)?.bbox;
169+
const extent = wfsData?.features.find(feature => {
170+
return feature.properties[settings.geometryIdFieldName] === uuid;
171+
})?.bbox;
172+
165173
if (!extent) return;
166174

167175
window.open(getEditGeometryUrl(settings, wfsData, extent), '_blank');
@@ -500,7 +508,7 @@ function configureGeometrySelection(map, contentElement, cdata, settings, wfsDat
500508
map.addInteraction(select);
501509
select.on('select', event => {
502510
const selectedGeometryId = event.selected.length > 0
503-
? event.selected[0].get('ouuid')
511+
? event.selected[0].get(settings.geometryIdFieldName)
504512
: undefined;
505513
rerenderEditorButtons(contentElement, cdata, settings, wfsData, extent, selectedGeometryId);
506514
});
@@ -562,7 +570,6 @@ function getMasterportalVectorLayerIds(fieldConfiguration, wfsData) {
562570
}
563571

564572
function getDefaultMasterportalVectorLayerId(fieldConfiguration) {
565-
566573
return fieldConfiguration.masterportal_default_vector_layer_id
567574
?.find(entry => entry.group_id === null || getUserGroupIds().includes(entry.group_id))
568575
?.layer_id;
@@ -579,7 +586,6 @@ function getMasterportalUrl() {
579586
}
580587

581588
function getConfigurationFileName() {
582-
583589
const configurationId = getUserConfiguration().masterportal_configuration;
584590
if (!configurationId?.length) return undefined;
585591

@@ -597,7 +603,9 @@ function getWfsUrl(settings, geometryIds) {
597603
return baseUrl
598604
+ '?service=WFS&version=1.1.0&request=GetFeature&typename='
599605
+ featureType
600-
+ '&outputFormat=application/json&srsname=EPSG:25832&cql_filter=ouuid in ('
606+
+ '&outputFormat=application/json&srsname=EPSG:25832&cql_filter='
607+
+ settings.geometryIdFieldName
608+
+ ' in ('
601609
+ geometryIds.map(id => '\'' + id + '\'').join(',')
602610
+ ')';
603611
}
@@ -609,6 +617,14 @@ function getAuthorizationString() {
609617
return 'Basic ' + window.btoa(username + ':' + password);
610618
}
611619

620+
function getGeometryIdFieldName() {
621+
const fieldName = getBaseConfiguration().wfs_geometry_id_field_name;
622+
623+
return fieldName?.length
624+
? fieldName
625+
: 'ouuid';
626+
}
627+
612628
function getBaseConfiguration() {
613629
return ez5.session.getBaseConfig('plugin', 'custom-data-type-nfis-geometry')['nfisGeoservices'];
614630
}

0 commit comments

Comments
 (0)