@geogirafe/lib-geoportal 1.3.0-dev.3018284934 → 1.3.0-dev.3018313151
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/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"1.3.0-dev.
|
|
1
|
+
{"version":"1.3.0-dev.3018313151", "build":"3018313151", "date":"02/11/2026"}
|
|
@@ -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
|
}
|