diff --git a/packages/clients/diplan/example/dev/config.js b/packages/clients/diplan/example/dev/config.js index 2fe63731..806fc3c3 100644 --- a/packages/clients/diplan/example/dev/config.js +++ b/packages/clients/diplan/example/dev/config.js @@ -11,6 +11,17 @@ export default { extent: [ 248651.73157077, 5227198.20287631, 928366.12236557, 6118661.62507136, ], + diplan: { + mergeToMultiGeometries: true, + validateGeoJson: true, + metaServices: [ + { + id: flurstuecke, + propertyNames: ['land', 'gemarkung', 'regbezirk', 'kreis', 'gemeinde'], + aggregationMode: 'unequal', + }, + ], + }, locales: [ { type: 'de', diff --git a/packages/clients/diplan/example/polar-ui/index.html b/packages/clients/diplan/example/polar-ui/index.html index a5f9f34d..861974bc 100644 --- a/packages/clients/diplan/example/polar-ui/index.html +++ b/packages/clients/diplan/example/polar-ui/index.html @@ -81,21 +81,6 @@

Informationen aus Kartenklient

uninitialized Die hergestellte Zeichnung als GeoJSON (ohne diplanspezifische Metainformationen und Modifikationen). - - plugin/... - uninitialized - Platz für weitere Beispiele - - - plugin/... - uninitialized - Platz für weitere Beispiele - - - plugin/... - uninitialized - Platz für weitere Beispiele - diff --git a/packages/clients/diplan/example/polar-ui/setup.js b/packages/clients/diplan/example/polar-ui/setup.js index ce8f7d6b..2aed4710 100644 --- a/packages/clients/diplan/example/polar-ui/setup.js +++ b/packages/clients/diplan/example/polar-ui/setup.js @@ -60,8 +60,6 @@ export default (client, layerConf, config) => { * https://dataport.github.io/polar/docs/diplan/client-diplan.html */ - // TODO expand example bindings - const actionPlus = document.getElementById('action-plus') const actionMinus = document.getElementById('action-minus') const actionToast = document.getElementById('action-toast') @@ -100,6 +98,15 @@ export default (client, layerConf, config) => { actionLasso.onclick = () => mapInstance.$store.dispatch('plugin/draw/setMode', 'lasso') + const htmlRevisedDrawExport = document.getElementById( + 'subscribed-revised-draw-export' + ) + const htmlRevisionInProgress = document.getElementById( + 'subscribed-revision-in-progress' + ) + const htmlSimpleGeometryValidity = document.getElementById( + 'subscribed-simple-geometry-validity' + ) const htmlZoom = document.getElementById('subscribed-zoom') const htmlGfi = document.getElementById('subscribed-gfi') const htmlExportA = document.getElementById('subscribed-export-a') @@ -128,6 +135,25 @@ export default (client, layerConf, config) => { mapInstance.subscribe('plugin/draw/featureCollection', (geojson) => { htmlDraw.innerHTML = JSON.stringify(geojson, null, 2) }) + mapInstance.subscribe('diplan/revisedDrawExport', (revisedDrawExport) => { + htmlRevisedDrawExport.innerHTML = JSON.stringify( + revisedDrawExport, + null, + 2 + ) + }) + mapInstance.subscribe( + 'diplan/revisionInProgress', + (revisionInProgress) => { + htmlRevisionInProgress.innerHTML = revisionInProgress + } + ) + mapInstance.subscribe( + 'diplan/simpleGeometryValidity', + (simpleGeometryValidity) => { + htmlSimpleGeometryValidity.innerHTML = simpleGeometryValidity + } + ) window.mapInstance = mapInstance }) diff --git a/packages/clients/diplan/src/store/module.ts b/packages/clients/diplan/src/store/module.ts index d1a1dd0c..f6a2b55d 100644 --- a/packages/clients/diplan/src/store/module.ts +++ b/packages/clients/diplan/src/store/module.ts @@ -69,7 +69,7 @@ const diplanModule: PolarModule = { if (getters.configuration.metaServices.length) { try { - await enrichWithMetaServices( + revisedFeatureCollection.features = await enrichWithMetaServices( revisedFeatureCollection, rootGetters.map, getters.configuration.metaServices, diff --git a/packages/clients/diplan/src/store/utils/enrichWithMetaServices.ts b/packages/clients/diplan/src/store/utils/enrichWithMetaServices.ts index 71416320..7dc32a43 100644 --- a/packages/clients/diplan/src/store/utils/enrichWithMetaServices.ts +++ b/packages/clients/diplan/src/store/utils/enrichWithMetaServices.ts @@ -8,7 +8,7 @@ import { } from '@polar/lib-get-features' import { rawLayerList } from '@masterportal/masterportalapi' import { booleanIntersects } from '@turf/boolean-intersects' -import { MetaService } from '../../types' +import { GeometryType, MetaService } from '../../types' const reader = new GeoJSON() @@ -58,48 +58,51 @@ const aggregateProperties = ( /** @throws */ export const enrichWithMetaServices = ( - featureCollection: FeatureCollection, + featureCollection: FeatureCollection, map: Map, metaServices: MetaService[], signal: AbortSignal -) => +): Promise[]> => Promise.all( - featureCollection.features.map((feature) => - Promise.all( - metaServices.map(({ id, propertyNames, aggregationMode }) => - getVectorFeaturesByFeatureRequest({ - feature: reader.readFeature(JSON.stringify(feature)) as Feature, - fetchLayerId: id, - projectionCode: map.getView().getProjection().getCode(), - signal, - }) - .then((response) => - rawLayerList.getLayerWhere({ id }).typ === 'WFS' - ? parseWfsResponse(response, undefined, false) - : (response.json() as Promise) - ) - .then((featuresFromBbox) => { - const applicableProperties = featuresFromBbox.features - .filter((featureFromBbox) => - booleanIntersects(featureFromBbox, feature) - ) - .map(({ properties }) => properties) - - const aggregatedProperties = aggregateProperties( - applicableProperties, - propertyNames, - aggregationMode + featureCollection.features.map(async (feature) => ({ + ...feature, + properties: { + ...feature.properties, + metaProperties: { + ...(feature.properties?.metaProperties || {}), + ...Object.fromEntries( + await Promise.all( + metaServices.map(({ id, propertyNames, aggregationMode }) => + getVectorFeaturesByFeatureRequest({ + feature: reader.readFeature( + JSON.stringify(feature) + ) as unknown as Feature, + fetchLayerId: id, + projectionCode: map.getView().getProjection().getCode(), + signal, + }) + .then((response) => + rawLayerList.getLayerWhere({ id }).typ === 'WFS' + ? parseWfsResponse(response, undefined, false) + : (response.json() as Promise) + ) + .then((featuresFromBbox) => { + const applicableProperties = featuresFromBbox.features + .filter((featureFromBbox) => + booleanIntersects(featureFromBbox, feature) + ) + .map(({ properties }) => properties) + const aggregatedProperties = aggregateProperties( + applicableProperties, + propertyNames, + aggregationMode + ) + return [id, aggregatedProperties] + }) ) - - feature.properties = { - ...feature.properties, - metaProperties: { - ...(feature.properties?.metaProperties || {}), - [id]: aggregatedProperties, - }, - } - }) - ) - ) - ) + ) + ), + }, + }, + })) )