Merge pull request #8718 from schmidtk/ts-format-gpx
Fix TypeScript errors in ol/format/GPX
This commit is contained in:
+23
-22
@@ -738,8 +738,8 @@ function writeWptType(node, coordinate, objectStack) {
|
|||||||
const namespaceURI = parentNode.namespaceURI;
|
const namespaceURI = parentNode.namespaceURI;
|
||||||
const properties = context['properties'];
|
const properties = context['properties'];
|
||||||
//FIXME Projection handling
|
//FIXME Projection handling
|
||||||
node.setAttributeNS(null, 'lat', coordinate[1]);
|
node.setAttributeNS(null, 'lat', String(coordinate[1]));
|
||||||
node.setAttributeNS(null, 'lon', coordinate[0]);
|
node.setAttributeNS(null, 'lon', String(coordinate[0]));
|
||||||
const geometryLayout = context['geometryLayout'];
|
const geometryLayout = context['geometryLayout'];
|
||||||
switch (geometryLayout) {
|
switch (geometryLayout) {
|
||||||
case GeometryLayout.XYZM:
|
case GeometryLayout.XYZM:
|
||||||
@@ -779,12 +779,13 @@ function writeWptType(node, coordinate, objectStack) {
|
|||||||
function writeRte(node, feature, objectStack) {
|
function writeRte(node, feature, objectStack) {
|
||||||
const options = /** @type {import("./Feature.js").WriteOptions} */ (objectStack[0]);
|
const options = /** @type {import("./Feature.js").WriteOptions} */ (objectStack[0]);
|
||||||
const properties = feature.getProperties();
|
const properties = feature.getProperties();
|
||||||
const context = {node: node, 'properties': properties};
|
const context = {node: node};
|
||||||
let geometry = feature.getGeometry();
|
context['properties'] = properties;
|
||||||
if (geometry) {
|
const geometry = feature.getGeometry();
|
||||||
geometry = /** @type {LineString} */ (transformWithOptions(geometry, true, options));
|
if (geometry instanceof LineString) {
|
||||||
context['geometryLayout'] = geometry.getLayout();
|
const lineString = /** @type {LineString} */ (transformWithOptions(geometry, true, options));
|
||||||
properties['rtept'] = geometry.getCoordinates();
|
context['geometryLayout'] = lineString.getLayout();
|
||||||
|
properties['rtept'] = lineString.getCoordinates();
|
||||||
}
|
}
|
||||||
const parentNode = objectStack[objectStack.length - 1].node;
|
const parentNode = objectStack[objectStack.length - 1].node;
|
||||||
const orderedKeys = RTE_SEQUENCE[parentNode.namespaceURI];
|
const orderedKeys = RTE_SEQUENCE[parentNode.namespaceURI];
|
||||||
@@ -804,12 +805,12 @@ function writeTrk(node, feature, objectStack) {
|
|||||||
const options = /** @type {import("./Feature.js").WriteOptions} */ (objectStack[0]);
|
const options = /** @type {import("./Feature.js").WriteOptions} */ (objectStack[0]);
|
||||||
const properties = feature.getProperties();
|
const properties = feature.getProperties();
|
||||||
/** @type {import("../xml.js").NodeStackItem} */
|
/** @type {import("../xml.js").NodeStackItem} */
|
||||||
const context = {node: node, 'properties': properties};
|
const context = {node: node};
|
||||||
let geometry = feature.getGeometry();
|
context['properties'] = properties;
|
||||||
if (geometry) {
|
const geometry = feature.getGeometry();
|
||||||
geometry = /** @type {MultiLineString} */
|
if (geometry instanceof MultiLineString) {
|
||||||
(transformWithOptions(geometry, true, options));
|
const multiLineString = /** @type {MultiLineString} */ (transformWithOptions(geometry, true, options));
|
||||||
properties['trkseg'] = geometry.getLineStrings();
|
properties['trkseg'] = multiLineString.getLineStrings();
|
||||||
}
|
}
|
||||||
const parentNode = objectStack[objectStack.length - 1].node;
|
const parentNode = objectStack[objectStack.length - 1].node;
|
||||||
const orderedKeys = TRK_SEQUENCE[parentNode.namespaceURI];
|
const orderedKeys = TRK_SEQUENCE[parentNode.namespaceURI];
|
||||||
@@ -827,8 +828,9 @@ function writeTrk(node, feature, objectStack) {
|
|||||||
*/
|
*/
|
||||||
function writeTrkSeg(node, lineString, objectStack) {
|
function writeTrkSeg(node, lineString, objectStack) {
|
||||||
/** @type {import("../xml.js").NodeStackItem} */
|
/** @type {import("../xml.js").NodeStackItem} */
|
||||||
const context = {node: node, 'geometryLayout': lineString.getLayout(),
|
const context = {node: node};
|
||||||
'properties': {}};
|
context['geometryLayout'] = lineString.getLayout();
|
||||||
|
context['properties'] = {};
|
||||||
pushSerializeAndPop(context,
|
pushSerializeAndPop(context,
|
||||||
TRKSEG_SERIALIZERS, TRKSEG_NODE_FACTORY,
|
TRKSEG_SERIALIZERS, TRKSEG_NODE_FACTORY,
|
||||||
lineString.getCoordinates(), objectStack);
|
lineString.getCoordinates(), objectStack);
|
||||||
@@ -844,12 +846,11 @@ function writeWpt(node, feature, objectStack) {
|
|||||||
const options = /** @type {import("./Feature.js").WriteOptions} */ (objectStack[0]);
|
const options = /** @type {import("./Feature.js").WriteOptions} */ (objectStack[0]);
|
||||||
const context = objectStack[objectStack.length - 1];
|
const context = objectStack[objectStack.length - 1];
|
||||||
context['properties'] = feature.getProperties();
|
context['properties'] = feature.getProperties();
|
||||||
let geometry = feature.getGeometry();
|
const geometry = feature.getGeometry();
|
||||||
if (geometry) {
|
if (geometry instanceof Point) {
|
||||||
geometry = /** @type {Point} */
|
const point = /** @type {Point} */ (transformWithOptions(geometry, true, options));
|
||||||
(transformWithOptions(geometry, true, options));
|
context['geometryLayout'] = point.getLayout();
|
||||||
context['geometryLayout'] = geometry.getLayout();
|
writeWptType(node, point.getCoordinates(), objectStack);
|
||||||
writeWptType(node, geometry.getCoordinates(), objectStack);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user