@geogirafe/lib-geoportal 1.3.0-dev.3018284934 → 1.3.0-dev.3046054236
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/components/print/tools/MFPEncoder.d.ts +22 -10
- package/components/print/tools/MFPEncoder.js +75 -43
- package/models/layers/grouplayer.d.ts +3 -3
- package/models/layers/grouplayer.js +5 -48
- package/package.json +1 -1
- package/templates/public/about.json +1 -1
- package/tools/main.d.ts +1 -0
- package/tools/tests/wmswfsmanagermocking.d.ts +2 -2
- package/tools/tests/wmswfsmanagermocking.js +68 -61
- package/tools/wfs/compositecurvegml.js +54 -13
- package/tools/wms/wmsclient.d.ts +164 -26
- package/tools/wms/wmsclient.js +415 -233
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { BaseCustomizer, MFPLayer, MFPMap, MFPWmtsLayer, MFPWmsLayer } from '@geoblocks/mapfishprint';
|
|
2
2
|
import type BaseLayer from '../../../models/layers/baselayer.js';
|
|
3
|
-
import GroupLayer from '../../../models/layers/grouplayer.js';
|
|
4
3
|
import MapManager from '../../../tools/state/mapManager.js';
|
|
5
4
|
import State from '../../../tools/state/state.js';
|
|
6
5
|
import LayerLocalFile from '../../../models/layers/layerlocalfile.js';
|
|
7
6
|
import LayerWms from '../../../models/layers/layerwms.js';
|
|
8
7
|
import LayerWmts from '../../../models/layers/layerwmts.js';
|
|
8
|
+
import WmsClient from '../../../tools/wms/wmsclient.js';
|
|
9
9
|
/** Options for encoding a map. */
|
|
10
10
|
export interface EncodeMapOptions {
|
|
11
11
|
state: State;
|
|
@@ -21,6 +21,8 @@ export interface EncodeMapOptions {
|
|
|
21
21
|
export default class MFPEncoder {
|
|
22
22
|
private printResolution;
|
|
23
23
|
private options?;
|
|
24
|
+
private wmsClients;
|
|
25
|
+
private mapInternal;
|
|
24
26
|
/**
|
|
25
27
|
* Sets the options for encoding the map.
|
|
26
28
|
*/
|
|
@@ -30,6 +32,10 @@ export default class MFPEncoder {
|
|
|
30
32
|
* @returns A Promise that resolves with the encoded map object.
|
|
31
33
|
*/
|
|
32
34
|
encodeMap(options: EncodeMapOptions): MFPMap;
|
|
35
|
+
/**
|
|
36
|
+
* @returns an appropriate (existing or new) WMS client for the layer.
|
|
37
|
+
*/
|
|
38
|
+
getWmsClient(layer: LayerWms): WmsClient;
|
|
33
39
|
/**
|
|
34
40
|
* @returns An array of all active layers from the state object in the right order
|
|
35
41
|
*/
|
|
@@ -38,6 +44,20 @@ export default class MFPEncoder {
|
|
|
38
44
|
* @returns The flattened array of base layers.
|
|
39
45
|
*/
|
|
40
46
|
getFlatLayers(baseLayers: BaseLayer[]): BaseLayer[];
|
|
47
|
+
/**
|
|
48
|
+
* See "getFlatLayers".
|
|
49
|
+
* Flatten the array of layer but without WMS layers (added to
|
|
50
|
+
* a WMS client and collected later).
|
|
51
|
+
* @returns The flattened array of base layers without WMS.
|
|
52
|
+
*/
|
|
53
|
+
getFlatLayersCollect(baseLayers: BaseLayer[]): BaseLayer[];
|
|
54
|
+
/**
|
|
55
|
+
* See "getFlatLayers".
|
|
56
|
+
* Add the previously collected WMS layers to the list of layers.
|
|
57
|
+
* This is needed to "group" WMS Layers together.
|
|
58
|
+
* @returns The flattened array of WMS layers.
|
|
59
|
+
*/
|
|
60
|
+
getFlatLayersAddWms(): BaseLayer[];
|
|
41
61
|
/**
|
|
42
62
|
* Encode special layers, meaning not-in-the-layer-tree layers.
|
|
43
63
|
* These layers are from the mapManager.getLayersToPrint method.
|
|
@@ -54,15 +74,6 @@ export default class MFPEncoder {
|
|
|
54
74
|
* @returns A promise that resolves to an array of MFP layers, a single MFP layer, or null.
|
|
55
75
|
*/
|
|
56
76
|
encodeLayer(layer: BaseLayer): MFPLayer[] | MFPLayer | null;
|
|
57
|
-
/**
|
|
58
|
-
* Only non mixed groups of WMS layers are supported.
|
|
59
|
-
*
|
|
60
|
-
* Will convert a group of WMS layers sharing the same OGC server into a single MFPWmsLayer
|
|
61
|
-
* where its 'layers' property is a concatenation of all child layers' 'layers' property.
|
|
62
|
-
*
|
|
63
|
-
* @param groupLayer
|
|
64
|
-
*/
|
|
65
|
-
encodeGroupLayer(groupLayer: GroupLayer): MFPWmsLayer | null;
|
|
66
77
|
/**
|
|
67
78
|
* Encodes an image layer from a WMS layer object.
|
|
68
79
|
* @returns The encoded image layer or null if the layer is not visible.
|
|
@@ -83,4 +94,5 @@ export default class MFPEncoder {
|
|
|
83
94
|
* @returns The encoded WMS layer or null if the ogcServer is missing.
|
|
84
95
|
*/
|
|
85
96
|
encodeWmsFromWmtsLayer(layerWmts: LayerWmts): MFPWmsLayer | null;
|
|
97
|
+
private clear;
|
|
86
98
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import GroupLayer from '../../../models/layers/grouplayer.js';
|
|
1
|
+
import OlMap from 'ol/Map.js';
|
|
3
2
|
import { toDegrees } from 'ol/math.js';
|
|
3
|
+
import { getAbsoluteUrl, getWmtsMatrices, getWmtsUrl, MFPVectorEncoder } from '@geoblocks/mapfishprint';
|
|
4
4
|
import LayerLocalFile from '../../../models/layers/layerlocalfile.js';
|
|
5
5
|
import LayerWms from '../../../models/layers/layerwms.js';
|
|
6
6
|
import LayerWmts from '../../../models/layers/layerwmts.js';
|
|
@@ -9,7 +9,7 @@ import { isLayerVisible } from './printUtils.js';
|
|
|
9
9
|
import VectorSource from 'ol/source/Vector.js';
|
|
10
10
|
import LayerWmtsExternal from '../../../models/layers/layerwmtsexternal.js';
|
|
11
11
|
import LayerWmsExternal from '../../../models/layers/layerwmsexternal.js';
|
|
12
|
-
import WmsClient from '../../../tools/wms/wmsclient.js';
|
|
12
|
+
import WmsClient, { WmsClientDefault } from '../../../tools/wms/wmsclient.js';
|
|
13
13
|
/** Supported MapFishPRint servers
|
|
14
14
|
* see https://github.com/mapfish/mapfish-print/blob/master/core/src/main/java/org/mapfish/print/map/image/wms/WmsLayerParam.java#L123
|
|
15
15
|
*/
|
|
@@ -20,6 +20,8 @@ const MFPSupportedServerType = new Set(['mapserver', 'geoserver', 'qgisserver'])
|
|
|
20
20
|
export default class MFPEncoder {
|
|
21
21
|
printResolution = 100;
|
|
22
22
|
options;
|
|
23
|
+
wmsClients = null;
|
|
24
|
+
mapInternal = null;
|
|
23
25
|
/**
|
|
24
26
|
* Sets the options for encoding the map.
|
|
25
27
|
*/
|
|
@@ -31,6 +33,7 @@ export default class MFPEncoder {
|
|
|
31
33
|
* @returns A Promise that resolves with the encoded map object.
|
|
32
34
|
*/
|
|
33
35
|
encodeMap(options) {
|
|
36
|
+
this.clear();
|
|
34
37
|
this.setOptions(options);
|
|
35
38
|
const mapManager = options.mapManager;
|
|
36
39
|
const view = mapManager.getMap().getView();
|
|
@@ -41,6 +44,7 @@ export default class MFPEncoder {
|
|
|
41
44
|
const allLayers = this.getAllLayers(options.state);
|
|
42
45
|
const mfpLayers = this.encodeLayers(allLayers);
|
|
43
46
|
mfpLayers.unshift(...this.encodeSpecialLayers(mapManager, options.customizer));
|
|
47
|
+
this.clear();
|
|
44
48
|
return {
|
|
45
49
|
center,
|
|
46
50
|
dpi: options.dpi,
|
|
@@ -51,6 +55,24 @@ export default class MFPEncoder {
|
|
|
51
55
|
useNearestScale: false
|
|
52
56
|
};
|
|
53
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* @returns an appropriate (existing or new) WMS client for the layer.
|
|
60
|
+
*/
|
|
61
|
+
getWmsClient(layer) {
|
|
62
|
+
if (!this.mapInternal || !this.wmsClients) {
|
|
63
|
+
this.mapInternal = new OlMap();
|
|
64
|
+
this.wmsClients = new Map();
|
|
65
|
+
}
|
|
66
|
+
let wmsClient = this.wmsClients.get(layer.ogcServer.name);
|
|
67
|
+
if (!wmsClient) {
|
|
68
|
+
wmsClient = new WmsClientDefault(layer.ogcServer, this.mapInternal, {
|
|
69
|
+
stateManager: { state: this.options?.state },
|
|
70
|
+
configManager: { Config: {} }
|
|
71
|
+
});
|
|
72
|
+
this.wmsClients.set(layer.ogcServer.name, wmsClient);
|
|
73
|
+
}
|
|
74
|
+
return wmsClient;
|
|
75
|
+
}
|
|
54
76
|
/**
|
|
55
77
|
* @returns An array of all active layers from the state object in the right order
|
|
56
78
|
*/
|
|
@@ -66,19 +88,27 @@ export default class MFPEncoder {
|
|
|
66
88
|
* @returns The flattened array of base layers.
|
|
67
89
|
*/
|
|
68
90
|
getFlatLayers(baseLayers) {
|
|
91
|
+
const flatLayers = this.getFlatLayersCollect(baseLayers);
|
|
92
|
+
flatLayers.push(...this.getFlatLayersAddWms());
|
|
93
|
+
return flatLayers;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* See "getFlatLayers".
|
|
97
|
+
* Flatten the array of layer but without WMS layers (added to
|
|
98
|
+
* a WMS client and collected later).
|
|
99
|
+
* @returns The flattened array of base layers without WMS.
|
|
100
|
+
*/
|
|
101
|
+
getFlatLayersCollect(baseLayers) {
|
|
69
102
|
return baseLayers.reduce((layers, layer) => {
|
|
70
103
|
const children = layer.children;
|
|
71
104
|
if (children) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const resultLayers = this.getFlatLayers(group.children);
|
|
80
|
-
layers.push(...resultLayers);
|
|
81
|
-
}
|
|
105
|
+
// Flat layers recursively.
|
|
106
|
+
layers.push(...this.getFlatLayersCollect(children));
|
|
107
|
+
}
|
|
108
|
+
else if (layer instanceof LayerWms) {
|
|
109
|
+
// Use the WMS client to group layers.
|
|
110
|
+
const wmsClient = this.getWmsClient(layer);
|
|
111
|
+
wmsClient.addLayer(layer);
|
|
82
112
|
}
|
|
83
113
|
else {
|
|
84
114
|
layers.push(layer);
|
|
@@ -86,6 +116,34 @@ export default class MFPEncoder {
|
|
|
86
116
|
return layers;
|
|
87
117
|
}, []);
|
|
88
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* See "getFlatLayers".
|
|
121
|
+
* Add the previously collected WMS layers to the list of layers.
|
|
122
|
+
* This is needed to "group" WMS Layers together.
|
|
123
|
+
* @returns The flattened array of WMS layers.
|
|
124
|
+
*/
|
|
125
|
+
getFlatLayersAddWms() {
|
|
126
|
+
if (!this.wmsClients) {
|
|
127
|
+
return [];
|
|
128
|
+
}
|
|
129
|
+
const wmsLayers = [];
|
|
130
|
+
Array.from(this.wmsClients.values()).forEach((wmsClient) => {
|
|
131
|
+
wmsClient.getLayerWmsArrays().forEach((layerWmsArray) => {
|
|
132
|
+
// Keep only one LayerWms, but push every layer "layers" of its group in the LayerWms, keep order.
|
|
133
|
+
layerWmsArray.sort((lWms1, lWms2) => lWms1.order - lWms2.order);
|
|
134
|
+
const layersLayers = [];
|
|
135
|
+
layerWmsArray.forEach((lWms) => {
|
|
136
|
+
if (lWms.layers) {
|
|
137
|
+
layersLayers.push(lWms.layers);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
const firstLayerClone = layerWmsArray[0].clone();
|
|
141
|
+
firstLayerClone.layers = [...layersLayers].reverse().join(',');
|
|
142
|
+
wmsLayers.push(firstLayerClone);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
return wmsLayers;
|
|
146
|
+
}
|
|
89
147
|
/**
|
|
90
148
|
* Encode special layers, meaning not-in-the-layer-tree layers.
|
|
91
149
|
* These layers are from the mapManager.getLayersToPrint method.
|
|
@@ -130,9 +188,6 @@ export default class MFPEncoder {
|
|
|
130
188
|
* @returns A promise that resolves to an array of MFP layers, a single MFP layer, or null.
|
|
131
189
|
*/
|
|
132
190
|
encodeLayer(layer) {
|
|
133
|
-
if (layer instanceof GroupLayer) {
|
|
134
|
-
return this.encodeGroupLayer(layer);
|
|
135
|
-
}
|
|
136
191
|
if (layer instanceof LayerWms || layer instanceof LayerWmsExternal) {
|
|
137
192
|
return this.encodeWmsLayer(layer);
|
|
138
193
|
}
|
|
@@ -145,33 +200,6 @@ export default class MFPEncoder {
|
|
|
145
200
|
console.warn('Unsupported layer type for encoding: ', layer);
|
|
146
201
|
return null;
|
|
147
202
|
}
|
|
148
|
-
/**
|
|
149
|
-
* Only non mixed groups of WMS layers are supported.
|
|
150
|
-
*
|
|
151
|
-
* Will convert a group of WMS layers sharing the same OGC server into a single MFPWmsLayer
|
|
152
|
-
* where its 'layers' property is a concatenation of all child layers' 'layers' property.
|
|
153
|
-
*
|
|
154
|
-
* @param groupLayer
|
|
155
|
-
*/
|
|
156
|
-
encodeGroupLayer(groupLayer) {
|
|
157
|
-
if (groupLayer.isMixed) {
|
|
158
|
-
console.error("A mixed group layer is passed to print and shouldn't", groupLayer);
|
|
159
|
-
return null;
|
|
160
|
-
}
|
|
161
|
-
if (groupLayer.hasGrandChildren) {
|
|
162
|
-
console.error("A group layer that has grandchildren is passed to print and shouldn't", groupLayer);
|
|
163
|
-
return null;
|
|
164
|
-
}
|
|
165
|
-
const firstWmsLayer = groupLayer.children.shift();
|
|
166
|
-
const spec = this.encodeWmsLayer(firstWmsLayer);
|
|
167
|
-
if (!spec) {
|
|
168
|
-
return this.encodeGroupLayer(groupLayer);
|
|
169
|
-
}
|
|
170
|
-
for (const childLayer of groupLayer.children) {
|
|
171
|
-
spec.layers.push(childLayer.layers || '');
|
|
172
|
-
}
|
|
173
|
-
return spec;
|
|
174
|
-
}
|
|
175
203
|
/**
|
|
176
204
|
* Encodes an image layer from a WMS layer object.
|
|
177
205
|
* @returns The encoded image layer or null if the layer is not visible.
|
|
@@ -289,4 +317,8 @@ export default class MFPEncoder {
|
|
|
289
317
|
layerWms.opacity = layerWmts.opacity;
|
|
290
318
|
return this.encodeWmsLayer(layerWms);
|
|
291
319
|
}
|
|
320
|
+
clear() {
|
|
321
|
+
this.mapInternal = null;
|
|
322
|
+
this.wmsClients = null;
|
|
323
|
+
}
|
|
292
324
|
}
|
|
@@ -28,12 +28,12 @@ declare class GroupLayer extends BaseLayer implements ILayerWithTime {
|
|
|
28
28
|
get inactive(): boolean;
|
|
29
29
|
get semiActive(): boolean;
|
|
30
30
|
get hasTimeRestriction(): boolean;
|
|
31
|
-
get hasGrandChildren(): boolean;
|
|
32
31
|
isFirstLevelGroup(): boolean;
|
|
33
32
|
setDefaultTimeRestriction(): void;
|
|
34
33
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
34
|
+
* This is not supposed to be used anymore.
|
|
35
|
+
* Now the WmsClient groups the layers itself.
|
|
36
|
+
* @deprecated
|
|
37
37
|
*/
|
|
38
38
|
get isMixed(): boolean;
|
|
39
39
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
import BaseLayer from './baselayer.js';
|
|
3
3
|
import LayerTimeFormatter from '../../tools/time/layertimeformatter.js';
|
|
4
|
-
import LayerWms from './layerwms.js';
|
|
5
4
|
/*
|
|
6
5
|
* This class is used in the state of the application, which will be accessed behind a JavaScript proxy.
|
|
7
6
|
* This means that each modification made to its properties must come from outside,
|
|
@@ -68,14 +67,6 @@ class GroupLayer extends BaseLayer {
|
|
|
68
67
|
get hasTimeRestriction() {
|
|
69
68
|
return !!this.timeRestriction;
|
|
70
69
|
}
|
|
71
|
-
get hasGrandChildren() {
|
|
72
|
-
for (const child of this.children) {
|
|
73
|
-
if (child.children?.length) {
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
70
|
isFirstLevelGroup() {
|
|
80
71
|
return !(this.parent instanceof GroupLayer);
|
|
81
72
|
}
|
|
@@ -86,47 +77,13 @@ class GroupLayer extends BaseLayer {
|
|
|
86
77
|
}
|
|
87
78
|
}
|
|
88
79
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
80
|
+
* This is not supposed to be used anymore.
|
|
81
|
+
* Now the WmsClient groups the layers itself.
|
|
82
|
+
* @deprecated
|
|
91
83
|
*/
|
|
92
84
|
get isMixed() {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return this._isMixed;
|
|
96
|
-
}
|
|
97
|
-
// If any child is not a GroupLayer or LayerWms, return true immediately
|
|
98
|
-
for (const child of this.children) {
|
|
99
|
-
if (!(child instanceof GroupLayer) && !(child instanceof LayerWms)) {
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
// Collect all LayerWms children and grandchildren recursively
|
|
104
|
-
const layerWmsList = [];
|
|
105
|
-
function collectLayerWms(layer) {
|
|
106
|
-
if (layer instanceof LayerWms) {
|
|
107
|
-
layerWmsList.push(layer);
|
|
108
|
-
}
|
|
109
|
-
else if (layer instanceof GroupLayer) {
|
|
110
|
-
for (const child of layer.children) {
|
|
111
|
-
collectLayerWms(child);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
for (const child of this.children) {
|
|
116
|
-
collectLayerWms(child);
|
|
117
|
-
}
|
|
118
|
-
// Check if all LayerWms have the same properties
|
|
119
|
-
if (layerWmsList.length > 0) {
|
|
120
|
-
const first = layerWmsList[0];
|
|
121
|
-
const allSame = layerWmsList.every((lw) => lw.opacity === first.opacity &&
|
|
122
|
-
lw.ogcServer === first.ogcServer &&
|
|
123
|
-
lw.filter === first.filter &&
|
|
124
|
-
lw.timeRestriction === first.timeRestriction);
|
|
125
|
-
if (allSame) {
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return true;
|
|
85
|
+
console.error('This property must not be used.');
|
|
86
|
+
return !!this._isMixed;
|
|
130
87
|
}
|
|
131
88
|
}
|
|
132
89
|
export default GroupLayer;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"1.3.0-dev.
|
|
1
|
+
{"version":"1.3.0-dev.3046054236", "build":"3046054236", "date":"09/11/2026"}
|
package/tools/main.d.ts
CHANGED
|
@@ -167,6 +167,7 @@ export type { WfsOperator } from './wfs/wfsfiltercondition.js';
|
|
|
167
167
|
export { default as WfsFilterCondition, isWfsOperator } from './wfs/wfsfiltercondition.js';
|
|
168
168
|
export { default as WfsManager } from './wfs/wfsmanager.js';
|
|
169
169
|
export { default as WfsParser } from './wfs/wfsparser.js';
|
|
170
|
+
export type { PairedLayer, GroupLayerInfo } from './wms/wmsclient.js';
|
|
170
171
|
export { default as WmsClient, WmsClientQgis, WmsClientMapServer, WmsClientDefault, WmsClientGeoServer } from './wms/wmsclient.js';
|
|
171
172
|
export { default as WmsLegendHelper } from './wms/wmslegendhelper.js';
|
|
172
173
|
export { default as WmsManager } from './wms/wmsmanager.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import LayerWms from '../../models/layers/layerwms';
|
|
2
2
|
import ServerOgc from '../../models/serverogc';
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
3
|
+
export declare const createMockOgcServers: () => Record<string, ServerOgc>;
|
|
4
|
+
export declare const createMockWmsLayers: () => Record<string, LayerWms>;
|
|
@@ -1,66 +1,73 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
import LayerWms from '../../models/layers/layerwms';
|
|
3
3
|
import ServerOgc from '../../models/serverogc';
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
4
|
+
export const createMockOgcServers = () => {
|
|
5
|
+
return {
|
|
6
|
+
'QGIS-1-has-wfs': new ServerOgc('QGIS-1-has-wfs', {
|
|
7
|
+
url: 'https://qgis-wms-1.test.url',
|
|
8
|
+
wfsSupport: true,
|
|
9
|
+
urlWfs: 'https://wfs-1.url',
|
|
10
|
+
type: 'qgisserver',
|
|
11
|
+
imageType: 'image/png'
|
|
12
|
+
}),
|
|
13
|
+
'QGIS-2-has-wfs': new ServerOgc('QGIS-2-has-wfs', {
|
|
14
|
+
url: 'https://qgis-wms-2.test.url',
|
|
15
|
+
wfsSupport: true,
|
|
16
|
+
urlWfs: 'https://qgis-wfs-2.url',
|
|
17
|
+
type: 'qgisserver',
|
|
18
|
+
imageType: 'image/png'
|
|
19
|
+
}),
|
|
20
|
+
'QGIS-3-no-wfs': new ServerOgc('QGIS-3-no-wfs', {
|
|
21
|
+
url: 'https://qgis-wms-3.test.url',
|
|
22
|
+
wfsSupport: false,
|
|
23
|
+
type: 'qgisserver',
|
|
24
|
+
imageType: 'image/png'
|
|
25
|
+
}),
|
|
26
|
+
'MapServer-1-has-wfs': new ServerOgc('MapServer-1-has-wfs', {
|
|
27
|
+
url: 'https://ms-wms-1.test.url',
|
|
28
|
+
wfsSupport: true,
|
|
29
|
+
urlWfs: 'https://ms-wfs-1.url',
|
|
30
|
+
type: 'mapserver',
|
|
31
|
+
imageType: 'image/png'
|
|
32
|
+
}),
|
|
33
|
+
'MapServer-2-has-wfs': new ServerOgc('MapServer-2-has-wfs', {
|
|
34
|
+
url: 'https://ms-wms-2.test.url',
|
|
35
|
+
wfsSupport: true,
|
|
36
|
+
urlWfs: 'https://ms-wfs-2.url',
|
|
37
|
+
type: 'mapserver',
|
|
38
|
+
imageType: 'image/png'
|
|
39
|
+
}),
|
|
40
|
+
'MapServer-3-no-wfs': new ServerOgc('MapServer-3-no-wfs', {
|
|
41
|
+
url: 'https://ms-wms-3.test.url',
|
|
42
|
+
wfsSupport: false,
|
|
43
|
+
type: 'mapserver',
|
|
44
|
+
imageType: 'image/png'
|
|
45
|
+
})
|
|
46
|
+
};
|
|
45
47
|
};
|
|
46
|
-
export const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
48
|
+
export const createMockWmsLayers = () => {
|
|
49
|
+
const mockOgcServers = createMockOgcServers();
|
|
50
|
+
return {
|
|
51
|
+
'qgis1-layer1': new LayerWms(1, 'qgis1-layer1', 1, mockOgcServers['QGIS-1-has-wfs'], {
|
|
52
|
+
queryable: true,
|
|
53
|
+
queryLayers: 'qgis1-ql1,qgis1-ql2,qgis1-ql3'
|
|
54
|
+
}), // multiple queryLayers
|
|
55
|
+
'qgis1-layer2': new LayerWms(1, 'qgis1-layer2', 2, mockOgcServers['QGIS-1-has-wfs'], {
|
|
56
|
+
queryable: true,
|
|
57
|
+
queryLayers: 'qgis1-ql3,qgis1-ql4',
|
|
58
|
+
opacity: 0.5
|
|
59
|
+
}), // opacity: another group of layers.
|
|
60
|
+
'qgis1-layer3': new LayerWms(1, 'qgis1-layer3', 3, mockOgcServers['QGIS-1-has-wfs'], {}), // layer without wfs on wfs-able server: should be ok
|
|
61
|
+
'qgis1-layer4': new LayerWms(1, 'qgis1-layer4', 4, mockOgcServers['QGIS-1-has-wfs'], {}), // Same layer, can be requested with the previous one.
|
|
62
|
+
'qgis1-layer5': new LayerWms(1, 'qgis1-layer5', 0, mockOgcServers['QGIS-1-has-wfs'], {}), // Same but ORDER = 0! (change grouping)
|
|
63
|
+
'qgis2-layer1': new LayerWms(1, 'qgis2-layer1', 6, mockOgcServers['QGIS-2-has-wfs'], {
|
|
64
|
+
queryable: true,
|
|
65
|
+
queryLayers: 'qgis2-ql3'
|
|
66
|
+
}), //single queryLayer
|
|
67
|
+
'qgis3-layer1': new LayerWms(1, 'qgis3-layer1', 7, mockOgcServers['QGIS-3-no-wfs'], {}), // layer without wfs on server without wfs: no problemo
|
|
68
|
+
'qgis3-layer2': new LayerWms(1, 'qgis3-layer2', 8, mockOgcServers['QGIS-3-no-wfs'], {
|
|
69
|
+
queryable: true,
|
|
70
|
+
queryLayers: 'qgis3-ql1nono'
|
|
71
|
+
}) // queryable layer on server without wfs: problemo
|
|
72
|
+
};
|
|
66
73
|
};
|
|
@@ -76,8 +76,16 @@ function readCurveElement(parser, node, objectStack) {
|
|
|
76
76
|
return lineStringToPieces(parser.readLineString(node, objectStack));
|
|
77
77
|
}
|
|
78
78
|
if (node.localName === 'Curve') {
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
const lineString = parser.readCurve(node, objectStack);
|
|
80
|
+
if (lineString && lineString.getCoordinates().length > 0) {
|
|
81
|
+
return lineStringToPieces(lineString);
|
|
82
|
+
}
|
|
83
|
+
// OpenLayers only understands LineStringSegment inside gml:Curve.
|
|
84
|
+
// QGIS WFS emits ArcString segments; read their posList directly.
|
|
85
|
+
return readSegmentsPosList(node);
|
|
86
|
+
}
|
|
87
|
+
if (node.localName === 'ArcString') {
|
|
88
|
+
return readSegmentsPosList(node);
|
|
81
89
|
}
|
|
82
90
|
if (node.localName === 'CompositeCurve') {
|
|
83
91
|
return geometryToPieces(parser.readCompositeCurve(node, objectStack));
|
|
@@ -88,6 +96,40 @@ function readCurveElement(parser, node, objectStack) {
|
|
|
88
96
|
console.warn(`CompositeCurve member contains unsupported ${describeNode(node)}.`);
|
|
89
97
|
return [];
|
|
90
98
|
}
|
|
99
|
+
function readSegmentsPosList(node) {
|
|
100
|
+
const pieces = [];
|
|
101
|
+
const containers = node.localName === 'Curve' ? Array.from(node.children).filter((c) => c.localName === 'segments') : [node];
|
|
102
|
+
for (const container of containers) {
|
|
103
|
+
for (const segment of Array.from(container.children)) {
|
|
104
|
+
if (segment.localName !== 'ArcString' && segment.localName !== 'LineStringSegment') {
|
|
105
|
+
console.warn(`CompositeCurve member contains unsupported ${describeNode(segment)} segment.`);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const piece = readPosListPiece(segment);
|
|
109
|
+
if (piece.length > 0) {
|
|
110
|
+
pieces.push(piece);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return pieces;
|
|
115
|
+
}
|
|
116
|
+
function readPosListPiece(node) {
|
|
117
|
+
const posList = Array.from(node.children).find((child) => child.localName === 'posList');
|
|
118
|
+
if (!posList) {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
const dimension = Number(posList.getAttribute('srsDimension') ?? posList.getAttribute('dimension') ?? 2) || 2;
|
|
122
|
+
const values = posList.textContent?.trim().split(/\s+/).map(Number) ?? [];
|
|
123
|
+
if (values.length === 0 || values.some((v) => Number.isNaN(v)) || values.length % dimension !== 0) {
|
|
124
|
+
console.warn(`CompositeCurve member contains invalid posList at ${describeNode(node)}.`);
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
const piece = [];
|
|
128
|
+
for (let i = 0; i < values.length; i += dimension) {
|
|
129
|
+
piece.push(values.slice(i, i + dimension));
|
|
130
|
+
}
|
|
131
|
+
return piece;
|
|
132
|
+
}
|
|
91
133
|
function readOrientableCurve(parser, node, objectStack) {
|
|
92
134
|
const baseCurve = Array.from(node.children).find((child) => child.localName === 'baseCurve');
|
|
93
135
|
if (!baseCurve) {
|
|
@@ -103,16 +145,6 @@ function readOrientableCurve(parser, node, objectStack) {
|
|
|
103
145
|
}
|
|
104
146
|
return buildCompositeGeometry(pieces);
|
|
105
147
|
}
|
|
106
|
-
function warnIfCurveHasUnsupportedSegments(node) {
|
|
107
|
-
const segments = Array.from(node.children).find((child) => child.localName === 'segments');
|
|
108
|
-
if (!segments) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
const unsupportedSegment = Array.from(segments.children).find((child) => child.localName !== 'LineStringSegment');
|
|
112
|
-
if (unsupportedSegment) {
|
|
113
|
-
console.warn(`CompositeCurve member contains unsupported ${describeNode(unsupportedSegment)} segment.`);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
148
|
function lineStringToPieces(lineString) {
|
|
117
149
|
if (!lineString) {
|
|
118
150
|
return [];
|
|
@@ -131,9 +163,10 @@ function buildCompositeGeometry(pieces) {
|
|
|
131
163
|
if (normalizedPieces.length === 0) {
|
|
132
164
|
return new MultiLineString([]);
|
|
133
165
|
}
|
|
166
|
+
const dimension = normalizedPieces[0][0].length;
|
|
134
167
|
const groups = [];
|
|
135
168
|
for (const piece of normalizedPieces) {
|
|
136
|
-
const current = clonePiece(piece);
|
|
169
|
+
const current = clonePiece(piece).map((coordinate) => normalizeDimension(coordinate, dimension));
|
|
137
170
|
const previous = groups.at(-1);
|
|
138
171
|
if (previous && coordinatesEqual(previous[previous.length - 1], current[0])) {
|
|
139
172
|
previous.push(...current.slice(1));
|
|
@@ -144,6 +177,14 @@ function buildCompositeGeometry(pieces) {
|
|
|
144
177
|
}
|
|
145
178
|
return groups.length === 1 ? new LineString(groups[0]) : new MultiLineString(groups);
|
|
146
179
|
}
|
|
180
|
+
function normalizeDimension(coordinate, dimension) {
|
|
181
|
+
if (coordinate.length === dimension) {
|
|
182
|
+
return coordinate;
|
|
183
|
+
}
|
|
184
|
+
return coordinate.length < dimension
|
|
185
|
+
? [...coordinate, ...new Array(dimension - coordinate.length).fill(0)]
|
|
186
|
+
: coordinate.slice(0, dimension);
|
|
187
|
+
}
|
|
147
188
|
function clonePiece(piece) {
|
|
148
189
|
return piece.map((coordinate) => [...coordinate]);
|
|
149
190
|
}
|