import { IIIFInfo_default } from "./chunk-QJMYH47T.js"; import { Feature_default as Feature_default3, GeoJSON_default, JSONFeature_default, transformExtentWithOptions, transformGeometryWithOptions } from "./chunk-X5Q6YOLZ.js"; import { Feature_default as Feature_default2 } from "./chunk-FDGVG43Y.js"; import { Fill_default, Icon_default, Stroke_default, Style_default, Text_default } from "./chunk-EMRMEHGR.js"; import "./chunk-GNM7L5BH.js"; import { asArray } from "./chunk-GMHZLYJW.js"; import "./chunk-PPP4FLHO.js"; import "./chunk-YWIWRQT2.js"; import "./chunk-3HOSDZVQ.js"; import { ImageState_default } from "./chunk-5TDNKDLD.js"; import "./chunk-5XHD7RSF.js"; import { Feature_default } from "./chunk-53ZECYYG.js"; import { GeometryCollection_default, MultiLineString_default, MultiPoint_default, MultiPolygon_default } from "./chunk-VIJW6LYV.js"; import { LinearRing_default, Polygon_default, inflateEnds, linearRingIsClockwise } from "./chunk-RBA5LKAR.js"; import { Point_default } from "./chunk-GA6VLMXX.js"; import { LineString_default } from "./chunk-CXIHWQDX.js"; import "./chunk-JFXZSSOM.js"; import { inflateCoordinates } from "./chunk-NLIGXLAR.js"; import "./chunk-YUSNUQO6.js"; import { Geometry_default, SimpleGeometry_default, deflateCoordinates, getStrideForLayout } from "./chunk-YUTQGDGI.js"; import "./chunk-JFONEOYG.js"; import { Projection_default, get } from "./chunk-XZU4LSFD.js"; import "./chunk-ZLPTRF2L.js"; import { compareVersions, padNumber } from "./chunk-3JZANJYE.js"; import { toRadians } from "./chunk-54BTDBAD.js"; import { boundingExtent, containsExtent, createOrUpdate } from "./chunk-CKDBVGKM.js"; import { assert } from "./chunk-QFCIXVZ3.js"; import { abstract } from "./chunk-H47PV7W6.js"; import "./chunk-KJXIHBKT.js"; import { extend } from "./chunk-FQY6EMA7.js"; import { isEmpty } from "./chunk-5RHQVMYD.js"; import "./chunk-LK32TJAX.js"; // node_modules/ol/format/EsriJSON.js var GEOMETRY_READERS = { Point: readPointGeometry, LineString: readLineStringGeometry, Polygon: readPolygonGeometry, MultiPoint: readMultiPointGeometry, MultiLineString: readMultiLineStringGeometry, MultiPolygon: readMultiPolygonGeometry }; var GEOMETRY_WRITERS = { Point: writePointGeometry, LineString: writeLineStringGeometry, Polygon: writePolygonGeometry, MultiPoint: writeMultiPointGeometry, MultiLineString: writeMultiLineStringGeometry, MultiPolygon: writeMultiPolygonGeometry }; var EsriJSON = class extends JSONFeature_default { /** * @param {Options} [options] Options. */ constructor(options) { options = options ? options : {}; super(); this.geometryName_ = options.geometryName; } /** * @param {Object} object Object. * @param {import("./Feature.js").ReadOptions} [options] Read options. * @param {string} [idField] Name of the field where to get the id from. * @protected * @return {import("../Feature.js").default} Feature. * @override */ readFeatureFromObject(object, options, idField) { const esriJSONFeature = ( /** @type {EsriJSONFeature} */ object ); const geometry = readGeometry(esriJSONFeature.geometry, options); const feature = new Feature_default(); if (this.geometryName_) { feature.setGeometryName(this.geometryName_); } feature.setGeometry(geometry); if (esriJSONFeature.attributes) { feature.setProperties(esriJSONFeature.attributes, true); const id = esriJSONFeature.attributes[idField]; if (id !== void 0) { feature.setId( /** @type {number} */ id ); } } return feature; } /** * @param {Object} object Object. * @param {import("./Feature.js").ReadOptions} [options] Read options. * @protected * @return {Array} Features. * @override */ readFeaturesFromObject(object, options) { options = options ? options : {}; if (object["features"]) { const esriJSONFeatureSet = ( /** @type {EsriJSONFeatureSet} */ object ); const features = []; const esriJSONFeatures = esriJSONFeatureSet.features; for (let i = 0, ii = esriJSONFeatures.length; i < ii; ++i) { features.push( this.readFeatureFromObject( esriJSONFeatures[i], options, object.objectIdFieldName ) ); } return features; } return [this.readFeatureFromObject(object, options)]; } /** * @param {EsriJSONGeometry} object Object. * @param {import("./Feature.js").ReadOptions} [options] Read options. * @protected * @return {import("../geom/Geometry.js").default} Geometry. * @override */ readGeometryFromObject(object, options) { return readGeometry(object, options); } /** * @param {Object} object Object. * @protected * @return {import("../proj/Projection.js").default} Projection. * @override */ readProjectionFromObject(object) { if (object["spatialReference"] && object["spatialReference"]["wkid"] !== void 0) { const spatialReference = ( /** @type {EsriJSONSpatialReferenceWkid} */ object["spatialReference"] ); const crs = spatialReference.wkid; return get("EPSG:" + crs); } return null; } /** * Encode a geometry as a EsriJSON object. * * @param {import("../geom/Geometry.js").default} geometry Geometry. * @param {import("./Feature.js").WriteOptions} [options] Write options. * @return {EsriJSONGeometry} Object. * @api * @override */ writeGeometryObject(geometry, options) { return writeGeometry(geometry, this.adaptOptions(options)); } /** * Encode a feature as a esriJSON Feature object. * * @param {import("../Feature.js").default} feature Feature. * @param {import("./Feature.js").WriteOptions} [options] Write options. * @return {Object} Object. * @api * @override */ writeFeatureObject(feature, options) { options = this.adaptOptions(options); const object = {}; if (!feature.hasProperties()) { object["attributes"] = {}; return object; } const properties = feature.getProperties(); const geometry = feature.getGeometry(); if (geometry) { object["geometry"] = writeGeometry(geometry, options); const projection = options && (options.dataProjection || options.featureProjection); if (projection) { object["geometry"]["spatialReference"] = /** @type {EsriJSONSpatialReferenceWkid} */ { wkid: Number(get(projection).getCode().split(":").pop()) }; } delete properties[feature.getGeometryName()]; } if (!isEmpty(properties)) { object["attributes"] = properties; } else { object["attributes"] = {}; } return object; } /** * Encode an array of features as a EsriJSON object. * * @param {Array} features Features. * @param {import("./Feature.js").WriteOptions} [options] Write options. * @return {EsriJSONFeatureSet} EsriJSON Object. * @api * @override */ writeFeaturesObject(features, options) { options = this.adaptOptions(options); const objects = []; for (let i = 0, ii = features.length; i < ii; ++i) { objects.push(this.writeFeatureObject(features[i], options)); } return { "features": objects }; } }; function readGeometry(object, options) { if (!object) { return null; } let type; if (typeof object["x"] === "number" && typeof object["y"] === "number") { type = "Point"; } else if (object["points"]) { type = "MultiPoint"; } else if (object["paths"]) { const esriJSONPolyline = ( /** @type {EsriJSONPolyline} */ object ); if (esriJSONPolyline.paths.length === 1) { type = "LineString"; } else { type = "MultiLineString"; } } else if (object["rings"]) { const esriJSONPolygon = ( /** @type {EsriJSONPolygon} */ object ); const layout = getGeometryLayout(esriJSONPolygon); const rings = convertRings(esriJSONPolygon.rings, layout); if (rings.length === 1) { type = "Polygon"; object = Object.assign({}, object, { ["rings"]: rings[0] }); } else { type = "MultiPolygon"; object = Object.assign({}, object, { ["rings"]: rings }); } } const geometryReader = GEOMETRY_READERS[type]; return transformGeometryWithOptions(geometryReader(object), false, options); } function convertRings(rings, layout) { const flatRing = []; const outerRings = []; const holes = []; let i, ii; for (i = 0, ii = rings.length; i < ii; ++i) { flatRing.length = 0; deflateCoordinates(flatRing, 0, rings[i], layout.length); const clockwise = linearRingIsClockwise( flatRing, 0, flatRing.length, layout.length ); if (clockwise) { outerRings.push([rings[i]]); } else { holes.push(rings[i]); } } while (holes.length) { const hole = holes.shift(); let matched = false; for (i = outerRings.length - 1; i >= 0; i--) { const outerRing = outerRings[i][0]; const containsHole = containsExtent( new LinearRing_default(outerRing).getExtent(), new LinearRing_default(hole).getExtent() ); if (containsHole) { outerRings[i].push(hole); matched = true; break; } } if (!matched) { outerRings.push([hole.reverse()]); } } return outerRings; } function readPointGeometry(object) { let point; if (object.m !== void 0 && object.z !== void 0) { point = new Point_default([object.x, object.y, object.z, object.m], "XYZM"); } else if (object.z !== void 0) { point = new Point_default([object.x, object.y, object.z], "XYZ"); } else if (object.m !== void 0) { point = new Point_default([object.x, object.y, object.m], "XYM"); } else { point = new Point_default([object.x, object.y]); } return point; } function readLineStringGeometry(object) { const layout = getGeometryLayout(object); return new LineString_default(object.paths[0], layout); } function readMultiLineStringGeometry(object) { const layout = getGeometryLayout(object); return new MultiLineString_default(object.paths, layout); } function getGeometryLayout(object) { let layout = "XY"; if (object.hasZ === true && object.hasM === true) { layout = "XYZM"; } else if (object.hasZ === true) { layout = "XYZ"; } else if (object.hasM === true) { layout = "XYM"; } return layout; } function readMultiPointGeometry(object) { const layout = getGeometryLayout(object); return new MultiPoint_default(object.points, layout); } function readMultiPolygonGeometry(object) { const layout = getGeometryLayout(object); return new MultiPolygon_default(object.rings, layout); } function readPolygonGeometry(object) { const layout = getGeometryLayout(object); return new Polygon_default(object.rings, layout); } function writePointGeometry(geometry, options) { const coordinates = geometry.getCoordinates(); let esriJSON; const layout = geometry.getLayout(); if (layout === "XYZ") { esriJSON = { x: coordinates[0], y: coordinates[1], z: coordinates[2] }; } else if (layout === "XYM") { esriJSON = { x: coordinates[0], y: coordinates[1], m: coordinates[2] }; } else if (layout === "XYZM") { esriJSON = { x: coordinates[0], y: coordinates[1], z: coordinates[2], m: coordinates[3] }; } else if (layout === "XY") { esriJSON = { x: coordinates[0], y: coordinates[1] }; } else { throw new Error("Invalid geometry layout"); } return esriJSON; } function getHasZM(geometry) { const layout = geometry.getLayout(); return { hasZ: layout === "XYZ" || layout === "XYZM", hasM: layout === "XYM" || layout === "XYZM" }; } function writeLineStringGeometry(lineString, options) { const hasZM = getHasZM(lineString); return { hasZ: hasZM.hasZ, hasM: hasZM.hasM, paths: [ /** @type {Array} */ lineString.getCoordinates() ] }; } function writePolygonGeometry(polygon, options) { const hasZM = getHasZM(polygon); return { hasZ: hasZM.hasZ, hasM: hasZM.hasM, rings: ( /** @type {Array>} */ polygon.getCoordinates(false) ) }; } function writeMultiLineStringGeometry(multiLineString, options) { const hasZM = getHasZM(multiLineString); return { hasZ: hasZM.hasZ, hasM: hasZM.hasM, paths: ( /** @type {Array>} */ multiLineString.getCoordinates() ) }; } function writeMultiPointGeometry(multiPoint, options) { const hasZM = getHasZM(multiPoint); return { hasZ: hasZM.hasZ, hasM: hasZM.hasM, points: ( /** @type {Array} */ multiPoint.getCoordinates() ) }; } function writeMultiPolygonGeometry(geometry, options) { const hasZM = getHasZM(geometry); const coordinates = geometry.getCoordinates(false); const output = []; for (let i = 0; i < coordinates.length; i++) { for (let x = coordinates[i].length - 1; x >= 0; x--) { output.push(coordinates[i][x]); } } return { hasZ: hasZM.hasZ, hasM: hasZM.hasM, rings: ( /** @type {Array>} */ output ) }; } function writeGeometry(geometry, options) { const geometryWriter = GEOMETRY_WRITERS[geometry.getType()]; return geometryWriter( transformGeometryWithOptions(geometry, true, options), options ); } var EsriJSON_default = EsriJSON; // node_modules/ol/xml.js var XML_SCHEMA_INSTANCE_URI = "http://www.w3.org/2001/XMLSchema-instance"; function createElementNS(namespaceURI, qualifiedName) { return getDocument().createElementNS(namespaceURI, qualifiedName); } function getAllTextContent(node, normalizeWhitespace) { return getAllTextContent_(node, normalizeWhitespace, []).join(""); } function getAllTextContent_(node, normalizeWhitespace, accumulator) { if (node.nodeType == Node.CDATA_SECTION_NODE || node.nodeType == Node.TEXT_NODE) { if (normalizeWhitespace) { accumulator.push(String(node.nodeValue).replace(/(\r\n|\r|\n)/g, "")); } else { accumulator.push(node.nodeValue); } } else { let n; for (n = node.firstChild; n; n = n.nextSibling) { getAllTextContent_(n, normalizeWhitespace, accumulator); } } return accumulator; } function isDocument(object) { return "documentElement" in object; } function getAttributeNS(node, namespaceURI, name) { return node.getAttributeNS(namespaceURI, name) || ""; } function parse(xml) { return new DOMParser().parseFromString(xml, "application/xml"); } function makeArrayExtender(valueReader, thisArg) { return ( /** * @param {Node} node Node. * @param {Array<*>} objectStack Object stack. * @this {*} */ (function(node, objectStack) { const value = valueReader.call(thisArg ?? this, node, objectStack); if (value !== void 0) { const array = ( /** @type {Array<*>} */ objectStack[objectStack.length - 1] ); extend(array, value); } }) ); } function makeArrayPusher(valueReader, thisArg) { return ( /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @this {*} */ (function(node, objectStack) { const value = valueReader.call(thisArg ?? this, node, objectStack); if (value !== void 0) { const array = ( /** @type {Array<*>} */ objectStack[objectStack.length - 1] ); array.push(value); } }) ); } function makeReplacer(valueReader, thisArg) { return ( /** * @param {Node} node Node. * @param {Array<*>} objectStack Object stack. * @this {*} */ (function(node, objectStack) { const value = valueReader.call(thisArg ?? this, node, objectStack); if (value !== void 0) { objectStack[objectStack.length - 1] = value; } }) ); } function makeObjectPropertyPusher(valueReader, property, thisArg) { return ( /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @this {*} */ (function(node, objectStack) { const value = valueReader.call(thisArg ?? this, node, objectStack); if (value !== void 0) { const object = ( /** @type {!Object} */ objectStack[objectStack.length - 1] ); const name = property !== void 0 ? property : node.localName; let array; if (name in object) { array = object[name]; } else { array = []; object[name] = array; } array.push(value); } }) ); } function makeObjectPropertySetter(valueReader, property, thisArg) { return ( /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @this {*} */ (function(node, objectStack) { const value = valueReader.call(thisArg ?? this, node, objectStack); if (value !== void 0) { const object = ( /** @type {!Object} */ objectStack[objectStack.length - 1] ); const name = property !== void 0 ? property : node.localName; object[name] = value; } }) ); } function makeChildAppender(nodeWriter, thisArg) { return ( /** * @param {Element} node Node. * @param {*} value Value to be written. * @param {Array<*>} objectStack Object stack. * @this {*} */ (function(node, value, objectStack) { nodeWriter.call(thisArg ?? this, node, value, objectStack); const parent = ( /** @type {NodeStackItem} */ objectStack[objectStack.length - 1] ); const parentNode = parent.node; parentNode.appendChild(node); }) ); } function makeArraySerializer(nodeWriter, thisArg) { let serializersNS, nodeFactory; return function(node, value, objectStack) { if (serializersNS === void 0) { serializersNS = {}; const serializers = {}; serializers[node.localName] = nodeWriter; serializersNS[node.namespaceURI] = serializers; nodeFactory = makeSimpleNodeFactory(node.localName); } serialize(serializersNS, nodeFactory, value, objectStack); }; } function makeSimpleNodeFactory(fixedNodeName, fixedNamespaceURI) { return ( /** * @param {*} value Value. * @param {Array<*>} objectStack Object stack. * @param {string} [newNodeName] Node name. * @return {Node} Node. */ (function(value, objectStack, newNodeName) { const context = ( /** @type {NodeStackItem} */ objectStack[objectStack.length - 1] ); const node = context.node; let nodeName = fixedNodeName; if (nodeName === void 0) { nodeName = newNodeName; } const namespaceURI = fixedNamespaceURI !== void 0 ? fixedNamespaceURI : node.namespaceURI; return createElementNS( namespaceURI, /** @type {string} */ nodeName ); }) ); } var OBJECT_PROPERTY_NODE_FACTORY = makeSimpleNodeFactory(); function makeSequence(object, orderedKeys) { const length = orderedKeys.length; const sequence = new Array(length); for (let i = 0; i < length; ++i) { sequence[i] = object[orderedKeys[i]]; } return sequence; } function makeStructureNS(namespaceURIs, structure, structureNS) { structureNS = structureNS !== void 0 ? structureNS : {}; let i, ii; for (i = 0, ii = namespaceURIs.length; i < ii; ++i) { structureNS[namespaceURIs[i]] = structure; } return structureNS; } function parseNode(parsersNS, node, objectStack, thisArg) { let n; for (n = node.firstElementChild; n; n = n.nextElementSibling) { const parsers = parsersNS[n.namespaceURI]; if (parsers !== void 0) { const parser = parsers[n.localName]; if (parser !== void 0) { parser.call(thisArg, n, objectStack); } } } } function pushParseAndPop(object, parsersNS, node, objectStack, thisArg) { objectStack.push(object); parseNode(parsersNS, node, objectStack, thisArg); return ( /** @type {T} */ objectStack.pop() ); } function serialize(serializersNS, nodeFactory, values, objectStack, keys, thisArg) { const length = (keys !== void 0 ? keys : values).length; let value, node; for (let i = 0; i < length; ++i) { value = values[i]; if (value !== void 0) { node = nodeFactory.call( thisArg, value, objectStack, keys !== void 0 ? keys[i] : void 0 ); if (node !== void 0) { serializersNS[node.namespaceURI][node.localName].call( thisArg, node, value, objectStack ); } } } } function pushSerializeAndPop(object, serializersNS, nodeFactory, values, objectStack, keys, thisArg) { objectStack.push(object); serialize(serializersNS, nodeFactory, values, objectStack, keys, thisArg); return ( /** @type {O|undefined} */ objectStack.pop() ); } var xmlSerializer_ = void 0; function getXMLSerializer() { if (xmlSerializer_ === void 0 && typeof XMLSerializer !== "undefined") { xmlSerializer_ = new XMLSerializer(); } return xmlSerializer_; } var document_ = void 0; function getDocument() { if (document_ === void 0 && typeof document !== "undefined") { document_ = document.implementation.createDocument("", "", null); } return document_; } // node_modules/ol/format/XMLFeature.js var XMLFeature = class extends Feature_default3 { constructor() { super(); this.xmlSerializer_ = getXMLSerializer(); } /** * @return {import("./Feature.js").Type} Format. * @override */ getType() { return "xml"; } /** * Read a single feature. * * @param {Document|Element|Object|string} source Source. * @param {import("./Feature.js").ReadOptions} [options] Read options. * @return {import("../Feature.js").default} Feature. * @api * @override */ readFeature(source, options) { if (!source) { return null; } if (typeof source === "string") { const doc = parse(source); return this.readFeatureFromDocument(doc, options); } if (isDocument(source)) { return this.readFeatureFromDocument( /** @type {Document} */ source, options ); } return this.readFeatureFromNode( /** @type {Element} */ source, options ); } /** * @param {Document} doc Document. * @param {import("./Feature.js").ReadOptions} [options] Options. * @return {import("../Feature.js").default} Feature. */ readFeatureFromDocument(doc, options) { const features = this.readFeaturesFromDocument(doc, options); if (features.length > 0) { return features[0]; } return null; } /** * @param {Element} node Node. * @param {import("./Feature.js").ReadOptions} [options] Options. * @return {import("../Feature.js").default} Feature. */ readFeatureFromNode(node, options) { return null; } /** * Read all features from a feature collection. * * @param {Document|Element|Object|string} source Source. * @param {import("./Feature.js").ReadOptions} [options] Options. * @return {Array} Features. * @api * @override */ readFeatures(source, options) { if (!source) { return []; } if (typeof source === "string") { const doc = parse(source); return this.readFeaturesFromDocument(doc, options); } if (isDocument(source)) { return this.readFeaturesFromDocument( /** @type {Document} */ source, options ); } return this.readFeaturesFromNode( /** @type {Element} */ source, options ); } /** * @param {Document} doc Document. * @param {import("./Feature.js").ReadOptions} [options] Options. * @protected * @return {Array} Features. */ readFeaturesFromDocument(doc, options) { const features = []; for (let n = doc.firstChild; n; n = n.nextSibling) { if (n.nodeType == Node.ELEMENT_NODE) { extend( features, this.readFeaturesFromNode( /** @type {Element} */ n, options ) ); } } return features; } /** * @abstract * @param {Element} node Node. * @param {import("./Feature.js").ReadOptions} [options] Options. * @protected * @return {Array} Features. */ readFeaturesFromNode(node, options) { return abstract(); } /** * Read a single geometry from a source. * * @param {Document|Element|Object|string} source Source. * @param {import("./Feature.js").ReadOptions} [options] Read options. * @return {import("../geom/Geometry.js").default} Geometry. * @override */ readGeometry(source, options) { if (!source) { return null; } if (typeof source === "string") { const doc = parse(source); return this.readGeometryFromDocument(doc, options); } if (isDocument(source)) { return this.readGeometryFromDocument( /** @type {Document} */ source, options ); } return this.readGeometryFromNode( /** @type {Element} */ source, options ); } /** * @param {Document} doc Document. * @param {import("./Feature.js").ReadOptions} [options] Options. * @protected * @return {import("../geom/Geometry.js").default} Geometry. */ readGeometryFromDocument(doc, options) { return null; } /** * @param {Element} node Node. * @param {import("./Feature.js").ReadOptions} [options] Options. * @protected * @return {import("../geom/Geometry.js").default} Geometry. */ readGeometryFromNode(node, options) { return null; } /** * Read the projection from the source. * * @param {Document|Element|Object|string} source Source. * @return {import("../proj/Projection.js").default} Projection. * @api * @override */ readProjection(source) { if (!source) { return null; } if (typeof source === "string") { const doc = parse(source); return this.readProjectionFromDocument(doc); } if (isDocument(source)) { return this.readProjectionFromDocument( /** @type {Document} */ source ); } return this.readProjectionFromNode( /** @type {Element} */ source ); } /** * @param {Document} doc Document. * @protected * @return {import("../proj/Projection.js").default} Projection. */ readProjectionFromDocument(doc) { return this.dataProjection; } /** * @param {Element} node Node. * @protected * @return {import("../proj/Projection.js").default} Projection. */ readProjectionFromNode(node) { return this.dataProjection; } /** * Encode a feature as string. * * @param {import("../Feature.js").default} feature Feature. * @param {import("./Feature.js").WriteOptions} [options] Write options. * @return {string} Encoded feature. * @override */ writeFeature(feature, options) { const node = this.writeFeatureNode(feature, options); return this.xmlSerializer_.serializeToString(node); } /** * @param {import("../Feature.js").default} feature Feature. * @param {import("./Feature.js").WriteOptions} [options] Options. * @protected * @return {Node} Node. */ writeFeatureNode(feature, options) { return null; } /** * Encode an array of features as string. * * @param {Array} features Features. * @param {import("./Feature.js").WriteOptions} [options] Write options. * @return {string} Result. * @api * @override */ writeFeatures(features, options) { const node = this.writeFeaturesNode(features, options); return this.xmlSerializer_.serializeToString(node); } /** * @param {Array} features Features. * @param {import("./Feature.js").WriteOptions} [options] Options. * @return {Node} Node. */ writeFeaturesNode(features, options) { return null; } /** * Encode a geometry as string. * * @param {import("../geom/Geometry.js").default} geometry Geometry. * @param {import("./Feature.js").WriteOptions} [options] Write options. * @return {string} Encoded geometry. * @override */ writeGeometry(geometry, options) { const node = this.writeGeometryNode(geometry, options); return this.xmlSerializer_.serializeToString(node); } /** * @param {import("../geom/Geometry.js").default} geometry Geometry. * @param {import("./Feature.js").WriteOptions} [options] Options. * @return {Node} Node. */ writeGeometryNode(geometry, options) { return null; } }; var XMLFeature_default = XMLFeature; // node_modules/ol/format/GMLBase.js var GMLNS = "http://www.opengis.net/gml"; var ONLY_WHITESPACE_RE = /^\s*$/; var GMLBase = class extends XMLFeature_default { /** * @param {Options} [options] Optional configuration object. */ constructor(options) { super(); options = options ? options : {}; this.featureType = options.featureType; this.featureNS = options.featureNS; this.srsName = options.srsName; this.schemaLocation = ""; this.FEATURE_COLLECTION_PARSERS = {}; this.FEATURE_COLLECTION_PARSERS[this.namespace] = { "featureMember": makeArrayPusher(this.readFeaturesInternal), "featureMembers": makeReplacer(this.readFeaturesInternal) }; this.supportedMediaTypes = ["application/gml+xml"]; } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {Array | undefined} Features. */ readFeaturesInternal(node, objectStack) { const localName = node.localName; let features = null; if (localName == "FeatureCollection") { features = pushParseAndPop( [], this.FEATURE_COLLECTION_PARSERS, node, objectStack, this ); } else if (localName == "featureMembers" || localName == "featureMember" || localName == "member") { const context = objectStack[0]; let featureType = context["featureType"]; let featureNS = context["featureNS"]; const prefix = "p"; const defaultPrefix = "p0"; if (!featureType && node.childNodes) { featureType = [], featureNS = {}; for (let i = 0, ii = node.childNodes.length; i < ii; ++i) { const child = ( /** @type {Element} */ node.childNodes[i] ); if (child.nodeType === 1) { const ft = child.nodeName.split(":").pop(); if (!featureType.includes(ft)) { let key = ""; let count = 0; const uri = child.namespaceURI; for (const candidate in featureNS) { if (featureNS[candidate] === uri) { key = candidate; break; } ++count; } if (!key) { key = prefix + count; featureNS[key] = uri; } featureType.push(key + ":" + ft); } } } if (localName != "featureMember") { context["featureType"] = featureType; context["featureNS"] = featureNS; } } if (typeof featureNS === "string") { const ns = featureNS; featureNS = {}; featureNS[defaultPrefix] = ns; } const parsersNS = {}; const featureTypes = Array.isArray(featureType) ? featureType : [featureType]; for (const p in featureNS) { const parsers = {}; for (let i = 0, ii = featureTypes.length; i < ii; ++i) { const featurePrefix = featureTypes[i].includes(":") ? featureTypes[i].split(":")[0] : defaultPrefix; if (featurePrefix === p) { parsers[featureTypes[i].split(":").pop()] = localName == "featureMembers" ? makeArrayPusher(this.readFeatureElement, this) : makeReplacer(this.readFeatureElement, this); } } parsersNS[featureNS[p]] = parsers; } if (localName == "featureMember" || localName == "member") { features = pushParseAndPop(void 0, parsersNS, node, objectStack); } else { features = pushParseAndPop([], parsersNS, node, objectStack); } } if (features === null) { features = []; } return features; } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {import("../geom/Geometry.js").default|import("../extent.js").Extent|undefined} Geometry. */ readGeometryOrExtent(node, objectStack) { const context = ( /** @type {Object} */ objectStack[0] ); context["srsName"] = node.firstElementChild.getAttribute("srsName"); context["srsDimension"] = node.firstElementChild.getAttribute("srsDimension"); return pushParseAndPop( null, this.GEOMETRY_PARSERS, node, objectStack, this ); } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {import("../extent.js").Extent|undefined} Geometry. */ readExtentElement(node, objectStack) { const context = ( /** @type {Object} */ objectStack[0] ); const extent = ( /** @type {import("../extent.js").Extent} */ this.readGeometryOrExtent(node, objectStack) ); return extent ? transformExtentWithOptions(extent, context) : void 0; } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {import("../geom/Geometry.js").default|undefined} Geometry. */ readGeometryElement(node, objectStack) { const context = ( /** @type {Object} */ objectStack[0] ); const geometry = ( /** @type {import("../geom/Geometry.js").default} */ this.readGeometryOrExtent(node, objectStack) ); return geometry ? transformGeometryWithOptions(geometry, false, context) : void 0; } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @param {boolean} asFeature whether result should be wrapped as a feature. * @return {Feature|Object} Feature */ readFeatureElementInternal(node, objectStack, asFeature) { let geometryName; const values = {}; for (let n = node.firstElementChild; n; n = n.nextElementSibling) { let value; const localName = n.localName; if (n.childNodes.length === 0 || n.childNodes.length === 1 && (n.firstChild.nodeType === 3 || n.firstChild.nodeType === 4)) { value = getAllTextContent(n, false); if (ONLY_WHITESPACE_RE.test(value)) { value = void 0; } } else { if (asFeature) { value = localName === "boundedBy" ? this.readExtentElement(n, objectStack) : this.readGeometryElement(n, objectStack); } if (!value) { value = this.readFeatureElementInternal(n, objectStack, false); } else if (localName !== "boundedBy") { geometryName = localName; } } const len = n.attributes.length; if (len > 0 && !(value instanceof Geometry_default)) { value = { _content_: value }; for (let i = 0; i < len; i++) { const attName = n.attributes[i].name; value[attName] = n.attributes[i].value; } } if (values[localName]) { if (!(values[localName] instanceof Array)) { values[localName] = [values[localName]]; } values[localName].push(value); } else { values[localName] = value; } } if (!asFeature) { return values; } const feature = new Feature_default(values); if (geometryName) { feature.setGeometryName(geometryName); } const fid = node.getAttribute("fid") || getAttributeNS(node, this.namespace, "id"); if (fid) { feature.setId(fid); } return feature; } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {Feature} Feature. */ readFeatureElement(node, objectStack) { return this.readFeatureElementInternal(node, objectStack, true); } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {Point|undefined} Point. */ readPoint(node, objectStack) { const flatCoordinates = this.readFlatCoordinatesFromNode(node, objectStack); if (flatCoordinates) { return new Point_default(flatCoordinates, "XYZ"); } } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {MultiPoint|undefined} MultiPoint. */ readMultiPoint(node, objectStack) { const coordinates = pushParseAndPop( [], this.MULTIPOINT_PARSERS, node, objectStack, this ); if (coordinates) { return new MultiPoint_default(coordinates); } return void 0; } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {MultiLineString|undefined} MultiLineString. */ readMultiLineString(node, objectStack) { const lineStrings = pushParseAndPop( [], this.MULTILINESTRING_PARSERS, node, objectStack, this ); if (lineStrings) { return new MultiLineString_default(lineStrings); } } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {MultiPolygon|undefined} MultiPolygon. */ readMultiPolygon(node, objectStack) { const polygons = pushParseAndPop( [], this.MULTIPOLYGON_PARSERS, node, objectStack, this ); if (polygons) { return new MultiPolygon_default(polygons); } } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. */ pointMemberParser(node, objectStack) { parseNode(this.POINTMEMBER_PARSERS, node, objectStack, this); } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. */ lineStringMemberParser(node, objectStack) { parseNode(this.LINESTRINGMEMBER_PARSERS, node, objectStack, this); } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. */ polygonMemberParser(node, objectStack) { parseNode(this.POLYGONMEMBER_PARSERS, node, objectStack, this); } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {LineString|undefined} LineString. */ readLineString(node, objectStack) { const flatCoordinates = this.readFlatCoordinatesFromNode(node, objectStack); if (flatCoordinates) { const lineString = new LineString_default(flatCoordinates, "XYZ"); return lineString; } return void 0; } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {Array|undefined} LinearRing flat coordinates. */ readFlatLinearRing(node, objectStack) { const ring = pushParseAndPop( null, this.GEOMETRY_FLAT_COORDINATES_PARSERS, node, objectStack, this ); if (ring) { return ring; } return void 0; } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {LinearRing|undefined} LinearRing. */ readLinearRing(node, objectStack) { const flatCoordinates = this.readFlatCoordinatesFromNode(node, objectStack); if (flatCoordinates) { return new LinearRing_default(flatCoordinates, "XYZ"); } } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {Polygon|undefined} Polygon. */ readPolygon(node, objectStack) { const flatLinearRings = pushParseAndPop( [null], this.FLAT_LINEAR_RINGS_PARSERS, node, objectStack, this ); if (flatLinearRings && flatLinearRings[0]) { const flatCoordinates = flatLinearRings[0]; const ends = [flatCoordinates.length]; let i, ii; for (i = 1, ii = flatLinearRings.length; i < ii; ++i) { extend(flatCoordinates, flatLinearRings[i]); ends.push(flatCoordinates.length); } return new Polygon_default(flatCoordinates, "XYZ", ends); } return void 0; } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {Array} Flat coordinates. */ readFlatCoordinatesFromNode(node, objectStack) { return pushParseAndPop( null, this.GEOMETRY_FLAT_COORDINATES_PARSERS, node, objectStack, this ); } /** * @param {Element} node Node. * @param {import("./Feature.js").ReadOptions} [options] Options. * @protected * @return {import("../geom/Geometry.js").default} Geometry. * @override */ readGeometryFromNode(node, options) { const geometry = this.readGeometryElement(node, [ this.getReadOptions(node, options ? options : {}) ]); return geometry ? geometry : null; } /** * @param {Element} node Node. * @param {import("./Feature.js").ReadOptions} [options] Options. * @return {Array} Features. * @override */ readFeaturesFromNode(node, options) { const internalOptions = { featureType: this.featureType, featureNS: this.featureNS }; if (internalOptions) { Object.assign(internalOptions, this.getReadOptions(node, options)); } const features = this.readFeaturesInternal(node, [internalOptions]); return features || []; } /** * @param {Element} node Node. * @return {import("../proj/Projection.js").default} Projection. * @override */ readProjectionFromNode(node) { return get( this.srsName ? this.srsName : node.firstElementChild.getAttribute("srsName") ); } }; GMLBase.prototype.namespace = GMLNS; GMLBase.prototype.FLAT_LINEAR_RINGS_PARSERS = { "http://www.opengis.net/gml": {} }; GMLBase.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS = { "http://www.opengis.net/gml": {} }; GMLBase.prototype.GEOMETRY_PARSERS = { "http://www.opengis.net/gml": {} }; GMLBase.prototype.MULTIPOINT_PARSERS = { "http://www.opengis.net/gml": { "pointMember": makeArrayPusher(GMLBase.prototype.pointMemberParser), "pointMembers": makeArrayPusher(GMLBase.prototype.pointMemberParser) } }; GMLBase.prototype.MULTILINESTRING_PARSERS = { "http://www.opengis.net/gml": { "lineStringMember": makeArrayPusher( GMLBase.prototype.lineStringMemberParser ), "lineStringMembers": makeArrayPusher( GMLBase.prototype.lineStringMemberParser ) } }; GMLBase.prototype.MULTIPOLYGON_PARSERS = { "http://www.opengis.net/gml": { "polygonMember": makeArrayPusher(GMLBase.prototype.polygonMemberParser), "polygonMembers": makeArrayPusher(GMLBase.prototype.polygonMemberParser) } }; GMLBase.prototype.POINTMEMBER_PARSERS = { "http://www.opengis.net/gml": { "Point": makeArrayPusher(GMLBase.prototype.readFlatCoordinatesFromNode) } }; GMLBase.prototype.LINESTRINGMEMBER_PARSERS = { "http://www.opengis.net/gml": { "LineString": makeArrayPusher(GMLBase.prototype.readLineString) } }; GMLBase.prototype.POLYGONMEMBER_PARSERS = { "http://www.opengis.net/gml": { "Polygon": makeArrayPusher(GMLBase.prototype.readPolygon) } }; GMLBase.prototype.RING_PARSERS = { "http://www.opengis.net/gml": { "LinearRing": makeReplacer(GMLBase.prototype.readFlatLinearRing) } }; var GMLBase_default = GMLBase; // node_modules/ol/format/xsd.js function readBoolean(node) { const s = getAllTextContent(node, false); return readBooleanString(s); } function readBooleanString(string) { const m = /^\s*(true|1)|(false|0)\s*$/.exec(string); if (m) { return m[1] !== void 0 || false; } return void 0; } function readDateTime(node) { const s = getAllTextContent(node, false); const dateTime = Date.parse(s); return isNaN(dateTime) ? void 0 : dateTime / 1e3; } function readDecimal(node) { const s = getAllTextContent(node, false); return readDecimalString(s); } function readDecimalString(string) { const m = /^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(string); if (m) { return parseFloat(m[1]); } return void 0; } function readPositiveInteger(node) { const s = getAllTextContent(node, false); return readNonNegativeIntegerString(s); } function readNonNegativeIntegerString(string) { const m = /^\s*(\d+)\s*$/.exec(string); if (m) { return parseInt(m[1], 10); } return void 0; } function readString(node) { return getAllTextContent(node, false).trim(); } function writeBooleanTextNode(node, bool) { writeStringTextNode(node, bool ? "1" : "0"); } function writeCDATASection(node, string) { node.appendChild(getDocument().createCDATASection(string)); } function writeDateTimeTextNode(node, dateTime) { const date = new Date(dateTime * 1e3); const string = date.getUTCFullYear() + "-" + padNumber(date.getUTCMonth() + 1, 2) + "-" + padNumber(date.getUTCDate(), 2) + "T" + padNumber(date.getUTCHours(), 2) + ":" + padNumber(date.getUTCMinutes(), 2) + ":" + padNumber(date.getUTCSeconds(), 2) + "Z"; node.appendChild(getDocument().createTextNode(string)); } function writeDecimalTextNode(node, decimal) { const string = decimal.toPrecision(); node.appendChild(getDocument().createTextNode(string)); } function writeNonNegativeIntegerTextNode(node, nonNegativeInteger) { const string = nonNegativeInteger.toString(); node.appendChild(getDocument().createTextNode(string)); } var whiteSpaceStart = /^\s/; var whiteSpaceEnd = /\s$/; var cdataCharacters = /(\n|\t|\r|<|&| {2})/; function writeStringTextNode(node, string) { if (typeof string === "string" && (whiteSpaceStart.test(string) || whiteSpaceEnd.test(string) || cdataCharacters.test(string))) { string.split("]]>").forEach((part, i, a) => { if (i < a.length - 1) { part += "]]"; } if (i > 0) { part = ">" + part; } writeCDATASection(node, part); }); } else { node.appendChild(getDocument().createTextNode(string)); } } // node_modules/ol/format/GML2.js var schemaLocation = GMLNS + " http://schemas.opengis.net/gml/2.1.2/feature.xsd"; var MULTIGEOMETRY_TO_MEMBER_NODENAME = { "MultiLineString": "lineStringMember", "MultiCurve": "curveMember", "MultiPolygon": "polygonMember", "MultiSurface": "surfaceMember" }; var GML2 = class extends GMLBase_default { /** * @param {import("./GMLBase.js").Options} [options] Optional configuration object. */ constructor(options) { options = options ? options : {}; super(options); this.FEATURE_COLLECTION_PARSERS[GMLNS]["featureMember"] = makeArrayPusher( this.readFeaturesInternal ); this.schemaLocation = options.schemaLocation ? options.schemaLocation : schemaLocation; } /** * @param {Node} node Node. * @param {Array<*>} objectStack Object stack. * @return {Array|undefined} Flat coordinates. */ readFlatCoordinates(node, objectStack) { const s = getAllTextContent(node, false).replace(/^\s*|\s*$/g, ""); const context = ( /** @type {import("../xml.js").NodeStackItem} */ objectStack[0] ); const containerSrs = context["srsName"]; let axisOrientation = "enu"; if (containerSrs) { const proj = get(containerSrs); if (proj) { axisOrientation = proj.getAxisOrientation(); } } const coordsGroups = s.trim().split(/\s+/); const flatCoordinates = []; for (let i = 0, ii = coordsGroups.length; i < ii; i++) { const coords = coordsGroups[i].split(/,+/); const x = parseFloat(coords[0]); const y = parseFloat(coords[1]); const z = coords.length === 3 ? parseFloat(coords[2]) : 0; if (axisOrientation.startsWith("en")) { flatCoordinates.push(x, y, z); } else { flatCoordinates.push(y, x, z); } } return flatCoordinates; } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {import("../extent.js").Extent|undefined} Envelope. */ readBox(node, objectStack) { const flatCoordinates = pushParseAndPop( [null], this.BOX_PARSERS_, node, objectStack, this ); return createOrUpdate( flatCoordinates[1][0], flatCoordinates[1][1], flatCoordinates[1][3], flatCoordinates[1][4] ); } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. */ innerBoundaryIsParser(node, objectStack) { const flatLinearRing = pushParseAndPop( void 0, this.RING_PARSERS, node, objectStack, this ); if (flatLinearRing) { const flatLinearRings = ( /** @type {Array>} */ objectStack[objectStack.length - 1] ); flatLinearRings.push(flatLinearRing); } } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. */ outerBoundaryIsParser(node, objectStack) { const flatLinearRing = pushParseAndPop( void 0, this.RING_PARSERS, node, objectStack, this ); if (flatLinearRing) { const flatLinearRings = ( /** @type {Array>} */ objectStack[objectStack.length - 1] ); flatLinearRings[0] = flatLinearRing; } } /** * @const * @param {*} value Value. * @param {Array<*>} objectStack Object stack. * @param {string} [nodeName] Node name. * @return {Element|undefined} Node. * @private */ GEOMETRY_NODE_FACTORY_(value, objectStack, nodeName) { const context = objectStack[objectStack.length - 1]; const multiSurface = context["multiSurface"]; const surface = context["surface"]; const multiCurve = context["multiCurve"]; if (!Array.isArray(value)) { nodeName = /** @type {import("../geom/Geometry.js").default} */ value.getType(); if (nodeName === "MultiPolygon" && multiSurface === true) { nodeName = "MultiSurface"; } else if (nodeName === "Polygon" && surface === true) { nodeName = "Surface"; } else if (nodeName === "MultiLineString" && multiCurve === true) { nodeName = "MultiCurve"; } } else { nodeName = "Envelope"; } return createElementNS("http://www.opengis.net/gml", nodeName); } /** * @param {Element} node Node. * @param {import("../Feature.js").default} feature Feature. * @param {Array<*>} objectStack Node stack. */ writeFeatureElement(node, feature, objectStack) { const fid = feature.getId(); if (fid) { node.setAttribute( "fid", /** @type {string} */ fid ); } const context = ( /** @type {Object} */ objectStack[objectStack.length - 1] ); const featureNS = context["featureNS"]; const geometryName = feature.getGeometryName(); if (!context.serializers) { context.serializers = {}; context.serializers[featureNS] = {}; } const keys = []; const values = []; if (feature.hasProperties()) { const properties = feature.getProperties(); for (const key in properties) { const value = properties[key]; if (value !== null && value !== void 0) { keys.push(key); values.push(value); if (key == geometryName || typeof /** @type {?} */ value.getSimplifiedGeometry === "function") { if (!(key in context.serializers[featureNS])) { context.serializers[featureNS][key] = makeChildAppender( this.writeGeometryElement, this ); } } else { if (!(key in context.serializers[featureNS])) { context.serializers[featureNS][key] = makeChildAppender(writeStringTextNode); } } } } } const item = Object.assign({}, context); item.node = node; pushSerializeAndPop( /** @type {import("../xml.js").NodeStackItem} */ item, context.serializers, makeSimpleNodeFactory(void 0, featureNS), values, objectStack, keys ); } /** * @param {Element} node Node. * @param {import("../geom/LineString.js").default} geometry LineString geometry. * @param {Array<*>} objectStack Node stack. */ writeCurveOrLineString(node, geometry, objectStack) { const context = objectStack[objectStack.length - 1]; const srsName = context["srsName"]; if (node.nodeName !== "LineStringSegment" && srsName) { node.setAttribute("srsName", srsName); } if (node.nodeName === "LineString" || node.nodeName === "LineStringSegment") { const coordinates = this.createCoordinatesNode_(node.namespaceURI); node.appendChild(coordinates); this.writeCoordinates_(coordinates, geometry, objectStack); } else if (node.nodeName === "Curve") { const segments = createElementNS(node.namespaceURI, "segments"); node.appendChild(segments); this.writeCurveSegments_(segments, geometry, objectStack); } } /** * @param {Element} node Node. * @param {import("../geom/LineString.js").default} line LineString geometry. * @param {Array<*>} objectStack Node stack. */ writeLineStringOrCurveMember(node, line, objectStack) { const child = this.GEOMETRY_NODE_FACTORY_(line, objectStack); if (child) { node.appendChild(child); this.writeCurveOrLineString(child, line, objectStack); } } /** * @param {Element} node Node. * @param {import("../geom/MultiLineString.js").default} geometry MultiLineString geometry. * @param {Array<*>} objectStack Node stack. */ writeMultiCurveOrLineString(node, geometry, objectStack) { const context = objectStack[objectStack.length - 1]; const hasZ = context["hasZ"]; const srsName = context["srsName"]; const curve = context["curve"]; if (srsName) { node.setAttribute("srsName", srsName); } const lines = geometry.getLineStrings(); pushSerializeAndPop( { node, hasZ, srsName, curve }, this.LINESTRINGORCURVEMEMBER_SERIALIZERS, this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, lines, objectStack, void 0, this ); } /** * @param {Node} node Node. * @param {import("../geom/Geometry.js").default|import("../extent.js").Extent} geometry Geometry. * @param {Array<*>} objectStack Node stack. */ writeGeometryElement(node, geometry, objectStack) { const context = ( /** @type {import("./Feature.js").WriteOptions} */ objectStack[objectStack.length - 1] ); const item = Object.assign({}, context); item["node"] = node; let value; if (Array.isArray(geometry)) { value = transformExtentWithOptions( /** @type {import("../extent.js").Extent} */ geometry, context ); } else { value = transformGeometryWithOptions( /** @type {import("../geom/Geometry.js").default} */ geometry, true, context ); } pushSerializeAndPop( /** @type {import("../xml.js").NodeStackItem} */ item, this.GEOMETRY_SERIALIZERS, this.GEOMETRY_NODE_FACTORY_, [value], objectStack, void 0, this ); } /** * @param {string} namespaceURI XML namespace. * @return {Element} coordinates node. * @private */ createCoordinatesNode_(namespaceURI) { const coordinates = createElementNS(namespaceURI, "coordinates"); coordinates.setAttribute("decimal", "."); coordinates.setAttribute("cs", ","); coordinates.setAttribute("ts", " "); return coordinates; } /** * @param {Node} node Node. * @param {import("../geom/LineString.js").default|import("../geom/LinearRing.js").default} value Geometry. * @param {Array<*>} objectStack Node stack. * @private */ writeCoordinates_(node, value, objectStack) { const context = objectStack[objectStack.length - 1]; const hasZ = context["hasZ"]; const srsName = context["srsName"]; const points = value.getCoordinates(); const len = points.length; const parts = new Array(len); for (let i = 0; i < len; ++i) { const point = points[i]; parts[i] = this.getCoords_(point, srsName, hasZ); } writeStringTextNode(node, parts.join(" ")); } /** * @param {Element} node Node. * @param {import("../geom/LineString.js").default} line LineString geometry. * @param {Array<*>} objectStack Node stack. * @private */ writeCurveSegments_(node, line, objectStack) { const child = createElementNS(node.namespaceURI, "LineStringSegment"); node.appendChild(child); this.writeCurveOrLineString(child, line, objectStack); } /** * @param {Element} node Node. * @param {import("../geom/Polygon.js").default} geometry Polygon geometry. * @param {Array<*>} objectStack Node stack. */ writeSurfaceOrPolygon(node, geometry, objectStack) { const context = objectStack[objectStack.length - 1]; const hasZ = context["hasZ"]; const srsName = context["srsName"]; if (node.nodeName !== "PolygonPatch" && srsName) { node.setAttribute("srsName", srsName); } if (node.nodeName === "Polygon" || node.nodeName === "PolygonPatch") { const rings = geometry.getLinearRings(); pushSerializeAndPop( { node, hasZ, srsName }, this.RING_SERIALIZERS, this.RING_NODE_FACTORY_, rings, objectStack, void 0, this ); } else if (node.nodeName === "Surface") { const patches = createElementNS(node.namespaceURI, "patches"); node.appendChild(patches); this.writeSurfacePatches_(patches, geometry, objectStack); } } /** * @param {*} value Value. * @param {Array<*>} objectStack Object stack. * @param {string} [nodeName] Node name. * @return {Node} Node. * @private */ RING_NODE_FACTORY_(value, objectStack, nodeName) { const context = objectStack[objectStack.length - 1]; const parentNode = context.node; const exteriorWritten = context["exteriorWritten"]; if (exteriorWritten === void 0) { context["exteriorWritten"] = true; } return createElementNS( parentNode.namespaceURI, exteriorWritten !== void 0 ? "innerBoundaryIs" : "outerBoundaryIs" ); } /** * @param {Element} node Node. * @param {import("../geom/Polygon.js").default} polygon Polygon geometry. * @param {Array<*>} objectStack Node stack. * @private */ writeSurfacePatches_(node, polygon, objectStack) { const child = createElementNS(node.namespaceURI, "PolygonPatch"); node.appendChild(child); this.writeSurfaceOrPolygon(child, polygon, objectStack); } /** * @param {Element} node Node. * @param {import("../geom/LinearRing.js").default} ring LinearRing geometry. * @param {Array<*>} objectStack Node stack. */ writeRing(node, ring, objectStack) { const linearRing = createElementNS(node.namespaceURI, "LinearRing"); node.appendChild(linearRing); this.writeLinearRing(linearRing, ring, objectStack); } /** * @param {Array} point Point geometry. * @param {string} [srsName] Optional srsName * @param {boolean} [hasZ] whether the geometry has a Z coordinate (is 3D) or not. * @return {string} The coords string. * @private */ getCoords_(point, srsName, hasZ) { const axisOrientation = srsName ? get(srsName).getAxisOrientation() : "enu"; let coords = axisOrientation.startsWith("en") ? point[0] + "," + point[1] : point[1] + "," + point[0]; if (hasZ) { const z = point[2] || 0; coords += "," + z; } return coords; } /** * @param {Element} node Node. * @param {import("../geom/Point.js").default} geometry Point geometry. * @param {Array<*>} objectStack Node stack. */ writePoint(node, geometry, objectStack) { const context = objectStack[objectStack.length - 1]; const hasZ = context["hasZ"]; const srsName = context["srsName"]; if (srsName) { node.setAttribute("srsName", srsName); } const coordinates = this.createCoordinatesNode_(node.namespaceURI); node.appendChild(coordinates); const point = geometry.getCoordinates(); const coord = this.getCoords_(point, srsName, hasZ); writeStringTextNode(coordinates, coord); } /** * @param {Element} node Node. * @param {import("../geom/MultiPoint.js").default} geometry MultiPoint geometry. * @param {Array<*>} objectStack Node stack. */ writeMultiPoint(node, geometry, objectStack) { const context = objectStack[objectStack.length - 1]; const hasZ = context["hasZ"]; const srsName = context["srsName"]; if (srsName) { node.setAttribute("srsName", srsName); } const points = geometry.getPoints(); pushSerializeAndPop( { node, hasZ, srsName }, this.POINTMEMBER_SERIALIZERS, makeSimpleNodeFactory("pointMember"), points, objectStack, void 0, this ); } /** * @param {Element} node Node. * @param {import("../geom/Point.js").default} point Point geometry. * @param {Array<*>} objectStack Node stack. */ writePointMember(node, point, objectStack) { const child = createElementNS(node.namespaceURI, "Point"); node.appendChild(child); this.writePoint(child, point, objectStack); } /** * @param {Element} node Node. * @param {import("../geom/LinearRing.js").default} geometry LinearRing geometry. * @param {Array<*>} objectStack Node stack. */ writeLinearRing(node, geometry, objectStack) { const context = objectStack[objectStack.length - 1]; const srsName = context["srsName"]; if (srsName) { node.setAttribute("srsName", srsName); } const coordinates = this.createCoordinatesNode_(node.namespaceURI); node.appendChild(coordinates); this.writeCoordinates_(coordinates, geometry, objectStack); } /** * @param {Element} node Node. * @param {import("../geom/MultiPolygon.js").default} geometry MultiPolygon geometry. * @param {Array<*>} objectStack Node stack. */ writeMultiSurfaceOrPolygon(node, geometry, objectStack) { const context = objectStack[objectStack.length - 1]; const hasZ = context["hasZ"]; const srsName = context["srsName"]; const surface = context["surface"]; if (srsName) { node.setAttribute("srsName", srsName); } const polygons = geometry.getPolygons(); pushSerializeAndPop( { node, hasZ, srsName, surface }, this.SURFACEORPOLYGONMEMBER_SERIALIZERS, this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, polygons, objectStack, void 0, this ); } /** * @param {Node} node Node. * @param {import("../geom/Polygon.js").default} polygon Polygon geometry. * @param {Array<*>} objectStack Node stack. */ writeSurfaceOrPolygonMember(node, polygon, objectStack) { const child = this.GEOMETRY_NODE_FACTORY_(polygon, objectStack); if (child) { node.appendChild(child); this.writeSurfaceOrPolygon(child, polygon, objectStack); } } /** * @param {Element} node Node. * @param {import("../extent.js").Extent} extent Extent. * @param {Array<*>} objectStack Node stack. */ writeEnvelope(node, extent, objectStack) { const context = objectStack[objectStack.length - 1]; const srsName = context["srsName"]; if (srsName) { node.setAttribute("srsName", srsName); } const keys = ["lowerCorner", "upperCorner"]; const values = [extent[0] + " " + extent[1], extent[2] + " " + extent[3]]; pushSerializeAndPop( /** @type {import("../xml.js").NodeStackItem} */ { node }, this.ENVELOPE_SERIALIZERS, OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, keys, this ); } /** * @const * @param {*} value Value. * @param {Array<*>} objectStack Object stack. * @param {string} [nodeName] Node name. * @return {Node|undefined} Node. * @private */ MULTIGEOMETRY_MEMBER_NODE_FACTORY_(value, objectStack, nodeName) { const parentNode = objectStack[objectStack.length - 1].node; return createElementNS( "http://www.opengis.net/gml", MULTIGEOMETRY_TO_MEMBER_NODENAME[parentNode.nodeName] ); } }; GML2.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS = { "http://www.opengis.net/gml": { "coordinates": makeReplacer(GML2.prototype.readFlatCoordinates) } }; GML2.prototype.FLAT_LINEAR_RINGS_PARSERS = { "http://www.opengis.net/gml": { "innerBoundaryIs": GML2.prototype.innerBoundaryIsParser, "outerBoundaryIs": GML2.prototype.outerBoundaryIsParser } }; GML2.prototype.BOX_PARSERS_ = { "http://www.opengis.net/gml": { "coordinates": makeArrayPusher(GML2.prototype.readFlatCoordinates) } }; GML2.prototype.GEOMETRY_PARSERS = { "http://www.opengis.net/gml": { "Point": makeReplacer(GMLBase_default.prototype.readPoint), "MultiPoint": makeReplacer(GMLBase_default.prototype.readMultiPoint), "LineString": makeReplacer(GMLBase_default.prototype.readLineString), "MultiLineString": makeReplacer(GMLBase_default.prototype.readMultiLineString), "LinearRing": makeReplacer(GMLBase_default.prototype.readLinearRing), "Polygon": makeReplacer(GMLBase_default.prototype.readPolygon), "MultiPolygon": makeReplacer(GMLBase_default.prototype.readMultiPolygon), "Box": makeReplacer(GML2.prototype.readBox) } }; GML2.prototype.GEOMETRY_SERIALIZERS = { "http://www.opengis.net/gml": { "Curve": makeChildAppender(GML2.prototype.writeCurveOrLineString), "MultiCurve": makeChildAppender(GML2.prototype.writeMultiCurveOrLineString), "Point": makeChildAppender(GML2.prototype.writePoint), "MultiPoint": makeChildAppender(GML2.prototype.writeMultiPoint), "LineString": makeChildAppender(GML2.prototype.writeCurveOrLineString), "MultiLineString": makeChildAppender( GML2.prototype.writeMultiCurveOrLineString ), "LinearRing": makeChildAppender(GML2.prototype.writeLinearRing), "Polygon": makeChildAppender(GML2.prototype.writeSurfaceOrPolygon), "MultiPolygon": makeChildAppender( GML2.prototype.writeMultiSurfaceOrPolygon ), "Surface": makeChildAppender(GML2.prototype.writeSurfaceOrPolygon), "MultiSurface": makeChildAppender( GML2.prototype.writeMultiSurfaceOrPolygon ), "Envelope": makeChildAppender(GML2.prototype.writeEnvelope) } }; GML2.prototype.LINESTRINGORCURVEMEMBER_SERIALIZERS = { "http://www.opengis.net/gml": { "lineStringMember": makeChildAppender( GML2.prototype.writeLineStringOrCurveMember ), "curveMember": makeChildAppender( GML2.prototype.writeLineStringOrCurveMember ) } }; GML2.prototype.RING_SERIALIZERS = { "http://www.opengis.net/gml": { "outerBoundaryIs": makeChildAppender(GML2.prototype.writeRing), "innerBoundaryIs": makeChildAppender(GML2.prototype.writeRing) } }; GML2.prototype.POINTMEMBER_SERIALIZERS = { "http://www.opengis.net/gml": { "pointMember": makeChildAppender(GML2.prototype.writePointMember) } }; GML2.prototype.SURFACEORPOLYGONMEMBER_SERIALIZERS = { "http://www.opengis.net/gml": { "surfaceMember": makeChildAppender( GML2.prototype.writeSurfaceOrPolygonMember ), "polygonMember": makeChildAppender( GML2.prototype.writeSurfaceOrPolygonMember ) } }; GML2.prototype.ENVELOPE_SERIALIZERS = { "http://www.opengis.net/gml": { "lowerCorner": makeChildAppender(writeStringTextNode), "upperCorner": makeChildAppender(writeStringTextNode) } }; var GML2_default = GML2; // node_modules/ol/format/GML3.js var schemaLocation2 = GMLNS + " http://schemas.opengis.net/gml/3.1.1/profiles/gmlsfProfile/1.0.0/gmlsf.xsd"; var MULTIGEOMETRY_TO_MEMBER_NODENAME2 = { "MultiLineString": "lineStringMember", "MultiCurve": "curveMember", "MultiPolygon": "polygonMember", "MultiSurface": "surfaceMember" }; var GML3 = class extends GMLBase_default { /** * @param {import("./GMLBase.js").Options} [options] Optional configuration object. */ constructor(options) { options = options ? options : {}; super(options); this.surface_ = options.surface !== void 0 ? options.surface : false; this.curve_ = options.curve !== void 0 ? options.curve : false; this.multiCurve_ = options.multiCurve !== void 0 ? options.multiCurve : true; this.multiSurface_ = options.multiSurface !== void 0 ? options.multiSurface : true; this.schemaLocation = options.schemaLocation ? options.schemaLocation : schemaLocation2; this.hasZ = options.hasZ !== void 0 ? options.hasZ : false; } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {MultiLineString|undefined} MultiLineString. */ readMultiCurve(node, objectStack) { const lineStrings = pushParseAndPop( [], this.MULTICURVE_PARSERS, node, objectStack, this ); if (lineStrings) { const multiLineString = new MultiLineString_default(lineStrings); return multiLineString; } return void 0; } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {Array|undefined} Polygon. */ readFlatCurveRing(node, objectStack) { const lineStrings = pushParseAndPop( [], this.MULTICURVE_PARSERS, node, objectStack, this ); const flatCoordinates = []; for (let i = 0, ii = lineStrings.length; i < ii; ++i) { extend(flatCoordinates, lineStrings[i].getFlatCoordinates()); } return flatCoordinates; } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {MultiPolygon|undefined} MultiPolygon. */ readMultiSurface(node, objectStack) { const polygons = pushParseAndPop( [], this.MULTISURFACE_PARSERS, node, objectStack, this ); if (polygons) { return new MultiPolygon_default(polygons); } } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. */ curveMemberParser(node, objectStack) { parseNode(this.CURVEMEMBER_PARSERS, node, objectStack, this); } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. */ surfaceMemberParser(node, objectStack) { parseNode(this.SURFACEMEMBER_PARSERS, node, objectStack, this); } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {Array<(Array)>|undefined} flat coordinates. */ readPatch(node, objectStack) { return pushParseAndPop( [null], this.PATCHES_PARSERS, node, objectStack, this ); } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {Array|undefined} flat coordinates. */ readSegment(node, objectStack) { return pushParseAndPop([], this.SEGMENTS_PARSERS, node, objectStack, this); } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {Array<(Array)>|undefined} flat coordinates. */ readPolygonPatch(node, objectStack) { return pushParseAndPop( [null], this.FLAT_LINEAR_RINGS_PARSERS, node, objectStack, this ); } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {Array|undefined} flat coordinates. */ readLineStringSegment(node, objectStack) { return pushParseAndPop( [null], this.GEOMETRY_FLAT_COORDINATES_PARSERS, node, objectStack, this ); } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. */ interiorParser(node, objectStack) { const flatLinearRing = pushParseAndPop( void 0, this.RING_PARSERS, node, objectStack, this ); if (flatLinearRing) { const flatLinearRings = ( /** @type {Array>} */ objectStack[objectStack.length - 1] ); flatLinearRings.push(flatLinearRing); } } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. */ exteriorParser(node, objectStack) { const flatLinearRing = pushParseAndPop( void 0, this.RING_PARSERS, node, objectStack, this ); if (flatLinearRing) { const flatLinearRings = ( /** @type {Array>} */ objectStack[objectStack.length - 1] ); flatLinearRings[0] = flatLinearRing; } } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {Polygon|undefined} Polygon. */ readSurface(node, objectStack) { const flatLinearRings = pushParseAndPop( [null], this.SURFACE_PARSERS, node, objectStack, this ); if (flatLinearRings && flatLinearRings[0]) { const flatCoordinates = flatLinearRings[0]; const ends = [flatCoordinates.length]; let i, ii; for (i = 1, ii = flatLinearRings.length; i < ii; ++i) { extend(flatCoordinates, flatLinearRings[i]); ends.push(flatCoordinates.length); } return new Polygon_default(flatCoordinates, "XYZ", ends); } return void 0; } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {LineString|undefined} LineString. */ readCurve(node, objectStack) { const flatCoordinates = pushParseAndPop( [null], this.CURVE_PARSERS, node, objectStack, this ); if (flatCoordinates) { const lineString = new LineString_default(flatCoordinates, "XYZ"); return lineString; } return void 0; } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {import("../extent.js").Extent|undefined} Envelope. */ readEnvelope(node, objectStack) { const flatCoordinates = pushParseAndPop( [null], this.ENVELOPE_PARSERS, node, objectStack, this ); return createOrUpdate( flatCoordinates[1][0], flatCoordinates[1][1], flatCoordinates[2][0], flatCoordinates[2][1] ); } /** * @param {Node} node Node. * @param {Array<*>} objectStack Object stack. * @return {Array|undefined} Flat coordinates. */ readFlatPos(node, objectStack) { let s = getAllTextContent(node, false); const re = /^\s*([+\-]?\d*\.?\d+(?:[eE][+\-]?\d+)?)\s*/; const flatCoordinates = []; let m; while (m = re.exec(s)) { flatCoordinates.push(parseFloat(m[1])); s = s.substr(m[0].length); } if (s !== "") { return void 0; } const context = objectStack[0]; const containerSrs = context["srsName"]; const axisOrientation = containerSrs ? get(containerSrs).getAxisOrientation() : "enu"; if (axisOrientation === "neu") { for (let i = 0, ii = flatCoordinates.length; i < ii; i += 3) { const y = flatCoordinates[i]; const x = flatCoordinates[i + 1]; flatCoordinates[i] = x; flatCoordinates[i + 1] = y; } } const len = flatCoordinates.length; if (len == 2) { flatCoordinates.push(0); } if (len === 0) { return void 0; } return flatCoordinates; } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @return {Array|undefined} Flat coordinates. */ readFlatPosList(node, objectStack) { const s = getAllTextContent(node, false).replace(/^\s*|\s*$/g, ""); const context = objectStack[0]; const containerSrs = context["srsName"]; const contextDimension = context["srsDimension"]; const axisOrientation = containerSrs ? get(containerSrs).getAxisOrientation() : "enu"; const coords = s.split(/\s+/); let dim = 2; if (node.getAttribute("srsDimension")) { dim = readNonNegativeIntegerString(node.getAttribute("srsDimension")); } else if (node.getAttribute("dimension")) { dim = readNonNegativeIntegerString(node.getAttribute("dimension")); } else if ( /** @type {Element} */ node.parentNode.getAttribute("srsDimension") ) { dim = readNonNegativeIntegerString( /** @type {Element} */ node.parentNode.getAttribute("srsDimension") ); } else if (contextDimension) { dim = readNonNegativeIntegerString(contextDimension); } const asXYZ = axisOrientation.startsWith("en"); let x, y, z; const flatCoordinates = []; for (let i = 0, ii = coords.length; i < ii; i += dim) { x = parseFloat(coords[i]); y = parseFloat(coords[i + 1]); z = dim === 3 ? parseFloat(coords[i + 2]) : 0; if (asXYZ) { flatCoordinates.push(x, y, z); } else { flatCoordinates.push(y, x, z); } } return flatCoordinates; } /** * @param {Element} node Node. * @param {import("../geom/Point.js").default} value Point geometry. * @param {Array<*>} objectStack Node stack. * @private */ writePos_(node, value, objectStack) { const context = objectStack[objectStack.length - 1]; const hasZ = context["hasZ"]; const srsDimension = hasZ ? "3" : "2"; node.setAttribute("srsDimension", srsDimension); const srsName = context["srsName"]; const axisOrientation = srsName ? get(srsName).getAxisOrientation() : "enu"; const point = value.getCoordinates(); let coords = axisOrientation.startsWith("en") ? point[0] + " " + point[1] : point[1] + " " + point[0]; if (hasZ) { const z = point[2] || 0; coords += " " + z; } writeStringTextNode(node, coords); } /** * @param {Array} point Point geometry. * @param {string} [srsName] Optional srsName * @param {boolean} [hasZ] whether the geometry has a Z coordinate (is 3D) or not. * @return {string} The coords string. * @private */ getCoords_(point, srsName, hasZ) { const axisOrientation = srsName ? get(srsName).getAxisOrientation() : "enu"; let coords = axisOrientation.startsWith("en") ? point[0] + " " + point[1] : point[1] + " " + point[0]; if (hasZ) { const z = point[2] || 0; coords += " " + z; } return coords; } /** * @param {Element} node Node. * @param {LineString|import("../geom/LinearRing.js").default} value Geometry. * @param {Array<*>} objectStack Node stack. * @private */ writePosList_(node, value, objectStack) { const context = objectStack[objectStack.length - 1]; const hasZ = context["hasZ"]; const srsDimension = hasZ ? "3" : "2"; node.setAttribute("srsDimension", srsDimension); const srsName = context["srsName"]; const points = value.getCoordinates(); const len = points.length; const parts = new Array(len); let point; for (let i = 0; i < len; ++i) { point = points[i]; parts[i] = this.getCoords_(point, srsName, hasZ); } writeStringTextNode(node, parts.join(" ")); } /** * @param {Element} node Node. * @param {import("../geom/Point.js").default} geometry Point geometry. * @param {Array<*>} objectStack Node stack. */ writePoint(node, geometry, objectStack) { const context = objectStack[objectStack.length - 1]; const srsName = context["srsName"]; if (srsName) { node.setAttribute("srsName", srsName); } const pos = createElementNS(node.namespaceURI, "pos"); node.appendChild(pos); this.writePos_(pos, geometry, objectStack); } /** * @param {Element} node Node. * @param {import("../extent.js").Extent} extent Extent. * @param {Array<*>} objectStack Node stack. */ writeEnvelope(node, extent, objectStack) { const context = objectStack[objectStack.length - 1]; const srsName = context["srsName"]; if (srsName) { node.setAttribute("srsName", srsName); } const keys = ["lowerCorner", "upperCorner"]; const values = [extent[0] + " " + extent[1], extent[2] + " " + extent[3]]; pushSerializeAndPop( /** @type {import("../xml.js").NodeStackItem} */ { node }, this.ENVELOPE_SERIALIZERS, OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, keys, this ); } /** * @param {Element} node Node. * @param {import("../geom/LinearRing.js").default} geometry LinearRing geometry. * @param {Array<*>} objectStack Node stack. */ writeLinearRing(node, geometry, objectStack) { const context = objectStack[objectStack.length - 1]; const srsName = context["srsName"]; if (srsName) { node.setAttribute("srsName", srsName); } const posList = createElementNS(node.namespaceURI, "posList"); node.appendChild(posList); this.writePosList_(posList, geometry, objectStack); } /** * @param {*} value Value. * @param {Array<*>} objectStack Object stack. * @param {string} [nodeName] Node name. * @return {Node} Node. * @private */ RING_NODE_FACTORY_(value, objectStack, nodeName) { const context = objectStack[objectStack.length - 1]; const parentNode = context.node; const exteriorWritten = context["exteriorWritten"]; if (exteriorWritten === void 0) { context["exteriorWritten"] = true; } return createElementNS( parentNode.namespaceURI, exteriorWritten !== void 0 ? "interior" : "exterior" ); } /** * @param {Element} node Node. * @param {Polygon} geometry Polygon geometry. * @param {Array<*>} objectStack Node stack. */ writeSurfaceOrPolygon(node, geometry, objectStack) { const context = objectStack[objectStack.length - 1]; const hasZ = context["hasZ"]; const srsName = context["srsName"]; if (node.nodeName !== "PolygonPatch" && srsName) { node.setAttribute("srsName", srsName); } if (node.nodeName === "Polygon" || node.nodeName === "PolygonPatch") { const rings = geometry.getLinearRings(); pushSerializeAndPop( { node, hasZ, srsName }, this.RING_SERIALIZERS, this.RING_NODE_FACTORY_, rings, objectStack, void 0, this ); } else if (node.nodeName === "Surface") { const patches = createElementNS(node.namespaceURI, "patches"); node.appendChild(patches); this.writeSurfacePatches_(patches, geometry, objectStack); } } /** * @param {Element} node Node. * @param {LineString} geometry LineString geometry. * @param {Array<*>} objectStack Node stack. */ writeCurveOrLineString(node, geometry, objectStack) { const context = objectStack[objectStack.length - 1]; const srsName = context["srsName"]; if (node.nodeName !== "LineStringSegment" && srsName) { node.setAttribute("srsName", srsName); } if (node.nodeName === "LineString" || node.nodeName === "LineStringSegment") { const posList = createElementNS(node.namespaceURI, "posList"); node.appendChild(posList); this.writePosList_(posList, geometry, objectStack); } else if (node.nodeName === "Curve") { const segments = createElementNS(node.namespaceURI, "segments"); node.appendChild(segments); this.writeCurveSegments_(segments, geometry, objectStack); } } /** * @param {Element} node Node. * @param {MultiPolygon} geometry MultiPolygon geometry. * @param {Array<*>} objectStack Node stack. */ writeMultiSurfaceOrPolygon(node, geometry, objectStack) { const context = objectStack[objectStack.length - 1]; const hasZ = context["hasZ"]; const srsName = context["srsName"]; const surface = context["surface"]; if (srsName) { node.setAttribute("srsName", srsName); } const polygons = geometry.getPolygons(); pushSerializeAndPop( { node, hasZ, srsName, surface }, this.SURFACEORPOLYGONMEMBER_SERIALIZERS, this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, polygons, objectStack, void 0, this ); } /** * @param {Element} node Node. * @param {import("../geom/MultiPoint.js").default} geometry MultiPoint geometry. * @param {Array<*>} objectStack Node stack. */ writeMultiPoint(node, geometry, objectStack) { const context = objectStack[objectStack.length - 1]; const srsName = context["srsName"]; const hasZ = context["hasZ"]; if (srsName) { node.setAttribute("srsName", srsName); } const points = geometry.getPoints(); pushSerializeAndPop( { node, hasZ, srsName }, this.POINTMEMBER_SERIALIZERS, makeSimpleNodeFactory("pointMember"), points, objectStack, void 0, this ); } /** * @param {Element} node Node. * @param {MultiLineString} geometry MultiLineString geometry. * @param {Array<*>} objectStack Node stack. */ writeMultiCurveOrLineString(node, geometry, objectStack) { const context = objectStack[objectStack.length - 1]; const hasZ = context["hasZ"]; const srsName = context["srsName"]; const curve = context["curve"]; if (srsName) { node.setAttribute("srsName", srsName); } const lines = geometry.getLineStrings(); pushSerializeAndPop( { node, hasZ, srsName, curve }, this.LINESTRINGORCURVEMEMBER_SERIALIZERS, this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, lines, objectStack, void 0, this ); } /** * @param {Element} node Node. * @param {import("../geom/LinearRing.js").default} ring LinearRing geometry. * @param {Array<*>} objectStack Node stack. */ writeRing(node, ring, objectStack) { const linearRing = createElementNS(node.namespaceURI, "LinearRing"); node.appendChild(linearRing); this.writeLinearRing(linearRing, ring, objectStack); } /** * @param {Node} node Node. * @param {Polygon} polygon Polygon geometry. * @param {Array<*>} objectStack Node stack. */ writeSurfaceOrPolygonMember(node, polygon, objectStack) { const child = this.GEOMETRY_NODE_FACTORY_(polygon, objectStack); if (child) { node.appendChild(child); this.writeSurfaceOrPolygon(child, polygon, objectStack); } } /** * @param {Element} node Node. * @param {import("../geom/Point.js").default} point Point geometry. * @param {Array<*>} objectStack Node stack. */ writePointMember(node, point, objectStack) { const child = createElementNS(node.namespaceURI, "Point"); node.appendChild(child); this.writePoint(child, point, objectStack); } /** * @param {Node} node Node. * @param {LineString} line LineString geometry. * @param {Array<*>} objectStack Node stack. */ writeLineStringOrCurveMember(node, line, objectStack) { const child = this.GEOMETRY_NODE_FACTORY_(line, objectStack); if (child) { node.appendChild(child); this.writeCurveOrLineString(child, line, objectStack); } } /** * @param {Element} node Node. * @param {Polygon} polygon Polygon geometry. * @param {Array<*>} objectStack Node stack. * @private */ writeSurfacePatches_(node, polygon, objectStack) { const child = createElementNS(node.namespaceURI, "PolygonPatch"); node.appendChild(child); this.writeSurfaceOrPolygon(child, polygon, objectStack); } /** * @param {Element} node Node. * @param {LineString} line LineString geometry. * @param {Array<*>} objectStack Node stack. * @private */ writeCurveSegments_(node, line, objectStack) { const child = createElementNS(node.namespaceURI, "LineStringSegment"); node.appendChild(child); this.writeCurveOrLineString(child, line, objectStack); } /** * @param {Node} node Node. * @param {import("../geom/Geometry.js").default|import("../extent.js").Extent} geometry Geometry. * @param {Array<*>} objectStack Node stack. */ writeGeometryElement(node, geometry, objectStack) { const context = ( /** @type {import("./Feature.js").WriteOptions} */ objectStack[objectStack.length - 1] ); const item = Object.assign({}, context); item["node"] = node; let value; if (Array.isArray(geometry)) { value = transformExtentWithOptions( /** @type {import("../extent.js").Extent} */ geometry, context ); } else { value = transformGeometryWithOptions( /** @type {import("../geom/Geometry.js").default} */ geometry, true, context ); } pushSerializeAndPop( /** @type {import("../xml.js").NodeStackItem} */ item, this.GEOMETRY_SERIALIZERS, this.GEOMETRY_NODE_FACTORY_, [value], objectStack, void 0, this ); } /** * @param {Element} node Node. * @param {import("../Feature.js").default} feature Feature. * @param {Array<*>} objectStack Node stack. */ writeFeatureElement(node, feature, objectStack) { const fid = feature.getId(); if (fid) { node.setAttribute( "fid", /** @type {string} */ fid ); } const context = ( /** @type {Object} */ objectStack[objectStack.length - 1] ); const featureNS = context["featureNS"]; const geometryName = feature.getGeometryName(); if (!context.serializers) { context.serializers = {}; context.serializers[featureNS] = {}; } const keys = []; const values = []; if (feature.hasProperties()) { const properties = feature.getProperties(); for (const key in properties) { const value = properties[key]; if (value !== null && value !== void 0) { keys.push(key); values.push(value); if (key == geometryName || typeof /** @type {?} */ value.getSimplifiedGeometry === "function") { if (!(key in context.serializers[featureNS])) { context.serializers[featureNS][key] = makeChildAppender( this.writeGeometryElement, this ); } } else { if (!(key in context.serializers[featureNS])) { context.serializers[featureNS][key] = makeChildAppender(writeStringTextNode); } } } } } const item = Object.assign({}, context); item.node = node; pushSerializeAndPop( /** @type {import("../xml.js").NodeStackItem} */ item, context.serializers, makeSimpleNodeFactory(void 0, featureNS), values, objectStack, keys ); } /** * @param {Node} node Node. * @param {Array} features Features. * @param {Array<*>} objectStack Node stack. * @private */ writeFeatureMembers_(node, features, objectStack) { const context = ( /** @type {Object} */ objectStack[objectStack.length - 1] ); const featureType = context["featureType"]; const featureNS = context["featureNS"]; const serializers = {}; serializers[featureNS] = {}; serializers[featureNS][featureType] = makeChildAppender( this.writeFeatureElement, this ); const item = Object.assign({}, context); item.node = node; pushSerializeAndPop( /** @type {import("../xml.js").NodeStackItem} */ item, serializers, makeSimpleNodeFactory(featureType, featureNS), features, objectStack ); } /** * @const * @param {*} value Value. * @param {Array<*>} objectStack Object stack. * @param {string} [nodeName] Node name. * @return {Node|undefined} Node. * @private */ MULTIGEOMETRY_MEMBER_NODE_FACTORY_(value, objectStack, nodeName) { const parentNode = objectStack[objectStack.length - 1].node; return createElementNS( this.namespace, MULTIGEOMETRY_TO_MEMBER_NODENAME2[parentNode.nodeName] ); } /** * @const * @param {*} value Value. * @param {Array<*>} objectStack Object stack. * @param {string} [nodeName] Node name. * @return {Element|undefined} Node. * @private */ GEOMETRY_NODE_FACTORY_(value, objectStack, nodeName) { const context = objectStack[objectStack.length - 1]; const multiSurface = context["multiSurface"]; const surface = context["surface"]; const curve = context["curve"]; const multiCurve = context["multiCurve"]; if (!Array.isArray(value)) { nodeName = /** @type {import("../geom/Geometry.js").default} */ value.getType(); if (nodeName === "MultiPolygon" && multiSurface === true) { nodeName = "MultiSurface"; } else if (nodeName === "Polygon" && surface === true) { nodeName = "Surface"; } else if (nodeName === "LineString" && curve === true) { nodeName = "Curve"; } else if (nodeName === "MultiLineString" && multiCurve === true) { nodeName = "MultiCurve"; } } else { nodeName = "Envelope"; } return createElementNS(this.namespace, nodeName); } /** * Encode a geometry in GML 3.1.1 Simple Features. * * @param {import("../geom/Geometry.js").default} geometry Geometry. * @param {import("./Feature.js").WriteOptions} [options] Options. * @return {Node} Node. * @api * @override */ writeGeometryNode(geometry, options) { options = this.adaptOptions(options); const geom = createElementNS(this.namespace, "geom"); const context = { node: geom, hasZ: this.hasZ, srsName: this.srsName, curve: this.curve_, surface: this.surface_, multiSurface: this.multiSurface_, multiCurve: this.multiCurve_ }; if (options) { Object.assign(context, options); } this.writeGeometryElement(geom, geometry, [context]); return geom; } /** * Encode an array of features in the GML 3.1.1 format as an XML node. * * @param {Array} features Features. * @param {import("./Feature.js").WriteOptions} [options] Options. * @return {Element} Node. * @api * @override */ writeFeaturesNode(features, options) { options = this.adaptOptions(options); const node = createElementNS(this.namespace, "featureMembers"); node.setAttributeNS( XML_SCHEMA_INSTANCE_URI, "xsi:schemaLocation", this.schemaLocation ); const context = { srsName: this.srsName, hasZ: this.hasZ, curve: this.curve_, surface: this.surface_, multiSurface: this.multiSurface_, multiCurve: this.multiCurve_, featureNS: this.featureNS, featureType: this.featureType }; if (options) { Object.assign(context, options); } this.writeFeatureMembers_(node, features, [context]); return node; } }; GML3.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS = { "http://www.opengis.net/gml": { "pos": makeReplacer(GML3.prototype.readFlatPos), "posList": makeReplacer(GML3.prototype.readFlatPosList), "coordinates": makeReplacer(GML2_default.prototype.readFlatCoordinates) } }; GML3.prototype.FLAT_LINEAR_RINGS_PARSERS = { "http://www.opengis.net/gml": { "interior": GML3.prototype.interiorParser, "exterior": GML3.prototype.exteriorParser } }; GML3.prototype.GEOMETRY_PARSERS = { "http://www.opengis.net/gml": { "Point": makeReplacer(GMLBase_default.prototype.readPoint), "MultiPoint": makeReplacer(GMLBase_default.prototype.readMultiPoint), "LineString": makeReplacer(GMLBase_default.prototype.readLineString), "MultiLineString": makeReplacer(GMLBase_default.prototype.readMultiLineString), "LinearRing": makeReplacer(GMLBase_default.prototype.readLinearRing), "Polygon": makeReplacer(GMLBase_default.prototype.readPolygon), "MultiPolygon": makeReplacer(GMLBase_default.prototype.readMultiPolygon), "Surface": makeReplacer(GML3.prototype.readSurface), "MultiSurface": makeReplacer(GML3.prototype.readMultiSurface), "Curve": makeReplacer(GML3.prototype.readCurve), "MultiCurve": makeReplacer(GML3.prototype.readMultiCurve), "Envelope": makeReplacer(GML3.prototype.readEnvelope) } }; GML3.prototype.MULTICURVE_PARSERS = { "http://www.opengis.net/gml": { "curveMember": makeArrayPusher(GML3.prototype.curveMemberParser), "curveMembers": makeArrayPusher(GML3.prototype.curveMemberParser) } }; GML3.prototype.MULTISURFACE_PARSERS = { "http://www.opengis.net/gml": { "surfaceMember": makeArrayPusher(GML3.prototype.surfaceMemberParser), "surfaceMembers": makeArrayPusher(GML3.prototype.surfaceMemberParser) } }; GML3.prototype.CURVEMEMBER_PARSERS = { "http://www.opengis.net/gml": { "LineString": makeArrayPusher(GMLBase_default.prototype.readLineString), "Curve": makeArrayPusher(GML3.prototype.readCurve) } }; GML3.prototype.SURFACEMEMBER_PARSERS = { "http://www.opengis.net/gml": { "Polygon": makeArrayPusher(GMLBase_default.prototype.readPolygon), "Surface": makeArrayPusher(GML3.prototype.readSurface) } }; GML3.prototype.SURFACE_PARSERS = { "http://www.opengis.net/gml": { "patches": makeReplacer(GML3.prototype.readPatch) } }; GML3.prototype.CURVE_PARSERS = { "http://www.opengis.net/gml": { "segments": makeReplacer(GML3.prototype.readSegment) } }; GML3.prototype.ENVELOPE_PARSERS = { "http://www.opengis.net/gml": { "lowerCorner": makeArrayPusher(GML3.prototype.readFlatPosList), "upperCorner": makeArrayPusher(GML3.prototype.readFlatPosList) } }; GML3.prototype.PATCHES_PARSERS = { "http://www.opengis.net/gml": { "PolygonPatch": makeReplacer(GML3.prototype.readPolygonPatch) } }; GML3.prototype.SEGMENTS_PARSERS = { "http://www.opengis.net/gml": { "LineStringSegment": makeArrayExtender( GML3.prototype.readLineStringSegment ) } }; GMLBase_default.prototype.RING_PARSERS = { "http://www.opengis.net/gml": { "LinearRing": makeReplacer(GMLBase_default.prototype.readFlatLinearRing), "Ring": makeReplacer(GML3.prototype.readFlatCurveRing) } }; GML3.prototype.writeFeatures; GML3.prototype.RING_SERIALIZERS = { "http://www.opengis.net/gml": { "exterior": makeChildAppender(GML3.prototype.writeRing), "interior": makeChildAppender(GML3.prototype.writeRing) } }; GML3.prototype.ENVELOPE_SERIALIZERS = { "http://www.opengis.net/gml": { "lowerCorner": makeChildAppender(writeStringTextNode), "upperCorner": makeChildAppender(writeStringTextNode) } }; GML3.prototype.SURFACEORPOLYGONMEMBER_SERIALIZERS = { "http://www.opengis.net/gml": { "surfaceMember": makeChildAppender( GML3.prototype.writeSurfaceOrPolygonMember ), "polygonMember": makeChildAppender( GML3.prototype.writeSurfaceOrPolygonMember ) } }; GML3.prototype.POINTMEMBER_SERIALIZERS = { "http://www.opengis.net/gml": { "pointMember": makeChildAppender(GML3.prototype.writePointMember) } }; GML3.prototype.LINESTRINGORCURVEMEMBER_SERIALIZERS = { "http://www.opengis.net/gml": { "lineStringMember": makeChildAppender( GML3.prototype.writeLineStringOrCurveMember ), "curveMember": makeChildAppender( GML3.prototype.writeLineStringOrCurveMember ) } }; GML3.prototype.GEOMETRY_SERIALIZERS = { "http://www.opengis.net/gml": { "Curve": makeChildAppender(GML3.prototype.writeCurveOrLineString), "MultiCurve": makeChildAppender(GML3.prototype.writeMultiCurveOrLineString), "Point": makeChildAppender(GML3.prototype.writePoint), "MultiPoint": makeChildAppender(GML3.prototype.writeMultiPoint), "LineString": makeChildAppender(GML3.prototype.writeCurveOrLineString), "MultiLineString": makeChildAppender( GML3.prototype.writeMultiCurveOrLineString ), "LinearRing": makeChildAppender(GML3.prototype.writeLinearRing), "Polygon": makeChildAppender(GML3.prototype.writeSurfaceOrPolygon), "MultiPolygon": makeChildAppender( GML3.prototype.writeMultiSurfaceOrPolygon ), "Surface": makeChildAppender(GML3.prototype.writeSurfaceOrPolygon), "MultiSurface": makeChildAppender( GML3.prototype.writeMultiSurfaceOrPolygon ), "Envelope": makeChildAppender(GML3.prototype.writeEnvelope) } }; var GML3_default = GML3; // node_modules/ol/format/GML.js var GML = GML3_default; GML.prototype.writeFeatures; GML.prototype.writeFeaturesNode; var GML_default = GML; // node_modules/ol/format/GPX.js var NAMESPACE_URIS = [ null, "http://www.topografix.com/GPX/1/0", "http://www.topografix.com/GPX/1/1" ]; var SCHEMA_LOCATION = "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"; var FEATURE_READER = { "rte": readRte, "trk": readTrk, "wpt": readWpt }; var GPX_PARSERS = makeStructureNS(NAMESPACE_URIS, { "rte": makeArrayPusher(readRte), "trk": makeArrayPusher(readTrk), "wpt": makeArrayPusher(readWpt) }); var LINK_PARSERS = makeStructureNS(NAMESPACE_URIS, { "text": makeObjectPropertySetter(readString, "linkText"), "type": makeObjectPropertySetter(readString, "linkType") }); var AUTHOR_PARSERS = makeStructureNS(NAMESPACE_URIS, { "name": makeObjectPropertySetter(readString), "email": parseEmail, "link": parseLink }); var METADATA_PARSERS = makeStructureNS(NAMESPACE_URIS, { "name": makeObjectPropertySetter(readString), "desc": makeObjectPropertySetter(readString), "author": makeObjectPropertySetter(readAuthor), "copyright": makeObjectPropertySetter(readCopyright), "link": parseLink, "time": makeObjectPropertySetter(readDateTime), "keywords": makeObjectPropertySetter(readString), "bounds": parseBounds, "extensions": parseExtensions }); var COPYRIGHT_PARSERS = makeStructureNS(NAMESPACE_URIS, { "year": makeObjectPropertySetter(readPositiveInteger), "license": makeObjectPropertySetter(readString) }); var GPX_SERIALIZERS = makeStructureNS(NAMESPACE_URIS, { "rte": makeChildAppender(writeRte), "trk": makeChildAppender(writeTrk), "wpt": makeChildAppender(writeWpt) }); var GPX = class extends XMLFeature_default { /** * @param {Options} [options] Options. */ constructor(options) { super(); options = options ? options : {}; this.dataProjection = get("EPSG:4326"); this.readExtensions_ = options.readExtensions; } /** * @param {Array} features List of features. * @private */ handleReadExtensions_(features) { if (!features) { features = []; } for (let i = 0, ii = features.length; i < ii; ++i) { const feature = features[i]; if (this.readExtensions_) { const extensionsNode = feature.get("extensionsNode_") || null; this.readExtensions_(feature, extensionsNode); } feature.set("extensionsNode_", void 0); } } /** * Reads a GPX file's metadata tag, reading among other things: * - the name and description of this GPX * - its author * - the copyright associated with this GPX file * * Will return null if no metadata tag is present (or no valid source is given). * * @param {Document|Element|Object|string} source Source. * @return {GPXMetadata | null} Metadata * @api */ readMetadata(source) { if (!source) { return null; } if (typeof source === "string") { return this.readMetadataFromDocument(parse(source)); } if (isDocument(source)) { return this.readMetadataFromDocument( /** @type {Document} */ source ); } return this.readMetadataFromNode(source); } /** * @param {Document} doc Document. * @return {GPXMetadata | null} Metadata */ readMetadataFromDocument(doc) { for (let n = ( /** @type {Node} */ doc.firstChild ); n; n = n.nextSibling) { if (n.nodeType === Node.ELEMENT_NODE) { const metadata = this.readMetadataFromNode( /** @type {Element} */ n ); if (metadata) { return metadata; } } } return null; } /** * @param {Element} node Node. * @return {Object} Metadata */ readMetadataFromNode(node) { if (!NAMESPACE_URIS.includes(node.namespaceURI)) { return null; } for (let n = node.firstElementChild; n; n = n.nextElementSibling) { if (NAMESPACE_URIS.includes(n.namespaceURI) && n.localName === "metadata") { return pushParseAndPop({}, METADATA_PARSERS, n, []); } } return null; } /** * @param {Element} node Node. * @param {import("./Feature.js").ReadOptions} [options] Options. * @return {import("../Feature.js").default} Feature. * @override */ readFeatureFromNode(node, options) { if (!NAMESPACE_URIS.includes(node.namespaceURI)) { return null; } const featureReader = FEATURE_READER[node.localName]; if (!featureReader) { return null; } const feature = featureReader(node, [this.getReadOptions(node, options)]); if (!feature) { return null; } this.handleReadExtensions_([feature]); return feature; } /** * @param {Element} node Node. * @param {import("./Feature.js").ReadOptions} [options] Options. * @return {Array} Features. * @override */ readFeaturesFromNode(node, options) { if (!NAMESPACE_URIS.includes(node.namespaceURI)) { return []; } if (node.localName == "gpx") { const features = pushParseAndPop([], GPX_PARSERS, node, [ this.getReadOptions(node, options) ]); if (features) { this.handleReadExtensions_(features); return features; } return []; } return []; } /** * Encode an array of features in the GPX format as an XML node. * LineString geometries are output as routes (``), and MultiLineString * as tracks (``). * * @param {Array} features Features. * @param {import("./Feature.js").WriteOptions} [options] Options. * @return {Node} Node. * @api * @override */ writeFeaturesNode(features, options) { options = this.adaptOptions(options); const gpx = createElementNS("http://www.topografix.com/GPX/1/1", "gpx"); const xmlnsUri = "http://www.w3.org/2000/xmlns/"; gpx.setAttributeNS(xmlnsUri, "xmlns:xsi", XML_SCHEMA_INSTANCE_URI); gpx.setAttributeNS( XML_SCHEMA_INSTANCE_URI, "xsi:schemaLocation", SCHEMA_LOCATION ); gpx.setAttribute("version", "1.1"); gpx.setAttribute("creator", "OpenLayers"); pushSerializeAndPop( /** @type {import("../xml.js").NodeStackItem} */ { node: gpx }, GPX_SERIALIZERS, GPX_NODE_FACTORY, features, [options] ); return gpx; } }; var RTE_PARSERS = makeStructureNS(NAMESPACE_URIS, { "name": makeObjectPropertySetter(readString), "cmt": makeObjectPropertySetter(readString), "desc": makeObjectPropertySetter(readString), "src": makeObjectPropertySetter(readString), "link": parseLink, "number": makeObjectPropertySetter(readPositiveInteger), "extensions": parseExtensions, "type": makeObjectPropertySetter(readString), "rtept": parseRtePt }); var RTEPT_PARSERS = makeStructureNS(NAMESPACE_URIS, { "ele": makeObjectPropertySetter(readDecimal), "time": makeObjectPropertySetter(readDateTime) }); var TRK_PARSERS = makeStructureNS(NAMESPACE_URIS, { "name": makeObjectPropertySetter(readString), "cmt": makeObjectPropertySetter(readString), "desc": makeObjectPropertySetter(readString), "src": makeObjectPropertySetter(readString), "link": parseLink, "number": makeObjectPropertySetter(readPositiveInteger), "type": makeObjectPropertySetter(readString), "extensions": parseExtensions, "trkseg": parseTrkSeg }); var TRKSEG_PARSERS = makeStructureNS(NAMESPACE_URIS, { "trkpt": parseTrkPt }); var TRKPT_PARSERS = makeStructureNS(NAMESPACE_URIS, { "ele": makeObjectPropertySetter(readDecimal), "time": makeObjectPropertySetter(readDateTime) }); var WPT_PARSERS = makeStructureNS(NAMESPACE_URIS, { "ele": makeObjectPropertySetter(readDecimal), "time": makeObjectPropertySetter(readDateTime), "magvar": makeObjectPropertySetter(readDecimal), "geoidheight": makeObjectPropertySetter(readDecimal), "name": makeObjectPropertySetter(readString), "cmt": makeObjectPropertySetter(readString), "desc": makeObjectPropertySetter(readString), "src": makeObjectPropertySetter(readString), "link": parseLink, "sym": makeObjectPropertySetter(readString), "type": makeObjectPropertySetter(readString), "fix": makeObjectPropertySetter(readString), "sat": makeObjectPropertySetter(readPositiveInteger), "hdop": makeObjectPropertySetter(readDecimal), "vdop": makeObjectPropertySetter(readDecimal), "pdop": makeObjectPropertySetter(readDecimal), "ageofdgpsdata": makeObjectPropertySetter(readDecimal), "dgpsid": makeObjectPropertySetter(readPositiveInteger), "extensions": parseExtensions }); var LINK_SEQUENCE = ["text", "type"]; var LINK_SERIALIZERS = makeStructureNS(NAMESPACE_URIS, { "text": makeChildAppender(writeStringTextNode), "type": makeChildAppender(writeStringTextNode) }); var RTE_SEQUENCE = makeStructureNS(NAMESPACE_URIS, [ "name", "cmt", "desc", "src", "link", "number", "type", "rtept" ]); var RTE_SERIALIZERS = makeStructureNS(NAMESPACE_URIS, { "name": makeChildAppender(writeStringTextNode), "cmt": makeChildAppender(writeStringTextNode), "desc": makeChildAppender(writeStringTextNode), "src": makeChildAppender(writeStringTextNode), "link": makeChildAppender(writeLink), "number": makeChildAppender(writeNonNegativeIntegerTextNode), "type": makeChildAppender(writeStringTextNode), "rtept": makeArraySerializer(makeChildAppender(writeWptType)) }); var RTEPT_TYPE_SEQUENCE = makeStructureNS(NAMESPACE_URIS, ["ele", "time"]); var TRK_SEQUENCE = makeStructureNS(NAMESPACE_URIS, [ "name", "cmt", "desc", "src", "link", "number", "type", "trkseg" ]); var TRK_SERIALIZERS = makeStructureNS(NAMESPACE_URIS, { "name": makeChildAppender(writeStringTextNode), "cmt": makeChildAppender(writeStringTextNode), "desc": makeChildAppender(writeStringTextNode), "src": makeChildAppender(writeStringTextNode), "link": makeChildAppender(writeLink), "number": makeChildAppender(writeNonNegativeIntegerTextNode), "type": makeChildAppender(writeStringTextNode), "trkseg": makeArraySerializer(makeChildAppender(writeTrkSeg)) }); var TRKSEG_NODE_FACTORY = makeSimpleNodeFactory("trkpt"); var TRKSEG_SERIALIZERS = makeStructureNS(NAMESPACE_URIS, { "trkpt": makeChildAppender(writeWptType) }); var WPT_TYPE_SEQUENCE = makeStructureNS(NAMESPACE_URIS, [ "ele", "time", "magvar", "geoidheight", "name", "cmt", "desc", "src", "link", "sym", "type", "fix", "sat", "hdop", "vdop", "pdop", "ageofdgpsdata", "dgpsid" ]); var WPT_TYPE_SERIALIZERS = makeStructureNS(NAMESPACE_URIS, { "ele": makeChildAppender(writeDecimalTextNode), "time": makeChildAppender(writeDateTimeTextNode), "magvar": makeChildAppender(writeDecimalTextNode), "geoidheight": makeChildAppender(writeDecimalTextNode), "name": makeChildAppender(writeStringTextNode), "cmt": makeChildAppender(writeStringTextNode), "desc": makeChildAppender(writeStringTextNode), "src": makeChildAppender(writeStringTextNode), "link": makeChildAppender(writeLink), "sym": makeChildAppender(writeStringTextNode), "type": makeChildAppender(writeStringTextNode), "fix": makeChildAppender(writeStringTextNode), "sat": makeChildAppender(writeNonNegativeIntegerTextNode), "hdop": makeChildAppender(writeDecimalTextNode), "vdop": makeChildAppender(writeDecimalTextNode), "pdop": makeChildAppender(writeDecimalTextNode), "ageofdgpsdata": makeChildAppender(writeDecimalTextNode), "dgpsid": makeChildAppender(writeNonNegativeIntegerTextNode) }); var GEOMETRY_TYPE_TO_NODENAME = { "Point": "wpt", "LineString": "rte", "MultiLineString": "trk" }; function GPX_NODE_FACTORY(value, objectStack, nodeName) { const geometry = ( /** @type {Feature} */ value.getGeometry() ); if (geometry) { const nodeName2 = GEOMETRY_TYPE_TO_NODENAME[geometry.getType()]; if (nodeName2) { const parentNode = objectStack[objectStack.length - 1].node; return createElementNS(parentNode.namespaceURI, nodeName2); } } } function appendCoordinate(flatCoordinates, layoutOptions, node, values) { flatCoordinates.push( parseFloat(node.getAttribute("lon")), parseFloat(node.getAttribute("lat")) ); if ("ele" in values) { flatCoordinates.push( /** @type {number} */ values["ele"] ); delete values["ele"]; layoutOptions.hasZ = true; } else { flatCoordinates.push(0); } if ("time" in values) { flatCoordinates.push( /** @type {number} */ values["time"] ); delete values["time"]; layoutOptions.hasM = true; } else { flatCoordinates.push(0); } return flatCoordinates; } function applyLayoutOptions(layoutOptions, flatCoordinates, ends) { let layout = "XY"; let stride = 2; if (layoutOptions.hasZ && layoutOptions.hasM) { layout = "XYZM"; stride = 4; } else if (layoutOptions.hasZ) { layout = "XYZ"; stride = 3; } else if (layoutOptions.hasM) { layout = "XYM"; stride = 3; } if (stride !== 4) { for (let i = 0, ii = flatCoordinates.length / 4; i < ii; i++) { flatCoordinates[i * stride] = flatCoordinates[i * 4]; flatCoordinates[i * stride + 1] = flatCoordinates[i * 4 + 1]; if (layoutOptions.hasZ) { flatCoordinates[i * stride + 2] = flatCoordinates[i * 4 + 2]; } if (layoutOptions.hasM) { flatCoordinates[i * stride + 2] = flatCoordinates[i * 4 + 3]; } } flatCoordinates.length = flatCoordinates.length / 4 * stride; if (ends) { for (let i = 0, ii = ends.length; i < ii; i++) { ends[i] = ends[i] / 4 * stride; } } } return layout; } function readAuthor(node, objectStack) { const values = pushParseAndPop({}, AUTHOR_PARSERS, node, objectStack); if (values) { return values; } return void 0; } function readCopyright(node, objectStack) { const values = pushParseAndPop({}, COPYRIGHT_PARSERS, node, objectStack); if (values) { const author = node.getAttribute("author"); if (author !== null) { values["author"] = author; } return values; } return void 0; } function parseBounds(node, objectStack) { const values = ( /** @type {Object} */ objectStack[objectStack.length - 1] ); const minlat = node.getAttribute("minlat"); const minlon = node.getAttribute("minlon"); const maxlat = node.getAttribute("maxlat"); const maxlon = node.getAttribute("maxlon"); if (minlon !== null && minlat !== null && maxlon !== null && maxlat !== null) { values["bounds"] = [ [parseFloat(minlon), parseFloat(minlat)], [parseFloat(maxlon), parseFloat(maxlat)] ]; } } function parseEmail(node, objectStack) { const values = ( /** @type {Object} */ objectStack[objectStack.length - 1] ); const id = node.getAttribute("id"); const domain = node.getAttribute("domain"); if (id !== null && domain !== null) { values["email"] = `${id}@${domain}`; } } function parseLink(node, objectStack) { const values = ( /** @type {Object} */ objectStack[objectStack.length - 1] ); const href = node.getAttribute("href"); if (href !== null) { values["link"] = href; } parseNode(LINK_PARSERS, node, objectStack); } function parseExtensions(node, objectStack) { const values = ( /** @type {Object} */ objectStack[objectStack.length - 1] ); values["extensionsNode_"] = node; } function parseRtePt(node, objectStack) { const values = pushParseAndPop({}, RTEPT_PARSERS, node, objectStack); if (values) { const rteValues = ( /** @type {!Object} */ objectStack[objectStack.length - 1] ); const flatCoordinates = ( /** @type {Array} */ rteValues["flatCoordinates"] ); const layoutOptions = ( /** @type {LayoutOptions} */ rteValues["layoutOptions"] ); appendCoordinate(flatCoordinates, layoutOptions, node, values); } } function parseTrkPt(node, objectStack) { const values = pushParseAndPop({}, TRKPT_PARSERS, node, objectStack); if (values) { const trkValues = ( /** @type {!Object} */ objectStack[objectStack.length - 1] ); const flatCoordinates = ( /** @type {Array} */ trkValues["flatCoordinates"] ); const layoutOptions = ( /** @type {LayoutOptions} */ trkValues["layoutOptions"] ); appendCoordinate(flatCoordinates, layoutOptions, node, values); } } function parseTrkSeg(node, objectStack) { const values = ( /** @type {Object} */ objectStack[objectStack.length - 1] ); parseNode(TRKSEG_PARSERS, node, objectStack); const flatCoordinates = ( /** @type {Array} */ values["flatCoordinates"] ); const ends = ( /** @type {Array} */ values["ends"] ); ends.push(flatCoordinates.length); } function readRte(node, objectStack) { const options = ( /** @type {import("./Feature.js").ReadOptions} */ objectStack[0] ); const values = pushParseAndPop( { "flatCoordinates": [], "layoutOptions": {} }, RTE_PARSERS, node, objectStack ); if (!values) { return void 0; } const flatCoordinates = ( /** @type {Array} */ values["flatCoordinates"] ); delete values["flatCoordinates"]; const layoutOptions = ( /** @type {LayoutOptions} */ values["layoutOptions"] ); delete values["layoutOptions"]; const layout = applyLayoutOptions(layoutOptions, flatCoordinates); const geometry = new LineString_default(flatCoordinates, layout); transformGeometryWithOptions(geometry, false, options); const feature = new Feature_default(geometry); feature.setProperties(values, true); return feature; } function readTrk(node, objectStack) { const options = ( /** @type {import("./Feature.js").ReadOptions} */ objectStack[0] ); const values = pushParseAndPop( { "flatCoordinates": [], "ends": [], "layoutOptions": {} }, TRK_PARSERS, node, objectStack ); if (!values) { return void 0; } const flatCoordinates = ( /** @type {Array} */ values["flatCoordinates"] ); delete values["flatCoordinates"]; const ends = ( /** @type {Array} */ values["ends"] ); delete values["ends"]; const layoutOptions = ( /** @type {LayoutOptions} */ values["layoutOptions"] ); delete values["layoutOptions"]; const layout = applyLayoutOptions(layoutOptions, flatCoordinates, ends); const geometry = new MultiLineString_default(flatCoordinates, layout, ends); transformGeometryWithOptions(geometry, false, options); const feature = new Feature_default(geometry); feature.setProperties(values, true); return feature; } function readWpt(node, objectStack) { const options = ( /** @type {import("./Feature.js").ReadOptions} */ objectStack[0] ); const values = pushParseAndPop({}, WPT_PARSERS, node, objectStack); if (!values) { return void 0; } const layoutOptions = ( /** @type {LayoutOptions} */ {} ); const coordinates = appendCoordinate([], layoutOptions, node, values); const layout = applyLayoutOptions(layoutOptions, coordinates); const geometry = new Point_default(coordinates, layout); transformGeometryWithOptions(geometry, false, options); const feature = new Feature_default(geometry); feature.setProperties(values, true); return feature; } function writeLink(node, value, objectStack) { node.setAttribute("href", value); const context = objectStack[objectStack.length - 1]; const properties = context["properties"]; const link = [properties["linkText"], properties["linkType"]]; pushSerializeAndPop( /** @type {import("../xml.js").NodeStackItem} */ { node }, LINK_SERIALIZERS, OBJECT_PROPERTY_NODE_FACTORY, link, objectStack, LINK_SEQUENCE ); } function writeWptType(node, coordinate, objectStack) { const context = objectStack[objectStack.length - 1]; const parentNode = context.node; const namespaceURI = parentNode.namespaceURI; const properties = context["properties"]; node.setAttributeNS(null, "lat", String(coordinate[1])); node.setAttributeNS(null, "lon", String(coordinate[0])); const geometryLayout = context["geometryLayout"]; switch (geometryLayout) { case "XYZM": if (coordinate[3] !== 0) { properties["time"] = coordinate[3]; } // fall through case "XYZ": if (coordinate[2] !== 0) { properties["ele"] = coordinate[2]; } break; case "XYM": if (coordinate[2] !== 0) { properties["time"] = coordinate[2]; } break; default: } const orderedKeys = node.nodeName == "rtept" ? RTEPT_TYPE_SEQUENCE[namespaceURI] : WPT_TYPE_SEQUENCE[namespaceURI]; const values = makeSequence(properties, orderedKeys); pushSerializeAndPop( /** @type {import("../xml.js").NodeStackItem} */ { node, "properties": properties }, WPT_TYPE_SERIALIZERS, OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys ); } function writeRte(node, feature, objectStack) { const options = ( /** @type {import("./Feature.js").WriteOptions} */ objectStack[0] ); const properties = feature.getProperties(); const context = { node }; context["properties"] = properties; const geometry = feature.getGeometry(); if (geometry.getType() == "LineString") { const lineString = ( /** @type {LineString} */ transformGeometryWithOptions(geometry, true, options) ); context["geometryLayout"] = lineString.getLayout(); properties["rtept"] = lineString.getCoordinates(); } const parentNode = objectStack[objectStack.length - 1].node; const orderedKeys = RTE_SEQUENCE[parentNode.namespaceURI]; const values = makeSequence(properties, orderedKeys); pushSerializeAndPop( context, RTE_SERIALIZERS, OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys ); } function writeTrk(node, feature, objectStack) { const options = ( /** @type {import("./Feature.js").WriteOptions} */ objectStack[0] ); const properties = feature.getProperties(); const context = { node }; context["properties"] = properties; const geometry = feature.getGeometry(); if (geometry.getType() == "MultiLineString") { const multiLineString = ( /** @type {MultiLineString} */ transformGeometryWithOptions(geometry, true, options) ); properties["trkseg"] = multiLineString.getLineStrings(); } const parentNode = objectStack[objectStack.length - 1].node; const orderedKeys = TRK_SEQUENCE[parentNode.namespaceURI]; const values = makeSequence(properties, orderedKeys); pushSerializeAndPop( context, TRK_SERIALIZERS, OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys ); } function writeTrkSeg(node, lineString, objectStack) { const context = { node }; context["geometryLayout"] = lineString.getLayout(); context["properties"] = {}; pushSerializeAndPop( context, TRKSEG_SERIALIZERS, TRKSEG_NODE_FACTORY, lineString.getCoordinates(), objectStack ); } function writeWpt(node, feature, objectStack) { const options = ( /** @type {import("./Feature.js").WriteOptions} */ objectStack[0] ); const context = objectStack[objectStack.length - 1]; context["properties"] = feature.getProperties(); const geometry = feature.getGeometry(); if (geometry.getType() == "Point") { const point = ( /** @type {Point} */ transformGeometryWithOptions(geometry, true, options) ); context["geometryLayout"] = point.getLayout(); writeWptType(node, point.getCoordinates(), objectStack); } } var GPX_default = GPX; // node_modules/ol/format/TextFeature.js var TextFeature = class extends Feature_default3 { constructor() { super(); } /** * @return {import("./Feature.js").Type} Format. * @override */ getType() { return "text"; } /** * Read the feature from the source. * * @param {Document|Element|Object|string} source Source. * @param {import("./Feature.js").ReadOptions} [options] Read options. * @return {import("../Feature.js").default} Feature. * @api * @override */ readFeature(source, options) { return this.readFeatureFromText( getText(source), this.adaptOptions(options) ); } /** * @abstract * @param {string} text Text. * @param {import("./Feature.js").ReadOptions} [options] Read options. * @protected * @return {import("../Feature.js").default} Feature. */ readFeatureFromText(text, options) { return abstract(); } /** * Read the features from the source. * * @param {Document|Element|Object|string} source Source. * @param {import("./Feature.js").ReadOptions} [options] Read options. * @return {Array} Features. * @api * @override */ readFeatures(source, options) { return this.readFeaturesFromText( getText(source), this.adaptOptions(options) ); } /** * @abstract * @param {string} text Text. * @param {import("./Feature.js").ReadOptions} [options] Read options. * @protected * @return {Array} Features. */ readFeaturesFromText(text, options) { return abstract(); } /** * Read the geometry from the source. * * @param {Document|Element|Object|string} source Source. * @param {import("./Feature.js").ReadOptions} [options] Read options. * @return {import("../geom/Geometry.js").default} Geometry. * @api * @override */ readGeometry(source, options) { return this.readGeometryFromText( getText(source), this.adaptOptions(options) ); } /** * @abstract * @param {string} text Text. * @param {import("./Feature.js").ReadOptions} [options] Read options. * @protected * @return {import("../geom/Geometry.js").default} Geometry. */ readGeometryFromText(text, options) { return abstract(); } /** * Read the projection from the source. * * @param {Document|Element|Object|string} source Source. * @return {import("../proj/Projection.js").default|undefined} Projection. * @api * @override */ readProjection(source) { return this.readProjectionFromText(getText(source)); } /** * @param {string} text Text. * @protected * @return {import("../proj/Projection.js").default|undefined} Projection. */ readProjectionFromText(text) { return this.dataProjection; } /** * Encode a feature as a string. * * @param {import("../Feature.js").default} feature Feature. * @param {import("./Feature.js").WriteOptions} [options] Write options. * @return {string} Encoded feature. * @api * @override */ writeFeature(feature, options) { return this.writeFeatureText(feature, this.adaptOptions(options)); } /** * @abstract * @param {import("../Feature.js").default} feature Features. * @param {import("./Feature.js").WriteOptions} [options] Write options. * @protected * @return {string} Text. */ writeFeatureText(feature, options) { return abstract(); } /** * Encode an array of features as string. * * @param {Array} features Features. * @param {import("./Feature.js").WriteOptions} [options] Write options. * @return {string} Encoded features. * @api * @override */ writeFeatures(features, options) { return this.writeFeaturesText(features, this.adaptOptions(options)); } /** * @abstract * @param {Array} features Features. * @param {import("./Feature.js").WriteOptions} [options] Write options. * @protected * @return {string} Text. */ writeFeaturesText(features, options) { return abstract(); } /** * Write a single geometry. * * @param {import("../geom/Geometry.js").default} geometry Geometry. * @param {import("./Feature.js").WriteOptions} [options] Write options. * @return {string} Geometry. * @api * @override */ writeGeometry(geometry, options) { return this.writeGeometryText(geometry, this.adaptOptions(options)); } /** * @abstract * @param {import("../geom/Geometry.js").default} geometry Geometry. * @param {import("./Feature.js").WriteOptions} [options] Write options. * @protected * @return {string} Text. */ writeGeometryText(geometry, options) { return abstract(); } }; function getText(source) { if (typeof source === "string") { return source; } return ""; } var TextFeature_default = TextFeature; // node_modules/ol/format/IGC.js var B_RECORD_RE = /^B(\d{2})(\d{2})(\d{2})(\d{2})(\d{5})([NS])(\d{3})(\d{5})([EW])([AV])(\d{5})(\d{5})/; var H_RECORD_RE = /^H.([A-Z]{3}).*?:(.*)/; var HFDTE_RECORD_RE = /^HFDTE(\d{2})(\d{2})(\d{2})/; var HFDTEDATE_RECORD_RE = /^HFDTEDATE:(\d{2})(\d{2})(\d{2}),(\d{2})/; var NEWLINE_RE = /\r\n|\r|\n/; var IGC = class extends TextFeature_default { /** * @param {Options} [options] Options. */ constructor(options) { super(); options = options ? options : {}; this.dataProjection = get("EPSG:4326"); this.altitudeMode_ = options.altitudeMode ? options.altitudeMode : "none"; this.lad_ = false; this.lod_ = false; this.ladStart_ = 0; this.ladStop_ = 0; this.lodStart_ = 0; this.lodStop_ = 0; } /** * @protected * @param {string} text Text. * @param {import("./Feature.js").ReadOptions} [options] Read options. * @return {import("../Feature.js").default} Feature. * @override */ readFeatureFromText(text, options) { const altitudeMode = this.altitudeMode_; const lines = text.split(NEWLINE_RE); const properties = {}; const flatCoordinates = []; let year = 2e3; let month = 0; let day = 1; let lastDateTime = -1; let i, ii; for (i = 0, ii = lines.length; i < ii; ++i) { const line = lines[i]; let m; if (line.charAt(0) == "B") { m = B_RECORD_RE.exec(line); if (m) { const hour = parseInt(m[1], 10); const minute = parseInt(m[2], 10); const second = parseInt(m[3], 10); let y = parseInt(m[4], 10) + parseInt(m[5], 10) / 6e4; if (this.lad_) { y += parseInt(line.slice(this.ladStart_, this.ladStop_), 10) / 6e4 / 10 ** (this.ladStop_ - this.ladStart_); } if (m[6] == "S") { y = -y; } let x = parseInt(m[7], 10) + parseInt(m[8], 10) / 6e4; if (this.lod_) { x += parseInt(line.slice(this.lodStart_, this.lodStop_), 10) / 6e4 / 10 ** (this.lodStop_ - this.lodStart_); } if (m[9] == "W") { x = -x; } flatCoordinates.push(x, y); if (altitudeMode != "none") { let z; if (altitudeMode == "gps") { z = parseInt(m[11], 10); } else if (altitudeMode == "barometric") { z = parseInt(m[12], 10); } else { z = 0; } flatCoordinates.push(z); } let dateTime = Date.UTC(year, month, day, hour, minute, second); if (dateTime < lastDateTime) { dateTime = Date.UTC(year, month, day + 1, hour, minute, second); } flatCoordinates.push(dateTime / 1e3); lastDateTime = dateTime; } } else if (line.charAt(0) == "H") { m = HFDTEDATE_RECORD_RE.exec(line); if (m) { day = parseInt(m[1], 10); month = parseInt(m[2], 10) - 1; year = 2e3 + parseInt(m[3], 10); } else { m = HFDTE_RECORD_RE.exec(line); if (m) { day = parseInt(m[1], 10); month = parseInt(m[2], 10) - 1; year = 2e3 + parseInt(m[3], 10); } else { m = H_RECORD_RE.exec(line); if (m) { properties[m[1]] = m[2].trim(); } } } } else if (line.charAt(0) == "I") { const numberAdds = parseInt(line.slice(1, 3), 10); for (let i2 = 0; i2 < numberAdds; i2++) { const addCode = line.slice(7 + i2 * 7, 10 + i2 * 7); if (addCode === "LAD" || addCode === "LOD") { const addStart = parseInt(line.slice(3 + i2 * 7, 5 + i2 * 7), 10) - 1; const addStop = parseInt(line.slice(5 + i2 * 7, 7 + i2 * 7), 10); if (addCode === "LAD") { this.lad_ = true; this.ladStart_ = addStart; this.ladStop_ = addStop; } else if (addCode === "LOD") { this.lod_ = true; this.lodStart_ = addStart; this.lodStop_ = addStop; } } } } } if (flatCoordinates.length === 0) { return null; } const layout = altitudeMode == "none" ? "XYM" : "XYZM"; const lineString = new LineString_default(flatCoordinates, layout); const feature = new Feature_default( transformGeometryWithOptions(lineString, false, options) ); feature.setProperties(properties, true); return feature; } /** * @param {string} text Text. * @param {import("./Feature.js").ReadOptions} [options] Read options. * @protected * @return {Array} Features. * @override */ readFeaturesFromText(text, options) { const feature = this.readFeatureFromText(text, options); if (feature) { return [feature]; } return []; } }; var IGC_default = IGC; // node_modules/ol/format/KML.js var GX_NAMESPACE_URIS = ["http://www.google.com/kml/ext/2.2"]; var NAMESPACE_URIS2 = [ null, "http://earth.google.com/kml/2.0", "http://earth.google.com/kml/2.1", "http://earth.google.com/kml/2.2", "http://www.opengis.net/kml/2.2" ]; var SCHEMA_LOCATION2 = "http://www.opengis.net/kml/2.2 https://developers.google.com/kml/schema/kml22gx.xsd"; var ICON_ANCHOR_UNITS_MAP = { "fraction": "fraction", "pixels": "pixels", "insetPixels": "pixels" }; var PLACEMARK_PARSERS = makeStructureNS( NAMESPACE_URIS2, { "ExtendedData": extendedDataParser, "Region": regionParser, "MultiGeometry": makeObjectPropertySetter(readMultiGeometry, "geometry"), "LineString": makeObjectPropertySetter(readLineString, "geometry"), "LinearRing": makeObjectPropertySetter(readLinearRing, "geometry"), "Point": makeObjectPropertySetter(readPoint, "geometry"), "Polygon": makeObjectPropertySetter(readPolygon, "geometry"), "Style": makeObjectPropertySetter(readStyle), "StyleMap": placemarkStyleMapParser, "address": makeObjectPropertySetter(readString), "description": makeObjectPropertySetter(readString), "name": makeObjectPropertySetter(readString), "open": makeObjectPropertySetter(readBoolean), "phoneNumber": makeObjectPropertySetter(readString), "styleUrl": makeObjectPropertySetter(readStyleURL), "visibility": makeObjectPropertySetter(readBoolean) }, makeStructureNS(GX_NAMESPACE_URIS, { "MultiTrack": makeObjectPropertySetter(readGxMultiTrack, "geometry"), "Track": makeObjectPropertySetter(readGxTrack, "geometry") }) ); var NETWORK_LINK_PARSERS = makeStructureNS(NAMESPACE_URIS2, { "ExtendedData": extendedDataParser, "Region": regionParser, "Link": linkParser, "address": makeObjectPropertySetter(readString), "description": makeObjectPropertySetter(readString), "name": makeObjectPropertySetter(readString), "open": makeObjectPropertySetter(readBoolean), "phoneNumber": makeObjectPropertySetter(readString), "visibility": makeObjectPropertySetter(readBoolean) }); var LINK_PARSERS2 = makeStructureNS(NAMESPACE_URIS2, { "href": makeObjectPropertySetter(readURI) }); var CAMERA_PARSERS = makeStructureNS(NAMESPACE_URIS2, { Altitude: makeObjectPropertySetter(readDecimal), Longitude: makeObjectPropertySetter(readDecimal), Latitude: makeObjectPropertySetter(readDecimal), Tilt: makeObjectPropertySetter(readDecimal), AltitudeMode: makeObjectPropertySetter(readString), Heading: makeObjectPropertySetter(readDecimal), Roll: makeObjectPropertySetter(readDecimal) }); var REGION_PARSERS = makeStructureNS(NAMESPACE_URIS2, { "LatLonAltBox": latLonAltBoxParser, "Lod": lodParser }); var KML_SEQUENCE = makeStructureNS(NAMESPACE_URIS2, ["Document", "Placemark"]); var KML_SERIALIZERS = makeStructureNS(NAMESPACE_URIS2, { "Document": makeChildAppender(writeDocument), "Placemark": makeChildAppender(writePlacemark) }); var DEFAULT_COLOR; var DEFAULT_FILL_STYLE = null; var DEFAULT_IMAGE_STYLE_ANCHOR; var DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS; var DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS; var DEFAULT_IMAGE_STYLE_SIZE; var DEFAULT_IMAGE_STYLE_SRC; var DEFAULT_IMAGE_STYLE = null; var DEFAULT_NO_IMAGE_STYLE; var DEFAULT_STROKE_STYLE = null; var DEFAULT_TEXT_STROKE_STYLE; var DEFAULT_TEXT_STYLE = null; var DEFAULT_STYLE = null; var DEFAULT_STYLE_ARRAY = null; function scaleForSize(size) { return 32 / Math.min(size[0], size[1]); } function createStyleDefaults() { DEFAULT_COLOR = [255, 255, 255, 1]; DEFAULT_FILL_STYLE = new Fill_default({ color: DEFAULT_COLOR }); DEFAULT_IMAGE_STYLE_ANCHOR = [20, 2]; DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS = "pixels"; DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS = "pixels"; DEFAULT_IMAGE_STYLE_SIZE = [64, 64]; DEFAULT_IMAGE_STYLE_SRC = "https://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png"; DEFAULT_IMAGE_STYLE = new Icon_default({ anchor: DEFAULT_IMAGE_STYLE_ANCHOR, anchorOrigin: "bottom-left", anchorXUnits: DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS, anchorYUnits: DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS, crossOrigin: "anonymous", rotation: 0, scale: scaleForSize(DEFAULT_IMAGE_STYLE_SIZE), size: DEFAULT_IMAGE_STYLE_SIZE, src: DEFAULT_IMAGE_STYLE_SRC }); DEFAULT_NO_IMAGE_STYLE = "NO_IMAGE"; DEFAULT_STROKE_STYLE = new Stroke_default({ color: DEFAULT_COLOR, width: 1 }); DEFAULT_TEXT_STROKE_STYLE = new Stroke_default({ color: [51, 51, 51, 1], width: 2 }); DEFAULT_TEXT_STYLE = new Text_default({ font: "bold 16px Helvetica", fill: DEFAULT_FILL_STYLE, stroke: DEFAULT_TEXT_STROKE_STYLE, scale: 0.8 }); DEFAULT_STYLE = new Style_default({ fill: DEFAULT_FILL_STYLE, image: DEFAULT_IMAGE_STYLE, text: DEFAULT_TEXT_STYLE, stroke: DEFAULT_STROKE_STYLE, zIndex: 0 }); DEFAULT_STYLE_ARRAY = [DEFAULT_STYLE]; } var TEXTAREA; function defaultIconUrlFunction(href) { return href; } var KML = class extends XMLFeature_default { /** * @param {Options} [options] Options. */ constructor(options) { super(); options = options ? options : {}; if (!DEFAULT_STYLE_ARRAY) { createStyleDefaults(); } this.dataProjection = get("EPSG:4326"); this.defaultStyle_ = options.defaultStyle ? options.defaultStyle : DEFAULT_STYLE_ARRAY; this.extractStyles_ = options.extractStyles !== void 0 ? options.extractStyles : true; this.writeStyles_ = options.writeStyles !== void 0 ? options.writeStyles : true; this.sharedStyles_ = {}; this.showPointNames_ = options.showPointNames !== void 0 ? options.showPointNames : true; this.crossOrigin_ = options.crossOrigin !== void 0 ? options.crossOrigin : "anonymous"; this.iconUrlFunction_ = options.iconUrlFunction ? options.iconUrlFunction : defaultIconUrlFunction; this.supportedMediaTypes = ["application/vnd.google-earth.kml+xml"]; } /** * @param {Node} node Node. * @param {Array<*>} objectStack Object stack. * @private * @return {Array|undefined} Features. */ readDocumentOrFolder_(node, objectStack) { const parsersNS = makeStructureNS(NAMESPACE_URIS2, { "Document": makeArrayExtender(this.readDocumentOrFolder_, this), "Folder": makeArrayExtender(this.readDocumentOrFolder_, this), "Placemark": makeArrayPusher(this.readPlacemark_, this), "Style": this.readSharedStyle_.bind(this), "StyleMap": this.readSharedStyleMap_.bind(this) }); const features = pushParseAndPop([], parsersNS, node, objectStack, this); if (features) { return features; } return void 0; } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @private * @return {Feature|undefined} Feature. */ readPlacemark_(node, objectStack) { const object = pushParseAndPop( { "geometry": null }, PLACEMARK_PARSERS, node, objectStack, this ); if (!object) { return void 0; } const feature = new Feature_default(); const id = node.getAttribute("id"); if (id !== null) { feature.setId(id); } const options = ( /** @type {import("./Feature.js").ReadOptions} */ objectStack[0] ); const geometry = object["geometry"]; if (geometry) { transformGeometryWithOptions(geometry, false, options); } feature.setGeometry(geometry); delete object["geometry"]; if (this.extractStyles_) { const style = object["Style"]; const styleUrl = object["styleUrl"]; const styleFunction = createFeatureStyleFunction( style, styleUrl, this.defaultStyle_, this.sharedStyles_, this.showPointNames_ ); feature.setStyle(styleFunction); } delete object["Style"]; feature.setProperties(object, true); return feature; } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @private */ readSharedStyle_(node, objectStack) { const id = node.getAttribute("id"); if (id !== null) { const style = readStyle.call(this, node, objectStack); if (style) { let styleUri; let baseURI = node.baseURI; if (!baseURI || baseURI == "about:blank") { baseURI = window.location.href; } if (baseURI) { const url = new URL("#" + id, baseURI); styleUri = url.href; } else { styleUri = "#" + id; } this.sharedStyles_[styleUri] = style; } } } /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. * @private */ readSharedStyleMap_(node, objectStack) { const id = node.getAttribute("id"); if (id === null) { return; } const styleMapValue = readStyleMapValue.call(this, node, objectStack); if (!styleMapValue) { return; } let styleUri; let baseURI = node.baseURI; if (!baseURI || baseURI == "about:blank") { baseURI = window.location.href; } if (baseURI) { const url = new URL("#" + id, baseURI); styleUri = url.href; } else { styleUri = "#" + id; } this.sharedStyles_[styleUri] = styleMapValue; } /** * @param {Element} node Node. * @param {import("./Feature.js").ReadOptions} [options] Options. * @return {import("../Feature.js").default} Feature. * @override */ readFeatureFromNode(node, options) { if (!NAMESPACE_URIS2.includes(node.namespaceURI)) { return null; } const feature = this.readPlacemark_(node, [ this.getReadOptions(node, options) ]); if (feature) { return feature; } return null; } /** * @protected * @param {Element} node Node. * @param {import("./Feature.js").ReadOptions} [options] Options. * @return {Array} Features. * @override */ readFeaturesFromNode(node, options) { if (!NAMESPACE_URIS2.includes(node.namespaceURI)) { return []; } let features; const localName = node.localName; if (localName == "Document" || localName == "Folder") { features = this.readDocumentOrFolder_(node, [ this.getReadOptions(node, options) ]); if (features) { return features; } return []; } if (localName == "Placemark") { const feature = this.readPlacemark_(node, [ this.getReadOptions(node, options) ]); if (feature) { return [feature]; } return []; } if (localName == "kml") { features = []; for (let n = node.firstElementChild; n; n = n.nextElementSibling) { const fs = this.readFeaturesFromNode(n, options); if (fs) { extend(features, fs); } } return features; } return []; } /** * Read the name of the KML. * * @param {Document|Element|string} source Source. * @return {string|undefined} Name. * @api */ readName(source) { if (!source) { return void 0; } if (typeof source === "string") { const doc = parse(source); return this.readNameFromDocument(doc); } if (isDocument(source)) { return this.readNameFromDocument( /** @type {Document} */ source ); } return this.readNameFromNode( /** @type {Element} */ source ); } /** * @param {Document} doc Document. * @return {string|undefined} Name. */ readNameFromDocument(doc) { for (let n = ( /** @type {Node} */ doc.firstChild ); n; n = n.nextSibling) { if (n.nodeType == Node.ELEMENT_NODE) { const name = this.readNameFromNode( /** @type {Element} */ n ); if (name) { return name; } } } return void 0; } /** * @param {Element} node Node. * @return {string|undefined} Name. */ readNameFromNode(node) { for (let n = node.firstElementChild; n; n = n.nextElementSibling) { if (NAMESPACE_URIS2.includes(n.namespaceURI) && n.localName == "name") { return readString(n); } } for (let n = node.firstElementChild; n; n = n.nextElementSibling) { const localName = n.localName; if (NAMESPACE_URIS2.includes(n.namespaceURI) && (localName == "Document" || localName == "Folder" || localName == "Placemark" || localName == "kml")) { const name = this.readNameFromNode(n); if (name) { return name; } } } return void 0; } /** * Read the network links of the KML. * * @param {Document|Element|string} source Source. * @return {Array} Network links. * @api */ readNetworkLinks(source) { const networkLinks = []; if (typeof source === "string") { const doc = parse(source); extend(networkLinks, this.readNetworkLinksFromDocument(doc)); } else if (isDocument(source)) { extend( networkLinks, this.readNetworkLinksFromDocument( /** @type {Document} */ source ) ); } else { extend( networkLinks, this.readNetworkLinksFromNode( /** @type {Element} */ source ) ); } return networkLinks; } /** * @param {Document} doc Document. * @return {Array} Network links. */ readNetworkLinksFromDocument(doc) { const networkLinks = []; for (let n = ( /** @type {Node} */ doc.firstChild ); n; n = n.nextSibling) { if (n.nodeType == Node.ELEMENT_NODE) { extend( networkLinks, this.readNetworkLinksFromNode( /** @type {Element} */ n ) ); } } return networkLinks; } /** * @param {Element} node Node. * @return {Array} Network links. */ readNetworkLinksFromNode(node) { const networkLinks = []; for (let n = node.firstElementChild; n; n = n.nextElementSibling) { if (NAMESPACE_URIS2.includes(n.namespaceURI) && n.localName == "NetworkLink") { const obj = pushParseAndPop({}, NETWORK_LINK_PARSERS, n, []); networkLinks.push(obj); } } for (let n = node.firstElementChild; n; n = n.nextElementSibling) { const localName = n.localName; if (NAMESPACE_URIS2.includes(n.namespaceURI) && (localName == "Document" || localName == "Folder" || localName == "kml")) { extend(networkLinks, this.readNetworkLinksFromNode(n)); } } return networkLinks; } /** * Read the regions of the KML. * * @param {Document|Element|string} source Source. * @return {Array} Regions. * @api */ readRegion(source) { const regions = []; if (typeof source === "string") { const doc = parse(source); extend(regions, this.readRegionFromDocument(doc)); } else if (isDocument(source)) { extend( regions, this.readRegionFromDocument( /** @type {Document} */ source ) ); } else { extend(regions, this.readRegionFromNode( /** @type {Element} */ source )); } return regions; } /** * @param {Document} doc Document. * @return {Array} Region. */ readRegionFromDocument(doc) { const regions = []; for (let n = ( /** @type {Node} */ doc.firstChild ); n; n = n.nextSibling) { if (n.nodeType == Node.ELEMENT_NODE) { extend(regions, this.readRegionFromNode( /** @type {Element} */ n )); } } return regions; } /** * @param {Element} node Node. * @return {Array} Region. * @api */ readRegionFromNode(node) { const regions = []; for (let n = node.firstElementChild; n; n = n.nextElementSibling) { if (NAMESPACE_URIS2.includes(n.namespaceURI) && n.localName == "Region") { const obj = pushParseAndPop({}, REGION_PARSERS, n, []); regions.push(obj); } } for (let n = node.firstElementChild; n; n = n.nextElementSibling) { const localName = n.localName; if (NAMESPACE_URIS2.includes(n.namespaceURI) && (localName == "Document" || localName == "Folder" || localName == "kml")) { extend(regions, this.readRegionFromNode(n)); } } return regions; } /** * @typedef {Object} KMLCamera Specifies the observer's viewpoint and associated view parameters. * @property {number} [Latitude] Latitude of the camera. * @property {number} [Longitude] Longitude of the camera. * @property {number} [Altitude] Altitude of the camera. * @property {string} [AltitudeMode] Floor-related altitude mode. * @property {number} [Heading] Horizontal camera rotation. * @property {number} [Tilt] Lateral camera rotation. * @property {number} [Roll] Vertical camera rotation. */ /** * Read the cameras of the KML. * * @param {Document|Element|string} source Source. * @return {Array} Cameras. * @api */ readCamera(source) { const cameras = []; if (typeof source === "string") { const doc = parse(source); extend(cameras, this.readCameraFromDocument(doc)); } else if (isDocument(source)) { extend( cameras, this.readCameraFromDocument( /** @type {Document} */ source ) ); } else { extend(cameras, this.readCameraFromNode( /** @type {Element} */ source )); } return cameras; } /** * @param {Document} doc Document. * @return {Array} Cameras. */ readCameraFromDocument(doc) { const cameras = []; for (let n = ( /** @type {Node} */ doc.firstChild ); n; n = n.nextSibling) { if (n.nodeType === Node.ELEMENT_NODE) { extend(cameras, this.readCameraFromNode( /** @type {Element} */ n )); } } return cameras; } /** * @param {Element} node Node. * @return {Array} Cameras. * @api */ readCameraFromNode(node) { const cameras = []; for (let n = node.firstElementChild; n; n = n.nextElementSibling) { if (NAMESPACE_URIS2.includes(n.namespaceURI) && n.localName === "Camera") { const obj = pushParseAndPop({}, CAMERA_PARSERS, n, []); cameras.push(obj); } } for (let n = node.firstElementChild; n; n = n.nextElementSibling) { const localName = n.localName; if (NAMESPACE_URIS2.includes(n.namespaceURI) && (localName === "Document" || localName === "Folder" || localName === "Placemark" || localName === "kml")) { extend(cameras, this.readCameraFromNode(n)); } } return cameras; } /** * Encode an array of features in the KML format as an XML node. GeometryCollections, * MultiPoints, MultiLineStrings, and MultiPolygons are output as MultiGeometries. * * @param {Array} features Features. * @param {import("./Feature.js").WriteOptions} [options] Options. * @return {Node} Node. * @api * @override */ writeFeaturesNode(features, options) { options = this.adaptOptions(options); const kml = createElementNS(NAMESPACE_URIS2[4], "kml"); const xmlnsUri = "http://www.w3.org/2000/xmlns/"; kml.setAttributeNS(xmlnsUri, "xmlns:gx", GX_NAMESPACE_URIS[0]); kml.setAttributeNS(xmlnsUri, "xmlns:xsi", XML_SCHEMA_INSTANCE_URI); kml.setAttributeNS( XML_SCHEMA_INSTANCE_URI, "xsi:schemaLocation", SCHEMA_LOCATION2 ); const context = { node: kml }; const properties = {}; if (features.length > 1) { properties["Document"] = features; } else if (features.length == 1) { properties["Placemark"] = features[0]; } const orderedKeys = KML_SEQUENCE[kml.namespaceURI]; const values = makeSequence(properties, orderedKeys); pushSerializeAndPop( context, KML_SERIALIZERS, OBJECT_PROPERTY_NODE_FACTORY, values, [options], orderedKeys, this ); return kml; } }; function createNameStyleFunction(foundStyle, name) { const textOffset = [0, 0]; let textAlign = "start"; const imageStyle = foundStyle.getImage(); if (imageStyle) { const imageSize = imageStyle.getSize(); if (imageSize && imageSize.length == 2) { const imageScale = imageStyle.getScaleArray(); const anchor = imageStyle.getAnchor(); textOffset[0] = imageScale[0] * (imageSize[0] - anchor[0]); textOffset[1] = imageScale[1] * (imageSize[1] / 2 - anchor[1]); textAlign = "left"; } } let textStyle = foundStyle.getText(); if (textStyle) { textStyle = textStyle.clone(); textStyle.setFont(textStyle.getFont() || DEFAULT_TEXT_STYLE.getFont()); textStyle.setScale(textStyle.getScale() || DEFAULT_TEXT_STYLE.getScale()); textStyle.setFill(textStyle.getFill() || DEFAULT_TEXT_STYLE.getFill()); textStyle.setStroke(textStyle.getStroke() || DEFAULT_TEXT_STROKE_STYLE); } else { textStyle = DEFAULT_TEXT_STYLE.clone(); } textStyle.setText(name); textStyle.setOffsetX(textOffset[0]); textStyle.setOffsetY(textOffset[1]); textStyle.setTextAlign(textAlign); const nameStyle = new Style_default({ image: imageStyle, text: textStyle }); return nameStyle; } function createFeatureStyleFunction(style, styleUrl, defaultStyle, sharedStyles, showPointNames) { return ( /** * @param {Feature} feature feature. * @param {number} resolution Resolution. * @return {Array