Skip to content

Commit d771cad

Browse files
committed
add missing example configuration for diplan prod
1 parent 121e789 commit d771cad

File tree

5 files changed

+83
-58
lines changed

5 files changed

+83
-58
lines changed

packages/clients/diplan/example/dev/config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ export default {
1111
extent: [
1212
248651.73157077, 5227198.20287631, 928366.12236557, 6118661.62507136,
1313
],
14+
diplan: {
15+
mergeToMultiGeometries: true,
16+
validateGeoJson: true,
17+
metaServices: [
18+
{
19+
id: flurstuecke,
20+
propertyNames: ['land', 'gemarkung', 'regbezirk', 'kreis', 'gemeinde'],
21+
aggregationMode: 'unequal',
22+
},
23+
],
24+
},
1425
locales: [
1526
{
1627
type: 'de',

packages/clients/diplan/example/polar-ui/index.html

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,6 @@ <h2>Informationen aus Kartenklient</h2>
8181
<td id="subscribed-draw">uninitialized</td>
8282
<td>Die hergestellte Zeichnung als GeoJSON (ohne diplanspezifische Metainformationen und Modifikationen).</td>
8383
</tr>
84-
<tr>
85-
<td><code>plugin/...</code></td>
86-
<td id="subscribed-a">uninitialized</td>
87-
<td>Platz für weitere Beispiele</td>
88-
</tr>
89-
<tr>
90-
<td><code>plugin/...</code></td>
91-
<td id="subscribed-b">uninitialized</td>
92-
<td>Platz für weitere Beispiele</td>
93-
</tr>
94-
<tr>
95-
<td><code>plugin/...</code></td>
96-
<td id="subscribed-c">uninitialized</td>
97-
<td>Platz für weitere Beispiele</td>
98-
</tr>
9984
</tbody>
10085
</table>
10186
</section>

packages/clients/diplan/example/polar-ui/setup.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ export default (client, layerConf, config) => {
6060
* https://dataport.github.io/polar/docs/diplan/client-diplan.html
6161
*/
6262

63-
// TODO expand example bindings
64-
6563
const actionPlus = document.getElementById('action-plus')
6664
const actionMinus = document.getElementById('action-minus')
6765
const actionToast = document.getElementById('action-toast')
@@ -100,6 +98,15 @@ export default (client, layerConf, config) => {
10098
actionLasso.onclick = () =>
10199
mapInstance.$store.dispatch('plugin/draw/setMode', 'lasso')
102100

101+
const htmlRevisedDrawExport = document.getElementById(
102+
'subscribed-revised-draw-export'
103+
)
104+
const htmlRevisionInProgress = document.getElementById(
105+
'subscribed-revision-in-progress'
106+
)
107+
const htmlSimpleGeometryValidity = document.getElementById(
108+
'subscribed-simple-geometry-validity'
109+
)
103110
const htmlZoom = document.getElementById('subscribed-zoom')
104111
const htmlGfi = document.getElementById('subscribed-gfi')
105112
const htmlExportA = document.getElementById('subscribed-export-a')
@@ -128,6 +135,25 @@ export default (client, layerConf, config) => {
128135
mapInstance.subscribe('plugin/draw/featureCollection', (geojson) => {
129136
htmlDraw.innerHTML = JSON.stringify(geojson, null, 2)
130137
})
138+
mapInstance.subscribe('diplan/revisedDrawExport', (revisedDrawExport) => {
139+
htmlRevisedDrawExport.innerHTML = JSON.stringify(
140+
revisedDrawExport,
141+
null,
142+
2
143+
)
144+
})
145+
mapInstance.subscribe(
146+
'diplan/revisionInProgress',
147+
(revisionInProgress) => {
148+
htmlRevisionInProgress.innerHTML = revisionInProgress
149+
}
150+
)
151+
mapInstance.subscribe(
152+
'diplan/simpleGeometryValidity',
153+
(simpleGeometryValidity) => {
154+
htmlSimpleGeometryValidity.innerHTML = simpleGeometryValidity
155+
}
156+
)
131157

132158
window.mapInstance = mapInstance
133159
})

packages/clients/diplan/src/store/module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const diplanModule: PolarModule<DiplanState, DiplanGetters> = {
6969

7070
if (getters.configuration.metaServices.length) {
7171
try {
72-
await enrichWithMetaServices(
72+
revisedFeatureCollection.features = await enrichWithMetaServices(
7373
revisedFeatureCollection,
7474
rootGetters.map,
7575
getters.configuration.metaServices,

packages/clients/diplan/src/store/utils/enrichWithMetaServices.ts

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from '@polar/lib-get-features'
99
import { rawLayerList } from '@masterportal/masterportalapi'
1010
import { booleanIntersects } from '@turf/boolean-intersects'
11-
import { MetaService } from '../../types'
11+
import { GeometryType, MetaService } from '../../types'
1212

1313
const reader = new GeoJSON()
1414

@@ -58,48 +58,51 @@ const aggregateProperties = (
5858

5959
/** @throws */
6060
export const enrichWithMetaServices = (
61-
featureCollection: FeatureCollection,
61+
featureCollection: FeatureCollection<GeometryType>,
6262
map: Map,
6363
metaServices: MetaService[],
6464
signal: AbortSignal
65-
) =>
65+
): Promise<GeoJsonFeature<GeometryType>[]> =>
6666
Promise.all(
67-
featureCollection.features.map((feature) =>
68-
Promise.all(
69-
metaServices.map(({ id, propertyNames, aggregationMode }) =>
70-
getVectorFeaturesByFeatureRequest({
71-
feature: reader.readFeature(JSON.stringify(feature)) as Feature,
72-
fetchLayerId: id,
73-
projectionCode: map.getView().getProjection().getCode(),
74-
signal,
75-
})
76-
.then((response) =>
77-
rawLayerList.getLayerWhere({ id }).typ === 'WFS'
78-
? parseWfsResponse(response, undefined, false)
79-
: (response.json() as Promise<FeatureCollection>)
80-
)
81-
.then((featuresFromBbox) => {
82-
const applicableProperties = featuresFromBbox.features
83-
.filter((featureFromBbox) =>
84-
booleanIntersects(featureFromBbox, feature)
85-
)
86-
.map(({ properties }) => properties)
87-
88-
const aggregatedProperties = aggregateProperties(
89-
applicableProperties,
90-
propertyNames,
91-
aggregationMode
67+
featureCollection.features.map(async (feature) => ({
68+
...feature,
69+
properties: {
70+
...feature.properties,
71+
metaProperties: {
72+
...(feature.properties?.metaProperties || {}),
73+
...Object.fromEntries(
74+
await Promise.all(
75+
metaServices.map(({ id, propertyNames, aggregationMode }) =>
76+
getVectorFeaturesByFeatureRequest({
77+
feature: reader.readFeature(
78+
JSON.stringify(feature)
79+
) as unknown as Feature,
80+
fetchLayerId: id,
81+
projectionCode: map.getView().getProjection().getCode(),
82+
signal,
83+
})
84+
.then((response) =>
85+
rawLayerList.getLayerWhere({ id }).typ === 'WFS'
86+
? parseWfsResponse(response, undefined, false)
87+
: (response.json() as Promise<FeatureCollection>)
88+
)
89+
.then((featuresFromBbox) => {
90+
const applicableProperties = featuresFromBbox.features
91+
.filter((featureFromBbox) =>
92+
booleanIntersects(featureFromBbox, feature)
93+
)
94+
.map(({ properties }) => properties)
95+
const aggregatedProperties = aggregateProperties(
96+
applicableProperties,
97+
propertyNames,
98+
aggregationMode
99+
)
100+
return [id, aggregatedProperties]
101+
})
92102
)
93-
94-
feature.properties = {
95-
...feature.properties,
96-
metaProperties: {
97-
...(feature.properties?.metaProperties || {}),
98-
[id]: aggregatedProperties,
99-
},
100-
}
101-
})
102-
)
103-
)
104-
)
103+
)
104+
),
105+
},
106+
},
107+
}))
105108
)

0 commit comments

Comments
 (0)