planning
Publish To Prod / deploy_and_publish (push) Successful in 35s

This commit is contained in:
2024-10-14 09:15:30 +02:00
parent bcba00a730
commit 6e64e138e2
21059 changed files with 2317811 additions and 1 deletions
+92
View File
@@ -0,0 +1,92 @@
export default EsriJSON;
export type EsriJSONFeature = import("arcgis-rest-api").Feature;
export type EsriJSONFeatureSet = import("arcgis-rest-api").FeatureSet;
export type EsriJSONGeometry = import("arcgis-rest-api").Geometry;
export type EsriJSONPoint = import("arcgis-rest-api").Point;
export type EsriJSONPolyline = import("arcgis-rest-api").Polyline;
export type EsriJSONPolygon = import("arcgis-rest-api").Polygon;
export type EsriJSONMultipoint = import("arcgis-rest-api").Multipoint;
export type EsriJSONHasZM = import("arcgis-rest-api").HasZM;
export type EsriJSONPosition = import("arcgis-rest-api").Position;
export type EsriJSONSpatialReferenceWkid = import("arcgis-rest-api").SpatialReferenceWkid;
export type EsriJSONMultiPolygon = {
/**
* Rings for the MultiPolygon.
*/
rings: Array<Array<Array<Array<number>>>>;
/**
* If the polygon coordinates have an M value.
*/
hasM?: boolean | undefined;
/**
* If the polygon coordinates have a Z value.
*/
hasZ?: boolean | undefined;
/**
* The coordinate reference system.
*/
spatialReference?: import("arcgis-rest-api").SpatialReferenceWkid | undefined;
};
export type Options = {
/**
* Geometry name to use when creating features.
*/
geometryName?: string | undefined;
};
/**
* @typedef {Object} Options
* @property {string} [geometryName] Geometry name to use when creating features.
*/
/**
* @classdesc
* Feature format for reading and writing data in the EsriJSON format.
*
* @api
*/
declare class EsriJSON extends JSONFeature {
/**
* @param {Options} [opt_options] Options.
*/
constructor(opt_options?: Options | undefined);
/**
* Name of the geometry attribute for features.
* @type {string|undefined}
* @private
*/
private geometryName_;
/**
* @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.
* @protected
* @return {import("../Feature.js").default} Feature.
*/
protected readFeatureFromObject(object: any, opt_options?: import("./Feature.js").ReadOptions | undefined, opt_idField?: string | undefined): import("../Feature.js").default;
/**
* @param {EsriJSONGeometry} object Object.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../geom/Geometry.js").default} Geometry.
*/
protected readGeometryFromObject(object: EsriJSONGeometry, opt_options?: import("./Feature.js").ReadOptions | undefined): import("../geom/Geometry.js").default;
/**
* Encode a geometry as a EsriJSON object.
*
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {EsriJSONGeometry} Object.
* @api
*/
writeGeometryObject(geometry: import("../geom/Geometry.js").default, opt_options?: import("./Feature.js").WriteOptions | undefined): EsriJSONGeometry;
/**
* 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.
* @return {EsriJSONFeatureSet} EsriJSON Object.
* @api
*/
writeFeaturesObject(features: Array<import("../Feature.js").default>, opt_options?: import("./Feature.js").WriteOptions | undefined): EsriJSONFeatureSet;
}
import JSONFeature from "./JSONFeature.js";
//# sourceMappingURL=EsriJSON.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"EsriJSON.d.ts","sourceRoot":"","sources":["../src/format/EsriJSON.js"],"names":[],"mappings":";8BAsBa,OAAO,iBAAiB,EAAE,OAAO;iCACjC,OAAO,iBAAiB,EAAE,UAAU;+BACpC,OAAO,iBAAiB,EAAE,QAAQ;4BAClC,OAAO,iBAAiB,EAAE,KAAK;+BAC/B,OAAO,iBAAiB,EAAE,QAAQ;8BAClC,OAAO,iBAAiB,EAAE,OAAO;iCACjC,OAAO,iBAAiB,EAAE,UAAU;4BACpC,OAAO,iBAAiB,EAAE,KAAK;+BAC/B,OAAO,iBAAiB,EAAE,QAAQ;2CAClC,OAAO,iBAAiB,EAAE,oBAAoB;;;;;WAK7C,MAAM,MAAM,MAAM,MAAM,MAAM,CAAC,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;AAgChD;;;GAGG;AAEH;;;;;GAKG;AACH;IACE;;OAEG;IACH,+CAWC;IANC;;;;OAIG;IACH,sBAAyC;IAG3C;;;;;;OAMG;IACH,8IAFY,OAAO,eAAe,EAAE,OAAO,CAkB1C;IA8BD;;;;;OAKG;IACH,yCALW,gBAAgB,iEAGf,OAAO,qBAAqB,EAAE,OAAO,CAIhD;IAsBD;;;;;;;OAOG;IACH,8BALW,OAAO,qBAAqB,EAAE,OAAO,kEAEpC,gBAAgB,CAK3B;IAwCD;;;;;;;OAOG;IACH,8BALW,MAAM,OAAO,eAAe,EAAE,OAAO,CAAC,kEAErC,kBAAkB,CAY7B;CACF"}
+552
View File
@@ -0,0 +1,552 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/format/EsriJSON
*/
import Feature from '../Feature.js';
import GeometryLayout from '../geom/GeometryLayout.js';
import JSONFeature from './JSONFeature.js';
import LineString from '../geom/LineString.js';
import LinearRing from '../geom/LinearRing.js';
import MultiLineString from '../geom/MultiLineString.js';
import MultiPoint from '../geom/MultiPoint.js';
import MultiPolygon from '../geom/MultiPolygon.js';
import Point from '../geom/Point.js';
import Polygon from '../geom/Polygon.js';
import { assert } from '../asserts.js';
import { assign, isEmpty } from '../obj.js';
import { containsExtent } from '../extent.js';
import { deflateCoordinates } from '../geom/flat/deflate.js';
import { get as getProjection } from '../proj.js';
import { linearRingIsClockwise } from '../geom/flat/orient.js';
import { transformGeometryWithOptions } from './Feature.js';
/**
* @typedef {import("arcgis-rest-api").Feature} EsriJSONFeature
* @typedef {import("arcgis-rest-api").FeatureSet} EsriJSONFeatureSet
* @typedef {import("arcgis-rest-api").Geometry} EsriJSONGeometry
* @typedef {import("arcgis-rest-api").Point} EsriJSONPoint
* @typedef {import("arcgis-rest-api").Polyline} EsriJSONPolyline
* @typedef {import("arcgis-rest-api").Polygon} EsriJSONPolygon
* @typedef {import("arcgis-rest-api").Multipoint} EsriJSONMultipoint
* @typedef {import("arcgis-rest-api").HasZM} EsriJSONHasZM
* @typedef {import("arcgis-rest-api").Position} EsriJSONPosition
* @typedef {import("arcgis-rest-api").SpatialReferenceWkid} EsriJSONSpatialReferenceWkid
*/
/**
* @typedef {Object} EsriJSONMultiPolygon
* @property {Array<Array<Array<Array<number>>>>} rings Rings for the MultiPolygon.
* @property {boolean} [hasM] If the polygon coordinates have an M value.
* @property {boolean} [hasZ] If the polygon coordinates have a Z value.
* @property {EsriJSONSpatialReferenceWkid} [spatialReference] The coordinate reference system.
*/
/**
* @const
* @type {Object<import("../geom/Geometry.js").Type, function(EsriJSONGeometry): import("../geom/Geometry.js").default>}
*/
var GEOMETRY_READERS = {
Point: readPointGeometry,
LineString: readLineStringGeometry,
Polygon: readPolygonGeometry,
MultiPoint: readMultiPointGeometry,
MultiLineString: readMultiLineStringGeometry,
MultiPolygon: readMultiPolygonGeometry,
};
/**
* @const
* @type {Object<import("../geom/Geometry.js").Type, function(import("../geom/Geometry.js").default, import("./Feature.js").WriteOptions=): (EsriJSONGeometry)>}
*/
var GEOMETRY_WRITERS = {
Point: writePointGeometry,
LineString: writeLineStringGeometry,
Polygon: writePolygonGeometry,
MultiPoint: writeMultiPointGeometry,
MultiLineString: writeMultiLineStringGeometry,
MultiPolygon: writeMultiPolygonGeometry,
};
/**
* @typedef {Object} Options
* @property {string} [geometryName] Geometry name to use when creating features.
*/
/**
* @classdesc
* Feature format for reading and writing data in the EsriJSON format.
*
* @api
*/
var EsriJSON = /** @class */ (function (_super) {
__extends(EsriJSON, _super);
/**
* @param {Options} [opt_options] Options.
*/
function EsriJSON(opt_options) {
var _this = this;
var options = opt_options ? opt_options : {};
_this = _super.call(this) || this;
/**
* Name of the geometry attribute for features.
* @type {string|undefined}
* @private
*/
_this.geometryName_ = options.geometryName;
return _this;
}
/**
* @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.
* @protected
* @return {import("../Feature.js").default} Feature.
*/
EsriJSON.prototype.readFeatureFromObject = function (object, opt_options, opt_idField) {
var esriJSONFeature = /** @type {EsriJSONFeature} */ (object);
var geometry = readGeometry(esriJSONFeature.geometry, opt_options);
var feature = new Feature();
if (this.geometryName_) {
feature.setGeometryName(this.geometryName_);
}
feature.setGeometry(geometry);
if (esriJSONFeature.attributes) {
feature.setProperties(esriJSONFeature.attributes, true);
var id = esriJSONFeature.attributes[opt_idField];
if (id !== undefined) {
feature.setId(/** @type {number} */ (id));
}
}
return feature;
};
/**
* @param {Object} object Object.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {Array<Feature>} Features.
*/
EsriJSON.prototype.readFeaturesFromObject = function (object, opt_options) {
var options = opt_options ? opt_options : {};
if (object['features']) {
var esriJSONFeatureSet = /** @type {EsriJSONFeatureSet} */ (object);
/** @type {Array<import("../Feature.js").default>} */
var features = [];
var esriJSONFeatures = esriJSONFeatureSet.features;
for (var i = 0, ii = esriJSONFeatures.length; i < ii; ++i) {
features.push(this.readFeatureFromObject(esriJSONFeatures[i], options, object.objectIdFieldName));
}
return features;
}
else {
return [this.readFeatureFromObject(object, options)];
}
};
/**
* @param {EsriJSONGeometry} object Object.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../geom/Geometry.js").default} Geometry.
*/
EsriJSON.prototype.readGeometryFromObject = function (object, opt_options) {
return readGeometry(object, opt_options);
};
/**
* @param {Object} object Object.
* @protected
* @return {import("../proj/Projection.js").default} Projection.
*/
EsriJSON.prototype.readProjectionFromObject = function (object) {
if (object['spatialReference'] &&
object['spatialReference']['wkid'] !== undefined) {
var spatialReference = /** @type {EsriJSONSpatialReferenceWkid} */ (object['spatialReference']);
var crs = spatialReference.wkid;
return getProjection('EPSG:' + crs);
}
else {
return null;
}
};
/**
* Encode a geometry as a EsriJSON object.
*
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {EsriJSONGeometry} Object.
* @api
*/
EsriJSON.prototype.writeGeometryObject = function (geometry, opt_options) {
return writeGeometry(geometry, this.adaptOptions(opt_options));
};
/**
* Encode a feature as a esriJSON Feature object.
*
* @param {import("../Feature.js").default} feature Feature.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {Object} Object.
* @api
*/
EsriJSON.prototype.writeFeatureObject = function (feature, opt_options) {
opt_options = this.adaptOptions(opt_options);
var object = {};
if (!feature.hasProperties()) {
object['attributes'] = {};
return object;
}
var properties = feature.getProperties();
var geometry = feature.getGeometry();
if (geometry) {
object['geometry'] = writeGeometry(geometry, opt_options);
var projection = opt_options &&
(opt_options.dataProjection || opt_options.featureProjection);
if (projection) {
object['geometry']['spatialReference'] =
/** @type {EsriJSONSpatialReferenceWkid} */ ({
wkid: Number(getProjection(projection).getCode().split(':').pop()),
});
}
delete properties[feature.getGeometryName()];
}
if (!isEmpty(properties)) {
object['attributes'] = properties;
}
else {
object['attributes'] = {};
}
return object;
};
/**
* Encode an array of features as a EsriJSON object.
*
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {EsriJSONFeatureSet} EsriJSON Object.
* @api
*/
EsriJSON.prototype.writeFeaturesObject = function (features, opt_options) {
opt_options = this.adaptOptions(opt_options);
var objects = [];
for (var i = 0, ii = features.length; i < ii; ++i) {
objects.push(this.writeFeatureObject(features[i], opt_options));
}
return {
'features': objects,
};
};
return EsriJSON;
}(JSONFeature));
/**
* @param {EsriJSONGeometry} object Object.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../geom/Geometry.js").default} Geometry.
*/
function readGeometry(object, opt_options) {
var _a, _b;
if (!object) {
return null;
}
/** @type {import("../geom/Geometry.js").Type} */
var type;
if (typeof object['x'] === 'number' && typeof object['y'] === 'number') {
type = 'Point';
}
else if (object['points']) {
type = 'MultiPoint';
}
else if (object['paths']) {
var esriJSONPolyline = /** @type {EsriJSONPolyline} */ (object);
if (esriJSONPolyline.paths.length === 1) {
type = 'LineString';
}
else {
type = 'MultiLineString';
}
}
else if (object['rings']) {
var esriJSONPolygon = /** @type {EsriJSONPolygon} */ (object);
var layout = getGeometryLayout(esriJSONPolygon);
var rings = convertRings(esriJSONPolygon.rings, layout);
if (rings.length === 1) {
type = 'Polygon';
object = assign({}, object, (_a = {}, _a['rings'] = rings[0], _a));
}
else {
type = 'MultiPolygon';
object = assign({}, object, (_b = {}, _b['rings'] = rings, _b));
}
}
var geometryReader = GEOMETRY_READERS[type];
return transformGeometryWithOptions(geometryReader(object), false, opt_options);
}
/**
* Determines inner and outer rings.
* Checks if any polygons in this array contain any other polygons in this
* array. It is used for checking for holes.
* Logic inspired by: https://github.com/Esri/terraformer-arcgis-parser
* @param {Array<!Array<!Array<number>>>} rings Rings.
* @param {import("../geom/GeometryLayout.js").default} layout Geometry layout.
* @return {Array<!Array<!Array<!Array<number>>>>} Transformed rings.
*/
function convertRings(rings, layout) {
var flatRing = [];
var outerRings = [];
var holes = [];
var i, ii;
for (i = 0, ii = rings.length; i < ii; ++i) {
flatRing.length = 0;
deflateCoordinates(flatRing, 0, rings[i], layout.length);
// is this ring an outer ring? is it clockwise?
var clockwise = linearRingIsClockwise(flatRing, 0, flatRing.length, layout.length);
if (clockwise) {
outerRings.push([rings[i]]);
}
else {
holes.push(rings[i]);
}
}
while (holes.length) {
var hole = holes.shift();
var matched = false;
// loop over all outer rings and see if they contain our hole.
for (i = outerRings.length - 1; i >= 0; i--) {
var outerRing = outerRings[i][0];
var containsHole = containsExtent(new LinearRing(outerRing).getExtent(), new LinearRing(hole).getExtent());
if (containsHole) {
// the hole is contained push it into our polygon
outerRings[i].push(hole);
matched = true;
break;
}
}
if (!matched) {
// no outer rings contain this hole turn it into and outer
// ring (reverse it)
outerRings.push([hole.reverse()]);
}
}
return outerRings;
}
/**
* @param {EsriJSONPoint} object Object.
* @return {import("../geom/Geometry.js").default} Point.
*/
function readPointGeometry(object) {
var point;
if (object.m !== undefined && object.z !== undefined) {
point = new Point([object.x, object.y, object.z, object.m], GeometryLayout.XYZM);
}
else if (object.z !== undefined) {
point = new Point([object.x, object.y, object.z], GeometryLayout.XYZ);
}
else if (object.m !== undefined) {
point = new Point([object.x, object.y, object.m], GeometryLayout.XYM);
}
else {
point = new Point([object.x, object.y]);
}
return point;
}
/**
* @param {EsriJSONPolyline} object Object.
* @return {import("../geom/Geometry.js").default} LineString.
*/
function readLineStringGeometry(object) {
var layout = getGeometryLayout(object);
return new LineString(object.paths[0], layout);
}
/**
* @param {EsriJSONPolyline} object Object.
* @return {import("../geom/Geometry.js").default} MultiLineString.
*/
function readMultiLineStringGeometry(object) {
var layout = getGeometryLayout(object);
return new MultiLineString(object.paths, layout);
}
/**
* @param {EsriJSONHasZM} object Object.
* @return {import("../geom/GeometryLayout.js").default} The geometry layout to use.
*/
function getGeometryLayout(object) {
var layout = GeometryLayout.XY;
if (object.hasZ === true && object.hasM === true) {
layout = GeometryLayout.XYZM;
}
else if (object.hasZ === true) {
layout = GeometryLayout.XYZ;
}
else if (object.hasM === true) {
layout = GeometryLayout.XYM;
}
return layout;
}
/**
* @param {EsriJSONMultipoint} object Object.
* @return {import("../geom/Geometry.js").default} MultiPoint.
*/
function readMultiPointGeometry(object) {
var layout = getGeometryLayout(object);
return new MultiPoint(object.points, layout);
}
/**
* @param {EsriJSONMultiPolygon} object Object.
* @return {import("../geom/Geometry.js").default} MultiPolygon.
*/
function readMultiPolygonGeometry(object) {
var layout = getGeometryLayout(object);
return new MultiPolygon(object.rings, layout);
}
/**
* @param {EsriJSONPolygon} object Object.
* @return {import("../geom/Geometry.js").default} Polygon.
*/
function readPolygonGeometry(object) {
var layout = getGeometryLayout(object);
return new Polygon(object.rings, layout);
}
/**
* @param {import("../geom/Point.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {EsriJSONPoint} EsriJSON geometry.
*/
function writePointGeometry(geometry, opt_options) {
var coordinates = geometry.getCoordinates();
/** @type {EsriJSONPoint} */
var esriJSON;
var layout = geometry.getLayout();
if (layout === GeometryLayout.XYZ) {
esriJSON = {
x: coordinates[0],
y: coordinates[1],
z: coordinates[2],
};
}
else if (layout === GeometryLayout.XYM) {
esriJSON = {
x: coordinates[0],
y: coordinates[1],
m: coordinates[2],
};
}
else if (layout === GeometryLayout.XYZM) {
esriJSON = {
x: coordinates[0],
y: coordinates[1],
z: coordinates[2],
m: coordinates[3],
};
}
else if (layout === GeometryLayout.XY) {
esriJSON = {
x: coordinates[0],
y: coordinates[1],
};
}
else {
assert(false, 34); // Invalid geometry layout
}
return esriJSON;
}
/**
* @param {import("../geom/SimpleGeometry.js").default} geometry Geometry.
* @return {Object} Object with boolean hasZ and hasM keys.
*/
function getHasZM(geometry) {
var layout = geometry.getLayout();
return {
hasZ: layout === GeometryLayout.XYZ || layout === GeometryLayout.XYZM,
hasM: layout === GeometryLayout.XYM || layout === GeometryLayout.XYZM,
};
}
/**
* @param {import("../geom/LineString.js").default} lineString Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {EsriJSONPolyline} EsriJSON geometry.
*/
function writeLineStringGeometry(lineString, opt_options) {
var hasZM = getHasZM(lineString);
return {
hasZ: hasZM.hasZ,
hasM: hasZM.hasM,
paths: [
/** @type {Array<EsriJSONPosition>} */ (lineString.getCoordinates()),
],
};
}
/**
* @param {import("../geom/Polygon.js").default} polygon Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {EsriJSONPolygon} EsriJSON geometry.
*/
function writePolygonGeometry(polygon, opt_options) {
// Esri geometries use the left-hand rule
var hasZM = getHasZM(polygon);
return {
hasZ: hasZM.hasZ,
hasM: hasZM.hasM,
rings: /** @type {Array<Array<EsriJSONPosition>>} */ (polygon.getCoordinates(false)),
};
}
/**
* @param {import("../geom/MultiLineString.js").default} multiLineString Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {EsriJSONPolyline} EsriJSON geometry.
*/
function writeMultiLineStringGeometry(multiLineString, opt_options) {
var hasZM = getHasZM(multiLineString);
return {
hasZ: hasZM.hasZ,
hasM: hasZM.hasM,
paths: /** @type {Array<Array<EsriJSONPosition>>} */ (multiLineString.getCoordinates()),
};
}
/**
* @param {import("../geom/MultiPoint.js").default} multiPoint Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {EsriJSONMultipoint} EsriJSON geometry.
*/
function writeMultiPointGeometry(multiPoint, opt_options) {
var hasZM = getHasZM(multiPoint);
return {
hasZ: hasZM.hasZ,
hasM: hasZM.hasM,
points: /** @type {Array<EsriJSONPosition>} */ (multiPoint.getCoordinates()),
};
}
/**
* @param {import("../geom/MultiPolygon.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {EsriJSONPolygon} EsriJSON geometry.
*/
function writeMultiPolygonGeometry(geometry, opt_options) {
var hasZM = getHasZM(geometry);
var coordinates = geometry.getCoordinates(false);
var output = [];
for (var i = 0; i < coordinates.length; i++) {
for (var x = coordinates[i].length - 1; x >= 0; x--) {
output.push(coordinates[i][x]);
}
}
return {
hasZ: hasZM.hasZ,
hasM: hasZM.hasM,
rings: /** @type {Array<Array<EsriJSONPosition>>} */ (output),
};
}
/**
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {EsriJSONGeometry} EsriJSON geometry.
*/
function writeGeometry(geometry, opt_options) {
var geometryWriter = GEOMETRY_WRITERS[geometry.getType()];
return geometryWriter(transformGeometryWithOptions(geometry, true, opt_options), opt_options);
}
export default EsriJSON;
//# sourceMappingURL=EsriJSON.js.map
+1
View File
File diff suppressed because one or more lines are too long
+230
View File
@@ -0,0 +1,230 @@
/**
* @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.
* @return {import("../geom/Geometry.js").default} Transformed geometry.
*/
export function transformGeometryWithOptions(geometry: import("../geom/Geometry.js").default, write: boolean, opt_options?: ReadOptions | WriteOptions | undefined): import("../geom/Geometry.js").default;
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {ReadOptions} [opt_options] Read options.
* @return {import("../extent.js").Extent} Transformed extent.
*/
export function transformExtentWithOptions(extent: import("../extent.js").Extent, opt_options?: ReadOptions | undefined): import("../extent.js").Extent;
export default FeatureFormat;
export type ReadOptions = {
/**
* Projection of the data we are reading.
* If not provided, the projection will be derived from the data (where possible) or
* the `dataProjection` of the format is assigned (where set). If the projection
* can not be derived from the data and if no `dataProjection` is set for a format,
* the features will not be reprojected.
*/
dataProjection?: import("../proj.js").ProjectionLike;
/**
* Tile extent in map units of the tile being read.
* This is only required when reading data with tile pixels as geometry units. When configured,
* a `dataProjection` with `TILE_PIXELS` as `units` and the tile's pixel extent as `extent` needs to be
* provided.
*/
extent?: import("../extent.js").Extent | undefined;
/**
* Projection of the feature geometries
* created by the format reader. If not provided, features will be returned in the
* `dataProjection`.
*/
featureProjection?: import("../proj.js").ProjectionLike;
};
export type WriteOptions = {
/**
* Projection of the data we are writing.
* If not provided, the `dataProjection` of the format is assigned (where set).
* If no `dataProjection` is set for a format, the features will be returned
* in the `featureProjection`.
*/
dataProjection?: import("../proj.js").ProjectionLike;
/**
* Projection of the feature geometries
* that will be serialized by the format writer. If not provided, geometries are assumed
* to be in the `dataProjection` if that is set; in other words, they are not transformed.
*/
featureProjection?: import("../proj.js").ProjectionLike;
/**
* When writing geometries, follow the right-hand
* rule for linear ring orientation. This means that polygons will have counter-clockwise
* exterior rings and clockwise interior rings. By default, coordinates are serialized
* as they are provided at construction. If `true`, the right-hand rule will
* be applied. If `false`, the left-hand rule will be applied (clockwise for
* exterior and counter-clockwise for interior rings). Note that not all
* formats support this. The GeoJSON format does use this property when writing
* geometries.
*/
rightHanded?: boolean | undefined;
/**
* Maximum number of decimal places for coordinates.
* Coordinates are stored internally as floats, but floating-point arithmetic can create
* coordinates with a large number of decimal places, not generally wanted on output.
* Set a number here to round coordinates. Can also be used to ensure that
* coordinates read in can be written back out with the same number of decimals.
* Default is no rounding.
*/
decimals?: number | undefined;
};
export type Type = 'arraybuffer' | 'json' | 'text' | 'xml';
/**
* @typedef {Object} ReadOptions
* @property {import("../proj.js").ProjectionLike} [dataProjection] Projection of the data we are reading.
* If not provided, the projection will be derived from the data (where possible) or
* the `dataProjection` of the format is assigned (where set). If the projection
* can not be derived from the data and if no `dataProjection` is set for a format,
* the features will not be reprojected.
* @property {import("../extent.js").Extent} [extent] Tile extent in map units of the tile being read.
* This is only required when reading data with tile pixels as geometry units. When configured,
* a `dataProjection` with `TILE_PIXELS` as `units` and the tile's pixel extent as `extent` needs to be
* provided.
* @property {import("../proj.js").ProjectionLike} [featureProjection] Projection of the feature geometries
* created by the format reader. If not provided, features will be returned in the
* `dataProjection`.
*/
/**
* @typedef {Object} WriteOptions
* @property {import("../proj.js").ProjectionLike} [dataProjection] Projection of the data we are writing.
* If not provided, the `dataProjection` of the format is assigned (where set).
* If no `dataProjection` is set for a format, the features will be returned
* in the `featureProjection`.
* @property {import("../proj.js").ProjectionLike} [featureProjection] Projection of the feature geometries
* that will be serialized by the format writer. If not provided, geometries are assumed
* to be in the `dataProjection` if that is set; in other words, they are not transformed.
* @property {boolean} [rightHanded] When writing geometries, follow the right-hand
* rule for linear ring orientation. This means that polygons will have counter-clockwise
* exterior rings and clockwise interior rings. By default, coordinates are serialized
* as they are provided at construction. If `true`, the right-hand rule will
* be applied. If `false`, the left-hand rule will be applied (clockwise for
* exterior and counter-clockwise for interior rings). Note that not all
* formats support this. The GeoJSON format does use this property when writing
* geometries.
* @property {number} [decimals] Maximum number of decimal places for coordinates.
* Coordinates are stored internally as floats, but floating-point arithmetic can create
* coordinates with a large number of decimal places, not generally wanted on output.
* Set a number here to round coordinates. Can also be used to ensure that
* coordinates read in can be written back out with the same number of decimals.
* Default is no rounding.
*/
/**
* @typedef {'arraybuffer' | 'json' | 'text' | 'xml'} Type
*/
/**
* @classdesc
* Abstract base class; normally only used for creating subclasses and not
* instantiated in apps.
* Base class for feature formats.
* {@link module:ol/format/Feature~FeatureFormat} subclasses provide the ability to decode and encode
* {@link module:ol/Feature~Feature} objects from a variety of commonly used geospatial
* file formats. See the documentation for each format for more details.
*
* @abstract
* @api
*/
declare class FeatureFormat {
/**
* @protected
* @type {import("../proj/Projection.js").default|undefined}
*/
protected dataProjection: import("../proj/Projection.js").default | undefined;
/**
* @protected
* @type {import("../proj/Projection.js").default|undefined}
*/
protected defaultFeatureProjection: import("../proj/Projection.js").default | undefined;
/**
* A list media types supported by the format in descending order of preference.
* @type {Array<string>}
*/
supportedMediaTypes: Array<string>;
/**
* Adds the data projection to the read options.
* @param {Document|Element|Object|string} source Source.
* @param {ReadOptions} [opt_options] Options.
* @return {ReadOptions|undefined} Options.
* @protected
*/
protected getReadOptions(source: Document | Element | any | string, opt_options?: ReadOptions | undefined): ReadOptions | undefined;
/**
* Sets the `dataProjection` on the options, if no `dataProjection`
* is set.
* @param {WriteOptions|ReadOptions|undefined} options
* Options.
* @protected
* @return {WriteOptions|ReadOptions|undefined}
* Updated options.
*/
protected adaptOptions(options: WriteOptions | ReadOptions | undefined): WriteOptions | ReadOptions | undefined;
/**
* @abstract
* @return {Type} The format type.
*/
getType(): Type;
/**
* Read a single feature from a source.
*
* @abstract
* @param {Document|Element|Object|string} source Source.
* @param {ReadOptions} [opt_options] Read options.
* @return {import("../Feature.js").FeatureLike} Feature.
*/
readFeature(source: Document | Element | any | string, opt_options?: ReadOptions | undefined): import("../Feature.js").FeatureLike;
/**
* Read all features from a source.
*
* @abstract
* @param {Document|Element|ArrayBuffer|Object|string} source Source.
* @param {ReadOptions} [opt_options] Read options.
* @return {Array<import("../Feature.js").FeatureLike>} Features.
*/
readFeatures(source: Document | Element | ArrayBuffer | any | string, opt_options?: ReadOptions | undefined): Array<import("../Feature.js").FeatureLike>;
/**
* Read a single geometry from a source.
*
* @abstract
* @param {Document|Element|Object|string} source Source.
* @param {ReadOptions} [opt_options] Read options.
* @return {import("../geom/Geometry.js").default} Geometry.
*/
readGeometry(source: Document | Element | any | string, opt_options?: ReadOptions | undefined): import("../geom/Geometry.js").default;
/**
* Read the projection from a source.
*
* @abstract
* @param {Document|Element|Object|string} source Source.
* @return {import("../proj/Projection.js").default|undefined} Projection.
*/
readProjection(source: Document | Element | any | string): import("../proj/Projection.js").default | undefined;
/**
* Encode a feature in this format.
*
* @abstract
* @param {import("../Feature.js").default} feature Feature.
* @param {WriteOptions} [opt_options] Write options.
* @return {string|ArrayBuffer} Result.
*/
writeFeature(feature: import("../Feature.js").default, opt_options?: WriteOptions | undefined): string | ArrayBuffer;
/**
* Encode an array of features in this format.
*
* @abstract
* @param {Array<import("../Feature.js").default>} features Features.
* @param {WriteOptions} [opt_options] Write options.
* @return {string|ArrayBuffer} Result.
*/
writeFeatures(features: Array<import("../Feature.js").default>, opt_options?: WriteOptions | undefined): string | ArrayBuffer;
/**
* Write a single geometry in this format.
*
* @abstract
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {WriteOptions} [opt_options] Write options.
* @return {string|ArrayBuffer} Result.
*/
writeGeometry(geometry: import("../geom/Geometry.js").default, opt_options?: WriteOptions | undefined): string | ArrayBuffer;
}
//# sourceMappingURL=Feature.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"Feature.d.ts","sourceRoot":"","sources":["../src/format/Feature.js"],"names":[],"mappings":"AAwOA;;;;;GAKG;AACH,uDALW,OAAO,qBAAqB,EAAE,OAAO,SACrC,OAAO,yDAEN,OAAO,qBAAqB,EAAE,OAAO,CAiDhD;AAED;;;;GAIG;AACH,mDAJW,OAAO,cAAc,EAAE,MAAM,0CAE5B,OAAO,cAAc,EAAE,MAAM,CAmBxC;;;;;;;;;;qBAvSa,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;wBASnC,OAAO,YAAY,EAAE,cAAc;;;;;;;;;qBAOnC,OAAO,YAAY,EAAE,cAAc;;;;;;wBAInC,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;mBAoBpC,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK;AA1CpD;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;GAEG;AAEH;;;;;;;;;;;GAWG;AACH;IAEI;;;OAGG;IACH,0BAFU,OAAO,uBAAuB,EAAE,OAAO,GAAC,SAAS,CAE5B;IAE/B;;;OAGG;IACH,oCAFU,OAAO,uBAAuB,EAAE,OAAO,GAAC,SAAS,CAElB;IAEzC;;;OAGG;IACH,qBAFU,MAAM,MAAM,CAAC,CAEQ;IAGjC;;;;;;OAMG;IACH,iCALW,QAAQ,GAAC,OAAO,SAAQ,MAAM,0CAE7B,WAAW,GAAC,SAAS,CAuBhC;IAED;;;;;;;;OAQG;IACH,gCANW,YAAY,GAAC,WAAW,GAAC,SAAS,GAGjC,YAAY,GAAC,WAAW,GAAC,SAAS,CAW7C;IAED;;;OAGG;IACH,WAFY,IAAI,CAIf;IAED;;;;;;;OAOG;IACH,oBAJW,QAAQ,GAAC,OAAO,SAAQ,MAAM,0CAE7B,OAAO,eAAe,EAAE,WAAW,CAI9C;IAED;;;;;;;OAOG;IACH,qBAJW,QAAQ,GAAC,OAAO,GAAC,WAAW,SAAQ,MAAM,0CAEzC,MAAM,OAAO,eAAe,EAAE,WAAW,CAAC,CAIrD;IAED;;;;;;;OAOG;IACH,qBAJW,QAAQ,GAAC,OAAO,SAAQ,MAAM,0CAE7B,OAAO,qBAAqB,EAAE,OAAO,CAIhD;IAED;;;;;;OAMG;IACH,uBAHW,QAAQ,GAAC,OAAO,SAAQ,MAAM,GAC7B,OAAO,uBAAuB,EAAE,OAAO,GAAC,SAAS,CAI5D;IAED;;;;;;;OAOG;IACH,sBAJW,OAAO,eAAe,EAAE,OAAO,2CAE9B,MAAM,GAAC,WAAW,CAI7B;IAED;;;;;;;OAOG;IACH,wBAJW,MAAM,OAAO,eAAe,EAAE,OAAO,CAAC,2CAErC,MAAM,GAAC,WAAW,CAI7B;IAED;;;;;;;OAOG;IACH,wBAJW,OAAO,qBAAqB,EAAE,OAAO,2CAEpC,MAAM,GAAC,WAAW,CAI7B;CACF"}
+273
View File
@@ -0,0 +1,273 @@
/**
* @module ol/format/Feature
*/
import Units from '../proj/Units.js';
import { abstract } from '../util.js';
import { assign } from '../obj.js';
import { equivalent as equivalentProjection, get as getProjection, transformExtent, } from '../proj.js';
/**
* @typedef {Object} ReadOptions
* @property {import("../proj.js").ProjectionLike} [dataProjection] Projection of the data we are reading.
* If not provided, the projection will be derived from the data (where possible) or
* the `dataProjection` of the format is assigned (where set). If the projection
* can not be derived from the data and if no `dataProjection` is set for a format,
* the features will not be reprojected.
* @property {import("../extent.js").Extent} [extent] Tile extent in map units of the tile being read.
* This is only required when reading data with tile pixels as geometry units. When configured,
* a `dataProjection` with `TILE_PIXELS` as `units` and the tile's pixel extent as `extent` needs to be
* provided.
* @property {import("../proj.js").ProjectionLike} [featureProjection] Projection of the feature geometries
* created by the format reader. If not provided, features will be returned in the
* `dataProjection`.
*/
/**
* @typedef {Object} WriteOptions
* @property {import("../proj.js").ProjectionLike} [dataProjection] Projection of the data we are writing.
* If not provided, the `dataProjection` of the format is assigned (where set).
* If no `dataProjection` is set for a format, the features will be returned
* in the `featureProjection`.
* @property {import("../proj.js").ProjectionLike} [featureProjection] Projection of the feature geometries
* that will be serialized by the format writer. If not provided, geometries are assumed
* to be in the `dataProjection` if that is set; in other words, they are not transformed.
* @property {boolean} [rightHanded] When writing geometries, follow the right-hand
* rule for linear ring orientation. This means that polygons will have counter-clockwise
* exterior rings and clockwise interior rings. By default, coordinates are serialized
* as they are provided at construction. If `true`, the right-hand rule will
* be applied. If `false`, the left-hand rule will be applied (clockwise for
* exterior and counter-clockwise for interior rings). Note that not all
* formats support this. The GeoJSON format does use this property when writing
* geometries.
* @property {number} [decimals] Maximum number of decimal places for coordinates.
* Coordinates are stored internally as floats, but floating-point arithmetic can create
* coordinates with a large number of decimal places, not generally wanted on output.
* Set a number here to round coordinates. Can also be used to ensure that
* coordinates read in can be written back out with the same number of decimals.
* Default is no rounding.
*/
/**
* @typedef {'arraybuffer' | 'json' | 'text' | 'xml'} Type
*/
/**
* @classdesc
* Abstract base class; normally only used for creating subclasses and not
* instantiated in apps.
* Base class for feature formats.
* {@link module:ol/format/Feature~FeatureFormat} subclasses provide the ability to decode and encode
* {@link module:ol/Feature~Feature} objects from a variety of commonly used geospatial
* file formats. See the documentation for each format for more details.
*
* @abstract
* @api
*/
var FeatureFormat = /** @class */ (function () {
function FeatureFormat() {
/**
* @protected
* @type {import("../proj/Projection.js").default|undefined}
*/
this.dataProjection = undefined;
/**
* @protected
* @type {import("../proj/Projection.js").default|undefined}
*/
this.defaultFeatureProjection = undefined;
/**
* A list media types supported by the format in descending order of preference.
* @type {Array<string>}
*/
this.supportedMediaTypes = null;
}
/**
* Adds the data projection to the read options.
* @param {Document|Element|Object|string} source Source.
* @param {ReadOptions} [opt_options] Options.
* @return {ReadOptions|undefined} Options.
* @protected
*/
FeatureFormat.prototype.getReadOptions = function (source, opt_options) {
var options;
if (opt_options) {
var dataProjection = opt_options.dataProjection
? getProjection(opt_options.dataProjection)
: this.readProjection(source);
if (opt_options.extent &&
dataProjection &&
dataProjection.getUnits() === Units.TILE_PIXELS) {
dataProjection = getProjection(dataProjection);
dataProjection.setWorldExtent(opt_options.extent);
}
options = {
dataProjection: dataProjection,
featureProjection: opt_options.featureProjection,
};
}
return this.adaptOptions(options);
};
/**
* Sets the `dataProjection` on the options, if no `dataProjection`
* is set.
* @param {WriteOptions|ReadOptions|undefined} options
* Options.
* @protected
* @return {WriteOptions|ReadOptions|undefined}
* Updated options.
*/
FeatureFormat.prototype.adaptOptions = function (options) {
return assign({
dataProjection: this.dataProjection,
featureProjection: this.defaultFeatureProjection,
}, options);
};
/**
* @abstract
* @return {Type} The format type.
*/
FeatureFormat.prototype.getType = function () {
return abstract();
};
/**
* Read a single feature from a source.
*
* @abstract
* @param {Document|Element|Object|string} source Source.
* @param {ReadOptions} [opt_options] Read options.
* @return {import("../Feature.js").FeatureLike} Feature.
*/
FeatureFormat.prototype.readFeature = function (source, opt_options) {
return abstract();
};
/**
* Read all features from a source.
*
* @abstract
* @param {Document|Element|ArrayBuffer|Object|string} source Source.
* @param {ReadOptions} [opt_options] Read options.
* @return {Array<import("../Feature.js").FeatureLike>} Features.
*/
FeatureFormat.prototype.readFeatures = function (source, opt_options) {
return abstract();
};
/**
* Read a single geometry from a source.
*
* @abstract
* @param {Document|Element|Object|string} source Source.
* @param {ReadOptions} [opt_options] Read options.
* @return {import("../geom/Geometry.js").default} Geometry.
*/
FeatureFormat.prototype.readGeometry = function (source, opt_options) {
return abstract();
};
/**
* Read the projection from a source.
*
* @abstract
* @param {Document|Element|Object|string} source Source.
* @return {import("../proj/Projection.js").default|undefined} Projection.
*/
FeatureFormat.prototype.readProjection = function (source) {
return abstract();
};
/**
* Encode a feature in this format.
*
* @abstract
* @param {import("../Feature.js").default} feature Feature.
* @param {WriteOptions} [opt_options] Write options.
* @return {string|ArrayBuffer} Result.
*/
FeatureFormat.prototype.writeFeature = function (feature, opt_options) {
return abstract();
};
/**
* Encode an array of features in this format.
*
* @abstract
* @param {Array<import("../Feature.js").default>} features Features.
* @param {WriteOptions} [opt_options] Write options.
* @return {string|ArrayBuffer} Result.
*/
FeatureFormat.prototype.writeFeatures = function (features, opt_options) {
return abstract();
};
/**
* Write a single geometry in this format.
*
* @abstract
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {WriteOptions} [opt_options] Write options.
* @return {string|ArrayBuffer} Result.
*/
FeatureFormat.prototype.writeGeometry = function (geometry, opt_options) {
return abstract();
};
return FeatureFormat;
}());
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.
* @return {import("../geom/Geometry.js").default} Transformed geometry.
*/
export function transformGeometryWithOptions(geometry, write, opt_options) {
var featureProjection = opt_options
? getProjection(opt_options.featureProjection)
: null;
var dataProjection = opt_options
? getProjection(opt_options.dataProjection)
: null;
var transformed;
if (featureProjection &&
dataProjection &&
!equivalentProjection(featureProjection, dataProjection)) {
transformed = (write ? geometry.clone() : geometry).transform(write ? featureProjection : dataProjection, write ? dataProjection : featureProjection);
}
else {
transformed = geometry;
}
if (write &&
opt_options &&
/** @type {WriteOptions} */ (opt_options).decimals !== undefined) {
var power_1 = Math.pow(10,
/** @type {WriteOptions} */ (opt_options).decimals);
// if decimals option on write, round each coordinate appropriately
/**
* @param {Array<number>} coordinates Coordinates.
* @return {Array<number>} Transformed coordinates.
*/
var transform = function (coordinates) {
for (var i = 0, ii = coordinates.length; i < ii; ++i) {
coordinates[i] = Math.round(coordinates[i] * power_1) / power_1;
}
return coordinates;
};
if (transformed === geometry) {
transformed = geometry.clone();
}
transformed.applyTransform(transform);
}
return transformed;
}
/**
* @param {import("../extent.js").Extent} extent Extent.
* @param {ReadOptions} [opt_options] Read options.
* @return {import("../extent.js").Extent} Transformed extent.
*/
export function transformExtentWithOptions(extent, opt_options) {
var featureProjection = opt_options
? getProjection(opt_options.featureProjection)
: null;
var dataProjection = opt_options
? getProjection(opt_options.dataProjection)
: null;
if (featureProjection &&
dataProjection &&
!equivalentProjection(featureProjection, dataProjection)) {
return transformExtent(extent, dataProjection, featureProjection);
}
else {
return extent;
}
}
//# sourceMappingURL=Feature.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"Feature.js","sourceRoot":"","sources":["../src/format/Feature.js"],"names":[],"mappings":"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"}
+14
View File
@@ -0,0 +1,14 @@
export default GML;
/**
* Feature format for reading and writing data in the GML format
* version 3.1.1.
* Currently only supports GML 3.1.1 Simple Features profile.
*
* @class
* @param {import("./GMLBase.js").Options} [opt_options]
* Optional configuration object.
* @api
*/
declare const GML: typeof GML3;
import GML3 from "./GML3.js";
//# sourceMappingURL=GML.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"GML.d.ts","sourceRoot":"","sources":["../src/format/GML.js"],"names":[],"mappings":";AAKA;;;;;;;;;GASG;AACH,+BAAiB"}
+37
View File
@@ -0,0 +1,37 @@
/**
* @module ol/format/GML
*/
import GML3 from './GML3.js';
/**
* Feature format for reading and writing data in the GML format
* version 3.1.1.
* Currently only supports GML 3.1.1 Simple Features profile.
*
* @class
* @param {import("./GMLBase.js").Options} [opt_options]
* Optional configuration object.
* @api
*/
var GML = GML3;
/**
* Encode an array of features in GML 3.1.1 Simple Features.
*
* @function
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
* @return {string} Result.
* @api
*/
GML.prototype.writeFeatures;
/**
* Encode an array of features in the GML 3.1.1 format as an XML node.
*
* @function
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
* @return {Node} Node.
* @api
*/
GML.prototype.writeFeaturesNode;
export default GML;
//# sourceMappingURL=GML.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"GML.js","sourceRoot":"","sources":["../src/format/GML.js"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;;;;;;GASG;AACH,IAAM,GAAG,GAAG,IAAI,CAAC;AAEjB;;;;;;;;GAQG;AACH,GAAG,CAAC,SAAS,CAAC,aAAa,CAAC;AAE5B;;;;;;;;GAQG;AACH,GAAG,CAAC,SAAS,CAAC,iBAAiB,CAAC;AAEhC,eAAe,GAAG,CAAC"}
+238
View File
@@ -0,0 +1,238 @@
export default GML2;
/**
* @classdesc
* Feature format for reading and writing data in the GML format,
* version 2.1.2.
*
* @api
*/
declare class GML2 extends GMLBase {
/**
* @param {Node} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Array<number>|undefined} Flat coordinates.
*/
readFlatCoordinates(node: Node, objectStack: Array<any>): Array<number> | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {import("../extent.js").Extent|undefined} Envelope.
*/
readBox(node: Element, objectStack: Array<any>): import("../extent.js").Extent | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
innerBoundaryIsParser(node: Element, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
outerBoundaryIsParser(node: Element, objectStack: Array<any>): void;
/**
* @const
* @param {*} value Value.
* @param {Array<*>} objectStack Object stack.
* @param {string} [opt_nodeName] Node name.
* @return {Element|undefined} Node.
* @private
*/
private GEOMETRY_NODE_FACTORY_;
/**
* @param {Element} node Node.
* @param {import("../Feature.js").default} feature Feature.
* @param {Array<*>} objectStack Node stack.
*/
writeFeatureElement(node: Element, feature: import("../Feature.js").default, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {import("../geom/LineString.js").default} geometry LineString geometry.
* @param {Array<*>} objectStack Node stack.
*/
writeCurveOrLineString(node: Element, geometry: import("../geom/LineString.js").default, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {import("../geom/LineString.js").default} line LineString geometry.
* @param {Array<*>} objectStack Node stack.
*/
writeLineStringOrCurveMember(node: Element, line: import("../geom/LineString.js").default, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {import("../geom/MultiLineString.js").default} geometry MultiLineString geometry.
* @param {Array<*>} objectStack Node stack.
*/
writeMultiCurveOrLineString(node: Element, geometry: import("../geom/MultiLineString.js").default, objectStack: Array<any>): void;
/**
* @param {Node} node Node.
* @param {import("../geom/Geometry.js").default|import("../extent.js").Extent} geometry Geometry.
* @param {Array<*>} objectStack Node stack.
*/
writeGeometryElement(node: Node, geometry: import("../geom/Geometry.js").default | import("../extent.js").Extent, objectStack: Array<any>): void;
/**
* @param {string} namespaceURI XML namespace.
* @return {Element} coordinates node.
* @private
*/
private createCoordinatesNode_;
/**
* @param {Node} node Node.
* @param {import("../geom/LineString.js").default|import("../geom/LinearRing.js").default} value Geometry.
* @param {Array<*>} objectStack Node stack.
* @private
*/
private writeCoordinates_;
/**
* @param {Element} node Node.
* @param {import("../geom/LineString.js").default} line LineString geometry.
* @param {Array<*>} objectStack Node stack.
* @private
*/
private writeCurveSegments_;
/**
* @param {Element} node Node.
* @param {import("../geom/Polygon.js").default} geometry Polygon geometry.
* @param {Array<*>} objectStack Node stack.
*/
writeSurfaceOrPolygon(node: Element, geometry: import("../geom/Polygon.js").default, objectStack: Array<any>): void;
/**
* @param {*} value Value.
* @param {Array<*>} objectStack Object stack.
* @param {string} [opt_nodeName] Node name.
* @return {Node} Node.
* @private
*/
private RING_NODE_FACTORY_;
/**
* @param {Element} node Node.
* @param {import("../geom/Polygon.js").default} polygon Polygon geometry.
* @param {Array<*>} objectStack Node stack.
* @private
*/
private writeSurfacePatches_;
/**
* @param {Element} node Node.
* @param {import("../geom/LinearRing.js").default} ring LinearRing geometry.
* @param {Array<*>} objectStack Node stack.
*/
writeRing(node: Element, ring: import("../geom/LinearRing.js").default, objectStack: Array<any>): void;
/**
* @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.
* @return {string} The coords string.
* @private
*/
private getCoords_;
/**
* @param {Element} node Node.
* @param {import("../geom/Point.js").default} geometry Point geometry.
* @param {Array<*>} objectStack Node stack.
*/
writePoint(node: Element, geometry: import("../geom/Point.js").default, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {import("../geom/MultiPoint.js").default} geometry MultiPoint geometry.
* @param {Array<*>} objectStack Node stack.
*/
writeMultiPoint(node: Element, geometry: import("../geom/MultiPoint.js").default, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {import("../geom/Point.js").default} point Point geometry.
* @param {Array<*>} objectStack Node stack.
*/
writePointMember(node: Element, point: import("../geom/Point.js").default, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {import("../geom/LinearRing.js").default} geometry LinearRing geometry.
* @param {Array<*>} objectStack Node stack.
*/
writeLinearRing(node: Element, geometry: import("../geom/LinearRing.js").default, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {import("../geom/MultiPolygon.js").default} geometry MultiPolygon geometry.
* @param {Array<*>} objectStack Node stack.
*/
writeMultiSurfaceOrPolygon(node: Element, geometry: import("../geom/MultiPolygon.js").default, objectStack: Array<any>): void;
/**
* @param {Node} node Node.
* @param {import("../geom/Polygon.js").default} polygon Polygon geometry.
* @param {Array<*>} objectStack Node stack.
*/
writeSurfaceOrPolygonMember(node: Node, polygon: import("../geom/Polygon.js").default, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {import("../extent.js").Extent} extent Extent.
* @param {Array<*>} objectStack Node stack.
*/
writeEnvelope(node: Element, extent: import("../extent.js").Extent, objectStack: Array<any>): void;
/**
* @const
* @param {*} value Value.
* @param {Array<*>} objectStack Object stack.
* @param {string} [opt_nodeName] Node name.
* @return {Node|undefined} Node.
* @private
*/
private MULTIGEOMETRY_MEMBER_NODE_FACTORY_;
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
BOX_PARSERS_: {
[x: string]: {
[x: string]: import("../xml.js").Parser;
};
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
GEOMETRY_SERIALIZERS: {
[x: string]: {
[x: string]: import("../xml.js").Serializer;
};
};
/**
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
LINESTRINGORCURVEMEMBER_SERIALIZERS: {
[x: string]: {
[x: string]: import("../xml.js").Serializer;
};
};
/**
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
RING_SERIALIZERS: {
[x: string]: {
[x: string]: import("../xml.js").Serializer;
};
};
/**
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
POINTMEMBER_SERIALIZERS: {
[x: string]: {
[x: string]: import("../xml.js").Serializer;
};
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
SURFACEORPOLYGONMEMBER_SERIALIZERS: {
[x: string]: {
[x: string]: import("../xml.js").Serializer;
};
};
/**
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
ENVELOPE_SERIALIZERS: {
[x: string]: {
[x: string]: import("../xml.js").Serializer;
};
};
}
import GMLBase from "./GMLBase.js";
//# sourceMappingURL=GML2.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"GML2.d.ts","sourceRoot":"","sources":["../src/format/GML2.js"],"names":[],"mappings":"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"}
+641
View File
@@ -0,0 +1,641 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/format/GML2
*/
import GMLBase, { GMLNS } from './GMLBase.js';
import { OBJECT_PROPERTY_NODE_FACTORY, createElementNS, getAllTextContent, makeArrayPusher, makeChildAppender, makeReplacer, makeSimpleNodeFactory, pushParseAndPop, pushSerializeAndPop, } from '../xml.js';
import { assign } from '../obj.js';
import { createOrUpdate } from '../extent.js';
import { get as getProjection } from '../proj.js';
import { transformExtentWithOptions, transformGeometryWithOptions, } from './Feature.js';
import { writeStringTextNode } from './xsd.js';
/**
* @const
* @type {string}
*/
var schemaLocation = GMLNS + ' http://schemas.opengis.net/gml/2.1.2/feature.xsd';
/**
* @const
* @type {Object<string, string>}
*/
var MULTIGEOMETRY_TO_MEMBER_NODENAME = {
'MultiLineString': 'lineStringMember',
'MultiCurve': 'curveMember',
'MultiPolygon': 'polygonMember',
'MultiSurface': 'surfaceMember',
};
/**
* @classdesc
* Feature format for reading and writing data in the GML format,
* version 2.1.2.
*
* @api
*/
var GML2 = /** @class */ (function (_super) {
__extends(GML2, _super);
/**
* @param {import("./GMLBase.js").Options} [opt_options] Optional configuration object.
*/
function GML2(opt_options) {
var _this = this;
var options =
/** @type {import("./GMLBase.js").Options} */
(opt_options ? opt_options : {});
_this = _super.call(this, options) || this;
_this.FEATURE_COLLECTION_PARSERS[GMLNS]['featureMember'] = makeArrayPusher(_this.readFeaturesInternal);
/**
* @type {string}
*/
_this.schemaLocation = options.schemaLocation
? options.schemaLocation
: schemaLocation;
return _this;
}
/**
* @param {Node} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Array<number>|undefined} Flat coordinates.
*/
GML2.prototype.readFlatCoordinates = function (node, objectStack) {
var s = getAllTextContent(node, false).replace(/^\s*|\s*$/g, '');
var context = /** @type {import("../xml.js").NodeStackItem} */ (objectStack[0]);
var containerSrs = context['srsName'];
var axisOrientation = 'enu';
if (containerSrs) {
var proj = getProjection(containerSrs);
if (proj) {
axisOrientation = proj.getAxisOrientation();
}
}
var coordsGroups = s.trim().split(/\s+/);
var flatCoordinates = [];
for (var i = 0, ii = coordsGroups.length; i < ii; i++) {
var coords = coordsGroups[i].split(/,+/);
var x = parseFloat(coords[0]);
var y = parseFloat(coords[1]);
var z = coords.length === 3 ? parseFloat(coords[2]) : 0;
if (axisOrientation.substr(0, 2) === 'en') {
flatCoordinates.push(x, y, z);
}
else {
flatCoordinates.push(y, x, z);
}
}
return flatCoordinates;
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {import("../extent.js").Extent|undefined} Envelope.
*/
GML2.prototype.readBox = function (node, objectStack) {
/** @type {Array<number>} */
var flatCoordinates = pushParseAndPop([null], this.BOX_PARSERS_, node, objectStack, this);
return createOrUpdate(flatCoordinates[1][0], flatCoordinates[1][1], flatCoordinates[1][3], flatCoordinates[1][4]);
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
GML2.prototype.innerBoundaryIsParser = function (node, objectStack) {
/** @type {Array<number>|undefined} */
var flatLinearRing = pushParseAndPop(undefined, this.RING_PARSERS, node, objectStack, this);
if (flatLinearRing) {
var flatLinearRings =
/** @type {Array<Array<number>>} */
(objectStack[objectStack.length - 1]);
flatLinearRings.push(flatLinearRing);
}
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
GML2.prototype.outerBoundaryIsParser = function (node, objectStack) {
/** @type {Array<number>|undefined} */
var flatLinearRing = pushParseAndPop(undefined, this.RING_PARSERS, node, objectStack, this);
if (flatLinearRing) {
var flatLinearRings =
/** @type {Array<Array<number>>} */
(objectStack[objectStack.length - 1]);
flatLinearRings[0] = flatLinearRing;
}
};
/**
* @const
* @param {*} value Value.
* @param {Array<*>} objectStack Object stack.
* @param {string} [opt_nodeName] Node name.
* @return {Element|undefined} Node.
* @private
*/
GML2.prototype.GEOMETRY_NODE_FACTORY_ = function (value, objectStack, opt_nodeName) {
var context = objectStack[objectStack.length - 1];
var multiSurface = context['multiSurface'];
var surface = context['surface'];
var multiCurve = context['multiCurve'];
var nodeName;
if (!Array.isArray(value)) {
nodeName = /** @type {import("../geom/Geometry.js").default} */ (value).getType();
if (nodeName === 'MultiPolygon' && multiSurface === true) {
nodeName = 'MultiSurface';
}
else if (nodeName === 'Polygon' && surface === true) {
nodeName = 'Surface';
}
else if (nodeName === 'MultiLineString' && multiCurve === true) {
nodeName = 'MultiCurve';
}
}
else {
nodeName = 'Envelope';
}
return createElementNS('http://www.opengis.net/gml', nodeName);
};
/**
* @param {Element} node Node.
* @param {import("../Feature.js").default} feature Feature.
* @param {Array<*>} objectStack Node stack.
*/
GML2.prototype.writeFeatureElement = function (node, feature, objectStack) {
var fid = feature.getId();
if (fid) {
node.setAttribute('fid', /** @type {string} */ (fid));
}
var context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
var featureNS = context['featureNS'];
var geometryName = feature.getGeometryName();
if (!context.serializers) {
context.serializers = {};
context.serializers[featureNS] = {};
}
var keys = [];
var values = [];
if (feature.hasProperties()) {
var properties = feature.getProperties();
for (var key in properties) {
var value = properties[key];
if (value !== null) {
keys.push(key);
values.push(value);
if (key == geometryName ||
typeof ( /** @type {?} */(value).getSimplifiedGeometry) ===
'function') {
if (!(key in context.serializers[featureNS])) {
context.serializers[featureNS][key] = makeChildAppender(this.writeGeometryElement, this);
}
}
else {
if (!(key in context.serializers[featureNS])) {
context.serializers[featureNS][key] =
makeChildAppender(writeStringTextNode);
}
}
}
}
}
var item = assign({}, context);
item.node = node;
pushSerializeAndPop(
/** @type {import("../xml.js").NodeStackItem} */
(item), context.serializers, makeSimpleNodeFactory(undefined, featureNS), values, objectStack, keys);
};
/**
* @param {Element} node Node.
* @param {import("../geom/LineString.js").default} geometry LineString geometry.
* @param {Array<*>} objectStack Node stack.
*/
GML2.prototype.writeCurveOrLineString = function (node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var srsName = context['srsName'];
if (node.nodeName !== 'LineStringSegment' && srsName) {
node.setAttribute('srsName', srsName);
}
if (node.nodeName === 'LineString' ||
node.nodeName === 'LineStringSegment') {
var coordinates = this.createCoordinatesNode_(node.namespaceURI);
node.appendChild(coordinates);
this.writeCoordinates_(coordinates, geometry, objectStack);
}
else if (node.nodeName === 'Curve') {
var segments = createElementNS(node.namespaceURI, 'segments');
node.appendChild(segments);
this.writeCurveSegments_(segments, geometry, objectStack);
}
};
/**
* @param {Element} node Node.
* @param {import("../geom/LineString.js").default} line LineString geometry.
* @param {Array<*>} objectStack Node stack.
*/
GML2.prototype.writeLineStringOrCurveMember = function (node, line, objectStack) {
var child = this.GEOMETRY_NODE_FACTORY_(line, objectStack);
if (child) {
node.appendChild(child);
this.writeCurveOrLineString(child, line, objectStack);
}
};
/**
* @param {Element} node Node.
* @param {import("../geom/MultiLineString.js").default} geometry MultiLineString geometry.
* @param {Array<*>} objectStack Node stack.
*/
GML2.prototype.writeMultiCurveOrLineString = function (node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var hasZ = context['hasZ'];
var srsName = context['srsName'];
var curve = context['curve'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var lines = geometry.getLineStrings();
pushSerializeAndPop({ node: node, hasZ: hasZ, srsName: srsName, curve: curve }, this.LINESTRINGORCURVEMEMBER_SERIALIZERS, this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, lines, objectStack, undefined, this);
};
/**
* @param {Node} node Node.
* @param {import("../geom/Geometry.js").default|import("../extent.js").Extent} geometry Geometry.
* @param {Array<*>} objectStack Node stack.
*/
GML2.prototype.writeGeometryElement = function (node, geometry, objectStack) {
var context = /** @type {import("./Feature.js").WriteOptions} */ (objectStack[objectStack.length - 1]);
var item = assign({}, context);
item['node'] = node;
var value;
if (Array.isArray(geometry)) {
value = transformExtentWithOptions(
/** @type {import("../extent.js").Extent} */ (geometry), context);
}
else {
value = transformGeometryWithOptions(
/** @type {import("../geom/Geometry.js").default} */ (geometry), true, context);
}
pushSerializeAndPop(
/** @type {import("../xml.js").NodeStackItem} */
(item), this.GEOMETRY_SERIALIZERS, this.GEOMETRY_NODE_FACTORY_, [value], objectStack, undefined, this);
};
/**
* @param {string} namespaceURI XML namespace.
* @return {Element} coordinates node.
* @private
*/
GML2.prototype.createCoordinatesNode_ = function (namespaceURI) {
var coordinates = createElementNS(namespaceURI, 'coordinates');
coordinates.setAttribute('decimal', '.');
coordinates.setAttribute('cs', ',');
coordinates.setAttribute('ts', ' ');
return coordinates;
};
/**
* @param {Node} node Node.
* @param {import("../geom/LineString.js").default|import("../geom/LinearRing.js").default} value Geometry.
* @param {Array<*>} objectStack Node stack.
* @private
*/
GML2.prototype.writeCoordinates_ = function (node, value, objectStack) {
var context = objectStack[objectStack.length - 1];
var hasZ = context['hasZ'];
var srsName = context['srsName'];
// only 2d for simple features profile
var points = value.getCoordinates();
var len = points.length;
var parts = new Array(len);
for (var i = 0; i < len; ++i) {
var point = points[i];
parts[i] = this.getCoords_(point, srsName, hasZ);
}
writeStringTextNode(node, parts.join(' '));
};
/**
* @param {Element} node Node.
* @param {import("../geom/LineString.js").default} line LineString geometry.
* @param {Array<*>} objectStack Node stack.
* @private
*/
GML2.prototype.writeCurveSegments_ = function (node, line, objectStack) {
var child = createElementNS(node.namespaceURI, 'LineStringSegment');
node.appendChild(child);
this.writeCurveOrLineString(child, line, objectStack);
};
/**
* @param {Element} node Node.
* @param {import("../geom/Polygon.js").default} geometry Polygon geometry.
* @param {Array<*>} objectStack Node stack.
*/
GML2.prototype.writeSurfaceOrPolygon = function (node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var hasZ = context['hasZ'];
var srsName = context['srsName'];
if (node.nodeName !== 'PolygonPatch' && srsName) {
node.setAttribute('srsName', srsName);
}
if (node.nodeName === 'Polygon' || node.nodeName === 'PolygonPatch') {
var rings = geometry.getLinearRings();
pushSerializeAndPop({ node: node, hasZ: hasZ, srsName: srsName }, this.RING_SERIALIZERS, this.RING_NODE_FACTORY_, rings, objectStack, undefined, this);
}
else if (node.nodeName === 'Surface') {
var patches = createElementNS(node.namespaceURI, 'patches');
node.appendChild(patches);
this.writeSurfacePatches_(patches, geometry, objectStack);
}
};
/**
* @param {*} value Value.
* @param {Array<*>} objectStack Object stack.
* @param {string} [opt_nodeName] Node name.
* @return {Node} Node.
* @private
*/
GML2.prototype.RING_NODE_FACTORY_ = function (value, objectStack, opt_nodeName) {
var context = objectStack[objectStack.length - 1];
var parentNode = context.node;
var exteriorWritten = context['exteriorWritten'];
if (exteriorWritten === undefined) {
context['exteriorWritten'] = true;
}
return createElementNS(parentNode.namespaceURI, exteriorWritten !== undefined ? 'innerBoundaryIs' : 'outerBoundaryIs');
};
/**
* @param {Element} node Node.
* @param {import("../geom/Polygon.js").default} polygon Polygon geometry.
* @param {Array<*>} objectStack Node stack.
* @private
*/
GML2.prototype.writeSurfacePatches_ = function (node, polygon, objectStack) {
var child = createElementNS(node.namespaceURI, 'PolygonPatch');
node.appendChild(child);
this.writeSurfaceOrPolygon(child, polygon, objectStack);
};
/**
* @param {Element} node Node.
* @param {import("../geom/LinearRing.js").default} ring LinearRing geometry.
* @param {Array<*>} objectStack Node stack.
*/
GML2.prototype.writeRing = function (node, ring, objectStack) {
var linearRing = createElementNS(node.namespaceURI, 'LinearRing');
node.appendChild(linearRing);
this.writeLinearRing(linearRing, ring, objectStack);
};
/**
* @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.
* @return {string} The coords string.
* @private
*/
GML2.prototype.getCoords_ = function (point, opt_srsName, opt_hasZ) {
var axisOrientation = 'enu';
if (opt_srsName) {
axisOrientation = getProjection(opt_srsName).getAxisOrientation();
}
var coords = axisOrientation.substr(0, 2) === 'en'
? point[0] + ',' + point[1]
: point[1] + ',' + point[0];
if (opt_hasZ) {
// For newly created points, Z can be undefined.
var z = point[2] || 0;
coords += ',' + z;
}
return coords;
};
/**
* @param {Element} node Node.
* @param {import("../geom/Point.js").default} geometry Point geometry.
* @param {Array<*>} objectStack Node stack.
*/
GML2.prototype.writePoint = function (node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var hasZ = context['hasZ'];
var srsName = context['srsName'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var coordinates = this.createCoordinatesNode_(node.namespaceURI);
node.appendChild(coordinates);
var point = geometry.getCoordinates();
var coord = this.getCoords_(point, srsName, hasZ);
writeStringTextNode(coordinates, coord);
};
/**
* @param {Element} node Node.
* @param {import("../geom/MultiPoint.js").default} geometry MultiPoint geometry.
* @param {Array<*>} objectStack Node stack.
*/
GML2.prototype.writeMultiPoint = function (node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var hasZ = context['hasZ'];
var srsName = context['srsName'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var points = geometry.getPoints();
pushSerializeAndPop({ node: node, hasZ: hasZ, srsName: srsName }, this.POINTMEMBER_SERIALIZERS, makeSimpleNodeFactory('pointMember'), points, objectStack, undefined, this);
};
/**
* @param {Element} node Node.
* @param {import("../geom/Point.js").default} point Point geometry.
* @param {Array<*>} objectStack Node stack.
*/
GML2.prototype.writePointMember = function (node, point, objectStack) {
var child = createElementNS(node.namespaceURI, 'Point');
node.appendChild(child);
this.writePoint(child, point, objectStack);
};
/**
* @param {Element} node Node.
* @param {import("../geom/LinearRing.js").default} geometry LinearRing geometry.
* @param {Array<*>} objectStack Node stack.
*/
GML2.prototype.writeLinearRing = function (node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var srsName = context['srsName'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var coordinates = this.createCoordinatesNode_(node.namespaceURI);
node.appendChild(coordinates);
this.writeCoordinates_(coordinates, geometry, objectStack);
};
/**
* @param {Element} node Node.
* @param {import("../geom/MultiPolygon.js").default} geometry MultiPolygon geometry.
* @param {Array<*>} objectStack Node stack.
*/
GML2.prototype.writeMultiSurfaceOrPolygon = function (node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var hasZ = context['hasZ'];
var srsName = context['srsName'];
var surface = context['surface'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var polygons = geometry.getPolygons();
pushSerializeAndPop({ node: node, hasZ: hasZ, srsName: srsName, surface: surface }, this.SURFACEORPOLYGONMEMBER_SERIALIZERS, this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, polygons, objectStack, undefined, this);
};
/**
* @param {Node} node Node.
* @param {import("../geom/Polygon.js").default} polygon Polygon geometry.
* @param {Array<*>} objectStack Node stack.
*/
GML2.prototype.writeSurfaceOrPolygonMember = function (node, polygon, objectStack) {
var child = this.GEOMETRY_NODE_FACTORY_(polygon, objectStack);
if (child) {
node.appendChild(child);
this.writeSurfaceOrPolygon(child, polygon, objectStack);
}
};
/**
* @param {Element} node Node.
* @param {import("../extent.js").Extent} extent Extent.
* @param {Array<*>} objectStack Node stack.
*/
GML2.prototype.writeEnvelope = function (node, extent, objectStack) {
var context = objectStack[objectStack.length - 1];
var srsName = context['srsName'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var keys = ['lowerCorner', 'upperCorner'];
var values = [extent[0] + ' ' + extent[1], extent[2] + ' ' + extent[3]];
pushSerializeAndPop(
/** @type {import("../xml.js").NodeStackItem} */
({ node: node }), this.ENVELOPE_SERIALIZERS, OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, keys, this);
};
/**
* @const
* @param {*} value Value.
* @param {Array<*>} objectStack Object stack.
* @param {string} [opt_nodeName] Node name.
* @return {Node|undefined} Node.
* @private
*/
GML2.prototype.MULTIGEOMETRY_MEMBER_NODE_FACTORY_ = function (value, objectStack, opt_nodeName) {
var parentNode = objectStack[objectStack.length - 1].node;
return createElementNS('http://www.opengis.net/gml', MULTIGEOMETRY_TO_MEMBER_NODENAME[parentNode.nodeName]);
};
return GML2;
}(GMLBase));
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML2.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS = {
'http://www.opengis.net/gml': {
'coordinates': makeReplacer(GML2.prototype.readFlatCoordinates),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML2.prototype.FLAT_LINEAR_RINGS_PARSERS = {
'http://www.opengis.net/gml': {
'innerBoundaryIs': GML2.prototype.innerBoundaryIsParser,
'outerBoundaryIs': GML2.prototype.outerBoundaryIsParser,
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML2.prototype.BOX_PARSERS_ = {
'http://www.opengis.net/gml': {
'coordinates': makeArrayPusher(GML2.prototype.readFlatCoordinates),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML2.prototype.GEOMETRY_PARSERS = {
'http://www.opengis.net/gml': {
'Point': makeReplacer(GMLBase.prototype.readPoint),
'MultiPoint': makeReplacer(GMLBase.prototype.readMultiPoint),
'LineString': makeReplacer(GMLBase.prototype.readLineString),
'MultiLineString': makeReplacer(GMLBase.prototype.readMultiLineString),
'LinearRing': makeReplacer(GMLBase.prototype.readLinearRing),
'Polygon': makeReplacer(GMLBase.prototype.readPolygon),
'MultiPolygon': makeReplacer(GMLBase.prototype.readMultiPolygon),
'Box': makeReplacer(GML2.prototype.readBox),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
GML2.prototype.GEOMETRY_SERIALIZERS = {
'http://www.opengis.net/gml': {
'Curve': makeChildAppender(GML2.prototype.writeCurveOrLineString),
'MultiCurve': makeChildAppender(GML2.prototype.writeMultiCurveOrLineString),
'Point': makeChildAppender(GML2.prototype.writePoint),
'MultiPoint': makeChildAppender(GML2.prototype.writeMultiPoint),
'LineString': makeChildAppender(GML2.prototype.writeCurveOrLineString),
'MultiLineString': makeChildAppender(GML2.prototype.writeMultiCurveOrLineString),
'LinearRing': makeChildAppender(GML2.prototype.writeLinearRing),
'Polygon': makeChildAppender(GML2.prototype.writeSurfaceOrPolygon),
'MultiPolygon': makeChildAppender(GML2.prototype.writeMultiSurfaceOrPolygon),
'Surface': makeChildAppender(GML2.prototype.writeSurfaceOrPolygon),
'MultiSurface': makeChildAppender(GML2.prototype.writeMultiSurfaceOrPolygon),
'Envelope': makeChildAppender(GML2.prototype.writeEnvelope),
},
};
/**
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
GML2.prototype.LINESTRINGORCURVEMEMBER_SERIALIZERS = {
'http://www.opengis.net/gml': {
'lineStringMember': makeChildAppender(GML2.prototype.writeLineStringOrCurveMember),
'curveMember': makeChildAppender(GML2.prototype.writeLineStringOrCurveMember),
},
};
/**
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
GML2.prototype.RING_SERIALIZERS = {
'http://www.opengis.net/gml': {
'outerBoundaryIs': makeChildAppender(GML2.prototype.writeRing),
'innerBoundaryIs': makeChildAppender(GML2.prototype.writeRing),
},
};
/**
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
GML2.prototype.POINTMEMBER_SERIALIZERS = {
'http://www.opengis.net/gml': {
'pointMember': makeChildAppender(GML2.prototype.writePointMember),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
GML2.prototype.SURFACEORPOLYGONMEMBER_SERIALIZERS = {
'http://www.opengis.net/gml': {
'surfaceMember': makeChildAppender(GML2.prototype.writeSurfaceOrPolygonMember),
'polygonMember': makeChildAppender(GML2.prototype.writeSurfaceOrPolygonMember),
},
};
/**
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
GML2.prototype.ENVELOPE_SERIALIZERS = {
'http://www.opengis.net/gml': {
'lowerCorner': makeChildAppender(writeStringTextNode),
'upperCorner': makeChildAppender(writeStringTextNode),
},
};
export default GML2;
//# sourceMappingURL=GML2.js.map
+1
View File
File diff suppressed because one or more lines are too long
+425
View File
@@ -0,0 +1,425 @@
export default GML3;
/**
* @classdesc
* Feature format for reading and writing data in the GML format
* version 3.1.1.
* Currently only supports GML 3.1.1 Simple Features profile.
*
* @api
*/
declare class GML3 extends GMLBase {
/**
* @private
* @type {boolean}
*/
private surface_;
/**
* @private
* @type {boolean}
*/
private curve_;
/**
* @private
* @type {boolean}
*/
private multiCurve_;
/**
* @private
* @type {boolean}
*/
private multiSurface_;
/**
* @private
* @type {boolean}
*/
private hasZ;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {MultiLineString|undefined} MultiLineString.
*/
readMultiCurve(node: Element, objectStack: Array<any>): MultiLineString | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Array<number>|undefined} Polygon.
*/
readFlatCurveRing(node: Element, objectStack: Array<any>): Array<number> | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {MultiPolygon|undefined} MultiPolygon.
*/
readMultiSurface(node: Element, objectStack: Array<any>): MultiPolygon | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
curveMemberParser(node: Element, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
surfaceMemberParser(node: Element, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Array<(Array<number>)>|undefined} flat coordinates.
*/
readPatch(node: Element, objectStack: Array<any>): Array<(Array<number>)> | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Array<number>|undefined} flat coordinates.
*/
readSegment(node: Element, objectStack: Array<any>): Array<number> | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Array<(Array<number>)>|undefined} flat coordinates.
*/
readPolygonPatch(node: Element, objectStack: Array<any>): Array<(Array<number>)> | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Array<number>|undefined} flat coordinates.
*/
readLineStringSegment(node: Element, objectStack: Array<any>): Array<number> | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
interiorParser(node: Element, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
exteriorParser(node: Element, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Polygon|undefined} Polygon.
*/
readSurface(node: Element, objectStack: Array<any>): Polygon | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {LineString|undefined} LineString.
*/
readCurve(node: Element, objectStack: Array<any>): LineString | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {import("../extent.js").Extent|undefined} Envelope.
*/
readEnvelope(node: Element, objectStack: Array<any>): import("../extent.js").Extent | undefined;
/**
* @param {Node} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Array<number>|undefined} Flat coordinates.
*/
readFlatPos(node: Node, objectStack: Array<any>): Array<number> | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Array<number>|undefined} Flat coordinates.
*/
readFlatPosList(node: Element, objectStack: Array<any>): Array<number> | undefined;
/**
* @param {Element} node Node.
* @param {import("../geom/Point.js").default} value Point geometry.
* @param {Array<*>} objectStack Node stack.
* @private
*/
private writePos_;
/**
* @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.
* @return {string} The coords string.
* @private
*/
private getCoords_;
/**
* @param {Element} node Node.
* @param {LineString|import("../geom/LinearRing.js").default} value Geometry.
* @param {Array<*>} objectStack Node stack.
* @private
*/
private writePosList_;
/**
* @param {Element} node Node.
* @param {import("../geom/Point.js").default} geometry Point geometry.
* @param {Array<*>} objectStack Node stack.
*/
writePoint(node: Element, geometry: import("../geom/Point.js").default, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {import("../extent.js").Extent} extent Extent.
* @param {Array<*>} objectStack Node stack.
*/
writeEnvelope(node: Element, extent: import("../extent.js").Extent, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {import("../geom/LinearRing.js").default} geometry LinearRing geometry.
* @param {Array<*>} objectStack Node stack.
*/
writeLinearRing(node: Element, geometry: import("../geom/LinearRing.js").default, objectStack: Array<any>): void;
/**
* @param {*} value Value.
* @param {Array<*>} objectStack Object stack.
* @param {string} [opt_nodeName] Node name.
* @return {Node} Node.
* @private
*/
private RING_NODE_FACTORY_;
/**
* @param {Element} node Node.
* @param {Polygon} geometry Polygon geometry.
* @param {Array<*>} objectStack Node stack.
*/
writeSurfaceOrPolygon(node: Element, geometry: Polygon, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {LineString} geometry LineString geometry.
* @param {Array<*>} objectStack Node stack.
*/
writeCurveOrLineString(node: Element, geometry: LineString, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {MultiPolygon} geometry MultiPolygon geometry.
* @param {Array<*>} objectStack Node stack.
*/
writeMultiSurfaceOrPolygon(node: Element, geometry: MultiPolygon, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {import("../geom/MultiPoint.js").default} geometry MultiPoint geometry.
* @param {Array<*>} objectStack Node stack.
*/
writeMultiPoint(node: Element, geometry: import("../geom/MultiPoint.js").default, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {MultiLineString} geometry MultiLineString geometry.
* @param {Array<*>} objectStack Node stack.
*/
writeMultiCurveOrLineString(node: Element, geometry: MultiLineString, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {import("../geom/LinearRing.js").default} ring LinearRing geometry.
* @param {Array<*>} objectStack Node stack.
*/
writeRing(node: Element, ring: import("../geom/LinearRing.js").default, objectStack: Array<any>): void;
/**
* @param {Node} node Node.
* @param {Polygon} polygon Polygon geometry.
* @param {Array<*>} objectStack Node stack.
*/
writeSurfaceOrPolygonMember(node: Node, polygon: Polygon, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {import("../geom/Point.js").default} point Point geometry.
* @param {Array<*>} objectStack Node stack.
*/
writePointMember(node: Element, point: import("../geom/Point.js").default, objectStack: Array<any>): void;
/**
* @param {Node} node Node.
* @param {LineString} line LineString geometry.
* @param {Array<*>} objectStack Node stack.
*/
writeLineStringOrCurveMember(node: Node, line: LineString, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {Polygon} polygon Polygon geometry.
* @param {Array<*>} objectStack Node stack.
* @private
*/
private writeSurfacePatches_;
/**
* @param {Element} node Node.
* @param {LineString} line LineString geometry.
* @param {Array<*>} objectStack Node stack.
* @private
*/
private writeCurveSegments_;
/**
* @param {Node} node Node.
* @param {import("../geom/Geometry.js").default|import("../extent.js").Extent} geometry Geometry.
* @param {Array<*>} objectStack Node stack.
*/
writeGeometryElement(node: Node, geometry: import("../geom/Geometry.js").default | import("../extent.js").Extent, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {import("../Feature.js").default} feature Feature.
* @param {Array<*>} objectStack Node stack.
*/
writeFeatureElement(node: Element, feature: import("../Feature.js").default, objectStack: Array<any>): void;
/**
* @param {Node} node Node.
* @param {Array<import("../Feature.js").default>} features Features.
* @param {Array<*>} objectStack Node stack.
* @private
*/
private writeFeatureMembers_;
/**
* @const
* @param {*} value Value.
* @param {Array<*>} objectStack Object stack.
* @param {string} [opt_nodeName] Node name.
* @return {Node|undefined} Node.
* @private
*/
private MULTIGEOMETRY_MEMBER_NODE_FACTORY_;
/**
* @const
* @param {*} value Value.
* @param {Array<*>} objectStack Object stack.
* @param {string} [opt_nodeName] Node name.
* @return {Element|undefined} Node.
* @private
*/
private GEOMETRY_NODE_FACTORY_;
/**
* 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.
* @return {Element} Node.
* @api
*/
writeFeaturesNode(features: Array<import("../Feature.js").default>, opt_options?: import("./Feature.js").WriteOptions | undefined): Element;
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
MULTICURVE_PARSERS: {
[x: string]: {
[x: string]: import("../xml.js").Parser;
};
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
MULTISURFACE_PARSERS: {
[x: string]: {
[x: string]: import("../xml.js").Parser;
};
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
CURVEMEMBER_PARSERS: {
[x: string]: {
[x: string]: import("../xml.js").Parser;
};
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
SURFACEMEMBER_PARSERS: {
[x: string]: {
[x: string]: import("../xml.js").Parser;
};
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
SURFACE_PARSERS: {
[x: string]: {
[x: string]: import("../xml.js").Parser;
};
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
CURVE_PARSERS: {
[x: string]: {
[x: string]: import("../xml.js").Parser;
};
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
ENVELOPE_PARSERS: {
[x: string]: {
[x: string]: import("../xml.js").Parser;
};
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
PATCHES_PARSERS: {
[x: string]: {
[x: string]: import("../xml.js").Parser;
};
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
SEGMENTS_PARSERS: {
[x: string]: {
[x: string]: import("../xml.js").Parser;
};
};
/**
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
RING_SERIALIZERS: {
[x: string]: {
[x: string]: import("../xml.js").Serializer;
};
};
/**
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
ENVELOPE_SERIALIZERS: {
[x: string]: {
[x: string]: import("../xml.js").Serializer;
};
};
/**
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
SURFACEORPOLYGONMEMBER_SERIALIZERS: {
[x: string]: {
[x: string]: import("../xml.js").Serializer;
};
};
/**
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
POINTMEMBER_SERIALIZERS: {
[x: string]: {
[x: string]: import("../xml.js").Serializer;
};
};
/**
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
LINESTRINGORCURVEMEMBER_SERIALIZERS: {
[x: string]: {
[x: string]: import("../xml.js").Serializer;
};
};
/**
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
GEOMETRY_SERIALIZERS: {
[x: string]: {
[x: string]: import("../xml.js").Serializer;
};
};
}
import GMLBase from "./GMLBase.js";
import MultiLineString from "../geom/MultiLineString.js";
import MultiPolygon from "../geom/MultiPolygon.js";
import Polygon from "../geom/Polygon.js";
import LineString from "../geom/LineString.js";
//# sourceMappingURL=GML3.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"GML3.d.ts","sourceRoot":"","sources":["../src/format/GML3.js"],"names":[],"mappings":"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"}
+1061
View File
File diff suppressed because it is too large Load Diff
+1
View File
File diff suppressed because one or more lines are too long
+10
View File
@@ -0,0 +1,10 @@
export default GML32;
/**
* @classdesc Feature format for reading and writing data in the GML format
* version 3.2.1.
* @api
*/
declare class GML32 extends GML3 {
}
import GML3 from "./GML3.js";
//# sourceMappingURL=GML32.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"GML32.d.ts","sourceRoot":"","sources":["../src/format/GML32.js"],"names":[],"mappings":";AAcA;;;;GAIG;AACH;CAkBC"}
+307
View File
@@ -0,0 +1,307 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/format/GML32
*/
import GML2 from './GML2.js';
import GML3 from './GML3.js';
import GMLBase from './GMLBase.js';
import { makeArrayExtender, makeArrayPusher, makeChildAppender, makeReplacer, } from '../xml.js';
import { writeStringTextNode } from '../format/xsd.js';
/**
* @classdesc Feature format for reading and writing data in the GML format
* version 3.2.1.
* @api
*/
var GML32 = /** @class */ (function (_super) {
__extends(GML32, _super);
/**
* @param {import("./GMLBase.js").Options} [opt_options] Optional configuration object.
*/
function GML32(opt_options) {
var _this = this;
var options = /** @type {import("./GMLBase.js").Options} */ (opt_options ? opt_options : {});
_this = _super.call(this, options) || this;
/**
* @type {string}
*/
_this.schemaLocation = options.schemaLocation
? options.schemaLocation
: _this.namespace + ' http://schemas.opengis.net/gml/3.2.1/gml.xsd';
return _this;
}
return GML32;
}(GML3));
GML32.prototype.namespace = 'http://www.opengis.net/gml/3.2';
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
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),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML32.prototype.FLAT_LINEAR_RINGS_PARSERS = {
'http://www.opengis.net/gml/3.2': {
'interior': GML3.prototype.interiorParser,
'exterior': GML3.prototype.exteriorParser,
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML32.prototype.GEOMETRY_PARSERS = {
'http://www.opengis.net/gml/3.2': {
'Point': makeReplacer(GMLBase.prototype.readPoint),
'MultiPoint': makeReplacer(GMLBase.prototype.readMultiPoint),
'LineString': makeReplacer(GMLBase.prototype.readLineString),
'MultiLineString': makeReplacer(GMLBase.prototype.readMultiLineString),
'LinearRing': makeReplacer(GMLBase.prototype.readLinearRing),
'Polygon': makeReplacer(GMLBase.prototype.readPolygon),
'MultiPolygon': makeReplacer(GMLBase.prototype.readMultiPolygon),
'Surface': makeReplacer(GML32.prototype.readSurface),
'MultiSurface': makeReplacer(GML3.prototype.readMultiSurface),
'Curve': makeReplacer(GML32.prototype.readCurve),
'MultiCurve': makeReplacer(GML3.prototype.readMultiCurve),
'Envelope': makeReplacer(GML32.prototype.readEnvelope),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML32.prototype.MULTICURVE_PARSERS = {
'http://www.opengis.net/gml/3.2': {
'curveMember': makeArrayPusher(GML3.prototype.curveMemberParser),
'curveMembers': makeArrayPusher(GML3.prototype.curveMemberParser),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML32.prototype.MULTISURFACE_PARSERS = {
'http://www.opengis.net/gml/3.2': {
'surfaceMember': makeArrayPusher(GML3.prototype.surfaceMemberParser),
'surfaceMembers': makeArrayPusher(GML3.prototype.surfaceMemberParser),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML32.prototype.CURVEMEMBER_PARSERS = {
'http://www.opengis.net/gml/3.2': {
'LineString': makeArrayPusher(GMLBase.prototype.readLineString),
'Curve': makeArrayPusher(GML3.prototype.readCurve),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML32.prototype.SURFACEMEMBER_PARSERS = {
'http://www.opengis.net/gml/3.2': {
'Polygon': makeArrayPusher(GMLBase.prototype.readPolygon),
'Surface': makeArrayPusher(GML3.prototype.readSurface),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML32.prototype.SURFACE_PARSERS = {
'http://www.opengis.net/gml/3.2': {
'patches': makeReplacer(GML3.prototype.readPatch),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML32.prototype.CURVE_PARSERS = {
'http://www.opengis.net/gml/3.2': {
'segments': makeReplacer(GML3.prototype.readSegment),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML32.prototype.ENVELOPE_PARSERS = {
'http://www.opengis.net/gml/3.2': {
'lowerCorner': makeArrayPusher(GML3.prototype.readFlatPosList),
'upperCorner': makeArrayPusher(GML3.prototype.readFlatPosList),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML32.prototype.PATCHES_PARSERS = {
'http://www.opengis.net/gml/3.2': {
'PolygonPatch': makeReplacer(GML3.prototype.readPolygonPatch),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML32.prototype.SEGMENTS_PARSERS = {
'http://www.opengis.net/gml/3.2': {
'LineStringSegment': makeArrayExtender(GML3.prototype.readLineStringSegment),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML32.prototype.MULTIPOINT_PARSERS = {
'http://www.opengis.net/gml/3.2': {
'pointMember': makeArrayPusher(GMLBase.prototype.pointMemberParser),
'pointMembers': makeArrayPusher(GMLBase.prototype.pointMemberParser),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML32.prototype.MULTILINESTRING_PARSERS = {
'http://www.opengis.net/gml/3.2': {
'lineStringMember': makeArrayPusher(GMLBase.prototype.lineStringMemberParser),
'lineStringMembers': makeArrayPusher(GMLBase.prototype.lineStringMemberParser),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML32.prototype.MULTIPOLYGON_PARSERS = {
'http://www.opengis.net/gml/3.2': {
'polygonMember': makeArrayPusher(GMLBase.prototype.polygonMemberParser),
'polygonMembers': makeArrayPusher(GMLBase.prototype.polygonMemberParser),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML32.prototype.POINTMEMBER_PARSERS = {
'http://www.opengis.net/gml/3.2': {
'Point': makeArrayPusher(GMLBase.prototype.readFlatCoordinatesFromNode),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML32.prototype.LINESTRINGMEMBER_PARSERS = {
'http://www.opengis.net/gml/3.2': {
'LineString': makeArrayPusher(GMLBase.prototype.readLineString),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML32.prototype.POLYGONMEMBER_PARSERS = {
'http://www.opengis.net/gml/3.2': {
'Polygon': makeArrayPusher(GMLBase.prototype.readPolygon),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GML32.prototype.RING_PARSERS = {
'http://www.opengis.net/gml/3.2': {
'LinearRing': makeReplacer(GMLBase.prototype.readFlatLinearRing),
'Ring': makeReplacer(GML32.prototype.readFlatCurveRing),
},
};
/**
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
GML32.prototype.RING_SERIALIZERS = {
'http://www.opengis.net/gml/3.2': {
'exterior': makeChildAppender(GML3.prototype.writeRing),
'interior': makeChildAppender(GML3.prototype.writeRing),
},
};
/**
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
GML32.prototype.ENVELOPE_SERIALIZERS = {
'http://www.opengis.net/gml/3.2': {
'lowerCorner': makeChildAppender(writeStringTextNode),
'upperCorner': makeChildAppender(writeStringTextNode),
},
};
/**
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
GML32.prototype.SURFACEORPOLYGONMEMBER_SERIALIZERS = {
'http://www.opengis.net/gml/3.2': {
'surfaceMember': makeChildAppender(GML3.prototype.writeSurfaceOrPolygonMember),
'polygonMember': makeChildAppender(GML3.prototype.writeSurfaceOrPolygonMember),
},
};
/**
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
GML32.prototype.POINTMEMBER_SERIALIZERS = {
'http://www.opengis.net/gml/3.2': {
'pointMember': makeChildAppender(GML3.prototype.writePointMember),
},
};
/**
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
GML32.prototype.LINESTRINGORCURVEMEMBER_SERIALIZERS = {
'http://www.opengis.net/gml/3.2': {
'lineStringMember': makeChildAppender(GML3.prototype.writeLineStringOrCurveMember),
'curveMember': makeChildAppender(GML3.prototype.writeLineStringOrCurveMember),
},
};
/**
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
GML32.prototype.GEOMETRY_SERIALIZERS = {
'http://www.opengis.net/gml/3.2': {
'Curve': makeChildAppender(GML3.prototype.writeCurveOrLineString),
'MultiCurve': makeChildAppender(GML3.prototype.writeMultiCurveOrLineString),
'Point': makeChildAppender(GML32.prototype.writePoint),
'MultiPoint': makeChildAppender(GML3.prototype.writeMultiPoint),
'LineString': makeChildAppender(GML3.prototype.writeCurveOrLineString),
'MultiLineString': makeChildAppender(GML3.prototype.writeMultiCurveOrLineString),
'LinearRing': makeChildAppender(GML3.prototype.writeLinearRing),
'Polygon': makeChildAppender(GML3.prototype.writeSurfaceOrPolygon),
'MultiPolygon': makeChildAppender(GML3.prototype.writeMultiSurfaceOrPolygon),
'Surface': makeChildAppender(GML3.prototype.writeSurfaceOrPolygon),
'MultiSurface': makeChildAppender(GML3.prototype.writeMultiSurfaceOrPolygon),
'Envelope': makeChildAppender(GML3.prototype.writeEnvelope),
},
};
export default GML32;
//# sourceMappingURL=GML32.js.map
+1
View File
File diff suppressed because one or more lines are too long
+350
View File
@@ -0,0 +1,350 @@
/**
* @const
* @type {string}
*/
export const GMLNS: string;
export default GMLBase;
export type Options = {
/**
* Feature
* namespace. If not defined will be derived from GML. If multiple
* feature types have been configured which come from different feature
* namespaces, this will be an object with the keys being the prefixes used
* in the entries of featureType array. The values of the object will be the
* feature namespaces themselves. So for instance there might be a featureType
* item `topp:states` in the `featureType` array and then there will be a key
* `topp` in the featureNS object with value `http://www.openplans.org/topp`.
*/
featureNS?: string | {
[x: string]: string;
} | undefined;
/**
* Feature type(s) to parse.
* If multiple feature types need to be configured
* which come from different feature namespaces, `featureNS` will be an object
* with the keys being the prefixes used in the entries of featureType array.
* The values of the object will be the feature namespaces themselves.
* So for instance there might be a featureType item `topp:states` and then
* there will be a key named `topp` in the featureNS object with value
* `http://www.openplans.org/topp`.
*/
featureType?: string | string[] | undefined;
/**
* srsName to use when writing geometries.
*/
srsName: string;
/**
* Write gml:Surface instead of gml:Polygon
* elements. This also affects the elements in multi-part geometries.
*/
surface?: boolean | undefined;
/**
* Write gml:Curve instead of gml:LineString
* elements. This also affects the elements in multi-part geometries.
*/
curve?: boolean | undefined;
/**
* Write gml:MultiCurve instead of gml:MultiLineString.
* Since the latter is deprecated in GML 3.
*/
multiCurve?: boolean | undefined;
/**
* Write gml:multiSurface instead of
* gml:MultiPolygon. Since the latter is deprecated in GML 3.
*/
multiSurface?: boolean | undefined;
/**
* Optional schemaLocation to use when
* writing out the GML, this will override the default provided.
*/
schemaLocation?: string | undefined;
/**
* If coordinates have a Z value.
*/
hasZ?: boolean | undefined;
};
/**
* @typedef {Object} Options
* @property {Object<string, string>|string} [featureNS] Feature
* namespace. If not defined will be derived from GML. If multiple
* feature types have been configured which come from different feature
* namespaces, this will be an object with the keys being the prefixes used
* in the entries of featureType array. The values of the object will be the
* feature namespaces themselves. So for instance there might be a featureType
* item `topp:states` in the `featureType` array and then there will be a key
* `topp` in the featureNS object with value `http://www.openplans.org/topp`.
* @property {Array<string>|string} [featureType] Feature type(s) to parse.
* If multiple feature types need to be configured
* which come from different feature namespaces, `featureNS` will be an object
* with the keys being the prefixes used in the entries of featureType array.
* The values of the object will be the feature namespaces themselves.
* So for instance there might be a featureType item `topp:states` and then
* there will be a key named `topp` in the featureNS object with value
* `http://www.openplans.org/topp`.
* @property {string} srsName srsName to use when writing geometries.
* @property {boolean} [surface=false] Write gml:Surface instead of gml:Polygon
* elements. This also affects the elements in multi-part geometries.
* @property {boolean} [curve=false] Write gml:Curve instead of gml:LineString
* elements. This also affects the elements in multi-part geometries.
* @property {boolean} [multiCurve=true] Write gml:MultiCurve instead of gml:MultiLineString.
* Since the latter is deprecated in GML 3.
* @property {boolean} [multiSurface=true] Write gml:multiSurface instead of
* 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.
*/
/**
* @classdesc
* Abstract base class; normally only used for creating subclasses and not
* instantiated in apps.
* Feature base format for reading and writing data in the GML format.
* This class cannot be instantiated, it contains only base content that
* is shared with versioned format classes GML2 and GML3.
*
* @abstract
* @api
*/
declare class GMLBase extends XMLFeature {
/**
* @param {Options} [opt_options] Optional configuration object.
*/
constructor(opt_options?: Options | undefined);
/**
* @protected
* @type {Array<string>|string|undefined}
*/
protected featureType: Array<string> | string | undefined;
/**
* @protected
* @type {Object<string, string>|string|undefined}
*/
protected featureNS: {
[x: string]: string;
} | string | undefined;
/**
* @protected
* @type {string}
*/
protected srsName: string;
/**
* @protected
* @type {string}
*/
protected schemaLocation: string;
/**
* @type {Object<string, Object<string, Object>>}
*/
FEATURE_COLLECTION_PARSERS: {
[x: string]: {
[x: string]: any;
};
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Array<Feature> | undefined} Features.
*/
readFeaturesInternal(node: Element, objectStack: Array<any>): Array<Feature> | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {import("../geom/Geometry.js").default|import("../extent.js").Extent|undefined} Geometry.
*/
readGeometryOrExtent(node: Element, objectStack: Array<any>): import("../geom/Geometry.js").default | import("../extent.js").Extent | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {import("../extent.js").Extent|undefined} Geometry.
*/
readExtentElement(node: Element, objectStack: Array<any>): import("../extent.js").Extent | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {import("../geom/Geometry.js").default|undefined} Geometry.
*/
readGeometryElement(node: Element, objectStack: Array<any>): import("../geom/Geometry.js").default | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @param {boolean} asFeature whether result should be wrapped as a feature.
* @return {Feature|Object} Feature
*/
readFeatureElementInternal(node: Element, objectStack: Array<any>, asFeature: boolean): Feature | any;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Feature} Feature.
*/
readFeatureElement(node: Element, objectStack: Array<any>): Feature;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Point|undefined} Point.
*/
readPoint(node: Element, objectStack: Array<any>): Point | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {MultiPoint|undefined} MultiPoint.
*/
readMultiPoint(node: Element, objectStack: Array<any>): MultiPoint | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {MultiLineString|undefined} MultiLineString.
*/
readMultiLineString(node: Element, objectStack: Array<any>): MultiLineString | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {MultiPolygon|undefined} MultiPolygon.
*/
readMultiPolygon(node: Element, objectStack: Array<any>): MultiPolygon | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
pointMemberParser(node: Element, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
lineStringMemberParser(node: Element, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
polygonMemberParser(node: Element, objectStack: Array<any>): void;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {LineString|undefined} LineString.
*/
readLineString(node: Element, objectStack: Array<any>): LineString | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Array<number>|undefined} LinearRing flat coordinates.
*/
readFlatLinearRing(node: Element, objectStack: Array<any>): Array<number> | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {LinearRing|undefined} LinearRing.
*/
readLinearRing(node: Element, objectStack: Array<any>): LinearRing | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Polygon|undefined} Polygon.
*/
readPolygon(node: Element, objectStack: Array<any>): Polygon | undefined;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Array<number>} Flat coordinates.
*/
readFlatCoordinatesFromNode(node: Element, objectStack: Array<any>): Array<number>;
namespace: string;
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
FLAT_LINEAR_RINGS_PARSERS: {
[x: string]: {
[x: string]: import("../xml.js").Parser;
};
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GEOMETRY_FLAT_COORDINATES_PARSERS: {
[x: string]: {
[x: string]: import("../xml.js").Parser;
};
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GEOMETRY_PARSERS: {
[x: string]: {
[x: string]: import("../xml.js").Parser;
};
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
MULTIPOINT_PARSERS: {
[x: string]: {
[x: string]: import("../xml.js").Parser;
};
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
MULTILINESTRING_PARSERS: {
[x: string]: {
[x: string]: import("../xml.js").Parser;
};
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
MULTIPOLYGON_PARSERS: {
[x: string]: {
[x: string]: import("../xml.js").Parser;
};
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
POINTMEMBER_PARSERS: {
[x: string]: {
[x: string]: import("../xml.js").Parser;
};
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
LINESTRINGMEMBER_PARSERS: {
[x: string]: {
[x: string]: import("../xml.js").Parser;
};
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
POLYGONMEMBER_PARSERS: {
[x: string]: {
[x: string]: import("../xml.js").Parser;
};
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
RING_PARSERS: {
[x: string]: {
[x: string]: import("../xml.js").Parser;
};
};
}
import XMLFeature from "./XMLFeature.js";
import Feature from "../Feature.js";
import Point from "../geom/Point.js";
import MultiPoint from "../geom/MultiPoint.js";
import MultiLineString from "../geom/MultiLineString.js";
import MultiPolygon from "../geom/MultiPolygon.js";
import LineString from "../geom/LineString.js";
import LinearRing from "../geom/LinearRing.js";
import Polygon from "../geom/Polygon.js";
//# sourceMappingURL=GMLBase.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"GMLBase.d.ts","sourceRoot":"","sources":["../src/format/GMLBase.js"],"names":[],"mappings":"AAgCA;;;GAGG;AACH,oBAFU,MAAM,CAEkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAiCpC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAlBpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH;;;;;;;;;;GAUG;AACH;IACE;;OAEG;IACH,+CAuCC;IAlCC;;;OAGG;IACH,uBAFU,MAAM,MAAM,CAAC,GAAC,MAAM,GAAC,SAAS,CAEF;IAEtC;;;OAGG;IACH,qBAFU;YAAO,MAAM,GAAE,MAAM;QAAE,MAAM,GAAC,SAAS,CAEf;IAElC;;;OAGG;IACH,mBAFU,MAAM,CAEc;IAE9B;;;OAGG;IACH,0BAFU,MAAM,CAEQ;IAExB;;OAEG;IACH;YAFiB,MAAM;gBAAS,MAAM;;MAEF;IAStC;;;;OAIG;IACH,2BAJW,OAAO,eACP,UAAQ,GACP,MAAM,OAAO,CAAC,GAAG,SAAS,CA2FrC;IAED;;;;OAIG;IACH,2BAJW,OAAO,eACP,UAAQ,GACP,OAAO,qBAAqB,EAAE,OAAO,GAAC,OAAO,cAAc,EAAE,MAAM,GAAC,SAAS,CAcxF;IAED;;;;OAIG;IACH,wBAJW,OAAO,eACP,UAAQ,GACP,OAAO,cAAc,EAAE,MAAM,GAAC,SAAS,CAQlD;IAED;;;;OAIG;IACH,0BAJW,OAAO,eACP,UAAQ,GACP,OAAO,qBAAqB,EAAE,OAAO,GAAC,SAAS,CAU1D;IAED;;;;;OAKG;IACH,iCALW,OAAO,eACP,UAAQ,aACR,OAAO,GACN,OAAO,MAAO,CAmEzB;IAED;;;;OAIG;IACH,yBAJW,OAAO,eACP,UAAQ,GACP,OAAO,CAIlB;IAED;;;;OAIG;IACH,gBAJW,OAAO,eACP,UAAQ,GACP,KAAK,GAAC,SAAS,CAO1B;IAED;;;;OAIG;IACH,qBAJW,OAAO,eACP,UAAQ,GACP,UAAU,GAAC,SAAS,CAgB/B;IAED;;;;OAIG;IACH,0BAJW,OAAO,eACP,UAAQ,GACP,eAAe,GAAC,SAAS,CAcpC;IAED;;;;OAIG;IACH,uBAJW,OAAO,eACP,UAAQ,GACP,YAAY,GAAC,SAAS,CAcjC;IAED;;;OAGG;IACH,wBAHW,OAAO,eACP,UAAQ,QAIlB;IAED;;;OAGG;IACH,6BAHW,OAAO,eACP,UAAQ,QAIlB;IAED;;;OAGG;IACH,0BAHW,OAAO,eACP,UAAQ,QAIlB;IAED;;;;OAIG;IACH,qBAJW,OAAO,eACP,UAAQ,GACP,UAAU,GAAC,SAAS,CAU/B;IAED;;;;OAIG;IACH,yBAJW,OAAO,eACP,UAAQ,GACP,MAAM,MAAM,CAAC,GAAC,SAAS,CAelC;IAED;;;;OAIG;IACH,qBAJW,OAAO,eACP,UAAQ,GACP,UAAU,GAAC,SAAS,CAO/B;IAED;;;;OAIG;IACH,kBAJW,OAAO,eACP,UAAQ,GACP,OAAO,GAAC,SAAS,CAuB5B;IAED;;;;OAIG;IACH,kCAJW,OAAO,eACP,UAAQ,GACP,MAAM,MAAM,CAAC,CAUxB;IA6CH,kBAA2B;IAE3B;;;OAGG;IACH;YAFiB,MAAM;gBAAS,MAAM,GAAE,OAAO,WAAW,EAAE,MAAM;;MAEvB;IAI3C;;;OAGG;IACH;YAFiB,MAAM;gBAAS,MAAM,GAAE,OAAO,WAAW,EAAE,MAAM;;MAEf;IAInD;;;OAGG;IACH;YAFiB,MAAM;gBAAS,MAAM,GAAE,OAAO,WAAW,EAAE,MAAM;;MAEhC;IAIlC;;;OAGG;IACH;YAFiB,MAAM;gBAAS,MAAM,GAAE,OAAO,WAAW,EAAE,MAAM;;MAE9B;IAOpC;;;OAGG;IACH;YAFiB,MAAM;gBAAS,MAAM,GAAE,OAAO,WAAW,EAAE,MAAM;;MAEzB;IAWzC;;;OAGG;IACH;YAFiB,MAAM;gBAAS,MAAM,GAAE,OAAO,WAAW,EAAE,MAAM;;MAE5B;IAOtC;;;OAGG;IACH;YAFiB,MAAM;gBAAS,MAAM,GAAE,OAAO,WAAW,EAAE,MAAM;;MAE7B;IAMrC;;;OAGG;IACH;YAFiB,MAAM;gBAAS,MAAM,GAAE,OAAO,WAAW,EAAE,MAAM;;MAExB;IAM1C;;;OAGG;IACH;YAFiB,MAAM;gBAAS,MAAM,GAAE,OAAO,WAAW,EAAE,MAAM;;MAE3B;IAMvC;;;OAGG;IACH;YAFiB,MAAM;gBAAS,MAAM,GAAE,OAAO,WAAW,EAAE,MAAM;;MAEpC;CAnG7B"}
+605
View File
@@ -0,0 +1,605 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/format/GMLBase
*/
// FIXME Envelopes should not be treated as geometries! readEnvelope_ is part
// of GEOMETRY_PARSERS_ and methods using GEOMETRY_PARSERS_ do not expect
// envelopes/extents, only geometries!
import Feature from '../Feature.js';
import GeometryLayout from '../geom/GeometryLayout.js';
import LineString from '../geom/LineString.js';
import LinearRing from '../geom/LinearRing.js';
import MultiLineString from '../geom/MultiLineString.js';
import MultiPoint from '../geom/MultiPoint.js';
import MultiPolygon from '../geom/MultiPolygon.js';
import Point from '../geom/Point.js';
import Polygon from '../geom/Polygon.js';
import XMLFeature from './XMLFeature.js';
import { assign } from '../obj.js';
import { extend } from '../array.js';
import { getAllTextContent, getAttributeNS, makeArrayPusher, makeReplacer, parseNode, pushParseAndPop, } from '../xml.js';
import { get as getProjection } from '../proj.js';
import { transformExtentWithOptions, transformGeometryWithOptions, } from './Feature.js';
/**
* @const
* @type {string}
*/
export var GMLNS = 'http://www.opengis.net/gml';
/**
* A regular expression that matches if a string only contains whitespace
* characters. It will e.g. match `''`, `' '`, `'\n'` etc. The non-breaking
* space (0xa0) is explicitly included as IE doesn't include it in its
* definition of `\s`.
*
* Information from `goog.string.isEmptyOrWhitespace`: https://github.com/google/closure-library/blob/e877b1e/closure/goog/string/string.js#L156-L160
*
* @const
* @type {RegExp}
*/
var ONLY_WHITESPACE_RE = /^[\s\xa0]*$/;
/**
* @typedef {Object} Options
* @property {Object<string, string>|string} [featureNS] Feature
* namespace. If not defined will be derived from GML. If multiple
* feature types have been configured which come from different feature
* namespaces, this will be an object with the keys being the prefixes used
* in the entries of featureType array. The values of the object will be the
* feature namespaces themselves. So for instance there might be a featureType
* item `topp:states` in the `featureType` array and then there will be a key
* `topp` in the featureNS object with value `http://www.openplans.org/topp`.
* @property {Array<string>|string} [featureType] Feature type(s) to parse.
* If multiple feature types need to be configured
* which come from different feature namespaces, `featureNS` will be an object
* with the keys being the prefixes used in the entries of featureType array.
* The values of the object will be the feature namespaces themselves.
* So for instance there might be a featureType item `topp:states` and then
* there will be a key named `topp` in the featureNS object with value
* `http://www.openplans.org/topp`.
* @property {string} srsName srsName to use when writing geometries.
* @property {boolean} [surface=false] Write gml:Surface instead of gml:Polygon
* elements. This also affects the elements in multi-part geometries.
* @property {boolean} [curve=false] Write gml:Curve instead of gml:LineString
* elements. This also affects the elements in multi-part geometries.
* @property {boolean} [multiCurve=true] Write gml:MultiCurve instead of gml:MultiLineString.
* Since the latter is deprecated in GML 3.
* @property {boolean} [multiSurface=true] Write gml:multiSurface instead of
* 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.
*/
/**
* @classdesc
* Abstract base class; normally only used for creating subclasses and not
* instantiated in apps.
* Feature base format for reading and writing data in the GML format.
* This class cannot be instantiated, it contains only base content that
* is shared with versioned format classes GML2 and GML3.
*
* @abstract
* @api
*/
var GMLBase = /** @class */ (function (_super) {
__extends(GMLBase, _super);
/**
* @param {Options} [opt_options] Optional configuration object.
*/
function GMLBase(opt_options) {
var _this = _super.call(this) || this;
var options = /** @type {Options} */ (opt_options ? opt_options : {});
/**
* @protected
* @type {Array<string>|string|undefined}
*/
_this.featureType = options.featureType;
/**
* @protected
* @type {Object<string, string>|string|undefined}
*/
_this.featureNS = options.featureNS;
/**
* @protected
* @type {string}
*/
_this.srsName = options.srsName;
/**
* @protected
* @type {string}
*/
_this.schemaLocation = '';
/**
* @type {Object<string, Object<string, Object>>}
*/
_this.FEATURE_COLLECTION_PARSERS = {};
_this.FEATURE_COLLECTION_PARSERS[_this.namespace] = {
'featureMember': makeArrayPusher(_this.readFeaturesInternal),
'featureMembers': makeReplacer(_this.readFeaturesInternal),
};
_this.supportedMediaTypes = ['application/gml+xml'];
return _this;
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Array<Feature> | undefined} Features.
*/
GMLBase.prototype.readFeaturesInternal = function (node, objectStack) {
var localName = node.localName;
var features = null;
if (localName == 'FeatureCollection') {
features = pushParseAndPop([], this.FEATURE_COLLECTION_PARSERS, node, objectStack, this);
}
else if (localName == 'featureMembers' ||
localName == 'featureMember' ||
localName == 'member') {
var context = objectStack[0];
var featureType = context['featureType'];
var featureNS = context['featureNS'];
var prefix = 'p';
var defaultPrefix = 'p0';
if (!featureType && node.childNodes) {
(featureType = []), (featureNS = {});
for (var i = 0, ii = node.childNodes.length; i < ii; ++i) {
var child = /** @type {Element} */ (node.childNodes[i]);
if (child.nodeType === 1) {
var ft = child.nodeName.split(':').pop();
if (featureType.indexOf(ft) === -1) {
var key = '';
var count = 0;
var uri = child.namespaceURI;
for (var candidate in featureNS) {
if (featureNS[candidate] === uri) {
key = candidate;
break;
}
++count;
}
if (!key) {
key = prefix + count;
featureNS[key] = uri;
}
featureType.push(key + ':' + ft);
}
}
}
if (localName != 'featureMember') {
// recheck featureType for each featureMember
context['featureType'] = featureType;
context['featureNS'] = featureNS;
}
}
if (typeof featureNS === 'string') {
var ns = featureNS;
featureNS = {};
featureNS[defaultPrefix] = ns;
}
/** @type {Object<string, Object<string, import("../xml.js").Parser>>} */
var parsersNS = {};
var featureTypes = Array.isArray(featureType)
? featureType
: [featureType];
for (var p in featureNS) {
/** @type {Object<string, import("../xml.js").Parser>} */
var parsers = {};
for (var i = 0, ii = featureTypes.length; i < ii; ++i) {
var featurePrefix = featureTypes[i].indexOf(':') === -1
? defaultPrefix
: featureTypes[i].split(':')[0];
if (featurePrefix === p) {
parsers[featureTypes[i].split(':').pop()] =
localName == 'featureMembers'
? makeArrayPusher(this.readFeatureElement, this)
: makeReplacer(this.readFeatureElement, this);
}
}
parsersNS[featureNS[p]] = parsers;
}
if (localName == 'featureMember' || localName == 'member') {
features = pushParseAndPop(undefined, parsersNS, node, objectStack);
}
else {
features = pushParseAndPop([], parsersNS, node, objectStack);
}
}
if (features === null) {
features = [];
}
return features;
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {import("../geom/Geometry.js").default|import("../extent.js").Extent|undefined} Geometry.
*/
GMLBase.prototype.readGeometryOrExtent = function (node, objectStack) {
var context = /** @type {Object} */ (objectStack[0]);
context['srsName'] = node.firstElementChild.getAttribute('srsName');
context['srsDimension'] =
node.firstElementChild.getAttribute('srsDimension');
return pushParseAndPop(null, this.GEOMETRY_PARSERS, node, objectStack, this);
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {import("../extent.js").Extent|undefined} Geometry.
*/
GMLBase.prototype.readExtentElement = function (node, objectStack) {
var context = /** @type {Object} */ (objectStack[0]);
var extent = /** @type {import("../extent.js").Extent} */ (this.readGeometryOrExtent(node, objectStack));
return extent ? transformExtentWithOptions(extent, context) : undefined;
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {import("../geom/Geometry.js").default|undefined} Geometry.
*/
GMLBase.prototype.readGeometryElement = function (node, objectStack) {
var context = /** @type {Object} */ (objectStack[0]);
var geometry = /** @type {import("../geom/Geometry.js").default} */ (this.readGeometryOrExtent(node, objectStack));
return geometry
? transformGeometryWithOptions(geometry, false, context)
: undefined;
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @param {boolean} asFeature whether result should be wrapped as a feature.
* @return {Feature|Object} Feature
*/
GMLBase.prototype.readFeatureElementInternal = function (node, objectStack, asFeature) {
var geometryName;
var values = {};
for (var n = node.firstElementChild; n; n = n.nextElementSibling) {
var value = void 0;
var localName = n.localName;
// first, check if it is simple attribute
if (n.childNodes.length === 0 ||
(n.childNodes.length === 1 &&
(n.firstChild.nodeType === 3 || n.firstChild.nodeType === 4))) {
value = getAllTextContent(n, false);
if (ONLY_WHITESPACE_RE.test(value)) {
value = undefined;
}
}
else {
if (asFeature) {
//if feature, try it as a geometry or extent
value =
localName === 'boundedBy'
? this.readExtentElement(n, objectStack)
: this.readGeometryElement(n, objectStack);
}
if (!value) {
//if not a geometry or not a feature, treat it as a complex attribute
value = this.readFeatureElementInternal(n, objectStack, false);
}
else if (localName !== 'boundedBy') {
// boundedBy is an extent and must not be considered as a geometry
geometryName = localName;
}
}
var len = n.attributes.length;
if (len > 0) {
value = { _content_: value };
for (var i = 0; i < len; i++) {
var attName = n.attributes[i].name;
value[attName] = n.attributes[i].value;
}
}
if (values[localName]) {
if (!(values[localName] instanceof Array)) {
values[localName] = [values[localName]];
}
values[localName].push(value);
}
else {
values[localName] = value;
}
}
if (!asFeature) {
return values;
}
else {
var feature = new Feature(values);
if (geometryName) {
feature.setGeometryName(geometryName);
}
var fid = node.getAttribute('fid') || getAttributeNS(node, this.namespace, 'id');
if (fid) {
feature.setId(fid);
}
return feature;
}
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Feature} Feature.
*/
GMLBase.prototype.readFeatureElement = function (node, objectStack) {
return this.readFeatureElementInternal(node, objectStack, true);
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Point|undefined} Point.
*/
GMLBase.prototype.readPoint = function (node, objectStack) {
var flatCoordinates = this.readFlatCoordinatesFromNode(node, objectStack);
if (flatCoordinates) {
return new Point(flatCoordinates, GeometryLayout.XYZ);
}
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {MultiPoint|undefined} MultiPoint.
*/
GMLBase.prototype.readMultiPoint = function (node, objectStack) {
/** @type {Array<Array<number>>} */
var coordinates = pushParseAndPop([], this.MULTIPOINT_PARSERS, node, objectStack, this);
if (coordinates) {
return new MultiPoint(coordinates);
}
else {
return undefined;
}
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {MultiLineString|undefined} MultiLineString.
*/
GMLBase.prototype.readMultiLineString = function (node, objectStack) {
/** @type {Array<LineString>} */
var lineStrings = pushParseAndPop([], this.MULTILINESTRING_PARSERS, node, objectStack, this);
if (lineStrings) {
return new MultiLineString(lineStrings);
}
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {MultiPolygon|undefined} MultiPolygon.
*/
GMLBase.prototype.readMultiPolygon = function (node, objectStack) {
/** @type {Array<Polygon>} */
var polygons = pushParseAndPop([], this.MULTIPOLYGON_PARSERS, node, objectStack, this);
if (polygons) {
return new MultiPolygon(polygons);
}
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
GMLBase.prototype.pointMemberParser = function (node, objectStack) {
parseNode(this.POINTMEMBER_PARSERS, node, objectStack, this);
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
GMLBase.prototype.lineStringMemberParser = function (node, objectStack) {
parseNode(this.LINESTRINGMEMBER_PARSERS, node, objectStack, this);
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
GMLBase.prototype.polygonMemberParser = function (node, objectStack) {
parseNode(this.POLYGONMEMBER_PARSERS, node, objectStack, this);
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {LineString|undefined} LineString.
*/
GMLBase.prototype.readLineString = function (node, objectStack) {
var flatCoordinates = this.readFlatCoordinatesFromNode(node, objectStack);
if (flatCoordinates) {
var lineString = new LineString(flatCoordinates, GeometryLayout.XYZ);
return lineString;
}
else {
return undefined;
}
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Array<number>|undefined} LinearRing flat coordinates.
*/
GMLBase.prototype.readFlatLinearRing = function (node, objectStack) {
var ring = pushParseAndPop(null, this.GEOMETRY_FLAT_COORDINATES_PARSERS, node, objectStack, this);
if (ring) {
return ring;
}
else {
return undefined;
}
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {LinearRing|undefined} LinearRing.
*/
GMLBase.prototype.readLinearRing = function (node, objectStack) {
var flatCoordinates = this.readFlatCoordinatesFromNode(node, objectStack);
if (flatCoordinates) {
return new LinearRing(flatCoordinates, GeometryLayout.XYZ);
}
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Polygon|undefined} Polygon.
*/
GMLBase.prototype.readPolygon = function (node, objectStack) {
/** @type {Array<Array<number>>} */
var flatLinearRings = pushParseAndPop([null], this.FLAT_LINEAR_RINGS_PARSERS, node, objectStack, this);
if (flatLinearRings && flatLinearRings[0]) {
var flatCoordinates = flatLinearRings[0];
var ends = [flatCoordinates.length];
var i = void 0, ii = void 0;
for (i = 1, ii = flatLinearRings.length; i < ii; ++i) {
extend(flatCoordinates, flatLinearRings[i]);
ends.push(flatCoordinates.length);
}
return new Polygon(flatCoordinates, GeometryLayout.XYZ, ends);
}
else {
return undefined;
}
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Array<number>} Flat coordinates.
*/
GMLBase.prototype.readFlatCoordinatesFromNode = function (node, objectStack) {
return pushParseAndPop(null, this.GEOMETRY_FLAT_COORDINATES_PARSERS, node, objectStack, this);
};
/**
* @param {Element} node Node.
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
* @protected
* @return {import("../geom/Geometry.js").default} Geometry.
*/
GMLBase.prototype.readGeometryFromNode = function (node, opt_options) {
var geometry = this.readGeometryElement(node, [
this.getReadOptions(node, opt_options ? opt_options : {}),
]);
return geometry ? geometry : null;
};
/**
* @param {Element} node Node.
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
* @return {Array<import("../Feature.js").default>} Features.
*/
GMLBase.prototype.readFeaturesFromNode = function (node, opt_options) {
var options = {
featureType: this.featureType,
featureNS: this.featureNS,
};
if (opt_options) {
assign(options, this.getReadOptions(node, opt_options));
}
var features = this.readFeaturesInternal(node, [options]);
return features || [];
};
/**
* @param {Element} node Node.
* @return {import("../proj/Projection.js").default} Projection.
*/
GMLBase.prototype.readProjectionFromNode = function (node) {
return getProjection(this.srsName
? this.srsName
: node.firstElementChild.getAttribute('srsName'));
};
return GMLBase;
}(XMLFeature));
GMLBase.prototype.namespace = GMLNS;
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GMLBase.prototype.FLAT_LINEAR_RINGS_PARSERS = {
'http://www.opengis.net/gml': {},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GMLBase.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS = {
'http://www.opengis.net/gml': {},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GMLBase.prototype.GEOMETRY_PARSERS = {
'http://www.opengis.net/gml': {},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GMLBase.prototype.MULTIPOINT_PARSERS = {
'http://www.opengis.net/gml': {
'pointMember': makeArrayPusher(GMLBase.prototype.pointMemberParser),
'pointMembers': makeArrayPusher(GMLBase.prototype.pointMemberParser),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GMLBase.prototype.MULTILINESTRING_PARSERS = {
'http://www.opengis.net/gml': {
'lineStringMember': makeArrayPusher(GMLBase.prototype.lineStringMemberParser),
'lineStringMembers': makeArrayPusher(GMLBase.prototype.lineStringMemberParser),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GMLBase.prototype.MULTIPOLYGON_PARSERS = {
'http://www.opengis.net/gml': {
'polygonMember': makeArrayPusher(GMLBase.prototype.polygonMemberParser),
'polygonMembers': makeArrayPusher(GMLBase.prototype.polygonMemberParser),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GMLBase.prototype.POINTMEMBER_PARSERS = {
'http://www.opengis.net/gml': {
'Point': makeArrayPusher(GMLBase.prototype.readFlatCoordinatesFromNode),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GMLBase.prototype.LINESTRINGMEMBER_PARSERS = {
'http://www.opengis.net/gml': {
'LineString': makeArrayPusher(GMLBase.prototype.readLineString),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GMLBase.prototype.POLYGONMEMBER_PARSERS = {
'http://www.opengis.net/gml': {
'Polygon': makeArrayPusher(GMLBase.prototype.readPolygon),
},
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
GMLBase.prototype.RING_PARSERS = {
'http://www.opengis.net/gml': {
'LinearRing': makeReplacer(GMLBase.prototype.readFlatLinearRing),
},
};
export default GMLBase;
//# sourceMappingURL=GMLBase.js.map
+1
View File
File diff suppressed because one or more lines are too long
+75
View File
@@ -0,0 +1,75 @@
export default GPX;
export type Options = {
/**
* Callback function
* to process `extensions` nodes. To prevent memory leaks, this callback function must
* not store any references to the node. Note that the `extensions`
* node is not allowed in GPX 1.0. Moreover, only `extensions`
* nodes from `wpt`, `rte` and `trk` can be processed, as those are
* directly mapped to a feature.
*/
readExtensions?: ((arg0: Feature, arg1: Node) => void) | undefined;
};
export type LayoutOptions = {
/**
* HasZ.
*/
hasZ?: boolean | undefined;
/**
* HasM.
*/
hasM?: boolean | undefined;
};
/**
* @typedef {Object} Options
* @property {function(Feature, Node):void} [readExtensions] Callback function
* to process `extensions` nodes. To prevent memory leaks, this callback function must
* not store any references to the node. Note that the `extensions`
* node is not allowed in GPX 1.0. Moreover, only `extensions`
* nodes from `wpt`, `rte` and `trk` can be processed, as those are
* directly mapped to a feature.
*/
/**
* @typedef {Object} LayoutOptions
* @property {boolean} [hasZ] HasZ.
* @property {boolean} [hasM] HasM.
*/
/**
* @classdesc
* Feature format for reading and writing data in the GPX format.
*
* Note that {@link module:ol/format/GPX~GPX#readFeature} only reads the first
* feature of the source.
*
* When reading, routes (`<rte>`) are converted into LineString geometries, and
* tracks (`<trk>`) into MultiLineString. Any properties on route and track
* waypoints are ignored.
*
* When writing, LineString geometries are output as routes (`<rte>`), and
* MultiLineString as tracks (`<trk>`).
*
* @api
*/
declare class GPX extends XMLFeature {
/**
* @param {Options} [opt_options] Options.
*/
constructor(opt_options?: Options | undefined);
/**
* @type {import("../proj/Projection.js").default}
*/
dataProjection: import("../proj/Projection.js").default;
/**
* @type {function(Feature, Node): void|undefined}
* @private
*/
private readExtensions_;
/**
* @param {Array<Feature>} features List of features.
* @private
*/
private handleReadExtensions_;
}
import Feature from "../Feature.js";
import XMLFeature from "./XMLFeature.js";
//# sourceMappingURL=GPX.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"GPX.d.ts","sourceRoot":"","sources":["../src/format/GPX.js"],"names":[],"mappings":";;;;;;;;;;6BAoGuB,OAAO,QAAE,IAAI,KAAE,IAAI;;;;;;;;;;;;AAF1C;;;;;;;;GAQG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;;GAeG;AACH;IACE;;OAEG;IACH,+CAeC;IAVC;;OAEG;IACH,gBAFU,OAAO,uBAAuB,EAAE,OAAO,CAED;IAEhD;;;OAGG;IACH,wBAA6C;IAG/C;;;OAGG;IACH,8BAYC;CAmFF"}
+805
View File
@@ -0,0 +1,805 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/format/GPX
*/
import Feature from '../Feature.js';
import GeometryLayout from '../geom/GeometryLayout.js';
import LineString from '../geom/LineString.js';
import MultiLineString from '../geom/MultiLineString.js';
import Point from '../geom/Point.js';
import XMLFeature from './XMLFeature.js';
import { OBJECT_PROPERTY_NODE_FACTORY, XML_SCHEMA_INSTANCE_URI, createElementNS, makeArrayPusher, makeArraySerializer, makeChildAppender, makeObjectPropertySetter, makeSequence, makeSimpleNodeFactory, makeStructureNS, parseNode, pushParseAndPop, pushSerializeAndPop, } from '../xml.js';
import { get as getProjection } from '../proj.js';
import { includes } from '../array.js';
import { readDateTime, readDecimal, readPositiveInteger, readString, writeDateTimeTextNode, writeDecimalTextNode, writeNonNegativeIntegerTextNode, writeStringTextNode, } from './xsd.js';
import { transformGeometryWithOptions } from './Feature.js';
/**
* @const
* @type {Array<null|string>}
*/
var NAMESPACE_URIS = [
null,
'http://www.topografix.com/GPX/1/0',
'http://www.topografix.com/GPX/1/1',
];
/**
* @const
* @type {string}
*/
var SCHEMA_LOCATION = 'http://www.topografix.com/GPX/1/1 ' +
'http://www.topografix.com/GPX/1/1/gpx.xsd';
/**
* @const
* @type {Object<string, function(Node, Array<*>): (Feature|undefined)>}
*/
var FEATURE_READER = {
'rte': readRte,
'trk': readTrk,
'wpt': readWpt,
};
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var GPX_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'rte': makeArrayPusher(readRte),
'trk': makeArrayPusher(readTrk),
'wpt': makeArrayPusher(readWpt),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var LINK_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'text': makeObjectPropertySetter(readString, 'linkText'),
'type': makeObjectPropertySetter(readString, 'linkType'),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
// @ts-ignore
var GPX_SERIALIZERS = makeStructureNS(NAMESPACE_URIS, {
'rte': makeChildAppender(writeRte),
'trk': makeChildAppender(writeTrk),
'wpt': makeChildAppender(writeWpt),
});
/**
* @typedef {Object} Options
* @property {function(Feature, Node):void} [readExtensions] Callback function
* to process `extensions` nodes. To prevent memory leaks, this callback function must
* not store any references to the node. Note that the `extensions`
* node is not allowed in GPX 1.0. Moreover, only `extensions`
* nodes from `wpt`, `rte` and `trk` can be processed, as those are
* directly mapped to a feature.
*/
/**
* @typedef {Object} LayoutOptions
* @property {boolean} [hasZ] HasZ.
* @property {boolean} [hasM] HasM.
*/
/**
* @classdesc
* Feature format for reading and writing data in the GPX format.
*
* Note that {@link module:ol/format/GPX~GPX#readFeature} only reads the first
* feature of the source.
*
* When reading, routes (`<rte>`) are converted into LineString geometries, and
* tracks (`<trk>`) into MultiLineString. Any properties on route and track
* waypoints are ignored.
*
* When writing, LineString geometries are output as routes (`<rte>`), and
* MultiLineString as tracks (`<trk>`).
*
* @api
*/
var GPX = /** @class */ (function (_super) {
__extends(GPX, _super);
/**
* @param {Options} [opt_options] Options.
*/
function GPX(opt_options) {
var _this = _super.call(this) || this;
var options = opt_options ? opt_options : {};
/**
* @type {import("../proj/Projection.js").default}
*/
_this.dataProjection = getProjection('EPSG:4326');
/**
* @type {function(Feature, Node): void|undefined}
* @private
*/
_this.readExtensions_ = options.readExtensions;
return _this;
}
/**
* @param {Array<Feature>} features List of features.
* @private
*/
GPX.prototype.handleReadExtensions_ = function (features) {
if (!features) {
features = [];
}
for (var i = 0, ii = features.length; i < ii; ++i) {
var feature = features[i];
if (this.readExtensions_) {
var extensionsNode = feature.get('extensionsNode_') || null;
this.readExtensions_(feature, extensionsNode);
}
feature.set('extensionsNode_', undefined);
}
};
/**
* @param {Element} node Node.
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
* @return {import("../Feature.js").default} Feature.
*/
GPX.prototype.readFeatureFromNode = function (node, opt_options) {
if (!includes(NAMESPACE_URIS, node.namespaceURI)) {
return null;
}
var featureReader = FEATURE_READER[node.localName];
if (!featureReader) {
return null;
}
var feature = featureReader(node, [
this.getReadOptions(node, opt_options),
]);
if (!feature) {
return null;
}
this.handleReadExtensions_([feature]);
return feature;
};
/**
* @param {Element} node Node.
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
* @return {Array<import("../Feature.js").default>} Features.
*/
GPX.prototype.readFeaturesFromNode = function (node, opt_options) {
if (!includes(NAMESPACE_URIS, node.namespaceURI)) {
return [];
}
if (node.localName == 'gpx') {
/** @type {Array<Feature>} */
var features = pushParseAndPop([], GPX_PARSERS, node, [
this.getReadOptions(node, opt_options),
]);
if (features) {
this.handleReadExtensions_(features);
return features;
}
else {
return [];
}
}
return [];
};
/**
* Encode an array of features in the GPX format as an XML node.
* LineString geometries are output as routes (`<rte>`), and MultiLineString
* as tracks (`<trk>`).
*
* @param {Array<Feature>} features Features.
* @param {import("./Feature.js").WriteOptions} [opt_options] Options.
* @return {Node} Node.
* @api
*/
GPX.prototype.writeFeaturesNode = function (features, opt_options) {
opt_options = this.adaptOptions(opt_options);
//FIXME Serialize metadata
var gpx = createElementNS('http://www.topografix.com/GPX/1/1', 'gpx');
var xmlnsUri = 'http://www.w3.org/2000/xmlns/';
gpx.setAttributeNS(xmlnsUri, 'xmlns:xsi', XML_SCHEMA_INSTANCE_URI);
gpx.setAttributeNS(XML_SCHEMA_INSTANCE_URI, 'xsi:schemaLocation', SCHEMA_LOCATION);
gpx.setAttribute('version', '1.1');
gpx.setAttribute('creator', 'OpenLayers');
pushSerializeAndPop(
/** @type {import("../xml.js").NodeStackItem} */
({ node: gpx }), GPX_SERIALIZERS, GPX_NODE_FACTORY, features, [opt_options]);
return gpx;
};
return GPX;
}(XMLFeature));
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var RTE_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'name': makeObjectPropertySetter(readString),
'cmt': makeObjectPropertySetter(readString),
'desc': makeObjectPropertySetter(readString),
'src': makeObjectPropertySetter(readString),
'link': parseLink,
'number': makeObjectPropertySetter(readPositiveInteger),
'extensions': parseExtensions,
'type': makeObjectPropertySetter(readString),
'rtept': parseRtePt,
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var RTEPT_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'ele': makeObjectPropertySetter(readDecimal),
'time': makeObjectPropertySetter(readDateTime),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var TRK_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'name': makeObjectPropertySetter(readString),
'cmt': makeObjectPropertySetter(readString),
'desc': makeObjectPropertySetter(readString),
'src': makeObjectPropertySetter(readString),
'link': parseLink,
'number': makeObjectPropertySetter(readPositiveInteger),
'type': makeObjectPropertySetter(readString),
'extensions': parseExtensions,
'trkseg': parseTrkSeg,
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var TRKSEG_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'trkpt': parseTrkPt,
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var TRKPT_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'ele': makeObjectPropertySetter(readDecimal),
'time': makeObjectPropertySetter(readDateTime),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var WPT_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'ele': makeObjectPropertySetter(readDecimal),
'time': makeObjectPropertySetter(readDateTime),
'magvar': makeObjectPropertySetter(readDecimal),
'geoidheight': makeObjectPropertySetter(readDecimal),
'name': makeObjectPropertySetter(readString),
'cmt': makeObjectPropertySetter(readString),
'desc': makeObjectPropertySetter(readString),
'src': makeObjectPropertySetter(readString),
'link': parseLink,
'sym': makeObjectPropertySetter(readString),
'type': makeObjectPropertySetter(readString),
'fix': makeObjectPropertySetter(readString),
'sat': makeObjectPropertySetter(readPositiveInteger),
'hdop': makeObjectPropertySetter(readDecimal),
'vdop': makeObjectPropertySetter(readDecimal),
'pdop': makeObjectPropertySetter(readDecimal),
'ageofdgpsdata': makeObjectPropertySetter(readDecimal),
'dgpsid': makeObjectPropertySetter(readPositiveInteger),
'extensions': parseExtensions,
});
/**
* @const
* @type {Array<string>}
*/
var LINK_SEQUENCE = ['text', 'type'];
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
// @ts-ignore
var LINK_SERIALIZERS = makeStructureNS(NAMESPACE_URIS, {
'text': makeChildAppender(writeStringTextNode),
'type': makeChildAppender(writeStringTextNode),
});
/**
* @const
* @type {Object<string, Array<string>>}
*/
// @ts-ignore
var RTE_SEQUENCE = makeStructureNS(NAMESPACE_URIS, [
'name',
'cmt',
'desc',
'src',
'link',
'number',
'type',
'rtept',
]);
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
// @ts-ignore
var RTE_SERIALIZERS = makeStructureNS(NAMESPACE_URIS, {
'name': makeChildAppender(writeStringTextNode),
'cmt': makeChildAppender(writeStringTextNode),
'desc': makeChildAppender(writeStringTextNode),
'src': makeChildAppender(writeStringTextNode),
'link': makeChildAppender(writeLink),
'number': makeChildAppender(writeNonNegativeIntegerTextNode),
'type': makeChildAppender(writeStringTextNode),
'rtept': makeArraySerializer(makeChildAppender(writeWptType)),
});
/**
* @const
* @type {Object<string, Array<string>>}
*/
// @ts-ignore
var RTEPT_TYPE_SEQUENCE = makeStructureNS(NAMESPACE_URIS, ['ele', 'time']);
/**
* @const
* @type {Object<string, Array<string>>}
*/
// @ts-ignore
var TRK_SEQUENCE = makeStructureNS(NAMESPACE_URIS, [
'name',
'cmt',
'desc',
'src',
'link',
'number',
'type',
'trkseg',
]);
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
// @ts-ignore
var TRK_SERIALIZERS = makeStructureNS(NAMESPACE_URIS, {
'name': makeChildAppender(writeStringTextNode),
'cmt': makeChildAppender(writeStringTextNode),
'desc': makeChildAppender(writeStringTextNode),
'src': makeChildAppender(writeStringTextNode),
'link': makeChildAppender(writeLink),
'number': makeChildAppender(writeNonNegativeIntegerTextNode),
'type': makeChildAppender(writeStringTextNode),
'trkseg': makeArraySerializer(makeChildAppender(writeTrkSeg)),
});
/**
* @const
* @type {function(*, Array<*>, string=): (Node|undefined)}
*/
var TRKSEG_NODE_FACTORY = makeSimpleNodeFactory('trkpt');
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
// @ts-ignore
var TRKSEG_SERIALIZERS = makeStructureNS(NAMESPACE_URIS, {
'trkpt': makeChildAppender(writeWptType),
});
/**
* @const
* @type {Object<string, Array<string>>}
*/
// @ts-ignore
var WPT_TYPE_SEQUENCE = makeStructureNS(NAMESPACE_URIS, [
'ele',
'time',
'magvar',
'geoidheight',
'name',
'cmt',
'desc',
'src',
'link',
'sym',
'type',
'fix',
'sat',
'hdop',
'vdop',
'pdop',
'ageofdgpsdata',
'dgpsid',
]);
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Serializer>>}
*/
// @ts-ignore
var WPT_TYPE_SERIALIZERS = makeStructureNS(NAMESPACE_URIS, {
'ele': makeChildAppender(writeDecimalTextNode),
'time': makeChildAppender(writeDateTimeTextNode),
'magvar': makeChildAppender(writeDecimalTextNode),
'geoidheight': makeChildAppender(writeDecimalTextNode),
'name': makeChildAppender(writeStringTextNode),
'cmt': makeChildAppender(writeStringTextNode),
'desc': makeChildAppender(writeStringTextNode),
'src': makeChildAppender(writeStringTextNode),
'link': makeChildAppender(writeLink),
'sym': makeChildAppender(writeStringTextNode),
'type': makeChildAppender(writeStringTextNode),
'fix': makeChildAppender(writeStringTextNode),
'sat': makeChildAppender(writeNonNegativeIntegerTextNode),
'hdop': makeChildAppender(writeDecimalTextNode),
'vdop': makeChildAppender(writeDecimalTextNode),
'pdop': makeChildAppender(writeDecimalTextNode),
'ageofdgpsdata': makeChildAppender(writeDecimalTextNode),
'dgpsid': makeChildAppender(writeNonNegativeIntegerTextNode),
});
/**
* @const
* @type {Object<string, string>}
*/
var GEOMETRY_TYPE_TO_NODENAME = {
'Point': 'wpt',
'LineString': 'rte',
'MultiLineString': 'trk',
};
/**
* @param {*} value Value.
* @param {Array<*>} objectStack Object stack.
* @param {string} [opt_nodeName] Node name.
* @return {Node|undefined} Node.
*/
function GPX_NODE_FACTORY(value, objectStack, opt_nodeName) {
var geometry = /** @type {Feature} */ (value).getGeometry();
if (geometry) {
var nodeName = GEOMETRY_TYPE_TO_NODENAME[geometry.getType()];
if (nodeName) {
var parentNode = objectStack[objectStack.length - 1].node;
return createElementNS(parentNode.namespaceURI, nodeName);
}
}
}
/**
* @param {Array<number>} flatCoordinates Flat coordinates.
* @param {LayoutOptions} layoutOptions Layout options.
* @param {Element} node Node.
* @param {!Object} values Values.
* @return {Array<number>} Flat coordinates.
*/
function appendCoordinate(flatCoordinates, layoutOptions, node, values) {
flatCoordinates.push(parseFloat(node.getAttribute('lon')), parseFloat(node.getAttribute('lat')));
if ('ele' in values) {
flatCoordinates.push(/** @type {number} */ (values['ele']));
delete values['ele'];
layoutOptions.hasZ = true;
}
else {
flatCoordinates.push(0);
}
if ('time' in values) {
flatCoordinates.push(/** @type {number} */ (values['time']));
delete values['time'];
layoutOptions.hasM = true;
}
else {
flatCoordinates.push(0);
}
return flatCoordinates;
}
/**
* Choose GeometryLayout based on flags in layoutOptions and adjust flatCoordinates
* and ends arrays by shrinking them accordingly (removing unused zero entries).
*
* @param {LayoutOptions} layoutOptions Layout options.
* @param {Array<number>} flatCoordinates Flat coordinates.
* @param {Array<number>} [ends] Ends.
* @return {import("../geom/GeometryLayout.js").default} Layout.
*/
function applyLayoutOptions(layoutOptions, flatCoordinates, ends) {
var layout = GeometryLayout.XY;
var stride = 2;
if (layoutOptions.hasZ && layoutOptions.hasM) {
layout = GeometryLayout.XYZM;
stride = 4;
}
else if (layoutOptions.hasZ) {
layout = GeometryLayout.XYZ;
stride = 3;
}
else if (layoutOptions.hasM) {
layout = GeometryLayout.XYM;
stride = 3;
}
if (stride !== 4) {
for (var i = 0, ii = flatCoordinates.length / 4; i < ii; i++) {
flatCoordinates[i * stride] = flatCoordinates[i * 4];
flatCoordinates[i * stride + 1] = flatCoordinates[i * 4 + 1];
if (layoutOptions.hasZ) {
flatCoordinates[i * stride + 2] = flatCoordinates[i * 4 + 2];
}
if (layoutOptions.hasM) {
flatCoordinates[i * stride + 2] = flatCoordinates[i * 4 + 3];
}
}
flatCoordinates.length = (flatCoordinates.length / 4) * stride;
if (ends) {
for (var i = 0, ii = ends.length; i < ii; i++) {
ends[i] = (ends[i] / 4) * stride;
}
}
}
return layout;
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
function parseLink(node, objectStack) {
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
var href = node.getAttribute('href');
if (href !== null) {
values['link'] = href;
}
parseNode(LINK_PARSERS, node, objectStack);
}
/**
* @param {Node} node Node.
* @param {Array<*>} objectStack Object stack.
*/
function parseExtensions(node, objectStack) {
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
values['extensionsNode_'] = node;
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
function parseRtePt(node, objectStack) {
var values = pushParseAndPop({}, RTEPT_PARSERS, node, objectStack);
if (values) {
var rteValues = /** @type {!Object} */ (objectStack[objectStack.length - 1]);
var flatCoordinates = /** @type {Array<number>} */ (rteValues['flatCoordinates']);
var layoutOptions = /** @type {LayoutOptions} */ (rteValues['layoutOptions']);
appendCoordinate(flatCoordinates, layoutOptions, node, values);
}
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
function parseTrkPt(node, objectStack) {
var values = pushParseAndPop({}, TRKPT_PARSERS, node, objectStack);
if (values) {
var trkValues = /** @type {!Object} */ (objectStack[objectStack.length - 1]);
var flatCoordinates = /** @type {Array<number>} */ (trkValues['flatCoordinates']);
var layoutOptions = /** @type {LayoutOptions} */ (trkValues['layoutOptions']);
appendCoordinate(flatCoordinates, layoutOptions, node, values);
}
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
function parseTrkSeg(node, objectStack) {
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
parseNode(TRKSEG_PARSERS, node, objectStack);
var flatCoordinates =
/** @type {Array<number>} */
(values['flatCoordinates']);
var ends = /** @type {Array<number>} */ (values['ends']);
ends.push(flatCoordinates.length);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Feature|undefined} Track.
*/
function readRte(node, objectStack) {
var options = /** @type {import("./Feature.js").ReadOptions} */ (objectStack[0]);
var values = pushParseAndPop({
'flatCoordinates': [],
'layoutOptions': {},
}, RTE_PARSERS, node, objectStack);
if (!values) {
return undefined;
}
var flatCoordinates =
/** @type {Array<number>} */
(values['flatCoordinates']);
delete values['flatCoordinates'];
var layoutOptions = /** @type {LayoutOptions} */ (values['layoutOptions']);
delete values['layoutOptions'];
var layout = applyLayoutOptions(layoutOptions, flatCoordinates);
var geometry = new LineString(flatCoordinates, layout);
transformGeometryWithOptions(geometry, false, options);
var feature = new Feature(geometry);
feature.setProperties(values, true);
return feature;
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Feature|undefined} Track.
*/
function readTrk(node, objectStack) {
var options = /** @type {import("./Feature.js").ReadOptions} */ (objectStack[0]);
var values = pushParseAndPop({
'flatCoordinates': [],
'ends': [],
'layoutOptions': {},
}, TRK_PARSERS, node, objectStack);
if (!values) {
return undefined;
}
var flatCoordinates =
/** @type {Array<number>} */
(values['flatCoordinates']);
delete values['flatCoordinates'];
var ends = /** @type {Array<number>} */ (values['ends']);
delete values['ends'];
var layoutOptions = /** @type {LayoutOptions} */ (values['layoutOptions']);
delete values['layoutOptions'];
var layout = applyLayoutOptions(layoutOptions, flatCoordinates, ends);
var geometry = new MultiLineString(flatCoordinates, layout, ends);
transformGeometryWithOptions(geometry, false, options);
var feature = new Feature(geometry);
feature.setProperties(values, true);
return feature;
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Feature|undefined} Waypoint.
*/
function readWpt(node, objectStack) {
var options = /** @type {import("./Feature.js").ReadOptions} */ (objectStack[0]);
var values = pushParseAndPop({}, WPT_PARSERS, node, objectStack);
if (!values) {
return undefined;
}
var layoutOptions = /** @type {LayoutOptions} */ ({});
var coordinates = appendCoordinate([], layoutOptions, node, values);
var layout = applyLayoutOptions(layoutOptions, coordinates);
var geometry = new Point(coordinates, layout);
transformGeometryWithOptions(geometry, false, options);
var feature = new Feature(geometry);
feature.setProperties(values, true);
return feature;
}
/**
* @param {Element} node Node.
* @param {string} value Value for the link's `href` attribute.
* @param {Array<*>} objectStack Node stack.
*/
function writeLink(node, value, objectStack) {
node.setAttribute('href', value);
var context = objectStack[objectStack.length - 1];
var properties = context['properties'];
var link = [properties['linkText'], properties['linkType']];
pushSerializeAndPop(
/** @type {import("../xml.js").NodeStackItem} */ ({ node: node }), LINK_SERIALIZERS, OBJECT_PROPERTY_NODE_FACTORY, link, objectStack, LINK_SEQUENCE);
}
/**
* @param {Element} node Node.
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
* @param {Array<*>} objectStack Object stack.
*/
function writeWptType(node, coordinate, objectStack) {
var context = objectStack[objectStack.length - 1];
var parentNode = context.node;
var namespaceURI = parentNode.namespaceURI;
var properties = context['properties'];
//FIXME Projection handling
node.setAttributeNS(null, 'lat', String(coordinate[1]));
node.setAttributeNS(null, 'lon', String(coordinate[0]));
var geometryLayout = context['geometryLayout'];
switch (geometryLayout) {
case GeometryLayout.XYZM:
if (coordinate[3] !== 0) {
properties['time'] = coordinate[3];
}
// fall through
case GeometryLayout.XYZ:
if (coordinate[2] !== 0) {
properties['ele'] = coordinate[2];
}
break;
case GeometryLayout.XYM:
if (coordinate[2] !== 0) {
properties['time'] = coordinate[2];
}
break;
default:
// pass
}
var orderedKeys = node.nodeName == 'rtept'
? RTEPT_TYPE_SEQUENCE[namespaceURI]
: WPT_TYPE_SEQUENCE[namespaceURI];
var values = makeSequence(properties, orderedKeys);
pushSerializeAndPop(
/** @type {import("../xml.js").NodeStackItem} */
({ node: node, 'properties': properties }), WPT_TYPE_SERIALIZERS, OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys);
}
/**
* @param {Node} node Node.
* @param {Feature} feature Feature.
* @param {Array<*>} objectStack Object stack.
*/
function writeRte(node, feature, objectStack) {
var options = /** @type {import("./Feature.js").WriteOptions} */ (objectStack[0]);
var properties = feature.getProperties();
var context = { node: node };
context['properties'] = properties;
var geometry = feature.getGeometry();
if (geometry.getType() == 'LineString') {
var lineString = /** @type {LineString} */ (transformGeometryWithOptions(geometry, true, options));
context['geometryLayout'] = lineString.getLayout();
properties['rtept'] = lineString.getCoordinates();
}
var parentNode = objectStack[objectStack.length - 1].node;
var orderedKeys = RTE_SEQUENCE[parentNode.namespaceURI];
var values = makeSequence(properties, orderedKeys);
pushSerializeAndPop(context, RTE_SERIALIZERS, OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys);
}
/**
* @param {Element} node Node.
* @param {Feature} feature Feature.
* @param {Array<*>} objectStack Object stack.
*/
function writeTrk(node, feature, objectStack) {
var options = /** @type {import("./Feature.js").WriteOptions} */ (objectStack[0]);
var properties = feature.getProperties();
/** @type {import("../xml.js").NodeStackItem} */
var context = { node: node };
context['properties'] = properties;
var geometry = feature.getGeometry();
if (geometry.getType() == 'MultiLineString') {
var multiLineString = /** @type {MultiLineString} */ (transformGeometryWithOptions(geometry, true, options));
properties['trkseg'] = multiLineString.getLineStrings();
}
var parentNode = objectStack[objectStack.length - 1].node;
var orderedKeys = TRK_SEQUENCE[parentNode.namespaceURI];
var values = makeSequence(properties, orderedKeys);
pushSerializeAndPop(context, TRK_SERIALIZERS, OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys);
}
/**
* @param {Element} node Node.
* @param {LineString} lineString LineString.
* @param {Array<*>} objectStack Object stack.
*/
function writeTrkSeg(node, lineString, objectStack) {
/** @type {import("../xml.js").NodeStackItem} */
var context = { node: node };
context['geometryLayout'] = lineString.getLayout();
context['properties'] = {};
pushSerializeAndPop(context, TRKSEG_SERIALIZERS, TRKSEG_NODE_FACTORY, lineString.getCoordinates(), objectStack);
}
/**
* @param {Element} node Node.
* @param {Feature} feature Feature.
* @param {Array<*>} objectStack Object stack.
*/
function writeWpt(node, feature, objectStack) {
var options = /** @type {import("./Feature.js").WriteOptions} */ (objectStack[0]);
var context = objectStack[objectStack.length - 1];
context['properties'] = feature.getProperties();
var geometry = feature.getGeometry();
if (geometry.getType() == 'Point') {
var point = /** @type {Point} */ (transformGeometryWithOptions(geometry, true, options));
context['geometryLayout'] = point.getLayout();
writeWptType(node, point.getCoordinates(), objectStack);
}
}
export default GPX;
//# sourceMappingURL=GPX.js.map
+1
View File
File diff suppressed because one or more lines are too long
+126
View File
@@ -0,0 +1,126 @@
export default GeoJSON;
export type GeoJSONObject = import("geojson").GeoJSON;
export type GeoJSONFeature = import("geojson").Feature;
export type GeoJSONFeatureCollection = import("geojson").FeatureCollection;
export type GeoJSONGeometry = import("geojson").Geometry;
export type GeoJSONPoint = import("geojson").Point;
export type GeoJSONLineString = import("geojson").LineString;
export type GeoJSONPolygon = import("geojson").Polygon;
export type GeoJSONMultiPoint = import("geojson").MultiPoint;
export type GeoJSONMultiLineString = import("geojson").MultiLineString;
export type GeoJSONMultiPolygon = import("geojson").MultiPolygon;
export type GeoJSONGeometryCollection = import("geojson").GeometryCollection;
export type Options = {
/**
* Default data projection.
*/
dataProjection?: import("../proj.js").ProjectionLike;
/**
* Projection for features read or
* written by the format. Options passed to read or write methods will take precedence.
*/
featureProjection?: import("../proj.js").ProjectionLike;
/**
* Geometry name to use when creating features.
*/
geometryName?: string | undefined;
/**
* Certain GeoJSON providers include
* the geometry_name field in the feature GeoJSON. If set to `true` the GeoJSON reader
* will look for that field to set the geometry name. If both this field is set to `true`
* and a `geometryName` is provided, the `geometryName` will take precedence.
*/
extractGeometryName?: boolean | undefined;
};
/**
* @typedef {import("geojson").GeoJSON} GeoJSONObject
* @typedef {import("geojson").Feature} GeoJSONFeature
* @typedef {import("geojson").FeatureCollection} GeoJSONFeatureCollection
* @typedef {import("geojson").Geometry} GeoJSONGeometry
* @typedef {import("geojson").Point} GeoJSONPoint
* @typedef {import("geojson").LineString} GeoJSONLineString
* @typedef {import("geojson").Polygon} GeoJSONPolygon
* @typedef {import("geojson").MultiPoint} GeoJSONMultiPoint
* @typedef {import("geojson").MultiLineString} GeoJSONMultiLineString
* @typedef {import("geojson").MultiPolygon} GeoJSONMultiPolygon
* @typedef {import("geojson").GeometryCollection} GeoJSONGeometryCollection
*/
/**
* @typedef {Object} Options
* @property {import("../proj.js").ProjectionLike} [dataProjection='EPSG:4326'] Default data projection.
* @property {import("../proj.js").ProjectionLike} [featureProjection] Projection for features read or
* written by the format. Options passed to read or write methods will take precedence.
* @property {string} [geometryName] Geometry name to use when creating features.
* @property {boolean} [extractGeometryName=false] Certain GeoJSON providers include
* the geometry_name field in the feature GeoJSON. If set to `true` the GeoJSON reader
* will look for that field to set the geometry name. If both this field is set to `true`
* and a `geometryName` is provided, the `geometryName` will take precedence.
*/
/**
* @classdesc
* Feature format for reading and writing data in the GeoJSON format.
*
* @api
*/
declare class GeoJSON extends JSONFeature {
/**
* @param {Options} [opt_options] Options.
*/
constructor(opt_options?: Options | undefined);
/**
* @type {import("../proj/Projection.js").default}
*/
dataProjection: import("../proj/Projection.js").default;
/**
* @type {import("../proj/Projection.js").default}
*/
defaultFeatureProjection: import("../proj/Projection.js").default;
/**
* Name of the geometry attribute for features.
* @type {string|undefined}
* @private
*/
private geometryName_;
/**
* Look for the geometry name in the feature GeoJSON
* @type {boolean|undefined}
* @private
*/
private extractGeometryName_;
/**
* @param {GeoJSONGeometry} object Object.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../geom/Geometry.js").default} Geometry.
*/
protected readGeometryFromObject(object: GeoJSONGeometry, opt_options?: import("./Feature.js").ReadOptions | undefined): import("../geom/Geometry.js").default;
/**
* Encode a feature as a GeoJSON Feature object.
*
* @param {import("../Feature.js").default} feature Feature.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONFeature} Object.
* @api
*/
writeFeatureObject(feature: import("../Feature.js").default, opt_options?: import("./Feature.js").WriteOptions | undefined): GeoJSONFeature;
/**
* 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.
* @return {GeoJSONFeatureCollection} GeoJSON Object.
* @api
*/
writeFeaturesObject(features: Array<import("../Feature.js").default>, opt_options?: import("./Feature.js").WriteOptions | undefined): GeoJSONFeatureCollection;
/**
* Encode a geometry as a GeoJSON object.
*
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONGeometry|GeoJSONGeometryCollection} Object.
* @api
*/
writeGeometryObject(geometry: import("../geom/Geometry.js").default, opt_options?: import("./Feature.js").WriteOptions | undefined): GeoJSONGeometry | GeoJSONGeometryCollection;
}
import JSONFeature from "./JSONFeature.js";
//# sourceMappingURL=GeoJSON.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"GeoJSON.d.ts","sourceRoot":"","sources":["../src/format/GeoJSON.js"],"names":[],"mappings":";4BAmBa,OAAO,SAAS,EAAE,OAAO;6BACzB,OAAO,SAAS,EAAE,OAAO;uCACzB,OAAO,SAAS,EAAE,iBAAiB;8BACnC,OAAO,SAAS,EAAE,QAAQ;2BAC1B,OAAO,SAAS,EAAE,KAAK;gCACvB,OAAO,SAAS,EAAE,UAAU;6BAC5B,OAAO,SAAS,EAAE,OAAO;gCACzB,OAAO,SAAS,EAAE,UAAU;qCAC5B,OAAO,SAAS,EAAE,eAAe;kCACjC,OAAO,SAAS,EAAE,YAAY;wCAC9B,OAAO,SAAS,EAAE,kBAAkB;;;;;qBAKnC,OAAO,YAAY,EAAE,cAAc;;;;;wBACnC,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;AAjBjD;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;GAKG;AACH;IACE;;OAEG;IACH,+CAqCC;IAhCC;;OAEG;IACH,gBAFU,OAAO,uBAAuB,EAAE,OAAO,CAIhD;IAGC;;OAEG;IACH,0BAFU,OAAO,uBAAuB,EAAE,OAAO,CAEuB;IAG1E;;;;OAIG;IACH,sBAAyC;IAEzC;;;;OAIG;IACH,6BAAuD;IA8EzD;;;;;OAKG;IACH,yCALW,eAAe,iEAGd,OAAO,qBAAqB,EAAE,OAAO,CAIhD;IAwBD;;;;;;;OAOG;IACH,4BALW,OAAO,eAAe,EAAE,OAAO,kEAE9B,cAAc,CAmCzB;IAED;;;;;;;OAOG;IACH,8BALW,MAAM,OAAO,eAAe,EAAE,OAAO,CAAC,kEAErC,wBAAwB,CAanC;IAED;;;;;;;OAOG;IACH,8BALW,OAAO,qBAAqB,EAAE,OAAO,kEAEpC,eAAe,GAAC,yBAAyB,CAKpD;CACF"}
+521
View File
@@ -0,0 +1,521 @@
/**
* @module ol/format/GeoJSON
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import Feature from '../Feature.js';
import GeometryCollection from '../geom/GeometryCollection.js';
import JSONFeature from './JSONFeature.js';
import LineString from '../geom/LineString.js';
import MultiLineString from '../geom/MultiLineString.js';
import MultiPoint from '../geom/MultiPoint.js';
import MultiPolygon from '../geom/MultiPolygon.js';
import Point from '../geom/Point.js';
import Polygon from '../geom/Polygon.js';
import { assert } from '../asserts.js';
import { assign, isEmpty } from '../obj.js';
import { get as getProjection } from '../proj.js';
import { transformGeometryWithOptions } from './Feature.js';
/**
* @typedef {import("geojson").GeoJSON} GeoJSONObject
* @typedef {import("geojson").Feature} GeoJSONFeature
* @typedef {import("geojson").FeatureCollection} GeoJSONFeatureCollection
* @typedef {import("geojson").Geometry} GeoJSONGeometry
* @typedef {import("geojson").Point} GeoJSONPoint
* @typedef {import("geojson").LineString} GeoJSONLineString
* @typedef {import("geojson").Polygon} GeoJSONPolygon
* @typedef {import("geojson").MultiPoint} GeoJSONMultiPoint
* @typedef {import("geojson").MultiLineString} GeoJSONMultiLineString
* @typedef {import("geojson").MultiPolygon} GeoJSONMultiPolygon
* @typedef {import("geojson").GeometryCollection} GeoJSONGeometryCollection
*/
/**
* @typedef {Object} Options
* @property {import("../proj.js").ProjectionLike} [dataProjection='EPSG:4326'] Default data projection.
* @property {import("../proj.js").ProjectionLike} [featureProjection] Projection for features read or
* written by the format. Options passed to read or write methods will take precedence.
* @property {string} [geometryName] Geometry name to use when creating features.
* @property {boolean} [extractGeometryName=false] Certain GeoJSON providers include
* the geometry_name field in the feature GeoJSON. If set to `true` the GeoJSON reader
* will look for that field to set the geometry name. If both this field is set to `true`
* and a `geometryName` is provided, the `geometryName` will take precedence.
*/
/**
* @classdesc
* Feature format for reading and writing data in the GeoJSON format.
*
* @api
*/
var GeoJSON = /** @class */ (function (_super) {
__extends(GeoJSON, _super);
/**
* @param {Options} [opt_options] Options.
*/
function GeoJSON(opt_options) {
var _this = this;
var options = opt_options ? opt_options : {};
_this = _super.call(this) || this;
/**
* @type {import("../proj/Projection.js").default}
*/
_this.dataProjection = getProjection(options.dataProjection ? options.dataProjection : 'EPSG:4326');
if (options.featureProjection) {
/**
* @type {import("../proj/Projection.js").default}
*/
_this.defaultFeatureProjection = getProjection(options.featureProjection);
}
/**
* Name of the geometry attribute for features.
* @type {string|undefined}
* @private
*/
_this.geometryName_ = options.geometryName;
/**
* Look for the geometry name in the feature GeoJSON
* @type {boolean|undefined}
* @private
*/
_this.extractGeometryName_ = options.extractGeometryName;
_this.supportedMediaTypes = [
'application/geo+json',
'application/vnd.geo+json',
];
return _this;
}
/**
* @param {Object} object Object.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../Feature.js").default} Feature.
*/
GeoJSON.prototype.readFeatureFromObject = function (object, opt_options) {
/**
* @type {GeoJSONFeature}
*/
var geoJSONFeature = null;
if (object['type'] === 'Feature') {
geoJSONFeature = /** @type {GeoJSONFeature} */ (object);
}
else {
geoJSONFeature = {
'type': 'Feature',
'geometry': /** @type {GeoJSONGeometry} */ (object),
'properties': null,
};
}
var geometry = readGeometry(geoJSONFeature['geometry'], opt_options);
var feature = new Feature();
if (this.geometryName_) {
feature.setGeometryName(this.geometryName_);
}
else if (this.extractGeometryName_ &&
'geometry_name' in geoJSONFeature !== undefined) {
feature.setGeometryName(geoJSONFeature['geometry_name']);
}
feature.setGeometry(geometry);
if ('id' in geoJSONFeature) {
feature.setId(geoJSONFeature['id']);
}
if (geoJSONFeature['properties']) {
feature.setProperties(geoJSONFeature['properties'], true);
}
return feature;
};
/**
* @param {Object} object Object.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {Array<Feature>} Features.
*/
GeoJSON.prototype.readFeaturesFromObject = function (object, opt_options) {
var geoJSONObject = /** @type {GeoJSONObject} */ (object);
/** @type {Array<import("../Feature.js").default>} */
var features = null;
if (geoJSONObject['type'] === 'FeatureCollection') {
var geoJSONFeatureCollection = /** @type {GeoJSONFeatureCollection} */ (object);
features = [];
var geoJSONFeatures = geoJSONFeatureCollection['features'];
for (var i = 0, ii = geoJSONFeatures.length; i < ii; ++i) {
features.push(this.readFeatureFromObject(geoJSONFeatures[i], opt_options));
}
}
else {
features = [this.readFeatureFromObject(object, opt_options)];
}
return features;
};
/**
* @param {GeoJSONGeometry} object Object.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../geom/Geometry.js").default} Geometry.
*/
GeoJSON.prototype.readGeometryFromObject = function (object, opt_options) {
return readGeometry(object, opt_options);
};
/**
* @param {Object} object Object.
* @protected
* @return {import("../proj/Projection.js").default} Projection.
*/
GeoJSON.prototype.readProjectionFromObject = function (object) {
var crs = object['crs'];
var projection;
if (crs) {
if (crs['type'] == 'name') {
projection = getProjection(crs['properties']['name']);
}
else if (crs['type'] === 'EPSG') {
projection = getProjection('EPSG:' + crs['properties']['code']);
}
else {
assert(false, 36); // Unknown SRS type
}
}
else {
projection = this.dataProjection;
}
return /** @type {import("../proj/Projection.js").default} */ (projection);
};
/**
* Encode a feature as a GeoJSON Feature object.
*
* @param {import("../Feature.js").default} feature Feature.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONFeature} Object.
* @api
*/
GeoJSON.prototype.writeFeatureObject = function (feature, opt_options) {
opt_options = this.adaptOptions(opt_options);
/** @type {GeoJSONFeature} */
var object = {
'type': 'Feature',
geometry: null,
properties: null,
};
var id = feature.getId();
if (id !== undefined) {
object.id = id;
}
if (!feature.hasProperties()) {
return object;
}
var properties = feature.getProperties();
var geometry = feature.getGeometry();
if (geometry) {
object.geometry = writeGeometry(geometry, opt_options);
delete properties[feature.getGeometryName()];
}
if (!isEmpty(properties)) {
object.properties = properties;
}
return object;
};
/**
* 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.
* @return {GeoJSONFeatureCollection} GeoJSON Object.
* @api
*/
GeoJSON.prototype.writeFeaturesObject = function (features, opt_options) {
opt_options = this.adaptOptions(opt_options);
var objects = [];
for (var i = 0, ii = features.length; i < ii; ++i) {
objects.push(this.writeFeatureObject(features[i], opt_options));
}
return {
type: 'FeatureCollection',
features: objects,
};
};
/**
* Encode a geometry as a GeoJSON object.
*
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONGeometry|GeoJSONGeometryCollection} Object.
* @api
*/
GeoJSON.prototype.writeGeometryObject = function (geometry, opt_options) {
return writeGeometry(geometry, this.adaptOptions(opt_options));
};
return GeoJSON;
}(JSONFeature));
/**
* @param {GeoJSONGeometry|GeoJSONGeometryCollection} object Object.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../geom/Geometry.js").default} Geometry.
*/
function readGeometry(object, opt_options) {
if (!object) {
return null;
}
/**
* @type {import("../geom/Geometry.js").default}
*/
var geometry;
switch (object['type']) {
case 'Point': {
geometry = readPointGeometry(/** @type {GeoJSONPoint} */ (object));
break;
}
case 'LineString': {
geometry = readLineStringGeometry(
/** @type {GeoJSONLineString} */ (object));
break;
}
case 'Polygon': {
geometry = readPolygonGeometry(/** @type {GeoJSONPolygon} */ (object));
break;
}
case 'MultiPoint': {
geometry = readMultiPointGeometry(
/** @type {GeoJSONMultiPoint} */ (object));
break;
}
case 'MultiLineString': {
geometry = readMultiLineStringGeometry(
/** @type {GeoJSONMultiLineString} */ (object));
break;
}
case 'MultiPolygon': {
geometry = readMultiPolygonGeometry(
/** @type {GeoJSONMultiPolygon} */ (object));
break;
}
case 'GeometryCollection': {
geometry = readGeometryCollectionGeometry(
/** @type {GeoJSONGeometryCollection} */ (object));
break;
}
default: {
throw new Error('Unsupported GeoJSON type: ' + object['type']);
}
}
return transformGeometryWithOptions(geometry, false, opt_options);
}
/**
* @param {GeoJSONGeometryCollection} object Object.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {GeometryCollection} Geometry collection.
*/
function readGeometryCollectionGeometry(object, opt_options) {
var geometries = object['geometries'].map(
/**
* @param {GeoJSONGeometry} geometry Geometry.
* @return {import("../geom/Geometry.js").default} geometry Geometry.
*/
function (geometry) {
return readGeometry(geometry, opt_options);
});
return new GeometryCollection(geometries);
}
/**
* @param {GeoJSONPoint} object Object.
* @return {Point} Point.
*/
function readPointGeometry(object) {
return new Point(object['coordinates']);
}
/**
* @param {GeoJSONLineString} object Object.
* @return {LineString} LineString.
*/
function readLineStringGeometry(object) {
return new LineString(object['coordinates']);
}
/**
* @param {GeoJSONMultiLineString} object Object.
* @return {MultiLineString} MultiLineString.
*/
function readMultiLineStringGeometry(object) {
return new MultiLineString(object['coordinates']);
}
/**
* @param {GeoJSONMultiPoint} object Object.
* @return {MultiPoint} MultiPoint.
*/
function readMultiPointGeometry(object) {
return new MultiPoint(object['coordinates']);
}
/**
* @param {GeoJSONMultiPolygon} object Object.
* @return {MultiPolygon} MultiPolygon.
*/
function readMultiPolygonGeometry(object) {
return new MultiPolygon(object['coordinates']);
}
/**
* @param {GeoJSONPolygon} object Object.
* @return {Polygon} Polygon.
*/
function readPolygonGeometry(object) {
return new Polygon(object['coordinates']);
}
/**
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONGeometry} GeoJSON geometry.
*/
function writeGeometry(geometry, opt_options) {
geometry = transformGeometryWithOptions(geometry, true, opt_options);
var type = geometry.getType();
/** @type {GeoJSONGeometry} */
var geoJSON;
switch (type) {
case 'Point': {
geoJSON = writePointGeometry(
/** @type {Point} */ (geometry), opt_options);
break;
}
case 'LineString': {
geoJSON = writeLineStringGeometry(
/** @type {LineString} */ (geometry), opt_options);
break;
}
case 'Polygon': {
geoJSON = writePolygonGeometry(
/** @type {Polygon} */ (geometry), opt_options);
break;
}
case 'MultiPoint': {
geoJSON = writeMultiPointGeometry(
/** @type {MultiPoint} */ (geometry), opt_options);
break;
}
case 'MultiLineString': {
geoJSON = writeMultiLineStringGeometry(
/** @type {MultiLineString} */ (geometry), opt_options);
break;
}
case 'MultiPolygon': {
geoJSON = writeMultiPolygonGeometry(
/** @type {MultiPolygon} */ (geometry), opt_options);
break;
}
case 'GeometryCollection': {
geoJSON = writeGeometryCollectionGeometry(
/** @type {GeometryCollection} */ (geometry), opt_options);
break;
}
case 'Circle': {
geoJSON = {
type: 'GeometryCollection',
geometries: [],
};
break;
}
default: {
throw new Error('Unsupported geometry type: ' + type);
}
}
return geoJSON;
}
/**
* @param {GeometryCollection} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONGeometryCollection} GeoJSON geometry collection.
*/
function writeGeometryCollectionGeometry(geometry, opt_options) {
var geometries = geometry.getGeometriesArray().map(function (geometry) {
var options = assign({}, opt_options);
delete options.featureProjection;
return writeGeometry(geometry, options);
});
return {
type: 'GeometryCollection',
geometries: geometries,
};
}
/**
* @param {LineString} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONGeometry} GeoJSON geometry.
*/
function writeLineStringGeometry(geometry, opt_options) {
return {
type: 'LineString',
coordinates: geometry.getCoordinates(),
};
}
/**
* @param {MultiLineString} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONGeometry} GeoJSON geometry.
*/
function writeMultiLineStringGeometry(geometry, opt_options) {
return {
type: 'MultiLineString',
coordinates: geometry.getCoordinates(),
};
}
/**
* @param {MultiPoint} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONGeometry} GeoJSON geometry.
*/
function writeMultiPointGeometry(geometry, opt_options) {
return {
type: 'MultiPoint',
coordinates: geometry.getCoordinates(),
};
}
/**
* @param {MultiPolygon} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONGeometry} GeoJSON geometry.
*/
function writeMultiPolygonGeometry(geometry, opt_options) {
var right;
if (opt_options) {
right = opt_options.rightHanded;
}
return {
type: 'MultiPolygon',
coordinates: geometry.getCoordinates(right),
};
}
/**
* @param {Point} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONGeometry} GeoJSON geometry.
*/
function writePointGeometry(geometry, opt_options) {
return {
type: 'Point',
coordinates: geometry.getCoordinates(),
};
}
/**
* @param {Polygon} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {GeoJSONGeometry} GeoJSON geometry.
*/
function writePolygonGeometry(geometry, opt_options) {
var right;
if (opt_options) {
right = opt_options.rightHanded;
}
return {
type: 'Polygon',
coordinates: geometry.getCoordinates(right),
};
}
export default GeoJSON;
//# sourceMappingURL=GeoJSON.js.map
+1
View File
File diff suppressed because one or more lines are too long
+40
View File
@@ -0,0 +1,40 @@
export default IGC;
export type Options = {
/**
* Altitude mode. Possible
* values are `'barometric'`, `'gps'`, and `'none'`.
*/
altitudeMode?: string | undefined;
};
/**
* @typedef {Object} Options
* @property {IGCZ|string} [altitudeMode='none'] Altitude mode. Possible
* values are `'barometric'`, `'gps'`, and `'none'`.
*/
/**
* @classdesc
* Feature format for `*.igc` flight recording files.
*
* As IGC sources contain a single feature,
* {@link module:ol/format/IGC~IGC#readFeatures} will return the feature in an
* array
*
* @api
*/
declare class IGC extends TextFeature {
/**
* @param {Options} [opt_options] Options.
*/
constructor(opt_options?: Options | undefined);
/**
* @type {import("../proj/Projection.js").default}
*/
dataProjection: import("../proj/Projection.js").default;
/**
* @private
* @type {IGCZ}
*/
private altitudeMode_;
}
import TextFeature from "./TextFeature.js";
//# sourceMappingURL=IGC.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"IGC.d.ts","sourceRoot":"","sources":["../src/format/IGC.js"],"names":[],"mappings":";;;;;;;;AA+CA;;;;GAIG;AAEH;;;;;;;;;GASG;AACH;IACE;;OAEG;IACH,+CAiBC;IAZC;;OAEG;IACH,gBAFU,OAAO,uBAAuB,EAAE,OAAO,CAED;IAEhD;;;OAGG;IACH,sBAEa;CAkGhB"}
+191
View File
@@ -0,0 +1,191 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/format/IGC
*/
import Feature from '../Feature.js';
import GeometryLayout from '../geom/GeometryLayout.js';
import LineString from '../geom/LineString.js';
import TextFeature from './TextFeature.js';
import { get as getProjection } from '../proj.js';
import { transformGeometryWithOptions } from './Feature.js';
/**
* IGC altitude/z. One of 'barometric', 'gps', 'none'.
* @enum {string}
*/
var IGCZ = {
BAROMETRIC: 'barometric',
GPS: 'gps',
NONE: 'none',
};
/**
* @const
* @type {RegExp}
*/
var B_RECORD_RE = /^B(\d{2})(\d{2})(\d{2})(\d{2})(\d{5})([NS])(\d{3})(\d{5})([EW])([AV])(\d{5})(\d{5})/;
/**
* @const
* @type {RegExp}
*/
var H_RECORD_RE = /^H.([A-Z]{3}).*?:(.*)/;
/**
* @const
* @type {RegExp}
*/
var HFDTE_RECORD_RE = /^HFDTE(\d{2})(\d{2})(\d{2})/;
/**
* A regular expression matching the newline characters `\r\n`, `\r` and `\n`.
*
* @const
* @type {RegExp}
*/
var NEWLINE_RE = /\r\n|\r|\n/;
/**
* @typedef {Object} Options
* @property {IGCZ|string} [altitudeMode='none'] Altitude mode. Possible
* values are `'barometric'`, `'gps'`, and `'none'`.
*/
/**
* @classdesc
* Feature format for `*.igc` flight recording files.
*
* As IGC sources contain a single feature,
* {@link module:ol/format/IGC~IGC#readFeatures} will return the feature in an
* array
*
* @api
*/
var IGC = /** @class */ (function (_super) {
__extends(IGC, _super);
/**
* @param {Options} [opt_options] Options.
*/
function IGC(opt_options) {
var _this = _super.call(this) || this;
var options = opt_options ? opt_options : {};
/**
* @type {import("../proj/Projection.js").default}
*/
_this.dataProjection = getProjection('EPSG:4326');
/**
* @private
* @type {IGCZ}
*/
_this.altitudeMode_ = options.altitudeMode
? options.altitudeMode
: IGCZ.NONE;
return _this;
}
/**
* @protected
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../Feature.js").default} Feature.
*/
IGC.prototype.readFeatureFromText = function (text, opt_options) {
var altitudeMode = this.altitudeMode_;
var lines = text.split(NEWLINE_RE);
/** @type {Object<string, string>} */
var properties = {};
var flatCoordinates = [];
var year = 2000;
var month = 0;
var day = 1;
var lastDateTime = -1;
var i, ii;
for (i = 0, ii = lines.length; i < ii; ++i) {
var line = lines[i];
var m = void 0;
if (line.charAt(0) == 'B') {
m = B_RECORD_RE.exec(line);
if (m) {
var hour = parseInt(m[1], 10);
var minute = parseInt(m[2], 10);
var second = parseInt(m[3], 10);
var y = parseInt(m[4], 10) + parseInt(m[5], 10) / 60000;
if (m[6] == 'S') {
y = -y;
}
var x = parseInt(m[7], 10) + parseInt(m[8], 10) / 60000;
if (m[9] == 'W') {
x = -x;
}
flatCoordinates.push(x, y);
if (altitudeMode != IGCZ.NONE) {
var z = void 0;
if (altitudeMode == IGCZ.GPS) {
z = parseInt(m[11], 10);
}
else if (altitudeMode == IGCZ.BAROMETRIC) {
z = parseInt(m[12], 10);
}
else {
z = 0;
}
flatCoordinates.push(z);
}
var dateTime = Date.UTC(year, month, day, hour, minute, second);
// Detect UTC midnight wrap around.
if (dateTime < lastDateTime) {
dateTime = Date.UTC(year, month, day + 1, hour, minute, second);
}
flatCoordinates.push(dateTime / 1000);
lastDateTime = dateTime;
}
}
else if (line.charAt(0) == 'H') {
m = HFDTE_RECORD_RE.exec(line);
if (m) {
day = parseInt(m[1], 10);
month = parseInt(m[2], 10) - 1;
year = 2000 + parseInt(m[3], 10);
}
else {
m = H_RECORD_RE.exec(line);
if (m) {
properties[m[1]] = m[2].trim();
}
}
}
}
if (flatCoordinates.length === 0) {
return null;
}
var layout = altitudeMode == IGCZ.NONE ? GeometryLayout.XYM : GeometryLayout.XYZM;
var lineString = new LineString(flatCoordinates, layout);
var feature = new Feature(transformGeometryWithOptions(lineString, false, opt_options));
feature.setProperties(properties, true);
return feature;
};
/**
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {Array<Feature>} Features.
*/
IGC.prototype.readFeaturesFromText = function (text, opt_options) {
var feature = this.readFeatureFromText(text, opt_options);
if (feature) {
return [feature];
}
else {
return [];
}
};
return IGC;
}(TextFeature));
export default IGC;
//# sourceMappingURL=IGC.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"IGC.js","sourceRoot":"","sources":["../src/format/IGC.js"],"names":[],"mappings":"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"}
+132
View File
@@ -0,0 +1,132 @@
/**
* Enum representing the major IIIF Image API versions
*/
export type Versions = string;
export namespace Versions {
const VERSION1: string;
const VERSION2: string;
const VERSION3: string;
}
export default IIIFInfo;
export type PreferredOptions = {
/**
* Preferred image format. Will be used if the image information
* indicates support for that format.
*/
format?: string | undefined;
/**
* IIIF image qualitiy. Will be used if the image information
* indicates support for that quality.
*/
quality?: string | undefined;
};
export type SupportedFeatures = {
/**
* Supported IIIF image size and region
* calculation features.
*/
supports?: string[] | undefined;
/**
* Supported image formats.
*/
formats?: string[] | undefined;
/**
* Supported IIIF image qualities.
*/
qualities?: string[] | undefined;
};
export type TileInfo = {
/**
* Supported resolution scaling factors.
*/
scaleFactors: Array<number>;
/**
* Tile width in pixels.
*/
width: number;
/**
* Tile height in pixels. Same as tile width if height is
* not given.
*/
height?: number | undefined;
};
export type IiifProfile = {
/**
* Supported image formats for the image service.
*/
formats?: string[] | undefined;
/**
* Supported IIIF image qualities.
*/
qualities?: string[] | undefined;
/**
* Supported features.
*/
supports?: string[] | undefined;
/**
* Maximum area (pixels) available for this image service.
*/
maxArea?: number | undefined;
/**
* Maximum height.
*/
maxHeight?: number | undefined;
/**
* Maximum width.
*/
maxWidth?: number | undefined;
};
export type ImageInformationResponse = {
[x: string]: string | number | Array<number | string | IiifProfile | {
[x: string]: number;
} | TileInfo>;
};
/**
* @classdesc
* Format for transforming IIIF Image API image information responses into
* IIIF tile source ready options
*
* @api
*/
declare class IIIFInfo {
/**
* @param {string|ImageInformationResponse} imageInfo
* Deserialized image information JSON response object or JSON response as string
*/
constructor(imageInfo: string | ImageInformationResponse);
/**
* @param {string|ImageInformationResponse} imageInfo
* Deserialized image information JSON response object or JSON response as string
* @api
*/
setImageInfo(imageInfo: string | ImageInformationResponse): void;
imageInfo: any;
/**
* @return {Versions} Major IIIF version.
* @api
*/
getImageApiVersion(): Versions;
/**
* @param {Versions} version Optional IIIF image API version
* @return {string} Compliance level as it appears in the IIIF image information
* response.
*/
getComplianceLevelEntryFromProfile(version: Versions): string;
/**
* @param {Versions} version Optional IIIF image API version
* @return {string} Compliance level, on of 'level0', 'level1' or 'level2' or undefined
*/
getComplianceLevelFromProfile(version: Versions): string;
/**
* @return {SupportedFeatures} Image formats, qualities and region / size calculation
* methods that are supported by the IIIF service.
*/
getComplianceLevelSupportedFeatures(): SupportedFeatures;
/**
* @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?: PreferredOptions | undefined): import("../source/IIIF.js").Options;
}
//# sourceMappingURL=IIIFInfo.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"IIIFInfo.d.ts","sourceRoot":"","sources":["../src/format/IIIFInfo.js"],"names":[],"mappings":";;;uBAgDU,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAvBF,MAAM,MAAM,CAAC;;;;WACb,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAgBA,MAAM,GAAC,MAAM,GAAC,MAAM,GAAC,MAAM,MAAM,GAAC,MAAM,GAAC,WAAW;YAAQ,MAAM,GAAE,MAAM;QAAE,QAAQ,CAAC;;AAoQzG;;;;;;GAMG;AACH;IACE;;;OAGG;IACH,uBAHW,MAAM,GAAC,wBAAwB,EAKzC;IAED;;;;OAIG;IACH,wBAJW,MAAM,GAAC,wBAAwB,QAUzC;IAJG,eAAsC;IAM1C;;;OAGG;IACH,sBAHY,QAAQ,CAiCnB;IAED;;;;OAIG;IACH,4CAJW,QAAQ,GACP,MAAM,CAuCjB;IAED;;;OAGG;IACH,uCAHW,QAAQ,GACP,MAAM,CASjB;IAED;;;OAGG;IACH,uCAHY,iBAAiB,CAa5B;IAED;;;;OAIG;IACH,2EAHY,OAAO,mBAAmB,EAAE,OAAO,CAwC9C;CACF"}
+439
View File
@@ -0,0 +1,439 @@
/**
* @module ol/format/IIIFInfo
*/
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
import { assert } from '../asserts.js';
import { includes } from '../array.js';
/**
* @typedef {Object} PreferredOptions
* @property {string} [format] Preferred image format. Will be used if the image information
* indicates support for that format.
* @property {string} [quality] IIIF image qualitiy. Will be used if the image information
* indicates support for that quality.
*/
/**
* @typedef {Object} SupportedFeatures
* @property {Array<string>} [supports] Supported IIIF image size and region
* calculation features.
* @property {Array<string>} [formats] Supported image formats.
* @property {Array<string>} [qualities] Supported IIIF image qualities.
*/
/**
* @typedef {Object} TileInfo
* @property {Array<number>} scaleFactors Supported resolution scaling factors.
* @property {number} width Tile width in pixels.
* @property {number} [height] Tile height in pixels. Same as tile width if height is
* not given.
*/
/**
* @typedef {Object} IiifProfile
* @property {Array<string>} [formats] Supported image formats for the image service.
* @property {Array<string>} [qualities] Supported IIIF image qualities.
* @property {Array<string>} [supports] Supported features.
* @property {number} [maxArea] Maximum area (pixels) available for this image service.
* @property {number} [maxHeight] Maximum height.
* @property {number} [maxWidth] Maximum width.
*/
/**
* @typedef {Object<string,string|number|Array<number|string|IiifProfile|Object<string, number>|TileInfo>>}
* ImageInformationResponse
*/
/**
* Enum representing the major IIIF Image API versions
* @enum {string}
*/
export var Versions = {
VERSION1: 'version1',
VERSION2: 'version2',
VERSION3: 'version3',
};
/**
* Supported image formats, qualities and supported region / size calculation features
* for different image API versions and compliance levels
* @const
* @type {Object<string, Object<string, SupportedFeatures>>}
*/
var IIIF_PROFILE_VALUES = {};
IIIF_PROFILE_VALUES[Versions.VERSION1] = {
'level0': {
supports: [],
formats: [],
qualities: ['native'],
},
'level1': {
supports: ['regionByPx', 'sizeByW', 'sizeByH', 'sizeByPct'],
formats: ['jpg'],
qualities: ['native'],
},
'level2': {
supports: [
'regionByPx',
'regionByPct',
'sizeByW',
'sizeByH',
'sizeByPct',
'sizeByConfinedWh',
'sizeByWh',
],
formats: ['jpg', 'png'],
qualities: ['native', 'color', 'grey', 'bitonal'],
},
};
IIIF_PROFILE_VALUES[Versions.VERSION2] = {
'level0': {
supports: [],
formats: ['jpg'],
qualities: ['default'],
},
'level1': {
supports: ['regionByPx', 'sizeByW', 'sizeByH', 'sizeByPct'],
formats: ['jpg'],
qualities: ['default'],
},
'level2': {
supports: [
'regionByPx',
'regionByPct',
'sizeByW',
'sizeByH',
'sizeByPct',
'sizeByConfinedWh',
'sizeByDistortedWh',
'sizeByWh',
],
formats: ['jpg', 'png'],
qualities: ['default', 'bitonal'],
},
};
IIIF_PROFILE_VALUES[Versions.VERSION3] = {
'level0': {
supports: [],
formats: ['jpg'],
qualities: ['default'],
},
'level1': {
supports: ['regionByPx', 'regionSquare', 'sizeByW', 'sizeByH', 'sizeByWh'],
formats: ['jpg'],
qualities: ['default'],
},
'level2': {
supports: [
'regionByPx',
'regionSquare',
'regionByPct',
'sizeByW',
'sizeByH',
'sizeByPct',
'sizeByConfinedWh',
'sizeByWh',
],
formats: ['jpg', 'png'],
qualities: ['default'],
},
};
IIIF_PROFILE_VALUES['none'] = {
'none': {
supports: [],
formats: [],
qualities: [],
},
};
var COMPLIANCE_VERSION1 = /^https?:\/\/library\.stanford\.edu\/iiif\/image-api\/(?:1\.1\/)?compliance\.html#level[0-2]$/;
var COMPLIANCE_VERSION2 = /^https?:\/\/iiif\.io\/api\/image\/2\/level[0-2](?:\.json)?$/;
var COMPLIANCE_VERSION3 = /(^https?:\/\/iiif\.io\/api\/image\/3\/level[0-2](?:\.json)?$)|(^level[0-2]$)/;
function generateVersion1Options(iiifInfo) {
var levelProfile = iiifInfo.getComplianceLevelSupportedFeatures();
// Version 1.0 and 1.1 do not require a profile.
if (levelProfile === undefined) {
levelProfile = IIIF_PROFILE_VALUES[Versions.VERSION1]['level0'];
}
return {
url: iiifInfo.imageInfo['@id'] === undefined
? undefined
: iiifInfo.imageInfo['@id'].replace(/\/?(?:info\.json)?$/g, ''),
supports: levelProfile.supports,
formats: __spreadArray(__spreadArray([], levelProfile.formats, true), [
iiifInfo.imageInfo.formats === undefined
? []
: iiifInfo.imageInfo.formats,
], false),
qualities: __spreadArray(__spreadArray([], levelProfile.qualities, true), [
iiifInfo.imageInfo.qualities === undefined
? []
: iiifInfo.imageInfo.qualities,
], false),
resolutions: iiifInfo.imageInfo.scale_factors,
tileSize: iiifInfo.imageInfo.tile_width !== undefined
? iiifInfo.imageInfo.tile_height !== undefined
? [iiifInfo.imageInfo.tile_width, iiifInfo.imageInfo.tile_height]
: [iiifInfo.imageInfo.tile_width, iiifInfo.imageInfo.tile_width]
: iiifInfo.imageInfo.tile_height != undefined
? [iiifInfo.imageInfo.tile_height, iiifInfo.imageInfo.tile_height]
: undefined,
};
}
function generateVersion2Options(iiifInfo) {
var levelProfile = iiifInfo.getComplianceLevelSupportedFeatures(), additionalProfile = Array.isArray(iiifInfo.imageInfo.profile) &&
iiifInfo.imageInfo.profile.length > 1, profileSupports = additionalProfile && iiifInfo.imageInfo.profile[1].supports
? iiifInfo.imageInfo.profile[1].supports
: [], profileFormats = additionalProfile && iiifInfo.imageInfo.profile[1].formats
? iiifInfo.imageInfo.profile[1].formats
: [], profileQualities = additionalProfile && iiifInfo.imageInfo.profile[1].qualities
? iiifInfo.imageInfo.profile[1].qualities
: [];
return {
url: iiifInfo.imageInfo['@id'].replace(/\/?(?:info\.json)?$/g, ''),
sizes: iiifInfo.imageInfo.sizes === undefined
? undefined
: iiifInfo.imageInfo.sizes.map(function (size) {
return [size.width, size.height];
}),
tileSize: iiifInfo.imageInfo.tiles === undefined
? undefined
: [
iiifInfo.imageInfo.tiles.map(function (tile) {
return tile.width;
})[0],
iiifInfo.imageInfo.tiles.map(function (tile) {
return tile.height === undefined ? tile.width : tile.height;
})[0],
],
resolutions: iiifInfo.imageInfo.tiles === undefined
? undefined
: iiifInfo.imageInfo.tiles.map(function (tile) {
return tile.scaleFactors;
})[0],
supports: __spreadArray(__spreadArray([], levelProfile.supports, true), profileSupports, true),
formats: __spreadArray(__spreadArray([], levelProfile.formats, true), profileFormats, true),
qualities: __spreadArray(__spreadArray([], levelProfile.qualities, true), profileQualities, true),
};
}
function generateVersion3Options(iiifInfo) {
var levelProfile = iiifInfo.getComplianceLevelSupportedFeatures(), formats = iiifInfo.imageInfo.extraFormats === undefined
? levelProfile.formats
: __spreadArray(__spreadArray([], levelProfile.formats, true), iiifInfo.imageInfo.extraFormats, true), preferredFormat = iiifInfo.imageInfo.preferredFormats !== undefined &&
Array.isArray(iiifInfo.imageInfo.preferredFormats) &&
iiifInfo.imageInfo.preferredFormats.length > 0
? iiifInfo.imageInfo.preferredFormats
.filter(function (format) {
return includes(['jpg', 'png', 'gif'], format);
})
.reduce(function (acc, format) {
return acc === undefined && includes(formats, format)
? format
: acc;
}, undefined)
: undefined;
return {
url: iiifInfo.imageInfo['id'],
sizes: iiifInfo.imageInfo.sizes === undefined
? undefined
: iiifInfo.imageInfo.sizes.map(function (size) {
return [size.width, size.height];
}),
tileSize: iiifInfo.imageInfo.tiles === undefined
? undefined
: [
iiifInfo.imageInfo.tiles.map(function (tile) {
return tile.width;
})[0],
iiifInfo.imageInfo.tiles.map(function (tile) {
return tile.height;
})[0],
],
resolutions: iiifInfo.imageInfo.tiles === undefined
? undefined
: iiifInfo.imageInfo.tiles.map(function (tile) {
return tile.scaleFactors;
})[0],
supports: iiifInfo.imageInfo.extraFeatures === undefined
? levelProfile.supports
: __spreadArray(__spreadArray([], levelProfile.supports, true), iiifInfo.imageInfo.extraFeatures, true),
formats: formats,
qualities: iiifInfo.imageInfo.extraQualities === undefined
? levelProfile.qualities
: __spreadArray(__spreadArray([], levelProfile.qualities, true), iiifInfo.imageInfo.extraQualities, true),
preferredFormat: preferredFormat,
};
}
var versionFunctions = {};
versionFunctions[Versions.VERSION1] = generateVersion1Options;
versionFunctions[Versions.VERSION2] = generateVersion2Options;
versionFunctions[Versions.VERSION3] = generateVersion3Options;
/**
* @classdesc
* Format for transforming IIIF Image API image information responses into
* IIIF tile source ready options
*
* @api
*/
var IIIFInfo = /** @class */ (function () {
/**
* @param {string|ImageInformationResponse} imageInfo
* Deserialized image information JSON response object or JSON response as string
*/
function IIIFInfo(imageInfo) {
this.setImageInfo(imageInfo);
}
/**
* @param {string|ImageInformationResponse} imageInfo
* Deserialized image information JSON response object or JSON response as string
* @api
*/
IIIFInfo.prototype.setImageInfo = function (imageInfo) {
if (typeof imageInfo == 'string') {
this.imageInfo = JSON.parse(imageInfo);
}
else {
this.imageInfo = imageInfo;
}
};
/**
* @return {Versions} Major IIIF version.
* @api
*/
IIIFInfo.prototype.getImageApiVersion = function () {
if (this.imageInfo === undefined) {
return;
}
var context = this.imageInfo['@context'] || 'ol-no-context';
if (typeof context == 'string') {
context = [context];
}
for (var i = 0; i < context.length; i++) {
switch (context[i]) {
case 'http://library.stanford.edu/iiif/image-api/1.1/context.json':
case 'http://iiif.io/api/image/1/context.json':
return Versions.VERSION1;
case 'http://iiif.io/api/image/2/context.json':
return Versions.VERSION2;
case 'http://iiif.io/api/image/3/context.json':
return Versions.VERSION3;
case 'ol-no-context':
// Image API 1.0 has no '@context'
if (this.getComplianceLevelEntryFromProfile(Versions.VERSION1) &&
this.imageInfo.identifier) {
return Versions.VERSION1;
}
break;
default:
}
}
assert(false, 61);
};
/**
* @param {Versions} version Optional IIIF image API version
* @return {string} Compliance level as it appears in the IIIF image information
* response.
*/
IIIFInfo.prototype.getComplianceLevelEntryFromProfile = function (version) {
if (this.imageInfo === undefined || this.imageInfo.profile === undefined) {
return;
}
if (version === undefined) {
version = this.getImageApiVersion();
}
switch (version) {
case Versions.VERSION1:
if (COMPLIANCE_VERSION1.test(this.imageInfo.profile)) {
return this.imageInfo.profile;
}
break;
case Versions.VERSION3:
if (COMPLIANCE_VERSION3.test(this.imageInfo.profile)) {
return this.imageInfo.profile;
}
break;
case Versions.VERSION2:
if (typeof this.imageInfo.profile === 'string' &&
COMPLIANCE_VERSION2.test(this.imageInfo.profile)) {
return this.imageInfo.profile;
}
if (Array.isArray(this.imageInfo.profile) &&
this.imageInfo.profile.length > 0 &&
typeof this.imageInfo.profile[0] === 'string' &&
COMPLIANCE_VERSION2.test(this.imageInfo.profile[0])) {
return this.imageInfo.profile[0];
}
break;
default:
}
};
/**
* @param {Versions} version Optional IIIF image API version
* @return {string} Compliance level, on of 'level0', 'level1' or 'level2' or undefined
*/
IIIFInfo.prototype.getComplianceLevelFromProfile = function (version) {
var complianceLevel = this.getComplianceLevelEntryFromProfile(version);
if (complianceLevel === undefined) {
return undefined;
}
var level = complianceLevel.match(/level[0-2](?:\.json)?$/g);
return Array.isArray(level) ? level[0].replace('.json', '') : undefined;
};
/**
* @return {SupportedFeatures} Image formats, qualities and region / size calculation
* methods that are supported by the IIIF service.
*/
IIIFInfo.prototype.getComplianceLevelSupportedFeatures = function () {
if (this.imageInfo === undefined) {
return;
}
var version = this.getImageApiVersion();
var level = this.getComplianceLevelFromProfile(version);
if (level === undefined) {
return IIIF_PROFILE_VALUES['none']['none'];
}
return IIIF_PROFILE_VALUES[version][level];
};
/**
* @param {PreferredOptions} [opt_preferredOptions] Optional options for preferred format and quality.
* @return {import("../source/IIIF.js").Options} IIIF tile source ready constructor options.
* @api
*/
IIIFInfo.prototype.getTileSourceOptions = function (opt_preferredOptions) {
var options = opt_preferredOptions || {}, version = this.getImageApiVersion();
if (version === undefined) {
return;
}
var imageOptions = version === undefined ? undefined : versionFunctions[version](this);
if (imageOptions === undefined) {
return;
}
return {
url: imageOptions.url,
version: version,
size: [this.imageInfo.width, this.imageInfo.height],
sizes: imageOptions.sizes,
format: options.format !== undefined &&
includes(imageOptions.formats, options.format)
? options.format
: imageOptions.preferredFormat !== undefined
? imageOptions.preferredFormat
: 'jpg',
supports: imageOptions.supports,
quality: options.quality && includes(imageOptions.qualities, options.quality)
? options.quality
: includes(imageOptions.qualities, 'native')
? 'native'
: 'default',
resolutions: Array.isArray(imageOptions.resolutions)
? imageOptions.resolutions.sort(function (a, b) {
return b - a;
})
: undefined,
tileSize: imageOptions.tileSize,
};
};
return IIIFInfo;
}());
export default IIIFInfo;
//# sourceMappingURL=IIIFInfo.js.map
+1
View File
File diff suppressed because one or more lines are too long
+120
View File
@@ -0,0 +1,120 @@
export default JSONFeature;
/**
* @classdesc
* Abstract base class; normally only used for creating subclasses and not
* instantiated in apps.
* Base class for JSON feature formats.
*
* @abstract
*/
declare class JSONFeature extends FeatureFormat {
/**
* Read a feature. Only works for a single feature. Use `readFeatures` to
* read a feature collection.
*
* @param {ArrayBuffer|Document|Element|Object|string} source Source.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../Feature.js").default} Feature.
* @api
*/
readFeature(source: ArrayBuffer | Document | Element | any | string, opt_options?: import("./Feature.js").ReadOptions | undefined): import("../Feature.js").default;
/**
* Read all features. Works with both a single feature and a feature
* collection.
*
* @param {ArrayBuffer|Document|Element|Object|string} source Source.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {Array<import("../Feature.js").default>} Features.
* @api
*/
readFeatures(source: ArrayBuffer | Document | Element | any | string, opt_options?: import("./Feature.js").ReadOptions | undefined): Array<import("../Feature.js").default>;
/**
* @abstract
* @param {Object} object Object.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../Feature.js").default} Feature.
*/
protected readFeatureFromObject(object: any, opt_options?: import("./Feature.js").ReadOptions | undefined): import("../Feature.js").default;
/**
* @abstract
* @param {Object} object Object.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {Array<import("../Feature.js").default>} Features.
*/
protected readFeaturesFromObject(object: any, opt_options?: import("./Feature.js").ReadOptions | undefined): Array<import("../Feature.js").default>;
/**
* @abstract
* @param {Object} object Object.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../geom/Geometry.js").default} Geometry.
*/
protected readGeometryFromObject(object: any, opt_options?: import("./Feature.js").ReadOptions | undefined): import("../geom/Geometry.js").default;
/**
* Read the projection.
*
* @param {ArrayBuffer|Document|Element|Object|string} source Source.
* @return {import("../proj/Projection.js").default} Projection.
* @api
*/
readProjection(source: ArrayBuffer | Document | Element | any | string): import("../proj/Projection.js").default;
/**
* @abstract
* @param {Object} object Object.
* @protected
* @return {import("../proj/Projection.js").default} Projection.
*/
protected readProjectionFromObject(object: any): import("../proj/Projection.js").default;
/**
* Encode a feature as string.
*
* @param {import("../Feature.js").default} feature Feature.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string} Encoded feature.
* @api
*/
writeFeature(feature: import("../Feature.js").default, opt_options?: import("./Feature.js").WriteOptions | undefined): string;
/**
* @abstract
* @param {import("../Feature.js").default} feature Feature.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {Object} Object.
*/
writeFeatureObject(feature: import("../Feature.js").default, opt_options?: import("./Feature.js").WriteOptions | undefined): any;
/**
* Encode an array of features as string.
*
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string} Encoded features.
* @api
*/
writeFeatures(features: Array<import("../Feature.js").default>, opt_options?: import("./Feature.js").WriteOptions | undefined): string;
/**
* @abstract
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {Object} Object.
*/
writeFeaturesObject(features: Array<import("../Feature.js").default>, opt_options?: import("./Feature.js").WriteOptions | undefined): any;
/**
* Encode a geometry as string.
*
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string} Encoded geometry.
* @api
*/
writeGeometry(geometry: import("../geom/Geometry.js").default, opt_options?: import("./Feature.js").WriteOptions | undefined): string;
/**
* @abstract
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {Object} Object.
*/
writeGeometryObject(geometry: import("../geom/Geometry.js").default, opt_options?: import("./Feature.js").WriteOptions | undefined): any;
}
import FeatureFormat from "./Feature.js";
//# sourceMappingURL=JSONFeature.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"JSONFeature.d.ts","sourceRoot":"","sources":["../src/format/JSONFeature.js"],"names":[],"mappings":";AAMA;;;;;;;GAOG;AACH;IAYE;;;;;;;;OAQG;IACH,oBALW,WAAW,GAAC,QAAQ,GAAC,OAAO,SAAQ,MAAM,iEAEzC,OAAO,eAAe,EAAE,OAAO,CAQ1C;IAED;;;;;;;;OAQG;IACH,qBALW,WAAW,GAAC,QAAQ,GAAC,OAAO,SAAQ,MAAM,iEAEzC,MAAM,OAAO,eAAe,EAAE,OAAO,CAAC,CAQjD;IAED;;;;;;OAMG;IACH,4GAFY,OAAO,eAAe,EAAE,OAAO,CAI1C;IAED;;;;;;OAMG;IACH,6GAFY,MAAM,OAAO,eAAe,EAAE,OAAO,CAAC,CAIjD;IAiBD;;;;;;OAMG;IACH,6GAFY,OAAO,qBAAqB,EAAE,OAAO,CAIhD;IAED;;;;;;OAMG;IACH,uBAJW,WAAW,GAAC,QAAQ,GAAC,OAAO,SAAQ,MAAM,GACzC,OAAO,uBAAuB,EAAE,OAAO,CAKlD;IAED;;;;;OAKG;IACH,iDAFY,OAAO,uBAAuB,EAAE,OAAO,CAIlD;IAED;;;;;;;OAOG;IACH,sBALW,OAAO,eAAe,EAAE,OAAO,kEAE9B,MAAM,CAKjB;IAED;;;;;OAKG;IACH,4BAJW,OAAO,eAAe,EAAE,OAAO,sEAMzC;IAED;;;;;;;OAOG;IACH,wBALW,MAAM,OAAO,eAAe,EAAE,OAAO,CAAC,kEAErC,MAAM,CAKjB;IAED;;;;;OAKG;IACH,8BAJW,MAAM,OAAO,eAAe,EAAE,OAAO,CAAC,sEAMhD;IAED;;;;;;;OAOG;IACH,wBALW,OAAO,qBAAqB,EAAE,OAAO,kEAEpC,MAAM,CAKjB;IAED;;;;;OAKG;IACH,8BAJW,OAAO,qBAAqB,EAAE,OAAO,sEAM/C;CACF"}
+203
View File
@@ -0,0 +1,203 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/format/JSONFeature
*/
import FeatureFormat from './Feature.js';
import { abstract } from '../util.js';
/**
* @classdesc
* Abstract base class; normally only used for creating subclasses and not
* instantiated in apps.
* Base class for JSON feature formats.
*
* @abstract
*/
var JSONFeature = /** @class */ (function (_super) {
__extends(JSONFeature, _super);
function JSONFeature() {
return _super.call(this) || this;
}
/**
* @return {import("./Feature.js").Type} Format.
*/
JSONFeature.prototype.getType = function () {
return 'json';
};
/**
* Read a feature. Only works for a single feature. Use `readFeatures` to
* read a feature collection.
*
* @param {ArrayBuffer|Document|Element|Object|string} source Source.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../Feature.js").default} Feature.
* @api
*/
JSONFeature.prototype.readFeature = function (source, opt_options) {
return this.readFeatureFromObject(getObject(source), this.getReadOptions(source, opt_options));
};
/**
* Read all features. Works with both a single feature and a feature
* collection.
*
* @param {ArrayBuffer|Document|Element|Object|string} source Source.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {Array<import("../Feature.js").default>} Features.
* @api
*/
JSONFeature.prototype.readFeatures = function (source, opt_options) {
return this.readFeaturesFromObject(getObject(source), this.getReadOptions(source, opt_options));
};
/**
* @abstract
* @param {Object} object Object.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../Feature.js").default} Feature.
*/
JSONFeature.prototype.readFeatureFromObject = function (object, opt_options) {
return abstract();
};
/**
* @abstract
* @param {Object} object Object.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {Array<import("../Feature.js").default>} Features.
*/
JSONFeature.prototype.readFeaturesFromObject = function (object, opt_options) {
return abstract();
};
/**
* Read a geometry.
*
* @param {ArrayBuffer|Document|Element|Object|string} source Source.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../geom/Geometry.js").default} Geometry.
* @api
*/
JSONFeature.prototype.readGeometry = function (source, opt_options) {
return this.readGeometryFromObject(getObject(source), this.getReadOptions(source, opt_options));
};
/**
* @abstract
* @param {Object} object Object.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../geom/Geometry.js").default} Geometry.
*/
JSONFeature.prototype.readGeometryFromObject = function (object, opt_options) {
return abstract();
};
/**
* Read the projection.
*
* @param {ArrayBuffer|Document|Element|Object|string} source Source.
* @return {import("../proj/Projection.js").default} Projection.
* @api
*/
JSONFeature.prototype.readProjection = function (source) {
return this.readProjectionFromObject(getObject(source));
};
/**
* @abstract
* @param {Object} object Object.
* @protected
* @return {import("../proj/Projection.js").default} Projection.
*/
JSONFeature.prototype.readProjectionFromObject = function (object) {
return abstract();
};
/**
* Encode a feature as string.
*
* @param {import("../Feature.js").default} feature Feature.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string} Encoded feature.
* @api
*/
JSONFeature.prototype.writeFeature = function (feature, opt_options) {
return JSON.stringify(this.writeFeatureObject(feature, opt_options));
};
/**
* @abstract
* @param {import("../Feature.js").default} feature Feature.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {Object} Object.
*/
JSONFeature.prototype.writeFeatureObject = function (feature, opt_options) {
return abstract();
};
/**
* Encode an array of features as string.
*
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string} Encoded features.
* @api
*/
JSONFeature.prototype.writeFeatures = function (features, opt_options) {
return JSON.stringify(this.writeFeaturesObject(features, opt_options));
};
/**
* @abstract
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {Object} Object.
*/
JSONFeature.prototype.writeFeaturesObject = function (features, opt_options) {
return abstract();
};
/**
* Encode a geometry as string.
*
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string} Encoded geometry.
* @api
*/
JSONFeature.prototype.writeGeometry = function (geometry, opt_options) {
return JSON.stringify(this.writeGeometryObject(geometry, opt_options));
};
/**
* @abstract
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {Object} Object.
*/
JSONFeature.prototype.writeGeometryObject = function (geometry, opt_options) {
return abstract();
};
return JSONFeature;
}(FeatureFormat));
/**
* @param {Document|Element|Object|string} source Source.
* @return {Object} Object.
*/
function getObject(source) {
if (typeof source === 'string') {
var object = JSON.parse(source);
return object ? /** @type {Object} */ (object) : null;
}
else if (source !== null) {
return source;
}
else {
return null;
}
}
export default JSONFeature;
//# sourceMappingURL=JSONFeature.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"JSONFeature.js","sourceRoot":"","sources":["../src/format/JSONFeature.js"],"names":[],"mappings":"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"}
+260
View File
@@ -0,0 +1,260 @@
/**
* Get the default fill style (or null if not yet set).
* @return {Fill|null} The default fill style.
*/
export function getDefaultFillStyle(): Fill | null;
/**
* Get the default image style (or null if not yet set).
* @return {import("../style/Image.js").default|null} The default image style.
*/
export function getDefaultImageStyle(): import("../style/Image.js").default | null;
/**
* Get the default stroke style (or null if not yet set).
* @return {Stroke|null} The default stroke style.
*/
export function getDefaultStrokeStyle(): Stroke | null;
/**
* Get the default text style (or null if not yet set).
* @return {Text|null} The default text style.
*/
export function getDefaultTextStyle(): Text | null;
/**
* Get the default style (or null if not yet set).
* @return {Style|null} The default style.
*/
export function getDefaultStyle(): Style | null;
/**
* Get the default style array (or null if not yet set).
* @return {Array<Style>|null} The default style.
*/
export function getDefaultStyleArray(): Array<Style> | null;
/**
* @param {Node} node Node.
* @return {Array<number>|undefined} Flat coordinates.
*/
export function readFlatCoordinates(node: Node): Array<number> | undefined;
export default KML;
/**
* 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.
*/
export type IconUrlFunction = (arg0: string) => string;
export type Vec2 = {
/**
* X coordinate.
*/
x: number;
/**
* Units of x.
*/
xunits: any;
/**
* Y coordinate.
*/
y: number;
/**
* Units of Y.
*/
yunits: any;
/**
* Origin.
*/
origin?: any;
};
export type GxTrackObject = {
/**
* Coordinates.
*/
coordinates: Array<Array<number>>;
/**
* Whens.
*/
whens: Array<number>;
};
export type Options = {
/**
* Extract styles from the KML.
*/
extractStyles?: boolean | undefined;
/**
* Show names as labels for placemarks which contain points.
*/
showPointNames?: boolean | undefined;
/**
* Default style. The
* default default style is the same as Google Earth.
*/
defaultStyle?: Style[] | undefined;
/**
* Write styles into KML.
*/
writeStyles?: boolean | undefined;
/**
* 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.
*/
crossOrigin?: string | null | undefined;
/**
* 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.
*/
iconUrlFunction?: IconUrlFunction | undefined;
};
import Fill from "../style/Fill.js";
import Stroke from "../style/Stroke.js";
import Text from "../style/Text.js";
import Style from "../style/Style.js";
/**
* @typedef {Object} Options
* @property {boolean} [extractStyles=true] Extract styles from the KML.
* @property {boolean} [showPointNames=true] Show names as labels for placemarks which contain points.
* @property {Array<Style>} [defaultStyle] Default style. The
* default default style is the same as Google Earth.
* @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.
*/
/**
* @classdesc
* Feature format for reading and writing data in the KML format.
*
* {@link module:ol/format/KML~KML#readFeature} will read the first feature from
* a KML source.
*
* MultiGeometries are converted into GeometryCollections if they are a mix of
* geometry types, and into MultiPoint/MultiLineString/MultiPolygon if they are
* all of the same type.
*
* Note that the KML format uses the URL() constructor. Older browsers such as IE
* which do not support this will need a URL polyfill to be loaded before use.
*
* @api
*/
declare class KML extends XMLFeature {
/**
* @param {Options} [opt_options] Options.
*/
constructor(opt_options?: Options | undefined);
/**
* @type {import("../proj/Projection.js").default}
*/
dataProjection: import("../proj/Projection.js").default;
/**
* @private
* @type {Array<Style>}
*/
private defaultStyle_;
/**
* @private
* @type {boolean}
*/
private extractStyles_;
/**
* @type {boolean}
*/
writeStyles_: boolean;
/**
* @private
* @type {!Object<string, (Array<Style>|string)>}
*/
private sharedStyles_;
/**
* @private
* @type {boolean}
*/
private showPointNames_;
/**
* @type {null|string}
*/
crossOrigin_: null | string;
/**
* @type {IconUrlFunction}
*/
iconUrlFunction_: IconUrlFunction;
/**
* @param {Node} node Node.
* @param {Array<*>} objectStack Object stack.
* @private
* @return {Array<Feature>|undefined} Features.
*/
private readDocumentOrFolder_;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @private
* @return {Feature|undefined} Feature.
*/
private readPlacemark_;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @private
*/
private readSharedStyle_;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @private
*/
private readSharedStyleMap_;
/**
* Read the name of the KML.
*
* @param {Document|Element|string} source Source.
* @return {string|undefined} Name.
* @api
*/
readName(source: Document | Element | string): string | undefined;
/**
* @param {Document} doc Document.
* @return {string|undefined} Name.
*/
readNameFromDocument(doc: Document): string | undefined;
/**
* @param {Element} node Node.
* @return {string|undefined} Name.
*/
readNameFromNode(node: Element): string | undefined;
/**
* Read the network links of the KML.
*
* @param {Document|Element|string} source Source.
* @return {Array<Object>} Network links.
* @api
*/
readNetworkLinks(source: Document | Element | string): Array<any>;
/**
* @param {Document} doc Document.
* @return {Array<Object>} Network links.
*/
readNetworkLinksFromDocument(doc: Document): Array<any>;
/**
* @param {Element} node Node.
* @return {Array<Object>} Network links.
*/
readNetworkLinksFromNode(node: Element): Array<any>;
/**
* Read the regions of the KML.
*
* @param {Document|Element|string} source Source.
* @return {Array<Object>} Regions.
* @api
*/
readRegion(source: Document | Element | string): Array<any>;
/**
* @param {Document} doc Document.
* @return {Array<Object>} Region.
*/
readRegionFromDocument(doc: Document): Array<any>;
/**
* @param {Element} node Node.
* @return {Array<Object>} Region.
* @api
*/
readRegionFromNode(node: Element): Array<any>;
}
import XMLFeature from "./XMLFeature.js";
//# sourceMappingURL=KML.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"KML.d.ts","sourceRoot":"","sources":["../src/format/KML.js"],"names":[],"mappings":"AAwMA;;;GAGG;AACH,uCAFY,IAAI,GAAC,IAAI,CAIpB;AAgCD;;;GAGG;AACH,wCAFY,OAAO,mBAAmB,EAAE,OAAO,GAAC,IAAI,CAInD;AAYD;;;GAGG;AACH,yCAFY,MAAM,GAAC,IAAI,CAItB;AAYD;;;GAGG;AACH,uCAFY,IAAI,GAAC,IAAI,CAIpB;AAOD;;;GAGG;AACH,mCAFY,KAAK,GAAC,IAAI,CAIrB;AAOD;;;GAGG;AACH,wCAFY,MAAM,KAAK,CAAC,GAAC,IAAI,CAI5B;AA8xBD;;;GAGG;AACH,0CAHW,IAAI,GACH,MAAM,MAAM,CAAC,GAAC,SAAS,CAsBlC;;;;;;;qCAruBqB,MAAM,KAAE,MAAM;;;;;OAzUtB,MAAM;;;;;;;;OAEN,MAAM;;;;;;;;;;;;;;iBAON,MAAM,MAAM,MAAM,CAAC,CAAC;;;;WACpB,MAAM,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4U3B;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;;;;;GAeG;AACH;IACE;;OAEG;IACH,+CA8DC;IArDC;;OAEG;IACH,gBAFU,OAAO,uBAAuB,EAAE,OAAO,CAED;IAEhD;;;OAGG;IACH,sBAEuB;IAEvB;;;OAGG;IACH,uBACoE;IAEpE;;OAEG;IACH,cAFU,OAAO,CAG+C;IAEhE;;;OAGG;IACH,sBAAuB;IAEvB;;;OAGG;IACH,wBACsE;IAEtE;;OAEG;IACH,cAFU,IAAI,GAAC,MAAM,CAGkD;IAEvE;;OAEG;IACH,kBAFU,eAAe,CAIC;IAK5B;;;;;OAKG;IACH,8BAiBC;IAED;;;;;OAKG;IACH,uBA8CC;IAED;;;;OAIG;IACH,yBAmBC;IAED;;;;OAIG;IACH,4BAqBC;IAiED;;;;;;OAMG;IACH,iBAJW,QAAQ,GAAC,OAAO,GAAC,MAAM,GACtB,MAAM,GAAC,SAAS,CAc3B;IAED;;;OAGG;IACH,0BAHW,QAAQ,GACP,MAAM,GAAC,SAAS,CAY3B;IAED;;;OAGG;IACH,uBAHW,OAAO,GACN,MAAM,GAAC,SAAS,CAwB3B;IAED;;;;;;OAMG;IACH,yBAJW,QAAQ,GAAC,OAAO,GAAC,MAAM,GACtB,UAAa,CAoBxB;IAED;;;OAGG;IACH,kCAHW,QAAQ,GACP,UAAa,CAaxB;IAED;;;OAGG;IACH,+BAHW,OAAO,GACN,UAAa,CAuBxB;IAED;;;;;;OAMG;IACH,mBAJW,QAAQ,GAAC,OAAO,GAAC,MAAM,GACtB,UAAa,CAiBxB;IAED;;;OAGG;IACH,4BAHW,QAAQ,GACP,UAAa,CAUxB;IAED;;;;OAIG;IACH,yBAJW,OAAO,GACN,UAAa,CAqBxB;CA8CF"}
+2870
View File
File diff suppressed because it is too large Load Diff
+1
View File
File diff suppressed because one or more lines are too long
+125
View File
@@ -0,0 +1,125 @@
export default MVT;
export type Options = {
/**
* Class for features returned by
* {@link module :ol/format/MVT~MVT#readFeatures}. Set to {@link module :ol/Feature~Feature} to get full editing and geometry
* support at the cost of decreased rendering performance. The default is
* {@link module :ol/render/Feature~RenderFeature}, which is optimized for rendering and hit detection.
*/
featureClass?: import("../Feature.js").FeatureClass | undefined;
/**
* Geometry name to use when creating features.
*/
geometryName?: string | undefined;
/**
* Name of the feature attribute that holds the layer name.
*/
layerName?: string | undefined;
/**
* Layers to read features from. If not provided, features will be read from all
*/
layers?: string[] | undefined;
/**
* Optional property that will be assigned as the feature id and removed from the properties.
* layers.
*/
idProperty?: string | undefined;
};
/**
* @typedef {Object} Options
* @property {import("../Feature.js").FeatureClass} [featureClass] Class for features returned by
* {@link module:ol/format/MVT~MVT#readFeatures}. Set to {@link module:ol/Feature~Feature} to get full editing and geometry
* support at the cost of decreased rendering performance. The default is
* {@link module:ol/render/Feature~RenderFeature}, which is optimized for rendering and hit detection.
* @property {string} [geometryName='geometry'] Geometry name to use when creating features.
* @property {string} [layerName='layer'] Name of the feature attribute that holds the layer name.
* @property {Array<string>} [layers] Layers to read features from. If not provided, features will be read from all
* @property {string} [idProperty] Optional property that will be assigned as the feature id and removed from the properties.
* layers.
*/
/**
* @classdesc
* Feature format for reading data in the Mapbox MVT format.
*
* @param {Options} [opt_options] Options.
* @api
*/
declare class MVT extends FeatureFormat {
/**
* @param {Options} [opt_options] Options.
*/
constructor(opt_options?: Options | undefined);
/**
* @type {Projection}
*/
dataProjection: Projection;
/**
* @private
* @type {import("../Feature.js").FeatureClass}
*/
private featureClass_;
/**
* @private
* @type {string|undefined}
*/
private geometryName_;
/**
* @private
* @type {string}
*/
private layerName_;
/**
* @private
* @type {Array<string>|null}
*/
private layers_;
/**
* @private
* @type {string}
*/
private idProperty_;
/**
* Read the raw geometry from the pbf offset stored in a raw feature's geometry
* property.
* @param {PBF} pbf PBF.
* @param {Object} feature Raw feature.
* @param {Array<number>} flatCoordinates Array to store flat coordinates in.
* @param {Array<number>} ends Array to store ends in.
* @private
*/
private readRawGeometry_;
/**
* @private
* @param {PBF} pbf PBF
* @param {Object} rawFeature Raw Mapbox feature.
* @param {import("./Feature.js").ReadOptions} options Read options.
* @return {import("../Feature.js").FeatureLike|null} Feature.
*/
private createFeature_;
/**
* Read all features.
*
* @param {ArrayBuffer} source Source.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {Array<import("../Feature.js").FeatureLike>} Features.
* @api
*/
readFeatures(source: ArrayBuffer, opt_options?: import("./Feature.js").ReadOptions | undefined): Array<import("../Feature.js").FeatureLike>;
/**
* Read the projection from the source.
*
* @param {Document|Element|Object|string} source Source.
* @return {import("../proj/Projection.js").default} Projection.
* @api
*/
readProjection(source: Document | Element | any | string): import("../proj/Projection.js").default;
/**
* Sets the layers that features will be read from.
* @param {Array<string>} layers Layers.
* @api
*/
setLayers(layers: Array<string>): void;
}
import FeatureFormat from "./Feature.js";
import Projection from "../proj/Projection.js";
//# sourceMappingURL=MVT.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"MVT.d.ts","sourceRoot":"","sources":["../src/format/MVT.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA;;;;;;;;;;;GAWG;AAEH;;;;;;GAMG;AACH;IACE;;OAEG;IACH,+CAiDC;IA5CC;;OAEG;IACH,gBAFU,UAAU,CAKlB;IAEF;;;OAGG;IACH,sBAEiB;IAEjB;;;OAGG;IACH,sBAAyC;IAEzC;;;OAGG;IACH,mBAAiE;IAEjE;;;OAGG;IACH,gBAAqD;IAErD;;;OAGG;IACH,oBAAqC;IAQvC;;;;;;;;OAQG;IACH,yBAoDC;IAED;;;;;;OAMG;IACH,uBAsEC;IASD;;;;;;;OAOG;IACH,qBALW,WAAW,iEAEV,MAAM,OAAO,eAAe,EAAE,WAAW,CAAC,CAkCrD;IAED;;;;;;OAMG;IACH,uBAJW,QAAQ,GAAC,OAAO,SAAQ,MAAM,GAC7B,OAAO,uBAAuB,EAAE,OAAO,CAKlD;IAED;;;;OAIG;IACH,kBAHW,MAAM,MAAM,CAAC,QAKvB;CACF"}
+416
View File
@@ -0,0 +1,416 @@
/**
* @module ol/format/MVT
*/
//FIXME Implement projection handling
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import FeatureFormat, { transformGeometryWithOptions } from './Feature.js';
import GeometryLayout from '../geom/GeometryLayout.js';
import LineString from '../geom/LineString.js';
import MultiLineString from '../geom/MultiLineString.js';
import MultiPoint from '../geom/MultiPoint.js';
import MultiPolygon from '../geom/MultiPolygon.js';
import PBF from 'pbf';
import Point from '../geom/Point.js';
import Polygon from '../geom/Polygon.js';
import Projection from '../proj/Projection.js';
import RenderFeature from '../render/Feature.js';
import Units from '../proj/Units.js';
import { assert } from '../asserts.js';
import { get } from '../proj.js';
import { inflateEnds } from '../geom/flat/orient.js';
/**
* @typedef {Object} Options
* @property {import("../Feature.js").FeatureClass} [featureClass] Class for features returned by
* {@link module:ol/format/MVT~MVT#readFeatures}. Set to {@link module:ol/Feature~Feature} to get full editing and geometry
* support at the cost of decreased rendering performance. The default is
* {@link module:ol/render/Feature~RenderFeature}, which is optimized for rendering and hit detection.
* @property {string} [geometryName='geometry'] Geometry name to use when creating features.
* @property {string} [layerName='layer'] Name of the feature attribute that holds the layer name.
* @property {Array<string>} [layers] Layers to read features from. If not provided, features will be read from all
* @property {string} [idProperty] Optional property that will be assigned as the feature id and removed from the properties.
* layers.
*/
/**
* @classdesc
* Feature format for reading data in the Mapbox MVT format.
*
* @param {Options} [opt_options] Options.
* @api
*/
var MVT = /** @class */ (function (_super) {
__extends(MVT, _super);
/**
* @param {Options} [opt_options] Options.
*/
function MVT(opt_options) {
var _this = _super.call(this) || this;
var options = opt_options ? opt_options : {};
/**
* @type {Projection}
*/
_this.dataProjection = new Projection({
code: '',
units: Units.TILE_PIXELS,
});
/**
* @private
* @type {import("../Feature.js").FeatureClass}
*/
_this.featureClass_ = options.featureClass
? options.featureClass
: RenderFeature;
/**
* @private
* @type {string|undefined}
*/
_this.geometryName_ = options.geometryName;
/**
* @private
* @type {string}
*/
_this.layerName_ = options.layerName ? options.layerName : 'layer';
/**
* @private
* @type {Array<string>|null}
*/
_this.layers_ = options.layers ? options.layers : null;
/**
* @private
* @type {string}
*/
_this.idProperty_ = options.idProperty;
_this.supportedMediaTypes = [
'application/vnd.mapbox-vector-tile',
'application/x-protobuf',
];
return _this;
}
/**
* Read the raw geometry from the pbf offset stored in a raw feature's geometry
* property.
* @param {PBF} pbf PBF.
* @param {Object} feature Raw feature.
* @param {Array<number>} flatCoordinates Array to store flat coordinates in.
* @param {Array<number>} ends Array to store ends in.
* @private
*/
MVT.prototype.readRawGeometry_ = function (pbf, feature, flatCoordinates, ends) {
pbf.pos = feature.geometry;
var end = pbf.readVarint() + pbf.pos;
var cmd = 1;
var length = 0;
var x = 0;
var y = 0;
var coordsLen = 0;
var currentEnd = 0;
while (pbf.pos < end) {
if (!length) {
var cmdLen = pbf.readVarint();
cmd = cmdLen & 0x7;
length = cmdLen >> 3;
}
length--;
if (cmd === 1 || cmd === 2) {
x += pbf.readSVarint();
y += pbf.readSVarint();
if (cmd === 1) {
// moveTo
if (coordsLen > currentEnd) {
ends.push(coordsLen);
currentEnd = coordsLen;
}
}
flatCoordinates.push(x, y);
coordsLen += 2;
}
else if (cmd === 7) {
if (coordsLen > currentEnd) {
// close polygon
flatCoordinates.push(flatCoordinates[currentEnd], flatCoordinates[currentEnd + 1]);
coordsLen += 2;
}
}
else {
assert(false, 59); // Invalid command found in the PBF
}
}
if (coordsLen > currentEnd) {
ends.push(coordsLen);
currentEnd = coordsLen;
}
};
/**
* @private
* @param {PBF} pbf PBF
* @param {Object} rawFeature Raw Mapbox feature.
* @param {import("./Feature.js").ReadOptions} options Read options.
* @return {import("../Feature.js").FeatureLike|null} Feature.
*/
MVT.prototype.createFeature_ = function (pbf, rawFeature, options) {
var type = rawFeature.type;
if (type === 0) {
return null;
}
var feature;
var values = rawFeature.properties;
var id;
if (!this.idProperty_) {
id = rawFeature.id;
}
else {
id = values[this.idProperty_];
delete values[this.idProperty_];
}
values[this.layerName_] = rawFeature.layer.name;
var flatCoordinates = /** @type {Array<number>} */ ([]);
var ends = /** @type {Array<number>} */ ([]);
this.readRawGeometry_(pbf, rawFeature, flatCoordinates, ends);
var geometryType = getGeometryType(type, ends.length);
if (this.featureClass_ === RenderFeature) {
feature = new this.featureClass_(geometryType, flatCoordinates, ends, values, id);
feature.transform(options.dataProjection);
}
else {
var geom = void 0;
if (geometryType == 'Polygon') {
var endss = inflateEnds(flatCoordinates, ends);
geom =
endss.length > 1
? new MultiPolygon(flatCoordinates, GeometryLayout.XY, endss)
: new Polygon(flatCoordinates, GeometryLayout.XY, ends);
}
else {
geom =
geometryType === 'Point'
? new Point(flatCoordinates, GeometryLayout.XY)
: geometryType === 'LineString'
? new LineString(flatCoordinates, GeometryLayout.XY)
: geometryType === 'MultiPoint'
? new MultiPoint(flatCoordinates, GeometryLayout.XY)
: geometryType === 'MultiLineString'
? new MultiLineString(flatCoordinates, GeometryLayout.XY, ends)
: null;
}
var ctor = /** @type {typeof import("../Feature.js").default} */ (this.featureClass_);
feature = new ctor();
if (this.geometryName_) {
feature.setGeometryName(this.geometryName_);
}
var geometry = transformGeometryWithOptions(geom, false, options);
feature.setGeometry(geometry);
if (id !== undefined) {
feature.setId(id);
}
feature.setProperties(values, true);
}
return feature;
};
/**
* @return {import("./Feature.js").Type} Format.
*/
MVT.prototype.getType = function () {
return 'arraybuffer';
};
/**
* Read all features.
*
* @param {ArrayBuffer} source Source.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {Array<import("../Feature.js").FeatureLike>} Features.
* @api
*/
MVT.prototype.readFeatures = function (source, opt_options) {
var layers = this.layers_;
var options = /** @type {import("./Feature.js").ReadOptions} */ (this.adaptOptions(opt_options));
var dataProjection = get(options.dataProjection);
dataProjection.setWorldExtent(options.extent);
options.dataProjection = dataProjection;
var pbf = new PBF(/** @type {ArrayBuffer} */ (source));
var pbfLayers = pbf.readFields(layersPBFReader, {});
var features = [];
for (var name_1 in pbfLayers) {
if (layers && layers.indexOf(name_1) == -1) {
continue;
}
var pbfLayer = pbfLayers[name_1];
var extent = pbfLayer ? [0, 0, pbfLayer.extent, pbfLayer.extent] : null;
dataProjection.setExtent(extent);
for (var i = 0, ii = pbfLayer.length; i < ii; ++i) {
var rawFeature = readRawFeature(pbf, pbfLayer, i);
var feature = this.createFeature_(pbf, rawFeature, options);
if (feature !== null) {
features.push(feature);
}
}
}
return features;
};
/**
* Read the projection from the source.
*
* @param {Document|Element|Object|string} source Source.
* @return {import("../proj/Projection.js").default} Projection.
* @api
*/
MVT.prototype.readProjection = function (source) {
return this.dataProjection;
};
/**
* Sets the layers that features will be read from.
* @param {Array<string>} layers Layers.
* @api
*/
MVT.prototype.setLayers = function (layers) {
this.layers_ = layers;
};
return MVT;
}(FeatureFormat));
/**
* Reader callback for parsing layers.
* @param {number} tag The tag.
* @param {Object} layers The layers object.
* @param {PBF} pbf The PBF.
*/
function layersPBFReader(tag, layers, pbf) {
if (tag === 3) {
var layer = {
keys: [],
values: [],
features: [],
};
var end = pbf.readVarint() + pbf.pos;
pbf.readFields(layerPBFReader, layer, end);
layer.length = layer.features.length;
if (layer.length) {
layers[layer.name] = layer;
}
}
}
/**
* Reader callback for parsing layer.
* @param {number} tag The tag.
* @param {Object} layer The layer object.
* @param {PBF} pbf The PBF.
*/
function layerPBFReader(tag, layer, pbf) {
if (tag === 15) {
layer.version = pbf.readVarint();
}
else if (tag === 1) {
layer.name = pbf.readString();
}
else if (tag === 5) {
layer.extent = pbf.readVarint();
}
else if (tag === 2) {
layer.features.push(pbf.pos);
}
else if (tag === 3) {
layer.keys.push(pbf.readString());
}
else if (tag === 4) {
var value = null;
var end = pbf.readVarint() + pbf.pos;
while (pbf.pos < end) {
tag = pbf.readVarint() >> 3;
value =
tag === 1
? pbf.readString()
: tag === 2
? pbf.readFloat()
: tag === 3
? pbf.readDouble()
: tag === 4
? pbf.readVarint64()
: tag === 5
? pbf.readVarint()
: tag === 6
? pbf.readSVarint()
: tag === 7
? pbf.readBoolean()
: null;
}
layer.values.push(value);
}
}
/**
* Reader callback for parsing feature.
* @param {number} tag The tag.
* @param {Object} feature The feature object.
* @param {PBF} pbf The PBF.
*/
function featurePBFReader(tag, feature, pbf) {
if (tag == 1) {
feature.id = pbf.readVarint();
}
else if (tag == 2) {
var end = pbf.readVarint() + pbf.pos;
while (pbf.pos < end) {
var key = feature.layer.keys[pbf.readVarint()];
var value = feature.layer.values[pbf.readVarint()];
feature.properties[key] = value;
}
}
else if (tag == 3) {
feature.type = pbf.readVarint();
}
else if (tag == 4) {
feature.geometry = pbf.pos;
}
}
/**
* Read a raw feature from the pbf offset stored at index `i` in the raw layer.
* @param {PBF} pbf PBF.
* @param {Object} layer Raw layer.
* @param {number} i Index of the feature in the raw layer's `features` array.
* @return {Object} Raw feature.
*/
function readRawFeature(pbf, layer, i) {
pbf.pos = layer.features[i];
var end = pbf.readVarint() + pbf.pos;
var feature = {
layer: layer,
type: 0,
properties: {},
};
pbf.readFields(featurePBFReader, feature, end);
return feature;
}
/**
* @param {number} type The raw feature's geometry type
* @param {number} numEnds Number of ends of the flat coordinates of the
* geometry.
* @return {import("../geom/Geometry.js").Type} The geometry type.
*/
function getGeometryType(type, numEnds) {
/** @type {import("../geom/Geometry.js").Type} */
var geometryType;
if (type === 1) {
geometryType = numEnds === 1 ? 'Point' : 'MultiPoint';
}
else if (type === 2) {
geometryType = numEnds === 1 ? 'LineString' : 'MultiLineString';
}
else if (type === 3) {
geometryType = 'Polygon';
// MultiPolygon not relevant for rendering - winding order determines
// outer rings of polygons.
}
return geometryType;
}
export default MVT;
//# sourceMappingURL=MVT.js.map
+1
View File
File diff suppressed because one or more lines are too long
+16
View File
@@ -0,0 +1,16 @@
export default OSMXML;
/**
* @classdesc
* Feature format for reading data in the
* [OSMXML format](https://wiki.openstreetmap.org/wiki/OSM_XML).
*
* @api
*/
declare class OSMXML extends XMLFeature {
/**
* @type {import("../proj/Projection.js").default}
*/
dataProjection: import("../proj/Projection.js").default;
}
import XMLFeature from "./XMLFeature.js";
//# sourceMappingURL=OSMXML.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"OSMXML.d.ts","sourceRoot":"","sources":["../src/format/OSMXML.js"],"names":[],"mappings":";AA0CA;;;;;;GAMG;AACH;IAII;;OAEG;IACH,gBAFU,OAAO,uBAAuB,EAAE,OAAO,CAED;CAsDnD"}
+187
View File
@@ -0,0 +1,187 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/format/OSMXML
*/
// FIXME add typedef for stack state objects
import Feature from '../Feature.js';
import GeometryLayout from '../geom/GeometryLayout.js';
import LineString from '../geom/LineString.js';
import Point from '../geom/Point.js';
import Polygon from '../geom/Polygon.js';
import XMLFeature from './XMLFeature.js';
import { extend } from '../array.js';
import { get as getProjection } from '../proj.js';
import { isEmpty } from '../obj.js';
import { makeStructureNS, pushParseAndPop } from '../xml.js';
import { transformGeometryWithOptions } from './Feature.js';
/**
* @const
* @type {Array<null>}
*/
var NAMESPACE_URIS = [null];
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var WAY_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'nd': readNd,
'tag': readTag,
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var PARSERS = makeStructureNS(NAMESPACE_URIS, {
'node': readNode,
'way': readWay,
});
/**
* @classdesc
* Feature format for reading data in the
* [OSMXML format](https://wiki.openstreetmap.org/wiki/OSM_XML).
*
* @api
*/
var OSMXML = /** @class */ (function (_super) {
__extends(OSMXML, _super);
function OSMXML() {
var _this = _super.call(this) || this;
/**
* @type {import("../proj/Projection.js").default}
*/
_this.dataProjection = getProjection('EPSG:4326');
return _this;
}
/**
* @protected
* @param {Element} node Node.
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
* @return {Array<import("../Feature.js").default>} Features.
*/
OSMXML.prototype.readFeaturesFromNode = function (node, opt_options) {
var options = this.getReadOptions(node, opt_options);
if (node.localName == 'osm') {
var state = pushParseAndPop({
nodes: {},
ways: [],
features: [],
}, PARSERS, node, [options]);
// parse nodes in ways
for (var j = 0; j < state.ways.length; j++) {
var values = /** @type {Object} */ (state.ways[j]);
/** @type {Array<number>} */
var flatCoordinates = [];
for (var i = 0, ii = values.ndrefs.length; i < ii; i++) {
var point = state.nodes[values.ndrefs[i]];
extend(flatCoordinates, point);
}
var geometry = void 0;
if (values.ndrefs[0] == values.ndrefs[values.ndrefs.length - 1]) {
// closed way
geometry = new Polygon(flatCoordinates, GeometryLayout.XY, [
flatCoordinates.length,
]);
}
else {
geometry = new LineString(flatCoordinates, GeometryLayout.XY);
}
transformGeometryWithOptions(geometry, false, options);
var feature = new Feature(geometry);
if (values.id !== undefined) {
feature.setId(values.id);
}
feature.setProperties(values.tags, true);
state.features.push(feature);
}
if (state.features) {
return state.features;
}
}
return [];
};
return OSMXML;
}(XMLFeature));
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var NODE_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'tag': readTag,
});
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
function readNode(node, objectStack) {
var options = /** @type {import("./Feature.js").ReadOptions} */ (objectStack[0]);
var state = /** @type {Object} */ (objectStack[objectStack.length - 1]);
var id = node.getAttribute('id');
/** @type {import("../coordinate.js").Coordinate} */
var coordinates = [
parseFloat(node.getAttribute('lon')),
parseFloat(node.getAttribute('lat')),
];
state.nodes[id] = coordinates;
var values = pushParseAndPop({
tags: {},
}, NODE_PARSERS, node, objectStack);
if (!isEmpty(values.tags)) {
var geometry = new Point(coordinates);
transformGeometryWithOptions(geometry, false, options);
var feature = new Feature(geometry);
if (id !== undefined) {
feature.setId(id);
}
feature.setProperties(values.tags, true);
state.features.push(feature);
}
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
function readWay(node, objectStack) {
var id = node.getAttribute('id');
var values = pushParseAndPop({
id: id,
ndrefs: [],
tags: {},
}, WAY_PARSERS, node, objectStack);
var state = /** @type {Object} */ (objectStack[objectStack.length - 1]);
state.ways.push(values);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
function readNd(node, objectStack) {
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
values.ndrefs.push(node.getAttribute('ref'));
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
*/
function readTag(node, objectStack) {
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
values.tags[node.getAttribute('k')] = node.getAttribute('v');
}
export default OSMXML;
//# sourceMappingURL=OSMXML.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"OSMXML.js","sourceRoot":"","sources":["../src/format/OSMXML.js"],"names":[],"mappings":"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"}
+5
View File
@@ -0,0 +1,5 @@
export default OWS;
declare class OWS extends XML {
}
import XML from "./XML.js";
//# sourceMappingURL=OWS.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"OWS.d.ts","sourceRoot":"","sources":["../src/format/OWS.js"],"names":[],"mappings":";AA8BA;CAaC"}
+301
View File
@@ -0,0 +1,301 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/format/OWS
*/
import XML from './XML.js';
import { makeObjectPropertyPusher, makeObjectPropertySetter, makeStructureNS, pushParseAndPop, } from '../xml.js';
import { readHref } from './xlink.js';
import { readString } from './xsd.js';
/**
* @const
* @type {Array<null|string>}
*/
var NAMESPACE_URIS = [null, 'http://www.opengis.net/ows/1.1'];
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var PARSERS = makeStructureNS(NAMESPACE_URIS, {
'ServiceIdentification': makeObjectPropertySetter(readServiceIdentification),
'ServiceProvider': makeObjectPropertySetter(readServiceProvider),
'OperationsMetadata': makeObjectPropertySetter(readOperationsMetadata),
});
var OWS = /** @class */ (function (_super) {
__extends(OWS, _super);
function OWS() {
return _super.call(this) || this;
}
/**
* @param {Element} node Node.
* @return {Object} Object
*/
OWS.prototype.readFromNode = function (node) {
var owsObject = pushParseAndPop({}, PARSERS, node, []);
return owsObject ? owsObject : null;
};
return OWS;
}(XML));
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var ADDRESS_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'DeliveryPoint': makeObjectPropertySetter(readString),
'City': makeObjectPropertySetter(readString),
'AdministrativeArea': makeObjectPropertySetter(readString),
'PostalCode': makeObjectPropertySetter(readString),
'Country': makeObjectPropertySetter(readString),
'ElectronicMailAddress': makeObjectPropertySetter(readString),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var ALLOWED_VALUES_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Value': makeObjectPropertyPusher(readValue),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var CONSTRAINT_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'AllowedValues': makeObjectPropertySetter(readAllowedValues),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var CONTACT_INFO_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Phone': makeObjectPropertySetter(readPhone),
'Address': makeObjectPropertySetter(readAddress),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var DCP_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'HTTP': makeObjectPropertySetter(readHttp),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var HTTP_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Get': makeObjectPropertyPusher(readGet),
'Post': undefined, // TODO
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var OPERATION_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'DCP': makeObjectPropertySetter(readDcp),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var OPERATIONS_METADATA_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Operation': readOperation,
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var PHONE_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Voice': makeObjectPropertySetter(readString),
'Facsimile': makeObjectPropertySetter(readString),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var REQUEST_METHOD_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Constraint': makeObjectPropertyPusher(readConstraint),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var SERVICE_CONTACT_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'IndividualName': makeObjectPropertySetter(readString),
'PositionName': makeObjectPropertySetter(readString),
'ContactInfo': makeObjectPropertySetter(readContactInfo),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var SERVICE_IDENTIFICATION_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Abstract': makeObjectPropertySetter(readString),
'AccessConstraints': makeObjectPropertySetter(readString),
'Fees': makeObjectPropertySetter(readString),
'Title': makeObjectPropertySetter(readString),
'ServiceTypeVersion': makeObjectPropertySetter(readString),
'ServiceType': makeObjectPropertySetter(readString),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var SERVICE_PROVIDER_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'ProviderName': makeObjectPropertySetter(readString),
'ProviderSite': makeObjectPropertySetter(readHref),
'ServiceContact': makeObjectPropertySetter(readServiceContact),
});
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} The address.
*/
function readAddress(node, objectStack) {
return pushParseAndPop({}, ADDRESS_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} The values.
*/
function readAllowedValues(node, objectStack) {
return pushParseAndPop({}, ALLOWED_VALUES_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} The constraint.
*/
function readConstraint(node, objectStack) {
var name = node.getAttribute('name');
if (!name) {
return undefined;
}
return pushParseAndPop({ 'name': name }, CONSTRAINT_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} The contact info.
*/
function readContactInfo(node, objectStack) {
return pushParseAndPop({}, CONTACT_INFO_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} The DCP.
*/
function readDcp(node, objectStack) {
return pushParseAndPop({}, DCP_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} The GET object.
*/
function readGet(node, objectStack) {
var href = readHref(node);
if (!href) {
return undefined;
}
return pushParseAndPop({ 'href': href }, REQUEST_METHOD_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} The HTTP object.
*/
function readHttp(node, objectStack) {
return pushParseAndPop({}, HTTP_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} The operation.
*/
function readOperation(node, objectStack) {
var name = node.getAttribute('name');
var value = pushParseAndPop({}, OPERATION_PARSERS, node, objectStack);
if (!value) {
return undefined;
}
var object = /** @type {Object} */ (objectStack[objectStack.length - 1]);
object[name] = value;
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} The operations metadata.
*/
function readOperationsMetadata(node, objectStack) {
return pushParseAndPop({}, OPERATIONS_METADATA_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} The phone.
*/
function readPhone(node, objectStack) {
return pushParseAndPop({}, PHONE_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} The service identification.
*/
function readServiceIdentification(node, objectStack) {
return pushParseAndPop({}, SERVICE_IDENTIFICATION_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} The service contact.
*/
function readServiceContact(node, objectStack) {
return pushParseAndPop({}, SERVICE_CONTACT_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} The service provider.
*/
function readServiceProvider(node, objectStack) {
return pushParseAndPop({}, SERVICE_PROVIDER_PARSERS, node, objectStack);
}
/**
* @param {Node} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {string|undefined} The value.
*/
function readValue(node, objectStack) {
return readString(node);
}
export default OWS;
//# sourceMappingURL=OWS.js.map
+1
View File
File diff suppressed because one or more lines are too long
+167
View File
@@ -0,0 +1,167 @@
/**
* Encode a list of n-dimensional points and return an encoded string
*
* Attention: This function will modify the passed array!
*
* @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
* multiplied. The remaining decimal places will get rounded away.
* Default is `1e5`.
* @return {string} The encoded string.
* @api
*/
export function encodeDeltas(numbers: Array<number>, stride: number, opt_factor?: number | undefined): string;
/**
* Decode a list of n-dimensional points from an encoded string
*
* @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
* be divided. Default is `1e5`.
* @return {Array<number>} A list of n-dimensional points.
* @api
*/
export function decodeDeltas(encoded: string, stride: number, opt_factor?: number | undefined): Array<number>;
/**
* Encode a list of floating point numbers and return an encoded string
*
* 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
* multiplied. The remaining decimal places will get rounded away.
* Default is `1e5`.
* @return {string} The encoded string.
* @api
*/
export function encodeFloats(numbers: Array<number>, opt_factor?: number | undefined): string;
/**
* 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.
* Default is `1e5`.
* @return {Array<number>} A list of floating point numbers.
* @api
*/
export function decodeFloats(encoded: string, opt_factor?: number | undefined): Array<number>;
/**
* Encode a list of signed integers and return an encoded string
*
* Attention: This function will modify the passed array!
*
* @param {Array<number>} numbers A list of signed integers.
* @return {string} The encoded string.
*/
export function encodeSignedIntegers(numbers: Array<number>): string;
/**
* Decode a list of signed integers from an encoded string
*
* @param {string} encoded An encoded string.
* @return {Array<number>} A list of signed integers.
*/
export function decodeSignedIntegers(encoded: string): Array<number>;
/**
* Encode a list of unsigned integers and return an encoded string
*
* @param {Array<number>} numbers A list of unsigned integers.
* @return {string} The encoded string.
*/
export function encodeUnsignedIntegers(numbers: Array<number>): string;
/**
* Decode a list of unsigned integers from an encoded string
*
* @param {string} encoded An encoded string.
* @return {Array<number>} A list of unsigned integers.
*/
export function decodeUnsignedIntegers(encoded: string): Array<number>;
/**
* Encode one single unsigned integer and return an encoded string
*
* @param {number} num Unsigned integer that should be encoded.
* @return {string} The encoded string.
*/
export function encodeUnsignedInteger(num: number): string;
export default Polyline;
export type Options = {
/**
* The factor by which the coordinates values will be scaled.
*/
factor?: number | undefined;
/**
* Layout of the
* feature geometries created by the format reader.
*/
geometryLayout?: {
XY: string;
XYZ: string;
XYM: string;
XYZM: string;
} | undefined;
};
/**
* @typedef {Object} Options
* @property {number} [factor=1e5] The factor by which the coordinates values will be scaled.
* @property {GeometryLayout} [geometryLayout='XY'] Layout of the
* feature geometries created by the format reader.
*/
/**
* @classdesc
* Feature format for reading and writing data in the Encoded
* Polyline Algorithm Format.
*
* When reading features, the coordinates are assumed to be in two dimensions
* and in [latitude, longitude] order.
*
* As Polyline sources contain a single feature,
* {@link module:ol/format/Polyline~Polyline#readFeatures} will return the
* feature in an array.
*
* @api
*/
declare class Polyline extends TextFeature {
/**
* @param {Options} [opt_options] Optional configuration object.
*/
constructor(opt_options?: Options | undefined);
/**
* @type {import("../proj/Projection.js").default}
*/
dataProjection: import("../proj/Projection.js").default;
/**
* @private
* @type {number}
*/
private factor_;
/**
* @private
* @type {import("../geom/GeometryLayout").default}
*/
private geometryLayout_;
/**
* @param {import("../Feature.js").default<LineString>} feature Features.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
protected writeFeatureText(feature: import("../Feature.js").default<LineString>, opt_options?: import("./Feature.js").WriteOptions | undefined): string;
/**
* @param {Array<import("../Feature.js").default<LineString>>} features Features.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
protected writeFeaturesText(features: Array<import("../Feature.js").default<LineString>>, opt_options?: import("./Feature.js").WriteOptions | undefined): string;
/**
* @param {LineString} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
protected writeGeometryText(geometry: LineString, opt_options?: import("./Feature.js").WriteOptions | undefined): string;
}
import TextFeature from "./TextFeature.js";
import LineString from "../geom/LineString.js";
//# sourceMappingURL=Polyline.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"Polyline.d.ts","sourceRoot":"","sources":["../src/format/Polyline.js"],"names":[],"mappings":"AAgKA;;;;;;;;;;;;GAYG;AACH,sCARW,MAAM,MAAM,CAAC,UACb,MAAM,oCAIL,MAAM,CAuBjB;AAED;;;;;;;;;;GAUG;AACH,sCARW,MAAM,UACN,MAAM,oCAIL,MAAM,MAAM,CAAC,CAwBxB;AAED;;;;;;;;;;;GAWG;AACH,sCAPW,MAAM,MAAM,CAAC,oCAIZ,MAAM,CAUjB;AAED;;;;;;;;GAQG;AACH,sCANW,MAAM,oCAGL,MAAM,MAAM,CAAC,CAUxB;AAED;;;;;;;GAOG;AACH,8CAHW,MAAM,MAAM,CAAC,GACZ,MAAM,CAQjB;AAED;;;;;GAKG;AACH,8CAHW,MAAM,GACL,MAAM,MAAM,CAAC,CASxB;AAED;;;;;GAKG;AACH,gDAHW,MAAM,MAAM,CAAC,GACZ,MAAM,CAQjB;AAED;;;;;GAKG;AACH,gDAHW,MAAM,GACL,MAAM,MAAM,CAAC,CAkBxB;AAED;;;;;GAKG;AACH,2CAHW,MAAM,GACL,MAAM,CAajB;;;;;;;;;;;;;;;;;;AApVD;;;;;GAKG;AAEH;;;;;;;;;;;;;GAaG;AACH;IACE;;OAEG;IACH,+CAuBC;IAlBC;;OAEG;IACH,gBAFU,OAAO,uBAAuB,EAAE,OAAO,CAED;IAEhD;;;OAGG;IACH,gBAAoD;IAEpD;;;OAGG;IACH,wBAEqB;IAkDvB;;;;;OAKG;IACH,oCALW,OAAO,eAAe,EAAE,OAAO,CAAC,UAAU,CAAC,kEAG1C,MAAM,CAUjB;IAED;;;;;OAKG;IACH,sCALW,MAAM,OAAO,eAAe,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,kEAGjD,MAAM,CAIjB;IAED;;;;;OAKG;IACH,sCALW,UAAU,kEAGT,MAAM,CAgBjB;CACF"}
+329
View File
@@ -0,0 +1,329 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/format/Polyline
*/
import Feature from '../Feature.js';
import GeometryLayout from '../geom/GeometryLayout.js';
import LineString from '../geom/LineString.js';
import TextFeature from './TextFeature.js';
import { assert } from '../asserts.js';
import { flipXY } from '../geom/flat/flip.js';
import { get as getProjection } from '../proj.js';
import { getStrideForLayout } from '../geom/SimpleGeometry.js';
import { inflateCoordinates } from '../geom/flat/inflate.js';
import { transformGeometryWithOptions } from './Feature.js';
/**
* @typedef {Object} Options
* @property {number} [factor=1e5] The factor by which the coordinates values will be scaled.
* @property {GeometryLayout} [geometryLayout='XY'] Layout of the
* feature geometries created by the format reader.
*/
/**
* @classdesc
* Feature format for reading and writing data in the Encoded
* Polyline Algorithm Format.
*
* When reading features, the coordinates are assumed to be in two dimensions
* and in [latitude, longitude] order.
*
* As Polyline sources contain a single feature,
* {@link module:ol/format/Polyline~Polyline#readFeatures} will return the
* feature in an array.
*
* @api
*/
var Polyline = /** @class */ (function (_super) {
__extends(Polyline, _super);
/**
* @param {Options} [opt_options] Optional configuration object.
*/
function Polyline(opt_options) {
var _this = _super.call(this) || this;
var options = opt_options ? opt_options : {};
/**
* @type {import("../proj/Projection.js").default}
*/
_this.dataProjection = getProjection('EPSG:4326');
/**
* @private
* @type {number}
*/
_this.factor_ = options.factor ? options.factor : 1e5;
/**
* @private
* @type {import("../geom/GeometryLayout").default}
*/
_this.geometryLayout_ = options.geometryLayout
? options.geometryLayout
: GeometryLayout.XY;
return _this;
}
/**
* @protected
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../Feature.js").default} Feature.
*/
Polyline.prototype.readFeatureFromText = function (text, opt_options) {
var geometry = this.readGeometryFromText(text, opt_options);
return new Feature(geometry);
};
/**
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {Array<Feature>} Features.
*/
Polyline.prototype.readFeaturesFromText = function (text, opt_options) {
var feature = this.readFeatureFromText(text, opt_options);
return [feature];
};
/**
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../geom/Geometry.js").default} Geometry.
*/
Polyline.prototype.readGeometryFromText = function (text, opt_options) {
var stride = getStrideForLayout(this.geometryLayout_);
var flatCoordinates = decodeDeltas(text, stride, this.factor_);
flipXY(flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
var coordinates = inflateCoordinates(flatCoordinates, 0, flatCoordinates.length, stride);
var lineString = new LineString(coordinates, this.geometryLayout_);
return transformGeometryWithOptions(lineString, false, this.adaptOptions(opt_options));
};
/**
* @param {import("../Feature.js").default<LineString>} feature Features.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
Polyline.prototype.writeFeatureText = function (feature, opt_options) {
var geometry = feature.getGeometry();
if (geometry) {
return this.writeGeometryText(geometry, opt_options);
}
else {
assert(false, 40); // Expected `feature` to have a geometry
return '';
}
};
/**
* @param {Array<import("../Feature.js").default<LineString>>} features Features.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
Polyline.prototype.writeFeaturesText = function (features, opt_options) {
return this.writeFeatureText(features[0], opt_options);
};
/**
* @param {LineString} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
Polyline.prototype.writeGeometryText = function (geometry, opt_options) {
geometry =
/** @type {LineString} */
(transformGeometryWithOptions(geometry, true, this.adaptOptions(opt_options)));
var flatCoordinates = geometry.getFlatCoordinates();
var stride = geometry.getStride();
flipXY(flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
return encodeDeltas(flatCoordinates, stride, this.factor_);
};
return Polyline;
}(TextFeature));
/**
* Encode a list of n-dimensional points and return an encoded string
*
* Attention: This function will modify the passed array!
*
* @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
* multiplied. The remaining decimal places will get rounded away.
* Default is `1e5`.
* @return {string} The encoded string.
* @api
*/
export function encodeDeltas(numbers, stride, opt_factor) {
var factor = opt_factor ? opt_factor : 1e5;
var d;
var lastNumbers = new Array(stride);
for (d = 0; d < stride; ++d) {
lastNumbers[d] = 0;
}
for (var i = 0, ii = numbers.length; i < ii;) {
for (d = 0; d < stride; ++d, ++i) {
var num = numbers[i];
var delta = num - lastNumbers[d];
lastNumbers[d] = num;
numbers[i] = delta;
}
}
return encodeFloats(numbers, factor);
}
/**
* Decode a list of n-dimensional points from an encoded string
*
* @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
* be divided. Default is `1e5`.
* @return {Array<number>} A list of n-dimensional points.
* @api
*/
export function decodeDeltas(encoded, stride, opt_factor) {
var factor = opt_factor ? opt_factor : 1e5;
var d;
/** @type {Array<number>} */
var lastNumbers = new Array(stride);
for (d = 0; d < stride; ++d) {
lastNumbers[d] = 0;
}
var numbers = decodeFloats(encoded, factor);
for (var i = 0, ii = numbers.length; i < ii;) {
for (d = 0; d < stride; ++d, ++i) {
lastNumbers[d] += numbers[i];
numbers[i] = lastNumbers[d];
}
}
return numbers;
}
/**
* Encode a list of floating point numbers and return an encoded string
*
* 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
* multiplied. The remaining decimal places will get rounded away.
* Default is `1e5`.
* @return {string} The encoded string.
* @api
*/
export function encodeFloats(numbers, opt_factor) {
var factor = opt_factor ? opt_factor : 1e5;
for (var i = 0, ii = numbers.length; i < ii; ++i) {
numbers[i] = Math.round(numbers[i] * factor);
}
return encodeSignedIntegers(numbers);
}
/**
* 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.
* Default is `1e5`.
* @return {Array<number>} A list of floating point numbers.
* @api
*/
export function decodeFloats(encoded, opt_factor) {
var factor = opt_factor ? opt_factor : 1e5;
var numbers = decodeSignedIntegers(encoded);
for (var i = 0, ii = numbers.length; i < ii; ++i) {
numbers[i] /= factor;
}
return numbers;
}
/**
* Encode a list of signed integers and return an encoded string
*
* Attention: This function will modify the passed array!
*
* @param {Array<number>} numbers A list of signed integers.
* @return {string} The encoded string.
*/
export function encodeSignedIntegers(numbers) {
for (var i = 0, ii = numbers.length; i < ii; ++i) {
var num = numbers[i];
numbers[i] = num < 0 ? ~(num << 1) : num << 1;
}
return encodeUnsignedIntegers(numbers);
}
/**
* Decode a list of signed integers from an encoded string
*
* @param {string} encoded An encoded string.
* @return {Array<number>} A list of signed integers.
*/
export function decodeSignedIntegers(encoded) {
var numbers = decodeUnsignedIntegers(encoded);
for (var i = 0, ii = numbers.length; i < ii; ++i) {
var num = numbers[i];
numbers[i] = num & 1 ? ~(num >> 1) : num >> 1;
}
return numbers;
}
/**
* Encode a list of unsigned integers and return an encoded string
*
* @param {Array<number>} numbers A list of unsigned integers.
* @return {string} The encoded string.
*/
export function encodeUnsignedIntegers(numbers) {
var encoded = '';
for (var i = 0, ii = numbers.length; i < ii; ++i) {
encoded += encodeUnsignedInteger(numbers[i]);
}
return encoded;
}
/**
* Decode a list of unsigned integers from an encoded string
*
* @param {string} encoded An encoded string.
* @return {Array<number>} A list of unsigned integers.
*/
export function decodeUnsignedIntegers(encoded) {
var numbers = [];
var current = 0;
var shift = 0;
for (var i = 0, ii = encoded.length; i < ii; ++i) {
var b = encoded.charCodeAt(i) - 63;
current |= (b & 0x1f) << shift;
if (b < 0x20) {
numbers.push(current);
current = 0;
shift = 0;
}
else {
shift += 5;
}
}
return numbers;
}
/**
* Encode one single unsigned integer and return an encoded string
*
* @param {number} num Unsigned integer that should be encoded.
* @return {string} The encoded string.
*/
export function encodeUnsignedInteger(num) {
var value, encoded = '';
while (num >= 0x20) {
value = (0x20 | (num & 0x1f)) + 63;
encoded += String.fromCharCode(value);
num >>= 5;
}
value = num + 63;
encoded += String.fromCharCode(value);
return encoded;
}
export default Polyline;
//# sourceMappingURL=Polyline.js.map
+1
View File
File diff suppressed because one or more lines are too long
+112
View File
@@ -0,0 +1,112 @@
export default TextFeature;
/**
* @classdesc
* Abstract base class; normally only used for creating subclasses and not
* instantiated in apps.
* Base class for text feature formats.
*
* @abstract
*/
declare 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.
* @return {import("../Feature.js").default} Feature.
* @api
*/
readFeature(source: Document | Element | any | string, opt_options?: import("../format/Feature.js").ReadOptions | undefined): import("../Feature.js").default;
/**
* @abstract
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../Feature.js").default} Feature.
*/
protected readFeatureFromText(text: string, opt_options?: import("../format/Feature.js").ReadOptions | undefined): import("../Feature.js").default;
/**
* Read the features from the source.
*
* @param {Document|Element|Object|string} source Source.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {Array<import("../Feature.js").default>} Features.
* @api
*/
readFeatures(source: Document | Element | any | string, opt_options?: import("../format/Feature.js").ReadOptions | undefined): Array<import("../Feature.js").default>;
/**
* @abstract
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {Array<import("../Feature.js").default>} Features.
*/
protected readFeaturesFromText(text: string, opt_options?: import("../format/Feature.js").ReadOptions | undefined): Array<import("../Feature.js").default>;
/**
* @abstract
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../geom/Geometry.js").default} Geometry.
*/
protected readGeometryFromText(text: string, opt_options?: import("../format/Feature.js").ReadOptions | undefined): import("../geom/Geometry.js").default;
/**
* @param {string} text Text.
* @protected
* @return {import("../proj/Projection.js").default|undefined} Projection.
*/
protected readProjectionFromText(text: string): import("../proj/Projection.js").default | undefined;
/**
* Encode a feature as a string.
*
* @param {import("../Feature.js").default} feature Feature.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string} Encoded feature.
* @api
*/
writeFeature(feature: import("../Feature.js").default, opt_options?: import("../format/Feature.js").WriteOptions | undefined): string;
/**
* @abstract
* @param {import("../Feature.js").default} feature Features.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
protected writeFeatureText(feature: import("../Feature.js").default, opt_options?: import("../format/Feature.js").WriteOptions | undefined): string;
/**
* Encode an array of features as string.
*
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string} Encoded features.
* @api
*/
writeFeatures(features: Array<import("../Feature.js").default>, opt_options?: import("../format/Feature.js").WriteOptions | undefined): string;
/**
* @abstract
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
protected writeFeaturesText(features: Array<import("../Feature.js").default>, opt_options?: import("../format/Feature.js").WriteOptions | undefined): string;
/**
* Write a single geometry.
*
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string} Geometry.
* @api
*/
writeGeometry(geometry: import("../geom/Geometry.js").default, opt_options?: import("../format/Feature.js").WriteOptions | undefined): string;
/**
* @abstract
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
protected writeGeometryText(geometry: import("../geom/Geometry.js").default, opt_options?: import("../format/Feature.js").WriteOptions | undefined): string;
}
import FeatureFormat from "../format/Feature.js";
//# sourceMappingURL=TextFeature.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"TextFeature.d.ts","sourceRoot":"","sources":["../src/format/TextFeature.js"],"names":[],"mappings":";AAMA;;;;;;;GAOG;AACH;IAYE;;;;;;;OAOG;IACH,oBALW,QAAQ,GAAC,OAAO,SAAQ,MAAM,yEAE7B,OAAO,eAAe,EAAE,OAAO,CAQ1C;IAED;;;;;;OAMG;IACH,oCALW,MAAM,yEAGL,OAAO,eAAe,EAAE,OAAO,CAI1C;IAED;;;;;;;OAOG;IACH,qBALW,QAAQ,GAAC,OAAO,SAAQ,MAAM,yEAE7B,MAAM,OAAO,eAAe,EAAE,OAAO,CAAC,CAQjD;IAED;;;;;;OAMG;IACH,qCALW,MAAM,yEAGL,MAAM,OAAO,eAAe,EAAE,OAAO,CAAC,CAIjD;IAiBD;;;;;;OAMG;IACH,qCALW,MAAM,yEAGL,OAAO,qBAAqB,EAAE,OAAO,CAIhD;IAaD;;;;OAIG;IACH,uCAJW,MAAM,GAEL,OAAO,uBAAuB,EAAE,OAAO,GAAC,SAAS,CAI5D;IAED;;;;;;;OAOG;IACH,sBALW,OAAO,eAAe,EAAE,OAAO,0EAE9B,MAAM,CAKjB;IAED;;;;;;OAMG;IACH,oCALW,OAAO,eAAe,EAAE,OAAO,0EAG9B,MAAM,CAIjB;IAED;;;;;;;OAOG;IACH,wBALW,MAAM,OAAO,eAAe,EAAE,OAAO,CAAC,0EAErC,MAAM,CAKjB;IAED;;;;;;OAMG;IACH,sCALW,MAAM,OAAO,eAAe,EAAE,OAAO,CAAC,0EAGrC,MAAM,CAIjB;IAED;;;;;;;OAOG;IACH,wBALW,OAAO,qBAAqB,EAAE,OAAO,0EAEpC,MAAM,CAKjB;IAED;;;;;;OAMG;IACH,sCALW,OAAO,qBAAqB,EAAE,OAAO,0EAGpC,MAAM,CAIjB;CACF"}
+199
View File
@@ -0,0 +1,199 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/format/TextFeature
*/
import FeatureFormat from '../format/Feature.js';
import { abstract } from '../util.js';
/**
* @classdesc
* Abstract base class; normally only used for creating subclasses and not
* instantiated in apps.
* Base class for text feature formats.
*
* @abstract
*/
var TextFeature = /** @class */ (function (_super) {
__extends(TextFeature, _super);
function TextFeature() {
return _super.call(this) || this;
}
/**
* @return {import("./Feature.js").Type} Format.
*/
TextFeature.prototype.getType = function () {
return 'text';
};
/**
* Read the feature from the source.
*
* @param {Document|Element|Object|string} source Source.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../Feature.js").default} Feature.
* @api
*/
TextFeature.prototype.readFeature = function (source, opt_options) {
return this.readFeatureFromText(getText(source), this.adaptOptions(opt_options));
};
/**
* @abstract
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../Feature.js").default} Feature.
*/
TextFeature.prototype.readFeatureFromText = function (text, opt_options) {
return abstract();
};
/**
* Read the features from the source.
*
* @param {Document|Element|Object|string} source Source.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {Array<import("../Feature.js").default>} Features.
* @api
*/
TextFeature.prototype.readFeatures = function (source, opt_options) {
return this.readFeaturesFromText(getText(source), this.adaptOptions(opt_options));
};
/**
* @abstract
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {Array<import("../Feature.js").default>} Features.
*/
TextFeature.prototype.readFeaturesFromText = function (text, opt_options) {
return abstract();
};
/**
* Read the geometry from the source.
*
* @param {Document|Element|Object|string} source Source.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../geom/Geometry.js").default} Geometry.
* @api
*/
TextFeature.prototype.readGeometry = function (source, opt_options) {
return this.readGeometryFromText(getText(source), this.adaptOptions(opt_options));
};
/**
* @abstract
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../geom/Geometry.js").default} Geometry.
*/
TextFeature.prototype.readGeometryFromText = function (text, opt_options) {
return abstract();
};
/**
* Read the projection from the source.
*
* @param {Document|Element|Object|string} source Source.
* @return {import("../proj/Projection.js").default|undefined} Projection.
* @api
*/
TextFeature.prototype.readProjection = function (source) {
return this.readProjectionFromText(getText(source));
};
/**
* @param {string} text Text.
* @protected
* @return {import("../proj/Projection.js").default|undefined} Projection.
*/
TextFeature.prototype.readProjectionFromText = function (text) {
return this.dataProjection;
};
/**
* Encode a feature as a string.
*
* @param {import("../Feature.js").default} feature Feature.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string} Encoded feature.
* @api
*/
TextFeature.prototype.writeFeature = function (feature, opt_options) {
return this.writeFeatureText(feature, this.adaptOptions(opt_options));
};
/**
* @abstract
* @param {import("../Feature.js").default} feature Features.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
TextFeature.prototype.writeFeatureText = function (feature, opt_options) {
return abstract();
};
/**
* Encode an array of features as string.
*
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string} Encoded features.
* @api
*/
TextFeature.prototype.writeFeatures = function (features, opt_options) {
return this.writeFeaturesText(features, this.adaptOptions(opt_options));
};
/**
* @abstract
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
TextFeature.prototype.writeFeaturesText = function (features, opt_options) {
return abstract();
};
/**
* Write a single geometry.
*
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string} Geometry.
* @api
*/
TextFeature.prototype.writeGeometry = function (geometry, opt_options) {
return this.writeGeometryText(geometry, this.adaptOptions(opt_options));
};
/**
* @abstract
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
TextFeature.prototype.writeGeometryText = function (geometry, opt_options) {
return abstract();
};
return TextFeature;
}(FeatureFormat));
/**
* @param {Document|Element|Object|string} source Source.
* @return {string} Text.
*/
function getText(source) {
if (typeof source === 'string') {
return source;
}
else {
return '';
}
}
export default TextFeature;
//# sourceMappingURL=TextFeature.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"TextFeature.js","sourceRoot":"","sources":["../src/format/TextFeature.js"],"names":[],"mappings":"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"}
+103
View File
@@ -0,0 +1,103 @@
export default TopoJSON;
export type TopoJSONTopology = import("topojson-specification").Topology;
export type TopoJSONGeometryCollection = import("topojson-specification").GeometryCollection;
export type TopoJSONGeometry = import("topojson-specification").GeometryObject;
export type TopoJSONPoint = import("topojson-specification").Point;
export type TopoJSONMultiPoint = import("topojson-specification").MultiPoint;
export type TopoJSONLineString = import("topojson-specification").LineString;
export type TopoJSONMultiLineString = import("topojson-specification").MultiLineString;
export type TopoJSONPolygon = import("topojson-specification").Polygon;
export type TopoJSONMultiPolygon = import("topojson-specification").MultiPolygon;
export type Options = {
/**
* Default data projection.
*/
dataProjection?: import("../proj.js").ProjectionLike;
/**
* Set the name of the TopoJSON topology
* `objects`'s children as feature property with the specified name. This means
* that when set to `'layer'`, a topology like
* ```
* {
* "type": "Topology",
* "objects": {
* "example": {
* "type": "GeometryCollection",
* "geometries": []
* }
* }
* }
* ```
* will result in features that have a property `'layer'` set to `'example'`.
* When not set, no property will be added to features.
*/
layerName?: string | undefined;
/**
* Names of the TopoJSON topology's
* `objects`'s children to read features from. If not provided, features will
* be read from all children.
*/
layers?: string[] | undefined;
};
/**
* @typedef {import("topojson-specification").Topology} TopoJSONTopology
* @typedef {import("topojson-specification").GeometryCollection} TopoJSONGeometryCollection
* @typedef {import("topojson-specification").GeometryObject} TopoJSONGeometry
* @typedef {import("topojson-specification").Point} TopoJSONPoint
* @typedef {import("topojson-specification").MultiPoint} TopoJSONMultiPoint
* @typedef {import("topojson-specification").LineString} TopoJSONLineString
* @typedef {import("topojson-specification").MultiLineString} TopoJSONMultiLineString
* @typedef {import("topojson-specification").Polygon} TopoJSONPolygon
* @typedef {import("topojson-specification").MultiPolygon} TopoJSONMultiPolygon
*/
/**
* @typedef {Object} Options
* @property {import("../proj.js").ProjectionLike} [dataProjection='EPSG:4326'] Default data projection.
* @property {string} [layerName] Set the name of the TopoJSON topology
* `objects`'s children as feature property with the specified name. This means
* that when set to `'layer'`, a topology like
* ```
* {
* "type": "Topology",
* "objects": {
* "example": {
* "type": "GeometryCollection",
* "geometries": []
* }
* }
* }
* ```
* will result in features that have a property `'layer'` set to `'example'`.
* When not set, no property will be added to features.
* @property {Array<string>} [layers] Names of the TopoJSON topology's
* `objects`'s children to read features from. If not provided, features will
* be read from all children.
*/
/**
* @classdesc
* Feature format for reading data in the TopoJSON format.
*
* @api
*/
declare class TopoJSON extends JSONFeature {
/**
* @param {Options} [opt_options] Options.
*/
constructor(opt_options?: Options | undefined);
/**
* @private
* @type {string|undefined}
*/
private layerName_;
/**
* @private
* @type {?Array<string>}
*/
private layers_;
/**
* @type {import("../proj/Projection.js").default}
*/
dataProjection: import("../proj/Projection.js").default;
}
import JSONFeature from "./JSONFeature.js";
//# sourceMappingURL=TopoJSON.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"TopoJSON.d.ts","sourceRoot":"","sources":["../src/format/TopoJSON.js"],"names":[],"mappings":";+BAea,OAAO,wBAAwB,EAAE,QAAQ;yCACzC,OAAO,wBAAwB,EAAE,kBAAkB;+BACnD,OAAO,wBAAwB,EAAE,cAAc;4BAC/C,OAAO,wBAAwB,EAAE,KAAK;iCACtC,OAAO,wBAAwB,EAAE,UAAU;iCAC3C,OAAO,wBAAwB,EAAE,UAAU;sCAC3C,OAAO,wBAAwB,EAAE,eAAe;8BAChD,OAAO,wBAAwB,EAAE,OAAO;mCACxC,OAAO,wBAAwB,EAAE,YAAY;;;;;qBAK5C,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;AAdjD;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;GAKG;AACH;IACE;;OAEG;IACH,+CAuBC;IAlBC;;;OAGG;IACH,mBAAmC;IAEnC;;;OAGG;IACH,gBAAqD;IAErD;;OAEG;IACH,gBAFU,OAAO,uBAAuB,EAAE,OAAO,CAIhD;CAgFJ"}
+394
View File
@@ -0,0 +1,394 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/format/TopoJSON
*/
import Feature from '../Feature.js';
import JSONFeature from './JSONFeature.js';
import LineString from '../geom/LineString.js';
import MultiLineString from '../geom/MultiLineString.js';
import MultiPoint from '../geom/MultiPoint.js';
import MultiPolygon from '../geom/MultiPolygon.js';
import Point from '../geom/Point.js';
import Polygon from '../geom/Polygon.js';
import { get as getProjection } from '../proj.js';
import { transformGeometryWithOptions } from './Feature.js';
/**
* @typedef {import("topojson-specification").Topology} TopoJSONTopology
* @typedef {import("topojson-specification").GeometryCollection} TopoJSONGeometryCollection
* @typedef {import("topojson-specification").GeometryObject} TopoJSONGeometry
* @typedef {import("topojson-specification").Point} TopoJSONPoint
* @typedef {import("topojson-specification").MultiPoint} TopoJSONMultiPoint
* @typedef {import("topojson-specification").LineString} TopoJSONLineString
* @typedef {import("topojson-specification").MultiLineString} TopoJSONMultiLineString
* @typedef {import("topojson-specification").Polygon} TopoJSONPolygon
* @typedef {import("topojson-specification").MultiPolygon} TopoJSONMultiPolygon
*/
/**
* @typedef {Object} Options
* @property {import("../proj.js").ProjectionLike} [dataProjection='EPSG:4326'] Default data projection.
* @property {string} [layerName] Set the name of the TopoJSON topology
* `objects`'s children as feature property with the specified name. This means
* that when set to `'layer'`, a topology like
* ```
* {
* "type": "Topology",
* "objects": {
* "example": {
* "type": "GeometryCollection",
* "geometries": []
* }
* }
* }
* ```
* will result in features that have a property `'layer'` set to `'example'`.
* When not set, no property will be added to features.
* @property {Array<string>} [layers] Names of the TopoJSON topology's
* `objects`'s children to read features from. If not provided, features will
* be read from all children.
*/
/**
* @classdesc
* Feature format for reading data in the TopoJSON format.
*
* @api
*/
var TopoJSON = /** @class */ (function (_super) {
__extends(TopoJSON, _super);
/**
* @param {Options} [opt_options] Options.
*/
function TopoJSON(opt_options) {
var _this = _super.call(this) || this;
var options = opt_options ? opt_options : {};
/**
* @private
* @type {string|undefined}
*/
_this.layerName_ = options.layerName;
/**
* @private
* @type {?Array<string>}
*/
_this.layers_ = options.layers ? options.layers : null;
/**
* @type {import("../proj/Projection.js").default}
*/
_this.dataProjection = getProjection(options.dataProjection ? options.dataProjection : 'EPSG:4326');
return _this;
}
/**
* @param {Object} object Object.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {Array<Feature>} Features.
*/
TopoJSON.prototype.readFeaturesFromObject = function (object, opt_options) {
if (object.type == 'Topology') {
var topoJSONTopology = /** @type {TopoJSONTopology} */ (object);
var transform = void 0, scale = null, translate = null;
if (topoJSONTopology['transform']) {
transform = topoJSONTopology['transform'];
scale = transform['scale'];
translate = transform['translate'];
}
var arcs = topoJSONTopology['arcs'];
if (transform) {
transformArcs(arcs, scale, translate);
}
/** @type {Array<Feature>} */
var features = [];
var topoJSONFeatures = topoJSONTopology['objects'];
var property = this.layerName_;
var feature = void 0;
for (var objectName in topoJSONFeatures) {
if (this.layers_ && this.layers_.indexOf(objectName) == -1) {
continue;
}
if (topoJSONFeatures[objectName].type === 'GeometryCollection') {
feature = /** @type {TopoJSONGeometryCollection} */ (topoJSONFeatures[objectName]);
features.push.apply(features, readFeaturesFromGeometryCollection(feature, arcs, scale, translate, property, objectName, opt_options));
}
else {
feature = /** @type {TopoJSONGeometry} */ (topoJSONFeatures[objectName]);
features.push(readFeatureFromGeometry(feature, arcs, scale, translate, property, objectName, opt_options));
}
}
return features;
}
else {
return [];
}
};
/**
* @param {Object} object Object.
* @protected
* @return {import("../proj/Projection.js").default} Projection.
*/
TopoJSON.prototype.readProjectionFromObject = function (object) {
return this.dataProjection;
};
return TopoJSON;
}(JSONFeature));
/**
* @const
* @type {Object<string, function(TopoJSONGeometry, Array, ...Array=): import("../geom/Geometry.js").default>}
*/
var GEOMETRY_READERS = {
'Point': readPointGeometry,
'LineString': readLineStringGeometry,
'Polygon': readPolygonGeometry,
'MultiPoint': readMultiPointGeometry,
'MultiLineString': readMultiLineStringGeometry,
'MultiPolygon': readMultiPolygonGeometry,
};
/**
* Concatenate arcs into a coordinate array.
* @param {Array<number>} indices Indices of arcs to concatenate. Negative
* values indicate arcs need to be reversed.
* @param {Array<Array<import("../coordinate.js").Coordinate>>} arcs Array of arcs (already
* transformed).
* @return {Array<import("../coordinate.js").Coordinate>} Coordinates array.
*/
function concatenateArcs(indices, arcs) {
/** @type {Array<import("../coordinate.js").Coordinate>} */
var coordinates = [];
var index;
for (var i = 0, ii = indices.length; i < ii; ++i) {
index = indices[i];
if (i > 0) {
// splicing together arcs, discard last point
coordinates.pop();
}
if (index >= 0) {
// forward arc
var arc = arcs[index];
for (var j = 0, jj = arc.length; j < jj; ++j) {
coordinates.push(arc[j].slice(0));
}
}
else {
// reverse arc
var arc = arcs[~index];
for (var j = arc.length - 1; j >= 0; --j) {
coordinates.push(arc[j].slice(0));
}
}
}
return coordinates;
}
/**
* Create a point from a TopoJSON geometry object.
*
* @param {TopoJSONPoint} object TopoJSON object.
* @param {Array<number>} scale Scale for each dimension.
* @param {Array<number>} translate Translation for each dimension.
* @return {Point} Geometry.
*/
function readPointGeometry(object, scale, translate) {
var coordinates = object['coordinates'];
if (scale && translate) {
transformVertex(coordinates, scale, translate);
}
return new Point(coordinates);
}
/**
* Create a multi-point from a TopoJSON geometry object.
*
* @param {TopoJSONMultiPoint} object TopoJSON object.
* @param {Array<number>} scale Scale for each dimension.
* @param {Array<number>} translate Translation for each dimension.
* @return {MultiPoint} Geometry.
*/
function readMultiPointGeometry(object, scale, translate) {
var coordinates = object['coordinates'];
if (scale && translate) {
for (var i = 0, ii = coordinates.length; i < ii; ++i) {
transformVertex(coordinates[i], scale, translate);
}
}
return new MultiPoint(coordinates);
}
/**
* Create a linestring from a TopoJSON geometry object.
*
* @param {TopoJSONLineString} object TopoJSON object.
* @param {Array<Array<import("../coordinate.js").Coordinate>>} arcs Array of arcs.
* @return {LineString} Geometry.
*/
function readLineStringGeometry(object, arcs) {
var coordinates = concatenateArcs(object['arcs'], arcs);
return new LineString(coordinates);
}
/**
* Create a multi-linestring from a TopoJSON geometry object.
*
* @param {TopoJSONMultiLineString} object TopoJSON object.
* @param {Array<Array<import("../coordinate.js").Coordinate>>} arcs Array of arcs.
* @return {MultiLineString} Geometry.
*/
function readMultiLineStringGeometry(object, arcs) {
var coordinates = [];
for (var i = 0, ii = object['arcs'].length; i < ii; ++i) {
coordinates[i] = concatenateArcs(object['arcs'][i], arcs);
}
return new MultiLineString(coordinates);
}
/**
* Create a polygon from a TopoJSON geometry object.
*
* @param {TopoJSONPolygon} object TopoJSON object.
* @param {Array<Array<import("../coordinate.js").Coordinate>>} arcs Array of arcs.
* @return {Polygon} Geometry.
*/
function readPolygonGeometry(object, arcs) {
var coordinates = [];
for (var i = 0, ii = object['arcs'].length; i < ii; ++i) {
coordinates[i] = concatenateArcs(object['arcs'][i], arcs);
}
return new Polygon(coordinates);
}
/**
* Create a multi-polygon from a TopoJSON geometry object.
*
* @param {TopoJSONMultiPolygon} object TopoJSON object.
* @param {Array<Array<import("../coordinate.js").Coordinate>>} arcs Array of arcs.
* @return {MultiPolygon} Geometry.
*/
function readMultiPolygonGeometry(object, arcs) {
var coordinates = [];
for (var i = 0, ii = object['arcs'].length; i < ii; ++i) {
// for each polygon
var polyArray = object['arcs'][i];
var ringCoords = [];
for (var j = 0, jj = polyArray.length; j < jj; ++j) {
// for each ring
ringCoords[j] = concatenateArcs(polyArray[j], arcs);
}
coordinates[i] = ringCoords;
}
return new MultiPolygon(coordinates);
}
/**
* Create features from a TopoJSON GeometryCollection object.
*
* @param {TopoJSONGeometryCollection} collection TopoJSON Geometry
* object.
* @param {Array<Array<import("../coordinate.js").Coordinate>>} arcs Array of arcs.
* @param {Array<number>} scale Scale for each dimension.
* @param {Array<number>} translate Translation for each dimension.
* @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.
* @return {Array<Feature>} Array of features.
*/
function readFeaturesFromGeometryCollection(collection, arcs, scale, translate, property, name, opt_options) {
var geometries = collection['geometries'];
var features = [];
for (var i = 0, ii = geometries.length; i < ii; ++i) {
features[i] = readFeatureFromGeometry(geometries[i], arcs, scale, translate, property, name, opt_options);
}
return features;
}
/**
* Create a feature from a TopoJSON geometry object.
*
* @param {TopoJSONGeometry} object TopoJSON geometry object.
* @param {Array<Array<import("../coordinate.js").Coordinate>>} arcs Array of arcs.
* @param {Array<number>} scale Scale for each dimension.
* @param {Array<number>} translate Translation for each dimension.
* @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.
* @return {Feature} Feature.
*/
function readFeatureFromGeometry(object, arcs, scale, translate, property, name, opt_options) {
var geometry = null;
var type = object.type;
if (type) {
var 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);
}
var feature = new Feature({ geometry: geometry });
if (object.id !== undefined) {
feature.setId(object.id);
}
var properties = object.properties;
if (property) {
if (!properties) {
properties = {};
}
properties[property] = name;
}
if (properties) {
feature.setProperties(properties, true);
}
return feature;
}
/**
* Apply a linear transform to array of arcs. The provided array of arcs is
* modified in place.
*
* @param {Array<Array<import("../coordinate.js").Coordinate>>} arcs Array of arcs.
* @param {Array<number>} scale Scale for each dimension.
* @param {Array<number>} translate Translation for each dimension.
*/
function transformArcs(arcs, scale, translate) {
for (var i = 0, ii = arcs.length; i < ii; ++i) {
transformArc(arcs[i], scale, translate);
}
}
/**
* Apply a linear transform to an arc. The provided arc is modified in place.
*
* @param {Array<import("../coordinate.js").Coordinate>} arc Arc.
* @param {Array<number>} scale Scale for each dimension.
* @param {Array<number>} translate Translation for each dimension.
*/
function transformArc(arc, scale, translate) {
var x = 0;
var y = 0;
for (var i = 0, ii = arc.length; i < ii; ++i) {
var vertex = arc[i];
x += vertex[0];
y += vertex[1];
vertex[0] = x;
vertex[1] = y;
transformVertex(vertex, scale, translate);
}
}
/**
* Apply a linear transform to a vertex. The provided vertex is modified in
* place.
*
* @param {import("../coordinate.js").Coordinate} vertex Vertex.
* @param {Array<number>} scale Scale for each dimension.
* @param {Array<number>} translate Translation for each dimension.
*/
function transformVertex(vertex, scale, translate) {
vertex[0] = vertex[0] * scale[0] + translate[0];
vertex[1] = vertex[1] * scale[1] + translate[1];
}
export default TopoJSON;
//# sourceMappingURL=TopoJSON.js.map
+1
View File
File diff suppressed because one or more lines are too long
+314
View File
@@ -0,0 +1,314 @@
/**
* Encode filter as WFS `Filter` and return the Node.
*
* @param {import("./filter/Filter.js").default} filter Filter.
* @param {string} opt_version WFS version. If not provided defaults to '1.1.0'
* @return {Node} Result.
* @api
*/
export function writeFilter(filter: import("./filter/Filter.js").default, opt_version: string): Node;
export default WFS;
export type Options = {
/**
* The namespace URI used for features.
*/
featureNS?: string | {
[x: string]: string;
} | undefined;
/**
* The feature type to parse. Only used for read operations.
*/
featureType?: string | string[] | undefined;
/**
* The GML format to use to parse the response.
* Default is `ol/format/GML2` for WFS 1.0.0, `ol/format/GML3` for WFS 1.1.0 and `ol/format/GML32` for WFS 2.0.0.
*/
gmlFormat?: GMLBase | undefined;
/**
* Optional schemaLocation to use for serialization, this will override the default.
*/
schemaLocation?: string | undefined;
/**
* WFS version to use. Can be either `1.0.0`, `1.1.0` or `2.0.0`.
*/
version?: string | undefined;
};
export type WriteGetFeatureOptions = {
/**
* The namespace URI used for features.
*/
featureNS: string;
/**
* The prefix for the feature namespace.
*/
featurePrefix: string;
/**
* The feature type names or FeatureType objects to
* define a unique bbox filter per feature type name (in this case, options `bbox` and `geometryName` are
* ignored.).
*/
featureTypes: Array<string | FeatureType>;
/**
* SRS name. No srsName attribute will be set on
* geometries when this is not provided.
*/
srsName?: string | undefined;
/**
* Handle.
*/
handle?: string | undefined;
/**
* Output format.
*/
outputFormat?: string | undefined;
/**
* Maximum number of features to fetch.
*/
maxFeatures?: number | undefined;
/**
* Geometry name to use in a BBOX filter.
*/
geometryName?: string | undefined;
/**
* Optional list of property names to serialize.
*/
propertyNames?: string[] | undefined;
/**
* viewParams GeoServer vendor parameter.
*/
viewParams?: string | undefined;
/**
* Start index to use for WFS paging. This is a
* WFS 2.0 feature backported to WFS 1.1.0 by some Web Feature Services.
*/
startIndex?: number | undefined;
/**
* Number of features to retrieve when paging. This is a
* WFS 2.0 feature backported to WFS 1.1.0 by some Web Feature Services. Please note that some
* Web Feature Services have repurposed `maxfeatures` instead.
*/
count?: number | undefined;
/**
* Extent to use for the BBOX filter. The `geometryName`
* option must be set.
*/
bbox?: import("../extent.js").Extent | undefined;
/**
* Filter condition. See
* {@link module :ol/format/filter} for more information.
*/
filter?: import("./filter/Filter.js").default | undefined;
/**
* Indicates what response should be returned,
* e.g. `hits` only includes the `numberOfFeatures` attribute in the response and no features.
*/
resultType?: string | undefined;
};
export type FeatureType = {
/**
* The feature type name.
*/
name: string;
/**
* Extent to use for the BBOX filter.
*/
bbox: import("../extent.js").Extent;
/**
* Geometry name to use in the BBOX filter.
*/
geometryName: string;
};
export type WriteTransactionOptions = {
/**
* The namespace URI used for features.
*/
featureNS: string;
/**
* The prefix for the feature namespace.
*/
featurePrefix: string;
/**
* The feature type name.
*/
featureType: string;
/**
* SRS name. No srsName attribute will be set on
* geometries when this is not provided.
*/
srsName?: string | undefined;
/**
* Handle.
*/
handle?: string | undefined;
/**
* Must be set to true if the transaction is for
* a 3D layer. This will allow the Z coordinate to be included in the transaction.
*/
hasZ?: boolean | undefined;
/**
* Native elements. Currently not supported.
*/
nativeElements: Array<any>;
/**
* GML options for the WFS transaction writer.
*/
gmlOptions?: import("./GMLBase.js").Options | undefined;
/**
* WFS version to use for the transaction. Can be either `1.0.0`, `1.1.0` or `2.0.0`.
*/
version?: string | undefined;
};
/**
* Number of features; bounds/extent.
*/
export type FeatureCollectionMetadata = {
/**
* NumberOfFeatures.
*/
numberOfFeatures: number;
/**
* Bounds.
*/
bounds: import("../extent.js").Extent;
};
/**
* Total deleted; total inserted; total updated; array of insert ids.
*/
export type TransactionResponse = {
/**
* TotalDeleted.
*/
totalDeleted: number;
/**
* TotalInserted.
*/
totalInserted: number;
/**
* TotalUpdated.
*/
totalUpdated: number;
/**
* InsertIds.
*/
insertIds: Array<string>;
};
/**
* @classdesc
* Feature format for reading and writing data in the WFS format.
* By default, supports WFS version 1.1.0. You can pass a GML format
* as option to override the default.
* Also see {@link module:ol/format/GMLBase~GMLBase} which is used by this format.
*
* @api
*/
declare class WFS extends XMLFeature {
/**
* @param {Options} [opt_options] Optional configuration object.
*/
constructor(opt_options?: Options | undefined);
/**
* @private
* @type {string}
*/
private version_;
/**
* @private
* @type {Array<string>|string|undefined}
*/
private featureType_;
/**
* @private
* @type {Object<string, string>|string|undefined}
*/
private featureNS_;
/**
* @private
* @type {GMLBase}
*/
private gmlFormat_;
/**
* @private
* @type {string}
*/
private schemaLocation_;
/**
* @return {Array<string>|string|undefined} featureType
*/
getFeatureType(): Array<string> | string | undefined;
/**
* @param {Array<string>|string|undefined} featureType Feature type(s) to parse.
*/
setFeatureType(featureType: Array<string> | string | undefined): void;
/**
* Read transaction response of the source.
*
* @param {Document|Element|Object|string} source Source.
* @return {TransactionResponse|undefined} Transaction response.
* @api
*/
readTransactionResponse(source: Document | Element | any | string): TransactionResponse | undefined;
/**
* Read feature collection metadata of the source.
*
* @param {Document|Element|Object|string} source Source.
* @return {FeatureCollectionMetadata|undefined}
* FeatureCollection metadata.
* @api
*/
readFeatureCollectionMetadata(source: Document | Element | any | string): FeatureCollectionMetadata | undefined;
/**
* @param {Document} doc Document.
* @return {FeatureCollectionMetadata|undefined}
* FeatureCollection metadata.
*/
readFeatureCollectionMetadataFromDocument(doc: Document): FeatureCollectionMetadata | undefined;
/**
* @param {Element} node Node.
* @return {FeatureCollectionMetadata|undefined}
* FeatureCollection metadata.
*/
readFeatureCollectionMetadataFromNode(node: Element): FeatureCollectionMetadata | undefined;
/**
* @param {Document} doc Document.
* @return {TransactionResponse|undefined} Transaction response.
*/
readTransactionResponseFromDocument(doc: Document): TransactionResponse | undefined;
/**
* @param {Element} node Node.
* @return {TransactionResponse|undefined} Transaction response.
*/
readTransactionResponseFromNode(node: Element): TransactionResponse | undefined;
/**
* Encode format as WFS `GetFeature` and return the Node.
*
* @param {WriteGetFeatureOptions} options Options.
* @return {Node} Result.
* @api
*/
writeGetFeature(options: WriteGetFeatureOptions): Node;
/**
* Create a bbox filter and combine it with another optional 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 on geometries when this is not provided.
* @param {import("./filter/Filter.js").default} [opt_filter] Filter condition.
* @return {import("./filter/Filter.js").default} The filter.
*/
combineBboxAndFilter(geometryName: string, extent: import("../extent.js").Extent, opt_srsName?: string | undefined, opt_filter?: import("./filter/Filter.js").default | undefined): import("./filter/Filter.js").default;
/**
* Encode format as WFS `Transaction` and return the Node.
*
* @param {Array<import("../Feature.js").default>} inserts The features to insert.
* @param {Array<import("../Feature.js").default>} updates The features to update.
* @param {Array<import("../Feature.js").default>} deletes The features to delete.
* @param {WriteTransactionOptions} options Write options.
* @return {Node} Result.
* @api
*/
writeTransaction(inserts: Array<import("../Feature.js").default>, updates: Array<import("../Feature.js").default>, deletes: Array<import("../Feature.js").default>, options: WriteTransactionOptions): Node;
}
import GMLBase from "./GMLBase.js";
import XMLFeature from "./XMLFeature.js";
//# sourceMappingURL=WFS.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"WFS.d.ts","sourceRoot":"","sources":["../src/format/WFS.js"],"names":[],"mappings":"AAwyCA;;;;;;;GAOG;AACH,oCALW,OAAO,oBAAoB,EAAE,OAAO,eACpC,MAAM,GACL,IAAI,CAef;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA3rCa,MAAM;;;;mBACN,MAAM;;;;;;kBACN,MAAM,MAAM,GAAC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA0BxB,MAAM;;;;UACN,OAAO,cAAc,EAAE,MAAM;;;;kBAC7B,MAAM;;;;;;eAKP,MAAM;;;;mBACN,MAAM;;;;iBACN,MAAM;;;;;;;;;;;;;;;;;;oBAMN,UAAa;;;;;;;;;;;;;;;;;sBAQb,MAAM;;;;YACN,OAAO,cAAc,EAAE,MAAM;;;;;;;;;kBAM7B,MAAM;;;;mBACN,MAAM;;;;kBACN,MAAM;;;;eACN,MAAM,MAAM,CAAC;;AAmE3B;;;;;;;;GAQG;AACH;IACE;;OAEG;IACH,+CAsCC;IAjCC;;;OAGG;IACH,iBAAmE;IAEnE;;;OAGG;IACH,qBAAuC;IAEvC;;;OAGG;IACH,mBAAmC;IAEnC;;;OAGG;IACH,mBAEoC;IAEpC;;;OAGG;IACH,wBAEmC;IAGrC;;OAEG;IACH,kBAFY,MAAM,MAAM,CAAC,GAAC,MAAM,GAAC,SAAS,CAIzC;IAED;;OAEG;IACH,4BAFW,MAAM,MAAM,CAAC,GAAC,MAAM,GAAC,SAAS,QAIxC;IAuCD;;;;;;OAMG;IACH,gCAJW,QAAQ,GAAC,OAAO,SAAQ,MAAM,GAC7B,mBAAmB,GAAC,SAAS,CAkBxC;IAED;;;;;;;OAOG;IACH,sCALW,QAAQ,GAAC,OAAO,SAAQ,MAAM,GAC7B,yBAAyB,GAAC,SAAS,CAmB9C;IAED;;;;OAIG;IACH,+CAJW,QAAQ,GACP,yBAAyB,GAAC,SAAS,CAY9C;IAED;;;;OAIG;IACH,4CAJW,OAAO,GACN,yBAAyB,GAAC,SAAS,CAgB9C;IAED;;;OAGG;IACH,yCAHW,QAAQ,GACP,mBAAmB,GAAC,SAAS,CASxC;IAED;;;OAGG;IACH,sCAHW,OAAO,GACN,mBAAmB,GAAC,SAAS,CASxC;IAED;;;;;;OAMG;IACH,yBAJW,sBAAsB,GACrB,IAAI,CAkFf;IAED;;;;;;;;;OASG;IACH,mCAPY,MAAM,UACN,OAAO,cAAc,EAAE,MAAM,oGAI7B,OAAO,oBAAoB,EAAE,OAAO,CAS/C;IAED;;;;;;;;;OASG;IACH,0BAPW,MAAM,OAAO,eAAe,EAAE,OAAO,CAAC,WACtC,MAAM,OAAO,eAAe,EAAE,OAAO,CAAC,WACtC,MAAM,OAAO,eAAe,EAAE,OAAO,CAAC,WACtC,uBAAuB,GACtB,IAAI,CA2Cf;CAsCF"}
+1191
View File
File diff suppressed because it is too large Load Diff
+1
View File
File diff suppressed because one or more lines are too long
+105
View File
@@ -0,0 +1,105 @@
export default WKB;
export type Options = {
/**
* Whether to split GeometryCollections into multiple features on reading.
*/
splitCollection?: boolean | undefined;
/**
* Returns hex string instead of ArrayBuffer for output. This also is used as a hint internally whether it should load contents as text or ArrayBuffer on reading.
*/
hex?: boolean | undefined;
/**
* Use littleEndian for output.
*/
littleEndian?: boolean | undefined;
/**
* Use EWKB format for output.
*/
ewkb?: boolean | undefined;
/**
* Use specific coordinate layout for output features (null: auto detect)
*/
geometryLayout?: any;
/**
* If the `geometryLayout` doesn't match with geometry to be output, this value is used to fill missing coordinate value of Z.
*/
nodataZ?: number | undefined;
/**
* If the `geometryLayout` doesn't match with geometry to be output, this value is used to fill missing coordinate value of M.
*/
nodataM?: number | undefined;
/**
* SRID for output. Specify integer value to enforce the value as a SRID. Specify `true` to extract from `dataProjection`. `false` to suppress the output. This option only takes effect when `ewkb` is `true`.
*/
srid?: number | boolean | undefined;
};
/**
* @typedef {Object} Options
* @property {boolean} [splitCollection=false] Whether to split GeometryCollections into multiple features on reading.
* @property {boolean} [hex=true] Returns hex string instead of ArrayBuffer for output. This also is used as a hint internally whether it should load contents as text or ArrayBuffer on reading.
* @property {boolean} [littleEndian=true] Use littleEndian for output.
* @property {boolean} [ewkb=true] Use EWKB format for output.
* @property {import("../geom/GeometryLayout").default} [geometryLayout=null] Use specific coordinate layout for output features (null: auto detect)
* @property {number} [nodataZ=0] If the `geometryLayout` doesn't match with geometry to be output, this value is used to fill missing coordinate value of Z.
* @property {number} [nodataM=0] If the `geometryLayout` doesn't match with geometry to be output, this value is used to fill missing coordinate value of M.
* @property {number|boolean} [srid=true] SRID for output. Specify integer value to enforce the value as a SRID. Specify `true` to extract from `dataProjection`. `false` to suppress the output. This option only takes effect when `ewkb` is `true`.
*/
/**
* @classdesc
* Geometry format for reading and writing data in the `Well-Known Binary` (WKB) format.
* Also supports `Extended Well-Known Binary` (EWKB) format, used in PostGIS for example.
*
* @api
*/
declare class WKB extends FeatureFormat {
/**
* @param {Options} [opt_options] Optional configuration object.
*/
constructor(opt_options?: Options | undefined);
splitCollection: boolean;
viewCache_: DataView | null;
hex_: boolean;
littleEndian_: boolean;
ewkb_: boolean;
layout_: any;
nodataZ_: number;
nodataM_: number;
srid_: number | boolean | undefined;
/**
* Read a single feature from a source.
*
* @param {string|ArrayBuffer|ArrayBufferView} source Source.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../Feature.js").default} Feature.
* @api
*/
readFeature(source: string | ArrayBuffer | ArrayBufferView, opt_options?: import("./Feature.js").ReadOptions | undefined): import("../Feature.js").default;
/**
* Read all features from a source.
*
* @param {string|ArrayBuffer|ArrayBufferView} source Source.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {Array<import("../Feature.js").default>} Features.
* @api
*/
readFeatures(source: string | ArrayBuffer | ArrayBufferView, opt_options?: import("./Feature.js").ReadOptions | undefined): Array<import("../Feature.js").default>;
/**
* Read a single geometry from a source.
*
* @param {string|ArrayBuffer|ArrayBufferView} source Source.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../geom/Geometry.js").default} Geometry.
* @api
*/
readGeometry(source: string | ArrayBuffer | ArrayBufferView, opt_options?: import("./Feature.js").ReadOptions | undefined): import("../geom/Geometry.js").default;
/**
* Read the projection from a source.
*
* @param {string|ArrayBuffer|ArrayBufferView} source Source.
* @return {import("../proj/Projection.js").default|undefined} Projection.
* @api
*/
readProjection(source: string | ArrayBuffer | ArrayBufferView): import("../proj/Projection.js").default | undefined;
}
import FeatureFormat from "./Feature.js";
//# sourceMappingURL=WKB.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"WKB.d.ts","sourceRoot":"","sources":["../src/format/WKB.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwoBA;;;;;;;;;;GAUG;AAEH;;;;;;GAMG;AACH;IACE;;OAEG;IACH,+CAkBC;IAbC,yBAAuD;IAEvD,4BAAsB;IAEtB,cAAiC;IACjC,uBAAmD;IACnD,eAAmC;IAEnC,aAAqC;IACrC,iBAAoC;IACpC,iBAAoC;IAEpC,oCAAyB;IAU3B;;;;;;;OAOG;IACH,oBALW,MAAM,GAAC,WAAW,GAAC,eAAe,iEAEjC,OAAO,eAAe,EAAE,OAAO,CAO1C;IAED;;;;;;;OAOG;IACH,qBALW,MAAM,GAAC,WAAW,GAAC,eAAe,iEAEjC,MAAM,OAAO,eAAe,EAAE,OAAO,CAAC,CAYjD;IAED;;;;;;;OAOG;IACH,qBALW,MAAM,GAAC,WAAW,GAAC,eAAe,iEAEjC,OAAO,qBAAqB,EAAE,OAAO,CAiBhD;IAED;;;;;;OAMG;IACH,uBAJW,MAAM,GAAC,WAAW,GAAC,eAAe,GACjC,OAAO,uBAAuB,EAAE,OAAO,GAAC,SAAS,CAgB5D;CAwEF"}
+763
View File
@@ -0,0 +1,763 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/format/WKB
*/
import Feature from '../Feature.js';
import FeatureFormat, { transformGeometryWithOptions } from './Feature.js';
import GeometryCollection from '../geom/GeometryCollection.js';
import GeometryLayout from '../geom/GeometryLayout.js';
import LineString from '../geom/LineString.js';
import MultiLineString from '../geom/MultiLineString.js';
import MultiPoint from '../geom/MultiPoint.js';
import MultiPolygon from '../geom/MultiPolygon.js';
import Point from '../geom/Point.js';
import Polygon from '../geom/Polygon.js';
import { get as getProjection } from '../proj.js';
import SimpleGeometry from '../geom/SimpleGeometry.js';
import { assign } from '../obj.js';
// WKB spec: https://www.ogc.org/standards/sfa
// EWKB spec: https://raw.githubusercontent.com/postgis/postgis/2.1.0/doc/ZMSgeoms.txt
/**
* @const
* @enum {number}
*/
var WKBGeometryType = {
POINT: 1,
LINE_STRING: 2,
POLYGON: 3,
MULTI_POINT: 4,
MULTI_LINE_STRING: 5,
MULTI_POLYGON: 6,
GEOMETRY_COLLECTION: 7,
/*
CIRCULAR_STRING: 8,
COMPOUND_CURVE: 9,
CURVE_POLYGON: 10,
MULTI_CURVE: 11,
MULTI_SURFACE: 12,
CURVE: 13,
SURFACE: 14,
*/
POLYHEDRAL_SURFACE: 15,
TIN: 16,
TRIANGLE: 17,
};
var WkbReader = /** @class */ (function () {
/**
* @param {DataView} view source to read
*/
function WkbReader(view) {
this.view_ = view;
this.pos_ = 0;
this.initialized_ = false;
this.isLittleEndian_ = false;
this.hasZ_ = false;
this.hasM_ = false;
/** @type {number|null} */
this.srid_ = null;
this.layout_ = GeometryLayout.XY;
}
/**
* @return {number} value
*/
WkbReader.prototype.readUint8 = function () {
return this.view_.getUint8(this.pos_++);
};
/**
* @param {boolean} [isLittleEndian] Whether read value as little endian
* @return {number} value
*/
WkbReader.prototype.readUint32 = function (isLittleEndian) {
return this.view_.getUint32((this.pos_ += 4) - 4, isLittleEndian !== undefined ? isLittleEndian : this.isLittleEndian_);
};
/**
* @param {boolean} [isLittleEndian] Whether read value as little endian
* @return {number} value
*/
WkbReader.prototype.readDouble = function (isLittleEndian) {
return this.view_.getFloat64((this.pos_ += 8) - 8, isLittleEndian !== undefined ? isLittleEndian : this.isLittleEndian_);
};
/**
* @return {import('../coordinate.js').Coordinate} coords for Point
*/
WkbReader.prototype.readPoint = function () {
/** @type import('../coordinate.js').Coordinate */
var coords = [];
coords.push(this.readDouble());
coords.push(this.readDouble());
if (this.hasZ_) {
coords.push(this.readDouble());
}
if (this.hasM_) {
coords.push(this.readDouble());
}
return coords;
};
/**
* @return {Array<import('../coordinate.js').Coordinate>} coords for LineString / LinearRing
*/
WkbReader.prototype.readLineString = function () {
var numPoints = this.readUint32();
/** @type Array<import('../coordinate.js').Coordinate> */
var coords = [];
for (var i = 0; i < numPoints; i++) {
coords.push(this.readPoint());
}
return coords;
};
/**
* @return {Array<Array<import('../coordinate.js').Coordinate>>} coords for Polygon like
*/
WkbReader.prototype.readPolygon = function () {
var numRings = this.readUint32();
/** @type Array<Array<import('../coordinate.js').Coordinate>> */
var rings = [];
for (var i = 0; i < numRings; i++) {
rings.push(this.readLineString()); // as a LinearRing
}
return rings;
};
/**
* @param {number} [expectedTypeId] Expected WKB Type ID
* @return {number} WKB Type ID
*/
WkbReader.prototype.readWkbHeader = function (expectedTypeId) {
var byteOrder = this.readUint8();
var isLittleEndian = byteOrder > 0;
var wkbType = this.readUint32(isLittleEndian);
var wkbTypeThousandth = Math.floor((wkbType & 0x0fffffff) / 1000);
var hasZ = Boolean(wkbType & 0x80000000) ||
wkbTypeThousandth === 1 ||
wkbTypeThousandth === 3;
var hasM = Boolean(wkbType & 0x40000000) ||
wkbTypeThousandth === 2 ||
wkbTypeThousandth === 3;
var hasSRID = Boolean(wkbType & 0x20000000);
var typeId = (wkbType & 0x0fffffff) % 1000; // Assume 1000 is an upper limit for type ID
var layout = ['XY', hasZ ? 'Z' : '', hasM ? 'M' : ''].join('');
var srid = hasSRID ? this.readUint32(isLittleEndian) : null;
if (expectedTypeId !== undefined && expectedTypeId !== typeId) {
throw new Error('Unexpected WKB geometry type ' + typeId);
}
if (this.initialized_) {
// sanity checks
if (this.isLittleEndian_ !== isLittleEndian) {
throw new Error('Inconsistent endian');
}
if (this.layout_ !== layout) {
throw new Error('Inconsistent geometry layout');
}
if (srid && this.srid_ !== srid) {
throw new Error('Inconsistent coordinate system (SRID)');
}
}
else {
this.isLittleEndian_ = isLittleEndian;
this.hasZ_ = hasZ;
this.hasM_ = hasM;
this.layout_ = layout;
this.srid_ = srid;
this.initialized_ = true;
}
return typeId;
};
/**
* @param {number} typeId WKB Type ID
* @return {any} values read
*/
WkbReader.prototype.readWkbPayload = function (typeId) {
switch (typeId) {
case WKBGeometryType.POINT:
return this.readPoint();
case WKBGeometryType.LINE_STRING:
return this.readLineString();
case WKBGeometryType.POLYGON:
case WKBGeometryType.TRIANGLE:
return this.readPolygon();
case WKBGeometryType.MULTI_POINT:
return this.readMultiPoint();
case WKBGeometryType.MULTI_LINE_STRING:
return this.readMultiLineString();
case WKBGeometryType.MULTI_POLYGON:
case WKBGeometryType.POLYHEDRAL_SURFACE:
case WKBGeometryType.TIN:
return this.readMultiPolygon();
case WKBGeometryType.GEOMETRY_COLLECTION:
return this.readGeometryCollection();
default:
throw new Error('Unsupported WKB geometry type ' + typeId + ' is found');
}
};
/**
* @param {number} expectedTypeId Expected WKB Type ID
* @return {any} values read
*/
WkbReader.prototype.readWkbBlock = function (expectedTypeId) {
return this.readWkbPayload(this.readWkbHeader(expectedTypeId));
};
/**
* @param {Function} reader reader function for each item
* @param {number} [expectedTypeId] Expected WKB Type ID
* @return {any} values read
*/
WkbReader.prototype.readWkbCollection = function (reader, expectedTypeId) {
var num = this.readUint32();
var items = [];
for (var i = 0; i < num; i++) {
var result = reader.call(this, expectedTypeId);
if (result) {
items.push(result);
}
}
return items;
};
/**
* @return {Array<import('../coordinate.js').Coordinate>} coords for MultiPoint
*/
WkbReader.prototype.readMultiPoint = function () {
return this.readWkbCollection(this.readWkbBlock, WKBGeometryType.POINT);
};
/**
* @return {Array<Array<import('../coordinate.js').Coordinate>>} coords for MultiLineString like
*/
WkbReader.prototype.readMultiLineString = function () {
return this.readWkbCollection(this.readWkbBlock, WKBGeometryType.LINE_STRING);
};
/**
* @return {Array<Array<Array<import('../coordinate.js').Coordinate>>>} coords for MultiPolygon like
*/
WkbReader.prototype.readMultiPolygon = function () {
return this.readWkbCollection(this.readWkbBlock, WKBGeometryType.POLYGON);
};
/**
* @return {Array<import('../geom/Geometry.js').default>} array of geometries
*/
WkbReader.prototype.readGeometryCollection = function () {
return this.readWkbCollection(this.readGeometry);
};
/**
* @return {import('../geom/Geometry.js').default} geometry
*/
WkbReader.prototype.readGeometry = function () {
var typeId = this.readWkbHeader();
var result = this.readWkbPayload(typeId);
switch (typeId) {
case WKBGeometryType.POINT:
return new Point(
/** @type {import('../coordinate.js').Coordinate} */ (result), this.layout_);
case WKBGeometryType.LINE_STRING:
return new LineString(
/** @type {Array<import('../coordinate.js').Coordinate>} */ (result), this.layout_);
case WKBGeometryType.POLYGON:
case WKBGeometryType.TRIANGLE:
return new Polygon(
/** @type {Array<Array<import('../coordinate.js').Coordinate>>} */ (result), this.layout_);
case WKBGeometryType.MULTI_POINT:
return new MultiPoint(
/** @type {Array<import('../coordinate.js').Coordinate>} */ (result), this.layout_);
case WKBGeometryType.MULTI_LINE_STRING:
return new MultiLineString(
/** @type {Array<Array<import('../coordinate.js').Coordinate>>} */ (result), this.layout_);
case WKBGeometryType.MULTI_POLYGON:
case WKBGeometryType.POLYHEDRAL_SURFACE:
case WKBGeometryType.TIN:
return new MultiPolygon(
/** @type {Array<Array<Array<import('../coordinate.js').Coordinate>>>} */ (result), this.layout_);
case WKBGeometryType.GEOMETRY_COLLECTION:
return new GeometryCollection(
/** @type {Array<import('../geom/Geometry.js').default>} */ (result));
default:
return null;
}
};
/**
* @return {number|null} SRID in the EWKB. `null` if not defined.
*/
WkbReader.prototype.getSrid = function () {
return this.srid_;
};
return WkbReader;
}());
var WkbWriter = /** @class */ (function () {
/**
* @type {Object}
* @property {string} [layout] geometryLayout
* @property {boolean} [littleEndian=true] littleEndian
* @property {boolean} [ewkb=true] Whether writes in EWKB format
* @property {Object} [nodata] NoData value for each axes
* @param {Object} opts options
*/
function WkbWriter(opts) {
opts = opts || {};
/** @type {string} */
this.layout_ = opts.layout;
this.isLittleEndian_ = opts.littleEndian !== false;
this.isEWKB_ = opts.ewkb !== false;
/** @type {Array<Array<number>>} */
this.writeQueue_ = [];
/**
* @type {Object}
* @property {number} X NoData value for X
* @property {number} Y NoData value for Y
* @property {number} Z NoData value for Z
* @property {number} M NoData value for M
*/
this.nodata_ = assign({ X: 0, Y: 0, Z: 0, M: 0 }, opts.nodata);
}
/**
* @param {number} value value
*/
WkbWriter.prototype.writeUint8 = function (value) {
this.writeQueue_.push([1, value]);
};
/**
* @param {number} value value
*/
WkbWriter.prototype.writeUint32 = function (value) {
this.writeQueue_.push([4, value]);
};
/**
* @param {number} value value
*/
WkbWriter.prototype.writeDouble = function (value) {
this.writeQueue_.push([8, value]);
};
/**
* @param {import('../coordinate.js').Coordinate} coords coords
* @param {import("../geom/GeometryLayout").default} layout layout
*/
WkbWriter.prototype.writePoint = function (coords, layout) {
/**
* @type {Object}
* @property {number} X NoData value for X
* @property {number} Y NoData value for Y
* @property {number} [Z] NoData value for Z
* @property {number} [M] NoData value for M
*/
var coordsObj = assign.apply(null, layout.split('').map(function (axis, idx) {
var _a;
return (_a = {}, _a[axis] = coords[idx], _a);
}));
for (var _i = 0, _a = this.layout_; _i < _a.length; _i++) {
var axis = _a[_i];
this.writeDouble(axis in coordsObj ? coordsObj[axis] : this.nodata_[axis]);
}
};
/**
* @param {Array<import('../coordinate.js').Coordinate>} coords coords
* @param {import("../geom/GeometryLayout").default} layout layout
*/
WkbWriter.prototype.writeLineString = function (coords, layout) {
this.writeUint32(coords.length); // numPoints
for (var i = 0; i < coords.length; i++) {
this.writePoint(coords[i], layout);
}
};
/**
* @param {Array<Array<import('../coordinate.js').Coordinate>>} rings rings
* @param {import("../geom/GeometryLayout").default} layout layout
*/
WkbWriter.prototype.writePolygon = function (rings, layout) {
this.writeUint32(rings.length); // numRings
for (var i = 0; i < rings.length; i++) {
this.writeLineString(rings[i], layout); // as a LinearRing
}
};
/**
* @param {number} wkbType WKB Type ID
* @param {number} [srid] SRID
*/
WkbWriter.prototype.writeWkbHeader = function (wkbType, srid) {
wkbType %= 1000; // Assume 1000 is an upper limit for type ID
if (this.layout_.indexOf('Z') >= 0) {
wkbType += this.isEWKB_ ? 0x80000000 : 1000;
}
if (this.layout_.indexOf('M') >= 0) {
wkbType += this.isEWKB_ ? 0x40000000 : 2000;
}
if (this.isEWKB_ && Number.isInteger(srid)) {
wkbType |= 0x20000000;
}
this.writeUint8(this.isLittleEndian_ ? 1 : 0);
this.writeUint32(wkbType);
if (this.isEWKB_ && Number.isInteger(srid)) {
this.writeUint32(srid);
}
};
/**
* @param {Array<import('../coordinate.js').Coordinate>} coords coords
* @param {string} layout layout
*/
WkbWriter.prototype.writeMultiPoint = function (coords, layout) {
this.writeUint32(coords.length); // numItems
for (var i = 0; i < coords.length; i++) {
this.writeWkbHeader(1);
this.writePoint(coords[i], layout);
}
};
/**
* @param {Array<Array<import('../coordinate.js').Coordinate>>} coords coords
* @param {string} layout layout
*/
WkbWriter.prototype.writeMultiLineString = function (coords, layout) {
this.writeUint32(coords.length); // numItems
for (var i = 0; i < coords.length; i++) {
this.writeWkbHeader(2);
this.writeLineString(coords[i], layout);
}
};
/**
* @param {Array<Array<Array<import('../coordinate.js').Coordinate>>>} coords coords
* @param {string} layout layout
*/
WkbWriter.prototype.writeMultiPolygon = function (coords, layout) {
this.writeUint32(coords.length); // numItems
for (var i = 0; i < coords.length; i++) {
this.writeWkbHeader(3);
this.writePolygon(coords[i], layout);
}
};
/**
* @param {Array<import('../geom/Geometry.js').default>} geometries geometries
*/
WkbWriter.prototype.writeGeometryCollection = function (geometries) {
this.writeUint32(geometries.length); // numItems
for (var i = 0; i < geometries.length; i++) {
this.writeGeometry(geometries[i]);
}
};
/**
* @param {import("../geom/Geometry.js").default} geom geometry
* @param {import("../geom/GeometryLayout.js").default} [layout] layout
* @return {import("../geom/GeometryLayout.js").default} minumum layout made by common axes
*/
WkbWriter.prototype.findMinimumLayout = function (geom, layout) {
if (layout === void 0) { layout = GeometryLayout.XYZM; }
/**
* @param {import("../geom/GeometryLayout.js").default} a A
* @param {import("../geom/GeometryLayout.js").default} b B
* @return {import("../geom/GeometryLayout.js").default} minumum layout made by common axes
*/
var GeometryLayout_min = function (a, b) {
if (a === b) {
return a;
}
if (a === GeometryLayout.XYZM) {
// anything `b` is minimum
return b;
}
if (b === GeometryLayout.XYZM) {
// anything `a` is minimum
return a;
}
// otherwise, incompatible
return GeometryLayout.XY;
};
if (geom instanceof SimpleGeometry) {
return GeometryLayout_min(geom.getLayout(), layout);
}
if (geom instanceof GeometryCollection) {
var geoms = geom.getGeometriesArray();
for (var i = 0; i < geoms.length && layout !== GeometryLayout.XY; i++) {
layout = this.findMinimumLayout(geoms[i], layout);
}
}
return layout;
};
/**
* @param {import("../geom/Geometry.js").default} geom geometry
* @param {number} [srid] SRID
*/
WkbWriter.prototype.writeGeometry = function (geom, srid) {
/**
* @type {Object<import("../geom/Geometry.js").Type, WKBGeometryType>}
*/
var wkblut = {
Point: WKBGeometryType.POINT,
LineString: WKBGeometryType.LINE_STRING,
Polygon: WKBGeometryType.POLYGON,
MultiPoint: WKBGeometryType.MULTI_POINT,
MultiLineString: WKBGeometryType.MULTI_LINE_STRING,
MultiPolygon: WKBGeometryType.MULTI_POLYGON,
GeometryCollection: WKBGeometryType.GEOMETRY_COLLECTION,
};
var geomType = geom.getType();
var typeId = wkblut[geomType];
if (!typeId) {
throw new Error('GeometryType ' + geomType + ' is not supported');
}
// first call of writeGeometry() traverse whole geometries to determine its output layout if not specified on constructor.
if (!this.layout_) {
this.layout_ = this.findMinimumLayout(geom);
}
this.writeWkbHeader(typeId, srid);
if (geom instanceof SimpleGeometry) {
var writerLUT = {
Point: this.writePoint,
LineString: this.writeLineString,
Polygon: this.writePolygon,
MultiPoint: this.writeMultiPoint,
MultiLineString: this.writeMultiLineString,
MultiPolygon: this.writeMultiPolygon,
};
writerLUT[geomType].call(this, geom.getCoordinates(), geom.getLayout());
}
else if (geom instanceof GeometryCollection) {
this.writeGeometryCollection(geom.getGeometriesArray());
}
};
WkbWriter.prototype.getBuffer = function () {
var _this = this;
var byteLength = this.writeQueue_.reduce(function (acc, item) { return acc + item[0]; }, 0);
var buffer = new ArrayBuffer(byteLength);
var view = new DataView(buffer);
var pos = 0;
this.writeQueue_.forEach(function (item) {
switch (item[0]) {
case 1:
view.setUint8(pos, item[1]);
break;
case 4:
view.setUint32(pos, item[1], _this.isLittleEndian_);
break;
case 8:
view.setFloat64(pos, item[1], _this.isLittleEndian_);
break;
default:
break;
}
pos += item[0];
});
return buffer;
};
return WkbWriter;
}());
/**
* @typedef {Object} Options
* @property {boolean} [splitCollection=false] Whether to split GeometryCollections into multiple features on reading.
* @property {boolean} [hex=true] Returns hex string instead of ArrayBuffer for output. This also is used as a hint internally whether it should load contents as text or ArrayBuffer on reading.
* @property {boolean} [littleEndian=true] Use littleEndian for output.
* @property {boolean} [ewkb=true] Use EWKB format for output.
* @property {import("../geom/GeometryLayout").default} [geometryLayout=null] Use specific coordinate layout for output features (null: auto detect)
* @property {number} [nodataZ=0] If the `geometryLayout` doesn't match with geometry to be output, this value is used to fill missing coordinate value of Z.
* @property {number} [nodataM=0] If the `geometryLayout` doesn't match with geometry to be output, this value is used to fill missing coordinate value of M.
* @property {number|boolean} [srid=true] SRID for output. Specify integer value to enforce the value as a SRID. Specify `true` to extract from `dataProjection`. `false` to suppress the output. This option only takes effect when `ewkb` is `true`.
*/
/**
* @classdesc
* Geometry format for reading and writing data in the `Well-Known Binary` (WKB) format.
* Also supports `Extended Well-Known Binary` (EWKB) format, used in PostGIS for example.
*
* @api
*/
var WKB = /** @class */ (function (_super) {
__extends(WKB, _super);
/**
* @param {Options} [opt_options] Optional configuration object.
*/
function WKB(opt_options) {
var _this = _super.call(this) || this;
var options = opt_options ? opt_options : {};
_this.splitCollection = Boolean(options.splitCollection);
_this.viewCache_ = null;
_this.hex_ = options.hex !== false;
_this.littleEndian_ = options.littleEndian !== false;
_this.ewkb_ = options.ewkb !== false;
_this.layout_ = options.geometryLayout; // null for auto detect
_this.nodataZ_ = options.nodataZ || 0;
_this.nodataM_ = options.nodataM || 0;
_this.srid_ = options.srid;
return _this;
}
/**
* @return {import("./Feature.js").Type} Format.
*/
WKB.prototype.getType = function () {
return this.hex_ ? 'text' : 'arraybuffer';
};
/**
* Read a single feature from a source.
*
* @param {string|ArrayBuffer|ArrayBufferView} source Source.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../Feature.js").default} Feature.
* @api
*/
WKB.prototype.readFeature = function (source, opt_options) {
return new Feature({
geometry: this.readGeometry(source, opt_options),
});
};
/**
* Read all features from a source.
*
* @param {string|ArrayBuffer|ArrayBufferView} source Source.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {Array<import("../Feature.js").default>} Features.
* @api
*/
WKB.prototype.readFeatures = function (source, opt_options) {
var geometries = [];
var geometry = this.readGeometry(source, opt_options);
if (this.splitCollection && geometry instanceof GeometryCollection) {
geometries = geometry.getGeometriesArray();
}
else {
geometries = [geometry];
}
return geometries.map(function (geometry) { return new Feature({ geometry: geometry }); });
};
/**
* Read a single geometry from a source.
*
* @param {string|ArrayBuffer|ArrayBufferView} source Source.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../geom/Geometry.js").default} Geometry.
* @api
*/
WKB.prototype.readGeometry = function (source, opt_options) {
var view = getDataView(source);
if (!view) {
return null;
}
var reader = new WkbReader(view);
var geometry = reader.readGeometry();
this.viewCache_ = view; // cache for internal subsequent call of readProjection()
var options = this.getReadOptions(source, opt_options);
this.viewCache_ = null; // release
return transformGeometryWithOptions(geometry, false, options);
};
/**
* Read the projection from a source.
*
* @param {string|ArrayBuffer|ArrayBufferView} source Source.
* @return {import("../proj/Projection.js").default|undefined} Projection.
* @api
*/
WKB.prototype.readProjection = function (source) {
var view = this.viewCache_ || getDataView(source);
if (!view) {
return undefined;
}
var reader = new WkbReader(view);
reader.readWkbHeader();
return ((reader.getSrid() && getProjection('EPSG:' + reader.getSrid())) ||
undefined);
};
/**
* Encode a feature in this format.
*
* @param {import("../Feature.js").default} feature Feature.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string|ArrayBuffer} Result.
* @api
*/
WKB.prototype.writeFeature = function (feature, opt_options) {
return this.writeGeometry(feature.getGeometry(), opt_options);
};
/**
* Encode an array of features in this format.
*
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string|ArrayBuffer} Result.
* @api
*/
WKB.prototype.writeFeatures = function (features, opt_options) {
return this.writeGeometry(new GeometryCollection(features.map(function (f) { return f.getGeometry(); })), opt_options);
};
/**
* Write a single geometry in this format.
*
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @return {string|ArrayBuffer} Result.
* @api
*/
WKB.prototype.writeGeometry = function (geometry, opt_options) {
var options = this.adaptOptions(opt_options);
var writer = new WkbWriter({
layout: this.layout_,
littleEndian: this.littleEndian_,
ewkb: this.ewkb_,
nodata: {
Z: this.nodataZ_,
M: this.nodataM_,
},
});
// extract SRID from `dataProjection`
var srid = Number.isInteger(this.srid_) ? Number(this.srid_) : null;
if (this.srid_ !== false && !Number.isInteger(this.srid_)) {
var dataProjection = options.dataProjection && getProjection(options.dataProjection);
if (dataProjection) {
var code = dataProjection.getCode();
if (code.indexOf('EPSG:') === 0) {
srid = Number(code.substring(5));
}
}
}
writer.writeGeometry(transformGeometryWithOptions(geometry, true, options), srid);
var buffer = writer.getBuffer();
return this.hex_ ? encodeHexString(buffer) : buffer;
};
return WKB;
}(FeatureFormat));
/**
* @param {ArrayBuffer} buffer source buffer
* @return {string} encoded hex string
*/
function encodeHexString(buffer) {
var view = new Uint8Array(buffer);
return Array.from(view.values())
.map(function (x) { return (x < 16 ? '0' : '') + Number(x).toString(16).toUpperCase(); })
.join('');
}
/**
* @param {string} text source text
* @return {DataView} decoded binary buffer
*/
function decodeHexString(text) {
var buffer = new Uint8Array(text.length / 2);
for (var i = 0; i < text.length / 2; i++) {
buffer[i] = parseInt(text.substr(i * 2, 2), 16);
}
return new DataView(buffer.buffer);
}
/**
* @param {string | ArrayBuffer | ArrayBufferView} source source
* @return {DataView} data view
*/
function getDataView(source) {
if (typeof source === 'string') {
return decodeHexString(source);
}
else if (ArrayBuffer.isView(source)) {
if (source instanceof DataView) {
return source;
}
return new DataView(source.buffer, source.byteOffset, source.byteLength);
}
else if (source instanceof ArrayBuffer) {
return new DataView(source);
}
else {
return null;
}
}
export default WKB;
//# sourceMappingURL=WKB.js.map
+1
View File
File diff suppressed because one or more lines are too long
+51
View File
@@ -0,0 +1,51 @@
export default WKT;
export type Options = {
/**
* Whether to split GeometryCollections into
* multiple features on reading.
*/
splitCollection?: boolean | undefined;
};
export type Token = {
/**
* Type.
*/
type: number;
/**
* Value.
*/
value?: string | number | undefined;
/**
* Position.
*/
position: number;
};
/**
* @classdesc
* Geometry format for reading and writing data in the `WellKnownText` (WKT)
* format.
*
* @api
*/
declare class WKT extends TextFeature {
/**
* @param {Options} [opt_options] Options.
*/
constructor(opt_options?: Options | undefined);
/**
* Split GeometryCollection into multiple features.
* @type {boolean}
* @private
*/
private splitCollection_;
/**
* Parse a WKT string.
* @param {string} wkt WKT string.
* @return {import("../geom/Geometry.js").default}
* The geometry created.
* @private
*/
private parse_;
}
import TextFeature from "./TextFeature.js";
//# sourceMappingURL=WKT.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"WKT.d.ts","sourceRoot":"","sources":["../src/format/WKT.js"],"names":[],"mappings":";;;;;;;;;;;;UAoCc,MAAM;;;;;;;;cAEN,MAAM;;AA4iBpB;;;;;;GAMG;AACH;IACE;;OAEG;IACH,+CAYC;IAPC;;;;OAIG;IACH,yBACyE;IAG3E;;;;;;OAMG;IACH,eAIC;CA4FF"}
+831
View File
@@ -0,0 +1,831 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/format/WKT
*/
import Feature from '../Feature.js';
import GeometryCollection from '../geom/GeometryCollection.js';
import GeometryLayout from '../geom/GeometryLayout.js';
import LineString from '../geom/LineString.js';
import MultiLineString from '../geom/MultiLineString.js';
import MultiPoint from '../geom/MultiPoint.js';
import MultiPolygon from '../geom/MultiPolygon.js';
import Point from '../geom/Point.js';
import Polygon from '../geom/Polygon.js';
import TextFeature from './TextFeature.js';
import { transformGeometryWithOptions } from './Feature.js';
/**
* Geometry constructors
* @enum {function (new:import("../geom/Geometry.js").default, Array, import("../geom/GeometryLayout.js").default)}
*/
var GeometryConstructor = {
'POINT': Point,
'LINESTRING': LineString,
'POLYGON': Polygon,
'MULTIPOINT': MultiPoint,
'MULTILINESTRING': MultiLineString,
'MULTIPOLYGON': MultiPolygon,
};
/**
* @typedef {Object} Options
* @property {boolean} [splitCollection=false] Whether to split GeometryCollections into
* multiple features on reading.
*/
/**
* @typedef {Object} Token
* @property {number} type Type.
* @property {number|string} [value] Value.
* @property {number} position Position.
*/
/**
* @const
* @type {string}
*/
var EMPTY = 'EMPTY';
/**
* @const
* @type {string}
*/
var Z = 'Z';
/**
* @const
* @type {string}
*/
var M = 'M';
/**
* @const
* @type {string}
*/
var ZM = 'ZM';
/**
* @const
* @enum {number}
*/
var TokenType = {
START: 0,
TEXT: 1,
LEFT_PAREN: 2,
RIGHT_PAREN: 3,
NUMBER: 4,
COMMA: 5,
EOF: 6,
};
/**
* @type {Object<import("../geom/Geometry.js").Type, string>}
*/
var wktTypeLookup = {
Point: 'POINT',
LineString: 'LINESTRING',
Polygon: 'POLYGON',
MultiPoint: 'MULTIPOINT',
MultiLineString: 'MULTILINESTRING',
MultiPolygon: 'MULTIPOLYGON',
GeometryCollection: 'GEOMETRYCOLLECTION',
Circle: 'CIRCLE',
};
/**
* Class to tokenize a WKT string.
*/
var Lexer = /** @class */ (function () {
/**
* @param {string} wkt WKT string.
*/
function Lexer(wkt) {
/**
* @type {string}
*/
this.wkt = wkt;
/**
* @type {number}
* @private
*/
this.index_ = -1;
}
/**
* @param {string} c Character.
* @return {boolean} Whether the character is alphabetic.
* @private
*/
Lexer.prototype.isAlpha_ = function (c) {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
};
/**
* @param {string} c Character.
* @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
*/
Lexer.prototype.isNumeric_ = function (c, opt_decimal) {
var decimal = opt_decimal !== undefined ? opt_decimal : false;
return (c >= '0' && c <= '9') || (c == '.' && !decimal);
};
/**
* @param {string} c Character.
* @return {boolean} Whether the character is whitespace.
* @private
*/
Lexer.prototype.isWhiteSpace_ = function (c) {
return c == ' ' || c == '\t' || c == '\r' || c == '\n';
};
/**
* @return {string} Next string character.
* @private
*/
Lexer.prototype.nextChar_ = function () {
return this.wkt.charAt(++this.index_);
};
/**
* Fetch and return the next token.
* @return {Token} Next string token.
*/
Lexer.prototype.nextToken = function () {
var c = this.nextChar_();
var position = this.index_;
/** @type {number|string} */
var value = c;
var type;
if (c == '(') {
type = TokenType.LEFT_PAREN;
}
else if (c == ',') {
type = TokenType.COMMA;
}
else if (c == ')') {
type = TokenType.RIGHT_PAREN;
}
else if (this.isNumeric_(c) || c == '-') {
type = TokenType.NUMBER;
value = this.readNumber_();
}
else if (this.isAlpha_(c)) {
type = TokenType.TEXT;
value = this.readText_();
}
else if (this.isWhiteSpace_(c)) {
return this.nextToken();
}
else if (c === '') {
type = TokenType.EOF;
}
else {
throw new Error('Unexpected character: ' + c);
}
return { position: position, value: value, type: type };
};
/**
* @return {number} Numeric token value.
* @private
*/
Lexer.prototype.readNumber_ = function () {
var c;
var index = this.index_;
var decimal = false;
var scientificNotation = false;
do {
if (c == '.') {
decimal = true;
}
else if (c == 'e' || c == 'E') {
scientificNotation = true;
}
c = this.nextChar_();
} while (this.isNumeric_(c, decimal) ||
// if we haven't detected a scientific number before, 'e' or 'E'
// hint that we should continue to read
(!scientificNotation && (c == 'e' || c == 'E')) ||
// once we know that we have a scientific number, both '-' and '+'
// are allowed
(scientificNotation && (c == '-' || c == '+')));
return parseFloat(this.wkt.substring(index, this.index_--));
};
/**
* @return {string} String token value.
* @private
*/
Lexer.prototype.readText_ = function () {
var c;
var index = this.index_;
do {
c = this.nextChar_();
} while (this.isAlpha_(c));
return this.wkt.substring(index, this.index_--).toUpperCase();
};
return Lexer;
}());
/**
* Class to parse the tokens from the WKT string.
*/
var Parser = /** @class */ (function () {
/**
* @param {Lexer} lexer The lexer.
*/
function Parser(lexer) {
/**
* @type {Lexer}
* @private
*/
this.lexer_ = lexer;
/**
* @type {Token}
* @private
*/
this.token_ = {
position: 0,
type: TokenType.START,
};
/**
* @type {import("../geom/GeometryLayout.js").default}
* @private
*/
this.layout_ = GeometryLayout.XY;
}
/**
* Fetch the next token form the lexer and replace the active token.
* @private
*/
Parser.prototype.consume_ = function () {
this.token_ = this.lexer_.nextToken();
};
/**
* Tests if the given type matches the type of the current token.
* @param {TokenType} type Token type.
* @return {boolean} Whether the token matches the given type.
*/
Parser.prototype.isTokenType = function (type) {
return this.token_.type == type;
};
/**
* If the given type matches the current token, consume it.
* @param {TokenType} type Token type.
* @return {boolean} Whether the token matches the given type.
*/
Parser.prototype.match = function (type) {
var isMatch = this.isTokenType(type);
if (isMatch) {
this.consume_();
}
return isMatch;
};
/**
* Try to parse the tokens provided by the lexer.
* @return {import("../geom/Geometry.js").default} The geometry.
*/
Parser.prototype.parse = function () {
this.consume_();
return this.parseGeometry_();
};
/**
* Try to parse the dimensional info.
* @return {import("../geom/GeometryLayout.js").default} The layout.
* @private
*/
Parser.prototype.parseGeometryLayout_ = function () {
var layout = GeometryLayout.XY;
var dimToken = this.token_;
if (this.isTokenType(TokenType.TEXT)) {
var dimInfo = dimToken.value;
if (dimInfo === Z) {
layout = GeometryLayout.XYZ;
}
else if (dimInfo === M) {
layout = GeometryLayout.XYM;
}
else if (dimInfo === ZM) {
layout = GeometryLayout.XYZM;
}
if (layout !== GeometryLayout.XY) {
this.consume_();
}
}
return layout;
};
/**
* @return {Array<import("../geom/Geometry.js").default>} A collection of geometries.
* @private
*/
Parser.prototype.parseGeometryCollectionText_ = function () {
if (this.match(TokenType.LEFT_PAREN)) {
var geometries = [];
do {
geometries.push(this.parseGeometry_());
} while (this.match(TokenType.COMMA));
if (this.match(TokenType.RIGHT_PAREN)) {
return geometries;
}
}
throw new Error(this.formatErrorMessage_());
};
/**
* @return {Array<number>} All values in a point.
* @private
*/
Parser.prototype.parsePointText_ = function () {
if (this.match(TokenType.LEFT_PAREN)) {
var coordinates = this.parsePoint_();
if (this.match(TokenType.RIGHT_PAREN)) {
return coordinates;
}
}
throw new Error(this.formatErrorMessage_());
};
/**
* @return {Array<Array<number>>} All points in a linestring.
* @private
*/
Parser.prototype.parseLineStringText_ = function () {
if (this.match(TokenType.LEFT_PAREN)) {
var coordinates = this.parsePointList_();
if (this.match(TokenType.RIGHT_PAREN)) {
return coordinates;
}
}
throw new Error(this.formatErrorMessage_());
};
/**
* @return {Array<Array<Array<number>>>} All points in a polygon.
* @private
*/
Parser.prototype.parsePolygonText_ = function () {
if (this.match(TokenType.LEFT_PAREN)) {
var coordinates = this.parseLineStringTextList_();
if (this.match(TokenType.RIGHT_PAREN)) {
return coordinates;
}
}
throw new Error(this.formatErrorMessage_());
};
/**
* @return {Array<Array<number>>} All points in a multipoint.
* @private
*/
Parser.prototype.parseMultiPointText_ = function () {
if (this.match(TokenType.LEFT_PAREN)) {
var coordinates = void 0;
if (this.token_.type == TokenType.LEFT_PAREN) {
coordinates = this.parsePointTextList_();
}
else {
coordinates = this.parsePointList_();
}
if (this.match(TokenType.RIGHT_PAREN)) {
return coordinates;
}
}
throw new Error(this.formatErrorMessage_());
};
/**
* @return {Array<Array<Array<number>>>} All linestring points
* in a multilinestring.
* @private
*/
Parser.prototype.parseMultiLineStringText_ = function () {
if (this.match(TokenType.LEFT_PAREN)) {
var coordinates = this.parseLineStringTextList_();
if (this.match(TokenType.RIGHT_PAREN)) {
return coordinates;
}
}
throw new Error(this.formatErrorMessage_());
};
/**
* @return {Array<Array<Array<Array<number>>>>} All polygon points in a multipolygon.
* @private
*/
Parser.prototype.parseMultiPolygonText_ = function () {
if (this.match(TokenType.LEFT_PAREN)) {
var coordinates = this.parsePolygonTextList_();
if (this.match(TokenType.RIGHT_PAREN)) {
return coordinates;
}
}
throw new Error(this.formatErrorMessage_());
};
/**
* @return {Array<number>} A point.
* @private
*/
Parser.prototype.parsePoint_ = function () {
var coordinates = [];
var dimensions = this.layout_.length;
for (var i = 0; i < dimensions; ++i) {
var token = this.token_;
if (this.match(TokenType.NUMBER)) {
coordinates.push(/** @type {number} */ (token.value));
}
else {
break;
}
}
if (coordinates.length == dimensions) {
return coordinates;
}
throw new Error(this.formatErrorMessage_());
};
/**
* @return {Array<Array<number>>} An array of points.
* @private
*/
Parser.prototype.parsePointList_ = function () {
var coordinates = [this.parsePoint_()];
while (this.match(TokenType.COMMA)) {
coordinates.push(this.parsePoint_());
}
return coordinates;
};
/**
* @return {Array<Array<number>>} An array of points.
* @private
*/
Parser.prototype.parsePointTextList_ = function () {
var coordinates = [this.parsePointText_()];
while (this.match(TokenType.COMMA)) {
coordinates.push(this.parsePointText_());
}
return coordinates;
};
/**
* @return {Array<Array<Array<number>>>} An array of points.
* @private
*/
Parser.prototype.parseLineStringTextList_ = function () {
var coordinates = [this.parseLineStringText_()];
while (this.match(TokenType.COMMA)) {
coordinates.push(this.parseLineStringText_());
}
return coordinates;
};
/**
* @return {Array<Array<Array<Array<number>>>>} An array of points.
* @private
*/
Parser.prototype.parsePolygonTextList_ = function () {
var coordinates = [this.parsePolygonText_()];
while (this.match(TokenType.COMMA)) {
coordinates.push(this.parsePolygonText_());
}
return coordinates;
};
/**
* @return {boolean} Whether the token implies an empty geometry.
* @private
*/
Parser.prototype.isEmptyGeometry_ = function () {
var isEmpty = this.isTokenType(TokenType.TEXT) && this.token_.value == EMPTY;
if (isEmpty) {
this.consume_();
}
return isEmpty;
};
/**
* Create an error message for an unexpected token error.
* @return {string} Error message.
* @private
*/
Parser.prototype.formatErrorMessage_ = function () {
return ('Unexpected `' +
this.token_.value +
'` at position ' +
this.token_.position +
' in `' +
this.lexer_.wkt +
'`');
};
/**
* @return {import("../geom/Geometry.js").default} The geometry.
* @private
*/
Parser.prototype.parseGeometry_ = function () {
var token = this.token_;
if (this.match(TokenType.TEXT)) {
var geomType = /** @type {string} */ (token.value);
this.layout_ = this.parseGeometryLayout_();
var isEmpty = this.isEmptyGeometry_();
if (geomType == 'GEOMETRYCOLLECTION') {
if (isEmpty) {
return new GeometryCollection([]);
}
var geometries = this.parseGeometryCollectionText_();
return new GeometryCollection(geometries);
}
else {
var ctor = GeometryConstructor[geomType];
if (!ctor) {
throw new Error('Invalid geometry type: ' + geomType);
}
var coordinates = void 0;
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_);
}
}
throw new Error(this.formatErrorMessage_());
};
return Parser;
}());
/**
* @classdesc
* Geometry format for reading and writing data in the `WellKnownText` (WKT)
* format.
*
* @api
*/
var WKT = /** @class */ (function (_super) {
__extends(WKT, _super);
/**
* @param {Options} [opt_options] Options.
*/
function WKT(opt_options) {
var _this = _super.call(this) || this;
var options = opt_options ? opt_options : {};
/**
* Split GeometryCollection into multiple features.
* @type {boolean}
* @private
*/
_this.splitCollection_ =
options.splitCollection !== undefined ? options.splitCollection : false;
return _this;
}
/**
* Parse a WKT string.
* @param {string} wkt WKT string.
* @return {import("../geom/Geometry.js").default}
* The geometry created.
* @private
*/
WKT.prototype.parse_ = function (wkt) {
var lexer = new Lexer(wkt);
var parser = new Parser(lexer);
return parser.parse();
};
/**
* @protected
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @return {import("../Feature.js").default} Feature.
*/
WKT.prototype.readFeatureFromText = function (text, opt_options) {
var geom = this.readGeometryFromText(text, opt_options);
var feature = new Feature();
feature.setGeometry(geom);
return feature;
};
/**
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {Array<Feature>} Features.
*/
WKT.prototype.readFeaturesFromText = function (text, opt_options) {
var geometries = [];
var geometry = this.readGeometryFromText(text, opt_options);
if (this.splitCollection_ && geometry.getType() == 'GeometryCollection') {
geometries = /** @type {GeometryCollection} */ (geometry).getGeometriesArray();
}
else {
geometries = [geometry];
}
var features = [];
for (var i = 0, ii = geometries.length; i < ii; ++i) {
var feature = new Feature();
feature.setGeometry(geometries[i]);
features.push(feature);
}
return features;
};
/**
* @param {string} text Text.
* @param {import("./Feature.js").ReadOptions} [opt_options] Read options.
* @protected
* @return {import("../geom/Geometry.js").default} Geometry.
*/
WKT.prototype.readGeometryFromText = function (text, opt_options) {
var geometry = this.parse_(text);
return transformGeometryWithOptions(geometry, false, opt_options);
};
/**
* @param {import("../Feature.js").default} feature Features.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
WKT.prototype.writeFeatureText = function (feature, opt_options) {
var geometry = feature.getGeometry();
if (geometry) {
return this.writeGeometryText(geometry, opt_options);
}
return '';
};
/**
* @param {Array<import("../Feature.js").default>} features Features.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
WKT.prototype.writeFeaturesText = function (features, opt_options) {
if (features.length == 1) {
return this.writeFeatureText(features[0], opt_options);
}
var geometries = [];
for (var i = 0, ii = features.length; i < ii; ++i) {
geometries.push(features[i].getGeometry());
}
var collection = new GeometryCollection(geometries);
return this.writeGeometryText(collection, opt_options);
};
/**
* @param {import("../geom/Geometry.js").default} geometry Geometry.
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
* @protected
* @return {string} Text.
*/
WKT.prototype.writeGeometryText = function (geometry, opt_options) {
return encode(transformGeometryWithOptions(geometry, true, opt_options));
};
return WKT;
}(TextFeature));
/**
* @param {Point} geom Point geometry.
* @return {string} Coordinates part of Point as WKT.
*/
function encodePointGeometry(geom) {
var coordinates = geom.getCoordinates();
if (coordinates.length === 0) {
return '';
}
return coordinates.join(' ');
}
/**
* @param {MultiPoint} geom MultiPoint geometry.
* @return {string} Coordinates part of MultiPoint as WKT.
*/
function encodeMultiPointGeometry(geom) {
var array = [];
var components = geom.getPoints();
for (var i = 0, ii = components.length; i < ii; ++i) {
array.push('(' + encodePointGeometry(components[i]) + ')');
}
return array.join(',');
}
/**
* @param {GeometryCollection} geom GeometryCollection geometry.
* @return {string} Coordinates part of GeometryCollection as WKT.
*/
function encodeGeometryCollectionGeometry(geom) {
var array = [];
var geoms = geom.getGeometries();
for (var i = 0, ii = geoms.length; i < ii; ++i) {
array.push(encode(geoms[i]));
}
return array.join(',');
}
/**
* @param {LineString|import("../geom/LinearRing.js").default} geom LineString geometry.
* @return {string} Coordinates part of LineString as WKT.
*/
function encodeLineStringGeometry(geom) {
var coordinates = geom.getCoordinates();
var array = [];
for (var i = 0, ii = coordinates.length; i < ii; ++i) {
array.push(coordinates[i].join(' '));
}
return array.join(',');
}
/**
* @param {MultiLineString} geom MultiLineString geometry.
* @return {string} Coordinates part of MultiLineString as WKT.
*/
function encodeMultiLineStringGeometry(geom) {
var array = [];
var components = geom.getLineStrings();
for (var i = 0, ii = components.length; i < ii; ++i) {
array.push('(' + encodeLineStringGeometry(components[i]) + ')');
}
return array.join(',');
}
/**
* @param {Polygon} geom Polygon geometry.
* @return {string} Coordinates part of Polygon as WKT.
*/
function encodePolygonGeometry(geom) {
var array = [];
var rings = geom.getLinearRings();
for (var i = 0, ii = rings.length; i < ii; ++i) {
array.push('(' + encodeLineStringGeometry(rings[i]) + ')');
}
return array.join(',');
}
/**
* @param {MultiPolygon} geom MultiPolygon geometry.
* @return {string} Coordinates part of MultiPolygon as WKT.
*/
function encodeMultiPolygonGeometry(geom) {
var array = [];
var components = geom.getPolygons();
for (var i = 0, ii = components.length; i < ii; ++i) {
array.push('(' + encodePolygonGeometry(components[i]) + ')');
}
return array.join(',');
}
/**
* @param {import("../geom/SimpleGeometry.js").default} geom SimpleGeometry geometry.
* @return {string} Potential dimensional information for WKT type.
*/
function encodeGeometryLayout(geom) {
var layout = geom.getLayout();
var dimInfo = '';
if (layout === GeometryLayout.XYZ || layout === GeometryLayout.XYZM) {
dimInfo += Z;
}
if (layout === GeometryLayout.XYM || layout === GeometryLayout.XYZM) {
dimInfo += M;
}
return dimInfo;
}
/**
* @const
* @type {Object<string, function(import("../geom/Geometry.js").default): string>}
*/
var GeometryEncoder = {
'Point': encodePointGeometry,
'LineString': encodeLineStringGeometry,
'Polygon': encodePolygonGeometry,
'MultiPoint': encodeMultiPointGeometry,
'MultiLineString': encodeMultiLineStringGeometry,
'MultiPolygon': encodeMultiPolygonGeometry,
'GeometryCollection': encodeGeometryCollectionGeometry,
};
/**
* Encode a geometry as WKT.
* @param {import("../geom/Geometry.js").default} geom The geometry to encode.
* @return {string} WKT string for the geometry.
*/
function encode(geom) {
var type = geom.getType();
var geometryEncoder = GeometryEncoder[type];
var enc = geometryEncoder(geom);
var wktType = wktTypeLookup[type];
if (typeof ( /** @type {?} */(geom).getFlatCoordinates) === 'function') {
var dimInfo = encodeGeometryLayout(
/** @type {import("../geom/SimpleGeometry.js").default} */ (geom));
if (dimInfo.length > 0) {
wktType += ' ' + dimInfo;
}
}
if (enc.length === 0) {
return wktType + ' ' + EMPTY;
}
return wktType + '(' + enc + ')';
}
export default WKT;
//# sourceMappingURL=WKT.js.map
+1
View File
File diff suppressed because one or more lines are too long
+15
View File
@@ -0,0 +1,15 @@
export default WMSCapabilities;
/**
* @classdesc
* Format for reading WMS capabilities data
*
* @api
*/
declare class WMSCapabilities extends XML {
/**
* @type {string|undefined}
*/
version: string | undefined;
}
import XML from "./XML.js";
//# sourceMappingURL=WMSCapabilities.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"WMSCapabilities.d.ts","sourceRoot":"","sources":["../src/format/WMSCapabilities.js"],"names":[],"mappings":";AAgDA;;;;;GAKG;AACH;IAII;;OAEG;IACH,SAFU,MAAM,GAAC,SAAS,CAEF;CAmB3B"}
+557
View File
@@ -0,0 +1,557 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/format/WMSCapabilities
*/
import XML from './XML.js';
import { makeArrayPusher, makeObjectPropertyPusher, makeObjectPropertySetter, makeStructureNS, pushParseAndPop, } from '../xml.js';
import { readBooleanString, readDecimal, readDecimalString, readNonNegativeIntegerString, readPositiveInteger, readString, } from './xsd.js';
import { readHref } from './xlink.js';
/**
* @const
* @type {Array<null|string>}
*/
var NAMESPACE_URIS = [null, 'http://www.opengis.net/wms'];
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Service': makeObjectPropertySetter(readService),
'Capability': makeObjectPropertySetter(readCapability),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var CAPABILITY_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Request': makeObjectPropertySetter(readRequest),
'Exception': makeObjectPropertySetter(readException),
'Layer': makeObjectPropertySetter(readCapabilityLayer),
});
/**
* @classdesc
* Format for reading WMS capabilities data
*
* @api
*/
var WMSCapabilities = /** @class */ (function (_super) {
__extends(WMSCapabilities, _super);
function WMSCapabilities() {
var _this = _super.call(this) || this;
/**
* @type {string|undefined}
*/
_this.version = undefined;
return _this;
}
/**
* @param {Element} node Node.
* @return {Object} Object
*/
WMSCapabilities.prototype.readFromNode = function (node) {
this.version = node.getAttribute('version').trim();
var wmsCapabilityObject = pushParseAndPop({
'version': this.version,
}, PARSERS, node, []);
return wmsCapabilityObject ? wmsCapabilityObject : null;
};
return WMSCapabilities;
}(XML));
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var SERVICE_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Name': makeObjectPropertySetter(readString),
'Title': makeObjectPropertySetter(readString),
'Abstract': makeObjectPropertySetter(readString),
'KeywordList': makeObjectPropertySetter(readKeywordList),
'OnlineResource': makeObjectPropertySetter(readHref),
'ContactInformation': makeObjectPropertySetter(readContactInformation),
'Fees': makeObjectPropertySetter(readString),
'AccessConstraints': makeObjectPropertySetter(readString),
'LayerLimit': makeObjectPropertySetter(readPositiveInteger),
'MaxWidth': makeObjectPropertySetter(readPositiveInteger),
'MaxHeight': makeObjectPropertySetter(readPositiveInteger),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var CONTACT_INFORMATION_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'ContactPersonPrimary': makeObjectPropertySetter(readContactPersonPrimary),
'ContactPosition': makeObjectPropertySetter(readString),
'ContactAddress': makeObjectPropertySetter(readContactAddress),
'ContactVoiceTelephone': makeObjectPropertySetter(readString),
'ContactFacsimileTelephone': makeObjectPropertySetter(readString),
'ContactElectronicMailAddress': makeObjectPropertySetter(readString),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var CONTACT_PERSON_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'ContactPerson': makeObjectPropertySetter(readString),
'ContactOrganization': makeObjectPropertySetter(readString),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var CONTACT_ADDRESS_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'AddressType': makeObjectPropertySetter(readString),
'Address': makeObjectPropertySetter(readString),
'City': makeObjectPropertySetter(readString),
'StateOrProvince': makeObjectPropertySetter(readString),
'PostCode': makeObjectPropertySetter(readString),
'Country': makeObjectPropertySetter(readString),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var EXCEPTION_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Format': makeArrayPusher(readString),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var LAYER_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Name': makeObjectPropertySetter(readString),
'Title': makeObjectPropertySetter(readString),
'Abstract': makeObjectPropertySetter(readString),
'KeywordList': makeObjectPropertySetter(readKeywordList),
'CRS': makeObjectPropertyPusher(readString),
'EX_GeographicBoundingBox': makeObjectPropertySetter(readEXGeographicBoundingBox),
'BoundingBox': makeObjectPropertyPusher(readBoundingBox),
'Dimension': makeObjectPropertyPusher(readDimension),
'Attribution': makeObjectPropertySetter(readAttribution),
'AuthorityURL': makeObjectPropertyPusher(readAuthorityURL),
'Identifier': makeObjectPropertyPusher(readString),
'MetadataURL': makeObjectPropertyPusher(readMetadataURL),
'DataURL': makeObjectPropertyPusher(readFormatOnlineresource),
'FeatureListURL': makeObjectPropertyPusher(readFormatOnlineresource),
'Style': makeObjectPropertyPusher(readStyle),
'MinScaleDenominator': makeObjectPropertySetter(readDecimal),
'MaxScaleDenominator': makeObjectPropertySetter(readDecimal),
'Layer': makeObjectPropertyPusher(readLayer),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var ATTRIBUTION_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Title': makeObjectPropertySetter(readString),
'OnlineResource': makeObjectPropertySetter(readHref),
'LogoURL': makeObjectPropertySetter(readSizedFormatOnlineresource),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'westBoundLongitude': makeObjectPropertySetter(readDecimal),
'eastBoundLongitude': makeObjectPropertySetter(readDecimal),
'southBoundLatitude': makeObjectPropertySetter(readDecimal),
'northBoundLatitude': makeObjectPropertySetter(readDecimal),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var REQUEST_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'GetCapabilities': makeObjectPropertySetter(readOperationType),
'GetMap': makeObjectPropertySetter(readOperationType),
'GetFeatureInfo': makeObjectPropertySetter(readOperationType),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var OPERATIONTYPE_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Format': makeObjectPropertyPusher(readString),
'DCPType': makeObjectPropertyPusher(readDCPType),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var DCPTYPE_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'HTTP': makeObjectPropertySetter(readHTTP),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var HTTP_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Get': makeObjectPropertySetter(readFormatOnlineresource),
'Post': makeObjectPropertySetter(readFormatOnlineresource),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var STYLE_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Name': makeObjectPropertySetter(readString),
'Title': makeObjectPropertySetter(readString),
'Abstract': makeObjectPropertySetter(readString),
'LegendURL': makeObjectPropertyPusher(readSizedFormatOnlineresource),
'StyleSheetURL': makeObjectPropertySetter(readFormatOnlineresource),
'StyleURL': makeObjectPropertySetter(readFormatOnlineresource),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var FORMAT_ONLINERESOURCE_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Format': makeObjectPropertySetter(readString),
'OnlineResource': makeObjectPropertySetter(readHref),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var KEYWORDLIST_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Keyword': makeArrayPusher(readString),
});
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Attribution object.
*/
function readAttribution(node, objectStack) {
return pushParseAndPop({}, ATTRIBUTION_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object} Bounding box object.
*/
function readBoundingBox(node, objectStack) {
var extent = [
readDecimalString(node.getAttribute('minx')),
readDecimalString(node.getAttribute('miny')),
readDecimalString(node.getAttribute('maxx')),
readDecimalString(node.getAttribute('maxy')),
];
var resolutions = [
readDecimalString(node.getAttribute('resx')),
readDecimalString(node.getAttribute('resy')),
];
return {
'crs': node.getAttribute('CRS'),
'extent': extent,
'res': resolutions,
};
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {import("../extent.js").Extent|undefined} Bounding box object.
*/
function readEXGeographicBoundingBox(node, objectStack) {
var geographicBoundingBox = pushParseAndPop({}, EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS, node, objectStack);
if (!geographicBoundingBox) {
return undefined;
}
var westBoundLongitude =
/** @type {number|undefined} */
(geographicBoundingBox['westBoundLongitude']);
var southBoundLatitude =
/** @type {number|undefined} */
(geographicBoundingBox['southBoundLatitude']);
var eastBoundLongitude =
/** @type {number|undefined} */
(geographicBoundingBox['eastBoundLongitude']);
var northBoundLatitude =
/** @type {number|undefined} */
(geographicBoundingBox['northBoundLatitude']);
if (westBoundLongitude === undefined ||
southBoundLatitude === undefined ||
eastBoundLongitude === undefined ||
northBoundLatitude === undefined) {
return undefined;
}
return [
westBoundLongitude,
southBoundLatitude,
eastBoundLongitude,
northBoundLatitude,
];
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Capability object.
*/
function readCapability(node, objectStack) {
return pushParseAndPop({}, CAPABILITY_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Service object.
*/
function readService(node, objectStack) {
return pushParseAndPop({}, SERVICE_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Contact information object.
*/
function readContactInformation(node, objectStack) {
return pushParseAndPop({}, CONTACT_INFORMATION_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Contact person object.
*/
function readContactPersonPrimary(node, objectStack) {
return pushParseAndPop({}, CONTACT_PERSON_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Contact address object.
*/
function readContactAddress(node, objectStack) {
return pushParseAndPop({}, CONTACT_ADDRESS_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Array<string>|undefined} Format array.
*/
function readException(node, objectStack) {
return pushParseAndPop([], EXCEPTION_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Layer object.
*/
function readCapabilityLayer(node, objectStack) {
var layerObject = pushParseAndPop({}, LAYER_PARSERS, node, objectStack);
if (layerObject['Layer'] === undefined) {
return Object.assign(layerObject, readLayer(node, objectStack));
}
return layerObject;
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Layer object.
*/
function readLayer(node, objectStack) {
var parentLayerObject = /** @type {!Object<string,*>} */ (objectStack[objectStack.length - 1]);
var layerObject = pushParseAndPop({}, LAYER_PARSERS, node, objectStack);
if (!layerObject) {
return undefined;
}
var queryable = readBooleanString(node.getAttribute('queryable'));
if (queryable === undefined) {
queryable = parentLayerObject['queryable'];
}
layerObject['queryable'] = queryable !== undefined ? queryable : false;
var cascaded = readNonNegativeIntegerString(node.getAttribute('cascaded'));
if (cascaded === undefined) {
cascaded = parentLayerObject['cascaded'];
}
layerObject['cascaded'] = cascaded;
var opaque = readBooleanString(node.getAttribute('opaque'));
if (opaque === undefined) {
opaque = parentLayerObject['opaque'];
}
layerObject['opaque'] = opaque !== undefined ? opaque : false;
var noSubsets = readBooleanString(node.getAttribute('noSubsets'));
if (noSubsets === undefined) {
noSubsets = parentLayerObject['noSubsets'];
}
layerObject['noSubsets'] = noSubsets !== undefined ? noSubsets : false;
var fixedWidth = readDecimalString(node.getAttribute('fixedWidth'));
if (!fixedWidth) {
fixedWidth = parentLayerObject['fixedWidth'];
}
layerObject['fixedWidth'] = fixedWidth;
var fixedHeight = readDecimalString(node.getAttribute('fixedHeight'));
if (!fixedHeight) {
fixedHeight = parentLayerObject['fixedHeight'];
}
layerObject['fixedHeight'] = fixedHeight;
// See 7.2.4.8
var addKeys = ['Style', 'CRS', 'AuthorityURL'];
addKeys.forEach(function (key) {
if (key in parentLayerObject) {
var childValue = layerObject[key] || [];
layerObject[key] = childValue.concat(parentLayerObject[key]);
}
});
var replaceKeys = [
'EX_GeographicBoundingBox',
'BoundingBox',
'Dimension',
'Attribution',
'MinScaleDenominator',
'MaxScaleDenominator',
];
replaceKeys.forEach(function (key) {
if (!(key in layerObject)) {
var parentValue = parentLayerObject[key];
layerObject[key] = parentValue;
}
});
return layerObject;
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object} Dimension object.
*/
function readDimension(node, objectStack) {
var dimensionObject = {
'name': node.getAttribute('name'),
'units': node.getAttribute('units'),
'unitSymbol': node.getAttribute('unitSymbol'),
'default': node.getAttribute('default'),
'multipleValues': readBooleanString(node.getAttribute('multipleValues')),
'nearestValue': readBooleanString(node.getAttribute('nearestValue')),
'current': readBooleanString(node.getAttribute('current')),
'values': readString(node),
};
return dimensionObject;
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Online resource object.
*/
function readFormatOnlineresource(node, objectStack) {
return pushParseAndPop({}, FORMAT_ONLINERESOURCE_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Request object.
*/
function readRequest(node, objectStack) {
return pushParseAndPop({}, REQUEST_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} DCP type object.
*/
function readDCPType(node, objectStack) {
return pushParseAndPop({}, DCPTYPE_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} HTTP object.
*/
function readHTTP(node, objectStack) {
return pushParseAndPop({}, HTTP_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Operation type object.
*/
function readOperationType(node, objectStack) {
return pushParseAndPop({}, OPERATIONTYPE_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Online resource object.
*/
function readSizedFormatOnlineresource(node, objectStack) {
var formatOnlineresource = readFormatOnlineresource(node, objectStack);
if (formatOnlineresource) {
var size = [
readNonNegativeIntegerString(node.getAttribute('width')),
readNonNegativeIntegerString(node.getAttribute('height')),
];
formatOnlineresource['size'] = size;
return formatOnlineresource;
}
return undefined;
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Authority URL object.
*/
function readAuthorityURL(node, objectStack) {
var authorityObject = readFormatOnlineresource(node, objectStack);
if (authorityObject) {
authorityObject['name'] = node.getAttribute('name');
return authorityObject;
}
return undefined;
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Metadata URL object.
*/
function readMetadataURL(node, objectStack) {
var metadataObject = readFormatOnlineresource(node, objectStack);
if (metadataObject) {
metadataObject['type'] = node.getAttribute('type');
return metadataObject;
}
return undefined;
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Style object.
*/
function readStyle(node, objectStack) {
return pushParseAndPop({}, STYLE_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Array<string>|undefined} Keyword list.
*/
function readKeywordList(node, objectStack) {
return pushParseAndPop([], KEYWORDLIST_PARSERS, node, objectStack);
}
export default WMSCapabilities;
//# sourceMappingURL=WMSCapabilities.js.map
File diff suppressed because one or more lines are too long
+52
View File
@@ -0,0 +1,52 @@
export default WMSGetFeatureInfo;
export type Options = {
/**
* If set, only features of the given layers will be returned by the format when read.
*/
layers?: string[] | undefined;
};
/**
* @classdesc
* Format for reading WMSGetFeatureInfo format. It uses
* {@link module:ol/format/GML2~GML2} to read features.
*
* @api
*/
declare class WMSGetFeatureInfo extends XMLFeature {
/**
* @param {Options} [opt_options] Options.
*/
constructor(opt_options?: Options | undefined);
/**
* @private
* @type {string}
*/
private featureNS_;
/**
* @private
* @type {GML2}
*/
private gmlFormat_;
/**
* @private
* @type {Array<string>|null}
*/
private layers_;
/**
* @return {Array<string>|null} layers
*/
getLayers(): Array<string> | null;
/**
* @param {Array<string>|null} layers Layers to parse.
*/
setLayers(layers: Array<string> | null): void;
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Array<import("../Feature.js").default>} Features.
* @private
*/
private readFeatures_;
}
import XMLFeature from "./XMLFeature.js";
//# sourceMappingURL=WMSGetFeatureInfo.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"WMSGetFeatureInfo.d.ts","sourceRoot":"","sources":["../src/format/WMSGetFeatureInfo.js"],"names":[],"mappings":";;;;;;;AA0BA;;;;;;GAMG;AACH;IACE;;OAEG;IACH,+CAsBC;IAjBC;;;OAGG;IACH,mBAA0D;IAE1D;;;OAGG;IACH,mBAA4B;IAE5B;;;OAGG;IACH,gBAAqD;IAGvD;;OAEG;IACH,aAFY,MAAM,MAAM,CAAC,GAAC,IAAI,CAI7B;IAED;;OAEG;IACH,kBAFW,MAAM,MAAM,CAAC,GAAC,IAAI,QAI5B;IAED;;;;;OAKG;IACH,sBAmEC;CAeF"}
+149
View File
@@ -0,0 +1,149 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/format/WMSGetFeatureInfo
*/
import GML2 from './GML2.js';
import XMLFeature from './XMLFeature.js';
import { assign } from '../obj.js';
import { extend, includes } from '../array.js';
import { makeArrayPusher, makeStructureNS, pushParseAndPop } from '../xml.js';
/**
* @typedef {Object} Options
* @property {Array<string>} [layers] If set, only features of the given layers will be returned by the format when read.
*/
/**
* @const
* @type {string}
*/
var featureIdentifier = '_feature';
/**
* @const
* @type {string}
*/
var layerIdentifier = '_layer';
/**
* @classdesc
* Format for reading WMSGetFeatureInfo format. It uses
* {@link module:ol/format/GML2~GML2} to read features.
*
* @api
*/
var WMSGetFeatureInfo = /** @class */ (function (_super) {
__extends(WMSGetFeatureInfo, _super);
/**
* @param {Options} [opt_options] Options.
*/
function WMSGetFeatureInfo(opt_options) {
var _this = _super.call(this) || this;
var options = opt_options ? opt_options : {};
/**
* @private
* @type {string}
*/
_this.featureNS_ = 'http://mapserver.gis.umn.edu/mapserver';
/**
* @private
* @type {GML2}
*/
_this.gmlFormat_ = new GML2();
/**
* @private
* @type {Array<string>|null}
*/
_this.layers_ = options.layers ? options.layers : null;
return _this;
}
/**
* @return {Array<string>|null} layers
*/
WMSGetFeatureInfo.prototype.getLayers = function () {
return this.layers_;
};
/**
* @param {Array<string>|null} layers Layers to parse.
*/
WMSGetFeatureInfo.prototype.setLayers = function (layers) {
this.layers_ = layers;
};
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Array<import("../Feature.js").default>} Features.
* @private
*/
WMSGetFeatureInfo.prototype.readFeatures_ = function (node, objectStack) {
node.setAttribute('namespaceURI', this.featureNS_);
var localName = node.localName;
/** @type {Array<import("../Feature.js").default>} */
var features = [];
if (node.childNodes.length === 0) {
return features;
}
if (localName == 'msGMLOutput') {
for (var i = 0, ii = node.childNodes.length; i < ii; i++) {
var layer = node.childNodes[i];
if (layer.nodeType !== Node.ELEMENT_NODE) {
continue;
}
var layerElement = /** @type {Element} */ (layer);
var context = objectStack[0];
var toRemove = layerIdentifier;
var layerName = layerElement.localName.replace(toRemove, '');
if (this.layers_ && !includes(this.layers_, layerName)) {
continue;
}
var featureType = layerName + featureIdentifier;
context['featureType'] = featureType;
context['featureNS'] = this.featureNS_;
/** @type {Object<string, import("../xml.js").Parser>} */
var parsers = {};
parsers[featureType] = makeArrayPusher(this.gmlFormat_.readFeatureElement, this.gmlFormat_);
var parsersNS = makeStructureNS([context['featureNS'], null], parsers);
layerElement.setAttribute('namespaceURI', this.featureNS_);
var layerFeatures = pushParseAndPop([],
// @ts-ignore
parsersNS, layerElement, objectStack, this.gmlFormat_);
if (layerFeatures) {
extend(features, layerFeatures);
}
}
}
if (localName == 'FeatureCollection') {
var gmlFeatures = pushParseAndPop([], this.gmlFormat_.FEATURE_COLLECTION_PARSERS, node, [{}], this.gmlFormat_);
if (gmlFeatures) {
features = gmlFeatures;
}
}
return features;
};
/**
* @protected
* @param {Element} node Node.
* @param {import("./Feature.js").ReadOptions} [opt_options] Options.
* @return {Array<import("../Feature.js").default>} Features.
*/
WMSGetFeatureInfo.prototype.readFeaturesFromNode = function (node, opt_options) {
var options = {};
if (opt_options) {
assign(options, this.getReadOptions(node, opt_options));
}
return this.readFeatures_(node, [options]);
};
return WMSGetFeatureInfo;
}(XMLFeature));
export default WMSGetFeatureInfo;
//# sourceMappingURL=WMSGetFeatureInfo.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"WMSGetFeatureInfo.js","sourceRoot":"","sources":["../src/format/WMSGetFeatureInfo.js"],"names":[],"mappings":"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"}
+16
View File
@@ -0,0 +1,16 @@
export default WMTSCapabilities;
/**
* @classdesc
* Format for reading WMTS capabilities data.
*
* @api
*/
declare class WMTSCapabilities extends XML {
/**
* @type {OWS}
* @private
*/
private owsParser_;
}
import XML from "./XML.js";
//# sourceMappingURL=WMTSCapabilities.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"WMTSCapabilities.d.ts","sourceRoot":"","sources":["../src/format/WMTSCapabilities.js"],"names":[],"mappings":";AAqCA;;;;;GAKG;AACH;IAII;;;OAGG;IACH,mBAA2B;CAyB9B"}
+333
View File
@@ -0,0 +1,333 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/format/WMTSCapabilities
*/
import OWS from './OWS.js';
import XML from './XML.js';
import { boundingExtent } from '../extent.js';
import { makeArrayPusher, makeObjectPropertyPusher, makeObjectPropertySetter, makeStructureNS, pushParseAndPop, } from '../xml.js';
import { readDecimal, readPositiveInteger, readString } from './xsd.js';
import { readHref } from './xlink.js';
/**
* @const
* @type {Array<null|string>}
*/
var NAMESPACE_URIS = [null, 'http://www.opengis.net/wmts/1.0'];
/**
* @const
* @type {Array<null|string>}
*/
var OWS_NAMESPACE_URIS = [null, 'http://www.opengis.net/ows/1.1'];
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Contents': makeObjectPropertySetter(readContents),
});
/**
* @classdesc
* Format for reading WMTS capabilities data.
*
* @api
*/
var WMTSCapabilities = /** @class */ (function (_super) {
__extends(WMTSCapabilities, _super);
function WMTSCapabilities() {
var _this = _super.call(this) || this;
/**
* @type {OWS}
* @private
*/
_this.owsParser_ = new OWS();
return _this;
}
/**
* @param {Element} node Node.
* @return {Object} Object
*/
WMTSCapabilities.prototype.readFromNode = function (node) {
var version = node.getAttribute('version');
if (version) {
version = version.trim();
}
var WMTSCapabilityObject = this.owsParser_.readFromNode(node);
if (!WMTSCapabilityObject) {
return null;
}
WMTSCapabilityObject['version'] = version;
WMTSCapabilityObject = pushParseAndPop(WMTSCapabilityObject, PARSERS, node, []);
return WMTSCapabilityObject ? WMTSCapabilityObject : null;
};
return WMTSCapabilities;
}(XML));
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var CONTENTS_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Layer': makeObjectPropertyPusher(readLayer),
'TileMatrixSet': makeObjectPropertyPusher(readTileMatrixSet),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var LAYER_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Style': makeObjectPropertyPusher(readStyle),
'Format': makeObjectPropertyPusher(readString),
'TileMatrixSetLink': makeObjectPropertyPusher(readTileMatrixSetLink),
'Dimension': makeObjectPropertyPusher(readDimensions),
'ResourceURL': makeObjectPropertyPusher(readResourceUrl),
}, makeStructureNS(OWS_NAMESPACE_URIS, {
'Title': makeObjectPropertySetter(readString),
'Abstract': makeObjectPropertySetter(readString),
'WGS84BoundingBox': makeObjectPropertySetter(readBoundingBox),
'Identifier': makeObjectPropertySetter(readString),
}));
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var STYLE_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'LegendURL': makeObjectPropertyPusher(readLegendUrl),
}, makeStructureNS(OWS_NAMESPACE_URIS, {
'Title': makeObjectPropertySetter(readString),
'Identifier': makeObjectPropertySetter(readString),
}));
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var TMS_LINKS_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'TileMatrixSet': makeObjectPropertySetter(readString),
'TileMatrixSetLimits': makeObjectPropertySetter(readTileMatrixLimitsList),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var TMS_LIMITS_LIST_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'TileMatrixLimits': makeArrayPusher(readTileMatrixLimits),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var TMS_LIMITS_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'TileMatrix': makeObjectPropertySetter(readString),
'MinTileRow': makeObjectPropertySetter(readPositiveInteger),
'MaxTileRow': makeObjectPropertySetter(readPositiveInteger),
'MinTileCol': makeObjectPropertySetter(readPositiveInteger),
'MaxTileCol': makeObjectPropertySetter(readPositiveInteger),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var DIMENSION_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'Default': makeObjectPropertySetter(readString),
'Value': makeObjectPropertyPusher(readString),
}, makeStructureNS(OWS_NAMESPACE_URIS, {
'Identifier': makeObjectPropertySetter(readString),
}));
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var WGS84_BBOX_READERS = makeStructureNS(OWS_NAMESPACE_URIS, {
'LowerCorner': makeArrayPusher(readCoordinates),
'UpperCorner': makeArrayPusher(readCoordinates),
});
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var TMS_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'WellKnownScaleSet': makeObjectPropertySetter(readString),
'TileMatrix': makeObjectPropertyPusher(readTileMatrix),
}, makeStructureNS(OWS_NAMESPACE_URIS, {
'SupportedCRS': makeObjectPropertySetter(readString),
'Identifier': makeObjectPropertySetter(readString),
'BoundingBox': makeObjectPropertySetter(readBoundingBox),
}));
/**
* @const
* @type {Object<string, Object<string, import("../xml.js").Parser>>}
*/
// @ts-ignore
var TM_PARSERS = makeStructureNS(NAMESPACE_URIS, {
'TopLeftCorner': makeObjectPropertySetter(readCoordinates),
'ScaleDenominator': makeObjectPropertySetter(readDecimal),
'TileWidth': makeObjectPropertySetter(readPositiveInteger),
'TileHeight': makeObjectPropertySetter(readPositiveInteger),
'MatrixWidth': makeObjectPropertySetter(readPositiveInteger),
'MatrixHeight': makeObjectPropertySetter(readPositiveInteger),
}, makeStructureNS(OWS_NAMESPACE_URIS, {
'Identifier': makeObjectPropertySetter(readString),
}));
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Attribution object.
*/
function readContents(node, objectStack) {
return pushParseAndPop({}, CONTENTS_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Layers object.
*/
function readLayer(node, objectStack) {
return pushParseAndPop({}, LAYER_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Tile Matrix Set object.
*/
function readTileMatrixSet(node, objectStack) {
return pushParseAndPop({}, TMS_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Style object.
*/
function readStyle(node, objectStack) {
var style = pushParseAndPop({}, STYLE_PARSERS, node, objectStack);
if (!style) {
return undefined;
}
var isDefault = node.getAttribute('isDefault') === 'true';
style['isDefault'] = isDefault;
return style;
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Tile Matrix Set Link object.
*/
function readTileMatrixSetLink(node, objectStack) {
return pushParseAndPop({}, TMS_LINKS_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Dimension object.
*/
function readDimensions(node, objectStack) {
return pushParseAndPop({}, DIMENSION_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Resource URL object.
*/
function readResourceUrl(node, objectStack) {
var format = node.getAttribute('format');
var template = node.getAttribute('template');
var resourceType = node.getAttribute('resourceType');
var resource = {};
if (format) {
resource['format'] = format;
}
if (template) {
resource['template'] = template;
}
if (resourceType) {
resource['resourceType'] = resourceType;
}
return resource;
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} BBox object.
*/
function readBoundingBox(node, objectStack) {
var coordinates = pushParseAndPop([], WGS84_BBOX_READERS, node, objectStack);
if (coordinates.length != 2) {
return undefined;
}
return boundingExtent(coordinates);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Legend object.
*/
function readLegendUrl(node, objectStack) {
var legend = {};
legend['format'] = node.getAttribute('format');
legend['href'] = readHref(node);
return legend;
}
/**
* @param {Node} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} Coordinates object.
*/
function readCoordinates(node, objectStack) {
var coordinates = readString(node).split(/\s+/);
if (!coordinates || coordinates.length != 2) {
return undefined;
}
var x = +coordinates[0];
var y = +coordinates[1];
if (isNaN(x) || isNaN(y)) {
return undefined;
}
return [x, y];
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} TileMatrix object.
*/
function readTileMatrix(node, objectStack) {
return pushParseAndPop({}, TM_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} TileMatrixSetLimits Object.
*/
function readTileMatrixLimitsList(node, objectStack) {
return pushParseAndPop([], TMS_LIMITS_LIST_PARSERS, node, objectStack);
}
/**
* @param {Element} node Node.
* @param {Array<*>} objectStack Object stack.
* @return {Object|undefined} TileMatrixLimits Array.
*/
function readTileMatrixLimits(node, objectStack) {
return pushParseAndPop({}, TMS_LIMITS_PARSERS, node, objectStack);
}
export default WMTSCapabilities;
//# sourceMappingURL=WMTSCapabilities.js.map
File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More