Merge pull request #12453 from MoonE/kml-multiple-linear-rings

Allow multiple LinearRings per innerBoundaryIs
This commit is contained in:
MoonE authored and GitHub committed 2021-07-06 00:05:50 +02:00
commit 2779ea1849
2 files changed
+56 -6

No files matched your search

+7 -6
View File
@@ -2206,7 +2206,9 @@ function lodParser(node, objectStack) {
*/
// @ts-ignore
const INNER_BOUNDARY_IS_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'LinearRing': makeReplacer(readFlatLinearRing),
// KML spec only allows one LinearRing per innerBoundaryIs, but Google Earth
// allows multiple, so we parse multiple here too.
'LinearRing': makeArrayPusher(readFlatLinearRing),
});
/**
@@ -2214,18 +2216,17 @@ const INNER_BOUNDARY_IS_PARSERS = makeStructureNS(NAMESPACE_URIS, {
* @param {Array<*>} objectStack Object stack.
*/
function innerBoundaryIsParser(node, objectStack) {
/** @type {Array<number>|undefined} */
const flatLinearRing = pushParseAndPop(
undefined,
const innerBoundaryFlatLinearRings = pushParseAndPop(
/** @type {Array<Array<number>>} */ ([]),
INNER_BOUNDARY_IS_PARSERS,
node,
objectStack
);
if (flatLinearRing) {
if (innerBoundaryFlatLinearRings.length > 0) {
const flatLinearRings =
/** @type {Array<Array<number>>} */
(objectStack[objectStack.length - 1]);
flatLinearRings.push(flatLinearRing);
flatLinearRings.push(...innerBoundaryFlatLinearRings);
}
}