This commit is contained in:
Amir Ashkan Baghdoust
2021-03-07 18:31:04 +01:00
481 changed files with 22380 additions and 6525 deletions
+21 -23
View File
@@ -78,7 +78,7 @@ GEOMETRY_WRITERS[GeometryType.MULTI_POLYGON] = writeMultiPolygonGeometry;
*/
class EsriJSON extends JSONFeature {
/**
* @param {Options=} opt_options Options.
* @param {Options} [opt_options] Options.
*/
constructor(opt_options) {
const options = opt_options ? opt_options : {};
@@ -95,8 +95,8 @@ class EsriJSON extends JSONFeature {
/**
* @param {Object} object Object.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {string=} opt_idField Name of the field where to get the id from.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @param {string} [opt_idField] Name of the field where to get the id from.
* @protected
* @return {import("../Feature.js").default} Feature.
*/
@@ -120,7 +120,7 @@ class EsriJSON extends JSONFeature {
/**
* @param {Object} object Object.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {Array<Feature>} Features.
*/
@@ -148,7 +148,7 @@ class EsriJSON extends JSONFeature {
/**
* @param {EsriJSONGeometry} object Object.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../geom/Geometry.js").default} Geometry.
*/
@@ -180,7 +180,7 @@ class EsriJSON extends JSONFeature {
* Encode a geometry as a EsriJSON object.
*
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {EsriJSONGeometry} Object.
* @api
*/
@@ -192,7 +192,7 @@ class EsriJSON extends JSONFeature {
* Encode a feature as a esriJSON Feature object.
*
* @param {import("../Feature.js").default} feature Feature.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {Object} Object.
* @api
*/
@@ -207,16 +207,14 @@ class EsriJSON extends JSONFeature {
const geometry = feature.getGeometry();
if (geometry) {
object['geometry'] = writeGeometry(geometry, opt_options);
if (opt_options && opt_options.featureProjection) {
const projection =
opt_options &&
(opt_options.dataProjection || opt_options.featureProjection);
if (projection) {
object['geometry'][
'spatialReference'
] = /** @type {EsriJSONSpatialReferenceWkid} */ ({
wkid: Number(
getProjection(opt_options.featureProjection)
.getCode()
.split(':')
.pop()
),
wkid: Number(getProjection(projection).getCode().split(':').pop()),
});
}
delete properties[feature.getGeometryName()];
@@ -233,7 +231,7 @@ class EsriJSON extends JSONFeature {
* Encode an array of features as a EsriJSON object.
*
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {EsriJSONFeatureSet} EsriJSON Object.
* @api
*/
@@ -251,7 +249,7 @@ class EsriJSON extends JSONFeature {
/**
* @param {EsriJSONGeometry} object Object.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../geom/Geometry.js").default} Geometry.
*/
function readGeometry(object, opt_options) {
@@ -431,7 +429,7 @@ function readPolygonGeometry(object) {
/**
* @param {import("../geom/Point.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {EsriJSONPoint} EsriJSON geometry.
*/
function writePointGeometry(geometry, opt_options) {
@@ -483,7 +481,7 @@ function getHasZM(geometry) {
/**
* @param {import("../geom/LineString.js").default} lineString Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {EsriJSONPolyline} EsriJSON geometry.
*/
function writeLineStringGeometry(lineString, opt_options) {
@@ -499,7 +497,7 @@ function writeLineStringGeometry(lineString, opt_options) {
/**
* @param {import("../geom/Polygon.js").default} polygon Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {EsriJSONPolygon} EsriJSON geometry.
*/
function writePolygonGeometry(polygon, opt_options) {
@@ -516,7 +514,7 @@ function writePolygonGeometry(polygon, opt_options) {
/**
* @param {import("../geom/MultiLineString.js").default} multiLineString Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {EsriJSONPolyline} EsriJSON geometry.
*/
function writeMultiLineStringGeometry(multiLineString, opt_options) {
@@ -530,7 +528,7 @@ function writeMultiLineStringGeometry(multiLineString, opt_options) {
/**
* @param {import("../geom/MultiPoint.js").default} multiPoint Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {EsriJSONMultipoint} EsriJSON geometry.
*/
function writeMultiPointGeometry(multiPoint, opt_options) {
@@ -544,7 +542,7 @@ function writeMultiPointGeometry(multiPoint, opt_options) {
/**
* @param {import("../geom/MultiPolygon.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {EsriJSONPolygon} EsriJSON geometry.
*/
function writeMultiPolygonGeometry(geometry, opt_options) {
@@ -565,7 +563,7 @@ function writeMultiPolygonGeometry(geometry, opt_options) {
/**
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {EsriJSONGeometry} EsriJSON geometry.
*/
function writeGeometry(geometry, opt_options) {
+14 -14
View File
@@ -67,21 +67,21 @@ class FeatureFormat {
constructor() {
/**
* @protected
* @type {import("../proj/Projection.js").default}
* @type {import("../proj/Projection.js").default|undefined}
*/
this.dataProjection = null;
this.dataProjection = undefined;
/**
* @protected
* @type {import("../proj/Projection.js").default}
* @type {import("../proj/Projection.js").default|undefined}
*/
this.defaultFeatureProjection = null;
this.defaultFeatureProjection = undefined;
}
/**
* Adds the data projection to the read options.
* @param {Document|Element|Object|string} source Source.
* @param {ReadOptions=} opt_options Options.
* @param {ReadOptions} [opt_options] Options.
* @return {ReadOptions|undefined} Options.
* @protected
*/
@@ -139,7 +139,7 @@ class FeatureFormat {
*
* @abstract
* @param {Document|Element|Object|string} source Source.
* @param {ReadOptions=} opt_options Read options.
* @param {ReadOptions} [opt_options] Read options.
* @return {import("../Feature.js").FeatureLike} Feature.
*/
readFeature(source, opt_options) {
@@ -151,7 +151,7 @@ class FeatureFormat {
*
* @abstract
* @param {Document|Element|ArrayBuffer|Object|string} source Source.
* @param {ReadOptions=} opt_options Read options.
* @param {ReadOptions} [opt_options] Read options.
* @return {Array<import("../Feature.js").FeatureLike>} Features.
*/
readFeatures(source, opt_options) {
@@ -163,7 +163,7 @@ class FeatureFormat {
*
* @abstract
* @param {Document|Element|Object|string} source Source.
* @param {ReadOptions=} opt_options Read options.
* @param {ReadOptions} [opt_options] Read options.
* @return {import("../geom/Geometry.js").default} Geometry.
*/
readGeometry(source, opt_options) {
@@ -175,7 +175,7 @@ class FeatureFormat {
*
* @abstract
* @param {Document|Element|Object|string} source Source.
* @return {import("../proj/Projection.js").default} Projection.
* @return {import("../proj/Projection.js").default|undefined} Projection.
*/
readProjection(source) {
return abstract();
@@ -186,7 +186,7 @@ class FeatureFormat {
*
* @abstract
* @param {import("../Feature.js").default} feature Feature.
* @param {WriteOptions=} opt_options Write options.
* @param {WriteOptions} [opt_options] Write options.
* @return {string} Result.
*/
writeFeature(feature, opt_options) {
@@ -198,7 +198,7 @@ class FeatureFormat {
*
* @abstract
* @param {Array<import("../Feature.js").default>} features Features.
* @param {WriteOptions=} opt_options Write options.
* @param {WriteOptions} [opt_options] Write options.
* @return {string} Result.
*/
writeFeatures(features, opt_options) {
@@ -210,7 +210,7 @@ class FeatureFormat {
*
* @abstract
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {WriteOptions=} opt_options Write options.
* @param {WriteOptions} [opt_options] Write options.
* @return {string} Result.
*/
writeGeometry(geometry, opt_options) {
@@ -223,7 +223,7 @@ export default FeatureFormat;
/**
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {boolean} write Set to true for writing, false for reading.
* @param {(WriteOptions|ReadOptions)=} opt_options Options.
* @param {WriteOptions|ReadOptions} [opt_options] Options.
* @return {import("../geom/Geometry.js").default} Transformed geometry.
*/
export function transformGeometryWithOptions(geometry, write, opt_options) {
@@ -277,7 +277,7 @@ export function transformGeometryWithOptions(geometry, write, opt_options) {
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {ReadOptions=} opt_options Read options.
* @param {ReadOptions} [opt_options] Read options.
* @return {import("../extent.js").Extent} Transformed extent.
*/
export function transformExtentWithOptions(extent, opt_options) {
+3 -3
View File
@@ -9,7 +9,7 @@ import GML3 from './GML3.js';
* version 3.1.1.
* Currently only supports GML 3.1.1 Simple Features profile.
*
* @param {import("./GMLBase.js").Options=} opt_options
* @param {import("./GMLBase.js").Options} [opt_options]
* Optional configuration object.
* @api
*/
@@ -20,7 +20,7 @@ const GML = GML3;
*
* @function
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions=} opt_options Options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
* @return {string} Result.
* @api
*/
@@ -31,7 +31,7 @@ GML.prototype.writeFeatures;
*
* @function
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions=} opt_options Options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
* @return {Node} Node.
* @api
*/
+7 -7
View File
@@ -49,7 +49,7 @@ const MULTIGEOMETRY_TO_MEMBER_NODENAME = {
*/
class GML2 extends GMLBase {
/**
* @param {import("./GMLBase.js").Options=} opt_options Optional configuration object.
* @param {import("./GMLBase.js").Options} [opt_options] Optional configuration object.
*/
constructor(opt_options) {
const options =
@@ -170,7 +170,7 @@ class GML2 extends GMLBase {
* @const
* @param {*} value Value.
* @param {Array<*>} objectStack Object stack.
* @param {string=} opt_nodeName Node name.
* @param {string} [opt_nodeName] Node name.
* @return {Element|undefined} Node.
* @private
*/
@@ -356,7 +356,7 @@ class GML2 extends GMLBase {
/**
* @param {string} namespaceURI XML namespace.
* @returns {Element} coordinates node.
* @return {Element} coordinates node.
* @private
*/
createCoordinatesNode_(namespaceURI) {
@@ -434,7 +434,7 @@ class GML2 extends GMLBase {
/**
* @param {*} value Value.
* @param {Array<*>} objectStack Object stack.
* @param {string=} opt_nodeName Node name.
* @param {string} [opt_nodeName] Node name.
* @return {Node} Node.
* @private
*/
@@ -476,8 +476,8 @@ class GML2 extends GMLBase {
/**
* @param {Array<number>} point Point geometry.
* @param {string=} opt_srsName Optional srsName
* @param {boolean=} opt_hasZ whether the geometry has a Z coordinate (is 3D) or not.
* @param {string} [opt_srsName] Optional srsName
* @param {boolean} [opt_hasZ] whether the geometry has a Z coordinate (is 3D) or not.
* @return {string} The coords string.
* @private
*/
@@ -636,7 +636,7 @@ class GML2 extends GMLBase {
* @const
* @param {*} value Value.
* @param {Array<*>} objectStack Object stack.
* @param {string=} opt_nodeName Node name.
* @param {string} [opt_nodeName] Node name.
* @return {Node|undefined} Node.
* @private
*/
+11 -9
View File
@@ -1,6 +1,7 @@
/**
* @module ol/format/GML3
*/
import GML2 from './GML2.js';
import GMLBase, {GMLNS} from './GMLBase.js';
import GeometryLayout from '../geom/GeometryLayout.js';
import LineString from '../geom/LineString.js';
@@ -61,7 +62,7 @@ const MULTIGEOMETRY_TO_MEMBER_NODENAME = {
*/
class GML3 extends GMLBase {
/**
* @param {import("./GMLBase.js").Options=} opt_options Optional configuration object.
* @param {import("./GMLBase.js").Options} [opt_options] Optional configuration object.
*/
constructor(opt_options) {
const options =
@@ -465,8 +466,8 @@ class GML3 extends GMLBase {
/**
* @param {Array<number>} point Point geometry.
* @param {string=} opt_srsName Optional srsName
* @param {boolean=} opt_hasZ whether the geometry has a Z coordinate (is 3D) or not.
* @param {string} [opt_srsName] Optional srsName
* @param {boolean} [opt_hasZ] whether the geometry has a Z coordinate (is 3D) or not.
* @return {string} The coords string.
* @private
*/
@@ -572,7 +573,7 @@ class GML3 extends GMLBase {
/**
* @param {*} value Value.
* @param {Array<*>} objectStack Object stack.
* @param {string=} opt_nodeName Node name.
* @param {string} [opt_nodeName] Node name.
* @return {Node} Node.
* @private
*/
@@ -919,7 +920,7 @@ class GML3 extends GMLBase {
* @const
* @param {*} value Value.
* @param {Array<*>} objectStack Object stack.
* @param {string=} opt_nodeName Node name.
* @param {string} [opt_nodeName] Node name.
* @return {Node|undefined} Node.
* @private
*/
@@ -935,7 +936,7 @@ class GML3 extends GMLBase {
* @const
* @param {*} value Value.
* @param {Array<*>} objectStack Object stack.
* @param {string=} opt_nodeName Node name.
* @param {string} [opt_nodeName] Node name.
* @return {Element|undefined} Node.
* @private
*/
@@ -967,7 +968,7 @@ class GML3 extends GMLBase {
* Encode a geometry in GML 3.1.1 Simple Features.
*
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
* @return {Node} Node.
* @api
*/
@@ -994,7 +995,7 @@ class GML3 extends GMLBase {
* Encode an array of features in the GML 3.1.1 format as an XML node.
*
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions=} opt_options Options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
* @return {Element} Node.
* @api
*/
@@ -1032,6 +1033,7 @@ GML3.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS = {
'http://www.opengis.net/gml': {
'pos': makeReplacer(GML3.prototype.readFlatPos),
'posList': makeReplacer(GML3.prototype.readFlatPosList),
'coordinates': makeReplacer(GML2.prototype.readFlatCoordinates),
},
};
@@ -1167,7 +1169,7 @@ GML3.prototype.SEGMENTS_PARSERS = {
*
* @function
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions=} opt_options Options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
* @return {string} Result.
* @api
*/
+3 -1
View File
@@ -1,6 +1,7 @@
/**
* @module ol/format/GML32
*/
import GML2 from './GML2.js';
import GML3 from './GML3.js';
import GMLBase from './GMLBase.js';
import {makeArrayPusher, makeChildAppender, makeReplacer} from '../xml.js';
@@ -13,7 +14,7 @@ import {writeStringTextNode} from '../format/xsd.js';
*/
class GML32 extends GML3 {
/**
* @param {import("./GMLBase.js").Options=} opt_options Optional configuration object.
* @param {import("./GMLBase.js").Options} [opt_options] Optional configuration object.
*/
constructor(opt_options) {
const options = /** @type {import("./GMLBase.js").Options} */ (opt_options
@@ -41,6 +42,7 @@ GML32.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS = {
'http://www.opengis.net/gml/3.2': {
'pos': makeReplacer(GML3.prototype.readFlatPos),
'posList': makeReplacer(GML3.prototype.readFlatPosList),
'coordinates': makeReplacer(GML2.prototype.readFlatCoordinates),
},
};
+9 -5
View File
@@ -93,7 +93,7 @@ const ONLY_WHITESPACE_RE = /^[\s\xa0]*$/;
*/
class GMLBase extends XMLFeature {
/**
* @param {Options=} opt_options Optional configuration object.
* @param {Options} [opt_options] Optional configuration object.
*/
constructor(opt_options) {
super();
@@ -150,7 +150,11 @@ class GMLBase extends XMLFeature {
objectStack,
this
);
} else if (localName == 'featureMembers' || localName == 'featureMember') {
} else if (
localName == 'featureMembers' ||
localName == 'featureMember' ||
localName == 'member'
) {
const context = objectStack[0];
let featureType = context['featureType'];
let featureNS = context['featureNS'];
@@ -214,7 +218,7 @@ class GMLBase extends XMLFeature {
}
parsersNS[featureNS[p]] = parsers;
}
if (localName == 'featureMember') {
if (localName == 'featureMember' || localName == 'member') {
features = pushParseAndPop(undefined, parsersNS, node, objectStack);
} else {
features = pushParseAndPop([], parsersNS, node, objectStack);
@@ -528,7 +532,7 @@ class GMLBase extends XMLFeature {
/**
* @param {Element} node Node.
* @param {import("./Feature.js").ReadOptions=} opt_options Options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
* @protected
* @return {import("../geom/Geometry.js").default|import("../extent.js").Extent} Geometry.
*/
@@ -542,7 +546,7 @@ class GMLBase extends XMLFeature {
/**
* @param {Element} node Node.
* @param {import("./Feature.js").ReadOptions=} opt_options Options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
* @return {Array<import("../Feature.js").default>} Features.
*/
readFeaturesFromNode(node, opt_options) {
+8 -8
View File
@@ -109,8 +109,8 @@ const GPX_SERIALIZERS = makeStructureNS(NAMESPACE_URIS, {
/**
* @typedef {Object} LayoutOptions
* @property {boolean} [hasZ]
* @property {boolean} [hasM]
* @property {boolean} [hasZ] HasZ.
* @property {boolean} [hasM] HasM.
*/
/**
@@ -131,7 +131,7 @@ const GPX_SERIALIZERS = makeStructureNS(NAMESPACE_URIS, {
*/
class GPX extends XMLFeature {
/**
* @param {Options=} opt_options Options.
* @param {Options} [opt_options] Options.
*/
constructor(opt_options) {
super();
@@ -170,7 +170,7 @@ class GPX extends XMLFeature {
/**
* @param {Element} node Node.
* @param {import("./Feature.js").ReadOptions=} opt_options Options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
* @return {import("../Feature.js").default} Feature.
*/
readFeatureFromNode(node, opt_options) {
@@ -193,7 +193,7 @@ class GPX extends XMLFeature {
/**
* @param {Element} node Node.
* @param {import("./Feature.js").ReadOptions=} opt_options Options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
* @return {Array<import("../Feature.js").default>} Features.
*/
readFeaturesFromNode(node, opt_options) {
@@ -221,7 +221,7 @@ class GPX extends XMLFeature {
* as tracks (`<trk>`).
*
* @param {Array<Feature>} features Features.
* @param {import("./Feature.js").WriteOptions=} opt_options Options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
* @return {Node} Node.
* @api
*/
@@ -508,7 +508,7 @@ const GEOMETRY_TYPE_TO_NODENAME = {
/**
* @param {*} value Value.
* @param {Array<*>} objectStack Object stack.
* @param {string=} opt_nodeName Node name.
* @param {string} [opt_nodeName] Node name.
* @return {Node|undefined} Node.
*/
function GPX_NODE_FACTORY(value, objectStack, opt_nodeName) {
@@ -557,7 +557,7 @@ function appendCoordinate(flatCoordinates, layoutOptions, node, values) {
*
* @param {LayoutOptions} layoutOptions Layout options.
* @param {Array<number>} flatCoordinates Flat coordinates.
* @param {Array<number>=} ends Ends.
* @param {Array<number>} [ends] Ends.
* @return {import("../geom/GeometryLayout.js").default} Layout.
*/
function applyLayoutOptions(layoutOptions, flatCoordinates, ends) {
+17 -17
View File
@@ -51,7 +51,7 @@ import {transformGeometryWithOptions} from './Feature.js';
*/
class GeoJSON extends JSONFeature {
/**
* @param {Options=} opt_options Options.
* @param {Options} [opt_options] Options.
*/
constructor(opt_options) {
const options = opt_options ? opt_options : {};
@@ -86,7 +86,7 @@ class GeoJSON extends JSONFeature {
/**
* @param {Object} object Object.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../Feature.js").default} Feature.
*/
@@ -129,7 +129,7 @@ class GeoJSON extends JSONFeature {
/**
* @param {Object} object Object.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {Array<Feature>} Features.
*/
@@ -154,7 +154,7 @@ class GeoJSON extends JSONFeature {
/**
* @param {GeoJSONGeometry} object Object.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../geom/Geometry.js").default} Geometry.
*/
@@ -188,7 +188,7 @@ class GeoJSON extends JSONFeature {
* Encode a feature as a GeoJSON Feature object.
*
* @param {import("../Feature.js").default} feature Feature.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONFeature} Object.
* @api
*/
@@ -230,7 +230,7 @@ class GeoJSON extends JSONFeature {
* Encode an array of features as a GeoJSON object.
*
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONFeatureCollection} GeoJSON Object.
* @api
*/
@@ -250,7 +250,7 @@ class GeoJSON extends JSONFeature {
* Encode a geometry as a GeoJSON object.
*
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONGeometry|GeoJSONGeometryCollection} Object.
* @api
*/
@@ -261,7 +261,7 @@ class GeoJSON extends JSONFeature {
/**
* @param {GeoJSONGeometry|GeoJSONGeometryCollection} object Object.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../geom/Geometry.js").default} Geometry.
*/
function readGeometry(object, opt_options) {
@@ -321,7 +321,7 @@ function readGeometry(object, opt_options) {
/**
* @param {GeoJSONGeometryCollection} object Object.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {GeometryCollection} Geometry collection.
*/
function readGeometryCollectionGeometry(object, opt_options) {
@@ -387,7 +387,7 @@ function readPolygonGeometry(object) {
/**
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONGeometry} GeoJSON geometry.
*/
function writeGeometry(geometry, opt_options) {
@@ -462,7 +462,7 @@ function writeGeometry(geometry, opt_options) {
/**
* @param {GeometryCollection} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONGeometryCollection} GeoJSON geometry collection.
*/
function writeGeometryCollectionGeometry(geometry, opt_options) {
@@ -479,7 +479,7 @@ function writeGeometryCollectionGeometry(geometry, opt_options) {
/**
* @param {LineString} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONGeometry} GeoJSON geometry.
*/
function writeLineStringGeometry(geometry, opt_options) {
@@ -491,7 +491,7 @@ function writeLineStringGeometry(geometry, opt_options) {
/**
* @param {MultiLineString} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONGeometry} GeoJSON geometry.
*/
function writeMultiLineStringGeometry(geometry, opt_options) {
@@ -503,7 +503,7 @@ function writeMultiLineStringGeometry(geometry, opt_options) {
/**
* @param {MultiPoint} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONGeometry} GeoJSON geometry.
*/
function writeMultiPointGeometry(geometry, opt_options) {
@@ -515,7 +515,7 @@ function writeMultiPointGeometry(geometry, opt_options) {
/**
* @param {MultiPolygon} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONGeometry} GeoJSON geometry.
*/
function writeMultiPolygonGeometry(geometry, opt_options) {
@@ -531,7 +531,7 @@ function writeMultiPolygonGeometry(geometry, opt_options) {
/**
* @param {Point} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONGeometry} GeoJSON geometry.
*/
function writePointGeometry(geometry, opt_options) {
@@ -543,7 +543,7 @@ function writePointGeometry(geometry, opt_options) {
/**
* @param {Polygon} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONGeometry} GeoJSON geometry.
*/
function writePolygonGeometry(geometry, opt_options) {
+3 -3
View File
@@ -62,7 +62,7 @@ const NEWLINE_RE = /\r\n|\r|\n/;
*/
class IGC extends TextFeature {
/**
* @param {Options=} opt_options Options.
* @param {Options} [opt_options] Options.
*/
constructor(opt_options) {
super();
@@ -86,7 +86,7 @@ class IGC extends TextFeature {
/**
* @protected
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../Feature.js").default} Feature.
*/
readFeatureFromText(text, opt_options) {
@@ -166,7 +166,7 @@ class IGC extends TextFeature {
/**
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {Array<Feature>} Features.
*/
+12 -11
View File
@@ -3,6 +3,7 @@
*/
import {assert} from '../asserts.js';
import {includes} from '../array.js';
/**
* @typedef {Object} PreferredOptions
@@ -245,10 +246,10 @@ function generateVersion3Options(iiifInfo) {
iiifInfo.imageInfo.preferredFormats.length > 0
? iiifInfo.imageInfo.preferredFormats
.filter(function (format) {
return ['jpg', 'png', 'gif'].includes(format);
return includes(['jpg', 'png', 'gif'], format);
})
.reduce(function (acc, format) {
return acc === undefined && formats.includes(format)
return acc === undefined && includes(formats, format)
? format
: acc;
}, undefined)
@@ -326,7 +327,7 @@ class IIIFInfo {
}
/**
* @returns {Versions} Major IIIF version.
* @return {Versions} Major IIIF version.
* @api
*/
getImageApiVersion() {
@@ -363,7 +364,7 @@ class IIIFInfo {
/**
* @param {Versions} version Optional IIIF image API version
* @returns {string} Compliance level as it appears in the IIIF image information
* @return {string} Compliance level as it appears in the IIIF image information
* response.
*/
getComplianceLevelEntryFromProfile(version) {
@@ -406,7 +407,7 @@ class IIIFInfo {
/**
* @param {Versions} version Optional IIIF image API version
* @returns {string} Compliance level, on of 'level0', 'level1' or 'level2' or undefined
* @return {string} Compliance level, on of 'level0', 'level1' or 'level2' or undefined
*/
getComplianceLevelFromProfile(version) {
const complianceLevel = this.getComplianceLevelEntryFromProfile(version);
@@ -418,7 +419,7 @@ class IIIFInfo {
}
/**
* @returns {SupportedFeatures} Image formats, qualities and region / size calculation
* @return {SupportedFeatures} Image formats, qualities and region / size calculation
* methods that are supported by the IIIF service.
*/
getComplianceLevelSupportedFeatures() {
@@ -434,8 +435,8 @@ class IIIFInfo {
}
/**
* @param {PreferredOptions=} opt_preferredOptions Optional options for preferred format and quality.
* @returns {import("../source/IIIF.js").Options} IIIF tile source ready constructor options.
* @param {PreferredOptions} [opt_preferredOptions] Optional options for preferred format and quality.
* @return {import("../source/IIIF.js").Options} IIIF tile source ready constructor options.
* @api
*/
getTileSourceOptions(opt_preferredOptions) {
@@ -456,16 +457,16 @@ class IIIFInfo {
sizes: imageOptions.sizes,
format:
options.format !== undefined &&
imageOptions.formats.includes(options.format)
includes(imageOptions.formats, options.format)
? options.format
: imageOptions.preferredFormat !== undefined
? imageOptions.preferredFormat
: 'jpg',
supports: imageOptions.supports,
quality:
options.quality && imageOptions.qualities.includes(options.quality)
options.quality && includes(imageOptions.qualities, options.quality)
? options.quality
: imageOptions.qualities.includes('native')
: includes(imageOptions.qualities, 'native')
? 'native'
: 'default',
resolutions: Array.isArray(imageOptions.resolutions)
+12 -12
View File
@@ -30,7 +30,7 @@ class JSONFeature extends FeatureFormat {
* read a feature collection.
*
* @param {ArrayBuffer|Document|Element|Object|string} source Source.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../Feature.js").default} Feature.
* @api
*/
@@ -46,7 +46,7 @@ class JSONFeature extends FeatureFormat {
* collection.
*
* @param {ArrayBuffer|Document|Element|Object|string} source Source.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {Array<import("../Feature.js").default>} Features.
* @api
*/
@@ -60,7 +60,7 @@ class JSONFeature extends FeatureFormat {
/**
* @abstract
* @param {Object} object Object.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../Feature.js").default} Feature.
*/
@@ -71,7 +71,7 @@ class JSONFeature extends FeatureFormat {
/**
* @abstract
* @param {Object} object Object.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {Array<import("../Feature.js").default>} Features.
*/
@@ -83,7 +83,7 @@ class JSONFeature extends FeatureFormat {
* Read a geometry.
*
* @param {ArrayBuffer|Document|Element|Object|string} source Source.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../geom/Geometry.js").default} Geometry.
* @api
*/
@@ -97,7 +97,7 @@ class JSONFeature extends FeatureFormat {
/**
* @abstract
* @param {Object} object Object.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../geom/Geometry.js").default} Geometry.
*/
@@ -130,7 +130,7 @@ class JSONFeature extends FeatureFormat {
* Encode a feature as string.
*
* @param {import("../Feature.js").default} feature Feature.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string} Encoded feature.
* @api
*/
@@ -141,7 +141,7 @@ class JSONFeature extends FeatureFormat {
/**
* @abstract
* @param {import("../Feature.js").default} feature Feature.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {Object} Object.
*/
writeFeatureObject(feature, opt_options) {
@@ -152,7 +152,7 @@ class JSONFeature extends FeatureFormat {
* Encode an array of features as string.
*
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string} Encoded features.
* @api
*/
@@ -163,7 +163,7 @@ class JSONFeature extends FeatureFormat {
/**
* @abstract
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {Object} Object.
*/
writeFeaturesObject(features, opt_options) {
@@ -174,7 +174,7 @@ class JSONFeature extends FeatureFormat {
* Encode a geometry as string.
*
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string} Encoded geometry.
* @api
*/
@@ -185,7 +185,7 @@ class JSONFeature extends FeatureFormat {
/**
* @abstract
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {Object} Object.
*/
writeGeometryObject(geometry, opt_options) {
+68 -24
View File
@@ -56,17 +56,17 @@ import {transformGeometryWithOptions} from './Feature.js';
/**
* @typedef {Object} Vec2
* @property {number} x
* @property {import("../style/IconAnchorUnits").default} xunits
* @property {number} y
* @property {import("../style/IconAnchorUnits").default} yunits
* @property {import("../style/IconOrigin.js").default} origin
* @property {number} x X coordinate.
* @property {import("../style/IconAnchorUnits").default} xunits Units of x.
* @property {number} y Y coordinate.
* @property {import("../style/IconAnchorUnits").default} yunits Units of Y.
* @property {import("../style/IconOrigin.js").default} origin Origin.
*/
/**
* @typedef {Object} GxTrackObject
* @property {Array<number>} flatCoordinates
* @property {Array<number>} whens
* @property {Array<number>} flatCoordinates Flat coordinates.
* @property {Array<number>} whens Whens.
*/
/**
@@ -126,7 +126,7 @@ const PLACEMARK_PARSERS = makeStructureNS(
'name': makeObjectPropertySetter(readString),
'open': makeObjectPropertySetter(readBoolean),
'phoneNumber': makeObjectPropertySetter(readString),
'styleUrl': makeObjectPropertySetter(readURI),
'styleUrl': makeObjectPropertySetter(readStyleURL),
'visibility': makeObjectPropertySetter(readBoolean),
},
makeStructureNS(GX_NAMESPACE_URIS, {
@@ -378,6 +378,24 @@ function createStyleDefaults() {
*/
let TEXTAREA;
/**
* A function that takes a url `{string}` and returns a url `{string}`.
* Might be used to change an icon path or to substitute a
* data url obtained from a KMZ array buffer.
*
* @typedef {function(string):string} IconUrlFunction
* @api
*/
/**
* Function that returns a url unchanged.
* @param {string} href Input url.
* @return {string} Output url.
*/
function defaultIconUrlFunction(href) {
return href;
}
/**
* @typedef {Object} Options
* @property {boolean} [extractStyles=true] Extract styles from the KML.
@@ -387,6 +405,8 @@ let TEXTAREA;
* @property {boolean} [writeStyles=true] Write styles into KML.
* @property {null|string} [crossOrigin='anonymous'] The `crossOrigin` attribute for loaded images. Note that you must provide a
* `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* @property {IconUrlFunction} [iconUrlFunction] Function that takes a url string and returns a url string.
* Might be used to change an icon path or to substitute a data url obtained from a KMZ array buffer.
*/
/**
@@ -407,7 +427,7 @@ let TEXTAREA;
*/
class KML extends XMLFeature {
/**
* @param {Options=} opt_options Options.
* @param {Options} [opt_options] Options.
*/
constructor(opt_options) {
super();
@@ -462,6 +482,13 @@ class KML extends XMLFeature {
*/
this.crossOrigin_ =
options.crossOrigin !== undefined ? options.crossOrigin : 'anonymous';
/**
* @type {IconUrlFunction}
*/
this.iconUrlFunction_ = options.iconUrlFunction
? options.iconUrlFunction
: defaultIconUrlFunction;
}
/**
@@ -597,7 +624,7 @@ class KML extends XMLFeature {
/**
* @param {Element} node Node.
* @param {import("./Feature.js").ReadOptions=} opt_options Options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
* @return {import("../Feature.js").default} Feature.
*/
readFeatureFromNode(node, opt_options) {
@@ -617,7 +644,7 @@ class KML extends XMLFeature {
/**
* @protected
* @param {Element} node Node.
* @param {import("./Feature.js").ReadOptions=} opt_options Options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
* @return {Array<import("../Feature.js").default>} Features.
*/
readFeaturesFromNode(node, opt_options) {
@@ -859,7 +886,7 @@ class KML extends XMLFeature {
* MultiPoints, MultiLineStrings, and MultiPolygons are output as MultiGeometries.
*
* @param {Array<Feature>} features Features.
* @param {import("./Feature.js").WriteOptions=} opt_options Options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
* @return {Node} Node.
* @api
*/
@@ -1047,12 +1074,6 @@ function findStyle(styleValue, defaultStyle, sharedStyles) {
if (Array.isArray(styleValue)) {
return styleValue;
} else if (typeof styleValue === 'string') {
// KML files in the wild occasionally forget the leading `#` on styleUrls
// defined in the same document. Add a leading `#` if it enables to find
// a style.
if (!(styleValue in sharedStyles) && '#' + styleValue in sharedStyles) {
styleValue = '#' + styleValue;
}
return findStyle(sharedStyles[styleValue], defaultStyle, sharedStyles);
} else {
return defaultStyle;
@@ -1090,7 +1111,8 @@ export function readFlatCoordinates(node) {
const flatCoordinates = [];
// The KML specification states that coordinate tuples should not include
// spaces, but we tolerate them.
const re = /^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*,\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)(?:\s*,\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?))?\s*/i;
s = s.replace(/\s*,\s*/g, ',');
const re = /^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?),([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)(?:\s+|,|$)(?:([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)(?:\s+|$))?\s*/i;
let m;
while ((m = re.exec(s))) {
const x = parseFloat(m[1]);
@@ -1123,6 +1145,28 @@ function readURI(node) {
}
}
/**
* @param {Node} node Node.
* @return {string} URI.
*/
function readStyleURL(node) {
// KML files in the wild occasionally forget the leading
// `#` on styleUrlsdefined in the same document.
const s = getAllTextContent(node, false)
.trim()
.replace(/^(?!.*#)/, '#');
let baseURI = node.baseURI;
if (!baseURI || baseURI == 'about:blank') {
baseURI = window.location.href;
}
if (baseURI) {
const url = new URL(s, baseURI);
return url.href;
} else {
return s;
}
}
/**
* @param {Element} node Node.
* @return {Vec2} Vec2.
@@ -1282,7 +1326,7 @@ function iconStyleParser(node, objectStack) {
rotation: rotation,
scale: scale,
size: size,
src: src,
src: this.iconUrlFunction_(src),
color: color,
});
styleObject['imageStyle'] = imageStyle;
@@ -1993,7 +2037,7 @@ function regionParser(node, objectStack) {
const PAIR_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Style': makeObjectPropertySetter(readStyle),
'key': makeObjectPropertySetter(readString),
'styleUrl': makeObjectPropertySetter(readURI),
'styleUrl': makeObjectPropertySetter(readStyleURL),
});
/**
@@ -2359,7 +2403,7 @@ const DOCUMENT_SERIALIZERS = makeStructureNS(NAMESPACE_URIS, {
* @const
* @param {*} value Value.
* @param {Array<*>} objectStack Object stack.
* @param {string=} opt_nodeName Node name.
* @param {string} [opt_nodeName] Node name.
* @return {Node|undefined} Node.
*/
const DOCUMENT_NODE_FACTORY = function (value, objectStack, opt_nodeName) {
@@ -2448,7 +2492,7 @@ const ICON_SERIALIZERS = makeStructureNS(
* @const
* @param {*} value Value.
* @param {Array<*>} objectStack Object stack.
* @param {string=} opt_nodeName Node name.
* @param {string} [opt_nodeName] Node name.
* @return {Node|undefined} Node.
*/
const GX_NODE_FACTORY = function (value, objectStack, opt_nodeName) {
@@ -2687,7 +2731,7 @@ const GEOMETRY_TYPE_TO_NODENAME = {
* @const
* @param {*} value Value.
* @param {Array<*>} objectStack Object stack.
* @param {string=} opt_nodeName Node name.
* @param {string} [opt_nodeName] Node name.
* @return {Node|undefined} Node.
*/
const GEOMETRY_NODE_FACTORY = function (value, objectStack, opt_nodeName) {
+4 -4
View File
@@ -38,12 +38,12 @@ import {linearRingIsClockwise} from '../geom/flat/orient.js';
* @classdesc
* Feature format for reading data in the Mapbox MVT format.
*
* @param {Options=} opt_options Options.
* @param {Options} [opt_options] Options.
* @api
*/
class MVT extends FeatureFormat {
/**
* @param {Options=} opt_options Options.
* @param {Options} [opt_options] Options.
*/
constructor(opt_options) {
super();
@@ -194,7 +194,7 @@ class MVT extends FeatureFormat {
values,
id
);
feature.transform(options.dataProjection, options.featureProjection);
feature.transform(options.dataProjection);
} else {
let geom;
if (geometryType == GeometryType.POLYGON) {
@@ -260,7 +260,7 @@ class MVT extends FeatureFormat {
* Read all features.
*
* @param {ArrayBuffer} source Source.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {Array<import("../Feature.js").FeatureLike>} Features.
* @api
*/
+2 -2
View File
@@ -43,7 +43,7 @@ const PARSERS = makeStructureNS(NAMESPACE_URIS, {
/**
* @classdesc
* Feature format for reading data in the
* [OSMXML format](http://wiki.openstreetmap.org/wiki/OSM_XML).
* [OSMXML format](https://wiki.openstreetmap.org/wiki/OSM_XML).
*
* @api
*/
@@ -60,7 +60,7 @@ class OSMXML extends XMLFeature {
/**
* @protected
* @param {Element} node Node.
* @param {import("./Feature.js").ReadOptions=} opt_options Options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
* @return {Array<import("../Feature.js").default>} Features.
*/
readFeaturesFromNode(node, opt_options) {
+11 -11
View File
@@ -35,7 +35,7 @@ import {transformGeometryWithOptions} from './Feature.js';
*/
class Polyline extends TextFeature {
/**
* @param {Options=} opt_options Optional configuration object.
* @param {Options} [opt_options] Optional configuration object.
*/
constructor(opt_options) {
super();
@@ -65,7 +65,7 @@ class Polyline extends TextFeature {
/**
* @protected
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../Feature.js").default} Feature.
*/
readFeatureFromText(text, opt_options) {
@@ -75,7 +75,7 @@ class Polyline extends TextFeature {
/**
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {Array<Feature>} Features.
*/
@@ -86,7 +86,7 @@ class Polyline extends TextFeature {
/**
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../geom/Geometry.js").default} Geometry.
*/
@@ -111,7 +111,7 @@ class Polyline extends TextFeature {
/**
* @param {import("../Feature.js").default} feature Features.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
@@ -127,7 +127,7 @@ class Polyline extends TextFeature {
/**
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
@@ -137,7 +137,7 @@ class Polyline extends TextFeature {
/**
* @param {LineString} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
@@ -163,7 +163,7 @@ class Polyline extends TextFeature {
*
* @param {Array<number>} numbers A list of n-dimensional points.
* @param {number} stride The number of dimension of the points in the list.
* @param {number=} opt_factor The factor by which the numbers will be
* @param {number} [opt_factor] The factor by which the numbers will be
* multiplied. The remaining decimal places will get rounded away.
* Default is `1e5`.
* @return {string} The encoded string.
@@ -197,7 +197,7 @@ export function encodeDeltas(numbers, stride, opt_factor) {
* @param {string} encoded An encoded string.
* @param {number} stride The number of dimension of the points in the
* encoded string.
* @param {number=} opt_factor The factor by which the resulting numbers will
* @param {number} [opt_factor] The factor by which the resulting numbers will
* be divided. Default is `1e5`.
* @return {Array<number>} A list of n-dimensional points.
* @api
@@ -231,7 +231,7 @@ export function decodeDeltas(encoded, stride, opt_factor) {
* Attention: This function will modify the passed array!
*
* @param {Array<number>} numbers A list of floating point numbers.
* @param {number=} opt_factor The factor by which the numbers will be
* @param {number} [opt_factor] The factor by which the numbers will be
* multiplied. The remaining decimal places will get rounded away.
* Default is `1e5`.
* @return {string} The encoded string.
@@ -250,7 +250,7 @@ export function encodeFloats(numbers, opt_factor) {
* Decode a list of floating point numbers from an encoded string
*
* @param {string} encoded An encoded string.
* @param {number=} opt_factor The factor by which the result will be divided.
* @param {number} [opt_factor] The factor by which the result will be divided.
* Default is `1e5`.
* @return {Array<number>} A list of floating point numbers.
* @api
+14 -14
View File
@@ -29,7 +29,7 @@ class TextFeature extends FeatureFormat {
* Read the feature from the source.
*
* @param {Document|Element|Object|string} source Source.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../Feature.js").default} Feature.
* @api
*/
@@ -43,7 +43,7 @@ class TextFeature extends FeatureFormat {
/**
* @abstract
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../Feature.js").default} Feature.
*/
@@ -55,7 +55,7 @@ class TextFeature extends FeatureFormat {
* Read the features from the source.
*
* @param {Document|Element|Object|string} source Source.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {Array<import("../Feature.js").default>} Features.
* @api
*/
@@ -69,7 +69,7 @@ class TextFeature extends FeatureFormat {
/**
* @abstract
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {Array<import("../Feature.js").default>} Features.
*/
@@ -81,7 +81,7 @@ class TextFeature extends FeatureFormat {
* Read the geometry from the source.
*
* @param {Document|Element|Object|string} source Source.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../geom/Geometry.js").default} Geometry.
* @api
*/
@@ -95,7 +95,7 @@ class TextFeature extends FeatureFormat {
/**
* @abstract
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../geom/Geometry.js").default} Geometry.
*/
@@ -107,7 +107,7 @@ class TextFeature extends FeatureFormat {
* Read the projection from the source.
*
* @param {Document|Element|Object|string} source Source.
* @return {import("../proj/Projection.js").default} Projection.
* @return {import("../proj/Projection.js").default|undefined} Projection.
* @api
*/
readProjection(source) {
@@ -117,7 +117,7 @@ class TextFeature extends FeatureFormat {
/**
* @param {string} text Text.
* @protected
* @return {import("../proj/Projection.js").default} Projection.
* @return {import("../proj/Projection.js").default|undefined} Projection.
*/
readProjectionFromText(text) {
return this.dataProjection;
@@ -127,7 +127,7 @@ class TextFeature extends FeatureFormat {
* Encode a feature as a string.
*
* @param {import("../Feature.js").default} feature Feature.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string} Encoded feature.
* @api
*/
@@ -138,7 +138,7 @@ class TextFeature extends FeatureFormat {
/**
* @abstract
* @param {import("../Feature.js").default} feature Features.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
@@ -150,7 +150,7 @@ class TextFeature extends FeatureFormat {
* Encode an array of features as string.
*
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string} Encoded features.
* @api
*/
@@ -161,7 +161,7 @@ class TextFeature extends FeatureFormat {
/**
* @abstract
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
@@ -173,7 +173,7 @@ class TextFeature extends FeatureFormat {
* Write a single geometry.
*
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string} Geometry.
* @api
*/
@@ -184,7 +184,7 @@ class TextFeature extends FeatureFormat {
/**
* @abstract
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
+14 -14
View File
@@ -56,7 +56,7 @@ import {transformGeometryWithOptions} from './Feature.js';
*/
class TopoJSON extends JSONFeature {
/**
* @param {Options=} opt_options Options.
* @param {Options} [opt_options] Options.
*/
constructor(opt_options) {
super();
@@ -85,7 +85,7 @@ class TopoJSON extends JSONFeature {
/**
* @param {Object} object Object.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {Array<Feature>} Features.
*/
@@ -318,7 +318,7 @@ function readMultiPolygonGeometry(object, arcs) {
* @param {string|undefined} property Property to set the `GeometryCollection`'s parent
* object to.
* @param {string} name Name of the `Topology`'s child object.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {Array<Feature>} Array of features.
*/
function readFeaturesFromGeometryCollection(
@@ -356,7 +356,7 @@ function readFeaturesFromGeometryCollection(
* @param {string|undefined} property Property to set the `GeometryCollection`'s parent
* object to.
* @param {string} name Name of the `Topology`'s child object.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {Feature} Feature.
*/
function readFeatureFromGeometry(
@@ -368,18 +368,18 @@ function readFeatureFromGeometry(
name,
opt_options
) {
let geometry;
let geometry = null;
const type = object.type;
const geometryReader = GEOMETRY_READERS[type];
if (type === 'Point' || type === 'MultiPoint') {
geometry = geometryReader(object, scale, translate);
} else {
geometry = geometryReader(object, arcs);
if (type) {
const geometryReader = GEOMETRY_READERS[type];
if (type === 'Point' || type === 'MultiPoint') {
geometry = geometryReader(object, scale, translate);
} else {
geometry = geometryReader(object, arcs);
}
geometry = transformGeometryWithOptions(geometry, false, opt_options);
}
const feature = new Feature();
feature.setGeometry(
transformGeometryWithOptions(geometry, false, opt_options)
);
const feature = new Feature({geometry: geometry});
if (object.id !== undefined) {
feature.setId(object.id);
}
+421 -218
View File
File diff suppressed because it is too large Load Diff
+74 -88
View File
@@ -35,9 +35,9 @@ const GeometryConstructor = {
/**
* @typedef {Object} Token
* @property {number} type
* @property {number|string} [value]
* @property {number} position
* @property {number} type Type.
* @property {number|string} [value] Value.
* @property {number} position Position.
*/
/**
@@ -69,6 +69,7 @@ const ZM = 'ZM';
* @enum {number}
*/
const TokenType = {
START: 0,
TEXT: 1,
LEFT_PAREN: 2,
RIGHT_PAREN: 3,
@@ -117,7 +118,7 @@ class Lexer {
/**
* @param {string} c Character.
* @param {boolean=} opt_decimal Whether the string number
* @param {boolean} [opt_decimal] Whether the string number
* contains a dot, i.e. is a decimal number.
* @return {boolean} Whether the character is numeric.
* @private
@@ -146,7 +147,7 @@ class Lexer {
/**
* Fetch and return the next token.
* @return {!Token} Next string token.
* @return {Token} Next string token.
*/
nextToken() {
const c = this.nextChar_();
@@ -238,7 +239,10 @@ class Parser {
* @type {Token}
* @private
*/
this.token_;
this.token_ = {
position: 0,
type: TokenType.START,
};
/**
* @type {import("../geom/GeometryLayout.js").default}
@@ -261,8 +265,7 @@ class Parser {
* @return {boolean} Whether the token matches the given type.
*/
isTokenType(type) {
const isMatch = this.token_.type == type;
return isMatch;
return this.token_.type == type;
}
/**
@@ -284,8 +287,7 @@ class Parser {
*/
parse() {
this.consume_();
const geometry = this.parseGeometry_();
return geometry;
return this.parseGeometry_();
}
/**
@@ -313,7 +315,7 @@ class Parser {
}
/**
* @return {!Array<import("../geom/Geometry.js").default>} A collection of geometries.
* @return {Array<import("../geom/Geometry.js").default>} A collection of geometries.
* @private
*/
parseGeometryCollectionText_() {
@@ -325,8 +327,6 @@ class Parser {
if (this.match(TokenType.RIGHT_PAREN)) {
return geometries;
}
} else if (this.isEmptyGeometry_()) {
return [];
}
throw new Error(this.formatErrorMessage_());
}
@@ -341,14 +341,12 @@ class Parser {
if (this.match(TokenType.RIGHT_PAREN)) {
return coordinates;
}
} else if (this.isEmptyGeometry_()) {
return null;
}
throw new Error(this.formatErrorMessage_());
}
/**
* @return {!Array<!Array<number>>} All points in a linestring.
* @return {Array<Array<number>>} All points in a linestring.
* @private
*/
parseLineStringText_() {
@@ -357,14 +355,12 @@ class Parser {
if (this.match(TokenType.RIGHT_PAREN)) {
return coordinates;
}
} else if (this.isEmptyGeometry_()) {
return [];
}
throw new Error(this.formatErrorMessage_());
}
/**
* @return {!Array<!Array<!Array<number>>>} All points in a polygon.
* @return {Array<Array<Array<number>>>} All points in a polygon.
* @private
*/
parsePolygonText_() {
@@ -373,14 +369,12 @@ class Parser {
if (this.match(TokenType.RIGHT_PAREN)) {
return coordinates;
}
} else if (this.isEmptyGeometry_()) {
return [];
}
throw new Error(this.formatErrorMessage_());
}
/**
* @return {!Array<!Array<number>>} All points in a multipoint.
* @return {Array<Array<number>>} All points in a multipoint.
* @private
*/
parseMultiPointText_() {
@@ -394,14 +388,12 @@ class Parser {
if (this.match(TokenType.RIGHT_PAREN)) {
return coordinates;
}
} else if (this.isEmptyGeometry_()) {
return [];
}
throw new Error(this.formatErrorMessage_());
}
/**
* @return {!Array<!Array<!Array<number>>>} All linestring points
* @return {Array<Array<Array<number>>>} All linestring points
* in a multilinestring.
* @private
*/
@@ -411,14 +403,12 @@ class Parser {
if (this.match(TokenType.RIGHT_PAREN)) {
return coordinates;
}
} else if (this.isEmptyGeometry_()) {
return [];
}
throw new Error(this.formatErrorMessage_());
}
/**
* @return {!Array<!Array<!Array<!Array<number>>>>} All polygon points in a multipolygon.
* @return {Array<Array<Array<Array<number>>>>} All polygon points in a multipolygon.
* @private
*/
parseMultiPolygonText_() {
@@ -427,14 +417,12 @@ class Parser {
if (this.match(TokenType.RIGHT_PAREN)) {
return coordinates;
}
} else if (this.isEmptyGeometry_()) {
return [];
}
throw new Error(this.formatErrorMessage_());
}
/**
* @return {!Array<number>} A point.
* @return {Array<number>} A point.
* @private
*/
parsePoint_() {
@@ -455,7 +443,7 @@ class Parser {
}
/**
* @return {!Array<!Array<number>>} An array of points.
* @return {Array<Array<number>>} An array of points.
* @private
*/
parsePointList_() {
@@ -467,7 +455,7 @@ class Parser {
}
/**
* @return {!Array<!Array<number>>} An array of points.
* @return {Array<Array<number>>} An array of points.
* @private
*/
parsePointTextList_() {
@@ -479,7 +467,7 @@ class Parser {
}
/**
* @return {!Array<!Array<!Array<number>>>} An array of points.
* @return {Array<Array<Array<number>>>} An array of points.
* @private
*/
parseLineStringTextList_() {
@@ -491,7 +479,7 @@ class Parser {
}
/**
* @return {!Array<!Array<!Array<!Array<number>>>>} An array of points.
* @return {Array<Array<Array<Array<number>>>>} An array of points.
* @private
*/
parsePolygonTextList_() {
@@ -533,15 +521,19 @@ class Parser {
}
/**
* @return {!import("../geom/Geometry.js").default} The geometry.
* @return {import("../geom/Geometry.js").default} The geometry.
* @private
*/
parseGeometry_() {
const token = this.token_;
if (this.match(TokenType.TEXT)) {
const geomType = token.value;
const geomType = /** @type {string} */ (token.value);
this.layout_ = this.parseGeometryLayout_();
const isEmpty = this.isEmptyGeometry_();
if (geomType == 'GEOMETRYCOLLECTION') {
if (isEmpty) {
return new GeometryCollection([]);
}
const geometries = this.parseGeometryCollectionText_();
return new GeometryCollection(geometries);
} else {
@@ -551,43 +543,44 @@ class Parser {
}
let coordinates;
switch (geomType) {
case 'POINT': {
coordinates = this.parsePointText_();
break;
}
case 'LINESTRING': {
coordinates = this.parseLineStringText_();
break;
}
case 'POLYGON': {
coordinates = this.parsePolygonText_();
break;
}
case 'MULTIPOINT': {
coordinates = this.parseMultiPointText_();
break;
}
case 'MULTILINESTRING': {
coordinates = this.parseMultiLineStringText_();
break;
}
case 'MULTIPOLYGON': {
coordinates = this.parseMultiPolygonText_();
break;
}
default: {
throw new Error('Invalid geometry type: ' + geomType);
}
}
if (!coordinates) {
if (ctor === GeometryConstructor['POINT']) {
if (isEmpty) {
if (geomType == 'POINT') {
coordinates = [NaN, NaN];
} else {
coordinates = [];
}
} else {
switch (geomType) {
case 'POINT': {
coordinates = this.parsePointText_();
break;
}
case 'LINESTRING': {
coordinates = this.parseLineStringText_();
break;
}
case 'POLYGON': {
coordinates = this.parsePolygonText_();
break;
}
case 'MULTIPOINT': {
coordinates = this.parseMultiPointText_();
break;
}
case 'MULTILINESTRING': {
coordinates = this.parseMultiLineStringText_();
break;
}
case 'MULTIPOLYGON': {
coordinates = this.parseMultiPolygonText_();
break;
}
default:
break;
}
}
return new ctor(coordinates, this.layout_);
}
}
@@ -604,7 +597,7 @@ class Parser {
*/
class WKT extends TextFeature {
/**
* @param {Options=} opt_options Options.
* @param {Options} [opt_options] Options.
*/
constructor(opt_options) {
super();
@@ -623,7 +616,7 @@ class WKT extends TextFeature {
/**
* Parse a WKT string.
* @param {string} wkt WKT string.
* @return {import("../geom/Geometry.js").default|undefined}
* @return {import("../geom/Geometry.js").default}
* The geometry created.
* @private
*/
@@ -636,22 +629,19 @@ class WKT extends TextFeature {
/**
* @protected
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../Feature.js").default} Feature.
*/
readFeatureFromText(text, opt_options) {
const geom = this.readGeometryFromText(text, opt_options);
if (geom) {
const feature = new Feature();
feature.setGeometry(geom);
return feature;
}
return null;
const feature = new Feature();
feature.setGeometry(geom);
return feature;
}
/**
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {Array<Feature>} Features.
*/
@@ -677,22 +667,18 @@ class WKT extends TextFeature {
/**
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../geom/Geometry.js").default} Geometry.
*/
readGeometryFromText(text, opt_options) {
const geometry = this.parse_(text);
if (geometry) {
return transformGeometryWithOptions(geometry, false, opt_options);
} else {
return null;
}
return transformGeometryWithOptions(geometry, false, opt_options);
}
/**
* @param {import("../Feature.js").default} feature Features.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
@@ -706,7 +692,7 @@ class WKT extends TextFeature {
/**
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
@@ -724,7 +710,7 @@ class WKT extends TextFeature {
/**
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
@@ -855,7 +841,7 @@ const GeometryEncoder = {
/**
* Encode a geometry as WKT.
* @param {!import("../geom/Geometry.js").default} geom The geometry to encode.
* @param {import("../geom/Geometry.js").default} geom The geometry to encode.
* @return {string} WKT string for the geometry.
*/
function encode(geom) {
+7 -1
View File
@@ -407,7 +407,13 @@ function readException(node, objectStack) {
* @return {Object|undefined} Layer object.
*/
function readCapabilityLayer(node, objectStack) {
return pushParseAndPop({}, LAYER_PARSERS, node, objectStack);
const layerObject = pushParseAndPop({}, LAYER_PARSERS, node, objectStack);
if (layerObject['Layer'] === undefined) {
return Object.assign(layerObject, readLayer(node, objectStack));
}
return layerObject;
}
/**
+2 -2
View File
@@ -33,7 +33,7 @@ const layerIdentifier = '_layer';
*/
class WMSGetFeatureInfo extends XMLFeature {
/**
* @param {Options=} opt_options Options.
* @param {Options} [opt_options] Options.
*/
constructor(opt_options) {
super();
@@ -151,7 +151,7 @@ class WMSGetFeatureInfo extends XMLFeature {
/**
* @protected
* @param {Element} node Node.
* @param {import("./Feature.js").ReadOptions=} opt_options Options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
* @return {Array<import("../Feature.js").default>} Features.
*/
readFeaturesFromNode(node, opt_options) {
+15 -15
View File
@@ -37,7 +37,7 @@ class XMLFeature extends FeatureFormat {
* Read a single feature.
*
* @param {Document|Element|Object|string} source Source.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../Feature.js").default} Feature.
* @api
*/
@@ -62,7 +62,7 @@ class XMLFeature extends FeatureFormat {
/**
* @param {Document} doc Document.
* @param {import("./Feature.js").ReadOptions=} opt_options Options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
* @return {import("../Feature.js").default} Feature.
*/
readFeatureFromDocument(doc, opt_options) {
@@ -76,7 +76,7 @@ class XMLFeature extends FeatureFormat {
/**
* @param {Element} node Node.
* @param {import("./Feature.js").ReadOptions=} opt_options Options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
* @return {import("../Feature.js").default} Feature.
*/
readFeatureFromNode(node, opt_options) {
@@ -87,7 +87,7 @@ class XMLFeature extends FeatureFormat {
* Read all features from a feature collection.
*
* @param {Document|Element|Object|string} source Source.
* @param {import("./Feature.js").ReadOptions=} opt_options Options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
* @return {Array<import("../Feature.js").default>} Features.
* @api
*/
@@ -112,7 +112,7 @@ class XMLFeature extends FeatureFormat {
/**
* @param {Document} doc Document.
* @param {import("./Feature.js").ReadOptions=} opt_options Options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
* @protected
* @return {Array<import("../Feature.js").default>} Features.
*/
@@ -133,7 +133,7 @@ class XMLFeature extends FeatureFormat {
/**
* @abstract
* @param {Element} node Node.
* @param {import("./Feature.js").ReadOptions=} opt_options Options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
* @protected
* @return {Array<import("../Feature.js").default>} Features.
*/
@@ -145,7 +145,7 @@ class XMLFeature extends FeatureFormat {
* Read a single geometry from a source.
*
* @param {Document|Element|Object|string} source Source.
* @param {import("./Feature.js").ReadOptions=} opt_options Read options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../geom/Geometry.js").default} Geometry.
*/
readGeometry(source, opt_options) {
@@ -169,7 +169,7 @@ class XMLFeature extends FeatureFormat {
/**
* @param {Document} doc Document.
* @param {import("./Feature.js").ReadOptions=} opt_options Options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
* @protected
* @return {import("../geom/Geometry.js").default} Geometry.
*/
@@ -179,7 +179,7 @@ class XMLFeature extends FeatureFormat {
/**
* @param {Element} node Node.
* @param {import("./Feature.js").ReadOptions=} opt_options Options.
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
* @protected
* @return {import("../geom/Geometry.js").default} Geometry.
*/
@@ -229,7 +229,7 @@ class XMLFeature extends FeatureFormat {
* Encode a feature as string.
*
* @param {import("../Feature.js").default} feature Feature.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string} Encoded feature.
*/
writeFeature(feature, opt_options) {
@@ -239,7 +239,7 @@ class XMLFeature extends FeatureFormat {
/**
* @param {import("../Feature.js").default} feature Feature.
* @param {import("./Feature.js").WriteOptions=} opt_options Options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
* @protected
* @return {Node} Node.
*/
@@ -251,7 +251,7 @@ class XMLFeature extends FeatureFormat {
* Encode an array of features as string.
*
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string} Result.
* @api
*/
@@ -262,7 +262,7 @@ class XMLFeature extends FeatureFormat {
/**
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions=} opt_options Options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
* @return {Node} Node.
*/
writeFeaturesNode(features, opt_options) {
@@ -273,7 +273,7 @@ class XMLFeature extends FeatureFormat {
* Encode a geometry as string.
*
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string} Encoded geometry.
*/
writeGeometry(geometry, opt_options) {
@@ -283,7 +283,7 @@ class XMLFeature extends FeatureFormat {
/**
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions=} opt_options Options.
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
* @return {Node} Node.
*/
writeGeometryNode(geometry, opt_options) {
+66 -27
View File
@@ -4,6 +4,8 @@
import And from './filter/And.js';
import Bbox from './filter/Bbox.js';
import Contains from './filter/Contains.js';
import DWithin from './filter/DWithin.js';
import Disjoint from './filter/Disjoint.js';
import During from './filter/During.js';
import EqualTo from './filter/EqualTo.js';
import GreaterThan from './filter/GreaterThan.js';
@@ -17,13 +19,14 @@ import LessThanOrEqualTo from './filter/LessThanOrEqualTo.js';
import Not from './filter/Not.js';
import NotEqualTo from './filter/NotEqualTo.js';
import Or from './filter/Or.js';
import ResourceId from './filter/ResourceId.js';
import Within from './filter/Within.js';
/**
* Create a logical `<And>` operator between two or more filter conditions.
*
* @param {...import("./filter/Filter.js").default} conditions Filter conditions.
* @returns {!And} `<And>` operator.
* @return {!And} `<And>` operator.
* @api
*/
export function and(conditions) {
@@ -35,7 +38,7 @@ export function and(conditions) {
* Create a logical `<Or>` operator between two or more filter conditions.
*
* @param {...import("./filter/Filter.js").default} conditions Filter conditions.
* @returns {!Or} `<Or>` operator.
* @return {!Or} `<Or>` operator.
* @api
*/
export function or(conditions) {
@@ -47,7 +50,7 @@ export function or(conditions) {
* Represents a logical `<Not>` operator for a filter condition.
*
* @param {!import("./filter/Filter.js").default} condition Filter condition.
* @returns {!Not} `<Not>` operator.
* @return {!Not} `<Not>` operator.
* @api
*/
export function not(condition) {
@@ -60,9 +63,9 @@ export function not(condition) {
*
* @param {!string} geometryName Geometry name to use.
* @param {!import("../extent.js").Extent} extent Extent.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @returns {!Bbox} `<BBOX>` operator.
* @return {!Bbox} `<BBOX>` operator.
* @api
*/
export function bbox(geometryName, extent, opt_srsName) {
@@ -75,9 +78,9 @@ export function bbox(geometryName, extent, opt_srsName) {
*
* @param {!string} geometryName Geometry name to use.
* @param {!import("../geom/Geometry.js").default} geometry Geometry.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @returns {!Contains} `<Contains>` operator.
* @return {!Contains} `<Contains>` operator.
* @api
*/
export function contains(geometryName, geometry, opt_srsName) {
@@ -90,37 +93,69 @@ export function contains(geometryName, geometry, opt_srsName) {
*
* @param {!string} geometryName Geometry name to use.
* @param {!import("../geom/Geometry.js").default} geometry Geometry.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @returns {!Intersects} `<Intersects>` operator.
* @return {!Intersects} `<Intersects>` operator.
* @api
*/
export function intersects(geometryName, geometry, opt_srsName) {
return new Intersects(geometryName, geometry, opt_srsName);
}
/**
* Create a `<Disjoint>` operator to test whether a geometry-valued property
* is disjoint to a given geometry.
*
* @param {!string} geometryName Geometry name to use.
* @param {!import("../geom/Geometry.js").default} geometry Geometry.
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @return {!Disjoint} `<Disjoint>` operator.
* @api
*/
export function disjoint(geometryName, geometry, opt_srsName) {
return new Disjoint(geometryName, geometry, opt_srsName);
}
/**
* Create a `<Within>` operator to test whether a geometry-valued property
* is within a given geometry.
*
* @param {!string} geometryName Geometry name to use.
* @param {!import("../geom/Geometry.js").default} geometry Geometry.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @returns {!Within} `<Within>` operator.
* @return {!Within} `<Within>` operator.
* @api
*/
export function within(geometryName, geometry, opt_srsName) {
return new Within(geometryName, geometry, opt_srsName);
}
/**
* Create a `<DWithin>` operator to test whether a geometry-valued property
* is within a distance to a given geometry.
*
* @param {!string} geometryName Geometry name to use.
* @param {!import("../geom/Geometry.js").default} geometry Geometry.
* @param {!number} distance Distance.
* @param {!string} unit Unit.
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @return {!DWithin} `<DWithin>` operator.
* @api
*/
export function dwithin(geometryName, geometry, distance, unit, opt_srsName) {
return new DWithin(geometryName, geometry, distance, unit, opt_srsName);
}
/**
* Creates a `<PropertyIsEqualTo>` comparison operator.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!(string|number)} expression The value to compare.
* @param {boolean=} opt_matchCase Case-sensitive?
* @returns {!EqualTo} `<PropertyIsEqualTo>` operator.
* @param {boolean} [opt_matchCase] Case-sensitive?
* @return {!EqualTo} `<PropertyIsEqualTo>` operator.
* @api
*/
export function equalTo(propertyName, expression, opt_matchCase) {
@@ -132,8 +167,8 @@ export function equalTo(propertyName, expression, opt_matchCase) {
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!(string|number)} expression The value to compare.
* @param {boolean=} opt_matchCase Case-sensitive?
* @returns {!NotEqualTo} `<PropertyIsNotEqualTo>` operator.
* @param {boolean} [opt_matchCase] Case-sensitive?
* @return {!NotEqualTo} `<PropertyIsNotEqualTo>` operator.
* @api
*/
export function notEqualTo(propertyName, expression, opt_matchCase) {
@@ -145,7 +180,7 @@ export function notEqualTo(propertyName, expression, opt_matchCase) {
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @returns {!LessThan} `<PropertyIsLessThan>` operator.
* @return {!LessThan} `<PropertyIsLessThan>` operator.
* @api
*/
export function lessThan(propertyName, expression) {
@@ -157,7 +192,7 @@ export function lessThan(propertyName, expression) {
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @returns {!LessThanOrEqualTo} `<PropertyIsLessThanOrEqualTo>` operator.
* @return {!LessThanOrEqualTo} `<PropertyIsLessThanOrEqualTo>` operator.
* @api
*/
export function lessThanOrEqualTo(propertyName, expression) {
@@ -169,7 +204,7 @@ export function lessThanOrEqualTo(propertyName, expression) {
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @returns {!GreaterThan} `<PropertyIsGreaterThan>` operator.
* @return {!GreaterThan} `<PropertyIsGreaterThan>` operator.
* @api
*/
export function greaterThan(propertyName, expression) {
@@ -181,7 +216,7 @@ export function greaterThan(propertyName, expression) {
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @returns {!GreaterThanOrEqualTo} `<PropertyIsGreaterThanOrEqualTo>` operator.
* @return {!GreaterThanOrEqualTo} `<PropertyIsGreaterThanOrEqualTo>` operator.
* @api
*/
export function greaterThanOrEqualTo(propertyName, expression) {
@@ -193,7 +228,7 @@ export function greaterThanOrEqualTo(propertyName, expression) {
* is null.
*
* @param {!string} propertyName Name of the context property to compare.
* @returns {!IsNull} `<PropertyIsNull>` operator.
* @return {!IsNull} `<PropertyIsNull>` operator.
* @api
*/
export function isNull(propertyName) {
@@ -207,7 +242,7 @@ export function isNull(propertyName) {
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} lowerBoundary The lower bound of the range.
* @param {!number} upperBoundary The upper bound of the range.
* @returns {!IsBetween} `<PropertyIsBetween>` operator.
* @return {!IsBetween} `<PropertyIsBetween>` operator.
* @api
*/
export function between(propertyName, lowerBoundary, upperBoundary) {
@@ -220,14 +255,14 @@ export function between(propertyName, lowerBoundary, upperBoundary) {
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!string} pattern Text pattern.
* @param {string=} opt_wildCard Pattern character which matches any sequence of
* @param {string} [opt_wildCard] Pattern character which matches any sequence of
* zero or more string characters. Default is '*'.
* @param {string=} opt_singleChar pattern character which matches any single
* @param {string} [opt_singleChar] pattern character which matches any single
* string character. Default is '.'.
* @param {string=} opt_escapeChar Escape character which can be used to escape
* @param {string} [opt_escapeChar] Escape character which can be used to escape
* the pattern characters. Default is '!'.
* @param {boolean=} opt_matchCase Case-sensitive?
* @returns {!IsLike} `<PropertyIsLike>` operator.
* @param {boolean} [opt_matchCase] Case-sensitive?
* @return {!IsLike} `<PropertyIsLike>` operator.
* @api
*/
export function like(
@@ -254,9 +289,13 @@ export function like(
* @param {!string} propertyName Name of the context property to compare.
* @param {!string} begin The begin date in ISO-8601 format.
* @param {!string} end The end date in ISO-8601 format.
* @returns {!During} `<During>` operator.
* @return {!During} `<During>` operator.
* @api
*/
export function during(propertyName, begin, end) {
return new During(propertyName, begin, end);
}
export function resourceId(rid) {
return new ResourceId(rid);
}
+1 -1
View File
@@ -14,7 +14,7 @@ class Bbox extends Filter {
/**
* @param {!string} geometryName Geometry name to use.
* @param {!import("../../extent.js").Extent} extent Extent.
* @param {string=} opt_srsName SRS name. No srsName attribute will be set
* @param {string} [opt_srsName] SRS name. No srsName attribute will be set
* on geometries when this is not provided.
*/
constructor(geometryName, extent, opt_srsName) {
+1 -1
View File
@@ -15,7 +15,7 @@ class ComparisonBinary extends Comparison {
* @param {!string} tagName The XML tag name for this filter.
* @param {!string} propertyName Name of the context property to compare.
* @param {!(string|number)} expression The value to compare.
* @param {boolean=} opt_matchCase Case-sensitive?
* @param {boolean} [opt_matchCase] Case-sensitive?
*/
constructor(tagName, propertyName, expression, opt_matchCase) {
super(tagName, propertyName);
+1 -1
View File
@@ -13,7 +13,7 @@ class Contains extends Spatial {
/**
* @param {!string} geometryName Geometry name to use.
* @param {!import("../../geom/Geometry.js").default} geometry Geometry.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
* set on geometries when this is not provided.
*/
constructor(geometryName, geometry, opt_srsName) {
+38
View File
@@ -0,0 +1,38 @@
/**
* @module ol/format/filter/DWithin
*/
import Spatial from './Spatial.js';
/**
* @classdesc
* Represents a `<DWithin>` operator to test whether a geometry-valued property
* is within a distance to a given geometry.
* @api
*/
class DWithin extends Spatial {
/**
* @param {!string} geometryName Geometry name to use.
* @param {!import("../../geom/Geometry.js").default} geometry Geometry.
* @param {!number} distance Distance.
* @param {!string} unit Unit.
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
* set on geometries when this is not provided.
*/
constructor(geometryName, geometry, distance, unit, opt_srsName) {
super('DWithin', geometryName, geometry, opt_srsName);
/**
* @public
* @type {!number}
*/
this.distance = distance;
/**
* @public
* @type {!string}
*/
this.unit = unit;
}
}
export default DWithin;
+24
View File
@@ -0,0 +1,24 @@
/**
* @module ol/format/filter/Disjoint
*/
import Spatial from './Spatial.js';
/**
* @classdesc
* Represents a `<Disjoint>` operator to test whether a geometry-valued property
* is disjoint to a given geometry.
* @api
*/
class Disjoint extends Spatial {
/**
* @param {!string} geometryName Geometry name to use.
* @param {!import("../../geom/Geometry.js").default} geometry Geometry.
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
* set on geometries when this is not provided.
*/
constructor(geometryName, geometry, opt_srsName) {
super('Disjoint', geometryName, geometry, opt_srsName);
}
}
export default Disjoint;
+1 -1
View File
@@ -12,7 +12,7 @@ class EqualTo extends ComparisonBinary {
/**
* @param {!string} propertyName Name of the context property to compare.
* @param {!(string|number)} expression The value to compare.
* @param {boolean=} opt_matchCase Case-sensitive?
* @param {boolean} [opt_matchCase] Case-sensitive?
*/
constructor(propertyName, expression, opt_matchCase) {
super('PropertyIsEqualTo', propertyName, expression, opt_matchCase);
+1 -1
View File
@@ -23,7 +23,7 @@ class Filter {
/**
* The XML tag name for a filter.
* @returns {!string} Name.
* @return {!string} Name.
*/
getTagName() {
return this.tagName_;
+1 -1
View File
@@ -13,7 +13,7 @@ class Intersects extends Spatial {
/**
* @param {!string} geometryName Geometry name to use.
* @param {!import("../../geom/Geometry.js").default} geometry Geometry.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
* set on geometries when this is not provided.
*/
constructor(geometryName, geometry, opt_srsName) {
+4 -4
View File
@@ -13,13 +13,13 @@ class IsLike extends Comparison {
* [constructor description]
* @param {!string} propertyName Name of the context property to compare.
* @param {!string} pattern Text pattern.
* @param {string=} opt_wildCard Pattern character which matches any sequence of
* @param {string} [opt_wildCard] Pattern character which matches any sequence of
* zero or more string characters. Default is '*'.
* @param {string=} opt_singleChar pattern character which matches any single
* @param {string} [opt_singleChar] pattern character which matches any single
* string character. Default is '.'.
* @param {string=} opt_escapeChar Escape character which can be used to escape
* @param {string} [opt_escapeChar] Escape character which can be used to escape
* the pattern characters. Default is '!'.
* @param {boolean=} opt_matchCase Case-sensitive?
* @param {boolean} [opt_matchCase] Case-sensitive?
*/
constructor(
propertyName,
+1 -1
View File
@@ -12,7 +12,7 @@ class NotEqualTo extends ComparisonBinary {
/**
* @param {!string} propertyName Name of the context property to compare.
* @param {!(string|number)} expression The value to compare.
* @param {boolean=} opt_matchCase Case-sensitive?
* @param {boolean} [opt_matchCase] Case-sensitive?
*/
constructor(propertyName, expression, opt_matchCase) {
super('PropertyIsNotEqualTo', propertyName, expression, opt_matchCase);
+25
View File
@@ -0,0 +1,25 @@
/**
* @module ol/format/filter/ResourceId
*/
import Filter from './Filter.js';
/**
* @classdesc
*
* @abstract
*/
class ResourceId extends Filter {
/**
* @param {!string} rid Resource ID.
*/
constructor(rid) {
super('ResourceId');
/**
* @type {!string}
*/
this.rid = rid;
}
}
export default ResourceId;
+1 -1
View File
@@ -16,7 +16,7 @@ class Spatial extends Filter {
* @param {!string} tagName The XML tag name for this filter.
* @param {!string} geometryName Geometry name to use.
* @param {!import("../../geom/Geometry.js").default} geometry Geometry.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
* set on geometries when this is not provided.
*/
constructor(tagName, geometryName, geometry, opt_srsName) {
+1 -1
View File
@@ -13,7 +13,7 @@ class Within extends Spatial {
/**
* @param {!string} geometryName Geometry name to use.
* @param {!import("../../geom/Geometry.js").default} geometry Geometry.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* @param {string} [opt_srsName] SRS name. No srsName attribute will be
* set on geometries when this is not provided.
*/
constructor(geometryName, geometry, opt_srsName) {
+1 -1
View File
@@ -124,7 +124,7 @@ In the above there are many common operations, like setting the property of the
### Putting it all together
With the above, you should be able to read through the [source code to `ol/format/GPX`](https://github.com/openlayers/openlayers/blob/main/src/ol/format/gpxformat.js) and get a feel for how it works. Start from the bottom of the file and work upwards. It's also useful to have [an example GPX file](http://www.topografix.com/fells_loop.gpx) and [the GPX specification](http://www.topografix.com/GPX/1/1/) to hand.
With the above, you should be able to read through the [source code to `ol/format/GPX`](https://github.com/openlayers/openlayers/blob/main/src/ol/format/GPX.js) and get a feel for how it works. Start from the bottom of the file and work upwards. It's also useful to have [an example GPX file](https://openlayers.org/en/latest/examples/data/fells_loop.gpx) and [the GPX specification](https://www.topografix.com/GPX/1/1/) to hand.
### Handling errors