Fix TypeScript errors in ol/format/GML
This commit is contained in:
@@ -179,7 +179,7 @@ class GML2 extends GMLBase {
|
||||
writeFeatureElement(node, feature, objectStack) {
|
||||
const fid = feature.getId();
|
||||
if (fid) {
|
||||
node.setAttribute('fid', fid);
|
||||
node.setAttribute('fid', /** @type {string} */ (fid));
|
||||
}
|
||||
const context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||
const featureNS = context['featureNS'];
|
||||
@@ -285,7 +285,7 @@ class GML2 extends GMLBase {
|
||||
writeGeometryElement(node, geometry, objectStack) {
|
||||
const context = /** @type {import("./Feature.js").WriteOptions} */ (objectStack[objectStack.length - 1]);
|
||||
const item = assign({}, context);
|
||||
item.node = node;
|
||||
item['node'] = node;
|
||||
let value;
|
||||
if (Array.isArray(geometry)) {
|
||||
if (context.dataProjection) {
|
||||
@@ -588,9 +588,9 @@ class GML2 extends GMLBase {
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
* @private
|
||||
* @protected
|
||||
*/
|
||||
GML2.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS_ = {
|
||||
GML2.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS = {
|
||||
'http://www.opengis.net/gml': {
|
||||
'coordinates': makeReplacer(GML2.prototype.readFlatCoordinates_)
|
||||
}
|
||||
@@ -599,9 +599,9 @@ GML2.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS_ = {
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
* @private
|
||||
* @protected
|
||||
*/
|
||||
GML2.prototype.FLAT_LINEAR_RINGS_PARSERS_ = {
|
||||
GML2.prototype.FLAT_LINEAR_RINGS_PARSERS = {
|
||||
'http://www.opengis.net/gml': {
|
||||
'innerBoundaryIs': GML2.prototype.innerBoundaryIsParser_,
|
||||
'outerBoundaryIs': GML2.prototype.outerBoundaryIsParser_
|
||||
@@ -623,9 +623,9 @@ GML2.prototype.BOX_PARSERS_ = {
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
* @private
|
||||
* @protected
|
||||
*/
|
||||
GML2.prototype.GEOMETRY_PARSERS_ = {
|
||||
GML2.prototype.GEOMETRY_PARSERS = {
|
||||
'http://www.opengis.net/gml': {
|
||||
'Point': makeReplacer(GMLBase.prototype.readPoint),
|
||||
'MultiPoint': makeReplacer(
|
||||
|
||||
@@ -183,7 +183,7 @@ class GML3 extends GMLBase {
|
||||
*/
|
||||
readPolygonPatch_(node, objectStack) {
|
||||
return pushParseAndPop([null],
|
||||
this.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack, this);
|
||||
this.FLAT_LINEAR_RINGS_PARSERS, node, objectStack, this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,7 +194,7 @@ class GML3 extends GMLBase {
|
||||
*/
|
||||
readLineStringSegment_(node, objectStack) {
|
||||
return pushParseAndPop([null],
|
||||
this.GEOMETRY_FLAT_COORDINATES_PARSERS_,
|
||||
this.GEOMETRY_FLAT_COORDINATES_PARSERS,
|
||||
node, objectStack, this);
|
||||
}
|
||||
|
||||
@@ -357,9 +357,9 @@ class GML3 extends GMLBase {
|
||||
} else if (node.getAttribute('dimension')) {
|
||||
dim = readNonNegativeIntegerString(
|
||||
node.getAttribute('dimension'));
|
||||
} else if (node.parentNode.getAttribute('srsDimension')) {
|
||||
} else if (/** @type {Element} */ (node.parentNode).getAttribute('srsDimension')) {
|
||||
dim = readNonNegativeIntegerString(
|
||||
node.parentNode.getAttribute('srsDimension'));
|
||||
/** @type {Element} */ (node.parentNode).getAttribute('srsDimension'));
|
||||
} else if (contextDimension) {
|
||||
dim = readNonNegativeIntegerString(contextDimension);
|
||||
}
|
||||
@@ -387,7 +387,7 @@ class GML3 extends GMLBase {
|
||||
writePos_(node, value, objectStack) {
|
||||
const context = objectStack[objectStack.length - 1];
|
||||
const hasZ = context['hasZ'];
|
||||
const srsDimension = hasZ ? 3 : 2;
|
||||
const srsDimension = hasZ ? '3' : '2';
|
||||
node.setAttribute('srsDimension', srsDimension);
|
||||
const srsName = context['srsName'];
|
||||
let axisOrientation = 'enu';
|
||||
@@ -443,7 +443,7 @@ class GML3 extends GMLBase {
|
||||
writePosList_(node, value, objectStack) {
|
||||
const context = objectStack[objectStack.length - 1];
|
||||
const hasZ = context['hasZ'];
|
||||
const srsDimension = hasZ ? 3 : 2;
|
||||
const srsDimension = hasZ ? '3' : '2';
|
||||
node.setAttribute('srsDimension', srsDimension);
|
||||
const srsName = context['srsName'];
|
||||
// only 2d for simple features profile
|
||||
@@ -731,7 +731,7 @@ class GML3 extends GMLBase {
|
||||
writeGeometryElement(node, geometry, objectStack) {
|
||||
const context = /** @type {import("./Feature.js").WriteOptions} */ (objectStack[objectStack.length - 1]);
|
||||
const item = assign({}, context);
|
||||
item.node = node;
|
||||
item['node'] = node;
|
||||
let value;
|
||||
if (Array.isArray(geometry)) {
|
||||
if (context.dataProjection) {
|
||||
@@ -757,7 +757,7 @@ class GML3 extends GMLBase {
|
||||
writeFeatureElement(node, feature, objectStack) {
|
||||
const fid = feature.getId();
|
||||
if (fid) {
|
||||
node.setAttribute('fid', fid);
|
||||
node.setAttribute('fid', /** @type {string} */ (fid));
|
||||
}
|
||||
const context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||
const featureNS = context['featureNS'];
|
||||
@@ -805,6 +805,7 @@ class GML3 extends GMLBase {
|
||||
const context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||
const featureType = context['featureType'];
|
||||
const featureNS = context['featureNS'];
|
||||
/** @type {Object<string, Object<string, import("../xml.js").Serializer>>} */
|
||||
const serializers = {};
|
||||
serializers[featureNS] = {};
|
||||
serializers[featureNS][featureType] = makeChildAppender(
|
||||
@@ -921,9 +922,9 @@ class GML3 extends GMLBase {
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
* @private
|
||||
* @protected
|
||||
*/
|
||||
GML3.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS_ = {
|
||||
GML3.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS = {
|
||||
'http://www.opengis.net/gml': {
|
||||
'pos': makeReplacer(GML3.prototype.readFlatPos_),
|
||||
'posList': makeReplacer(GML3.prototype.readFlatPosList_)
|
||||
@@ -934,9 +935,9 @@ GML3.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS_ = {
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
* @private
|
||||
* @protected
|
||||
*/
|
||||
GML3.prototype.FLAT_LINEAR_RINGS_PARSERS_ = {
|
||||
GML3.prototype.FLAT_LINEAR_RINGS_PARSERS = {
|
||||
'http://www.opengis.net/gml': {
|
||||
'interior': GML3.prototype.interiorParser_,
|
||||
'exterior': GML3.prototype.exteriorParser_
|
||||
@@ -947,9 +948,9 @@ GML3.prototype.FLAT_LINEAR_RINGS_PARSERS_ = {
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
* @private
|
||||
* @protected
|
||||
*/
|
||||
GML3.prototype.GEOMETRY_PARSERS_ = {
|
||||
GML3.prototype.GEOMETRY_PARSERS = {
|
||||
'http://www.opengis.net/gml': {
|
||||
'Point': makeReplacer(GMLBase.prototype.readPoint),
|
||||
'MultiPoint': makeReplacer(
|
||||
|
||||
@@ -71,6 +71,7 @@ const ONLY_WHITESPACE_RE = /^[\s\xa0]*$/;
|
||||
* gml:MultiPolygon. Since the latter is deprecated in GML 3.
|
||||
* @property {string} [schemaLocation] Optional schemaLocation to use when
|
||||
* writing out the GML, this will override the default provided.
|
||||
* @property {boolean} [hasZ=false] If coordinates have a Z value.
|
||||
*/
|
||||
|
||||
|
||||
@@ -126,7 +127,6 @@ class GMLBase extends XMLFeature {
|
||||
'featureMember': makeReplacer(this.readFeaturesInternal),
|
||||
'featureMembers': makeReplacer(this.readFeaturesInternal)
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,9 +189,11 @@ class GMLBase extends XMLFeature {
|
||||
featureNS = {};
|
||||
featureNS[defaultPrefix] = ns;
|
||||
}
|
||||
/** @type {Object<string, Object<string, import("../xml.js").Parser>>} */
|
||||
const parsersNS = {};
|
||||
const featureTypes = Array.isArray(featureType) ? featureType : [featureType];
|
||||
for (const p in featureNS) {
|
||||
/** @type {Object<string, import("../xml.js").Parser>} */
|
||||
const parsers = {};
|
||||
for (let i = 0, ii = featureTypes.length; i < ii; ++i) {
|
||||
const featurePrefix = featureTypes[i].indexOf(':') === -1 ?
|
||||
@@ -227,7 +229,7 @@ class GMLBase extends XMLFeature {
|
||||
context['srsName'] = node.firstElementChild.getAttribute('srsName');
|
||||
context['srsDimension'] = node.firstElementChild.getAttribute('srsDimension');
|
||||
/** @type {import("../geom/Geometry.js").default} */
|
||||
const geometry = pushParseAndPop(null, this.GEOMETRY_PARSERS_, node, objectStack, this);
|
||||
const geometry = pushParseAndPop(null, this.GEOMETRY_PARSERS, node, objectStack, this);
|
||||
if (geometry) {
|
||||
return (
|
||||
/** @type {import("../geom/Geometry.js").default} */ (transformWithOptions(geometry, false, context))
|
||||
@@ -383,7 +385,7 @@ class GMLBase extends XMLFeature {
|
||||
*/
|
||||
readFlatLinearRing_(node, objectStack) {
|
||||
const ring = pushParseAndPop(null,
|
||||
this.GEOMETRY_FLAT_COORDINATES_PARSERS_, node,
|
||||
this.GEOMETRY_FLAT_COORDINATES_PARSERS, node,
|
||||
objectStack, this);
|
||||
if (ring) {
|
||||
return ring;
|
||||
@@ -412,7 +414,7 @@ class GMLBase extends XMLFeature {
|
||||
readPolygon(node, objectStack) {
|
||||
/** @type {Array<Array<number>>} */
|
||||
const flatLinearRings = pushParseAndPop([null],
|
||||
this.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack, this);
|
||||
this.FLAT_LINEAR_RINGS_PARSERS, node, objectStack, this);
|
||||
if (flatLinearRings && flatLinearRings[0]) {
|
||||
const flatCoordinates = flatLinearRings[0];
|
||||
const ends = [flatCoordinates.length];
|
||||
@@ -434,7 +436,7 @@ class GMLBase extends XMLFeature {
|
||||
* @return {Array<number>} Flat coordinates.
|
||||
*/
|
||||
readFlatCoordinatesFromNode_(node, objectStack) {
|
||||
return pushParseAndPop(null, this.GEOMETRY_FLAT_COORDINATES_PARSERS_, node, objectStack, this);
|
||||
return pushParseAndPop(null, this.GEOMETRY_FLAT_COORDINATES_PARSERS, node, objectStack, this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -469,6 +471,37 @@ class GMLBase extends XMLFeature {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
* @protected
|
||||
*/
|
||||
GMLBase.prototype.FLAT_LINEAR_RINGS_PARSERS = {
|
||||
'http://www.opengis.net/gml': {}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
* @protected
|
||||
*/
|
||||
GMLBase.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS = {
|
||||
'http://www.opengis.net/gml': {}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
* @protected
|
||||
*/
|
||||
GMLBase.prototype.GEOMETRY_PARSERS = {
|
||||
'http://www.opengis.net/gml': {}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
|
||||
|
||||
@@ -23,7 +23,7 @@ import {douglasPeuckerArray} from '../geom/flat/simplify.js';
|
||||
class MultiLineString extends SimpleGeometry {
|
||||
|
||||
/**
|
||||
* @param {Array<Array<import("../coordinate.js").Coordinate>|import("../geom.js").MultiLineString>|Array<number>} coordinates
|
||||
* @param {Array<Array<import("../coordinate.js").Coordinate>|LineString>|Array<number>} coordinates
|
||||
* Coordinates or LineString geometries. (For internal use, flat coordinates in
|
||||
* combination with `opt_layout` and `opt_ends` are also accepted.)
|
||||
* @param {GeometryLayout=} opt_layout Layout.
|
||||
@@ -58,7 +58,7 @@ class MultiLineString extends SimpleGeometry {
|
||||
this.ends_ = opt_ends;
|
||||
} else {
|
||||
let layout = this.getLayout();
|
||||
const lineStrings = /** @type {Array<import("../geom.js").MultiLineString>} */ (coordinates);
|
||||
const lineStrings = /** @type {Array<LineString>} */ (coordinates);
|
||||
const flatCoordinates = [];
|
||||
const ends = [];
|
||||
for (let i = 0, ii = lineStrings.length; i < ii; ++i) {
|
||||
|
||||
@@ -29,7 +29,7 @@ class MultiPolygon extends SimpleGeometry {
|
||||
|
||||
/**
|
||||
* @param {Array<Array<Array<import("../coordinate.js").Coordinate>>|Polygon>|Array<number>} coordinates Coordinates.
|
||||
* For internal use, flat coordinats in combination with `opt_layout` and `opt_endss` are also accepted.
|
||||
* For internal use, flat coordinates in combination with `opt_layout` and `opt_endss` are also accepted.
|
||||
* @param {GeometryLayout=} opt_layout Layout.
|
||||
* @param {Array<Array<number>>=} opt_endss Array of ends for internal use with flat coordinates.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user