Use blocked scoped variables

In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
This commit is contained in:
Tim Schaub
2018-01-11 23:32:36 -07:00
parent 0bf2b04dee
commit ad62739a6e
684 changed files with 18120 additions and 18184 deletions
+71 -71
View File
@@ -30,9 +30,9 @@ import {get as getProjection} from '../proj.js';
* @param {olx.format.EsriJSONOptions=} opt_options Options.
* @api
*/
var EsriJSON = function(opt_options) {
const EsriJSON = function(opt_options) {
var options = opt_options ? opt_options : {};
const options = opt_options ? opt_options : {};
JSONFeature.call(this);
@@ -59,7 +59,7 @@ EsriJSON.readGeometry_ = function(object, opt_options) {
return null;
}
/** @type {ol.geom.GeometryType} */
var type;
let type;
if (typeof object.x === 'number' && typeof object.y === 'number') {
type = GeometryType.POINT;
} else if (object.points) {
@@ -71,8 +71,8 @@ EsriJSON.readGeometry_ = function(object, opt_options) {
type = GeometryType.MULTI_LINE_STRING;
}
} else if (object.rings) {
var layout = EsriJSON.getGeometryLayout_(object);
var rings = EsriJSON.convertRings_(object.rings, layout);
const layout = EsriJSON.getGeometryLayout_(object);
const rings = EsriJSON.convertRings_(object.rings, layout);
object = /** @type {EsriJSONGeometry} */(_ol_obj_.assign({}, object));
if (rings.length === 1) {
type = GeometryType.POLYGON;
@@ -82,10 +82,10 @@ EsriJSON.readGeometry_ = function(object, opt_options) {
object.rings = rings;
}
}
var geometryReader = EsriJSON.GEOMETRY_READERS_[type];
const geometryReader = EsriJSON.GEOMETRY_READERS_[type];
return (
/** @type {ol.geom.Geometry} */ transformWithOptions(
geometryReader(object), false, opt_options)
geometryReader(object), false, opt_options)
);
};
@@ -101,16 +101,16 @@ EsriJSON.readGeometry_ = function(object, opt_options) {
* @return {Array.<!Array.<!Array.<number>>>} Transformed rings.
*/
EsriJSON.convertRings_ = function(rings, layout) {
var flatRing = [];
var outerRings = [];
var holes = [];
var i, ii;
const flatRing = [];
const outerRings = [];
const holes = [];
let i, ii;
for (i = 0, ii = rings.length; i < ii; ++i) {
flatRing.length = 0;
_ol_geom_flat_deflate_.coordinates(flatRing, 0, rings[i], layout.length);
// is this ring an outer ring? is it clockwise?
var clockwise = _ol_geom_flat_orient_.linearRingIsClockwise(flatRing, 0,
flatRing.length, layout.length);
const clockwise = _ol_geom_flat_orient_.linearRingIsClockwise(flatRing, 0,
flatRing.length, layout.length);
if (clockwise) {
outerRings.push([rings[i]]);
} else {
@@ -118,14 +118,14 @@ EsriJSON.convertRings_ = function(rings, layout) {
}
}
while (holes.length) {
var hole = holes.shift();
var matched = false;
const hole = holes.shift();
let 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()
const outerRing = outerRings[i][0];
const containsHole = containsExtent(
new LinearRing(outerRing).getExtent(),
new LinearRing(hole).getExtent()
);
if (containsHole) {
// the hole is contained push it into our polygon
@@ -150,16 +150,16 @@ EsriJSON.convertRings_ = function(rings, layout) {
* @return {ol.geom.Geometry} Point.
*/
EsriJSON.readPointGeometry_ = function(object) {
var point;
let point;
if (object.m !== undefined && object.z !== undefined) {
point = new Point([object.x, object.y, object.z, object.m],
GeometryLayout.XYZM);
GeometryLayout.XYZM);
} else if (object.z !== undefined) {
point = new Point([object.x, object.y, object.z],
GeometryLayout.XYZ);
GeometryLayout.XYZ);
} else if (object.m !== undefined) {
point = new Point([object.x, object.y, object.m],
GeometryLayout.XYM);
GeometryLayout.XYM);
} else {
point = new Point([object.x, object.y]);
}
@@ -173,7 +173,7 @@ EsriJSON.readPointGeometry_ = function(object) {
* @return {ol.geom.Geometry} LineString.
*/
EsriJSON.readLineStringGeometry_ = function(object) {
var layout = EsriJSON.getGeometryLayout_(object);
const layout = EsriJSON.getGeometryLayout_(object);
return new LineString(object.paths[0], layout);
};
@@ -184,7 +184,7 @@ EsriJSON.readLineStringGeometry_ = function(object) {
* @return {ol.geom.Geometry} MultiLineString.
*/
EsriJSON.readMultiLineStringGeometry_ = function(object) {
var layout = EsriJSON.getGeometryLayout_(object);
const layout = EsriJSON.getGeometryLayout_(object);
return new MultiLineString(object.paths, layout);
};
@@ -195,7 +195,7 @@ EsriJSON.readMultiLineStringGeometry_ = function(object) {
* @return {ol.geom.GeometryLayout} The geometry layout to use.
*/
EsriJSON.getGeometryLayout_ = function(object) {
var layout = GeometryLayout.XY;
let layout = GeometryLayout.XY;
if (object.hasZ === true && object.hasM === true) {
layout = GeometryLayout.XYZM;
} else if (object.hasZ === true) {
@@ -213,7 +213,7 @@ EsriJSON.getGeometryLayout_ = function(object) {
* @return {ol.geom.Geometry} MultiPoint.
*/
EsriJSON.readMultiPointGeometry_ = function(object) {
var layout = EsriJSON.getGeometryLayout_(object);
const layout = EsriJSON.getGeometryLayout_(object);
return new MultiPoint(object.points, layout);
};
@@ -224,10 +224,10 @@ EsriJSON.readMultiPointGeometry_ = function(object) {
* @return {ol.geom.Geometry} MultiPolygon.
*/
EsriJSON.readMultiPolygonGeometry_ = function(object) {
var layout = EsriJSON.getGeometryLayout_(object);
const layout = EsriJSON.getGeometryLayout_(object);
return new MultiPolygon(
/** @type {Array.<Array.<Array.<Array.<number>>>>} */(object.rings),
layout);
/** @type {Array.<Array.<Array.<Array.<number>>>>} */(object.rings),
layout);
};
@@ -237,7 +237,7 @@ EsriJSON.readMultiPolygonGeometry_ = function(object) {
* @return {ol.geom.Geometry} Polygon.
*/
EsriJSON.readPolygonGeometry_ = function(object) {
var layout = EsriJSON.getGeometryLayout_(object);
const layout = EsriJSON.getGeometryLayout_(object);
return new Polygon(object.rings, layout);
};
@@ -249,9 +249,9 @@ EsriJSON.readPolygonGeometry_ = function(object) {
* @return {EsriJSONGeometry} EsriJSON geometry.
*/
EsriJSON.writePointGeometry_ = function(geometry, opt_options) {
var coordinates = /** @type {ol.geom.Point} */ (geometry).getCoordinates();
var esriJSON;
var layout = /** @type {ol.geom.Point} */ (geometry).getLayout();
const coordinates = /** @type {ol.geom.Point} */ (geometry).getCoordinates();
let esriJSON;
const layout = /** @type {ol.geom.Point} */ (geometry).getLayout();
if (layout === GeometryLayout.XYZ) {
esriJSON = /** @type {EsriJSONPoint} */ ({
x: coordinates[0],
@@ -289,7 +289,7 @@ EsriJSON.writePointGeometry_ = function(geometry, opt_options) {
* @return {Object} Object with boolean hasZ and hasM keys.
*/
EsriJSON.getHasZM_ = function(geometry) {
var layout = geometry.getLayout();
const layout = geometry.getLayout();
return {
hasZ: (layout === GeometryLayout.XYZ ||
layout === GeometryLayout.XYZM),
@@ -306,7 +306,7 @@ EsriJSON.getHasZM_ = function(geometry) {
* @return {EsriJSONPolyline} EsriJSON geometry.
*/
EsriJSON.writeLineStringGeometry_ = function(geometry, opt_options) {
var hasZM = EsriJSON.getHasZM_(/** @type {ol.geom.LineString} */(geometry));
const hasZM = EsriJSON.getHasZM_(/** @type {ol.geom.LineString} */(geometry));
return /** @type {EsriJSONPolyline} */ ({
hasZ: hasZM.hasZ,
hasM: hasZM.hasM,
@@ -325,7 +325,7 @@ EsriJSON.writeLineStringGeometry_ = function(geometry, opt_options) {
*/
EsriJSON.writePolygonGeometry_ = function(geometry, opt_options) {
// Esri geometries use the left-hand rule
var hasZM = EsriJSON.getHasZM_(/** @type {ol.geom.Polygon} */(geometry));
const hasZM = EsriJSON.getHasZM_(/** @type {ol.geom.Polygon} */(geometry));
return /** @type {EsriJSONPolygon} */ ({
hasZ: hasZM.hasZ,
hasM: hasZM.hasM,
@@ -341,7 +341,7 @@ EsriJSON.writePolygonGeometry_ = function(geometry, opt_options) {
* @return {EsriJSONPolyline} EsriJSON geometry.
*/
EsriJSON.writeMultiLineStringGeometry_ = function(geometry, opt_options) {
var hasZM = EsriJSON.getHasZM_(/** @type {ol.geom.MultiLineString} */(geometry));
const hasZM = EsriJSON.getHasZM_(/** @type {ol.geom.MultiLineString} */(geometry));
return /** @type {EsriJSONPolyline} */ ({
hasZ: hasZM.hasZ,
hasM: hasZM.hasM,
@@ -357,7 +357,7 @@ EsriJSON.writeMultiLineStringGeometry_ = function(geometry, opt_options) {
* @return {EsriJSONMultipoint} EsriJSON geometry.
*/
EsriJSON.writeMultiPointGeometry_ = function(geometry, opt_options) {
var hasZM = EsriJSON.getHasZM_(/** @type {ol.geom.MultiPoint} */(geometry));
const hasZM = EsriJSON.getHasZM_(/** @type {ol.geom.MultiPoint} */(geometry));
return /** @type {EsriJSONMultipoint} */ ({
hasZ: hasZM.hasZ,
hasM: hasZM.hasM,
@@ -373,12 +373,12 @@ EsriJSON.writeMultiPointGeometry_ = function(geometry, opt_options) {
* @return {EsriJSONPolygon} EsriJSON geometry.
*/
EsriJSON.writeMultiPolygonGeometry_ = function(geometry,
opt_options) {
var hasZM = EsriJSON.getHasZM_(/** @type {ol.geom.MultiPolygon} */(geometry));
var coordinates = /** @type {ol.geom.MultiPolygon} */ (geometry).getCoordinates(false);
var output = [];
for (var i = 0; i < coordinates.length; i++) {
for (var x = coordinates[i].length - 1; x >= 0; x--) {
opt_options) {
const hasZM = EsriJSON.getHasZM_(/** @type {ol.geom.MultiPolygon} */(geometry));
const coordinates = /** @type {ol.geom.MultiPolygon} */ (geometry).getCoordinates(false);
const output = [];
for (let i = 0; i < coordinates.length; i++) {
for (let x = coordinates[i].length - 1; x >= 0; x--) {
output.push(coordinates[i][x]);
}
}
@@ -460,11 +460,11 @@ EsriJSON.prototype.readFeatures;
* @inheritDoc
*/
EsriJSON.prototype.readFeatureFromObject = function(
object, opt_options) {
var esriJSONFeature = /** @type {EsriJSONFeature} */ (object);
var geometry = EsriJSON.readGeometry_(esriJSONFeature.geometry,
opt_options);
var feature = new Feature();
object, opt_options) {
const esriJSONFeature = /** @type {EsriJSONFeature} */ (object);
const geometry = EsriJSON.readGeometry_(esriJSONFeature.geometry,
opt_options);
const feature = new Feature();
if (this.geometryName_) {
feature.setGeometryName(this.geometryName_);
}
@@ -485,20 +485,20 @@ EsriJSON.prototype.readFeatureFromObject = function(
* @inheritDoc
*/
EsriJSON.prototype.readFeaturesFromObject = function(
object, opt_options) {
var esriJSONObject = /** @type {EsriJSONObject} */ (object);
var options = opt_options ? opt_options : {};
object, opt_options) {
const esriJSONObject = /** @type {EsriJSONObject} */ (object);
const options = opt_options ? opt_options : {};
if (esriJSONObject.features) {
var esriJSONFeatureCollection = /** @type {EsriJSONFeatureCollection} */
const esriJSONFeatureCollection = /** @type {EsriJSONFeatureCollection} */
(object);
/** @type {Array.<ol.Feature>} */
var features = [];
var esriJSONFeatures = esriJSONFeatureCollection.features;
var i, ii;
const features = [];
const esriJSONFeatures = esriJSONFeatureCollection.features;
let i, ii;
options.idField = object.objectIdFieldName;
for (i = 0, ii = esriJSONFeatures.length; i < ii; ++i) {
features.push(this.readFeatureFromObject(esriJSONFeatures[i],
options));
options));
}
return features;
} else {
@@ -523,9 +523,9 @@ EsriJSON.prototype.readGeometry;
* @inheritDoc
*/
EsriJSON.prototype.readGeometryFromObject = function(
object, opt_options) {
object, opt_options) {
return EsriJSON.readGeometry_(
/** @type {EsriJSONGeometry} */(object), opt_options);
/** @type {EsriJSONGeometry} */(object), opt_options);
};
@@ -544,9 +544,9 @@ EsriJSON.prototype.readProjection;
* @inheritDoc
*/
EsriJSON.prototype.readProjectionFromObject = function(object) {
var esriJSONObject = /** @type {EsriJSONObject} */ (object);
const esriJSONObject = /** @type {EsriJSONObject} */ (object);
if (esriJSONObject.spatialReference && esriJSONObject.spatialReference.wkid) {
var crs = esriJSONObject.spatialReference.wkid;
const crs = esriJSONObject.spatialReference.wkid;
return getProjection('EPSG:' + crs);
} else {
return null;
@@ -561,7 +561,7 @@ EsriJSON.prototype.readProjectionFromObject = function(object) {
* @return {EsriJSONGeometry} EsriJSON geometry.
*/
EsriJSON.writeGeometry_ = function(geometry, opt_options) {
var geometryWriter = EsriJSON.GEOMETRY_WRITERS_[geometry.getType()];
const geometryWriter = EsriJSON.GEOMETRY_WRITERS_[geometry.getType()];
return geometryWriter(/** @type {ol.geom.Geometry} */(
transformWithOptions(geometry, true, opt_options)), opt_options);
};
@@ -589,9 +589,9 @@ EsriJSON.prototype.writeGeometry;
* @api
*/
EsriJSON.prototype.writeGeometryObject = function(geometry,
opt_options) {
opt_options) {
return EsriJSON.writeGeometry_(geometry,
this.adaptOptions(opt_options));
this.adaptOptions(opt_options));
};
@@ -617,10 +617,10 @@ EsriJSON.prototype.writeFeature;
* @api
*/
EsriJSON.prototype.writeFeatureObject = function(
feature, opt_options) {
feature, opt_options) {
opt_options = this.adaptOptions(opt_options);
var object = {};
var geometry = feature.getGeometry();
const object = {};
const geometry = feature.getGeometry();
if (geometry) {
object['geometry'] =
EsriJSON.writeGeometry_(geometry, opt_options);
@@ -630,7 +630,7 @@ EsriJSON.prototype.writeFeatureObject = function(
});
}
}
var properties = feature.getProperties();
const properties = feature.getProperties();
delete properties[feature.getGeometryName()];
if (!_ol_obj_.isEmpty(properties)) {
object['attributes'] = properties;
@@ -664,8 +664,8 @@ EsriJSON.prototype.writeFeatures;
*/
EsriJSON.prototype.writeFeaturesObject = function(features, opt_options) {
opt_options = this.adaptOptions(opt_options);
var objects = [];
var i, ii;
const objects = [];
let i, ii;
for (i = 0, ii = features.length; i < ii; ++i) {
objects.push(this.writeFeatureObject(features[i], opt_options));
}
+13 -13
View File
@@ -18,7 +18,7 @@ import {get as getProjection, equivalent as equivalentProjection, transformExten
* @abstract
* @api
*/
var FeatureFormat = function() {
const FeatureFormat = function() {
/**
* @protected
@@ -43,7 +43,7 @@ var FeatureFormat = function() {
* @protected
*/
FeatureFormat.prototype.getReadOptions = function(source, opt_options) {
var options;
let options;
if (opt_options) {
options = {
dataProjection: opt_options.dataProjection ?
@@ -173,40 +173,40 @@ export default FeatureFormat;
* @return {ol.geom.Geometry|ol.Extent} Transformed geometry.
*/
export function transformWithOptions(geometry, write, opt_options) {
var featureProjection = opt_options ?
const featureProjection = opt_options ?
getProjection(opt_options.featureProjection) : null;
var dataProjection = opt_options ?
const dataProjection = opt_options ?
getProjection(opt_options.dataProjection) : null;
/**
* @type {ol.geom.Geometry|ol.Extent}
*/
var transformed;
let transformed;
if (featureProjection && dataProjection &&
!equivalentProjection(featureProjection, dataProjection)) {
if (geometry instanceof Geometry) {
transformed = (write ? geometry.clone() : geometry).transform(
write ? featureProjection : dataProjection,
write ? dataProjection : featureProjection);
write ? featureProjection : dataProjection,
write ? dataProjection : featureProjection);
} else {
// FIXME this is necessary because ol.format.GML treats extents
// as geometries
transformed = transformExtent(
geometry,
dataProjection,
featureProjection);
geometry,
dataProjection,
featureProjection);
}
} else {
transformed = geometry;
}
if (write && opt_options && opt_options.decimals !== undefined) {
var power = Math.pow(10, opt_options.decimals);
const power = Math.pow(10, 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) {
const transform = function(coordinates) {
for (let i = 0, ii = coordinates.length; i < ii; ++i) {
coordinates[i] = Math.round(coordinates[i] * power) / power;
}
return coordinates;
+1 -1
View File
@@ -15,7 +15,7 @@ import GML3 from '../format/GML3.js';
* @extends {ol.format.GMLBase}
* @api
*/
var _ol_format_GML_ = GML3;
const _ol_format_GML_ = GML3;
/**
+157 -156
View File
@@ -21,14 +21,14 @@ import _ol_xml_ from '../xml.js';
* @extends {ol.format.GMLBase}
* @api
*/
var GML2 = function(opt_options) {
var options = /** @type {olx.format.GMLOptions} */
const GML2 = function(opt_options) {
const options = /** @type {olx.format.GMLOptions} */
(opt_options ? opt_options : {});
GMLBase.call(this, options);
this.FEATURE_COLLECTION_PARSERS[GMLBase.GMLNS][
'featureMember'] =
'featureMember'] =
_ol_xml_.makeArrayPusher(GMLBase.prototype.readFeaturesInternal);
/**
@@ -58,21 +58,21 @@ GML2.schemaLocation_ = GMLBase.GMLNS +
* @return {Array.<number>|undefined} Flat coordinates.
*/
GML2.prototype.readFlatCoordinates_ = function(node, objectStack) {
var s = _ol_xml_.getAllTextContent(node, false).replace(/^\s*|\s*$/g, '');
var context = /** @type {ol.XmlNodeStackItem} */ (objectStack[0]);
var containerSrs = context['srsName'];
var axisOrientation = 'enu';
const s = _ol_xml_.getAllTextContent(node, false).replace(/^\s*|\s*$/g, '');
const context = /** @type {ol.XmlNodeStackItem} */ (objectStack[0]);
const containerSrs = context['srsName'];
let axisOrientation = 'enu';
if (containerSrs) {
var proj = getProjection(containerSrs);
const proj = getProjection(containerSrs);
if (proj) {
axisOrientation = proj.getAxisOrientation();
}
}
var coordsGroups = s.trim().split(/\s+/);
var x, y, z;
var flatCoordinates = [];
for (var i = 0, ii = coordsGroups.length; i < ii; i++) {
var coords = coordsGroups[i].split(/,+/);
const coordsGroups = s.trim().split(/\s+/);
let x, y, z;
const flatCoordinates = [];
for (let i = 0, ii = coordsGroups.length; i < ii; i++) {
const coords = coordsGroups[i].split(/,+/);
x = parseFloat(coords[0]);
y = parseFloat(coords[1]);
z = (coords.length === 3) ? parseFloat(coords[2]) : 0;
@@ -94,11 +94,11 @@ GML2.prototype.readFlatCoordinates_ = function(node, objectStack) {
*/
GML2.prototype.readBox_ = function(node, objectStack) {
/** @type {Array.<number>} */
var flatCoordinates = _ol_xml_.pushParseAndPop([null],
this.BOX_PARSERS_, node, objectStack, this);
const flatCoordinates = _ol_xml_.pushParseAndPop([null],
this.BOX_PARSERS_, node, objectStack, this);
return createOrUpdate(flatCoordinates[1][0],
flatCoordinates[1][1], flatCoordinates[1][3],
flatCoordinates[1][4]);
flatCoordinates[1][1], flatCoordinates[1][3],
flatCoordinates[1][4]);
};
@@ -109,10 +109,10 @@ GML2.prototype.readBox_ = function(node, objectStack) {
*/
GML2.prototype.innerBoundaryIsParser_ = function(node, objectStack) {
/** @type {Array.<number>|undefined} */
var flatLinearRing = _ol_xml_.pushParseAndPop(undefined,
this.RING_PARSERS, node, objectStack, this);
const flatLinearRing = _ol_xml_.pushParseAndPop(undefined,
this.RING_PARSERS, node, objectStack, this);
if (flatLinearRing) {
var flatLinearRings = /** @type {Array.<Array.<number>>} */
const flatLinearRings = /** @type {Array.<Array.<number>>} */
(objectStack[objectStack.length - 1]);
flatLinearRings.push(flatLinearRing);
}
@@ -126,10 +126,10 @@ GML2.prototype.innerBoundaryIsParser_ = function(node, objectStack) {
*/
GML2.prototype.outerBoundaryIsParser_ = function(node, objectStack) {
/** @type {Array.<number>|undefined} */
var flatLinearRing = _ol_xml_.pushParseAndPop(undefined,
this.RING_PARSERS, node, objectStack, this);
const flatLinearRing = _ol_xml_.pushParseAndPop(undefined,
this.RING_PARSERS, node, objectStack, this);
if (flatLinearRing) {
var flatLinearRings = /** @type {Array.<Array.<number>>} */
const flatLinearRings = /** @type {Array.<Array.<number>>} */
(objectStack[objectStack.length - 1]);
flatLinearRings[0] = flatLinearRing;
}
@@ -144,7 +144,7 @@ GML2.prototype.outerBoundaryIsParser_ = function(node, objectStack) {
GML2.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS_ = {
'http://www.opengis.net/gml': {
'coordinates': _ol_xml_.makeReplacer(
GML2.prototype.readFlatCoordinates_)
GML2.prototype.readFlatCoordinates_)
}
};
@@ -170,7 +170,7 @@ GML2.prototype.FLAT_LINEAR_RINGS_PARSERS_ = {
GML2.prototype.BOX_PARSERS_ = {
'http://www.opengis.net/gml': {
'coordinates': _ol_xml_.makeArrayPusher(
GML2.prototype.readFlatCoordinates_)
GML2.prototype.readFlatCoordinates_)
}
};
@@ -184,16 +184,16 @@ GML2.prototype.GEOMETRY_PARSERS_ = {
'http://www.opengis.net/gml': {
'Point': _ol_xml_.makeReplacer(GMLBase.prototype.readPoint),
'MultiPoint': _ol_xml_.makeReplacer(
GMLBase.prototype.readMultiPoint),
GMLBase.prototype.readMultiPoint),
'LineString': _ol_xml_.makeReplacer(
GMLBase.prototype.readLineString),
GMLBase.prototype.readLineString),
'MultiLineString': _ol_xml_.makeReplacer(
GMLBase.prototype.readMultiLineString),
GMLBase.prototype.readMultiLineString),
'LinearRing': _ol_xml_.makeReplacer(
GMLBase.prototype.readLinearRing),
GMLBase.prototype.readLinearRing),
'Polygon': _ol_xml_.makeReplacer(GMLBase.prototype.readPolygon),
'MultiPolygon': _ol_xml_.makeReplacer(
GMLBase.prototype.readMultiPolygon),
GMLBase.prototype.readMultiPolygon),
'Box': _ol_xml_.makeReplacer(GML2.prototype.readBox_)
}
};
@@ -208,11 +208,11 @@ GML2.prototype.GEOMETRY_PARSERS_ = {
* @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;
const context = objectStack[objectStack.length - 1];
const multiSurface = context['multiSurface'];
const surface = context['surface'];
const multiCurve = context['multiCurve'];
let nodeName;
if (!Array.isArray(value)) {
nodeName = /** @type {ol.geom.Geometry} */ (value).getType();
if (nodeName === 'MultiPolygon' && multiSurface === true) {
@@ -226,7 +226,7 @@ GML2.prototype.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, opt_nodeNam
nodeName = 'Envelope';
}
return _ol_xml_.createElementNS('http://www.opengis.net/gml',
nodeName);
nodeName);
};
@@ -236,44 +236,45 @@ GML2.prototype.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, opt_nodeNam
* @param {Array.<*>} objectStack Node stack.
*/
GML2.prototype.writeFeatureElement = function(node, feature, objectStack) {
var fid = feature.getId();
const fid = feature.getId();
if (fid) {
node.setAttribute('fid', fid);
}
var context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
var featureNS = context['featureNS'];
var geometryName = feature.getGeometryName();
const context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
const featureNS = context['featureNS'];
const geometryName = feature.getGeometryName();
if (!context.serializers) {
context.serializers = {};
context.serializers[featureNS] = {};
}
var properties = feature.getProperties();
var keys = [], values = [];
for (var key in properties) {
var value = properties[key];
const properties = feature.getProperties();
const keys = [];
const values = [];
for (const key in properties) {
const value = properties[key];
if (value !== null) {
keys.push(key);
values.push(value);
if (key == geometryName || value instanceof Geometry) {
if (!(key in context.serializers[featureNS])) {
context.serializers[featureNS][key] = _ol_xml_.makeChildAppender(
this.writeGeometryElement, this);
this.writeGeometryElement, this);
}
} else {
if (!(key in context.serializers[featureNS])) {
context.serializers[featureNS][key] = _ol_xml_.makeChildAppender(
XSD.writeStringTextNode);
XSD.writeStringTextNode);
}
}
}
}
var item = _ol_obj_.assign({}, context);
const item = _ol_obj_.assign({}, context);
item.node = node;
_ol_xml_.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */
(item), context.serializers,
_ol_xml_.makeSimpleNodeFactory(undefined, featureNS),
values,
objectStack, keys);
(item), context.serializers,
_ol_xml_.makeSimpleNodeFactory(undefined, featureNS),
values,
objectStack, keys);
};
@@ -283,14 +284,14 @@ GML2.prototype.writeFeatureElement = function(node, feature, objectStack) {
* @param {Array.<*>} objectStack Node stack.
*/
GML2.prototype.writeGeometryElement = function(node, geometry, objectStack) {
var context = /** @type {olx.format.WriteOptions} */ (objectStack[objectStack.length - 1]);
var item = _ol_obj_.assign({}, context);
const context = /** @type {olx.format.WriteOptions} */ (objectStack[objectStack.length - 1]);
const item = _ol_obj_.assign({}, context);
item.node = node;
var value;
let value;
if (Array.isArray(geometry)) {
if (context.dataProjection) {
value = transformExtent(
geometry, context.featureProjection, context.dataProjection);
geometry, context.featureProjection, context.dataProjection);
} else {
value = geometry;
}
@@ -298,9 +299,9 @@ GML2.prototype.writeGeometryElement = function(node, geometry, objectStack) {
value = transformWithOptions(/** @type {ol.geom.Geometry} */ (geometry), true, context);
}
_ol_xml_.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */
(item), GML2.GEOMETRY_SERIALIZERS_,
this.GEOMETRY_NODE_FACTORY_, [value],
objectStack, undefined, this);
(item), GML2.GEOMETRY_SERIALIZERS_,
this.GEOMETRY_NODE_FACTORY_, [value],
objectStack, undefined, this);
};
@@ -311,21 +312,21 @@ GML2.prototype.writeGeometryElement = function(node, geometry, objectStack) {
* @private
*/
GML2.prototype.writeCurveOrLineString_ = function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var srsName = context['srsName'];
const context = objectStack[objectStack.length - 1];
const srsName = context['srsName'];
if (node.nodeName !== 'LineStringSegment' && srsName) {
node.setAttribute('srsName', srsName);
}
if (node.nodeName === 'LineString' ||
node.nodeName === 'LineStringSegment') {
var coordinates = this.createCoordinatesNode_(node.namespaceURI);
const coordinates = this.createCoordinatesNode_(node.namespaceURI);
node.appendChild(coordinates);
this.writeCoordinates_(coordinates, geometry, objectStack);
} else if (node.nodeName === 'Curve') {
var segments = _ol_xml_.createElementNS(node.namespaceURI, 'segments');
const segments = _ol_xml_.createElementNS(node.namespaceURI, 'segments');
node.appendChild(segments);
this.writeCurveSegments_(segments,
geometry, objectStack);
geometry, objectStack);
}
};
@@ -336,7 +337,7 @@ GML2.prototype.writeCurveOrLineString_ = function(node, geometry, objectStack) {
* @private
*/
GML2.prototype.createCoordinatesNode_ = function(namespaceURI) {
var coordinates = _ol_xml_.createElementNS(namespaceURI, 'coordinates');
const coordinates = _ol_xml_.createElementNS(namespaceURI, 'coordinates');
coordinates.setAttribute('decimal', '.');
coordinates.setAttribute('cs', ',');
coordinates.setAttribute('ts', ' ');
@@ -352,15 +353,15 @@ GML2.prototype.createCoordinatesNode_ = function(namespaceURI) {
* @private
*/
GML2.prototype.writeCoordinates_ = function(node, value, objectStack) {
var context = objectStack[objectStack.length - 1];
var hasZ = context['hasZ'];
var srsName = context['srsName'];
const context = objectStack[objectStack.length - 1];
const hasZ = context['hasZ'];
const srsName = context['srsName'];
// only 2d for simple features profile
var points = value.getCoordinates();
var len = points.length;
var parts = new Array(len);
var point;
for (var i = 0; i < len; ++i) {
const points = value.getCoordinates();
const len = points.length;
const parts = new Array(len);
let point;
for (let i = 0; i < len; ++i) {
point = points[i];
parts[i] = this.getCoords_(point, srsName, hasZ);
}
@@ -375,8 +376,8 @@ GML2.prototype.writeCoordinates_ = function(node, value, objectStack) {
* @private
*/
GML2.prototype.writeCurveSegments_ = function(node, line, objectStack) {
var child = _ol_xml_.createElementNS(node.namespaceURI,
'LineStringSegment');
const child = _ol_xml_.createElementNS(node.namespaceURI,
'LineStringSegment');
node.appendChild(child);
this.writeCurveOrLineString_(child, line, objectStack);
};
@@ -389,24 +390,24 @@ GML2.prototype.writeCurveSegments_ = function(node, line, objectStack) {
* @private
*/
GML2.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var hasZ = context['hasZ'];
var srsName = context['srsName'];
const context = objectStack[objectStack.length - 1];
const hasZ = context['hasZ'];
const srsName = context['srsName'];
if (node.nodeName !== 'PolygonPatch' && srsName) {
node.setAttribute('srsName', srsName);
}
if (node.nodeName === 'Polygon' || node.nodeName === 'PolygonPatch') {
var rings = geometry.getLinearRings();
const rings = geometry.getLinearRings();
_ol_xml_.pushSerializeAndPop(
{node: node, hasZ: hasZ, srsName: srsName},
GML2.RING_SERIALIZERS_,
this.RING_NODE_FACTORY_,
rings, objectStack, undefined, this);
{node: node, hasZ: hasZ, srsName: srsName},
GML2.RING_SERIALIZERS_,
this.RING_NODE_FACTORY_,
rings, objectStack, undefined, this);
} else if (node.nodeName === 'Surface') {
var patches = _ol_xml_.createElementNS(node.namespaceURI, 'patches');
const patches = _ol_xml_.createElementNS(node.namespaceURI, 'patches');
node.appendChild(patches);
this.writeSurfacePatches_(
patches, geometry, objectStack);
patches, geometry, objectStack);
}
};
@@ -419,14 +420,14 @@ GML2.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objectStack) {
* @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'];
const context = objectStack[objectStack.length - 1];
const parentNode = context.node;
const exteriorWritten = context['exteriorWritten'];
if (exteriorWritten === undefined) {
context['exteriorWritten'] = true;
}
return _ol_xml_.createElementNS(parentNode.namespaceURI,
exteriorWritten !== undefined ? 'innerBoundaryIs' : 'outerBoundaryIs');
exteriorWritten !== undefined ? 'innerBoundaryIs' : 'outerBoundaryIs');
};
@@ -437,7 +438,7 @@ GML2.prototype.RING_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) {
* @private
*/
GML2.prototype.writeSurfacePatches_ = function(node, polygon, objectStack) {
var child = _ol_xml_.createElementNS(node.namespaceURI, 'PolygonPatch');
const child = _ol_xml_.createElementNS(node.namespaceURI, 'PolygonPatch');
node.appendChild(child);
this.writeSurfaceOrPolygon_(child, polygon, objectStack);
};
@@ -450,7 +451,7 @@ GML2.prototype.writeSurfacePatches_ = function(node, polygon, objectStack) {
* @private
*/
GML2.prototype.writeRing_ = function(node, ring, objectStack) {
var linearRing = _ol_xml_.createElementNS(node.namespaceURI, 'LinearRing');
const linearRing = _ol_xml_.createElementNS(node.namespaceURI, 'LinearRing');
node.appendChild(linearRing);
this.writeLinearRing_(linearRing, ring, objectStack);
};
@@ -464,16 +465,16 @@ GML2.prototype.writeRing_ = function(node, ring, objectStack) {
* @private
*/
GML2.prototype.getCoords_ = function(point, opt_srsName, opt_hasZ) {
var axisOrientation = 'enu';
let axisOrientation = 'enu';
if (opt_srsName) {
axisOrientation = getProjection(opt_srsName).getAxisOrientation();
}
var coords = ((axisOrientation.substr(0, 2) === 'en') ?
let 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;
const z = point[2] || 0;
coords += ',' + z;
}
@@ -488,18 +489,18 @@ GML2.prototype.getCoords_ = function(point, opt_srsName, opt_hasZ) {
* @private
*/
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'];
const context = objectStack[objectStack.length - 1];
const hasZ = context['hasZ'];
const srsName = context['srsName'];
const curve = context['curve'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var lines = geometry.getLineStrings();
const lines = geometry.getLineStrings();
_ol_xml_.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName, curve: curve},
GML2.LINESTRINGORCURVEMEMBER_SERIALIZERS_,
this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, lines,
objectStack, undefined, this);
GML2.LINESTRINGORCURVEMEMBER_SERIALIZERS_,
this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, lines,
objectStack, undefined, this);
};
@@ -510,16 +511,16 @@ GML2.prototype.writeMultiCurveOrLineString_ = function(node, geometry, objectSta
* @private
*/
GML2.prototype.writePoint_ = function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var hasZ = context['hasZ'];
var srsName = context['srsName'];
const context = objectStack[objectStack.length - 1];
const hasZ = context['hasZ'];
const srsName = context['srsName'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var coordinates = this.createCoordinatesNode_(node.namespaceURI);
const coordinates = this.createCoordinatesNode_(node.namespaceURI);
node.appendChild(coordinates);
var point = geometry.getCoordinates();
var coord = this.getCoords_(point, srsName, hasZ);
const point = geometry.getCoordinates();
const coord = this.getCoords_(point, srsName, hasZ);
XSD.writeStringTextNode(coordinates, coord);
};
@@ -531,18 +532,18 @@ GML2.prototype.writePoint_ = function(node, geometry, objectStack) {
* @private
*/
GML2.prototype.writeMultiPoint_ = function(node, geometry,
objectStack) {
var context = objectStack[objectStack.length - 1];
var hasZ = context['hasZ'];
var srsName = context['srsName'];
objectStack) {
const context = objectStack[objectStack.length - 1];
const hasZ = context['hasZ'];
const srsName = context['srsName'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var points = geometry.getPoints();
const points = geometry.getPoints();
_ol_xml_.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName},
GML2.POINTMEMBER_SERIALIZERS_,
_ol_xml_.makeSimpleNodeFactory('pointMember'), points,
objectStack, undefined, this);
GML2.POINTMEMBER_SERIALIZERS_,
_ol_xml_.makeSimpleNodeFactory('pointMember'), points,
objectStack, undefined, this);
};
@@ -553,7 +554,7 @@ GML2.prototype.writeMultiPoint_ = function(node, geometry,
* @private
*/
GML2.prototype.writePointMember_ = function(node, point, objectStack) {
var child = _ol_xml_.createElementNS(node.namespaceURI, 'Point');
const child = _ol_xml_.createElementNS(node.namespaceURI, 'Point');
node.appendChild(child);
this.writePoint_(child, point, objectStack);
};
@@ -566,7 +567,7 @@ GML2.prototype.writePointMember_ = function(node, point, objectStack) {
* @private
*/
GML2.prototype.writeLineStringOrCurveMember_ = function(node, line, objectStack) {
var child = this.GEOMETRY_NODE_FACTORY_(line, objectStack);
const child = this.GEOMETRY_NODE_FACTORY_(line, objectStack);
if (child) {
node.appendChild(child);
this.writeCurveOrLineString_(child, line, objectStack);
@@ -581,12 +582,12 @@ GML2.prototype.writeLineStringOrCurveMember_ = function(node, line, objectStack)
* @private
*/
GML2.prototype.writeLinearRing_ = function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var srsName = context['srsName'];
const context = objectStack[objectStack.length - 1];
const srsName = context['srsName'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var coordinates = this.createCoordinatesNode_(node.namespaceURI);
const coordinates = this.createCoordinatesNode_(node.namespaceURI);
node.appendChild(coordinates);
this.writeCoordinates_(coordinates, geometry, objectStack);
};
@@ -599,18 +600,18 @@ GML2.prototype.writeLinearRing_ = function(node, geometry, objectStack) {
* @private
*/
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'];
const context = objectStack[objectStack.length - 1];
const hasZ = context['hasZ'];
const srsName = context['srsName'];
const surface = context['surface'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var polygons = geometry.getPolygons();
const polygons = geometry.getPolygons();
_ol_xml_.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName, surface: surface},
GML2.SURFACEORPOLYGONMEMBER_SERIALIZERS_,
this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, polygons,
objectStack, undefined, this);
GML2.SURFACEORPOLYGONMEMBER_SERIALIZERS_,
this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, polygons,
objectStack, undefined, this);
};
@@ -621,8 +622,8 @@ GML2.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry, objectStac
* @private
*/
GML2.prototype.writeSurfaceOrPolygonMember_ = function(node, polygon, objectStack) {
var child = this.GEOMETRY_NODE_FACTORY_(
polygon, objectStack);
const child = this.GEOMETRY_NODE_FACTORY_(
polygon, objectStack);
if (child) {
node.appendChild(child);
this.writeSurfaceOrPolygon_(child, polygon, objectStack);
@@ -637,18 +638,18 @@ GML2.prototype.writeSurfaceOrPolygonMember_ = function(node, polygon, objectStac
* @private
*/
GML2.prototype.writeEnvelope = function(node, extent, objectStack) {
var context = objectStack[objectStack.length - 1];
var srsName = context['srsName'];
const context = objectStack[objectStack.length - 1];
const srsName = context['srsName'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var keys = ['lowerCorner', 'upperCorner'];
var values = [extent[0] + ' ' + extent[1], extent[2] + ' ' + extent[3]];
const keys = ['lowerCorner', 'upperCorner'];
const values = [extent[0] + ' ' + extent[1], extent[2] + ' ' + extent[3]];
_ol_xml_.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */
({node: node}), GML2.ENVELOPE_SERIALIZERS_,
_ol_xml_.OBJECT_PROPERTY_NODE_FACTORY,
values,
objectStack, keys, this);
({node: node}), GML2.ENVELOPE_SERIALIZERS_,
_ol_xml_.OBJECT_PROPERTY_NODE_FACTORY,
values,
objectStack, keys, this);
};
@@ -660,28 +661,28 @@ GML2.prototype.writeEnvelope = function(node, extent, objectStack) {
GML2.GEOMETRY_SERIALIZERS_ = {
'http://www.opengis.net/gml': {
'Curve': _ol_xml_.makeChildAppender(
GML2.prototype.writeCurveOrLineString_),
GML2.prototype.writeCurveOrLineString_),
'MultiCurve': _ol_xml_.makeChildAppender(
GML2.prototype.writeMultiCurveOrLineString_),
GML2.prototype.writeMultiCurveOrLineString_),
'Point': _ol_xml_.makeChildAppender(GML2.prototype.writePoint_),
'MultiPoint': _ol_xml_.makeChildAppender(
GML2.prototype.writeMultiPoint_),
GML2.prototype.writeMultiPoint_),
'LineString': _ol_xml_.makeChildAppender(
GML2.prototype.writeCurveOrLineString_),
GML2.prototype.writeCurveOrLineString_),
'MultiLineString': _ol_xml_.makeChildAppender(
GML2.prototype.writeMultiCurveOrLineString_),
GML2.prototype.writeMultiCurveOrLineString_),
'LinearRing': _ol_xml_.makeChildAppender(
GML2.prototype.writeLinearRing_),
GML2.prototype.writeLinearRing_),
'Polygon': _ol_xml_.makeChildAppender(
GML2.prototype.writeSurfaceOrPolygon_),
GML2.prototype.writeSurfaceOrPolygon_),
'MultiPolygon': _ol_xml_.makeChildAppender(
GML2.prototype.writeMultiSurfaceOrPolygon_),
GML2.prototype.writeMultiSurfaceOrPolygon_),
'Surface': _ol_xml_.makeChildAppender(
GML2.prototype.writeSurfaceOrPolygon_),
GML2.prototype.writeSurfaceOrPolygon_),
'MultiSurface': _ol_xml_.makeChildAppender(
GML2.prototype.writeMultiSurfaceOrPolygon_),
GML2.prototype.writeMultiSurfaceOrPolygon_),
'Envelope': _ol_xml_.makeChildAppender(
GML2.prototype.writeEnvelope)
GML2.prototype.writeEnvelope)
}
};
@@ -705,7 +706,7 @@ GML2.RING_SERIALIZERS_ = {
GML2.POINTMEMBER_SERIALIZERS_ = {
'http://www.opengis.net/gml': {
'pointMember': _ol_xml_.makeChildAppender(
GML2.prototype.writePointMember_)
GML2.prototype.writePointMember_)
}
};
@@ -717,9 +718,9 @@ GML2.POINTMEMBER_SERIALIZERS_ = {
GML2.LINESTRINGORCURVEMEMBER_SERIALIZERS_ = {
'http://www.opengis.net/gml': {
'lineStringMember': _ol_xml_.makeChildAppender(
GML2.prototype.writeLineStringOrCurveMember_),
GML2.prototype.writeLineStringOrCurveMember_),
'curveMember': _ol_xml_.makeChildAppender(
GML2.prototype.writeLineStringOrCurveMember_)
GML2.prototype.writeLineStringOrCurveMember_)
}
};
@@ -733,9 +734,9 @@ GML2.LINESTRINGORCURVEMEMBER_SERIALIZERS_ = {
* @private
*/
GML2.prototype.MULTIGEOMETRY_MEMBER_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) {
var parentNode = objectStack[objectStack.length - 1].node;
const parentNode = objectStack[objectStack.length - 1].node;
return _ol_xml_.createElementNS('http://www.opengis.net/gml',
GML2.MULTIGEOMETRY_TO_MEMBER_NODENAME_[parentNode.nodeName]);
GML2.MULTIGEOMETRY_TO_MEMBER_NODENAME_[parentNode.nodeName]);
};
/**
@@ -759,9 +760,9 @@ GML2.MULTIGEOMETRY_TO_MEMBER_NODENAME_ = {
GML2.SURFACEORPOLYGONMEMBER_SERIALIZERS_ = {
'http://www.opengis.net/gml': {
'surfaceMember': _ol_xml_.makeChildAppender(
GML2.prototype.writeSurfaceOrPolygonMember_),
GML2.prototype.writeSurfaceOrPolygonMember_),
'polygonMember': _ol_xml_.makeChildAppender(
GML2.prototype.writeSurfaceOrPolygonMember_)
GML2.prototype.writeSurfaceOrPolygonMember_)
}
};
+225 -224
View File
@@ -29,8 +29,8 @@ import _ol_xml_ from '../xml.js';
* @extends {ol.format.GMLBase}
* @api
*/
var GML3 = function(opt_options) {
var options = /** @type {olx.format.GMLOptions} */
const GML3 = function(opt_options) {
const options = /** @type {olx.format.GMLOptions} */
(opt_options ? opt_options : {});
GMLBase.call(this, options);
@@ -97,10 +97,10 @@ GML3.schemaLocation_ = GMLBase.GMLNS +
*/
GML3.prototype.readMultiCurve_ = function(node, objectStack) {
/** @type {Array.<ol.geom.LineString>} */
var lineStrings = _ol_xml_.pushParseAndPop([],
this.MULTICURVE_PARSERS_, node, objectStack, this);
const lineStrings = _ol_xml_.pushParseAndPop([],
this.MULTICURVE_PARSERS_, node, objectStack, this);
if (lineStrings) {
var multiLineString = new MultiLineString(null);
const multiLineString = new MultiLineString(null);
multiLineString.setLineStrings(lineStrings);
return multiLineString;
} else {
@@ -117,10 +117,10 @@ GML3.prototype.readMultiCurve_ = function(node, objectStack) {
*/
GML3.prototype.readMultiSurface_ = function(node, objectStack) {
/** @type {Array.<ol.geom.Polygon>} */
var polygons = _ol_xml_.pushParseAndPop([],
this.MULTISURFACE_PARSERS_, node, objectStack, this);
const polygons = _ol_xml_.pushParseAndPop([],
this.MULTISURFACE_PARSERS_, node, objectStack, this);
if (polygons) {
var multiPolygon = new MultiPolygon(null);
const multiPolygon = new MultiPolygon(null);
multiPolygon.setPolygons(polygons);
return multiPolygon;
} else {
@@ -146,7 +146,7 @@ GML3.prototype.curveMemberParser_ = function(node, objectStack) {
*/
GML3.prototype.surfaceMemberParser_ = function(node, objectStack) {
_ol_xml_.parseNode(this.SURFACEMEMBER_PARSERS_,
node, objectStack, this);
node, objectStack, this);
};
@@ -158,7 +158,7 @@ GML3.prototype.surfaceMemberParser_ = function(node, objectStack) {
*/
GML3.prototype.readPatch_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop([null],
this.PATCHES_PARSERS_, node, objectStack, this);
this.PATCHES_PARSERS_, node, objectStack, this);
};
@@ -170,7 +170,7 @@ GML3.prototype.readPatch_ = function(node, objectStack) {
*/
GML3.prototype.readSegment_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop([null],
this.SEGMENTS_PARSERS_, node, objectStack, this);
this.SEGMENTS_PARSERS_, node, objectStack, this);
};
@@ -182,7 +182,7 @@ GML3.prototype.readSegment_ = function(node, objectStack) {
*/
GML3.prototype.readPolygonPatch_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop([null],
this.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack, this);
this.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack, this);
};
@@ -194,8 +194,8 @@ GML3.prototype.readPolygonPatch_ = function(node, objectStack) {
*/
GML3.prototype.readLineStringSegment_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop([null],
this.GEOMETRY_FLAT_COORDINATES_PARSERS_,
node, objectStack, this);
this.GEOMETRY_FLAT_COORDINATES_PARSERS_,
node, objectStack, this);
};
@@ -206,10 +206,10 @@ GML3.prototype.readLineStringSegment_ = function(node, objectStack) {
*/
GML3.prototype.interiorParser_ = function(node, objectStack) {
/** @type {Array.<number>|undefined} */
var flatLinearRing = _ol_xml_.pushParseAndPop(undefined,
this.RING_PARSERS, node, objectStack, this);
const flatLinearRing = _ol_xml_.pushParseAndPop(undefined,
this.RING_PARSERS, node, objectStack, this);
if (flatLinearRing) {
var flatLinearRings = /** @type {Array.<Array.<number>>} */
const flatLinearRings = /** @type {Array.<Array.<number>>} */
(objectStack[objectStack.length - 1]);
flatLinearRings.push(flatLinearRing);
}
@@ -223,10 +223,10 @@ GML3.prototype.interiorParser_ = function(node, objectStack) {
*/
GML3.prototype.exteriorParser_ = function(node, objectStack) {
/** @type {Array.<number>|undefined} */
var flatLinearRing = _ol_xml_.pushParseAndPop(undefined,
this.RING_PARSERS, node, objectStack, this);
const flatLinearRing = _ol_xml_.pushParseAndPop(undefined,
this.RING_PARSERS, node, objectStack, this);
if (flatLinearRing) {
var flatLinearRings = /** @type {Array.<Array.<number>>} */
const flatLinearRings = /** @type {Array.<Array.<number>>} */
(objectStack[objectStack.length - 1]);
flatLinearRings[0] = flatLinearRing;
}
@@ -241,19 +241,19 @@ GML3.prototype.exteriorParser_ = function(node, objectStack) {
*/
GML3.prototype.readSurface_ = function(node, objectStack) {
/** @type {Array.<Array.<number>>} */
var flatLinearRings = _ol_xml_.pushParseAndPop([null],
this.SURFACE_PARSERS_, node, objectStack, this);
const flatLinearRings = _ol_xml_.pushParseAndPop([null],
this.SURFACE_PARSERS_, node, objectStack, this);
if (flatLinearRings && flatLinearRings[0]) {
var polygon = new Polygon(null);
var flatCoordinates = flatLinearRings[0];
var ends = [flatCoordinates.length];
var i, ii;
const polygon = new Polygon(null);
const flatCoordinates = flatLinearRings[0];
const ends = [flatCoordinates.length];
let i, ii;
for (i = 1, ii = flatLinearRings.length; i < ii; ++i) {
extend(flatCoordinates, flatLinearRings[i]);
ends.push(flatCoordinates.length);
}
polygon.setFlatCoordinates(
GeometryLayout.XYZ, flatCoordinates, ends);
GeometryLayout.XYZ, flatCoordinates, ends);
return polygon;
} else {
return undefined;
@@ -269,10 +269,10 @@ GML3.prototype.readSurface_ = function(node, objectStack) {
*/
GML3.prototype.readCurve_ = function(node, objectStack) {
/** @type {Array.<number>} */
var flatCoordinates = _ol_xml_.pushParseAndPop([null],
this.CURVE_PARSERS_, node, objectStack, this);
const flatCoordinates = _ol_xml_.pushParseAndPop([null],
this.CURVE_PARSERS_, node, objectStack, this);
if (flatCoordinates) {
var lineString = new LineString(null);
const lineString = new LineString(null);
lineString.setFlatCoordinates(GeometryLayout.XYZ, flatCoordinates);
return lineString;
} else {
@@ -289,11 +289,11 @@ GML3.prototype.readCurve_ = function(node, objectStack) {
*/
GML3.prototype.readEnvelope_ = function(node, objectStack) {
/** @type {Array.<number>} */
var flatCoordinates = _ol_xml_.pushParseAndPop([null],
this.ENVELOPE_PARSERS_, node, objectStack, this);
const flatCoordinates = _ol_xml_.pushParseAndPop([null],
this.ENVELOPE_PARSERS_, node, objectStack, this);
return createOrUpdate(flatCoordinates[1][0],
flatCoordinates[1][1], flatCoordinates[2][0],
flatCoordinates[2][1]);
flatCoordinates[1][1], flatCoordinates[2][0],
flatCoordinates[2][1]);
};
@@ -304,11 +304,11 @@ GML3.prototype.readEnvelope_ = function(node, objectStack) {
* @return {Array.<number>|undefined} Flat coordinates.
*/
GML3.prototype.readFlatPos_ = function(node, objectStack) {
var s = _ol_xml_.getAllTextContent(node, false);
var re = /^\s*([+\-]?\d*\.?\d+(?:[eE][+\-]?\d+)?)\s*/;
let s = _ol_xml_.getAllTextContent(node, false);
const re = /^\s*([+\-]?\d*\.?\d+(?:[eE][+\-]?\d+)?)\s*/;
/** @type {Array.<number>} */
var flatCoordinates = [];
var m;
const flatCoordinates = [];
let m;
while ((m = re.exec(s))) {
flatCoordinates.push(parseFloat(m[1]));
s = s.substr(m[0].length);
@@ -316,23 +316,23 @@ GML3.prototype.readFlatPos_ = function(node, objectStack) {
if (s !== '') {
return undefined;
}
var context = objectStack[0];
var containerSrs = context['srsName'];
var axisOrientation = 'enu';
const context = objectStack[0];
const containerSrs = context['srsName'];
let axisOrientation = 'enu';
if (containerSrs) {
var proj = getProjection(containerSrs);
const proj = getProjection(containerSrs);
axisOrientation = proj.getAxisOrientation();
}
if (axisOrientation === 'neu') {
var i, ii;
let i, ii;
for (i = 0, ii = flatCoordinates.length; i < ii; i += 3) {
var y = flatCoordinates[i];
var x = flatCoordinates[i + 1];
const y = flatCoordinates[i];
const x = flatCoordinates[i + 1];
flatCoordinates[i] = x;
flatCoordinates[i + 1] = y;
}
}
var len = flatCoordinates.length;
const len = flatCoordinates.length;
if (len == 2) {
flatCoordinates.push(0);
}
@@ -350,33 +350,33 @@ GML3.prototype.readFlatPos_ = function(node, objectStack) {
* @return {Array.<number>|undefined} Flat coordinates.
*/
GML3.prototype.readFlatPosList_ = function(node, objectStack) {
var s = _ol_xml_.getAllTextContent(node, false).replace(/^\s*|\s*$/g, '');
var context = objectStack[0];
var containerSrs = context['srsName'];
var contextDimension = context['srsDimension'];
var axisOrientation = 'enu';
const s = _ol_xml_.getAllTextContent(node, false).replace(/^\s*|\s*$/g, '');
const context = objectStack[0];
const containerSrs = context['srsName'];
const contextDimension = context['srsDimension'];
let axisOrientation = 'enu';
if (containerSrs) {
var proj = getProjection(containerSrs);
const proj = getProjection(containerSrs);
axisOrientation = proj.getAxisOrientation();
}
var coords = s.split(/\s+/);
const coords = s.split(/\s+/);
// The "dimension" attribute is from the GML 3.0.1 spec.
var dim = 2;
let dim = 2;
if (node.getAttribute('srsDimension')) {
dim = XSD.readNonNegativeIntegerString(
node.getAttribute('srsDimension'));
node.getAttribute('srsDimension'));
} else if (node.getAttribute('dimension')) {
dim = XSD.readNonNegativeIntegerString(
node.getAttribute('dimension'));
node.getAttribute('dimension'));
} else if (node.parentNode.getAttribute('srsDimension')) {
dim = XSD.readNonNegativeIntegerString(
node.parentNode.getAttribute('srsDimension'));
node.parentNode.getAttribute('srsDimension'));
} else if (contextDimension) {
dim = XSD.readNonNegativeIntegerString(contextDimension);
}
var x, y, z;
var flatCoordinates = [];
for (var i = 0, ii = coords.length; i < ii; i += dim) {
let x, y, z;
const flatCoordinates = [];
for (let i = 0, ii = coords.length; i < ii; i += dim) {
x = parseFloat(coords[i]);
y = parseFloat(coords[i + 1]);
z = (dim === 3) ? parseFloat(coords[i + 2]) : 0;
@@ -425,22 +425,22 @@ GML3.prototype.GEOMETRY_PARSERS_ = {
'http://www.opengis.net/gml': {
'Point': _ol_xml_.makeReplacer(GMLBase.prototype.readPoint),
'MultiPoint': _ol_xml_.makeReplacer(
GMLBase.prototype.readMultiPoint),
GMLBase.prototype.readMultiPoint),
'LineString': _ol_xml_.makeReplacer(
GMLBase.prototype.readLineString),
GMLBase.prototype.readLineString),
'MultiLineString': _ol_xml_.makeReplacer(
GMLBase.prototype.readMultiLineString),
GMLBase.prototype.readMultiLineString),
'LinearRing': _ol_xml_.makeReplacer(
GMLBase.prototype.readLinearRing),
GMLBase.prototype.readLinearRing),
'Polygon': _ol_xml_.makeReplacer(GMLBase.prototype.readPolygon),
'MultiPolygon': _ol_xml_.makeReplacer(
GMLBase.prototype.readMultiPolygon),
GMLBase.prototype.readMultiPolygon),
'Surface': _ol_xml_.makeReplacer(GML3.prototype.readSurface_),
'MultiSurface': _ol_xml_.makeReplacer(
GML3.prototype.readMultiSurface_),
GML3.prototype.readMultiSurface_),
'Curve': _ol_xml_.makeReplacer(GML3.prototype.readCurve_),
'MultiCurve': _ol_xml_.makeReplacer(
GML3.prototype.readMultiCurve_),
GML3.prototype.readMultiCurve_),
'Envelope': _ol_xml_.makeReplacer(GML3.prototype.readEnvelope_)
}
};
@@ -454,9 +454,9 @@ GML3.prototype.GEOMETRY_PARSERS_ = {
GML3.prototype.MULTICURVE_PARSERS_ = {
'http://www.opengis.net/gml': {
'curveMember': _ol_xml_.makeArrayPusher(
GML3.prototype.curveMemberParser_),
GML3.prototype.curveMemberParser_),
'curveMembers': _ol_xml_.makeArrayPusher(
GML3.prototype.curveMemberParser_)
GML3.prototype.curveMemberParser_)
}
};
@@ -469,9 +469,9 @@ GML3.prototype.MULTICURVE_PARSERS_ = {
GML3.prototype.MULTISURFACE_PARSERS_ = {
'http://www.opengis.net/gml': {
'surfaceMember': _ol_xml_.makeArrayPusher(
GML3.prototype.surfaceMemberParser_),
GML3.prototype.surfaceMemberParser_),
'surfaceMembers': _ol_xml_.makeArrayPusher(
GML3.prototype.surfaceMemberParser_)
GML3.prototype.surfaceMemberParser_)
}
};
@@ -484,7 +484,7 @@ GML3.prototype.MULTISURFACE_PARSERS_ = {
GML3.prototype.CURVEMEMBER_PARSERS_ = {
'http://www.opengis.net/gml': {
'LineString': _ol_xml_.makeArrayPusher(
GMLBase.prototype.readLineString),
GMLBase.prototype.readLineString),
'Curve': _ol_xml_.makeArrayPusher(GML3.prototype.readCurve_)
}
};
@@ -535,9 +535,9 @@ GML3.prototype.CURVE_PARSERS_ = {
GML3.prototype.ENVELOPE_PARSERS_ = {
'http://www.opengis.net/gml': {
'lowerCorner': _ol_xml_.makeArrayPusher(
GML3.prototype.readFlatPosList_),
GML3.prototype.readFlatPosList_),
'upperCorner': _ol_xml_.makeArrayPusher(
GML3.prototype.readFlatPosList_)
GML3.prototype.readFlatPosList_)
}
};
@@ -550,7 +550,7 @@ GML3.prototype.ENVELOPE_PARSERS_ = {
GML3.prototype.PATCHES_PARSERS_ = {
'http://www.opengis.net/gml': {
'PolygonPatch': _ol_xml_.makeReplacer(
GML3.prototype.readPolygonPatch_)
GML3.prototype.readPolygonPatch_)
}
};
@@ -563,7 +563,7 @@ GML3.prototype.PATCHES_PARSERS_ = {
GML3.prototype.SEGMENTS_PARSERS_ = {
'http://www.opengis.net/gml': {
'LineStringSegment': _ol_xml_.makeReplacer(
GML3.prototype.readLineStringSegment_)
GML3.prototype.readLineStringSegment_)
}
};
@@ -575,17 +575,17 @@ GML3.prototype.SEGMENTS_PARSERS_ = {
* @private
*/
GML3.prototype.writePos_ = function(node, value, objectStack) {
var context = objectStack[objectStack.length - 1];
var hasZ = context['hasZ'];
var srsDimension = hasZ ? 3 : 2;
const context = objectStack[objectStack.length - 1];
const hasZ = context['hasZ'];
const srsDimension = hasZ ? 3 : 2;
node.setAttribute('srsDimension', srsDimension);
var srsName = context['srsName'];
var axisOrientation = 'enu';
const srsName = context['srsName'];
let axisOrientation = 'enu';
if (srsName) {
axisOrientation = getProjection(srsName).getAxisOrientation();
}
var point = value.getCoordinates();
var coords;
const point = value.getCoordinates();
let coords;
// only 2d for simple features profile
if (axisOrientation.substr(0, 2) === 'en') {
coords = (point[0] + ' ' + point[1]);
@@ -594,7 +594,7 @@ GML3.prototype.writePos_ = function(node, value, objectStack) {
}
if (hasZ) {
// For newly created points, Z can be undefined.
var z = point[2] || 0;
const z = point[2] || 0;
coords += ' ' + z;
}
XSD.writeStringTextNode(node, coords);
@@ -609,16 +609,16 @@ GML3.prototype.writePos_ = function(node, value, objectStack) {
* @private
*/
GML3.prototype.getCoords_ = function(point, opt_srsName, opt_hasZ) {
var axisOrientation = 'enu';
let axisOrientation = 'enu';
if (opt_srsName) {
axisOrientation = getProjection(opt_srsName).getAxisOrientation();
}
var coords = ((axisOrientation.substr(0, 2) === 'en') ?
let 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;
const z = point[2] || 0;
coords += ' ' + z;
}
@@ -633,17 +633,17 @@ GML3.prototype.getCoords_ = function(point, opt_srsName, opt_hasZ) {
* @private
*/
GML3.prototype.writePosList_ = function(node, value, objectStack) {
var context = objectStack[objectStack.length - 1];
var hasZ = context['hasZ'];
var srsDimension = hasZ ? 3 : 2;
const context = objectStack[objectStack.length - 1];
const hasZ = context['hasZ'];
const srsDimension = hasZ ? 3 : 2;
node.setAttribute('srsDimension', srsDimension);
var srsName = context['srsName'];
const srsName = context['srsName'];
// only 2d for simple features profile
var points = value.getCoordinates();
var len = points.length;
var parts = new Array(len);
var point;
for (var i = 0; i < len; ++i) {
const points = value.getCoordinates();
const len = points.length;
const parts = new Array(len);
let point;
for (let i = 0; i < len; ++i) {
point = points[i];
parts[i] = this.getCoords_(point, srsName, hasZ);
}
@@ -658,12 +658,12 @@ GML3.prototype.writePosList_ = function(node, value, objectStack) {
* @private
*/
GML3.prototype.writePoint_ = function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var srsName = context['srsName'];
const context = objectStack[objectStack.length - 1];
const srsName = context['srsName'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var pos = _ol_xml_.createElementNS(node.namespaceURI, 'pos');
const pos = _ol_xml_.createElementNS(node.namespaceURI, 'pos');
node.appendChild(pos);
this.writePos_(pos, geometry, objectStack);
};
@@ -687,18 +687,18 @@ GML3.ENVELOPE_SERIALIZERS_ = {
* @param {Array.<*>} objectStack Node stack.
*/
GML3.prototype.writeEnvelope = function(node, extent, objectStack) {
var context = objectStack[objectStack.length - 1];
var srsName = context['srsName'];
const context = objectStack[objectStack.length - 1];
const srsName = context['srsName'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var keys = ['lowerCorner', 'upperCorner'];
var values = [extent[0] + ' ' + extent[1], extent[2] + ' ' + extent[3]];
const keys = ['lowerCorner', 'upperCorner'];
const values = [extent[0] + ' ' + extent[1], extent[2] + ' ' + extent[3]];
_ol_xml_.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */
({node: node}), GML3.ENVELOPE_SERIALIZERS_,
_ol_xml_.OBJECT_PROPERTY_NODE_FACTORY,
values,
objectStack, keys, this);
({node: node}), GML3.ENVELOPE_SERIALIZERS_,
_ol_xml_.OBJECT_PROPERTY_NODE_FACTORY,
values,
objectStack, keys, this);
};
@@ -709,12 +709,12 @@ GML3.prototype.writeEnvelope = function(node, extent, objectStack) {
* @private
*/
GML3.prototype.writeLinearRing_ = function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var srsName = context['srsName'];
const context = objectStack[objectStack.length - 1];
const srsName = context['srsName'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var posList = _ol_xml_.createElementNS(node.namespaceURI, 'posList');
const posList = _ol_xml_.createElementNS(node.namespaceURI, 'posList');
node.appendChild(posList);
this.writePosList_(posList, geometry, objectStack);
};
@@ -728,14 +728,14 @@ GML3.prototype.writeLinearRing_ = function(node, geometry, objectStack) {
* @private
*/
GML3.prototype.RING_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) {
var context = objectStack[objectStack.length - 1];
var parentNode = context.node;
var exteriorWritten = context['exteriorWritten'];
const context = objectStack[objectStack.length - 1];
const parentNode = context.node;
const exteriorWritten = context['exteriorWritten'];
if (exteriorWritten === undefined) {
context['exteriorWritten'] = true;
}
return _ol_xml_.createElementNS(parentNode.namespaceURI,
exteriorWritten !== undefined ? 'interior' : 'exterior');
exteriorWritten !== undefined ? 'interior' : 'exterior');
};
@@ -746,24 +746,24 @@ GML3.prototype.RING_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) {
* @private
*/
GML3.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var hasZ = context['hasZ'];
var srsName = context['srsName'];
const context = objectStack[objectStack.length - 1];
const hasZ = context['hasZ'];
const srsName = context['srsName'];
if (node.nodeName !== 'PolygonPatch' && srsName) {
node.setAttribute('srsName', srsName);
}
if (node.nodeName === 'Polygon' || node.nodeName === 'PolygonPatch') {
var rings = geometry.getLinearRings();
const rings = geometry.getLinearRings();
_ol_xml_.pushSerializeAndPop(
{node: node, hasZ: hasZ, srsName: srsName},
GML3.RING_SERIALIZERS_,
this.RING_NODE_FACTORY_,
rings, objectStack, undefined, this);
{node: node, hasZ: hasZ, srsName: srsName},
GML3.RING_SERIALIZERS_,
this.RING_NODE_FACTORY_,
rings, objectStack, undefined, this);
} else if (node.nodeName === 'Surface') {
var patches = _ol_xml_.createElementNS(node.namespaceURI, 'patches');
const patches = _ol_xml_.createElementNS(node.namespaceURI, 'patches');
node.appendChild(patches);
this.writeSurfacePatches_(
patches, geometry, objectStack);
patches, geometry, objectStack);
}
};
@@ -775,21 +775,21 @@ GML3.prototype.writeSurfaceOrPolygon_ = function(node, geometry, objectStack) {
* @private
*/
GML3.prototype.writeCurveOrLineString_ = function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var srsName = context['srsName'];
const context = objectStack[objectStack.length - 1];
const srsName = context['srsName'];
if (node.nodeName !== 'LineStringSegment' && srsName) {
node.setAttribute('srsName', srsName);
}
if (node.nodeName === 'LineString' ||
node.nodeName === 'LineStringSegment') {
var posList = _ol_xml_.createElementNS(node.namespaceURI, 'posList');
const posList = _ol_xml_.createElementNS(node.namespaceURI, 'posList');
node.appendChild(posList);
this.writePosList_(posList, geometry, objectStack);
} else if (node.nodeName === 'Curve') {
var segments = _ol_xml_.createElementNS(node.namespaceURI, 'segments');
const segments = _ol_xml_.createElementNS(node.namespaceURI, 'segments');
node.appendChild(segments);
this.writeCurveSegments_(segments,
geometry, objectStack);
geometry, objectStack);
}
};
@@ -801,18 +801,18 @@ GML3.prototype.writeCurveOrLineString_ = function(node, geometry, objectStack) {
* @private
*/
GML3.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var hasZ = context['hasZ'];
var srsName = context['srsName'];
var surface = context['surface'];
const context = objectStack[objectStack.length - 1];
const hasZ = context['hasZ'];
const srsName = context['srsName'];
const surface = context['surface'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var polygons = geometry.getPolygons();
const polygons = geometry.getPolygons();
_ol_xml_.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName, surface: surface},
GML3.SURFACEORPOLYGONMEMBER_SERIALIZERS_,
this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, polygons,
objectStack, undefined, this);
GML3.SURFACEORPOLYGONMEMBER_SERIALIZERS_,
this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, polygons,
objectStack, undefined, this);
};
@@ -823,18 +823,18 @@ GML3.prototype.writeMultiSurfaceOrPolygon_ = function(node, geometry, objectStac
* @private
*/
GML3.prototype.writeMultiPoint_ = function(node, geometry,
objectStack) {
var context = objectStack[objectStack.length - 1];
var srsName = context['srsName'];
var hasZ = context['hasZ'];
objectStack) {
const context = objectStack[objectStack.length - 1];
const srsName = context['srsName'];
const hasZ = context['hasZ'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var points = geometry.getPoints();
const points = geometry.getPoints();
_ol_xml_.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName},
GML3.POINTMEMBER_SERIALIZERS_,
_ol_xml_.makeSimpleNodeFactory('pointMember'), points,
objectStack, undefined, this);
GML3.POINTMEMBER_SERIALIZERS_,
_ol_xml_.makeSimpleNodeFactory('pointMember'), points,
objectStack, undefined, this);
};
@@ -845,18 +845,18 @@ GML3.prototype.writeMultiPoint_ = function(node, geometry,
* @private
*/
GML3.prototype.writeMultiCurveOrLineString_ = function(node, geometry, objectStack) {
var context = objectStack[objectStack.length - 1];
var hasZ = context['hasZ'];
var srsName = context['srsName'];
var curve = context['curve'];
const context = objectStack[objectStack.length - 1];
const hasZ = context['hasZ'];
const srsName = context['srsName'];
const curve = context['curve'];
if (srsName) {
node.setAttribute('srsName', srsName);
}
var lines = geometry.getLineStrings();
const lines = geometry.getLineStrings();
_ol_xml_.pushSerializeAndPop({node: node, hasZ: hasZ, srsName: srsName, curve: curve},
GML3.LINESTRINGORCURVEMEMBER_SERIALIZERS_,
this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, lines,
objectStack, undefined, this);
GML3.LINESTRINGORCURVEMEMBER_SERIALIZERS_,
this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_, lines,
objectStack, undefined, this);
};
@@ -867,7 +867,7 @@ GML3.prototype.writeMultiCurveOrLineString_ = function(node, geometry, objectSta
* @private
*/
GML3.prototype.writeRing_ = function(node, ring, objectStack) {
var linearRing = _ol_xml_.createElementNS(node.namespaceURI, 'LinearRing');
const linearRing = _ol_xml_.createElementNS(node.namespaceURI, 'LinearRing');
node.appendChild(linearRing);
this.writeLinearRing_(linearRing, ring, objectStack);
};
@@ -880,8 +880,8 @@ GML3.prototype.writeRing_ = function(node, ring, objectStack) {
* @private
*/
GML3.prototype.writeSurfaceOrPolygonMember_ = function(node, polygon, objectStack) {
var child = this.GEOMETRY_NODE_FACTORY_(
polygon, objectStack);
const child = this.GEOMETRY_NODE_FACTORY_(
polygon, objectStack);
if (child) {
node.appendChild(child);
this.writeSurfaceOrPolygon_(child, polygon, objectStack);
@@ -896,7 +896,7 @@ GML3.prototype.writeSurfaceOrPolygonMember_ = function(node, polygon, objectStac
* @private
*/
GML3.prototype.writePointMember_ = function(node, point, objectStack) {
var child = _ol_xml_.createElementNS(node.namespaceURI, 'Point');
const child = _ol_xml_.createElementNS(node.namespaceURI, 'Point');
node.appendChild(child);
this.writePoint_(child, point, objectStack);
};
@@ -909,7 +909,7 @@ GML3.prototype.writePointMember_ = function(node, point, objectStack) {
* @private
*/
GML3.prototype.writeLineStringOrCurveMember_ = function(node, line, objectStack) {
var child = this.GEOMETRY_NODE_FACTORY_(line, objectStack);
const child = this.GEOMETRY_NODE_FACTORY_(line, objectStack);
if (child) {
node.appendChild(child);
this.writeCurveOrLineString_(child, line, objectStack);
@@ -924,7 +924,7 @@ GML3.prototype.writeLineStringOrCurveMember_ = function(node, line, objectStack)
* @private
*/
GML3.prototype.writeSurfacePatches_ = function(node, polygon, objectStack) {
var child = _ol_xml_.createElementNS(node.namespaceURI, 'PolygonPatch');
const child = _ol_xml_.createElementNS(node.namespaceURI, 'PolygonPatch');
node.appendChild(child);
this.writeSurfaceOrPolygon_(child, polygon, objectStack);
};
@@ -937,8 +937,8 @@ GML3.prototype.writeSurfacePatches_ = function(node, polygon, objectStack) {
* @private
*/
GML3.prototype.writeCurveSegments_ = function(node, line, objectStack) {
var child = _ol_xml_.createElementNS(node.namespaceURI,
'LineStringSegment');
const child = _ol_xml_.createElementNS(node.namespaceURI,
'LineStringSegment');
node.appendChild(child);
this.writeCurveOrLineString_(child, line, objectStack);
};
@@ -950,14 +950,14 @@ GML3.prototype.writeCurveSegments_ = function(node, line, objectStack) {
* @param {Array.<*>} objectStack Node stack.
*/
GML3.prototype.writeGeometryElement = function(node, geometry, objectStack) {
var context = /** @type {olx.format.WriteOptions} */ (objectStack[objectStack.length - 1]);
var item = _ol_obj_.assign({}, context);
const context = /** @type {olx.format.WriteOptions} */ (objectStack[objectStack.length - 1]);
const item = _ol_obj_.assign({}, context);
item.node = node;
var value;
let value;
if (Array.isArray(geometry)) {
if (context.dataProjection) {
value = transformExtent(
geometry, context.featureProjection, context.dataProjection);
geometry, context.featureProjection, context.dataProjection);
} else {
value = geometry;
}
@@ -965,9 +965,9 @@ GML3.prototype.writeGeometryElement = function(node, geometry, objectStack) {
value = transformWithOptions(/** @type {ol.geom.Geometry} */ (geometry), true, context);
}
_ol_xml_.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */
(item), GML3.GEOMETRY_SERIALIZERS_,
this.GEOMETRY_NODE_FACTORY_, [value],
objectStack, undefined, this);
(item), GML3.GEOMETRY_SERIALIZERS_,
this.GEOMETRY_NODE_FACTORY_, [value],
objectStack, undefined, this);
};
@@ -977,44 +977,45 @@ GML3.prototype.writeGeometryElement = function(node, geometry, objectStack) {
* @param {Array.<*>} objectStack Node stack.
*/
GML3.prototype.writeFeatureElement = function(node, feature, objectStack) {
var fid = feature.getId();
const fid = feature.getId();
if (fid) {
node.setAttribute('fid', fid);
}
var context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
var featureNS = context['featureNS'];
var geometryName = feature.getGeometryName();
const context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
const featureNS = context['featureNS'];
const geometryName = feature.getGeometryName();
if (!context.serializers) {
context.serializers = {};
context.serializers[featureNS] = {};
}
var properties = feature.getProperties();
var keys = [], values = [];
for (var key in properties) {
var value = properties[key];
const properties = feature.getProperties();
const keys = [];
const values = [];
for (const key in properties) {
const value = properties[key];
if (value !== null) {
keys.push(key);
values.push(value);
if (key == geometryName || value instanceof Geometry) {
if (!(key in context.serializers[featureNS])) {
context.serializers[featureNS][key] = _ol_xml_.makeChildAppender(
this.writeGeometryElement, this);
this.writeGeometryElement, this);
}
} else {
if (!(key in context.serializers[featureNS])) {
context.serializers[featureNS][key] = _ol_xml_.makeChildAppender(
XSD.writeStringTextNode);
XSD.writeStringTextNode);
}
}
}
}
var item = _ol_obj_.assign({}, context);
const item = _ol_obj_.assign({}, context);
item.node = node;
_ol_xml_.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */
(item), context.serializers,
_ol_xml_.makeSimpleNodeFactory(undefined, featureNS),
values,
objectStack, keys);
(item), context.serializers,
_ol_xml_.makeSimpleNodeFactory(undefined, featureNS),
values,
objectStack, keys);
};
@@ -1025,20 +1026,20 @@ GML3.prototype.writeFeatureElement = function(node, feature, objectStack) {
* @private
*/
GML3.prototype.writeFeatureMembers_ = function(node, features, objectStack) {
var context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
var featureType = context['featureType'];
var featureNS = context['featureNS'];
var serializers = {};
const context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
const featureType = context['featureType'];
const featureNS = context['featureNS'];
const serializers = {};
serializers[featureNS] = {};
serializers[featureNS][featureType] = _ol_xml_.makeChildAppender(
this.writeFeatureElement, this);
var item = _ol_obj_.assign({}, context);
this.writeFeatureElement, this);
const item = _ol_obj_.assign({}, context);
item.node = node;
_ol_xml_.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */
(item),
serializers,
_ol_xml_.makeSimpleNodeFactory(featureType, featureNS), features,
objectStack);
(item),
serializers,
_ol_xml_.makeSimpleNodeFactory(featureType, featureNS), features,
objectStack);
};
@@ -1049,9 +1050,9 @@ GML3.prototype.writeFeatureMembers_ = function(node, features, objectStack) {
GML3.SURFACEORPOLYGONMEMBER_SERIALIZERS_ = {
'http://www.opengis.net/gml': {
'surfaceMember': _ol_xml_.makeChildAppender(
GML3.prototype.writeSurfaceOrPolygonMember_),
GML3.prototype.writeSurfaceOrPolygonMember_),
'polygonMember': _ol_xml_.makeChildAppender(
GML3.prototype.writeSurfaceOrPolygonMember_)
GML3.prototype.writeSurfaceOrPolygonMember_)
}
};
@@ -1063,7 +1064,7 @@ GML3.SURFACEORPOLYGONMEMBER_SERIALIZERS_ = {
GML3.POINTMEMBER_SERIALIZERS_ = {
'http://www.opengis.net/gml': {
'pointMember': _ol_xml_.makeChildAppender(
GML3.prototype.writePointMember_)
GML3.prototype.writePointMember_)
}
};
@@ -1075,9 +1076,9 @@ GML3.POINTMEMBER_SERIALIZERS_ = {
GML3.LINESTRINGORCURVEMEMBER_SERIALIZERS_ = {
'http://www.opengis.net/gml': {
'lineStringMember': _ol_xml_.makeChildAppender(
GML3.prototype.writeLineStringOrCurveMember_),
GML3.prototype.writeLineStringOrCurveMember_),
'curveMember': _ol_xml_.makeChildAppender(
GML3.prototype.writeLineStringOrCurveMember_)
GML3.prototype.writeLineStringOrCurveMember_)
}
};
@@ -1101,28 +1102,28 @@ GML3.RING_SERIALIZERS_ = {
GML3.GEOMETRY_SERIALIZERS_ = {
'http://www.opengis.net/gml': {
'Curve': _ol_xml_.makeChildAppender(
GML3.prototype.writeCurveOrLineString_),
GML3.prototype.writeCurveOrLineString_),
'MultiCurve': _ol_xml_.makeChildAppender(
GML3.prototype.writeMultiCurveOrLineString_),
GML3.prototype.writeMultiCurveOrLineString_),
'Point': _ol_xml_.makeChildAppender(GML3.prototype.writePoint_),
'MultiPoint': _ol_xml_.makeChildAppender(
GML3.prototype.writeMultiPoint_),
GML3.prototype.writeMultiPoint_),
'LineString': _ol_xml_.makeChildAppender(
GML3.prototype.writeCurveOrLineString_),
GML3.prototype.writeCurveOrLineString_),
'MultiLineString': _ol_xml_.makeChildAppender(
GML3.prototype.writeMultiCurveOrLineString_),
GML3.prototype.writeMultiCurveOrLineString_),
'LinearRing': _ol_xml_.makeChildAppender(
GML3.prototype.writeLinearRing_),
GML3.prototype.writeLinearRing_),
'Polygon': _ol_xml_.makeChildAppender(
GML3.prototype.writeSurfaceOrPolygon_),
GML3.prototype.writeSurfaceOrPolygon_),
'MultiPolygon': _ol_xml_.makeChildAppender(
GML3.prototype.writeMultiSurfaceOrPolygon_),
GML3.prototype.writeMultiSurfaceOrPolygon_),
'Surface': _ol_xml_.makeChildAppender(
GML3.prototype.writeSurfaceOrPolygon_),
GML3.prototype.writeSurfaceOrPolygon_),
'MultiSurface': _ol_xml_.makeChildAppender(
GML3.prototype.writeMultiSurfaceOrPolygon_),
GML3.prototype.writeMultiSurfaceOrPolygon_),
'Envelope': _ol_xml_.makeChildAppender(
GML3.prototype.writeEnvelope)
GML3.prototype.writeEnvelope)
}
};
@@ -1149,9 +1150,9 @@ GML3.MULTIGEOMETRY_TO_MEMBER_NODENAME_ = {
* @private
*/
GML3.prototype.MULTIGEOMETRY_MEMBER_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) {
var parentNode = objectStack[objectStack.length - 1].node;
const parentNode = objectStack[objectStack.length - 1].node;
return _ol_xml_.createElementNS('http://www.opengis.net/gml',
GML3.MULTIGEOMETRY_TO_MEMBER_NODENAME_[parentNode.nodeName]);
GML3.MULTIGEOMETRY_TO_MEMBER_NODENAME_[parentNode.nodeName]);
};
@@ -1164,12 +1165,12 @@ GML3.prototype.MULTIGEOMETRY_MEMBER_NODE_FACTORY_ = function(value, objectStack,
* @private
*/
GML3.prototype.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) {
var context = objectStack[objectStack.length - 1];
var multiSurface = context['multiSurface'];
var surface = context['surface'];
var curve = context['curve'];
var multiCurve = context['multiCurve'];
var nodeName;
const context = objectStack[objectStack.length - 1];
const multiSurface = context['multiSurface'];
const surface = context['surface'];
const curve = context['curve'];
const multiCurve = context['multiCurve'];
let nodeName;
if (!Array.isArray(value)) {
nodeName = /** @type {ol.geom.Geometry} */ (value).getType();
if (nodeName === 'MultiPolygon' && multiSurface === true) {
@@ -1185,7 +1186,7 @@ GML3.prototype.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, opt_nodeNam
nodeName = 'Envelope';
}
return _ol_xml_.createElementNS('http://www.opengis.net/gml',
nodeName);
nodeName);
};
@@ -1200,8 +1201,8 @@ GML3.prototype.GEOMETRY_NODE_FACTORY_ = function(value, objectStack, opt_nodeNam
*/
GML3.prototype.writeGeometryNode = function(geometry, opt_options) {
opt_options = this.adaptOptions(opt_options);
var geom = _ol_xml_.createElementNS('http://www.opengis.net/gml', 'geom');
var context = {node: geom, hasZ: this.hasZ, srsName: this.srsName,
const geom = _ol_xml_.createElementNS('http://www.opengis.net/gml', 'geom');
const context = {node: geom, hasZ: this.hasZ, srsName: this.srsName,
curve: this.curve_, surface: this.surface_,
multiSurface: this.multiSurface_, multiCurve: this.multiCurve_};
if (opt_options) {
@@ -1235,11 +1236,11 @@ GML3.prototype.writeFeatures;
*/
GML3.prototype.writeFeaturesNode = function(features, opt_options) {
opt_options = this.adaptOptions(opt_options);
var node = _ol_xml_.createElementNS('http://www.opengis.net/gml',
'featureMembers');
const node = _ol_xml_.createElementNS('http://www.opengis.net/gml',
'featureMembers');
_ol_xml_.setAttributeNS(node, 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation', this.schemaLocation);
var context = {
'xsi:schemaLocation', this.schemaLocation);
const context = {
srsName: this.srsName,
hasZ: this.hasZ,
curve: this.curve_,
+81 -78
View File
@@ -36,8 +36,8 @@ import _ol_xml_ from '../xml.js';
* Optional configuration object.
* @extends {ol.format.XMLFeature}
*/
var GMLBase = function(opt_options) {
var options = /** @type {olx.format.GMLOptions} */
const GMLBase = function(opt_options) {
const options = /** @type {olx.format.GMLOptions} */
(opt_options ? opt_options : {});
/**
@@ -70,9 +70,9 @@ var GMLBase = function(opt_options) {
this.FEATURE_COLLECTION_PARSERS = {};
this.FEATURE_COLLECTION_PARSERS[GMLBase.GMLNS] = {
'featureMember': _ol_xml_.makeReplacer(
GMLBase.prototype.readFeaturesInternal),
GMLBase.prototype.readFeaturesInternal),
'featureMembers': _ol_xml_.makeReplacer(
GMLBase.prototype.readFeaturesInternal)
GMLBase.prototype.readFeaturesInternal)
};
XMLFeature.call(this);
@@ -109,34 +109,36 @@ GMLBase.ONLY_WHITESPACE_RE_ = /^[\s\xa0]*$/;
* @return {Array.<ol.Feature> | undefined} Features.
*/
GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
var localName = node.localName;
var features = null;
const localName = node.localName;
let features = null;
if (localName == 'FeatureCollection') {
if (node.namespaceURI === 'http://www.opengis.net/wfs') {
features = _ol_xml_.pushParseAndPop([],
this.FEATURE_COLLECTION_PARSERS, node,
objectStack, this);
this.FEATURE_COLLECTION_PARSERS, node,
objectStack, this);
} else {
features = _ol_xml_.pushParseAndPop(null,
this.FEATURE_COLLECTION_PARSERS, node,
objectStack, this);
this.FEATURE_COLLECTION_PARSERS, node,
objectStack, this);
}
} else if (localName == 'featureMembers' || localName == 'featureMember') {
var context = objectStack[0];
var featureType = context['featureType'];
var featureNS = context['featureNS'];
var i, ii, prefix = 'p', defaultPrefix = 'p0';
const context = objectStack[0];
let featureType = context['featureType'];
let featureNS = context['featureNS'];
let i, ii;
const prefix = 'p';
const defaultPrefix = 'p0';
if (!featureType && node.childNodes) {
featureType = [], featureNS = {};
for (i = 0, ii = node.childNodes.length; i < ii; ++i) {
var child = node.childNodes[i];
const child = node.childNodes[i];
if (child.nodeType === 1) {
var ft = child.nodeName.split(':').pop();
const ft = child.nodeName.split(':').pop();
if (featureType.indexOf(ft) === -1) {
var key = '';
var count = 0;
var uri = child.namespaceURI;
for (var candidate in featureNS) {
let key = '';
let count = 0;
const uri = child.namespaceURI;
for (const candidate in featureNS) {
if (featureNS[candidate] === uri) {
key = candidate;
break;
@@ -158,16 +160,16 @@ GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
}
}
if (typeof featureNS === 'string') {
var ns = featureNS;
const ns = featureNS;
featureNS = {};
featureNS[defaultPrefix] = ns;
}
var parsersNS = {};
var featureTypes = Array.isArray(featureType) ? featureType : [featureType];
for (var p in featureNS) {
var parsers = {};
const parsersNS = {};
const featureTypes = Array.isArray(featureType) ? featureType : [featureType];
for (const p in featureNS) {
const parsers = {};
for (i = 0, ii = featureTypes.length; i < ii; ++i) {
var featurePrefix = featureTypes[i].indexOf(':') === -1 ?
const featurePrefix = featureTypes[i].indexOf(':') === -1 ?
defaultPrefix : featureTypes[i].split(':')[0];
if (featurePrefix === p) {
parsers[featureTypes[i].split(':').pop()] =
@@ -197,12 +199,12 @@ GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
* @return {ol.geom.Geometry|undefined} Geometry.
*/
GMLBase.prototype.readGeometryElement = function(node, objectStack) {
var context = /** @type {Object} */ (objectStack[0]);
const context = /** @type {Object} */ (objectStack[0]);
context['srsName'] = node.firstElementChild.getAttribute('srsName');
context['srsDimension'] = node.firstElementChild.getAttribute('srsDimension');
/** @type {ol.geom.Geometry} */
var geometry = _ol_xml_.pushParseAndPop(null,
this.GEOMETRY_PARSERS_, node, objectStack, this);
const geometry = _ol_xml_.pushParseAndPop(null,
this.GEOMETRY_PARSERS_, node, objectStack, this);
if (geometry) {
return (
/** @type {ol.geom.Geometry} */ transformWithOptions(geometry, false, context)
@@ -219,19 +221,20 @@ GMLBase.prototype.readGeometryElement = function(node, objectStack) {
* @return {ol.Feature} Feature.
*/
GMLBase.prototype.readFeatureElement = function(node, objectStack) {
var n;
var fid = node.getAttribute('fid') ||
let n;
const fid = node.getAttribute('fid') ||
_ol_xml_.getAttributeNS(node, GMLBase.GMLNS, 'id');
var values = {}, geometryName;
const values = {};
let geometryName;
for (n = node.firstElementChild; n; n = n.nextElementSibling) {
var localName = n.localName;
const localName = n.localName;
// Assume attribute elements have one child node and that the child
// is a text or CDATA node (to be treated as text).
// Otherwise assume it is a geometry node.
if (n.childNodes.length === 0 ||
(n.childNodes.length === 1 &&
(n.firstChild.nodeType === 3 || n.firstChild.nodeType === 4))) {
var value = _ol_xml_.getAllTextContent(n, false);
let value = _ol_xml_.getAllTextContent(n, false);
if (GMLBase.ONLY_WHITESPACE_RE_.test(value)) {
value = undefined;
}
@@ -244,7 +247,7 @@ GMLBase.prototype.readFeatureElement = function(node, objectStack) {
values[localName] = this.readGeometryElement(n, objectStack);
}
}
var feature = new Feature(values);
const feature = new Feature(values);
if (geometryName) {
feature.setGeometryName(geometryName);
}
@@ -261,10 +264,10 @@ GMLBase.prototype.readFeatureElement = function(node, objectStack) {
* @return {ol.geom.Point|undefined} Point.
*/
GMLBase.prototype.readPoint = function(node, objectStack) {
var flatCoordinates =
const flatCoordinates =
this.readFlatCoordinatesFromNode_(node, objectStack);
if (flatCoordinates) {
var point = new Point(null);
const point = new Point(null);
point.setFlatCoordinates(GeometryLayout.XYZ, flatCoordinates);
return point;
}
@@ -278,8 +281,8 @@ GMLBase.prototype.readPoint = function(node, objectStack) {
*/
GMLBase.prototype.readMultiPoint = function(node, objectStack) {
/** @type {Array.<Array.<number>>} */
var coordinates = _ol_xml_.pushParseAndPop([],
this.MULTIPOINT_PARSERS_, node, objectStack, this);
const coordinates = _ol_xml_.pushParseAndPop([],
this.MULTIPOINT_PARSERS_, node, objectStack, this);
if (coordinates) {
return new MultiPoint(coordinates);
} else {
@@ -295,10 +298,10 @@ GMLBase.prototype.readMultiPoint = function(node, objectStack) {
*/
GMLBase.prototype.readMultiLineString = function(node, objectStack) {
/** @type {Array.<ol.geom.LineString>} */
var lineStrings = _ol_xml_.pushParseAndPop([],
this.MULTILINESTRING_PARSERS_, node, objectStack, this);
const lineStrings = _ol_xml_.pushParseAndPop([],
this.MULTILINESTRING_PARSERS_, node, objectStack, this);
if (lineStrings) {
var multiLineString = new MultiLineString(null);
const multiLineString = new MultiLineString(null);
multiLineString.setLineStrings(lineStrings);
return multiLineString;
} else {
@@ -314,10 +317,10 @@ GMLBase.prototype.readMultiLineString = function(node, objectStack) {
*/
GMLBase.prototype.readMultiPolygon = function(node, objectStack) {
/** @type {Array.<ol.geom.Polygon>} */
var polygons = _ol_xml_.pushParseAndPop([],
this.MULTIPOLYGON_PARSERS_, node, objectStack, this);
const polygons = _ol_xml_.pushParseAndPop([],
this.MULTIPOLYGON_PARSERS_, node, objectStack, this);
if (polygons) {
var multiPolygon = new MultiPolygon(null);
const multiPolygon = new MultiPolygon(null);
multiPolygon.setPolygons(polygons);
return multiPolygon;
} else {
@@ -333,7 +336,7 @@ GMLBase.prototype.readMultiPolygon = function(node, objectStack) {
*/
GMLBase.prototype.pointMemberParser_ = function(node, objectStack) {
_ol_xml_.parseNode(this.POINTMEMBER_PARSERS_,
node, objectStack, this);
node, objectStack, this);
};
@@ -344,7 +347,7 @@ GMLBase.prototype.pointMemberParser_ = function(node, objectStack) {
*/
GMLBase.prototype.lineStringMemberParser_ = function(node, objectStack) {
_ol_xml_.parseNode(this.LINESTRINGMEMBER_PARSERS_,
node, objectStack, this);
node, objectStack, this);
};
@@ -355,7 +358,7 @@ GMLBase.prototype.lineStringMemberParser_ = function(node, objectStack) {
*/
GMLBase.prototype.polygonMemberParser_ = function(node, objectStack) {
_ol_xml_.parseNode(this.POLYGONMEMBER_PARSERS_, node,
objectStack, this);
objectStack, this);
};
@@ -365,10 +368,10 @@ GMLBase.prototype.polygonMemberParser_ = function(node, objectStack) {
* @return {ol.geom.LineString|undefined} LineString.
*/
GMLBase.prototype.readLineString = function(node, objectStack) {
var flatCoordinates =
const flatCoordinates =
this.readFlatCoordinatesFromNode_(node, objectStack);
if (flatCoordinates) {
var lineString = new LineString(null);
const lineString = new LineString(null);
lineString.setFlatCoordinates(GeometryLayout.XYZ, flatCoordinates);
return lineString;
} else {
@@ -384,9 +387,9 @@ GMLBase.prototype.readLineString = function(node, objectStack) {
* @return {Array.<number>|undefined} LinearRing flat coordinates.
*/
GMLBase.prototype.readFlatLinearRing_ = function(node, objectStack) {
var ring = _ol_xml_.pushParseAndPop(null,
this.GEOMETRY_FLAT_COORDINATES_PARSERS_, node,
objectStack, this);
const ring = _ol_xml_.pushParseAndPop(null,
this.GEOMETRY_FLAT_COORDINATES_PARSERS_, node,
objectStack, this);
if (ring) {
return ring;
} else {
@@ -401,10 +404,10 @@ GMLBase.prototype.readFlatLinearRing_ = function(node, objectStack) {
* @return {ol.geom.LinearRing|undefined} LinearRing.
*/
GMLBase.prototype.readLinearRing = function(node, objectStack) {
var flatCoordinates =
const flatCoordinates =
this.readFlatCoordinatesFromNode_(node, objectStack);
if (flatCoordinates) {
var ring = new LinearRing(null);
const ring = new LinearRing(null);
ring.setFlatCoordinates(GeometryLayout.XYZ, flatCoordinates);
return ring;
} else {
@@ -420,19 +423,19 @@ GMLBase.prototype.readLinearRing = function(node, objectStack) {
*/
GMLBase.prototype.readPolygon = function(node, objectStack) {
/** @type {Array.<Array.<number>>} */
var flatLinearRings = _ol_xml_.pushParseAndPop([null],
this.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack, this);
const flatLinearRings = _ol_xml_.pushParseAndPop([null],
this.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack, this);
if (flatLinearRings && flatLinearRings[0]) {
var polygon = new Polygon(null);
var flatCoordinates = flatLinearRings[0];
var ends = [flatCoordinates.length];
var i, ii;
const polygon = new Polygon(null);
const flatCoordinates = flatLinearRings[0];
const ends = [flatCoordinates.length];
let i, ii;
for (i = 1, ii = flatLinearRings.length; i < ii; ++i) {
extend(flatCoordinates, flatLinearRings[i]);
ends.push(flatCoordinates.length);
}
polygon.setFlatCoordinates(
GeometryLayout.XYZ, flatCoordinates, ends);
GeometryLayout.XYZ, flatCoordinates, ends);
return polygon;
} else {
return undefined;
@@ -448,8 +451,8 @@ GMLBase.prototype.readPolygon = function(node, objectStack) {
*/
GMLBase.prototype.readFlatCoordinatesFromNode_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop(null,
this.GEOMETRY_FLAT_COORDINATES_PARSERS_, node,
objectStack, this);
this.GEOMETRY_FLAT_COORDINATES_PARSERS_, node,
objectStack, this);
};
@@ -461,9 +464,9 @@ GMLBase.prototype.readFlatCoordinatesFromNode_ = function(node, objectStack) {
GMLBase.prototype.MULTIPOINT_PARSERS_ = {
'http://www.opengis.net/gml': {
'pointMember': _ol_xml_.makeArrayPusher(
GMLBase.prototype.pointMemberParser_),
GMLBase.prototype.pointMemberParser_),
'pointMembers': _ol_xml_.makeArrayPusher(
GMLBase.prototype.pointMemberParser_)
GMLBase.prototype.pointMemberParser_)
}
};
@@ -476,9 +479,9 @@ GMLBase.prototype.MULTIPOINT_PARSERS_ = {
GMLBase.prototype.MULTILINESTRING_PARSERS_ = {
'http://www.opengis.net/gml': {
'lineStringMember': _ol_xml_.makeArrayPusher(
GMLBase.prototype.lineStringMemberParser_),
GMLBase.prototype.lineStringMemberParser_),
'lineStringMembers': _ol_xml_.makeArrayPusher(
GMLBase.prototype.lineStringMemberParser_)
GMLBase.prototype.lineStringMemberParser_)
}
};
@@ -491,9 +494,9 @@ GMLBase.prototype.MULTILINESTRING_PARSERS_ = {
GMLBase.prototype.MULTIPOLYGON_PARSERS_ = {
'http://www.opengis.net/gml': {
'polygonMember': _ol_xml_.makeArrayPusher(
GMLBase.prototype.polygonMemberParser_),
GMLBase.prototype.polygonMemberParser_),
'polygonMembers': _ol_xml_.makeArrayPusher(
GMLBase.prototype.polygonMemberParser_)
GMLBase.prototype.polygonMemberParser_)
}
};
@@ -506,7 +509,7 @@ GMLBase.prototype.MULTIPOLYGON_PARSERS_ = {
GMLBase.prototype.POINTMEMBER_PARSERS_ = {
'http://www.opengis.net/gml': {
'Point': _ol_xml_.makeArrayPusher(
GMLBase.prototype.readFlatCoordinatesFromNode_)
GMLBase.prototype.readFlatCoordinatesFromNode_)
}
};
@@ -519,7 +522,7 @@ GMLBase.prototype.POINTMEMBER_PARSERS_ = {
GMLBase.prototype.LINESTRINGMEMBER_PARSERS_ = {
'http://www.opengis.net/gml': {
'LineString': _ol_xml_.makeArrayPusher(
GMLBase.prototype.readLineString)
GMLBase.prototype.readLineString)
}
};
@@ -532,7 +535,7 @@ GMLBase.prototype.LINESTRINGMEMBER_PARSERS_ = {
GMLBase.prototype.POLYGONMEMBER_PARSERS_ = {
'http://www.opengis.net/gml': {
'Polygon': _ol_xml_.makeArrayPusher(
GMLBase.prototype.readPolygon)
GMLBase.prototype.readPolygon)
}
};
@@ -545,7 +548,7 @@ GMLBase.prototype.POLYGONMEMBER_PARSERS_ = {
GMLBase.prototype.RING_PARSERS = {
'http://www.opengis.net/gml': {
'LinearRing': _ol_xml_.makeReplacer(
GMLBase.prototype.readFlatLinearRing_)
GMLBase.prototype.readFlatLinearRing_)
}
};
@@ -554,8 +557,8 @@ GMLBase.prototype.RING_PARSERS = {
* @inheritDoc
*/
GMLBase.prototype.readGeometryFromNode = function(node, opt_options) {
var geometry = this.readGeometryElement(node,
[this.getReadOptions(node, opt_options ? opt_options : {})]);
const geometry = this.readGeometryElement(node,
[this.getReadOptions(node, opt_options ? opt_options : {})]);
return geometry ? geometry : null;
};
@@ -576,14 +579,14 @@ GMLBase.prototype.readFeatures;
* @inheritDoc
*/
GMLBase.prototype.readFeaturesFromNode = function(node, opt_options) {
var options = {
const options = {
featureType: this.featureType,
featureNS: this.featureNS
};
if (opt_options) {
_ol_obj_.assign(options, this.getReadOptions(node, opt_options));
}
var features = this.readFeaturesInternal(node, [options]);
const features = this.readFeaturesInternal(node, [options]);
return features || [];
};
+251 -251
View File
@@ -23,9 +23,9 @@ import _ol_xml_ from '../xml.js';
* @param {olx.format.GPXOptions=} opt_options Options.
* @api
*/
var GPX = function(opt_options) {
const GPX = function(opt_options) {
var options = opt_options ? opt_options : {};
const options = opt_options ? opt_options : {};
XMLFeature.call(this);
@@ -48,7 +48,7 @@ inherits(GPX, XMLFeature);
* @const
* @type {Array.<string>}
*/
var NAMESPACE_URIS = [
const NAMESPACE_URIS = [
null,
'http://www.topografix.com/GPX/1/0',
'http://www.topografix.com/GPX/1/1'
@@ -59,7 +59,7 @@ var NAMESPACE_URIS = [
* @const
* @type {string}
*/
var SCHEMA_LOCATION = 'http://www.topografix.com/GPX/1/1 ' +
const SCHEMA_LOCATION = 'http://www.topografix.com/GPX/1/1 ' +
'http://www.topografix.com/GPX/1/1/gpx.xsd';
@@ -67,7 +67,7 @@ var SCHEMA_LOCATION = 'http://www.topografix.com/GPX/1/1 ' +
* @const
* @type {Object.<string, function(Node, Array.<*>): (ol.Feature|undefined)>}
*/
var FEATURE_READER = {
const FEATURE_READER = {
'rte': readRte,
'trk': readTrk,
'wpt': readWpt
@@ -78,264 +78,264 @@ var FEATURE_READER = {
* @const
* @type {Object.<string, Object.<string, ol.XmlParser>>}
*/
var GPX_PARSERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'rte': _ol_xml_.makeArrayPusher(readRte),
'trk': _ol_xml_.makeArrayPusher(readTrk),
'wpt': _ol_xml_.makeArrayPusher(readWpt)
});
const GPX_PARSERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'rte': _ol_xml_.makeArrayPusher(readRte),
'trk': _ol_xml_.makeArrayPusher(readTrk),
'wpt': _ol_xml_.makeArrayPusher(readWpt)
});
/**
* @const
* @type {Object.<string, Object.<string, ol.XmlParser>>}
*/
var LINK_PARSERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'text': _ol_xml_.makeObjectPropertySetter(XSD.readString, 'linkText'),
'type': _ol_xml_.makeObjectPropertySetter(XSD.readString, 'linkType')
});
const LINK_PARSERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'text': _ol_xml_.makeObjectPropertySetter(XSD.readString, 'linkText'),
'type': _ol_xml_.makeObjectPropertySetter(XSD.readString, 'linkType')
});
/**
* @const
* @type {Object.<string, Object.<string, ol.XmlParser>>}
*/
var RTE_PARSERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'name': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'cmt': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'desc': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'src': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'link': parseLink,
'number': _ol_xml_.makeObjectPropertySetter(XSD.readNonNegativeInteger),
'extensions': parseExtensions,
'type': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'rtept': parseRtePt
});
const RTE_PARSERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'name': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'cmt': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'desc': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'src': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'link': parseLink,
'number': _ol_xml_.makeObjectPropertySetter(XSD.readNonNegativeInteger),
'extensions': parseExtensions,
'type': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'rtept': parseRtePt
});
/**
* @const
* @type {Object.<string, Object.<string, ol.XmlParser>>}
*/
var RTEPT_PARSERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'ele': _ol_xml_.makeObjectPropertySetter(XSD.readDecimal),
'time': _ol_xml_.makeObjectPropertySetter(XSD.readDateTime)
});
const RTEPT_PARSERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'ele': _ol_xml_.makeObjectPropertySetter(XSD.readDecimal),
'time': _ol_xml_.makeObjectPropertySetter(XSD.readDateTime)
});
/**
* @const
* @type {Object.<string, Object.<string, ol.XmlParser>>}
*/
var TRK_PARSERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'name': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'cmt': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'desc': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'src': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'link': parseLink,
'number': _ol_xml_.makeObjectPropertySetter(XSD.readNonNegativeInteger),
'type': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'extensions': parseExtensions,
'trkseg': parseTrkSeg
});
const TRK_PARSERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'name': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'cmt': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'desc': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'src': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'link': parseLink,
'number': _ol_xml_.makeObjectPropertySetter(XSD.readNonNegativeInteger),
'type': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'extensions': parseExtensions,
'trkseg': parseTrkSeg
});
/**
* @const
* @type {Object.<string, Object.<string, ol.XmlParser>>}
*/
var TRKSEG_PARSERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'trkpt': parseTrkPt
});
const TRKSEG_PARSERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'trkpt': parseTrkPt
});
/**
* @const
* @type {Object.<string, Object.<string, ol.XmlParser>>}
*/
var TRKPT_PARSERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'ele': _ol_xml_.makeObjectPropertySetter(XSD.readDecimal),
'time': _ol_xml_.makeObjectPropertySetter(XSD.readDateTime)
});
const TRKPT_PARSERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'ele': _ol_xml_.makeObjectPropertySetter(XSD.readDecimal),
'time': _ol_xml_.makeObjectPropertySetter(XSD.readDateTime)
});
/**
* @const
* @type {Object.<string, Object.<string, ol.XmlParser>>}
*/
var WPT_PARSERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'ele': _ol_xml_.makeObjectPropertySetter(XSD.readDecimal),
'time': _ol_xml_.makeObjectPropertySetter(XSD.readDateTime),
'magvar': _ol_xml_.makeObjectPropertySetter(XSD.readDecimal),
'geoidheight': _ol_xml_.makeObjectPropertySetter(XSD.readDecimal),
'name': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'cmt': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'desc': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'src': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'link': parseLink,
'sym': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'type': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'fix': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'sat': _ol_xml_.makeObjectPropertySetter(XSD.readNonNegativeInteger),
'hdop': _ol_xml_.makeObjectPropertySetter(XSD.readDecimal),
'vdop': _ol_xml_.makeObjectPropertySetter(XSD.readDecimal),
'pdop': _ol_xml_.makeObjectPropertySetter(XSD.readDecimal),
'ageofdgpsdata': _ol_xml_.makeObjectPropertySetter(XSD.readDecimal),
'dgpsid': _ol_xml_.makeObjectPropertySetter(XSD.readNonNegativeInteger),
'extensions': parseExtensions
});
const WPT_PARSERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'ele': _ol_xml_.makeObjectPropertySetter(XSD.readDecimal),
'time': _ol_xml_.makeObjectPropertySetter(XSD.readDateTime),
'magvar': _ol_xml_.makeObjectPropertySetter(XSD.readDecimal),
'geoidheight': _ol_xml_.makeObjectPropertySetter(XSD.readDecimal),
'name': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'cmt': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'desc': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'src': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'link': parseLink,
'sym': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'type': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'fix': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'sat': _ol_xml_.makeObjectPropertySetter(XSD.readNonNegativeInteger),
'hdop': _ol_xml_.makeObjectPropertySetter(XSD.readDecimal),
'vdop': _ol_xml_.makeObjectPropertySetter(XSD.readDecimal),
'pdop': _ol_xml_.makeObjectPropertySetter(XSD.readDecimal),
'ageofdgpsdata': _ol_xml_.makeObjectPropertySetter(XSD.readDecimal),
'dgpsid': _ol_xml_.makeObjectPropertySetter(XSD.readNonNegativeInteger),
'extensions': parseExtensions
});
/**
* @const
* @type {Array.<string>}
*/
var LINK_SEQUENCE = ['text', 'type'];
const LINK_SEQUENCE = ['text', 'type'];
/**
* @const
* @type {Object.<string, Object.<string, ol.XmlSerializer>>}
*/
var LINK_SERIALIZERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'text': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'type': _ol_xml_.makeChildAppender(XSD.writeStringTextNode)
});
const LINK_SERIALIZERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'text': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'type': _ol_xml_.makeChildAppender(XSD.writeStringTextNode)
});
/**
* @const
* @type {Object.<string, Array.<string>>}
*/
var RTE_SEQUENCE = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, [
'name', 'cmt', 'desc', 'src', 'link', 'number', 'type', 'rtept'
]);
const RTE_SEQUENCE = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, [
'name', 'cmt', 'desc', 'src', 'link', 'number', 'type', 'rtept'
]);
/**
* @const
* @type {Object.<string, Object.<string, ol.XmlSerializer>>}
*/
var RTE_SERIALIZERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'name': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'cmt': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'desc': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'src': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'link': _ol_xml_.makeChildAppender(writeLink),
'number': _ol_xml_.makeChildAppender(XSD.writeNonNegativeIntegerTextNode),
'type': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'rtept': _ol_xml_.makeArraySerializer(_ol_xml_.makeChildAppender(writeWptType))
});
const RTE_SERIALIZERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'name': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'cmt': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'desc': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'src': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'link': _ol_xml_.makeChildAppender(writeLink),
'number': _ol_xml_.makeChildAppender(XSD.writeNonNegativeIntegerTextNode),
'type': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'rtept': _ol_xml_.makeArraySerializer(_ol_xml_.makeChildAppender(writeWptType))
});
/**
* @const
* @type {Object.<string, Array.<string>>}
*/
var RTEPT_TYPE_SEQUENCE = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, [
'ele', 'time'
]);
const RTEPT_TYPE_SEQUENCE = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, [
'ele', 'time'
]);
/**
* @const
* @type {Object.<string, Array.<string>>}
*/
var TRK_SEQUENCE = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, [
'name', 'cmt', 'desc', 'src', 'link', 'number', 'type', 'trkseg'
]);
const TRK_SEQUENCE = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, [
'name', 'cmt', 'desc', 'src', 'link', 'number', 'type', 'trkseg'
]);
/**
* @const
* @type {Object.<string, Object.<string, ol.XmlSerializer>>}
*/
var TRK_SERIALIZERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'name': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'cmt': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'desc': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'src': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'link': _ol_xml_.makeChildAppender(writeLink),
'number': _ol_xml_.makeChildAppender(XSD.writeNonNegativeIntegerTextNode),
'type': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'trkseg': _ol_xml_.makeArraySerializer(_ol_xml_.makeChildAppender(writeTrkSeg))
});
const TRK_SERIALIZERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'name': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'cmt': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'desc': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'src': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'link': _ol_xml_.makeChildAppender(writeLink),
'number': _ol_xml_.makeChildAppender(XSD.writeNonNegativeIntegerTextNode),
'type': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'trkseg': _ol_xml_.makeArraySerializer(_ol_xml_.makeChildAppender(writeTrkSeg))
});
/**
* @const
* @type {function(*, Array.<*>, string=): (Node|undefined)}
*/
var TRKSEG_NODE_FACTORY = _ol_xml_.makeSimpleNodeFactory('trkpt');
const TRKSEG_NODE_FACTORY = _ol_xml_.makeSimpleNodeFactory('trkpt');
/**
* @const
* @type {Object.<string, Object.<string, ol.XmlSerializer>>}
*/
var TRKSEG_SERIALIZERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'trkpt': _ol_xml_.makeChildAppender(writeWptType)
});
const TRKSEG_SERIALIZERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'trkpt': _ol_xml_.makeChildAppender(writeWptType)
});
/**
* @const
* @type {Object.<string, Array.<string>>}
*/
var WPT_TYPE_SEQUENCE = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, [
'ele', 'time', 'magvar', 'geoidheight', 'name', 'cmt', 'desc', 'src',
'link', 'sym', 'type', 'fix', 'sat', 'hdop', 'vdop', 'pdop',
'ageofdgpsdata', 'dgpsid'
]);
const WPT_TYPE_SEQUENCE = _ol_xml_.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, ol.XmlSerializer>>}
*/
var WPT_TYPE_SERIALIZERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'ele': _ol_xml_.makeChildAppender(XSD.writeDecimalTextNode),
'time': _ol_xml_.makeChildAppender(XSD.writeDateTimeTextNode),
'magvar': _ol_xml_.makeChildAppender(XSD.writeDecimalTextNode),
'geoidheight': _ol_xml_.makeChildAppender(XSD.writeDecimalTextNode),
'name': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'cmt': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'desc': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'src': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'link': _ol_xml_.makeChildAppender(writeLink),
'sym': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'type': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'fix': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'sat': _ol_xml_.makeChildAppender(XSD.writeNonNegativeIntegerTextNode),
'hdop': _ol_xml_.makeChildAppender(XSD.writeDecimalTextNode),
'vdop': _ol_xml_.makeChildAppender(XSD.writeDecimalTextNode),
'pdop': _ol_xml_.makeChildAppender(XSD.writeDecimalTextNode),
'ageofdgpsdata': _ol_xml_.makeChildAppender(XSD.writeDecimalTextNode),
'dgpsid': _ol_xml_.makeChildAppender(XSD.writeNonNegativeIntegerTextNode)
});
const WPT_TYPE_SERIALIZERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'ele': _ol_xml_.makeChildAppender(XSD.writeDecimalTextNode),
'time': _ol_xml_.makeChildAppender(XSD.writeDateTimeTextNode),
'magvar': _ol_xml_.makeChildAppender(XSD.writeDecimalTextNode),
'geoidheight': _ol_xml_.makeChildAppender(XSD.writeDecimalTextNode),
'name': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'cmt': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'desc': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'src': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'link': _ol_xml_.makeChildAppender(writeLink),
'sym': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'type': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'fix': _ol_xml_.makeChildAppender(XSD.writeStringTextNode),
'sat': _ol_xml_.makeChildAppender(XSD.writeNonNegativeIntegerTextNode),
'hdop': _ol_xml_.makeChildAppender(XSD.writeDecimalTextNode),
'vdop': _ol_xml_.makeChildAppender(XSD.writeDecimalTextNode),
'pdop': _ol_xml_.makeChildAppender(XSD.writeDecimalTextNode),
'ageofdgpsdata': _ol_xml_.makeChildAppender(XSD.writeDecimalTextNode),
'dgpsid': _ol_xml_.makeChildAppender(XSD.writeNonNegativeIntegerTextNode)
});
/**
* @const
* @type {Object.<string, string>}
*/
var GEOMETRY_TYPE_TO_NODENAME = {
const GEOMETRY_TYPE_TO_NODENAME = {
'Point': 'wpt',
'LineString': 'rte',
'MultiLineString': 'trk'
@@ -349,11 +349,11 @@ var GEOMETRY_TYPE_TO_NODENAME = {
* @return {Node|undefined} Node.
*/
function GPX_NODE_FACTORY(value, objectStack, opt_nodeName) {
var geometry = /** @type {ol.Feature} */ (value).getGeometry();
const geometry = /** @type {ol.Feature} */ (value).getGeometry();
if (geometry) {
var nodeName = GEOMETRY_TYPE_TO_NODENAME[geometry.getType()];
const nodeName = GEOMETRY_TYPE_TO_NODENAME[geometry.getType()];
if (nodeName) {
var parentNode = objectStack[objectStack.length - 1].node;
const parentNode = objectStack[objectStack.length - 1].node;
return _ol_xml_.createElementNS(parentNode.namespaceURI, nodeName);
}
}
@@ -364,12 +364,12 @@ function GPX_NODE_FACTORY(value, objectStack, opt_nodeName) {
* @const
* @type {Object.<string, Object.<string, ol.XmlSerializer>>}
*/
var GPX_SERIALIZERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'rte': _ol_xml_.makeChildAppender(writeRte),
'trk': _ol_xml_.makeChildAppender(writeTrk),
'wpt': _ol_xml_.makeChildAppender(writeWpt)
});
const GPX_SERIALIZERS = _ol_xml_.makeStructureNS(
NAMESPACE_URIS, {
'rte': _ol_xml_.makeChildAppender(writeRte),
'trk': _ol_xml_.makeChildAppender(writeTrk),
'wpt': _ol_xml_.makeChildAppender(writeWpt)
});
/**
@@ -381,8 +381,8 @@ var GPX_SERIALIZERS = _ol_xml_.makeStructureNS(
*/
function appendCoordinate(flatCoordinates, layoutOptions, node, values) {
flatCoordinates.push(
parseFloat(node.getAttribute('lon')),
parseFloat(node.getAttribute('lat')));
parseFloat(node.getAttribute('lon')),
parseFloat(node.getAttribute('lat')));
if ('ele' in values) {
flatCoordinates.push(/** @type {number} */ (values['ele']));
delete values['ele'];
@@ -411,8 +411,8 @@ function appendCoordinate(flatCoordinates, layoutOptions, node, values) {
* @return {ol.geom.GeometryLayout} Layout.
*/
GPX.applyLayoutOptions_ = function(layoutOptions, flatCoordinates, ends) {
var layout = GeometryLayout.XY;
var stride = 2;
let layout = GeometryLayout.XY;
let stride = 2;
if (layoutOptions.hasZ && layoutOptions.hasM) {
layout = GeometryLayout.XYZM;
stride = 4;
@@ -424,7 +424,7 @@ GPX.applyLayoutOptions_ = function(layoutOptions, flatCoordinates, ends) {
stride = 3;
}
if (stride !== 4) {
var i, ii;
let i, ii;
for (i = 0, ii = flatCoordinates.length / 4; i < ii; i++) {
flatCoordinates[i * stride] = flatCoordinates[i * 4];
flatCoordinates[i * stride + 1] = flatCoordinates[i * 4 + 1];
@@ -451,8 +451,8 @@ GPX.applyLayoutOptions_ = function(layoutOptions, flatCoordinates, ends) {
* @param {Array.<*>} objectStack Object stack.
*/
function parseLink(node, objectStack) {
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
var href = node.getAttribute('href');
const values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
const href = node.getAttribute('href');
if (href !== null) {
values['link'] = href;
}
@@ -465,7 +465,7 @@ function parseLink(node, objectStack) {
* @param {Array.<*>} objectStack Object stack.
*/
function parseExtensions(node, objectStack) {
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
const values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
values['extensionsNode_'] = node;
}
@@ -475,13 +475,13 @@ function parseExtensions(node, objectStack) {
* @param {Array.<*>} objectStack Object stack.
*/
function parseRtePt(node, objectStack) {
var values = _ol_xml_.pushParseAndPop(
{}, RTEPT_PARSERS, node, objectStack);
const values = _ol_xml_.pushParseAndPop(
{}, RTEPT_PARSERS, node, objectStack);
if (values) {
var rteValues = /** @type {Object} */ (objectStack[objectStack.length - 1]);
var flatCoordinates = /** @type {Array.<number>} */
const rteValues = /** @type {Object} */ (objectStack[objectStack.length - 1]);
const flatCoordinates = /** @type {Array.<number>} */
(rteValues['flatCoordinates']);
var layoutOptions = /** @type {ol.LayoutOptions} */
const layoutOptions = /** @type {ol.LayoutOptions} */
(rteValues['layoutOptions']);
appendCoordinate(flatCoordinates, layoutOptions, node, values);
}
@@ -493,12 +493,12 @@ function parseRtePt(node, objectStack) {
* @param {Array.<*>} objectStack Object stack.
*/
function parseTrkPt(node, objectStack) {
var values = _ol_xml_.pushParseAndPop({}, TRKPT_PARSERS, node, objectStack);
const values = _ol_xml_.pushParseAndPop({}, TRKPT_PARSERS, node, objectStack);
if (values) {
var trkValues = /** @type {Object} */ (objectStack[objectStack.length - 1]);
var flatCoordinates = /** @type {Array.<number>} */
const trkValues = /** @type {Object} */ (objectStack[objectStack.length - 1]);
const flatCoordinates = /** @type {Array.<number>} */
(trkValues['flatCoordinates']);
var layoutOptions = /** @type {ol.LayoutOptions} */
const layoutOptions = /** @type {ol.LayoutOptions} */
(trkValues['layoutOptions']);
appendCoordinate(flatCoordinates, layoutOptions, node, values);
}
@@ -510,11 +510,11 @@ function parseTrkPt(node, objectStack) {
* @param {Array.<*>} objectStack Object stack.
*/
function parseTrkSeg(node, objectStack) {
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
const values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
_ol_xml_.parseNode(TRKSEG_PARSERS, node, objectStack);
var flatCoordinates = /** @type {Array.<number>} */
const flatCoordinates = /** @type {Array.<number>} */
(values['flatCoordinates']);
var ends = /** @type {Array.<number>} */ (values['ends']);
const ends = /** @type {Array.<number>} */ (values['ends']);
ends.push(flatCoordinates.length);
}
@@ -525,24 +525,24 @@ function parseTrkSeg(node, objectStack) {
* @return {ol.Feature|undefined} Track.
*/
function readRte(node, objectStack) {
var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
var values = _ol_xml_.pushParseAndPop({
const options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
const values = _ol_xml_.pushParseAndPop({
'flatCoordinates': [],
'layoutOptions': {}
}, RTE_PARSERS, node, objectStack);
if (!values) {
return undefined;
}
var flatCoordinates = /** @type {Array.<number>} */
const flatCoordinates = /** @type {Array.<number>} */
(values['flatCoordinates']);
delete values['flatCoordinates'];
var layoutOptions = /** @type {ol.LayoutOptions} */ (values['layoutOptions']);
const layoutOptions = /** @type {ol.LayoutOptions} */ (values['layoutOptions']);
delete values['layoutOptions'];
var layout = GPX.applyLayoutOptions_(layoutOptions, flatCoordinates);
var geometry = new LineString(null);
const layout = GPX.applyLayoutOptions_(layoutOptions, flatCoordinates);
const geometry = new LineString(null);
geometry.setFlatCoordinates(layout, flatCoordinates);
transformWithOptions(geometry, false, options);
var feature = new Feature(geometry);
const feature = new Feature(geometry);
feature.setProperties(values);
return feature;
}
@@ -554,8 +554,8 @@ function readRte(node, objectStack) {
* @return {ol.Feature|undefined} Track.
*/
function readTrk(node, objectStack) {
var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
var values = _ol_xml_.pushParseAndPop({
const options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
const values = _ol_xml_.pushParseAndPop({
'flatCoordinates': [],
'ends': [],
'layoutOptions': {}
@@ -563,18 +563,18 @@ function readTrk(node, objectStack) {
if (!values) {
return undefined;
}
var flatCoordinates = /** @type {Array.<number>} */
const flatCoordinates = /** @type {Array.<number>} */
(values['flatCoordinates']);
delete values['flatCoordinates'];
var ends = /** @type {Array.<number>} */ (values['ends']);
const ends = /** @type {Array.<number>} */ (values['ends']);
delete values['ends'];
var layoutOptions = /** @type {ol.LayoutOptions} */ (values['layoutOptions']);
const layoutOptions = /** @type {ol.LayoutOptions} */ (values['layoutOptions']);
delete values['layoutOptions'];
var layout = GPX.applyLayoutOptions_(layoutOptions, flatCoordinates, ends);
var geometry = new MultiLineString(null);
const layout = GPX.applyLayoutOptions_(layoutOptions, flatCoordinates, ends);
const geometry = new MultiLineString(null);
geometry.setFlatCoordinates(layout, flatCoordinates, ends);
transformWithOptions(geometry, false, options);
var feature = new Feature(geometry);
const feature = new Feature(geometry);
feature.setProperties(values);
return feature;
}
@@ -586,17 +586,17 @@ function readTrk(node, objectStack) {
* @return {ol.Feature|undefined} Waypoint.
*/
function readWpt(node, objectStack) {
var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
var values = _ol_xml_.pushParseAndPop({}, WPT_PARSERS, node, objectStack);
const options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
const values = _ol_xml_.pushParseAndPop({}, WPT_PARSERS, node, objectStack);
if (!values) {
return undefined;
}
var layoutOptions = /** @type {ol.LayoutOptions} */ ({});
var coordinates = appendCoordinate([], layoutOptions, node, values);
var layout = GPX.applyLayoutOptions_(layoutOptions, coordinates);
var geometry = new Point(coordinates, layout);
const layoutOptions = /** @type {ol.LayoutOptions} */ ({});
const coordinates = appendCoordinate([], layoutOptions, node, values);
const layout = GPX.applyLayoutOptions_(layoutOptions, coordinates);
const geometry = new Point(coordinates, layout);
transformWithOptions(geometry, false, options);
var feature = new Feature(geometry);
const feature = new Feature(geometry);
feature.setProperties(values);
return feature;
}
@@ -610,10 +610,10 @@ GPX.prototype.handleReadExtensions_ = function(features) {
if (!features) {
features = [];
}
for (var i = 0, ii = features.length; i < ii; ++i) {
var feature = features[i];
for (let i = 0, ii = features.length; i < ii; ++i) {
const feature = features[i];
if (this.readExtensions_) {
var extensionsNode = feature.get('extensionsNode_') || null;
const extensionsNode = feature.get('extensionsNode_') || null;
this.readExtensions_(feature, extensionsNode);
}
feature.set('extensionsNode_', undefined);
@@ -642,11 +642,11 @@ GPX.prototype.readFeatureFromNode = function(node, opt_options) {
if (!includes(NAMESPACE_URIS, node.namespaceURI)) {
return null;
}
var featureReader = FEATURE_READER[node.localName];
const featureReader = FEATURE_READER[node.localName];
if (!featureReader) {
return null;
}
var feature = featureReader(node, [this.getReadOptions(node, opt_options)]);
const feature = featureReader(node, [this.getReadOptions(node, opt_options)]);
if (!feature) {
return null;
}
@@ -678,8 +678,8 @@ GPX.prototype.readFeaturesFromNode = function(node, opt_options) {
}
if (node.localName == 'gpx') {
/** @type {Array.<ol.Feature>} */
var features = _ol_xml_.pushParseAndPop([], GPX_PARSERS,
node, [this.getReadOptions(node, opt_options)]);
const features = _ol_xml_.pushParseAndPop([], GPX_PARSERS,
node, [this.getReadOptions(node, opt_options)]);
if (features) {
this.handleReadExtensions_(features);
return features;
@@ -709,15 +709,15 @@ GPX.prototype.readProjection;
*/
function writeLink(node, value, objectStack) {
node.setAttribute('href', value);
var context = objectStack[objectStack.length - 1];
var properties = context['properties'];
var link = [
const context = objectStack[objectStack.length - 1];
const properties = context['properties'];
const link = [
properties['linkText'],
properties['linkType']
];
_ol_xml_.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */ ({node: node}),
LINK_SERIALIZERS, _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY,
link, objectStack, LINK_SEQUENCE);
LINK_SERIALIZERS, _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY,
link, objectStack, LINK_SEQUENCE);
}
@@ -727,14 +727,14 @@ function writeLink(node, value, objectStack) {
* @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'];
const context = objectStack[objectStack.length - 1];
const parentNode = context.node;
const namespaceURI = parentNode.namespaceURI;
const properties = context['properties'];
//FIXME Projection handling
_ol_xml_.setAttributeNS(node, null, 'lat', coordinate[1]);
_ol_xml_.setAttributeNS(node, null, 'lon', coordinate[0]);
var geometryLayout = context['geometryLayout'];
const geometryLayout = context['geometryLayout'];
switch (geometryLayout) {
case GeometryLayout.XYZM:
if (coordinate[3] !== 0) {
@@ -754,14 +754,14 @@ function writeWptType(node, coordinate, objectStack) {
default:
// pass
}
var orderedKeys = (node.nodeName == 'rtept') ?
const orderedKeys = (node.nodeName == 'rtept') ?
RTEPT_TYPE_SEQUENCE[namespaceURI] :
WPT_TYPE_SEQUENCE[namespaceURI];
var values = _ol_xml_.makeSequence(properties, orderedKeys);
const values = _ol_xml_.makeSequence(properties, orderedKeys);
_ol_xml_.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */
({node: node, 'properties': properties}),
WPT_TYPE_SERIALIZERS, _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY,
values, objectStack, orderedKeys);
({node: node, 'properties': properties}),
WPT_TYPE_SERIALIZERS, _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY,
values, objectStack, orderedKeys);
}
@@ -771,21 +771,21 @@ function writeWptType(node, coordinate, objectStack) {
* @param {Array.<*>} objectStack Object stack.
*/
function writeRte(node, feature, objectStack) {
var options = /** @type {olx.format.WriteOptions} */ (objectStack[0]);
var properties = feature.getProperties();
var context = {node: node, 'properties': properties};
var geometry = feature.getGeometry();
const options = /** @type {olx.format.WriteOptions} */ (objectStack[0]);
const properties = feature.getProperties();
const context = {node: node, 'properties': properties};
let geometry = feature.getGeometry();
if (geometry) {
geometry = /** @type {ol.geom.LineString} */ (transformWithOptions(geometry, true, options));
context['geometryLayout'] = geometry.getLayout();
properties['rtept'] = geometry.getCoordinates();
}
var parentNode = objectStack[objectStack.length - 1].node;
var orderedKeys = RTE_SEQUENCE[parentNode.namespaceURI];
var values = _ol_xml_.makeSequence(properties, orderedKeys);
const parentNode = objectStack[objectStack.length - 1].node;
const orderedKeys = RTE_SEQUENCE[parentNode.namespaceURI];
const values = _ol_xml_.makeSequence(properties, orderedKeys);
_ol_xml_.pushSerializeAndPop(context,
RTE_SERIALIZERS, _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY,
values, objectStack, orderedKeys);
RTE_SERIALIZERS, _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY,
values, objectStack, orderedKeys);
}
@@ -795,22 +795,22 @@ function writeRte(node, feature, objectStack) {
* @param {Array.<*>} objectStack Object stack.
*/
function writeTrk(node, feature, objectStack) {
var options = /** @type {olx.format.WriteOptions} */ (objectStack[0]);
var properties = feature.getProperties();
const options = /** @type {olx.format.WriteOptions} */ (objectStack[0]);
const properties = feature.getProperties();
/** @type {ol.XmlNodeStackItem} */
var context = {node: node, 'properties': properties};
var geometry = feature.getGeometry();
const context = {node: node, 'properties': properties};
let geometry = feature.getGeometry();
if (geometry) {
geometry = /** @type {ol.geom.MultiLineString} */
(transformWithOptions(geometry, true, options));
properties['trkseg'] = geometry.getLineStrings();
}
var parentNode = objectStack[objectStack.length - 1].node;
var orderedKeys = TRK_SEQUENCE[parentNode.namespaceURI];
var values = _ol_xml_.makeSequence(properties, orderedKeys);
const parentNode = objectStack[objectStack.length - 1].node;
const orderedKeys = TRK_SEQUENCE[parentNode.namespaceURI];
const values = _ol_xml_.makeSequence(properties, orderedKeys);
_ol_xml_.pushSerializeAndPop(context,
TRK_SERIALIZERS, _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY,
values, objectStack, orderedKeys);
TRK_SERIALIZERS, _ol_xml_.OBJECT_PROPERTY_NODE_FACTORY,
values, objectStack, orderedKeys);
}
@@ -821,11 +821,11 @@ function writeTrk(node, feature, objectStack) {
*/
function writeTrkSeg(node, lineString, objectStack) {
/** @type {ol.XmlNodeStackItem} */
var context = {node: node, 'geometryLayout': lineString.getLayout(),
const context = {node: node, 'geometryLayout': lineString.getLayout(),
'properties': {}};
_ol_xml_.pushSerializeAndPop(context,
TRKSEG_SERIALIZERS, TRKSEG_NODE_FACTORY,
lineString.getCoordinates(), objectStack);
TRKSEG_SERIALIZERS, TRKSEG_NODE_FACTORY,
lineString.getCoordinates(), objectStack);
}
@@ -835,10 +835,10 @@ function writeTrkSeg(node, lineString, objectStack) {
* @param {Array.<*>} objectStack Object stack.
*/
function writeWpt(node, feature, objectStack) {
var options = /** @type {olx.format.WriteOptions} */ (objectStack[0]);
var context = objectStack[objectStack.length - 1];
const options = /** @type {olx.format.WriteOptions} */ (objectStack[0]);
const context = objectStack[objectStack.length - 1];
context['properties'] = feature.getProperties();
var geometry = feature.getGeometry();
let geometry = feature.getGeometry();
if (geometry) {
geometry = /** @type {ol.geom.Point} */
(transformWithOptions(geometry, true, options));
@@ -876,17 +876,17 @@ GPX.prototype.writeFeatures;
GPX.prototype.writeFeaturesNode = function(features, opt_options) {
opt_options = this.adaptOptions(opt_options);
//FIXME Serialize metadata
var gpx = _ol_xml_.createElementNS('http://www.topografix.com/GPX/1/1', 'gpx');
var xmlnsUri = 'http://www.w3.org/2000/xmlns/';
var xmlSchemaInstanceUri = 'http://www.w3.org/2001/XMLSchema-instance';
const gpx = _ol_xml_.createElementNS('http://www.topografix.com/GPX/1/1', 'gpx');
const xmlnsUri = 'http://www.w3.org/2000/xmlns/';
const xmlSchemaInstanceUri = 'http://www.w3.org/2001/XMLSchema-instance';
_ol_xml_.setAttributeNS(gpx, xmlnsUri, 'xmlns:xsi', xmlSchemaInstanceUri);
_ol_xml_.setAttributeNS(gpx, xmlSchemaInstanceUri, 'xsi:schemaLocation',
SCHEMA_LOCATION);
SCHEMA_LOCATION);
gpx.setAttribute('version', '1.1');
gpx.setAttribute('creator', 'OpenLayers');
_ol_xml_.pushSerializeAndPop(/** @type {ol.XmlNodeStackItem} */
({node: gpx}), GPX_SERIALIZERS, GPX_NODE_FACTORY, features, [opt_options]);
({node: gpx}), GPX_SERIALIZERS, GPX_NODE_FACTORY, features, [opt_options]);
return gpx;
};
export default GPX;
+36 -36
View File
@@ -28,9 +28,9 @@ import {get as getProjection} from '../proj.js';
* @param {olx.format.GeoJSONOptions=} opt_options Options.
* @api
*/
var GeoJSON = function(opt_options) {
const GeoJSON = function(opt_options) {
var options = opt_options ? opt_options : {};
const options = opt_options ? opt_options : {};
JSONFeature.call(this);
@@ -38,8 +38,8 @@ var GeoJSON = function(opt_options) {
* @inheritDoc
*/
this.defaultDataProjection = getProjection(
options.defaultDataProjection ?
options.defaultDataProjection : 'EPSG:4326');
options.defaultDataProjection ?
options.defaultDataProjection : 'EPSG:4326');
if (options.featureProjection) {
@@ -69,7 +69,7 @@ inherits(GeoJSON, JSONFeature);
* @const
* @type {Object.<string, function(GeoJSONObject): ol.geom.Geometry>}
*/
var GEOMETRY_READERS = {
const GEOMETRY_READERS = {
'Point': readPointGeometry,
'LineString': readLineStringGeometry,
'Polygon': readPolygonGeometry,
@@ -84,7 +84,7 @@ var GEOMETRY_READERS = {
* @const
* @type {Object.<string, function(ol.geom.Geometry, olx.format.WriteOptions=): (GeoJSONGeometry|GeoJSONGeometryCollection)>}
*/
var GEOMETRY_WRITERS = {
const GEOMETRY_WRITERS = {
'Point': writePointGeometry,
'LineString': writeLineStringGeometry,
'Polygon': writePolygonGeometry,
@@ -105,10 +105,10 @@ function readGeometry(object, opt_options) {
if (!object) {
return null;
}
var geometryReader = GEOMETRY_READERS[object.type];
const geometryReader = GEOMETRY_READERS[object.type];
return (
/** @type {ol.geom.Geometry} */ transformWithOptions(
geometryReader(object), false, opt_options)
geometryReader(object), false, opt_options)
);
}
@@ -119,14 +119,14 @@ function readGeometry(object, opt_options) {
* @return {ol.geom.GeometryCollection} Geometry collection.
*/
function readGeometryCollectionGeometry(object, opt_options) {
var geometries = object.geometries.map(
/**
const geometries = object.geometries.map(
/**
* @param {GeoJSONGeometry} geometry Geometry.
* @return {ol.geom.Geometry} geometry Geometry.
*/
function(geometry) {
return readGeometry(geometry, opt_options);
});
function(geometry) {
return readGeometry(geometry, opt_options);
});
return new GeometryCollection(geometries);
}
@@ -191,7 +191,7 @@ function readPolygonGeometry(object) {
* @return {GeoJSONGeometry|GeoJSONGeometryCollection} GeoJSON geometry.
*/
function writeGeometry(geometry, opt_options) {
var geometryWriter = GEOMETRY_WRITERS[geometry.getType()];
const geometryWriter = GEOMETRY_WRITERS[geometry.getType()];
return geometryWriter(/** @type {ol.geom.Geometry} */ (
transformWithOptions(geometry, true, opt_options)), opt_options);
}
@@ -215,8 +215,8 @@ function writeEmptyGeometryCollectionGeometry(geometry) {
* @return {GeoJSONGeometryCollection} GeoJSON geometry collection.
*/
function writeGeometryCollectionGeometry(geometry, opt_options) {
var geometries = geometry.getGeometriesArray().map(function(geometry) {
var options = _ol_obj_.assign({}, opt_options);
const geometries = geometry.getGeometriesArray().map(function(geometry) {
const options = _ol_obj_.assign({}, opt_options);
delete options.featureProjection;
return writeGeometry(geometry, options);
});
@@ -272,7 +272,7 @@ function writeMultiPointGeometry(geometry, opt_options) {
* @return {GeoJSONGeometry} GeoJSON geometry.
*/
function writeMultiPolygonGeometry(geometry, opt_options) {
var right;
let right;
if (opt_options) {
right = opt_options.rightHanded;
}
@@ -302,7 +302,7 @@ function writePointGeometry(geometry, opt_options) {
* @return {GeoJSONGeometry} GeoJSON geometry.
*/
function writePolygonGeometry(geometry, opt_options) {
var right;
let right;
if (opt_options) {
right = opt_options.rightHanded;
}
@@ -349,7 +349,7 @@ GeoJSON.prototype.readFeatureFromObject = function(object, opt_options) {
/**
* @type {GeoJSONFeature}
*/
var geoJSONFeature = null;
let geoJSONFeature = null;
if (object.type === 'Feature') {
geoJSONFeature = /** @type {GeoJSONFeature} */ (object);
} else {
@@ -359,8 +359,8 @@ GeoJSON.prototype.readFeatureFromObject = function(object, opt_options) {
});
}
var geometry = readGeometry(geoJSONFeature.geometry, opt_options);
var feature = new Feature();
const geometry = readGeometry(geoJSONFeature.geometry, opt_options);
const feature = new Feature();
if (this.geometryName_) {
feature.setGeometryName(this.geometryName_);
} else if (this.extractGeometryName_ && geoJSONFeature.geometry_name !== undefined) {
@@ -381,18 +381,18 @@ GeoJSON.prototype.readFeatureFromObject = function(object, opt_options) {
* @inheritDoc
*/
GeoJSON.prototype.readFeaturesFromObject = function(object, opt_options) {
var geoJSONObject = /** @type {GeoJSONObject} */ (object);
const geoJSONObject = /** @type {GeoJSONObject} */ (object);
/** @type {Array.<ol.Feature>} */
var features = null;
let features = null;
if (geoJSONObject.type === 'FeatureCollection') {
var geoJSONFeatureCollection = /** @type {GeoJSONFeatureCollection} */
const geoJSONFeatureCollection = /** @type {GeoJSONFeatureCollection} */
(object);
features = [];
var geoJSONFeatures = geoJSONFeatureCollection.features;
var i, ii;
const geoJSONFeatures = geoJSONFeatureCollection.features;
let i, ii;
for (i = 0, ii = geoJSONFeatures.length; i < ii; ++i) {
features.push(this.readFeatureFromObject(geoJSONFeatures[i],
opt_options));
opt_options));
}
} else {
features = [this.readFeatureFromObject(object, opt_options)];
@@ -436,9 +436,9 @@ GeoJSON.prototype.readProjection;
* @inheritDoc
*/
GeoJSON.prototype.readProjectionFromObject = function(object) {
var geoJSONObject = /** @type {GeoJSONObject} */ (object);
var crs = geoJSONObject.crs;
var projection;
const geoJSONObject = /** @type {GeoJSONObject} */ (object);
const crs = geoJSONObject.crs;
let projection;
if (crs) {
if (crs.type == 'name') {
projection = getProjection(crs.properties.name);
@@ -477,20 +477,20 @@ GeoJSON.prototype.writeFeature;
GeoJSON.prototype.writeFeatureObject = function(feature, opt_options) {
opt_options = this.adaptOptions(opt_options);
var object = /** @type {GeoJSONFeature} */ ({
const object = /** @type {GeoJSONFeature} */ ({
'type': 'Feature'
});
var id = feature.getId();
const id = feature.getId();
if (id !== undefined) {
object.id = id;
}
var geometry = feature.getGeometry();
const geometry = feature.getGeometry();
if (geometry) {
object.geometry = writeGeometry(geometry, opt_options);
} else {
object.geometry = null;
}
var properties = feature.getProperties();
const properties = feature.getProperties();
delete properties[feature.getGeometryName()];
if (!_ol_obj_.isEmpty(properties)) {
object.properties = properties;
@@ -524,8 +524,8 @@ GeoJSON.prototype.writeFeatures;
*/
GeoJSON.prototype.writeFeaturesObject = function(features, opt_options) {
opt_options = this.adaptOptions(opt_options);
var objects = [];
var i, ii;
const objects = [];
let i, ii;
for (i = 0, ii = features.length; i < ii; ++i) {
objects.push(this.writeFeatureObject(features[i], opt_options));
}
+29 -29
View File
@@ -13,7 +13,7 @@ import {get as getProjection} from '../proj.js';
* IGC altitude/z. One of 'barometric', 'gps', 'none'.
* @enum {string}
*/
var IGCZ = {
const IGCZ = {
BAROMETRIC: 'barometric',
GPS: 'gps',
NONE: 'none'
@@ -28,9 +28,9 @@ var IGCZ = {
* @param {olx.format.IGCOptions=} opt_options Options.
* @api
*/
var IGC = function(opt_options) {
const IGC = function(opt_options) {
var options = opt_options ? opt_options : {};
const options = opt_options ? opt_options : {};
TextFeature.call(this);
@@ -53,7 +53,7 @@ inherits(IGC, TextFeature);
* @const
* @type {RegExp}
*/
var B_RECORD_RE =
const 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})/;
@@ -61,14 +61,14 @@ var B_RECORD_RE =
* @const
* @type {RegExp}
*/
var H_RECORD_RE = /^H.([A-Z]{3}).*?:(.*)/;
const H_RECORD_RE = /^H.([A-Z]{3}).*?:(.*)/;
/**
* @const
* @type {RegExp}
*/
var HFDTE_RECORD_RE = /^HFDTE(\d{2})(\d{2})(\d{2})/;
const HFDTE_RECORD_RE = /^HFDTE(\d{2})(\d{2})(\d{2})/;
/**
@@ -77,7 +77,7 @@ var HFDTE_RECORD_RE = /^HFDTE(\d{2})(\d{2})(\d{2})/;
* @const
* @type {RegExp}
*/
var NEWLINE_RE = /\r\n|\r|\n/;
const NEWLINE_RE = /\r\n|\r|\n/;
/**
@@ -96,36 +96,36 @@ IGC.prototype.readFeature;
* @inheritDoc
*/
IGC.prototype.readFeatureFromText = function(text, opt_options) {
var altitudeMode = this.altitudeMode_;
var lines = text.split(NEWLINE_RE);
const altitudeMode = this.altitudeMode_;
const 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;
const properties = {};
const flatCoordinates = [];
let year = 2000;
let month = 0;
let day = 1;
let lastDateTime = -1;
let i, ii;
for (i = 0, ii = lines.length; i < ii; ++i) {
var line = lines[i];
var m;
const line = lines[i];
let m;
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;
const hour = parseInt(m[1], 10);
const minute = parseInt(m[2], 10);
const second = parseInt(m[3], 10);
let y = parseInt(m[4], 10) + parseInt(m[5], 10) / 60000;
if (m[6] == 'S') {
y = -y;
}
var x = parseInt(m[7], 10) + parseInt(m[8], 10) / 60000;
let 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;
let z;
if (altitudeMode == IGCZ.GPS) {
z = parseInt(m[11], 10);
} else if (altitudeMode == IGCZ.BAROMETRIC) {
@@ -135,7 +135,7 @@ IGC.prototype.readFeatureFromText = function(text, opt_options) {
}
flatCoordinates.push(z);
}
var dateTime = Date.UTC(year, month, day, hour, minute, second);
let 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);
@@ -160,10 +160,10 @@ IGC.prototype.readFeatureFromText = function(text, opt_options) {
if (flatCoordinates.length === 0) {
return null;
}
var lineString = new LineString(null);
var layout = altitudeMode == IGCZ.NONE ? GeometryLayout.XYM : GeometryLayout.XYZM;
const lineString = new LineString(null);
const layout = altitudeMode == IGCZ.NONE ? GeometryLayout.XYM : GeometryLayout.XYZM;
lineString.setFlatCoordinates(layout, flatCoordinates);
var feature = new Feature(transformWithOptions(lineString, false, opt_options));
const feature = new Feature(transformWithOptions(lineString, false, opt_options));
feature.setProperties(properties);
return feature;
};
@@ -186,7 +186,7 @@ IGC.prototype.readFeatures;
* @inheritDoc
*/
IGC.prototype.readFeaturesFromText = function(text, opt_options) {
var feature = this.readFeatureFromText(text, opt_options);
const feature = this.readFeatureFromText(text, opt_options);
if (feature) {
return [feature];
} else {
+5 -5
View File
@@ -15,7 +15,7 @@ import FormatType from '../format/FormatType.js';
* @abstract
* @extends {ol.format.Feature}
*/
var JSONFeature = function() {
const JSONFeature = function() {
FeatureFormat.call(this);
};
@@ -28,7 +28,7 @@ inherits(JSONFeature, FeatureFormat);
*/
function getObject(source) {
if (typeof source === 'string') {
var object = JSON.parse(source);
const object = JSON.parse(source);
return object ? /** @type {Object} */ (object) : null;
} else if (source !== null) {
return source;
@@ -51,7 +51,7 @@ JSONFeature.prototype.getType = function() {
*/
JSONFeature.prototype.readFeature = function(source, opt_options) {
return this.readFeatureFromObject(
getObject(source), this.getReadOptions(source, opt_options));
getObject(source), this.getReadOptions(source, opt_options));
};
@@ -60,7 +60,7 @@ JSONFeature.prototype.readFeature = function(source, opt_options) {
*/
JSONFeature.prototype.readFeatures = function(source, opt_options) {
return this.readFeaturesFromObject(
getObject(source), this.getReadOptions(source, opt_options));
getObject(source), this.getReadOptions(source, opt_options));
};
@@ -89,7 +89,7 @@ JSONFeature.prototype.readFeaturesFromObject = function(object, opt_options) {};
*/
JSONFeature.prototype.readGeometry = function(source, opt_options) {
return this.readGeometryFromObject(
getObject(source), this.getReadOptions(source, opt_options));
getObject(source), this.getReadOptions(source, opt_options));
};
+649 -648
View File
File diff suppressed because it is too large Load Diff
+43 -44
View File
@@ -30,11 +30,11 @@ import RenderFeature from '../render/Feature.js';
* @param {olx.format.MVTOptions=} opt_options Options.
* @api
*/
var MVT = function(opt_options) {
const MVT = function(opt_options) {
FeatureFormat.call(this);
var options = opt_options ? opt_options : {};
const options = opt_options ? opt_options : {};
/**
* @type {ol.proj.Projection}
@@ -89,12 +89,12 @@ inherits(MVT, FeatureFormat);
MVT.pbfReaders_ = {
layers: function(tag, layers, pbf) {
if (tag === 3) {
var layer = {
const layer = {
keys: [],
values: [],
features: []
};
var end = pbf.readVarint() + pbf.pos;
const end = pbf.readVarint() + pbf.pos;
pbf.readFields(MVT.pbfReaders_.layer, layer, end);
layer.length = layer.features.length;
if (layer.length) {
@@ -114,8 +114,8 @@ MVT.pbfReaders_ = {
} else if (tag === 3) {
layer.keys.push(pbf.readString());
} else if (tag === 4) {
var value = null;
var end = pbf.readVarint() + pbf.pos;
let value = null;
const end = pbf.readVarint() + pbf.pos;
while (pbf.pos < end) {
tag = pbf.readVarint() >> 3;
value = tag === 1 ? pbf.readString() :
@@ -133,10 +133,10 @@ MVT.pbfReaders_ = {
if (tag == 1) {
feature.id = pbf.readVarint();
} else if (tag == 2) {
var end = pbf.readVarint() + pbf.pos;
const end = pbf.readVarint() + pbf.pos;
while (pbf.pos < end) {
var key = feature.layer.keys[pbf.readVarint()];
var value = feature.layer.values[pbf.readVarint()];
const key = feature.layer.keys[pbf.readVarint()];
const value = feature.layer.values[pbf.readVarint()];
feature.properties[key] = value;
}
} else if (tag == 3) {
@@ -159,9 +159,9 @@ MVT.pbfReaders_ = {
*/
MVT.readRawFeature_ = function(pbf, layer, i) {
pbf.pos = layer.features[i];
var end = pbf.readVarint() + pbf.pos;
const end = pbf.readVarint() + pbf.pos;
var feature = {
const feature = {
layer: layer,
type: 0,
properties: {}
@@ -184,17 +184,17 @@ MVT.readRawFeature_ = function(pbf, layer, i) {
MVT.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;
const end = pbf.readVarint() + pbf.pos;
let cmd = 1;
let length = 0;
let x = 0;
let y = 0;
let coordsLen = 0;
let currentEnd = 0;
while (pbf.pos < end) {
if (!length) {
var cmdLen = pbf.readVarint();
const cmdLen = pbf.readVarint();
cmd = cmdLen & 0x7;
length = cmdLen >> 3;
}
@@ -220,7 +220,7 @@ MVT.readRawGeometry_ = function(pbf, feature, flatCoordinates, ends) {
if (coordsLen > currentEnd) {
// close polygon
flatCoordinates.push(
flatCoordinates[currentEnd], flatCoordinates[currentEnd + 1]);
flatCoordinates[currentEnd], flatCoordinates[currentEnd + 1]);
coordsLen += 2;
}
@@ -247,7 +247,7 @@ MVT.readRawGeometry_ = function(pbf, feature, flatCoordinates, ends) {
*/
MVT.getGeometryType_ = function(type, numEnds) {
/** @type {ol.geom.GeometryType} */
var geometryType;
let geometryType;
if (type === 1) {
geometryType = numEnds === 1 ?
GeometryType.POINT : GeometryType.MULTI_POINT;
@@ -271,32 +271,32 @@ MVT.getGeometryType_ = function(type, numEnds) {
* @return {ol.Feature|ol.render.Feature} Feature.
*/
MVT.prototype.createFeature_ = function(pbf, rawFeature, opt_options) {
var type = rawFeature.type;
const type = rawFeature.type;
if (type === 0) {
return null;
}
var feature;
var id = rawFeature.id;
var values = rawFeature.properties;
let feature;
const id = rawFeature.id;
const values = rawFeature.properties;
values[this.layerName_] = rawFeature.layer.name;
var flatCoordinates = [];
var ends = [];
const flatCoordinates = [];
let ends = [];
MVT.readRawGeometry_(pbf, rawFeature, flatCoordinates, ends);
var geometryType = MVT.getGeometryType_(type, ends.length);
const geometryType = MVT.getGeometryType_(type, ends.length);
if (this.featureClass_ === RenderFeature) {
feature = new this.featureClass_(geometryType, flatCoordinates, ends, values, id);
} else {
var geom;
let geom;
if (geometryType == GeometryType.POLYGON) {
var endss = [];
var offset = 0;
var prevEndIndex = 0;
for (var i = 0, ii = ends.length; i < ii; ++i) {
var end = ends[i];
const endss = [];
let offset = 0;
let prevEndIndex = 0;
for (let i = 0, ii = ends.length; i < ii; ++i) {
const end = ends[i];
if (!_ol_geom_flat_orient_.linearRingIsClockwise(flatCoordinates, offset, end, 2)) {
endss.push(ends.slice(prevEndIndex, i));
prevEndIndex = i;
@@ -322,7 +322,7 @@ MVT.prototype.createFeature_ = function(pbf, rawFeature, opt_options) {
if (this.geometryName_) {
feature.setGeometryName(this.geometryName_);
}
var geometry = transformWithOptions(geom, false, this.adaptOptions(opt_options));
const geometry = transformWithOptions(geom, false, this.adaptOptions(opt_options));
feature.setGeometry(geometry);
feature.setId(id);
feature.setProperties(values);
@@ -354,22 +354,21 @@ MVT.prototype.getType = function() {
* @api
*/
MVT.prototype.readFeatures = function(source, opt_options) {
var layers = this.layers_;
const layers = this.layers_;
var pbf = new PBF(/** @type {ArrayBuffer} */ (source));
var pbfLayers = pbf.readFields(MVT.pbfReaders_.layers, {});
const pbf = new PBF(/** @type {ArrayBuffer} */ (source));
const pbfLayers = pbf.readFields(MVT.pbfReaders_.layers, {});
/** @type {Array.<ol.Feature|ol.render.Feature>} */
var features = [];
var pbfLayer;
for (var name in pbfLayers) {
const features = [];
let pbfLayer;
for (const name in pbfLayers) {
if (layers && layers.indexOf(name) == -1) {
continue;
}
pbfLayer = pbfLayers[name];
var rawFeature;
for (var i = 0, ii = pbfLayer.length; i < ii; ++i) {
rawFeature = MVT.readRawFeature_(pbf, pbfLayer, i);
for (let i = 0, ii = pbfLayer.length; i < ii; ++i) {
const rawFeature = MVT.readRawFeature_(pbf, pbfLayer, i);
features.push(this.createFeature_(pbf, rawFeature));
}
this.extent_ = pbfLayer ? [0, 0, pbfLayer.extent, pbfLayer.extent] : null;
+34 -34
View File
@@ -24,7 +24,7 @@ import _ol_xml_ from '../xml.js';
* @extends {ol.format.XMLFeature}
* @api
*/
var OSMXML = function() {
const OSMXML = function() {
XMLFeature.call(this);
/**
@@ -42,23 +42,23 @@ inherits(OSMXML, XMLFeature);
* @private
*/
OSMXML.readNode_ = function(node, objectStack) {
var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
var state = /** @type {Object} */ (objectStack[objectStack.length - 1]);
var id = node.getAttribute('id');
const options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
const state = /** @type {Object} */ (objectStack[objectStack.length - 1]);
const id = node.getAttribute('id');
/** @type {ol.Coordinate} */
var coordinates = [
const coordinates = [
parseFloat(node.getAttribute('lon')),
parseFloat(node.getAttribute('lat'))
];
state.nodes[id] = coordinates;
var values = _ol_xml_.pushParseAndPop({
const values = _ol_xml_.pushParseAndPop({
tags: {}
}, OSMXML.NODE_PARSERS_, node, objectStack);
if (!_ol_obj_.isEmpty(values.tags)) {
var geometry = new Point(coordinates);
const geometry = new Point(coordinates);
transformWithOptions(geometry, false, options);
var feature = new Feature(geometry);
const feature = new Feature(geometry);
feature.setId(id);
feature.setProperties(values.tags);
state.features.push(feature);
@@ -72,13 +72,13 @@ OSMXML.readNode_ = function(node, objectStack) {
* @private
*/
OSMXML.readWay_ = function(node, objectStack) {
var id = node.getAttribute('id');
var values = _ol_xml_.pushParseAndPop({
const id = node.getAttribute('id');
const values = _ol_xml_.pushParseAndPop({
id: id,
ndrefs: [],
tags: {}
}, OSMXML.WAY_PARSERS_, node, objectStack);
var state = /** @type {Object} */ (objectStack[objectStack.length - 1]);
const state = /** @type {Object} */ (objectStack[objectStack.length - 1]);
state.ways.push(values);
};
@@ -89,7 +89,7 @@ OSMXML.readWay_ = function(node, objectStack) {
* @private
*/
OSMXML.readNd_ = function(node, objectStack) {
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
const values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
values.ndrefs.push(node.getAttribute('ref'));
};
@@ -100,7 +100,7 @@ OSMXML.readNd_ = function(node, objectStack) {
* @private
*/
OSMXML.readTag_ = function(node, objectStack) {
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
const values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
values.tags[node.getAttribute('k')] = node.getAttribute('v');
};
@@ -121,10 +121,10 @@ OSMXML.NAMESPACE_URIS_ = [
* @private
*/
OSMXML.WAY_PARSERS_ = _ol_xml_.makeStructureNS(
OSMXML.NAMESPACE_URIS_, {
'nd': OSMXML.readNd_,
'tag': OSMXML.readTag_
});
OSMXML.NAMESPACE_URIS_, {
'nd': OSMXML.readNd_,
'tag': OSMXML.readTag_
});
/**
@@ -133,10 +133,10 @@ OSMXML.WAY_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
OSMXML.PARSERS_ = _ol_xml_.makeStructureNS(
OSMXML.NAMESPACE_URIS_, {
'node': OSMXML.readNode_,
'way': OSMXML.readWay_
});
OSMXML.NAMESPACE_URIS_, {
'node': OSMXML.readNode_,
'way': OSMXML.readWay_
});
/**
@@ -145,9 +145,9 @@ OSMXML.PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
OSMXML.NODE_PARSERS_ = _ol_xml_.makeStructureNS(
OSMXML.NAMESPACE_URIS_, {
'tag': OSMXML.readTag_
});
OSMXML.NAMESPACE_URIS_, {
'tag': OSMXML.readTag_
});
/**
@@ -166,34 +166,34 @@ OSMXML.prototype.readFeatures;
* @inheritDoc
*/
OSMXML.prototype.readFeaturesFromNode = function(node, opt_options) {
var options = this.getReadOptions(node, opt_options);
const options = this.getReadOptions(node, opt_options);
if (node.localName == 'osm') {
var state = _ol_xml_.pushParseAndPop({
const state = _ol_xml_.pushParseAndPop({
nodes: {},
ways: [],
features: []
}, OSMXML.PARSERS_, node, [options]);
// parse nodes in ways
for (var j = 0; j < state.ways.length; j++) {
var values = /** @type {Object} */ (state.ways[j]);
for (let j = 0; j < state.ways.length; j++) {
const 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]];
const flatCoordinates = [];
for (let i = 0, ii = values.ndrefs.length; i < ii; i++) {
const point = state.nodes[values.ndrefs[i]];
extend(flatCoordinates, point);
}
var geometry;
let geometry;
if (values.ndrefs[0] == values.ndrefs[values.ndrefs.length - 1]) {
// closed way
geometry = new Polygon(null);
geometry.setFlatCoordinates(GeometryLayout.XY, flatCoordinates,
[flatCoordinates.length]);
[flatCoordinates.length]);
} else {
geometry = new LineString(null);
geometry.setFlatCoordinates(GeometryLayout.XY, flatCoordinates);
}
transformWithOptions(geometry, false, options);
var feature = new Feature(geometry);
const feature = new Feature(geometry);
feature.setId(values.id);
feature.setProperties(values.tags);
state.features.push(feature);
+102 -102
View File
@@ -11,7 +11,7 @@ import _ol_xml_ from '../xml.js';
* @constructor
* @extends {ol.format.XML}
*/
var OWS = function() {
const OWS = function() {
XML.call(this);
};
@@ -22,7 +22,7 @@ inherits(OWS, XML);
* @inheritDoc
*/
OWS.prototype.readFromDocument = function(doc) {
for (var n = doc.firstChild; n; n = n.nextSibling) {
for (let n = doc.firstChild; n; n = n.nextSibling) {
if (n.nodeType == Node.ELEMENT_NODE) {
return this.readFromNode(n);
}
@@ -35,8 +35,8 @@ OWS.prototype.readFromDocument = function(doc) {
* @inheritDoc
*/
OWS.prototype.readFromNode = function(node) {
var owsObject = _ol_xml_.pushParseAndPop({},
OWS.PARSERS_, node, []);
const owsObject = _ol_xml_.pushParseAndPop({},
OWS.PARSERS_, node, []);
return owsObject ? owsObject : null;
};
@@ -49,7 +49,7 @@ OWS.prototype.readFromNode = function(node) {
*/
OWS.readAddress_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop({},
OWS.ADDRESS_PARSERS_, node, objectStack);
OWS.ADDRESS_PARSERS_, node, objectStack);
};
@@ -61,7 +61,7 @@ OWS.readAddress_ = function(node, objectStack) {
*/
OWS.readAllowedValues_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop({},
OWS.ALLOWED_VALUES_PARSERS_, node, objectStack);
OWS.ALLOWED_VALUES_PARSERS_, node, objectStack);
};
@@ -72,13 +72,13 @@ OWS.readAllowedValues_ = function(node, objectStack) {
* @return {Object|undefined} The constraint.
*/
OWS.readConstraint_ = function(node, objectStack) {
var name = node.getAttribute('name');
const name = node.getAttribute('name');
if (!name) {
return undefined;
}
return _ol_xml_.pushParseAndPop({'name': name},
OWS.CONSTRAINT_PARSERS_, node,
objectStack);
OWS.CONSTRAINT_PARSERS_, node,
objectStack);
};
@@ -90,7 +90,7 @@ OWS.readConstraint_ = function(node, objectStack) {
*/
OWS.readContactInfo_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop({},
OWS.CONTACT_INFO_PARSERS_, node, objectStack);
OWS.CONTACT_INFO_PARSERS_, node, objectStack);
};
@@ -102,7 +102,7 @@ OWS.readContactInfo_ = function(node, objectStack) {
*/
OWS.readDcp_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop({},
OWS.DCP_PARSERS_, node, objectStack);
OWS.DCP_PARSERS_, node, objectStack);
};
@@ -113,12 +113,12 @@ OWS.readDcp_ = function(node, objectStack) {
* @return {Object|undefined} The GET object.
*/
OWS.readGet_ = function(node, objectStack) {
var href = XLink.readHref(node);
const href = XLink.readHref(node);
if (!href) {
return undefined;
}
return _ol_xml_.pushParseAndPop({'href': href},
OWS.REQUEST_METHOD_PARSERS_, node, objectStack);
OWS.REQUEST_METHOD_PARSERS_, node, objectStack);
};
@@ -130,7 +130,7 @@ OWS.readGet_ = function(node, objectStack) {
*/
OWS.readHttp_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop({}, OWS.HTTP_PARSERS_,
node, objectStack);
node, objectStack);
};
@@ -141,13 +141,13 @@ OWS.readHttp_ = function(node, objectStack) {
* @return {Object|undefined} The operation.
*/
OWS.readOperation_ = function(node, objectStack) {
var name = node.getAttribute('name');
var value = _ol_xml_.pushParseAndPop({},
OWS.OPERATION_PARSERS_, node, objectStack);
const name = node.getAttribute('name');
const value = _ol_xml_.pushParseAndPop({},
OWS.OPERATION_PARSERS_, node, objectStack);
if (!value) {
return undefined;
}
var object = /** @type {Object} */
const object = /** @type {Object} */
(objectStack[objectStack.length - 1]);
object[name] = value;
};
@@ -160,10 +160,10 @@ OWS.readOperation_ = function(node, objectStack) {
* @return {Object|undefined} The operations metadata.
*/
OWS.readOperationsMetadata_ = function(node,
objectStack) {
objectStack) {
return _ol_xml_.pushParseAndPop({},
OWS.OPERATIONS_METADATA_PARSERS_, node,
objectStack);
OWS.OPERATIONS_METADATA_PARSERS_, node,
objectStack);
};
@@ -175,7 +175,7 @@ OWS.readOperationsMetadata_ = function(node,
*/
OWS.readPhone_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop({},
OWS.PHONE_PARSERS_, node, objectStack);
OWS.PHONE_PARSERS_, node, objectStack);
};
@@ -186,10 +186,10 @@ OWS.readPhone_ = function(node, objectStack) {
* @return {Object|undefined} The service identification.
*/
OWS.readServiceIdentification_ = function(node,
objectStack) {
objectStack) {
return _ol_xml_.pushParseAndPop(
{}, OWS.SERVICE_IDENTIFICATION_PARSERS_, node,
objectStack);
{}, OWS.SERVICE_IDENTIFICATION_PARSERS_, node,
objectStack);
};
@@ -201,8 +201,8 @@ OWS.readServiceIdentification_ = function(node,
*/
OWS.readServiceContact_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop(
{}, OWS.SERVICE_CONTACT_PARSERS_, node,
objectStack);
{}, OWS.SERVICE_CONTACT_PARSERS_, node,
objectStack);
};
@@ -214,8 +214,8 @@ OWS.readServiceContact_ = function(node, objectStack) {
*/
OWS.readServiceProvider_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop(
{}, OWS.SERVICE_PROVIDER_PARSERS_, node,
objectStack);
{}, OWS.SERVICE_PROVIDER_PARSERS_, node,
objectStack);
};
@@ -247,14 +247,14 @@ OWS.NAMESPACE_URIS_ = [
* @private
*/
OWS.PARSERS_ = _ol_xml_.makeStructureNS(
OWS.NAMESPACE_URIS_, {
'ServiceIdentification': _ol_xml_.makeObjectPropertySetter(
OWS.readServiceIdentification_),
'ServiceProvider': _ol_xml_.makeObjectPropertySetter(
OWS.readServiceProvider_),
'OperationsMetadata': _ol_xml_.makeObjectPropertySetter(
OWS.readOperationsMetadata_)
});
OWS.NAMESPACE_URIS_, {
'ServiceIdentification': _ol_xml_.makeObjectPropertySetter(
OWS.readServiceIdentification_),
'ServiceProvider': _ol_xml_.makeObjectPropertySetter(
OWS.readServiceProvider_),
'OperationsMetadata': _ol_xml_.makeObjectPropertySetter(
OWS.readOperationsMetadata_)
});
/**
@@ -263,17 +263,17 @@ OWS.PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
OWS.ADDRESS_PARSERS_ = _ol_xml_.makeStructureNS(
OWS.NAMESPACE_URIS_, {
'DeliveryPoint': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'City': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'AdministrativeArea': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'PostalCode': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Country': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'ElectronicMailAddress': _ol_xml_.makeObjectPropertySetter(
XSD.readString)
});
OWS.NAMESPACE_URIS_, {
'DeliveryPoint': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'City': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'AdministrativeArea': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'PostalCode': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Country': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'ElectronicMailAddress': _ol_xml_.makeObjectPropertySetter(
XSD.readString)
});
/**
@@ -282,9 +282,9 @@ OWS.ADDRESS_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
OWS.ALLOWED_VALUES_PARSERS_ = _ol_xml_.makeStructureNS(
OWS.NAMESPACE_URIS_, {
'Value': _ol_xml_.makeObjectPropertyPusher(OWS.readValue_)
});
OWS.NAMESPACE_URIS_, {
'Value': _ol_xml_.makeObjectPropertyPusher(OWS.readValue_)
});
/**
@@ -293,10 +293,10 @@ OWS.ALLOWED_VALUES_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
OWS.CONSTRAINT_PARSERS_ = _ol_xml_.makeStructureNS(
OWS.NAMESPACE_URIS_, {
'AllowedValues': _ol_xml_.makeObjectPropertySetter(
OWS.readAllowedValues_)
});
OWS.NAMESPACE_URIS_, {
'AllowedValues': _ol_xml_.makeObjectPropertySetter(
OWS.readAllowedValues_)
});
/**
@@ -305,10 +305,10 @@ OWS.CONSTRAINT_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
OWS.CONTACT_INFO_PARSERS_ = _ol_xml_.makeStructureNS(
OWS.NAMESPACE_URIS_, {
'Phone': _ol_xml_.makeObjectPropertySetter(OWS.readPhone_),
'Address': _ol_xml_.makeObjectPropertySetter(OWS.readAddress_)
});
OWS.NAMESPACE_URIS_, {
'Phone': _ol_xml_.makeObjectPropertySetter(OWS.readPhone_),
'Address': _ol_xml_.makeObjectPropertySetter(OWS.readAddress_)
});
/**
@@ -317,9 +317,9 @@ OWS.CONTACT_INFO_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
OWS.DCP_PARSERS_ = _ol_xml_.makeStructureNS(
OWS.NAMESPACE_URIS_, {
'HTTP': _ol_xml_.makeObjectPropertySetter(OWS.readHttp_)
});
OWS.NAMESPACE_URIS_, {
'HTTP': _ol_xml_.makeObjectPropertySetter(OWS.readHttp_)
});
/**
@@ -328,10 +328,10 @@ OWS.DCP_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
OWS.HTTP_PARSERS_ = _ol_xml_.makeStructureNS(
OWS.NAMESPACE_URIS_, {
'Get': _ol_xml_.makeObjectPropertyPusher(OWS.readGet_),
'Post': undefined // TODO
});
OWS.NAMESPACE_URIS_, {
'Get': _ol_xml_.makeObjectPropertyPusher(OWS.readGet_),
'Post': undefined // TODO
});
/**
@@ -340,9 +340,9 @@ OWS.HTTP_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
OWS.OPERATION_PARSERS_ = _ol_xml_.makeStructureNS(
OWS.NAMESPACE_URIS_, {
'DCP': _ol_xml_.makeObjectPropertySetter(OWS.readDcp_)
});
OWS.NAMESPACE_URIS_, {
'DCP': _ol_xml_.makeObjectPropertySetter(OWS.readDcp_)
});
/**
@@ -351,9 +351,9 @@ OWS.OPERATION_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
OWS.OPERATIONS_METADATA_PARSERS_ = _ol_xml_.makeStructureNS(
OWS.NAMESPACE_URIS_, {
'Operation': OWS.readOperation_
});
OWS.NAMESPACE_URIS_, {
'Operation': OWS.readOperation_
});
/**
@@ -362,10 +362,10 @@ OWS.OPERATIONS_METADATA_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
OWS.PHONE_PARSERS_ = _ol_xml_.makeStructureNS(
OWS.NAMESPACE_URIS_, {
'Voice': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Facsimile': _ol_xml_.makeObjectPropertySetter(XSD.readString)
});
OWS.NAMESPACE_URIS_, {
'Voice': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Facsimile': _ol_xml_.makeObjectPropertySetter(XSD.readString)
});
/**
@@ -374,10 +374,10 @@ OWS.PHONE_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
OWS.REQUEST_METHOD_PARSERS_ = _ol_xml_.makeStructureNS(
OWS.NAMESPACE_URIS_, {
'Constraint': _ol_xml_.makeObjectPropertyPusher(
OWS.readConstraint_)
});
OWS.NAMESPACE_URIS_, {
'Constraint': _ol_xml_.makeObjectPropertyPusher(
OWS.readConstraint_)
});
/**
@@ -387,13 +387,13 @@ OWS.REQUEST_METHOD_PARSERS_ = _ol_xml_.makeStructureNS(
*/
OWS.SERVICE_CONTACT_PARSERS_ =
_ol_xml_.makeStructureNS(
OWS.NAMESPACE_URIS_, {
'IndividualName': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'PositionName': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'ContactInfo': _ol_xml_.makeObjectPropertySetter(
OWS.readContactInfo_)
});
OWS.NAMESPACE_URIS_, {
'IndividualName': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'PositionName': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'ContactInfo': _ol_xml_.makeObjectPropertySetter(
OWS.readContactInfo_)
});
/**
@@ -403,15 +403,15 @@ OWS.SERVICE_CONTACT_PARSERS_ =
*/
OWS.SERVICE_IDENTIFICATION_PARSERS_ =
_ol_xml_.makeStructureNS(
OWS.NAMESPACE_URIS_, {
'Abstract': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'AccessConstraints': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Fees': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Title': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'ServiceTypeVersion': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'ServiceType': _ol_xml_.makeObjectPropertySetter(XSD.readString)
});
OWS.NAMESPACE_URIS_, {
'Abstract': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'AccessConstraints': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Fees': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Title': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'ServiceTypeVersion': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'ServiceType': _ol_xml_.makeObjectPropertySetter(XSD.readString)
});
/**
@@ -421,10 +421,10 @@ OWS.SERVICE_IDENTIFICATION_PARSERS_ =
*/
OWS.SERVICE_PROVIDER_PARSERS_ =
_ol_xml_.makeStructureNS(
OWS.NAMESPACE_URIS_, {
'ProviderName': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'ProviderSite': _ol_xml_.makeObjectPropertySetter(XLink.readHref),
'ServiceContact': _ol_xml_.makeObjectPropertySetter(
OWS.readServiceContact_)
});
OWS.NAMESPACE_URIS_, {
'ProviderName': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'ProviderSite': _ol_xml_.makeObjectPropertySetter(XLink.readHref),
'ServiceContact': _ol_xml_.makeObjectPropertySetter(
OWS.readServiceContact_)
});
export default OWS;
+44 -44
View File
@@ -24,9 +24,9 @@ import {get as getProjection} from '../proj.js';
* Optional configuration object.
* @api
*/
var Polyline = function(opt_options) {
const Polyline = function(opt_options) {
var options = opt_options ? opt_options : {};
const options = opt_options ? opt_options : {};
TextFeature.call(this);
@@ -66,19 +66,19 @@ inherits(Polyline, TextFeature);
* @api
*/
export function encodeDeltas(numbers, stride, opt_factor) {
var factor = opt_factor ? opt_factor : 1e5;
var d;
const factor = opt_factor ? opt_factor : 1e5;
let d;
var lastNumbers = new Array(stride);
const lastNumbers = new Array(stride);
for (d = 0; d < stride; ++d) {
lastNumbers[d] = 0;
}
var i, ii;
let i, ii;
for (i = 0, ii = numbers.length; i < ii;) {
for (d = 0; d < stride; ++d, ++i) {
var num = numbers[i];
var delta = num - lastNumbers[d];
const num = numbers[i];
const delta = num - lastNumbers[d];
lastNumbers[d] = num;
numbers[i] = delta;
@@ -101,18 +101,18 @@ export function encodeDeltas(numbers, stride, opt_factor) {
* @api
*/
export function decodeDeltas(encoded, stride, opt_factor) {
var factor = opt_factor ? opt_factor : 1e5;
var d;
const factor = opt_factor ? opt_factor : 1e5;
let d;
/** @type {Array.<number>} */
var lastNumbers = new Array(stride);
const lastNumbers = new Array(stride);
for (d = 0; d < stride; ++d) {
lastNumbers[d] = 0;
}
var numbers = decodeFloats(encoded, factor);
const numbers = decodeFloats(encoded, factor);
var i, ii;
let i, ii;
for (i = 0, ii = numbers.length; i < ii;) {
for (d = 0; d < stride; ++d, ++i) {
lastNumbers[d] += numbers[i];
@@ -138,8 +138,8 @@ export function decodeDeltas(encoded, stride, opt_factor) {
* @api
*/
export function encodeFloats(numbers, opt_factor) {
var factor = opt_factor ? opt_factor : 1e5;
var i, ii;
const factor = opt_factor ? opt_factor : 1e5;
let i, ii;
for (i = 0, ii = numbers.length; i < ii; ++i) {
numbers[i] = Math.round(numbers[i] * factor);
}
@@ -158,9 +158,9 @@ export function encodeFloats(numbers, opt_factor) {
* @api
*/
export function decodeFloats(encoded, opt_factor) {
var factor = opt_factor ? opt_factor : 1e5;
var numbers = decodeSignedIntegers(encoded);
var i, ii;
const factor = opt_factor ? opt_factor : 1e5;
const numbers = decodeSignedIntegers(encoded);
let i, ii;
for (i = 0, ii = numbers.length; i < ii; ++i) {
numbers[i] /= factor;
}
@@ -177,9 +177,9 @@ export function decodeFloats(encoded, opt_factor) {
* @return {string} The encoded string.
*/
export function encodeSignedIntegers(numbers) {
var i, ii;
let i, ii;
for (i = 0, ii = numbers.length; i < ii; ++i) {
var num = numbers[i];
const num = numbers[i];
numbers[i] = (num < 0) ? ~(num << 1) : (num << 1);
}
return encodeUnsignedIntegers(numbers);
@@ -193,10 +193,10 @@ export function encodeSignedIntegers(numbers) {
* @return {Array.<number>} A list of signed integers.
*/
export function decodeSignedIntegers(encoded) {
var numbers = decodeUnsignedIntegers(encoded);
var i, ii;
const numbers = decodeUnsignedIntegers(encoded);
let i, ii;
for (i = 0, ii = numbers.length; i < ii; ++i) {
var num = numbers[i];
const num = numbers[i];
numbers[i] = (num & 1) ? ~(num >> 1) : (num >> 1);
}
return numbers;
@@ -210,8 +210,8 @@ export function decodeSignedIntegers(encoded) {
* @return {string} The encoded string.
*/
export function encodeUnsignedIntegers(numbers) {
var encoded = '';
var i, ii;
let encoded = '';
let i, ii;
for (i = 0, ii = numbers.length; i < ii; ++i) {
encoded += encodeUnsignedInteger(numbers[i]);
}
@@ -226,12 +226,12 @@ export function encodeUnsignedIntegers(numbers) {
* @return {Array.<number>} A list of unsigned integers.
*/
export function decodeUnsignedIntegers(encoded) {
var numbers = [];
var current = 0;
var shift = 0;
var i, ii;
const numbers = [];
let current = 0;
let shift = 0;
let i, ii;
for (i = 0, ii = encoded.length; i < ii; ++i) {
var b = encoded.charCodeAt(i) - 63;
const b = encoded.charCodeAt(i) - 63;
current |= (b & 0x1f) << shift;
if (b < 0x20) {
numbers.push(current);
@@ -252,7 +252,7 @@ export function decodeUnsignedIntegers(encoded) {
* @return {string} The encoded string.
*/
export function encodeUnsignedInteger(num) {
var value, encoded = '';
let value, encoded = '';
while (num >= 0x20) {
value = (0x20 | (num & 0x1f)) + 63;
encoded += String.fromCharCode(value);
@@ -281,7 +281,7 @@ Polyline.prototype.readFeature;
* @inheritDoc
*/
Polyline.prototype.readFeatureFromText = function(text, opt_options) {
var geometry = this.readGeometryFromText(text, opt_options);
const geometry = this.readGeometryFromText(text, opt_options);
return new Feature(geometry);
};
@@ -303,7 +303,7 @@ Polyline.prototype.readFeatures;
* @inheritDoc
*/
Polyline.prototype.readFeaturesFromText = function(text, opt_options) {
var feature = this.readFeatureFromText(text, opt_options);
const feature = this.readFeatureFromText(text, opt_options);
return [feature];
};
@@ -324,17 +324,17 @@ Polyline.prototype.readGeometry;
* @inheritDoc
*/
Polyline.prototype.readGeometryFromText = function(text, opt_options) {
var stride = getStrideForLayout(this.geometryLayout_);
var flatCoordinates = decodeDeltas(text, stride, this.factor_);
const stride = getStrideForLayout(this.geometryLayout_);
const flatCoordinates = decodeDeltas(text, stride, this.factor_);
_ol_geom_flat_flip_.flipXY(
flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
var coordinates = _ol_geom_flat_inflate_.coordinates(
flatCoordinates, 0, flatCoordinates.length, stride);
flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
const coordinates = _ol_geom_flat_inflate_.coordinates(
flatCoordinates, 0, flatCoordinates.length, stride);
return (
/** @type {ol.geom.Geometry} */ transformWithOptions(
new LineString(coordinates, this.geometryLayout_), false,
this.adaptOptions(opt_options))
new LineString(coordinates, this.geometryLayout_), false,
this.adaptOptions(opt_options))
);
};
@@ -354,7 +354,7 @@ Polyline.prototype.readProjection;
* @inheritDoc
*/
Polyline.prototype.writeFeatureText = function(feature, opt_options) {
var geometry = feature.getGeometry();
const geometry = feature.getGeometry();
if (geometry) {
return this.writeGeometryText(geometry, opt_options);
} else {
@@ -390,10 +390,10 @@ Polyline.prototype.writeGeometry;
Polyline.prototype.writeGeometryText = function(geometry, opt_options) {
geometry = /** @type {ol.geom.LineString} */
(transformWithOptions(geometry, true, this.adaptOptions(opt_options)));
var flatCoordinates = geometry.getFlatCoordinates();
var stride = geometry.getStride();
const flatCoordinates = geometry.getFlatCoordinates();
const stride = geometry.getStride();
_ol_geom_flat_flip_.flipXY(
flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
return encodeDeltas(flatCoordinates, stride, this.factor_);
};
export default Polyline;
+1 -1
View File
@@ -15,7 +15,7 @@ import FormatType from '../format/FormatType.js';
* @abstract
* @extends {ol.format.Feature}
*/
var TextFeature = function() {
const TextFeature = function() {
FeatureFormat.call(this);
};
+44 -44
View File
@@ -22,9 +22,9 @@ import {get as getProjection} from '../proj.js';
* @param {olx.format.TopoJSONOptions=} opt_options Options.
* @api
*/
var TopoJSON = function(opt_options) {
const TopoJSON = function(opt_options) {
var options = opt_options ? opt_options : {};
const options = opt_options ? opt_options : {};
JSONFeature.call(this);
@@ -44,8 +44,8 @@ var TopoJSON = function(opt_options) {
* @inheritDoc
*/
this.defaultDataProjection = getProjection(
options.defaultDataProjection ?
options.defaultDataProjection : 'EPSG:4326');
options.defaultDataProjection ?
options.defaultDataProjection : 'EPSG:4326');
};
@@ -56,7 +56,7 @@ inherits(TopoJSON, JSONFeature);
* @const
* @type {Object.<string, function(TopoJSONGeometry, Array, ...Array): ol.geom.Geometry>}
*/
var GEOMETRY_READERS = {
const GEOMETRY_READERS = {
'Point': readPointGeometry,
'LineString': readLineStringGeometry,
'Polygon': readPolygonGeometry,
@@ -76,10 +76,10 @@ var GEOMETRY_READERS = {
*/
function concatenateArcs(indices, arcs) {
/** @type {Array.<ol.Coordinate>} */
var coordinates = [];
var index, arc;
var i, ii;
var j, jj;
const coordinates = [];
let index, arc;
let i, ii;
let j, jj;
for (i = 0, ii = indices.length; i < ii; ++i) {
index = indices[i];
if (i > 0) {
@@ -112,7 +112,7 @@ function concatenateArcs(indices, arcs) {
* @return {ol.geom.Point} Geometry.
*/
function readPointGeometry(object, scale, translate) {
var coordinates = object.coordinates;
const coordinates = object.coordinates;
if (scale && translate) {
transformVertex(coordinates, scale, translate);
}
@@ -129,8 +129,8 @@ function readPointGeometry(object, scale, translate) {
* @return {ol.geom.MultiPoint} Geometry.
*/
function readMultiPointGeometry(object, scale, translate) {
var coordinates = object.coordinates;
var i, ii;
const coordinates = object.coordinates;
let i, ii;
if (scale && translate) {
for (i = 0, ii = coordinates.length; i < ii; ++i) {
transformVertex(coordinates[i], scale, translate);
@@ -148,7 +148,7 @@ function readMultiPointGeometry(object, scale, translate) {
* @return {ol.geom.LineString} Geometry.
*/
function readLineStringGeometry(object, arcs) {
var coordinates = concatenateArcs(object.arcs, arcs);
const coordinates = concatenateArcs(object.arcs, arcs);
return new LineString(coordinates);
}
@@ -161,8 +161,8 @@ function readLineStringGeometry(object, arcs) {
* @return {ol.geom.MultiLineString} Geometry.
*/
function readMultiLineStringGeometry(object, arcs) {
var coordinates = [];
var i, ii;
const coordinates = [];
let i, ii;
for (i = 0, ii = object.arcs.length; i < ii; ++i) {
coordinates[i] = concatenateArcs(object.arcs[i], arcs);
}
@@ -178,8 +178,8 @@ function readMultiLineStringGeometry(object, arcs) {
* @return {ol.geom.Polygon} Geometry.
*/
function readPolygonGeometry(object, arcs) {
var coordinates = [];
var i, ii;
const coordinates = [];
let i, ii;
for (i = 0, ii = object.arcs.length; i < ii; ++i) {
coordinates[i] = concatenateArcs(object.arcs[i], arcs);
}
@@ -195,9 +195,9 @@ function readPolygonGeometry(object, arcs) {
* @return {ol.geom.MultiPolygon} Geometry.
*/
function readMultiPolygonGeometry(object, arcs) {
var coordinates = [];
var polyArray, ringCoords, j, jj;
var i, ii;
const coordinates = [];
let polyArray, ringCoords, j, jj;
let i, ii;
for (i = 0, ii = object.arcs.length; i < ii; ++i) {
// for each polygon
polyArray = object.arcs[i];
@@ -227,12 +227,12 @@ function readMultiPolygonGeometry(object, arcs) {
* @return {Array.<ol.Feature>} Array of features.
*/
function readFeaturesFromGeometryCollection(collection, arcs, scale, translate, property, name, opt_options) {
var geometries = collection.geometries;
var features = [];
var i, ii;
const geometries = collection.geometries;
const features = [];
let i, ii;
for (i = 0, ii = geometries.length; i < ii; ++i) {
features[i] = readFeatureFromGeometry(
geometries[i], arcs, scale, translate, property, name, opt_options);
geometries[i], arcs, scale, translate, property, name, opt_options);
}
return features;
}
@@ -252,21 +252,21 @@ function readFeaturesFromGeometryCollection(collection, arcs, scale, translate,
* @return {ol.Feature} Feature.
*/
function readFeatureFromGeometry(object, arcs, scale, translate, property, name, opt_options) {
var geometry;
var type = object.type;
var geometryReader = GEOMETRY_READERS[type];
let geometry;
const type = object.type;
const geometryReader = GEOMETRY_READERS[type];
if ((type === 'Point') || (type === 'MultiPoint')) {
geometry = geometryReader(object, scale, translate);
} else {
geometry = geometryReader(object, arcs);
}
var feature = new Feature();
const feature = new Feature();
feature.setGeometry(/** @type {ol.geom.Geometry} */ (
transformWithOptions(geometry, false, opt_options)));
if (object.id !== undefined) {
feature.setId(object.id);
}
var properties = object.properties;
let properties = object.properties;
if (property) {
if (!properties) {
properties = {};
@@ -295,24 +295,24 @@ TopoJSON.prototype.readFeatures;
* @inheritDoc
*/
TopoJSON.prototype.readFeaturesFromObject = function(
object, opt_options) {
object, opt_options) {
if (object.type == 'Topology') {
var topoJSONTopology = /** @type {TopoJSONTopology} */ (object);
var transform, scale = null, translate = null;
const topoJSONTopology = /** @type {TopoJSONTopology} */ (object);
let transform, scale = null, translate = null;
if (topoJSONTopology.transform) {
transform = topoJSONTopology.transform;
scale = transform.scale;
translate = transform.translate;
}
var arcs = topoJSONTopology.arcs;
const arcs = topoJSONTopology.arcs;
if (transform) {
transformArcs(arcs, scale, translate);
}
/** @type {Array.<ol.Feature>} */
var features = [];
var topoJSONFeatures = topoJSONTopology.objects;
var property = this.layerName_;
var objectName, feature;
const features = [];
const topoJSONFeatures = topoJSONTopology.objects;
const property = this.layerName_;
let objectName, feature;
for (objectName in topoJSONFeatures) {
if (this.layers_ && this.layers_.indexOf(objectName) == -1) {
continue;
@@ -320,11 +320,11 @@ TopoJSON.prototype.readFeaturesFromObject = function(
if (topoJSONFeatures[objectName].type === 'GeometryCollection') {
feature = /** @type {TopoJSONGeometryCollection} */ (topoJSONFeatures[objectName]);
features.push.apply(features, readFeaturesFromGeometryCollection(
feature, arcs, scale, translate, property, objectName, opt_options));
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));
feature, arcs, scale, translate, property, objectName, opt_options));
}
}
return features;
@@ -343,7 +343,7 @@ TopoJSON.prototype.readFeaturesFromObject = function(
* @param {Array.<number>} translate Translation for each dimension.
*/
function transformArcs(arcs, scale, translate) {
var i, ii;
let i, ii;
for (i = 0, ii = arcs.length; i < ii; ++i) {
transformArc(arcs[i], scale, translate);
}
@@ -358,10 +358,10 @@ function transformArcs(arcs, scale, translate) {
* @param {Array.<number>} translate Translation for each dimension.
*/
function transformArc(arc, scale, translate) {
var x = 0;
var y = 0;
var vertex;
var i, ii;
let x = 0;
let y = 0;
let vertex;
let i, ii;
for (i = 0, ii = arc.length; i < ii; ++i) {
vertex = arc[i];
x += vertex[0];
+140 -140
View File
@@ -27,8 +27,8 @@ import _ol_xml_ from '../xml.js';
* @extends {ol.format.XMLFeature}
* @api
*/
var WFS = function(opt_options) {
var options = opt_options ? opt_options : {};
const WFS = function(opt_options) {
const options = opt_options ? opt_options : {};
/**
* @private
@@ -149,19 +149,19 @@ WFS.prototype.readFeatures;
* @inheritDoc
*/
WFS.prototype.readFeaturesFromNode = function(node, opt_options) {
var context = /** @type {ol.XmlNodeStackItem} */ ({
const context = /** @type {ol.XmlNodeStackItem} */ ({
'featureType': this.featureType_,
'featureNS': this.featureNS_
});
_ol_obj_.assign(context, this.getReadOptions(node,
opt_options ? opt_options : {}));
var objectStack = [context];
opt_options ? opt_options : {}));
const objectStack = [context];
this.gmlFormat_.FEATURE_COLLECTION_PARSERS[GMLBase.GMLNS][
'featureMember'] =
'featureMember'] =
_ol_xml_.makeArrayPusher(GMLBase.prototype.readFeaturesInternal);
var features = _ol_xml_.pushParseAndPop([],
this.gmlFormat_.FEATURE_COLLECTION_PARSERS, node,
objectStack, this.gmlFormat_);
let features = _ol_xml_.pushParseAndPop([],
this.gmlFormat_.FEATURE_COLLECTION_PARSERS, node,
objectStack, this.gmlFormat_);
if (!features) {
features = [];
}
@@ -179,11 +179,11 @@ WFS.prototype.readFeaturesFromNode = function(node, opt_options) {
WFS.prototype.readTransactionResponse = function(source) {
if (_ol_xml_.isDocument(source)) {
return this.readTransactionResponseFromDocument(
/** @type {Document} */ (source));
/** @type {Document} */ (source));
} else if (_ol_xml_.isNode(source)) {
return this.readTransactionResponseFromNode(/** @type {Node} */ (source));
} else if (typeof source === 'string') {
var doc = _ol_xml_.parse(source);
const doc = _ol_xml_.parse(source);
return this.readTransactionResponseFromDocument(doc);
} else {
return undefined;
@@ -202,12 +202,12 @@ WFS.prototype.readTransactionResponse = function(source) {
WFS.prototype.readFeatureCollectionMetadata = function(source) {
if (_ol_xml_.isDocument(source)) {
return this.readFeatureCollectionMetadataFromDocument(
/** @type {Document} */ (source));
/** @type {Document} */ (source));
} else if (_ol_xml_.isNode(source)) {
return this.readFeatureCollectionMetadataFromNode(
/** @type {Node} */ (source));
/** @type {Node} */ (source));
} else if (typeof source === 'string') {
var doc = _ol_xml_.parse(source);
const doc = _ol_xml_.parse(source);
return this.readFeatureCollectionMetadataFromDocument(doc);
} else {
return undefined;
@@ -221,7 +221,7 @@ WFS.prototype.readFeatureCollectionMetadata = function(source) {
* FeatureCollection metadata.
*/
WFS.prototype.readFeatureCollectionMetadataFromDocument = function(doc) {
for (var n = doc.firstChild; n; n = n.nextSibling) {
for (let n = doc.firstChild; n; n = n.nextSibling) {
if (n.nodeType == Node.ELEMENT_NODE) {
return this.readFeatureCollectionMetadataFromNode(n);
}
@@ -238,7 +238,7 @@ WFS.prototype.readFeatureCollectionMetadataFromDocument = function(doc) {
WFS.FEATURE_COLLECTION_PARSERS_ = {
'http://www.opengis.net/gml': {
'boundedBy': _ol_xml_.makeObjectPropertySetter(
GMLBase.prototype.readGeometryElement, 'bounds')
GMLBase.prototype.readGeometryElement, 'bounds')
}
};
@@ -249,13 +249,13 @@ WFS.FEATURE_COLLECTION_PARSERS_ = {
* FeatureCollection metadata.
*/
WFS.prototype.readFeatureCollectionMetadataFromNode = function(node) {
var result = {};
var value = XSD.readNonNegativeIntegerString(
node.getAttribute('numberOfFeatures'));
const result = {};
const value = XSD.readNonNegativeIntegerString(
node.getAttribute('numberOfFeatures'));
result['numberOfFeatures'] = value;
return _ol_xml_.pushParseAndPop(
/** @type {ol.WFSFeatureCollectionMetadata} */ (result),
WFS.FEATURE_COLLECTION_PARSERS_, node, [], this.gmlFormat_);
/** @type {ol.WFSFeatureCollectionMetadata} */ (result),
WFS.FEATURE_COLLECTION_PARSERS_, node, [], this.gmlFormat_);
};
@@ -267,11 +267,11 @@ WFS.prototype.readFeatureCollectionMetadataFromNode = function(node) {
WFS.TRANSACTION_SUMMARY_PARSERS_ = {
'http://www.opengis.net/wfs': {
'totalInserted': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger),
XSD.readNonNegativeInteger),
'totalUpdated': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger),
XSD.readNonNegativeInteger),
'totalDeleted': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger)
XSD.readNonNegativeInteger)
}
};
@@ -284,7 +284,7 @@ WFS.TRANSACTION_SUMMARY_PARSERS_ = {
*/
WFS.readTransactionSummary_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop(
{}, WFS.TRANSACTION_SUMMARY_PARSERS_, node, objectStack);
{}, WFS.TRANSACTION_SUMMARY_PARSERS_, node, objectStack);
};
@@ -332,7 +332,7 @@ WFS.INSERT_RESULTS_PARSERS_ = {
*/
WFS.readInsertResults_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop(
[], WFS.INSERT_RESULTS_PARSERS_, node, objectStack);
[], WFS.INSERT_RESULTS_PARSERS_, node, objectStack);
};
@@ -344,9 +344,9 @@ WFS.readInsertResults_ = function(node, objectStack) {
WFS.TRANSACTION_RESPONSE_PARSERS_ = {
'http://www.opengis.net/wfs': {
'TransactionSummary': _ol_xml_.makeObjectPropertySetter(
WFS.readTransactionSummary_, 'transactionSummary'),
WFS.readTransactionSummary_, 'transactionSummary'),
'InsertResults': _ol_xml_.makeObjectPropertySetter(
WFS.readInsertResults_, 'insertIds')
WFS.readInsertResults_, 'insertIds')
}
};
@@ -356,7 +356,7 @@ WFS.TRANSACTION_RESPONSE_PARSERS_ = {
* @return {ol.WFSTransactionResponse|undefined} Transaction response.
*/
WFS.prototype.readTransactionResponseFromDocument = function(doc) {
for (var n = doc.firstChild; n; n = n.nextSibling) {
for (let n = doc.firstChild; n; n = n.nextSibling) {
if (n.nodeType == Node.ELEMENT_NODE) {
return this.readTransactionResponseFromNode(n);
}
@@ -371,8 +371,8 @@ WFS.prototype.readTransactionResponseFromDocument = function(doc) {
*/
WFS.prototype.readTransactionResponseFromNode = function(node) {
return _ol_xml_.pushParseAndPop(
/** @type {ol.WFSTransactionResponse} */({}),
WFS.TRANSACTION_RESPONSE_PARSERS_, node, []);
/** @type {ol.WFSTransactionResponse} */({}),
WFS.TRANSACTION_RESPONSE_PARSERS_, node, []);
};
@@ -394,11 +394,11 @@ WFS.QUERY_SERIALIZERS_ = {
* @private
*/
WFS.writeFeature_ = function(node, feature, objectStack) {
var context = objectStack[objectStack.length - 1];
var featureType = context['featureType'];
var featureNS = context['featureNS'];
var gmlVersion = context['gmlVersion'];
var child = _ol_xml_.createElementNS(featureNS, featureType);
const context = objectStack[objectStack.length - 1];
const featureType = context['featureType'];
const featureNS = context['featureNS'];
const gmlVersion = context['gmlVersion'];
const child = _ol_xml_.createElementNS(featureNS, featureType);
node.appendChild(child);
if (gmlVersion === 2) {
GML2.prototype.writeFeatureElement(child, feature, objectStack);
@@ -415,8 +415,8 @@ WFS.writeFeature_ = function(node, feature, objectStack) {
* @private
*/
WFS.writeOgcFidFilter_ = function(node, fid, objectStack) {
var filter = _ol_xml_.createElementNS(WFS.OGCNS, 'Filter');
var child = _ol_xml_.createElementNS(WFS.OGCNS, 'FeatureId');
const filter = _ol_xml_.createElementNS(WFS.OGCNS, 'Filter');
const child = _ol_xml_.createElementNS(WFS.OGCNS, 'FeatureId');
filter.appendChild(child);
child.setAttribute('fid', fid);
node.appendChild(filter);
@@ -432,7 +432,7 @@ WFS.writeOgcFidFilter_ = function(node, fid, objectStack) {
WFS.getTypeName_ = function(featurePrefix, featureType) {
featurePrefix = featurePrefix ? featurePrefix :
WFS.FEATURE_PREFIX;
var prefix = featurePrefix + ':';
const prefix = featurePrefix + ':';
// The featureType already contains the prefix.
if (featureType.indexOf(prefix) === 0) {
return featureType;
@@ -449,16 +449,16 @@ WFS.getTypeName_ = function(featurePrefix, featureType) {
* @private
*/
WFS.writeDelete_ = function(node, feature, objectStack) {
var context = objectStack[objectStack.length - 1];
const context = objectStack[objectStack.length - 1];
assert(feature.getId() !== undefined, 26); // Features must have an id set
var featureType = context['featureType'];
var featurePrefix = context['featurePrefix'];
var featureNS = context['featureNS'];
var typeName = WFS.getTypeName_(featurePrefix, featureType);
const featureType = context['featureType'];
const featurePrefix = context['featurePrefix'];
const featureNS = context['featureNS'];
const typeName = WFS.getTypeName_(featurePrefix, featureType);
node.setAttribute('typeName', typeName);
_ol_xml_.setAttributeNS(node, WFS.XMLNS, 'xmlns:' + featurePrefix,
featureNS);
var fid = feature.getId();
featureNS);
const fid = feature.getId();
if (fid !== undefined) {
WFS.writeOgcFidFilter_(node, fid, objectStack);
}
@@ -472,24 +472,24 @@ WFS.writeDelete_ = function(node, feature, objectStack) {
* @private
*/
WFS.writeUpdate_ = function(node, feature, objectStack) {
var context = objectStack[objectStack.length - 1];
const context = objectStack[objectStack.length - 1];
assert(feature.getId() !== undefined, 27); // Features must have an id set
var featureType = context['featureType'];
var featurePrefix = context['featurePrefix'];
var featureNS = context['featureNS'];
var typeName = WFS.getTypeName_(featurePrefix, featureType);
var geometryName = feature.getGeometryName();
const featureType = context['featureType'];
const featurePrefix = context['featurePrefix'];
const featureNS = context['featureNS'];
const typeName = WFS.getTypeName_(featurePrefix, featureType);
const geometryName = feature.getGeometryName();
node.setAttribute('typeName', typeName);
_ol_xml_.setAttributeNS(node, WFS.XMLNS, 'xmlns:' + featurePrefix,
featureNS);
var fid = feature.getId();
featureNS);
const fid = feature.getId();
if (fid !== undefined) {
var keys = feature.getKeys();
var values = [];
for (var i = 0, ii = keys.length; i < ii; i++) {
var value = feature.get(keys[i]);
const keys = feature.getKeys();
const values = [];
for (let i = 0, ii = keys.length; i < ii; i++) {
const value = feature.get(keys[i]);
if (value !== undefined) {
var name = keys[i];
let name = keys[i];
if (value instanceof Geometry) {
name = geometryName;
}
@@ -514,21 +514,21 @@ WFS.writeUpdate_ = function(node, feature, objectStack) {
* @private
*/
WFS.writeProperty_ = function(node, pair, objectStack) {
var name = _ol_xml_.createElementNS(WFS.WFSNS, 'Name');
var context = objectStack[objectStack.length - 1];
var gmlVersion = context['gmlVersion'];
const name = _ol_xml_.createElementNS(WFS.WFSNS, 'Name');
const context = objectStack[objectStack.length - 1];
const gmlVersion = context['gmlVersion'];
node.appendChild(name);
XSD.writeStringTextNode(name, pair.name);
if (pair.value !== undefined && pair.value !== null) {
var value = _ol_xml_.createElementNS(WFS.WFSNS, 'Value');
const value = _ol_xml_.createElementNS(WFS.WFSNS, 'Value');
node.appendChild(value);
if (pair.value instanceof Geometry) {
if (gmlVersion === 2) {
GML2.prototype.writeGeometryElement(value,
pair.value, objectStack);
pair.value, objectStack);
} else {
GML3.prototype.writeGeometryElement(value,
pair.value, objectStack);
pair.value, objectStack);
}
} else {
XSD.writeStringTextNode(value, pair.value);
@@ -579,12 +579,12 @@ WFS.TRANSACTION_SERIALIZERS_ = {
* @private
*/
WFS.writeQuery_ = function(node, featureType, objectStack) {
var context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
var featurePrefix = context['featurePrefix'];
var featureNS = context['featureNS'];
var propertyNames = context['propertyNames'];
var srsName = context['srsName'];
var typeName;
const context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
const featurePrefix = context['featurePrefix'];
const featureNS = context['featureNS'];
const propertyNames = context['propertyNames'];
const srsName = context['srsName'];
let typeName;
// If feature prefix is not defined, we must not use the default prefix.
if (featurePrefix) {
typeName = WFS.getTypeName_(featurePrefix, featureType);
@@ -597,17 +597,17 @@ WFS.writeQuery_ = function(node, featureType, objectStack) {
}
if (featureNS) {
_ol_xml_.setAttributeNS(node, WFS.XMLNS, 'xmlns:' + featurePrefix,
featureNS);
featureNS);
}
var item = /** @type {ol.XmlNodeStackItem} */ (_ol_obj_.assign({}, context));
const item = /** @type {ol.XmlNodeStackItem} */ (_ol_obj_.assign({}, context));
item.node = node;
_ol_xml_.pushSerializeAndPop(item,
WFS.QUERY_SERIALIZERS_,
_ol_xml_.makeSimpleNodeFactory('PropertyName'), propertyNames,
objectStack);
var filter = context['filter'];
WFS.QUERY_SERIALIZERS_,
_ol_xml_.makeSimpleNodeFactory('PropertyName'), propertyNames,
objectStack);
const filter = context['filter'];
if (filter) {
var child = _ol_xml_.createElementNS(WFS.OGCNS, 'Filter');
const child = _ol_xml_.createElementNS(WFS.OGCNS, 'Filter');
node.appendChild(child);
WFS.writeFilterCondition_(child, filter, objectStack);
}
@@ -622,11 +622,11 @@ WFS.writeQuery_ = function(node, featureType, objectStack) {
*/
WFS.writeFilterCondition_ = function(node, filter, objectStack) {
/** @type {ol.XmlNodeStackItem} */
var item = {node: node};
const item = {node: node};
_ol_xml_.pushSerializeAndPop(item,
WFS.GETFEATURE_SERIALIZERS_,
_ol_xml_.makeSimpleNodeFactory(filter.getTagName()),
[filter], objectStack);
WFS.GETFEATURE_SERIALIZERS_,
_ol_xml_.makeSimpleNodeFactory(filter.getTagName()),
[filter], objectStack);
};
@@ -637,7 +637,7 @@ WFS.writeFilterCondition_ = function(node, filter, objectStack) {
* @private
*/
WFS.writeBboxFilter_ = function(node, filter, objectStack) {
var context = objectStack[objectStack.length - 1];
const context = objectStack[objectStack.length - 1];
context['srsName'] = filter.srsName;
WFS.writeOgcPropertyName_(node, filter.geometryName);
@@ -652,7 +652,7 @@ WFS.writeBboxFilter_ = function(node, filter, objectStack) {
* @private
*/
WFS.writeContainsFilter_ = function(node, filter, objectStack) {
var context = objectStack[objectStack.length - 1];
const context = objectStack[objectStack.length - 1];
context['srsName'] = filter.srsName;
WFS.writeOgcPropertyName_(node, filter.geometryName);
@@ -667,7 +667,7 @@ WFS.writeContainsFilter_ = function(node, filter, objectStack) {
* @private
*/
WFS.writeIntersectsFilter_ = function(node, filter, objectStack) {
var context = objectStack[objectStack.length - 1];
const context = objectStack[objectStack.length - 1];
context['srsName'] = filter.srsName;
WFS.writeOgcPropertyName_(node, filter.geometryName);
@@ -682,7 +682,7 @@ WFS.writeIntersectsFilter_ = function(node, filter, objectStack) {
* @private
*/
WFS.writeWithinFilter_ = function(node, filter, objectStack) {
var context = objectStack[objectStack.length - 1];
const context = objectStack[objectStack.length - 1];
context['srsName'] = filter.srsName;
WFS.writeOgcPropertyName_(node, filter.geometryName);
@@ -698,19 +698,19 @@ WFS.writeWithinFilter_ = function(node, filter, objectStack) {
*/
WFS.writeDuringFilter_ = function(node, filter, objectStack) {
var valueReference = _ol_xml_.createElementNS(WFS.FESNS, 'ValueReference');
const valueReference = _ol_xml_.createElementNS(WFS.FESNS, 'ValueReference');
XSD.writeStringTextNode(valueReference, filter.propertyName);
node.appendChild(valueReference);
var timePeriod = _ol_xml_.createElementNS(GMLBase.GMLNS, 'TimePeriod');
const timePeriod = _ol_xml_.createElementNS(GMLBase.GMLNS, 'TimePeriod');
node.appendChild(timePeriod);
var begin = _ol_xml_.createElementNS(GMLBase.GMLNS, 'begin');
const begin = _ol_xml_.createElementNS(GMLBase.GMLNS, 'begin');
timePeriod.appendChild(begin);
WFS.writeTimeInstant_(begin, filter.begin);
var end = _ol_xml_.createElementNS(GMLBase.GMLNS, 'end');
const end = _ol_xml_.createElementNS(GMLBase.GMLNS, 'end');
timePeriod.appendChild(end);
WFS.writeTimeInstant_(end, filter.end);
};
@@ -724,14 +724,14 @@ WFS.writeDuringFilter_ = function(node, filter, objectStack) {
*/
WFS.writeLogicalFilter_ = function(node, filter, objectStack) {
/** @type {ol.XmlNodeStackItem} */
var item = {node: node};
var conditions = filter.conditions;
for (var i = 0, ii = conditions.length; i < ii; ++i) {
var condition = conditions[i];
const item = {node: node};
const conditions = filter.conditions;
for (let i = 0, ii = conditions.length; i < ii; ++i) {
const condition = conditions[i];
_ol_xml_.pushSerializeAndPop(item,
WFS.GETFEATURE_SERIALIZERS_,
_ol_xml_.makeSimpleNodeFactory(condition.getTagName()),
[condition], objectStack);
WFS.GETFEATURE_SERIALIZERS_,
_ol_xml_.makeSimpleNodeFactory(condition.getTagName()),
[condition], objectStack);
}
};
@@ -744,12 +744,12 @@ WFS.writeLogicalFilter_ = function(node, filter, objectStack) {
*/
WFS.writeNotFilter_ = function(node, filter, objectStack) {
/** @type {ol.XmlNodeStackItem} */
var item = {node: node};
var condition = filter.condition;
const item = {node: node};
const condition = filter.condition;
_ol_xml_.pushSerializeAndPop(item,
WFS.GETFEATURE_SERIALIZERS_,
_ol_xml_.makeSimpleNodeFactory(condition.getTagName()),
[condition], objectStack);
WFS.GETFEATURE_SERIALIZERS_,
_ol_xml_.makeSimpleNodeFactory(condition.getTagName()),
[condition], objectStack);
};
@@ -788,11 +788,11 @@ WFS.writeIsNullFilter_ = function(node, filter, objectStack) {
WFS.writeIsBetweenFilter_ = function(node, filter, objectStack) {
WFS.writeOgcPropertyName_(node, filter.propertyName);
var lowerBoundary = _ol_xml_.createElementNS(WFS.OGCNS, 'LowerBoundary');
const lowerBoundary = _ol_xml_.createElementNS(WFS.OGCNS, 'LowerBoundary');
node.appendChild(lowerBoundary);
WFS.writeOgcLiteral_(lowerBoundary, '' + filter.lowerBoundary);
var upperBoundary = _ol_xml_.createElementNS(WFS.OGCNS, 'UpperBoundary');
const upperBoundary = _ol_xml_.createElementNS(WFS.OGCNS, 'UpperBoundary');
node.appendChild(upperBoundary);
WFS.writeOgcLiteral_(upperBoundary, '' + filter.upperBoundary);
};
@@ -823,7 +823,7 @@ WFS.writeIsLikeFilter_ = function(node, filter, objectStack) {
* @private
*/
WFS.writeOgcExpression_ = function(tagName, node, value) {
var property = _ol_xml_.createElementNS(WFS.OGCNS, tagName);
const property = _ol_xml_.createElementNS(WFS.OGCNS, tagName);
XSD.writeStringTextNode(property, value);
node.appendChild(property);
};
@@ -855,10 +855,10 @@ WFS.writeOgcLiteral_ = function(node, value) {
* @private
*/
WFS.writeTimeInstant_ = function(node, time) {
var timeInstant = _ol_xml_.createElementNS(GMLBase.GMLNS, 'TimeInstant');
const timeInstant = _ol_xml_.createElementNS(GMLBase.GMLNS, 'TimeInstant');
node.appendChild(timeInstant);
var timePosition = _ol_xml_.createElementNS(GMLBase.GMLNS, 'timePosition');
const timePosition = _ol_xml_.createElementNS(GMLBase.GMLNS, 'timePosition');
timeInstant.appendChild(timePosition);
XSD.writeStringTextNode(timePosition, time);
};
@@ -902,7 +902,7 @@ WFS.GETFEATURE_SERIALIZERS_ = {
* @api
*/
WFS.writeFilter = function(filter) {
var child = _ol_xml_.createElementNS(WFS.OGCNS, 'Filter');
const child = _ol_xml_.createElementNS(WFS.OGCNS, 'Filter');
WFS.writeFilterCondition_(child, filter, []);
return child;
};
@@ -915,13 +915,13 @@ WFS.writeFilter = function(filter) {
* @private
*/
WFS.writeGetFeature_ = function(node, featureTypes, objectStack) {
var context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
var item = /** @type {ol.XmlNodeStackItem} */ (_ol_obj_.assign({}, context));
const context = /** @type {Object} */ (objectStack[objectStack.length - 1]);
const item = /** @type {ol.XmlNodeStackItem} */ (_ol_obj_.assign({}, context));
item.node = node;
_ol_xml_.pushSerializeAndPop(item,
WFS.GETFEATURE_SERIALIZERS_,
_ol_xml_.makeSimpleNodeFactory('Query'), featureTypes,
objectStack);
WFS.GETFEATURE_SERIALIZERS_,
_ol_xml_.makeSimpleNodeFactory('Query'), featureTypes,
objectStack);
};
@@ -933,10 +933,10 @@ WFS.writeGetFeature_ = function(node, featureTypes, objectStack) {
* @api
*/
WFS.prototype.writeGetFeature = function(options) {
var node = _ol_xml_.createElementNS(WFS.WFSNS, 'GetFeature');
const node = _ol_xml_.createElementNS(WFS.WFSNS, 'GetFeature');
node.setAttribute('service', 'WFS');
node.setAttribute('version', '1.1.0');
var filter;
let filter;
if (options) {
if (options.handle) {
node.setAttribute('handle', options.handle);
@@ -959,9 +959,9 @@ WFS.prototype.writeGetFeature = function(options) {
filter = options.filter;
if (options.bbox) {
assert(options.geometryName,
12); // `options.geometryName` must also be provided when `options.bbox` is set
var bbox = _ol_format_filter_.bbox(
/** @type {string} */ (options.geometryName), options.bbox, options.srsName);
12); // `options.geometryName` must also be provided when `options.bbox` is set
const bbox = _ol_format_filter_.bbox(
/** @type {string} */ (options.geometryName), options.bbox, options.srsName);
if (filter) {
// if bbox and filter are both set, combine the two into a single filter
filter = _ol_format_filter_.and(filter, bbox);
@@ -971,9 +971,9 @@ WFS.prototype.writeGetFeature = function(options) {
}
}
_ol_xml_.setAttributeNS(node, 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation', this.schemaLocation_);
'xsi:schemaLocation', this.schemaLocation_);
/** @type {ol.XmlNodeStackItem} */
var context = {
const context = {
node: node,
'srsName': options.srsName,
'featureNS': options.featureNS ? options.featureNS : this.featureNS_,
@@ -983,7 +983,7 @@ WFS.prototype.writeGetFeature = function(options) {
'propertyNames': options.propertyNames ? options.propertyNames : []
};
assert(Array.isArray(options.featureTypes),
11); // `options.featureTypes` should be an Array
11); // `options.featureTypes` should be an Array
WFS.writeGetFeature_(node, /** @type {!Array.<string>} */ (options.featureTypes), [context]);
return node;
};
@@ -1000,36 +1000,36 @@ WFS.prototype.writeGetFeature = function(options) {
* @api
*/
WFS.prototype.writeTransaction = function(inserts, updates, deletes,
options) {
var objectStack = [];
var node = _ol_xml_.createElementNS(WFS.WFSNS, 'Transaction');
var version = options.version ?
options) {
const objectStack = [];
const node = _ol_xml_.createElementNS(WFS.WFSNS, 'Transaction');
const version = options.version ?
options.version : WFS.DEFAULT_VERSION;
var gmlVersion = version === '1.0.0' ? 2 : 3;
const gmlVersion = version === '1.0.0' ? 2 : 3;
node.setAttribute('service', 'WFS');
node.setAttribute('version', version);
var baseObj;
let baseObj;
/** @type {ol.XmlNodeStackItem} */
var obj;
let obj;
if (options) {
baseObj = options.gmlOptions ? options.gmlOptions : {};
if (options.handle) {
node.setAttribute('handle', options.handle);
}
}
var schemaLocation = WFS.SCHEMA_LOCATIONS[version];
const schemaLocation = WFS.SCHEMA_LOCATIONS[version];
_ol_xml_.setAttributeNS(node, 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation', schemaLocation);
var featurePrefix = options.featurePrefix ? options.featurePrefix : WFS.FEATURE_PREFIX;
'xsi:schemaLocation', schemaLocation);
const featurePrefix = options.featurePrefix ? options.featurePrefix : WFS.FEATURE_PREFIX;
if (inserts) {
obj = {node: node, 'featureNS': options.featureNS,
'featureType': options.featureType, 'featurePrefix': featurePrefix,
'gmlVersion': gmlVersion, 'hasZ': options.hasZ, 'srsName': options.srsName};
_ol_obj_.assign(obj, baseObj);
_ol_xml_.pushSerializeAndPop(obj,
WFS.TRANSACTION_SERIALIZERS_,
_ol_xml_.makeSimpleNodeFactory('Insert'), inserts,
objectStack);
WFS.TRANSACTION_SERIALIZERS_,
_ol_xml_.makeSimpleNodeFactory('Insert'), inserts,
objectStack);
}
if (updates) {
obj = {node: node, 'featureNS': options.featureNS,
@@ -1037,9 +1037,9 @@ WFS.prototype.writeTransaction = function(inserts, updates, deletes,
'gmlVersion': gmlVersion, 'hasZ': options.hasZ, 'srsName': options.srsName};
_ol_obj_.assign(obj, baseObj);
_ol_xml_.pushSerializeAndPop(obj,
WFS.TRANSACTION_SERIALIZERS_,
_ol_xml_.makeSimpleNodeFactory('Update'), updates,
objectStack);
WFS.TRANSACTION_SERIALIZERS_,
_ol_xml_.makeSimpleNodeFactory('Update'), updates,
objectStack);
}
if (deletes) {
_ol_xml_.pushSerializeAndPop({node: node, 'featureNS': options.featureNS,
@@ -1076,7 +1076,7 @@ WFS.prototype.readProjection;
* @inheritDoc
*/
WFS.prototype.readProjectionFromDocument = function(doc) {
for (var n = doc.firstChild; n; n = n.nextSibling) {
for (let n = doc.firstChild; n; n = n.nextSibling) {
if (n.nodeType == Node.ELEMENT_NODE) {
return this.readProjectionFromNode(n);
}
@@ -1092,11 +1092,11 @@ WFS.prototype.readProjectionFromNode = function(node) {
if (node.firstElementChild &&
node.firstElementChild.firstElementChild) {
node = node.firstElementChild.firstElementChild;
for (var n = node.firstElementChild; n; n = n.nextElementSibling) {
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
if (!(n.childNodes.length === 0 ||
(n.childNodes.length === 1 &&
n.firstChild.nodeType === 3))) {
var objectStack = [{}];
const objectStack = [{}];
this.gmlFormat_.readGeometryElement(n, objectStack);
return getProjection(objectStack.pop().srsName);
}
+82 -79
View File
@@ -26,9 +26,9 @@ import SimpleGeometry from '../geom/SimpleGeometry.js';
* @param {olx.format.WKTOptions=} opt_options Options.
* @api
*/
var WKT = function(opt_options) {
const WKT = function(opt_options) {
var options = opt_options ? opt_options : {};
const options = opt_options ? opt_options : {};
TextFeature.call(this);
@@ -79,7 +79,7 @@ WKT.ZM = 'ZM';
* @private
*/
WKT.encodePointGeometry_ = function(geom) {
var coordinates = geom.getCoordinates();
const coordinates = geom.getCoordinates();
if (coordinates.length === 0) {
return '';
}
@@ -93,9 +93,9 @@ WKT.encodePointGeometry_ = function(geom) {
* @private
*/
WKT.encodeMultiPointGeometry_ = function(geom) {
var array = [];
var components = geom.getPoints();
for (var i = 0, ii = components.length; i < ii; ++i) {
const array = [];
const components = geom.getPoints();
for (let i = 0, ii = components.length; i < ii; ++i) {
array.push('(' + WKT.encodePointGeometry_(components[i]) + ')');
}
return array.join(',');
@@ -108,9 +108,9 @@ WKT.encodeMultiPointGeometry_ = function(geom) {
* @private
*/
WKT.encodeGeometryCollectionGeometry_ = function(geom) {
var array = [];
var geoms = geom.getGeometries();
for (var i = 0, ii = geoms.length; i < ii; ++i) {
const array = [];
const geoms = geom.getGeometries();
for (let i = 0, ii = geoms.length; i < ii; ++i) {
array.push(WKT.encode_(geoms[i]));
}
return array.join(',');
@@ -123,9 +123,9 @@ WKT.encodeGeometryCollectionGeometry_ = function(geom) {
* @private
*/
WKT.encodeLineStringGeometry_ = function(geom) {
var coordinates = geom.getCoordinates();
var array = [];
for (var i = 0, ii = coordinates.length; i < ii; ++i) {
const coordinates = geom.getCoordinates();
const array = [];
for (let i = 0, ii = coordinates.length; i < ii; ++i) {
array.push(coordinates[i].join(' '));
}
return array.join(',');
@@ -138,11 +138,11 @@ WKT.encodeLineStringGeometry_ = function(geom) {
* @private
*/
WKT.encodeMultiLineStringGeometry_ = function(geom) {
var array = [];
var components = geom.getLineStrings();
for (var i = 0, ii = components.length; i < ii; ++i) {
const array = [];
const components = geom.getLineStrings();
for (let i = 0, ii = components.length; i < ii; ++i) {
array.push('(' + WKT.encodeLineStringGeometry_(
components[i]) + ')');
components[i]) + ')');
}
return array.join(',');
};
@@ -154,11 +154,11 @@ WKT.encodeMultiLineStringGeometry_ = function(geom) {
* @private
*/
WKT.encodePolygonGeometry_ = function(geom) {
var array = [];
var rings = geom.getLinearRings();
for (var i = 0, ii = rings.length; i < ii; ++i) {
const array = [];
const rings = geom.getLinearRings();
for (let i = 0, ii = rings.length; i < ii; ++i) {
array.push('(' + WKT.encodeLineStringGeometry_(
rings[i]) + ')');
rings[i]) + ')');
}
return array.join(',');
};
@@ -170,11 +170,11 @@ WKT.encodePolygonGeometry_ = function(geom) {
* @private
*/
WKT.encodeMultiPolygonGeometry_ = function(geom) {
var array = [];
var components = geom.getPolygons();
for (var i = 0, ii = components.length; i < ii; ++i) {
const array = [];
const components = geom.getPolygons();
for (let i = 0, ii = components.length; i < ii; ++i) {
array.push('(' + WKT.encodePolygonGeometry_(
components[i]) + ')');
components[i]) + ')');
}
return array.join(',');
};
@@ -185,8 +185,8 @@ WKT.encodeMultiPolygonGeometry_ = function(geom) {
* @private
*/
WKT.encodeGeometryLayout_ = function(geom) {
var layout = geom.getLayout();
var dimInfo = '';
const layout = geom.getLayout();
let dimInfo = '';
if (layout === GeometryLayout.XYZ || layout === GeometryLayout.XYZM) {
dimInfo += WKT.Z;
}
@@ -204,12 +204,12 @@ WKT.encodeGeometryLayout_ = function(geom) {
* @private
*/
WKT.encode_ = function(geom) {
var type = geom.getType();
var geometryEncoder = WKT.GeometryEncoder_[type];
var enc = geometryEncoder(geom);
let type = geom.getType();
const geometryEncoder = WKT.GeometryEncoder_[type];
const enc = geometryEncoder(geom);
type = type.toUpperCase();
if (geom instanceof SimpleGeometry) {
var dimInfo = WKT.encodeGeometryLayout_(geom);
const dimInfo = WKT.encodeGeometryLayout_(geom);
if (dimInfo.length > 0) {
type += ' ' + dimInfo;
}
@@ -245,8 +245,8 @@ WKT.GeometryEncoder_ = {
* @private
*/
WKT.prototype.parse_ = function(wkt) {
var lexer = new WKT.Lexer(wkt);
var parser = new WKT.Parser(lexer);
const lexer = new WKT.Lexer(wkt);
const parser = new WKT.Parser(lexer);
return parser.parse();
};
@@ -267,9 +267,9 @@ WKT.prototype.readFeature;
* @inheritDoc
*/
WKT.prototype.readFeatureFromText = function(text, opt_options) {
var geom = this.readGeometryFromText(text, opt_options);
const geom = this.readGeometryFromText(text, opt_options);
if (geom) {
var feature = new Feature();
const feature = new Feature();
feature.setGeometry(geom);
return feature;
}
@@ -293,17 +293,18 @@ WKT.prototype.readFeatures;
* @inheritDoc
*/
WKT.prototype.readFeaturesFromText = function(text, opt_options) {
var geometries = [];
var geometry = this.readGeometryFromText(text, opt_options);
let geometries = [];
const geometry = this.readGeometryFromText(text, opt_options);
if (this.splitCollection_ &&
geometry.getType() == GeometryType.GEOMETRY_COLLECTION) {
geometries = (/** @type {ol.geom.GeometryCollection} */ (geometry))
.getGeometriesArray();
.getGeometriesArray();
} else {
geometries = [geometry];
}
var feature, features = [];
for (var i = 0, ii = geometries.length; i < ii; ++i) {
const features = [];
let feature;
for (let i = 0, ii = geometries.length; i < ii; ++i) {
feature = new Feature();
feature.setGeometry(geometries[i]);
features.push(feature);
@@ -328,7 +329,7 @@ WKT.prototype.readGeometry;
* @inheritDoc
*/
WKT.prototype.readGeometryFromText = function(text, opt_options) {
var geometry = this.parse_(text);
const geometry = this.parse_(text);
if (geometry) {
return (
/** @type {ol.geom.Geometry} */ transformWithOptions(geometry, false, opt_options)
@@ -355,7 +356,7 @@ WKT.prototype.writeFeature;
* @inheritDoc
*/
WKT.prototype.writeFeatureText = function(feature, opt_options) {
var geometry = feature.getGeometry();
const geometry = feature.getGeometry();
if (geometry) {
return this.writeGeometryText(geometry, opt_options);
}
@@ -382,11 +383,11 @@ 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) {
const geometries = [];
for (let i = 0, ii = features.length; i < ii; ++i) {
geometries.push(features[i].getGeometry());
}
var collection = new GeometryCollection(geometries);
const collection = new GeometryCollection(geometries);
return this.writeGeometryText(collection, opt_options);
};
@@ -466,7 +467,7 @@ WKT.Lexer.prototype.isAlpha_ = function(c) {
* @private
*/
WKT.Lexer.prototype.isNumeric_ = function(c, opt_decimal) {
var decimal = opt_decimal !== undefined ? opt_decimal : false;
const decimal = opt_decimal !== undefined ? opt_decimal : false;
return c >= '0' && c <= '9' || c == '.' && !decimal;
};
@@ -495,8 +496,8 @@ WKT.Lexer.prototype.nextChar_ = function() {
* @return {!ol.WKTToken} Next string token.
*/
WKT.Lexer.prototype.nextToken = function() {
var c = this.nextChar_();
var token = {position: this.index_, value: c};
const c = this.nextChar_();
const token = {position: this.index_, value: c};
if (c == '(') {
token.type = WKT.TokenType_.LEFT_PAREN;
@@ -527,9 +528,10 @@ WKT.Lexer.prototype.nextToken = function() {
* @private
*/
WKT.Lexer.prototype.readNumber_ = function() {
var c, index = this.index_;
var decimal = false;
var scientificNotation = false;
let c;
const index = this.index_;
let decimal = false;
let scientificNotation = false;
do {
if (c == '.') {
decimal = true;
@@ -555,7 +557,8 @@ WKT.Lexer.prototype.readNumber_ = function() {
* @private
*/
WKT.Lexer.prototype.readText_ = function() {
var c, index = this.index_;
let c;
const index = this.index_;
do {
c = this.nextChar_();
} while (this.isAlpha_(c));
@@ -605,7 +608,7 @@ WKT.Parser.prototype.consume_ = function() {
* @return {boolean} Whether the token matches the given type.
*/
WKT.Parser.prototype.isTokenType = function(type) {
var isMatch = this.token_.type == type;
const isMatch = this.token_.type == type;
return isMatch;
};
@@ -616,7 +619,7 @@ WKT.Parser.prototype.isTokenType = function(type) {
* @return {boolean} Whether the token matches the given type.
*/
WKT.Parser.prototype.match = function(type) {
var isMatch = this.isTokenType(type);
const isMatch = this.isTokenType(type);
if (isMatch) {
this.consume_();
}
@@ -630,7 +633,7 @@ WKT.Parser.prototype.match = function(type) {
*/
WKT.Parser.prototype.parse = function() {
this.consume_();
var geometry = this.parseGeometry_();
const geometry = this.parseGeometry_();
return geometry;
};
@@ -641,10 +644,10 @@ WKT.Parser.prototype.parse = function() {
* @private
*/
WKT.Parser.prototype.parseGeometryLayout_ = function() {
var layout = GeometryLayout.XY;
var dimToken = this.token_;
let layout = GeometryLayout.XY;
const dimToken = this.token_;
if (this.isTokenType(WKT.TokenType_.TEXT)) {
var dimInfo = dimToken.value;
const dimInfo = dimToken.value;
if (dimInfo === WKT.Z) {
layout = GeometryLayout.XYZ;
} else if (dimInfo === WKT.M) {
@@ -665,20 +668,20 @@ WKT.Parser.prototype.parseGeometryLayout_ = function() {
* @private
*/
WKT.Parser.prototype.parseGeometry_ = function() {
var token = this.token_;
const token = this.token_;
if (this.match(WKT.TokenType_.TEXT)) {
var geomType = token.value;
const geomType = token.value;
this.layout_ = this.parseGeometryLayout_();
if (geomType == GeometryType.GEOMETRY_COLLECTION.toUpperCase()) {
var geometries = this.parseGeometryCollectionText_();
const geometries = this.parseGeometryCollectionText_();
return new GeometryCollection(geometries);
} else {
var parser = WKT.Parser.GeometryParser_[geomType];
var ctor = WKT.Parser.GeometryConstructor_[geomType];
const parser = WKT.Parser.GeometryParser_[geomType];
const ctor = WKT.Parser.GeometryConstructor_[geomType];
if (!parser || !ctor) {
throw new Error('Invalid geometry type: ' + geomType);
}
var coordinates = parser.call(this);
const coordinates = parser.call(this);
return new ctor(coordinates, this.layout_);
}
}
@@ -692,7 +695,7 @@ WKT.Parser.prototype.parseGeometry_ = function() {
*/
WKT.Parser.prototype.parseGeometryCollectionText_ = function() {
if (this.match(WKT.TokenType_.LEFT_PAREN)) {
var geometries = [];
const geometries = [];
do {
geometries.push(this.parseGeometry_());
} while (this.match(WKT.TokenType_.COMMA));
@@ -712,7 +715,7 @@ WKT.Parser.prototype.parseGeometryCollectionText_ = function() {
*/
WKT.Parser.prototype.parsePointText_ = function() {
if (this.match(WKT.TokenType_.LEFT_PAREN)) {
var coordinates = this.parsePoint_();
const coordinates = this.parsePoint_();
if (this.match(WKT.TokenType_.RIGHT_PAREN)) {
return coordinates;
}
@@ -729,7 +732,7 @@ WKT.Parser.prototype.parsePointText_ = function() {
*/
WKT.Parser.prototype.parseLineStringText_ = function() {
if (this.match(WKT.TokenType_.LEFT_PAREN)) {
var coordinates = this.parsePointList_();
const coordinates = this.parsePointList_();
if (this.match(WKT.TokenType_.RIGHT_PAREN)) {
return coordinates;
}
@@ -746,7 +749,7 @@ WKT.Parser.prototype.parseLineStringText_ = function() {
*/
WKT.Parser.prototype.parsePolygonText_ = function() {
if (this.match(WKT.TokenType_.LEFT_PAREN)) {
var coordinates = this.parseLineStringTextList_();
const coordinates = this.parseLineStringTextList_();
if (this.match(WKT.TokenType_.RIGHT_PAREN)) {
return coordinates;
}
@@ -763,7 +766,7 @@ WKT.Parser.prototype.parsePolygonText_ = function() {
*/
WKT.Parser.prototype.parseMultiPointText_ = function() {
if (this.match(WKT.TokenType_.LEFT_PAREN)) {
var coordinates;
let coordinates;
if (this.token_.type == WKT.TokenType_.LEFT_PAREN) {
coordinates = this.parsePointTextList_();
} else {
@@ -786,7 +789,7 @@ WKT.Parser.prototype.parseMultiPointText_ = function() {
*/
WKT.Parser.prototype.parseMultiLineStringText_ = function() {
if (this.match(WKT.TokenType_.LEFT_PAREN)) {
var coordinates = this.parseLineStringTextList_();
const coordinates = this.parseLineStringTextList_();
if (this.match(WKT.TokenType_.RIGHT_PAREN)) {
return coordinates;
}
@@ -803,7 +806,7 @@ WKT.Parser.prototype.parseMultiLineStringText_ = function() {
*/
WKT.Parser.prototype.parseMultiPolygonText_ = function() {
if (this.match(WKT.TokenType_.LEFT_PAREN)) {
var coordinates = this.parsePolygonTextList_();
const coordinates = this.parsePolygonTextList_();
if (this.match(WKT.TokenType_.RIGHT_PAREN)) {
return coordinates;
}
@@ -819,10 +822,10 @@ WKT.Parser.prototype.parseMultiPolygonText_ = function() {
* @private
*/
WKT.Parser.prototype.parsePoint_ = function() {
var coordinates = [];
var dimensions = this.layout_.length;
for (var i = 0; i < dimensions; ++i) {
var token = this.token_;
const coordinates = [];
const dimensions = this.layout_.length;
for (let i = 0; i < dimensions; ++i) {
const token = this.token_;
if (this.match(WKT.TokenType_.NUMBER)) {
coordinates.push(token.value);
} else {
@@ -841,7 +844,7 @@ WKT.Parser.prototype.parsePoint_ = function() {
* @private
*/
WKT.Parser.prototype.parsePointList_ = function() {
var coordinates = [this.parsePoint_()];
const coordinates = [this.parsePoint_()];
while (this.match(WKT.TokenType_.COMMA)) {
coordinates.push(this.parsePoint_());
}
@@ -854,7 +857,7 @@ WKT.Parser.prototype.parsePointList_ = function() {
* @private
*/
WKT.Parser.prototype.parsePointTextList_ = function() {
var coordinates = [this.parsePointText_()];
const coordinates = [this.parsePointText_()];
while (this.match(WKT.TokenType_.COMMA)) {
coordinates.push(this.parsePointText_());
}
@@ -867,7 +870,7 @@ WKT.Parser.prototype.parsePointTextList_ = function() {
* @private
*/
WKT.Parser.prototype.parseLineStringTextList_ = function() {
var coordinates = [this.parseLineStringText_()];
const coordinates = [this.parseLineStringText_()];
while (this.match(WKT.TokenType_.COMMA)) {
coordinates.push(this.parseLineStringText_());
}
@@ -880,7 +883,7 @@ WKT.Parser.prototype.parseLineStringTextList_ = function() {
* @private
*/
WKT.Parser.prototype.parsePolygonTextList_ = function() {
var coordinates = [this.parsePolygonText_()];
const coordinates = [this.parsePolygonText_()];
while (this.match(WKT.TokenType_.COMMA)) {
coordinates.push(this.parsePolygonText_());
}
@@ -893,7 +896,7 @@ WKT.Parser.prototype.parsePolygonTextList_ = function() {
* @private
*/
WKT.Parser.prototype.isEmptyGeometry_ = function() {
var isEmpty = this.isTokenType(WKT.TokenType_.TEXT) &&
const isEmpty = this.isTokenType(WKT.TokenType_.TEXT) &&
this.token_.value == WKT.EMPTY;
if (isEmpty) {
this.consume_();
+201 -201
View File
@@ -15,7 +15,7 @@ import _ol_xml_ from '../xml.js';
* @extends {ol.format.XML}
* @api
*/
var WMSCapabilities = function() {
const WMSCapabilities = function() {
XML.call(this);
@@ -43,7 +43,7 @@ WMSCapabilities.prototype.read;
* @inheritDoc
*/
WMSCapabilities.prototype.readFromDocument = function(doc) {
for (var n = doc.firstChild; n; n = n.nextSibling) {
for (let n = doc.firstChild; n; n = n.nextSibling) {
if (n.nodeType == Node.ELEMENT_NODE) {
return this.readFromNode(n);
}
@@ -57,7 +57,7 @@ WMSCapabilities.prototype.readFromDocument = function(doc) {
*/
WMSCapabilities.prototype.readFromNode = function(node) {
this.version = node.getAttribute('version').trim();
var wmsCapabilityObject = _ol_xml_.pushParseAndPop({
const wmsCapabilityObject = _ol_xml_.pushParseAndPop({
'version': this.version
}, WMSCapabilities.PARSERS_, node, []);
return wmsCapabilityObject ? wmsCapabilityObject : null;
@@ -72,7 +72,7 @@ WMSCapabilities.prototype.readFromNode = function(node) {
*/
WMSCapabilities.readAttribution_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop(
{}, WMSCapabilities.ATTRIBUTION_PARSERS_, node, objectStack);
{}, WMSCapabilities.ATTRIBUTION_PARSERS_, node, objectStack);
};
@@ -83,14 +83,14 @@ WMSCapabilities.readAttribution_ = function(node, objectStack) {
* @return {Object} Bounding box object.
*/
WMSCapabilities.readBoundingBox_ = function(node, objectStack) {
var extent = [
const extent = [
XSD.readDecimalString(node.getAttribute('minx')),
XSD.readDecimalString(node.getAttribute('miny')),
XSD.readDecimalString(node.getAttribute('maxx')),
XSD.readDecimalString(node.getAttribute('maxy'))
];
var resolutions = [
const resolutions = [
XSD.readDecimalString(node.getAttribute('resx')),
XSD.readDecimalString(node.getAttribute('resy'))
];
@@ -110,20 +110,20 @@ WMSCapabilities.readBoundingBox_ = function(node, objectStack) {
* @return {ol.Extent|undefined} Bounding box object.
*/
WMSCapabilities.readEXGeographicBoundingBox_ = function(node, objectStack) {
var geographicBoundingBox = _ol_xml_.pushParseAndPop(
{},
WMSCapabilities.EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS_,
node, objectStack);
const geographicBoundingBox = _ol_xml_.pushParseAndPop(
{},
WMSCapabilities.EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS_,
node, objectStack);
if (!geographicBoundingBox) {
return undefined;
}
var westBoundLongitude = /** @type {number|undefined} */
const westBoundLongitude = /** @type {number|undefined} */
(geographicBoundingBox['westBoundLongitude']);
var southBoundLatitude = /** @type {number|undefined} */
const southBoundLatitude = /** @type {number|undefined} */
(geographicBoundingBox['southBoundLatitude']);
var eastBoundLongitude = /** @type {number|undefined} */
const eastBoundLongitude = /** @type {number|undefined} */
(geographicBoundingBox['eastBoundLongitude']);
var northBoundLatitude = /** @type {number|undefined} */
const northBoundLatitude = /** @type {number|undefined} */
(geographicBoundingBox['northBoundLatitude']);
if (westBoundLongitude === undefined || southBoundLatitude === undefined ||
eastBoundLongitude === undefined || northBoundLatitude === undefined) {
@@ -144,7 +144,7 @@ WMSCapabilities.readEXGeographicBoundingBox_ = function(node, objectStack) {
*/
WMSCapabilities.readCapability_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop(
{}, WMSCapabilities.CAPABILITY_PARSERS_, node, objectStack);
{}, WMSCapabilities.CAPABILITY_PARSERS_, node, objectStack);
};
@@ -156,7 +156,7 @@ WMSCapabilities.readCapability_ = function(node, objectStack) {
*/
WMSCapabilities.readService_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop(
{}, WMSCapabilities.SERVICE_PARSERS_, node, objectStack);
{}, WMSCapabilities.SERVICE_PARSERS_, node, objectStack);
};
@@ -168,8 +168,8 @@ WMSCapabilities.readService_ = function(node, objectStack) {
*/
WMSCapabilities.readContactInformation_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop(
{}, WMSCapabilities.CONTACT_INFORMATION_PARSERS_,
node, objectStack);
{}, WMSCapabilities.CONTACT_INFORMATION_PARSERS_,
node, objectStack);
};
@@ -181,8 +181,8 @@ WMSCapabilities.readContactInformation_ = function(node, objectStack) {
*/
WMSCapabilities.readContactPersonPrimary_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop(
{}, WMSCapabilities.CONTACT_PERSON_PARSERS_,
node, objectStack);
{}, WMSCapabilities.CONTACT_PERSON_PARSERS_,
node, objectStack);
};
@@ -194,8 +194,8 @@ WMSCapabilities.readContactPersonPrimary_ = function(node, objectStack) {
*/
WMSCapabilities.readContactAddress_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop(
{}, WMSCapabilities.CONTACT_ADDRESS_PARSERS_,
node, objectStack);
{}, WMSCapabilities.CONTACT_ADDRESS_PARSERS_,
node, objectStack);
};
@@ -207,7 +207,7 @@ WMSCapabilities.readContactAddress_ = function(node, objectStack) {
*/
WMSCapabilities.readException_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop(
[], WMSCapabilities.EXCEPTION_PARSERS_, node, objectStack);
[], WMSCapabilities.EXCEPTION_PARSERS_, node, objectStack);
};
@@ -219,7 +219,7 @@ WMSCapabilities.readException_ = function(node, objectStack) {
*/
WMSCapabilities.readCapabilityLayer_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop(
{}, WMSCapabilities.LAYER_PARSERS_, node, objectStack);
{}, WMSCapabilities.LAYER_PARSERS_, node, objectStack);
};
@@ -230,50 +230,50 @@ WMSCapabilities.readCapabilityLayer_ = function(node, objectStack) {
* @return {Object|undefined} Layer object.
*/
WMSCapabilities.readLayer_ = function(node, objectStack) {
var parentLayerObject = /** @type {Object.<string,*>} */
const parentLayerObject = /** @type {Object.<string,*>} */
(objectStack[objectStack.length - 1]);
var layerObject = _ol_xml_.pushParseAndPop(
{}, WMSCapabilities.LAYER_PARSERS_, node, objectStack);
const layerObject = _ol_xml_.pushParseAndPop(
{}, WMSCapabilities.LAYER_PARSERS_, node, objectStack);
if (!layerObject) {
return undefined;
}
var queryable =
let queryable =
XSD.readBooleanString(node.getAttribute('queryable'));
if (queryable === undefined) {
queryable = parentLayerObject['queryable'];
}
layerObject['queryable'] = queryable !== undefined ? queryable : false;
var cascaded = XSD.readNonNegativeIntegerString(
node.getAttribute('cascaded'));
let cascaded = XSD.readNonNegativeIntegerString(
node.getAttribute('cascaded'));
if (cascaded === undefined) {
cascaded = parentLayerObject['cascaded'];
}
layerObject['cascaded'] = cascaded;
var opaque = XSD.readBooleanString(node.getAttribute('opaque'));
let opaque = XSD.readBooleanString(node.getAttribute('opaque'));
if (opaque === undefined) {
opaque = parentLayerObject['opaque'];
}
layerObject['opaque'] = opaque !== undefined ? opaque : false;
var noSubsets =
let noSubsets =
XSD.readBooleanString(node.getAttribute('noSubsets'));
if (noSubsets === undefined) {
noSubsets = parentLayerObject['noSubsets'];
}
layerObject['noSubsets'] = noSubsets !== undefined ? noSubsets : false;
var fixedWidth =
let fixedWidth =
XSD.readDecimalString(node.getAttribute('fixedWidth'));
if (!fixedWidth) {
fixedWidth = parentLayerObject['fixedWidth'];
}
layerObject['fixedWidth'] = fixedWidth;
var fixedHeight =
let fixedHeight =
XSD.readDecimalString(node.getAttribute('fixedHeight'));
if (!fixedHeight) {
fixedHeight = parentLayerObject['fixedHeight'];
@@ -281,19 +281,19 @@ WMSCapabilities.readLayer_ = function(node, objectStack) {
layerObject['fixedHeight'] = fixedHeight;
// See 7.2.4.8
var addKeys = ['Style', 'CRS', 'AuthorityURL'];
const addKeys = ['Style', 'CRS', 'AuthorityURL'];
addKeys.forEach(function(key) {
if (key in parentLayerObject) {
var childValue = layerObject[key] || [];
const childValue = layerObject[key] || [];
layerObject[key] = childValue.concat(parentLayerObject[key]);
}
});
var replaceKeys = ['EX_GeographicBoundingBox', 'BoundingBox', 'Dimension',
const replaceKeys = ['EX_GeographicBoundingBox', 'BoundingBox', 'Dimension',
'Attribution', 'MinScaleDenominator', 'MaxScaleDenominator'];
replaceKeys.forEach(function(key) {
if (!(key in layerObject)) {
var parentValue = parentLayerObject[key];
const parentValue = parentLayerObject[key];
layerObject[key] = parentValue;
}
});
@@ -309,15 +309,15 @@ WMSCapabilities.readLayer_ = function(node, objectStack) {
* @return {Object} Dimension object.
*/
WMSCapabilities.readDimension_ = function(node, objectStack) {
var dimensionObject = {
const dimensionObject = {
'name': node.getAttribute('name'),
'units': node.getAttribute('units'),
'unitSymbol': node.getAttribute('unitSymbol'),
'default': node.getAttribute('default'),
'multipleValues': XSD.readBooleanString(
node.getAttribute('multipleValues')),
node.getAttribute('multipleValues')),
'nearestValue': XSD.readBooleanString(
node.getAttribute('nearestValue')),
node.getAttribute('nearestValue')),
'current': XSD.readBooleanString(node.getAttribute('current')),
'values': XSD.readString(node)
};
@@ -333,8 +333,8 @@ WMSCapabilities.readDimension_ = function(node, objectStack) {
*/
WMSCapabilities.readFormatOnlineresource_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop(
{}, WMSCapabilities.FORMAT_ONLINERESOURCE_PARSERS_,
node, objectStack);
{}, WMSCapabilities.FORMAT_ONLINERESOURCE_PARSERS_,
node, objectStack);
};
@@ -346,7 +346,7 @@ WMSCapabilities.readFormatOnlineresource_ = function(node, objectStack) {
*/
WMSCapabilities.readRequest_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop(
{}, WMSCapabilities.REQUEST_PARSERS_, node, objectStack);
{}, WMSCapabilities.REQUEST_PARSERS_, node, objectStack);
};
@@ -358,7 +358,7 @@ WMSCapabilities.readRequest_ = function(node, objectStack) {
*/
WMSCapabilities.readDCPType_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop(
{}, WMSCapabilities.DCPTYPE_PARSERS_, node, objectStack);
{}, WMSCapabilities.DCPTYPE_PARSERS_, node, objectStack);
};
@@ -370,7 +370,7 @@ WMSCapabilities.readDCPType_ = function(node, objectStack) {
*/
WMSCapabilities.readHTTP_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop(
{}, WMSCapabilities.HTTP_PARSERS_, node, objectStack);
{}, WMSCapabilities.HTTP_PARSERS_, node, objectStack);
};
@@ -382,7 +382,7 @@ WMSCapabilities.readHTTP_ = function(node, objectStack) {
*/
WMSCapabilities.readOperationType_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop(
{}, WMSCapabilities.OPERATIONTYPE_PARSERS_, node, objectStack);
{}, WMSCapabilities.OPERATIONTYPE_PARSERS_, node, objectStack);
};
@@ -393,10 +393,10 @@ WMSCapabilities.readOperationType_ = function(node, objectStack) {
* @return {Object|undefined} Online resource object.
*/
WMSCapabilities.readSizedFormatOnlineresource_ = function(node, objectStack) {
var formatOnlineresource =
const formatOnlineresource =
WMSCapabilities.readFormatOnlineresource_(node, objectStack);
if (formatOnlineresource) {
var size = [
const size = [
XSD.readNonNegativeIntegerString(node.getAttribute('width')),
XSD.readNonNegativeIntegerString(node.getAttribute('height'))
];
@@ -414,7 +414,7 @@ WMSCapabilities.readSizedFormatOnlineresource_ = function(node, objectStack) {
* @return {Object|undefined} Authority URL object.
*/
WMSCapabilities.readAuthorityURL_ = function(node, objectStack) {
var authorityObject =
const authorityObject =
WMSCapabilities.readFormatOnlineresource_(node, objectStack);
if (authorityObject) {
authorityObject['name'] = node.getAttribute('name');
@@ -431,7 +431,7 @@ WMSCapabilities.readAuthorityURL_ = function(node, objectStack) {
* @return {Object|undefined} Metadata URL object.
*/
WMSCapabilities.readMetadataURL_ = function(node, objectStack) {
var metadataObject =
const metadataObject =
WMSCapabilities.readFormatOnlineresource_(node, objectStack);
if (metadataObject) {
metadataObject['type'] = node.getAttribute('type');
@@ -449,7 +449,7 @@ WMSCapabilities.readMetadataURL_ = function(node, objectStack) {
*/
WMSCapabilities.readStyle_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop(
{}, WMSCapabilities.STYLE_PARSERS_, node, objectStack);
{}, WMSCapabilities.STYLE_PARSERS_, node, objectStack);
};
@@ -461,7 +461,7 @@ WMSCapabilities.readStyle_ = function(node, objectStack) {
*/
WMSCapabilities.readKeywordList_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop(
[], WMSCapabilities.KEYWORDLIST_PARSERS_, node, objectStack);
[], WMSCapabilities.KEYWORDLIST_PARSERS_, node, objectStack);
};
@@ -482,12 +482,12 @@ WMSCapabilities.NAMESPACE_URIS_ = [
* @private
*/
WMSCapabilities.PARSERS_ = _ol_xml_.makeStructureNS(
WMSCapabilities.NAMESPACE_URIS_, {
'Service': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readService_),
'Capability': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readCapability_)
});
WMSCapabilities.NAMESPACE_URIS_, {
'Service': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readService_),
'Capability': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readCapability_)
});
/**
@@ -496,14 +496,14 @@ WMSCapabilities.PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
WMSCapabilities.CAPABILITY_PARSERS_ = _ol_xml_.makeStructureNS(
WMSCapabilities.NAMESPACE_URIS_, {
'Request': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readRequest_),
'Exception': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readException_),
'Layer': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readCapabilityLayer_)
});
WMSCapabilities.NAMESPACE_URIS_, {
'Request': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readRequest_),
'Exception': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readException_),
'Layer': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readCapabilityLayer_)
});
/**
@@ -512,26 +512,26 @@ WMSCapabilities.CAPABILITY_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
WMSCapabilities.SERVICE_PARSERS_ = _ol_xml_.makeStructureNS(
WMSCapabilities.NAMESPACE_URIS_, {
'Name': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Title': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Abstract': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'KeywordList': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readKeywordList_),
'OnlineResource': _ol_xml_.makeObjectPropertySetter(
XLink.readHref),
'ContactInformation': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readContactInformation_),
'Fees': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'AccessConstraints': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'LayerLimit': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger),
'MaxWidth': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger),
'MaxHeight': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger)
});
WMSCapabilities.NAMESPACE_URIS_, {
'Name': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Title': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Abstract': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'KeywordList': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readKeywordList_),
'OnlineResource': _ol_xml_.makeObjectPropertySetter(
XLink.readHref),
'ContactInformation': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readContactInformation_),
'Fees': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'AccessConstraints': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'LayerLimit': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger),
'MaxWidth': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger),
'MaxHeight': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger)
});
/**
@@ -540,20 +540,20 @@ WMSCapabilities.SERVICE_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
WMSCapabilities.CONTACT_INFORMATION_PARSERS_ = _ol_xml_.makeStructureNS(
WMSCapabilities.NAMESPACE_URIS_, {
'ContactPersonPrimary': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readContactPersonPrimary_),
'ContactPosition': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'ContactAddress': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readContactAddress_),
'ContactVoiceTelephone': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'ContactFacsimileTelephone': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'ContactElectronicMailAddress': _ol_xml_.makeObjectPropertySetter(
XSD.readString)
});
WMSCapabilities.NAMESPACE_URIS_, {
'ContactPersonPrimary': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readContactPersonPrimary_),
'ContactPosition': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'ContactAddress': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readContactAddress_),
'ContactVoiceTelephone': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'ContactFacsimileTelephone': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'ContactElectronicMailAddress': _ol_xml_.makeObjectPropertySetter(
XSD.readString)
});
/**
@@ -562,12 +562,12 @@ WMSCapabilities.CONTACT_INFORMATION_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
WMSCapabilities.CONTACT_PERSON_PARSERS_ = _ol_xml_.makeStructureNS(
WMSCapabilities.NAMESPACE_URIS_, {
'ContactPerson': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'ContactOrganization': _ol_xml_.makeObjectPropertySetter(
XSD.readString)
});
WMSCapabilities.NAMESPACE_URIS_, {
'ContactPerson': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'ContactOrganization': _ol_xml_.makeObjectPropertySetter(
XSD.readString)
});
/**
@@ -576,15 +576,15 @@ WMSCapabilities.CONTACT_PERSON_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
WMSCapabilities.CONTACT_ADDRESS_PARSERS_ = _ol_xml_.makeStructureNS(
WMSCapabilities.NAMESPACE_URIS_, {
'AddressType': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Address': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'City': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'StateOrProvince': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'PostCode': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Country': _ol_xml_.makeObjectPropertySetter(XSD.readString)
});
WMSCapabilities.NAMESPACE_URIS_, {
'AddressType': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Address': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'City': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'StateOrProvince': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'PostCode': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Country': _ol_xml_.makeObjectPropertySetter(XSD.readString)
});
/**
@@ -593,9 +593,9 @@ WMSCapabilities.CONTACT_ADDRESS_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
WMSCapabilities.EXCEPTION_PARSERS_ = _ol_xml_.makeStructureNS(
WMSCapabilities.NAMESPACE_URIS_, {
'Format': _ol_xml_.makeArrayPusher(XSD.readString)
});
WMSCapabilities.NAMESPACE_URIS_, {
'Format': _ol_xml_.makeArrayPusher(XSD.readString)
});
/**
@@ -604,39 +604,39 @@ WMSCapabilities.EXCEPTION_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
WMSCapabilities.LAYER_PARSERS_ = _ol_xml_.makeStructureNS(
WMSCapabilities.NAMESPACE_URIS_, {
'Name': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Title': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Abstract': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'KeywordList': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readKeywordList_),
'CRS': _ol_xml_.makeObjectPropertyPusher(XSD.readString),
'EX_GeographicBoundingBox': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readEXGeographicBoundingBox_),
'BoundingBox': _ol_xml_.makeObjectPropertyPusher(
WMSCapabilities.readBoundingBox_),
'Dimension': _ol_xml_.makeObjectPropertyPusher(
WMSCapabilities.readDimension_),
'Attribution': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readAttribution_),
'AuthorityURL': _ol_xml_.makeObjectPropertyPusher(
WMSCapabilities.readAuthorityURL_),
'Identifier': _ol_xml_.makeObjectPropertyPusher(XSD.readString),
'MetadataURL': _ol_xml_.makeObjectPropertyPusher(
WMSCapabilities.readMetadataURL_),
'DataURL': _ol_xml_.makeObjectPropertyPusher(
WMSCapabilities.readFormatOnlineresource_),
'FeatureListURL': _ol_xml_.makeObjectPropertyPusher(
WMSCapabilities.readFormatOnlineresource_),
'Style': _ol_xml_.makeObjectPropertyPusher(
WMSCapabilities.readStyle_),
'MinScaleDenominator': _ol_xml_.makeObjectPropertySetter(
XSD.readDecimal),
'MaxScaleDenominator': _ol_xml_.makeObjectPropertySetter(
XSD.readDecimal),
'Layer': _ol_xml_.makeObjectPropertyPusher(
WMSCapabilities.readLayer_)
});
WMSCapabilities.NAMESPACE_URIS_, {
'Name': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Title': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Abstract': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'KeywordList': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readKeywordList_),
'CRS': _ol_xml_.makeObjectPropertyPusher(XSD.readString),
'EX_GeographicBoundingBox': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readEXGeographicBoundingBox_),
'BoundingBox': _ol_xml_.makeObjectPropertyPusher(
WMSCapabilities.readBoundingBox_),
'Dimension': _ol_xml_.makeObjectPropertyPusher(
WMSCapabilities.readDimension_),
'Attribution': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readAttribution_),
'AuthorityURL': _ol_xml_.makeObjectPropertyPusher(
WMSCapabilities.readAuthorityURL_),
'Identifier': _ol_xml_.makeObjectPropertyPusher(XSD.readString),
'MetadataURL': _ol_xml_.makeObjectPropertyPusher(
WMSCapabilities.readMetadataURL_),
'DataURL': _ol_xml_.makeObjectPropertyPusher(
WMSCapabilities.readFormatOnlineresource_),
'FeatureListURL': _ol_xml_.makeObjectPropertyPusher(
WMSCapabilities.readFormatOnlineresource_),
'Style': _ol_xml_.makeObjectPropertyPusher(
WMSCapabilities.readStyle_),
'MinScaleDenominator': _ol_xml_.makeObjectPropertySetter(
XSD.readDecimal),
'MaxScaleDenominator': _ol_xml_.makeObjectPropertySetter(
XSD.readDecimal),
'Layer': _ol_xml_.makeObjectPropertyPusher(
WMSCapabilities.readLayer_)
});
/**
@@ -645,13 +645,13 @@ WMSCapabilities.LAYER_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
WMSCapabilities.ATTRIBUTION_PARSERS_ = _ol_xml_.makeStructureNS(
WMSCapabilities.NAMESPACE_URIS_, {
'Title': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'OnlineResource': _ol_xml_.makeObjectPropertySetter(
XLink.readHref),
'LogoURL': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readSizedFormatOnlineresource_)
});
WMSCapabilities.NAMESPACE_URIS_, {
'Title': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'OnlineResource': _ol_xml_.makeObjectPropertySetter(
XLink.readHref),
'LogoURL': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readSizedFormatOnlineresource_)
});
/**
@@ -662,13 +662,13 @@ WMSCapabilities.ATTRIBUTION_PARSERS_ = _ol_xml_.makeStructureNS(
WMSCapabilities.EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS_ =
_ol_xml_.makeStructureNS(WMSCapabilities.NAMESPACE_URIS_, {
'westBoundLongitude': _ol_xml_.makeObjectPropertySetter(
XSD.readDecimal),
XSD.readDecimal),
'eastBoundLongitude': _ol_xml_.makeObjectPropertySetter(
XSD.readDecimal),
XSD.readDecimal),
'southBoundLatitude': _ol_xml_.makeObjectPropertySetter(
XSD.readDecimal),
XSD.readDecimal),
'northBoundLatitude': _ol_xml_.makeObjectPropertySetter(
XSD.readDecimal)
XSD.readDecimal)
});
@@ -678,14 +678,14 @@ WMSCapabilities.EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS_ =
* @private
*/
WMSCapabilities.REQUEST_PARSERS_ = _ol_xml_.makeStructureNS(
WMSCapabilities.NAMESPACE_URIS_, {
'GetCapabilities': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readOperationType_),
'GetMap': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readOperationType_),
'GetFeatureInfo': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readOperationType_)
});
WMSCapabilities.NAMESPACE_URIS_, {
'GetCapabilities': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readOperationType_),
'GetMap': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readOperationType_),
'GetFeatureInfo': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readOperationType_)
});
/**
@@ -694,11 +694,11 @@ WMSCapabilities.REQUEST_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
WMSCapabilities.OPERATIONTYPE_PARSERS_ = _ol_xml_.makeStructureNS(
WMSCapabilities.NAMESPACE_URIS_, {
'Format': _ol_xml_.makeObjectPropertyPusher(XSD.readString),
'DCPType': _ol_xml_.makeObjectPropertyPusher(
WMSCapabilities.readDCPType_)
});
WMSCapabilities.NAMESPACE_URIS_, {
'Format': _ol_xml_.makeObjectPropertyPusher(XSD.readString),
'DCPType': _ol_xml_.makeObjectPropertyPusher(
WMSCapabilities.readDCPType_)
});
/**
@@ -707,10 +707,10 @@ WMSCapabilities.OPERATIONTYPE_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
WMSCapabilities.DCPTYPE_PARSERS_ = _ol_xml_.makeStructureNS(
WMSCapabilities.NAMESPACE_URIS_, {
'HTTP': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readHTTP_)
});
WMSCapabilities.NAMESPACE_URIS_, {
'HTTP': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readHTTP_)
});
/**
@@ -719,12 +719,12 @@ WMSCapabilities.DCPTYPE_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
WMSCapabilities.HTTP_PARSERS_ = _ol_xml_.makeStructureNS(
WMSCapabilities.NAMESPACE_URIS_, {
'Get': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readFormatOnlineresource_),
'Post': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readFormatOnlineresource_)
});
WMSCapabilities.NAMESPACE_URIS_, {
'Get': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readFormatOnlineresource_),
'Post': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readFormatOnlineresource_)
});
/**
@@ -733,17 +733,17 @@ WMSCapabilities.HTTP_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
WMSCapabilities.STYLE_PARSERS_ = _ol_xml_.makeStructureNS(
WMSCapabilities.NAMESPACE_URIS_, {
'Name': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Title': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Abstract': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'LegendURL': _ol_xml_.makeObjectPropertyPusher(
WMSCapabilities.readSizedFormatOnlineresource_),
'StyleSheetURL': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readFormatOnlineresource_),
'StyleURL': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readFormatOnlineresource_)
});
WMSCapabilities.NAMESPACE_URIS_, {
'Name': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Title': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'Abstract': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'LegendURL': _ol_xml_.makeObjectPropertyPusher(
WMSCapabilities.readSizedFormatOnlineresource_),
'StyleSheetURL': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readFormatOnlineresource_),
'StyleURL': _ol_xml_.makeObjectPropertySetter(
WMSCapabilities.readFormatOnlineresource_)
});
/**
@@ -755,7 +755,7 @@ WMSCapabilities.FORMAT_ONLINERESOURCE_PARSERS_ =
_ol_xml_.makeStructureNS(WMSCapabilities.NAMESPACE_URIS_, {
'Format': _ol_xml_.makeObjectPropertySetter(XSD.readString),
'OnlineResource': _ol_xml_.makeObjectPropertySetter(
XLink.readHref)
XLink.readHref)
});
@@ -765,7 +765,7 @@ WMSCapabilities.FORMAT_ONLINERESOURCE_PARSERS_ =
* @private
*/
WMSCapabilities.KEYWORDLIST_PARSERS_ = _ol_xml_.makeStructureNS(
WMSCapabilities.NAMESPACE_URIS_, {
'Keyword': _ol_xml_.makeArrayPusher(XSD.readString)
});
WMSCapabilities.NAMESPACE_URIS_, {
'Keyword': _ol_xml_.makeArrayPusher(XSD.readString)
});
export default WMSCapabilities;
+20 -20
View File
@@ -18,9 +18,9 @@ import _ol_xml_ from '../xml.js';
* @param {olx.format.WMSGetFeatureInfoOptions=} opt_options Options.
* @api
*/
var WMSGetFeatureInfo = function(opt_options) {
const WMSGetFeatureInfo = function(opt_options) {
var options = opt_options ? opt_options : {};
const options = opt_options ? opt_options : {};
/**
* @private
@@ -88,50 +88,50 @@ WMSGetFeatureInfo.prototype.setLayers = function(layers) {
*/
WMSGetFeatureInfo.prototype.readFeatures_ = function(node, objectStack) {
node.setAttribute('namespaceURI', this.featureNS_);
var localName = node.localName;
const localName = node.localName;
/** @type {Array.<ol.Feature>} */
var features = [];
let 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];
for (let i = 0, ii = node.childNodes.length; i < ii; i++) {
const layer = node.childNodes[i];
if (layer.nodeType !== Node.ELEMENT_NODE) {
continue;
}
var context = objectStack[0];
const context = objectStack[0];
var toRemove = WMSGetFeatureInfo.layerIdentifier_;
var layerName = layer.localName.replace(toRemove, '');
const toRemove = WMSGetFeatureInfo.layerIdentifier_;
const layerName = layer.localName.replace(toRemove, '');
if (this.layers_ && !includes(this.layers_, layerName)) {
continue;
}
var featureType = layerName +
const featureType = layerName +
WMSGetFeatureInfo.featureIdentifier_;
context['featureType'] = featureType;
context['featureNS'] = this.featureNS_;
var parsers = {};
const parsers = {};
parsers[featureType] = _ol_xml_.makeArrayPusher(
this.gmlFormat_.readFeatureElement, this.gmlFormat_);
var parsersNS = _ol_xml_.makeStructureNS(
[context['featureNS'], null], parsers);
this.gmlFormat_.readFeatureElement, this.gmlFormat_);
const parsersNS = _ol_xml_.makeStructureNS(
[context['featureNS'], null], parsers);
layer.setAttribute('namespaceURI', this.featureNS_);
var layerFeatures = _ol_xml_.pushParseAndPop(
[], parsersNS, layer, objectStack, this.gmlFormat_);
const layerFeatures = _ol_xml_.pushParseAndPop(
[], parsersNS, layer, objectStack, this.gmlFormat_);
if (layerFeatures) {
extend(features, layerFeatures);
}
}
}
if (localName == 'FeatureCollection') {
var gmlFeatures = _ol_xml_.pushParseAndPop([],
this.gmlFormat_.FEATURE_COLLECTION_PARSERS, node,
[{}], this.gmlFormat_);
const gmlFeatures = _ol_xml_.pushParseAndPop([],
this.gmlFormat_.FEATURE_COLLECTION_PARSERS, node,
[{}], this.gmlFormat_);
if (gmlFeatures) {
features = gmlFeatures;
}
@@ -156,7 +156,7 @@ WMSGetFeatureInfo.prototype.readFeatures;
* @inheritDoc
*/
WMSGetFeatureInfo.prototype.readFeaturesFromNode = function(node, opt_options) {
var options = {};
const options = {};
if (opt_options) {
_ol_obj_.assign(options, this.getReadOptions(node, opt_options));
}
+134 -134
View File
@@ -17,7 +17,7 @@ import _ol_xml_ from '../xml.js';
* @extends {ol.format.XML}
* @api
*/
var _ol_format_WMTSCapabilities_ = function() {
const _ol_format_WMTSCapabilities_ = function() {
XML.call(this);
/**
@@ -45,7 +45,7 @@ _ol_format_WMTSCapabilities_.prototype.read;
* @inheritDoc
*/
_ol_format_WMTSCapabilities_.prototype.readFromDocument = function(doc) {
for (var n = doc.firstChild; n; n = n.nextSibling) {
for (let n = doc.firstChild; n; n = n.nextSibling) {
if (n.nodeType == Node.ELEMENT_NODE) {
return this.readFromNode(n);
}
@@ -58,14 +58,14 @@ _ol_format_WMTSCapabilities_.prototype.readFromDocument = function(doc) {
* @inheritDoc
*/
_ol_format_WMTSCapabilities_.prototype.readFromNode = function(node) {
var version = node.getAttribute('version').trim();
var WMTSCapabilityObject = this.owsParser_.readFromNode(node);
const version = node.getAttribute('version').trim();
let WMTSCapabilityObject = this.owsParser_.readFromNode(node);
if (!WMTSCapabilityObject) {
return null;
}
WMTSCapabilityObject['version'] = version;
WMTSCapabilityObject = _ol_xml_.pushParseAndPop(WMTSCapabilityObject,
_ol_format_WMTSCapabilities_.PARSERS_, node, []);
_ol_format_WMTSCapabilities_.PARSERS_, node, []);
return WMTSCapabilityObject ? WMTSCapabilityObject : null;
};
@@ -78,7 +78,7 @@ _ol_format_WMTSCapabilities_.prototype.readFromNode = function(node) {
*/
_ol_format_WMTSCapabilities_.readContents_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop({},
_ol_format_WMTSCapabilities_.CONTENTS_PARSERS_, node, objectStack);
_ol_format_WMTSCapabilities_.CONTENTS_PARSERS_, node, objectStack);
};
@@ -90,7 +90,7 @@ _ol_format_WMTSCapabilities_.readContents_ = function(node, objectStack) {
*/
_ol_format_WMTSCapabilities_.readLayer_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop({},
_ol_format_WMTSCapabilities_.LAYER_PARSERS_, node, objectStack);
_ol_format_WMTSCapabilities_.LAYER_PARSERS_, node, objectStack);
};
@@ -102,7 +102,7 @@ _ol_format_WMTSCapabilities_.readLayer_ = function(node, objectStack) {
*/
_ol_format_WMTSCapabilities_.readTileMatrixSet_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop({},
_ol_format_WMTSCapabilities_.TMS_PARSERS_, node, objectStack);
_ol_format_WMTSCapabilities_.TMS_PARSERS_, node, objectStack);
};
@@ -113,12 +113,12 @@ _ol_format_WMTSCapabilities_.readTileMatrixSet_ = function(node, objectStack) {
* @return {Object|undefined} Style object.
*/
_ol_format_WMTSCapabilities_.readStyle_ = function(node, objectStack) {
var style = _ol_xml_.pushParseAndPop({},
_ol_format_WMTSCapabilities_.STYLE_PARSERS_, node, objectStack);
const style = _ol_xml_.pushParseAndPop({},
_ol_format_WMTSCapabilities_.STYLE_PARSERS_, node, objectStack);
if (!style) {
return undefined;
}
var isDefault = node.getAttribute('isDefault') === 'true';
const isDefault = node.getAttribute('isDefault') === 'true';
style['isDefault'] = isDefault;
return style;
@@ -132,9 +132,9 @@ _ol_format_WMTSCapabilities_.readStyle_ = function(node, objectStack) {
* @return {Object|undefined} Tile Matrix Set Link object.
*/
_ol_format_WMTSCapabilities_.readTileMatrixSetLink_ = function(node,
objectStack) {
objectStack) {
return _ol_xml_.pushParseAndPop({},
_ol_format_WMTSCapabilities_.TMS_LINKS_PARSERS_, node, objectStack);
_ol_format_WMTSCapabilities_.TMS_LINKS_PARSERS_, node, objectStack);
};
@@ -146,7 +146,7 @@ _ol_format_WMTSCapabilities_.readTileMatrixSetLink_ = function(node,
*/
_ol_format_WMTSCapabilities_.readDimensions_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop({},
_ol_format_WMTSCapabilities_.DIMENSION_PARSERS_, node, objectStack);
_ol_format_WMTSCapabilities_.DIMENSION_PARSERS_, node, objectStack);
};
@@ -157,10 +157,10 @@ _ol_format_WMTSCapabilities_.readDimensions_ = function(node, objectStack) {
* @return {Object|undefined} Resource URL object.
*/
_ol_format_WMTSCapabilities_.readResourceUrl_ = function(node, objectStack) {
var format = node.getAttribute('format');
var template = node.getAttribute('template');
var resourceType = node.getAttribute('resourceType');
var resource = {};
const format = node.getAttribute('format');
const template = node.getAttribute('template');
const resourceType = node.getAttribute('resourceType');
const resource = {};
if (format) {
resource['format'] = format;
}
@@ -181,8 +181,8 @@ _ol_format_WMTSCapabilities_.readResourceUrl_ = function(node, objectStack) {
* @return {Object|undefined} WGS84 BBox object.
*/
_ol_format_WMTSCapabilities_.readWgs84BoundingBox_ = function(node, objectStack) {
var coordinates = _ol_xml_.pushParseAndPop([],
_ol_format_WMTSCapabilities_.WGS84_BBOX_READERS_, node, objectStack);
const coordinates = _ol_xml_.pushParseAndPop([],
_ol_format_WMTSCapabilities_.WGS84_BBOX_READERS_, node, objectStack);
if (coordinates.length != 2) {
return undefined;
}
@@ -197,7 +197,7 @@ _ol_format_WMTSCapabilities_.readWgs84BoundingBox_ = function(node, objectStack)
* @return {Object|undefined} Legend object.
*/
_ol_format_WMTSCapabilities_.readLegendUrl_ = function(node, objectStack) {
var legend = {};
const legend = {};
legend['format'] = node.getAttribute('format');
legend['href'] = XLink.readHref(node);
return legend;
@@ -211,12 +211,12 @@ _ol_format_WMTSCapabilities_.readLegendUrl_ = function(node, objectStack) {
* @return {Object|undefined} Coordinates object.
*/
_ol_format_WMTSCapabilities_.readCoordinates_ = function(node, objectStack) {
var coordinates = XSD.readString(node).split(' ');
const coordinates = XSD.readString(node).split(' ');
if (!coordinates || coordinates.length != 2) {
return undefined;
}
var x = +coordinates[0];
var y = +coordinates[1];
const x = +coordinates[0];
const y = +coordinates[1];
if (isNaN(x) || isNaN(y)) {
return undefined;
}
@@ -232,7 +232,7 @@ _ol_format_WMTSCapabilities_.readCoordinates_ = function(node, objectStack) {
*/
_ol_format_WMTSCapabilities_.readTileMatrix_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop({},
_ol_format_WMTSCapabilities_.TM_PARSERS_, node, objectStack);
_ol_format_WMTSCapabilities_.TM_PARSERS_, node, objectStack);
};
@@ -243,10 +243,10 @@ _ol_format_WMTSCapabilities_.readTileMatrix_ = function(node, objectStack) {
* @return {Object|undefined} TileMatrixSetLimits Object.
*/
_ol_format_WMTSCapabilities_.readTileMatrixLimitsList_ = function(node,
objectStack) {
objectStack) {
return _ol_xml_.pushParseAndPop([],
_ol_format_WMTSCapabilities_.TMS_LIMITS_LIST_PARSERS_, node,
objectStack);
_ol_format_WMTSCapabilities_.TMS_LIMITS_LIST_PARSERS_, node,
objectStack);
};
@@ -258,7 +258,7 @@ _ol_format_WMTSCapabilities_.readTileMatrixLimitsList_ = function(node,
*/
_ol_format_WMTSCapabilities_.readTileMatrixLimits_ = function(node, objectStack) {
return _ol_xml_.pushParseAndPop({},
_ol_format_WMTSCapabilities_.TMS_LIMITS_PARSERS_, node, objectStack);
_ol_format_WMTSCapabilities_.TMS_LIMITS_PARSERS_, node, objectStack);
};
@@ -290,10 +290,10 @@ _ol_format_WMTSCapabilities_.OWS_NAMESPACE_URIS_ = [
* @private
*/
_ol_format_WMTSCapabilities_.PARSERS_ = _ol_xml_.makeStructureNS(
_ol_format_WMTSCapabilities_.NAMESPACE_URIS_, {
'Contents': _ol_xml_.makeObjectPropertySetter(
_ol_format_WMTSCapabilities_.readContents_)
});
_ol_format_WMTSCapabilities_.NAMESPACE_URIS_, {
'Contents': _ol_xml_.makeObjectPropertySetter(
_ol_format_WMTSCapabilities_.readContents_)
});
/**
@@ -302,12 +302,12 @@ _ol_format_WMTSCapabilities_.PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
_ol_format_WMTSCapabilities_.CONTENTS_PARSERS_ = _ol_xml_.makeStructureNS(
_ol_format_WMTSCapabilities_.NAMESPACE_URIS_, {
'Layer': _ol_xml_.makeObjectPropertyPusher(
_ol_format_WMTSCapabilities_.readLayer_),
'TileMatrixSet': _ol_xml_.makeObjectPropertyPusher(
_ol_format_WMTSCapabilities_.readTileMatrixSet_)
});
_ol_format_WMTSCapabilities_.NAMESPACE_URIS_, {
'Layer': _ol_xml_.makeObjectPropertyPusher(
_ol_format_WMTSCapabilities_.readLayer_),
'TileMatrixSet': _ol_xml_.makeObjectPropertyPusher(
_ol_format_WMTSCapabilities_.readTileMatrixSet_)
});
/**
@@ -316,27 +316,27 @@ _ol_format_WMTSCapabilities_.CONTENTS_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
_ol_format_WMTSCapabilities_.LAYER_PARSERS_ = _ol_xml_.makeStructureNS(
_ol_format_WMTSCapabilities_.NAMESPACE_URIS_, {
'Style': _ol_xml_.makeObjectPropertyPusher(
_ol_format_WMTSCapabilities_.readStyle_),
'Format': _ol_xml_.makeObjectPropertyPusher(
XSD.readString),
'TileMatrixSetLink': _ol_xml_.makeObjectPropertyPusher(
_ol_format_WMTSCapabilities_.readTileMatrixSetLink_),
'Dimension': _ol_xml_.makeObjectPropertyPusher(
_ol_format_WMTSCapabilities_.readDimensions_),
'ResourceURL': _ol_xml_.makeObjectPropertyPusher(
_ol_format_WMTSCapabilities_.readResourceUrl_)
}, _ol_xml_.makeStructureNS(_ol_format_WMTSCapabilities_.OWS_NAMESPACE_URIS_, {
'Title': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'Abstract': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'WGS84BoundingBox': _ol_xml_.makeObjectPropertySetter(
_ol_format_WMTSCapabilities_.readWgs84BoundingBox_),
'Identifier': _ol_xml_.makeObjectPropertySetter(
XSD.readString)
}));
_ol_format_WMTSCapabilities_.NAMESPACE_URIS_, {
'Style': _ol_xml_.makeObjectPropertyPusher(
_ol_format_WMTSCapabilities_.readStyle_),
'Format': _ol_xml_.makeObjectPropertyPusher(
XSD.readString),
'TileMatrixSetLink': _ol_xml_.makeObjectPropertyPusher(
_ol_format_WMTSCapabilities_.readTileMatrixSetLink_),
'Dimension': _ol_xml_.makeObjectPropertyPusher(
_ol_format_WMTSCapabilities_.readDimensions_),
'ResourceURL': _ol_xml_.makeObjectPropertyPusher(
_ol_format_WMTSCapabilities_.readResourceUrl_)
}, _ol_xml_.makeStructureNS(_ol_format_WMTSCapabilities_.OWS_NAMESPACE_URIS_, {
'Title': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'Abstract': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'WGS84BoundingBox': _ol_xml_.makeObjectPropertySetter(
_ol_format_WMTSCapabilities_.readWgs84BoundingBox_),
'Identifier': _ol_xml_.makeObjectPropertySetter(
XSD.readString)
}));
/**
@@ -345,15 +345,15 @@ _ol_format_WMTSCapabilities_.LAYER_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
_ol_format_WMTSCapabilities_.STYLE_PARSERS_ = _ol_xml_.makeStructureNS(
_ol_format_WMTSCapabilities_.NAMESPACE_URIS_, {
'LegendURL': _ol_xml_.makeObjectPropertyPusher(
_ol_format_WMTSCapabilities_.readLegendUrl_)
}, _ol_xml_.makeStructureNS(_ol_format_WMTSCapabilities_.OWS_NAMESPACE_URIS_, {
'Title': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'Identifier': _ol_xml_.makeObjectPropertySetter(
XSD.readString)
}));
_ol_format_WMTSCapabilities_.NAMESPACE_URIS_, {
'LegendURL': _ol_xml_.makeObjectPropertyPusher(
_ol_format_WMTSCapabilities_.readLegendUrl_)
}, _ol_xml_.makeStructureNS(_ol_format_WMTSCapabilities_.OWS_NAMESPACE_URIS_, {
'Title': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'Identifier': _ol_xml_.makeObjectPropertySetter(
XSD.readString)
}));
/**
@@ -362,12 +362,12 @@ _ol_format_WMTSCapabilities_.STYLE_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
_ol_format_WMTSCapabilities_.TMS_LINKS_PARSERS_ = _ol_xml_.makeStructureNS(
_ol_format_WMTSCapabilities_.NAMESPACE_URIS_, {
'TileMatrixSet': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'TileMatrixSetLimits': _ol_xml_.makeObjectPropertySetter(
_ol_format_WMTSCapabilities_.readTileMatrixLimitsList_)
});
_ol_format_WMTSCapabilities_.NAMESPACE_URIS_, {
'TileMatrixSet': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'TileMatrixSetLimits': _ol_xml_.makeObjectPropertySetter(
_ol_format_WMTSCapabilities_.readTileMatrixLimitsList_)
});
/**
* @const
@@ -375,10 +375,10 @@ _ol_format_WMTSCapabilities_.TMS_LINKS_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
_ol_format_WMTSCapabilities_.TMS_LIMITS_LIST_PARSERS_ = _ol_xml_.makeStructureNS(
_ol_format_WMTSCapabilities_.NAMESPACE_URIS_, {
'TileMatrixLimits': _ol_xml_.makeArrayPusher(
_ol_format_WMTSCapabilities_.readTileMatrixLimits_)
});
_ol_format_WMTSCapabilities_.NAMESPACE_URIS_, {
'TileMatrixLimits': _ol_xml_.makeArrayPusher(
_ol_format_WMTSCapabilities_.readTileMatrixLimits_)
});
/**
@@ -387,18 +387,18 @@ _ol_format_WMTSCapabilities_.TMS_LIMITS_LIST_PARSERS_ = _ol_xml_.makeStructureNS
* @private
*/
_ol_format_WMTSCapabilities_.TMS_LIMITS_PARSERS_ = _ol_xml_.makeStructureNS(
_ol_format_WMTSCapabilities_.NAMESPACE_URIS_, {
'TileMatrix': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'MinTileRow': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger),
'MaxTileRow': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger),
'MinTileCol': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger),
'MaxTileCol': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger)
});
_ol_format_WMTSCapabilities_.NAMESPACE_URIS_, {
'TileMatrix': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'MinTileRow': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger),
'MaxTileRow': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger),
'MinTileCol': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger),
'MaxTileCol': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger)
});
/**
@@ -407,15 +407,15 @@ _ol_format_WMTSCapabilities_.TMS_LIMITS_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
_ol_format_WMTSCapabilities_.DIMENSION_PARSERS_ = _ol_xml_.makeStructureNS(
_ol_format_WMTSCapabilities_.NAMESPACE_URIS_, {
'Default': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'Value': _ol_xml_.makeObjectPropertyPusher(
XSD.readString)
}, _ol_xml_.makeStructureNS(_ol_format_WMTSCapabilities_.OWS_NAMESPACE_URIS_, {
'Identifier': _ol_xml_.makeObjectPropertySetter(
XSD.readString)
}));
_ol_format_WMTSCapabilities_.NAMESPACE_URIS_, {
'Default': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'Value': _ol_xml_.makeObjectPropertyPusher(
XSD.readString)
}, _ol_xml_.makeStructureNS(_ol_format_WMTSCapabilities_.OWS_NAMESPACE_URIS_, {
'Identifier': _ol_xml_.makeObjectPropertySetter(
XSD.readString)
}));
/**
@@ -424,12 +424,12 @@ _ol_format_WMTSCapabilities_.DIMENSION_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
_ol_format_WMTSCapabilities_.WGS84_BBOX_READERS_ = _ol_xml_.makeStructureNS(
_ol_format_WMTSCapabilities_.OWS_NAMESPACE_URIS_, {
'LowerCorner': _ol_xml_.makeArrayPusher(
_ol_format_WMTSCapabilities_.readCoordinates_),
'UpperCorner': _ol_xml_.makeArrayPusher(
_ol_format_WMTSCapabilities_.readCoordinates_)
});
_ol_format_WMTSCapabilities_.OWS_NAMESPACE_URIS_, {
'LowerCorner': _ol_xml_.makeArrayPusher(
_ol_format_WMTSCapabilities_.readCoordinates_),
'UpperCorner': _ol_xml_.makeArrayPusher(
_ol_format_WMTSCapabilities_.readCoordinates_)
});
/**
@@ -438,17 +438,17 @@ _ol_format_WMTSCapabilities_.WGS84_BBOX_READERS_ = _ol_xml_.makeStructureNS(
* @private
*/
_ol_format_WMTSCapabilities_.TMS_PARSERS_ = _ol_xml_.makeStructureNS(
_ol_format_WMTSCapabilities_.NAMESPACE_URIS_, {
'WellKnownScaleSet': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'TileMatrix': _ol_xml_.makeObjectPropertyPusher(
_ol_format_WMTSCapabilities_.readTileMatrix_)
}, _ol_xml_.makeStructureNS(_ol_format_WMTSCapabilities_.OWS_NAMESPACE_URIS_, {
'SupportedCRS': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'Identifier': _ol_xml_.makeObjectPropertySetter(
XSD.readString)
}));
_ol_format_WMTSCapabilities_.NAMESPACE_URIS_, {
'WellKnownScaleSet': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'TileMatrix': _ol_xml_.makeObjectPropertyPusher(
_ol_format_WMTSCapabilities_.readTileMatrix_)
}, _ol_xml_.makeStructureNS(_ol_format_WMTSCapabilities_.OWS_NAMESPACE_URIS_, {
'SupportedCRS': _ol_xml_.makeObjectPropertySetter(
XSD.readString),
'Identifier': _ol_xml_.makeObjectPropertySetter(
XSD.readString)
}));
/**
@@ -457,21 +457,21 @@ _ol_format_WMTSCapabilities_.TMS_PARSERS_ = _ol_xml_.makeStructureNS(
* @private
*/
_ol_format_WMTSCapabilities_.TM_PARSERS_ = _ol_xml_.makeStructureNS(
_ol_format_WMTSCapabilities_.NAMESPACE_URIS_, {
'TopLeftCorner': _ol_xml_.makeObjectPropertySetter(
_ol_format_WMTSCapabilities_.readCoordinates_),
'ScaleDenominator': _ol_xml_.makeObjectPropertySetter(
XSD.readDecimal),
'TileWidth': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger),
'TileHeight': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger),
'MatrixWidth': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger),
'MatrixHeight': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger)
}, _ol_xml_.makeStructureNS(_ol_format_WMTSCapabilities_.OWS_NAMESPACE_URIS_, {
'Identifier': _ol_xml_.makeObjectPropertySetter(
XSD.readString)
}));
_ol_format_WMTSCapabilities_.NAMESPACE_URIS_, {
'TopLeftCorner': _ol_xml_.makeObjectPropertySetter(
_ol_format_WMTSCapabilities_.readCoordinates_),
'ScaleDenominator': _ol_xml_.makeObjectPropertySetter(
XSD.readDecimal),
'TileWidth': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger),
'TileHeight': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger),
'MatrixWidth': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger),
'MatrixHeight': _ol_xml_.makeObjectPropertySetter(
XSD.readNonNegativeInteger)
}, _ol_xml_.makeStructureNS(_ol_format_WMTSCapabilities_.OWS_NAMESPACE_URIS_, {
'Identifier': _ol_xml_.makeObjectPropertySetter(
XSD.readString)
}));
export default _ol_format_WMTSCapabilities_;
+2 -2
View File
@@ -1,14 +1,14 @@
/**
* @module ol/format/XLink
*/
var XLink = {};
const XLink = {};
/**
* @const
* @type {string}
*/
var NAMESPACE_URI = 'http://www.w3.org/1999/xlink';
const NAMESPACE_URI = 'http://www.w3.org/1999/xlink';
/**
+2 -2
View File
@@ -11,7 +11,7 @@ import _ol_xml_ from '../xml.js';
* @abstract
* @struct
*/
var XML = function() {
const XML = function() {
};
@@ -25,7 +25,7 @@ XML.prototype.read = function(source) {
} else if (_ol_xml_.isNode(source)) {
return this.readFromNode(/** @type {Node} */ (source));
} else if (typeof source === 'string') {
var doc = _ol_xml_.parse(source);
const doc = _ol_xml_.parse(source);
return this.readFromDocument(doc);
} else {
return null;
+16 -16
View File
@@ -17,7 +17,7 @@ import _ol_xml_ from '../xml.js';
* @abstract
* @extends {ol.format.Feature}
*/
var XMLFeature = function() {
const XMLFeature = function() {
/**
* @type {XMLSerializer}
@@ -45,11 +45,11 @@ XMLFeature.prototype.getType = function() {
XMLFeature.prototype.readFeature = function(source, opt_options) {
if (_ol_xml_.isDocument(source)) {
return this.readFeatureFromDocument(
/** @type {Document} */ (source), opt_options);
/** @type {Document} */ (source), opt_options);
} else if (_ol_xml_.isNode(source)) {
return this.readFeatureFromNode(/** @type {Node} */ (source), opt_options);
} else if (typeof source === 'string') {
var doc = _ol_xml_.parse(source);
const doc = _ol_xml_.parse(source);
return this.readFeatureFromDocument(doc, opt_options);
} else {
return null;
@@ -63,8 +63,8 @@ XMLFeature.prototype.readFeature = function(source, opt_options) {
* @return {ol.Feature} Feature.
*/
XMLFeature.prototype.readFeatureFromDocument = function(
doc, opt_options) {
var features = this.readFeaturesFromDocument(doc, opt_options);
doc, opt_options) {
const features = this.readFeaturesFromDocument(doc, opt_options);
if (features.length > 0) {
return features[0];
} else {
@@ -89,11 +89,11 @@ XMLFeature.prototype.readFeatureFromNode = function(node, opt_options) {
XMLFeature.prototype.readFeatures = function(source, opt_options) {
if (_ol_xml_.isDocument(source)) {
return this.readFeaturesFromDocument(
/** @type {Document} */ (source), opt_options);
/** @type {Document} */ (source), opt_options);
} else if (_ol_xml_.isNode(source)) {
return this.readFeaturesFromNode(/** @type {Node} */ (source), opt_options);
} else if (typeof source === 'string') {
var doc = _ol_xml_.parse(source);
const doc = _ol_xml_.parse(source);
return this.readFeaturesFromDocument(doc, opt_options);
} else {
return [];
@@ -108,10 +108,10 @@ XMLFeature.prototype.readFeatures = function(source, opt_options) {
* @return {Array.<ol.Feature>} Features.
*/
XMLFeature.prototype.readFeaturesFromDocument = function(
doc, opt_options) {
doc, opt_options) {
/** @type {Array.<ol.Feature>} */
var features = [];
var n;
const features = [];
let n;
for (n = doc.firstChild; n; n = n.nextSibling) {
if (n.nodeType == Node.ELEMENT_NODE) {
extend(features, this.readFeaturesFromNode(n, opt_options));
@@ -137,11 +137,11 @@ XMLFeature.prototype.readFeaturesFromNode = function(node, opt_options) {};
XMLFeature.prototype.readGeometry = function(source, opt_options) {
if (_ol_xml_.isDocument(source)) {
return this.readGeometryFromDocument(
/** @type {Document} */ (source), opt_options);
/** @type {Document} */ (source), opt_options);
} else if (_ol_xml_.isNode(source)) {
return this.readGeometryFromNode(/** @type {Node} */ (source), opt_options);
} else if (typeof source === 'string') {
var doc = _ol_xml_.parse(source);
const doc = _ol_xml_.parse(source);
return this.readGeometryFromDocument(doc, opt_options);
} else {
return null;
@@ -180,7 +180,7 @@ XMLFeature.prototype.readProjection = function(source) {
} else if (_ol_xml_.isNode(source)) {
return this.readProjectionFromNode(/** @type {Node} */ (source));
} else if (typeof source === 'string') {
var doc = _ol_xml_.parse(source);
const doc = _ol_xml_.parse(source);
return this.readProjectionFromDocument(doc);
} else {
return null;
@@ -212,7 +212,7 @@ XMLFeature.prototype.readProjectionFromNode = function(node) {
* @inheritDoc
*/
XMLFeature.prototype.writeFeature = function(feature, opt_options) {
var node = this.writeFeatureNode(feature, opt_options);
const node = this.writeFeatureNode(feature, opt_options);
return this.xmlSerializer_.serializeToString(node);
};
@@ -232,7 +232,7 @@ XMLFeature.prototype.writeFeatureNode = function(feature, opt_options) {
* @inheritDoc
*/
XMLFeature.prototype.writeFeatures = function(features, opt_options) {
var node = this.writeFeaturesNode(features, opt_options);
const node = this.writeFeaturesNode(features, opt_options);
return this.xmlSerializer_.serializeToString(node);
};
@@ -251,7 +251,7 @@ XMLFeature.prototype.writeFeaturesNode = function(features, opt_options) {
* @inheritDoc
*/
XMLFeature.prototype.writeGeometry = function(geometry, opt_options) {
var node = this.writeGeometryNode(geometry, opt_options);
const node = this.writeGeometryNode(geometry, opt_options);
return this.xmlSerializer_.serializeToString(node);
};
+13 -13
View File
@@ -3,7 +3,7 @@
*/
import _ol_xml_ from '../xml.js';
import _ol_string_ from '../string.js';
var XSD = {};
const XSD = {};
/**
@@ -11,7 +11,7 @@ var XSD = {};
* @return {boolean|undefined} Boolean.
*/
XSD.readBoolean = function(node) {
var s = _ol_xml_.getAllTextContent(node, false);
const s = _ol_xml_.getAllTextContent(node, false);
return XSD.readBooleanString(s);
};
@@ -21,7 +21,7 @@ XSD.readBoolean = function(node) {
* @return {boolean|undefined} Boolean.
*/
XSD.readBooleanString = function(string) {
var m = /^\s*(true|1)|(false|0)\s*$/.exec(string);
const m = /^\s*(true|1)|(false|0)\s*$/.exec(string);
if (m) {
return m[1] !== undefined || false;
} else {
@@ -35,8 +35,8 @@ XSD.readBooleanString = function(string) {
* @return {number|undefined} DateTime in seconds.
*/
XSD.readDateTime = function(node) {
var s = _ol_xml_.getAllTextContent(node, false);
var dateTime = Date.parse(s);
const s = _ol_xml_.getAllTextContent(node, false);
const dateTime = Date.parse(s);
return isNaN(dateTime) ? undefined : dateTime / 1000;
};
@@ -46,7 +46,7 @@ XSD.readDateTime = function(node) {
* @return {number|undefined} Decimal.
*/
XSD.readDecimal = function(node) {
var s = _ol_xml_.getAllTextContent(node, false);
const s = _ol_xml_.getAllTextContent(node, false);
return XSD.readDecimalString(s);
};
@@ -57,7 +57,7 @@ XSD.readDecimal = function(node) {
*/
XSD.readDecimalString = function(string) {
// FIXME check spec
var m = /^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(string);
const m = /^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(string);
if (m) {
return parseFloat(m[1]);
} else {
@@ -71,7 +71,7 @@ XSD.readDecimalString = function(string) {
* @return {number|undefined} Non negative integer.
*/
XSD.readNonNegativeInteger = function(node) {
var s = _ol_xml_.getAllTextContent(node, false);
const s = _ol_xml_.getAllTextContent(node, false);
return XSD.readNonNegativeIntegerString(s);
};
@@ -81,7 +81,7 @@ XSD.readNonNegativeInteger = function(node) {
* @return {number|undefined} Non negative integer.
*/
XSD.readNonNegativeIntegerString = function(string) {
var m = /^\s*(\d+)\s*$/.exec(string);
const m = /^\s*(\d+)\s*$/.exec(string);
if (m) {
return parseInt(m[1], 10);
} else {
@@ -122,8 +122,8 @@ XSD.writeCDATASection = function(node, string) {
* @param {number} dateTime DateTime in seconds.
*/
XSD.writeDateTimeTextNode = function(node, dateTime) {
var date = new Date(dateTime * 1000);
var string = date.getUTCFullYear() + '-' +
const date = new Date(dateTime * 1000);
const string = date.getUTCFullYear() + '-' +
_ol_string_.padNumber(date.getUTCMonth() + 1, 2) + '-' +
_ol_string_.padNumber(date.getUTCDate(), 2) + 'T' +
_ol_string_.padNumber(date.getUTCHours(), 2) + ':' +
@@ -138,7 +138,7 @@ XSD.writeDateTimeTextNode = function(node, dateTime) {
* @param {number} decimal Decimal.
*/
XSD.writeDecimalTextNode = function(node, decimal) {
var string = decimal.toPrecision();
const string = decimal.toPrecision();
node.appendChild(_ol_xml_.DOCUMENT.createTextNode(string));
};
@@ -148,7 +148,7 @@ XSD.writeDecimalTextNode = function(node, decimal) {
* @param {number} nonNegativeInteger Non negative integer.
*/
XSD.writeNonNegativeIntegerTextNode = function(node, nonNegativeInteger) {
var string = nonNegativeInteger.toString();
const string = nonNegativeInteger.toString();
node.appendChild(_ol_xml_.DOCUMENT.createTextNode(string));
};
+5 -5
View File
@@ -18,7 +18,7 @@ import _ol_format_filter_Not_ from '../format/filter/Not.js';
import _ol_format_filter_NotEqualTo_ from '../format/filter/NotEqualTo.js';
import _ol_format_filter_Or_ from '../format/filter/Or.js';
import _ol_format_filter_Within_ from '../format/filter/Within.js';
var _ol_format_filter_ = {};
const _ol_format_filter_ = {};
/**
@@ -29,7 +29,7 @@ var _ol_format_filter_ = {};
* @api
*/
_ol_format_filter_.and = function(conditions) {
var params = [null].concat(Array.prototype.slice.call(arguments));
const params = [null].concat(Array.prototype.slice.call(arguments));
return new (Function.prototype.bind.apply(_ol_format_filter_And_, params));
};
@@ -42,7 +42,7 @@ _ol_format_filter_.and = function(conditions) {
* @api
*/
_ol_format_filter_.or = function(conditions) {
var params = [null].concat(Array.prototype.slice.call(arguments));
const params = [null].concat(Array.prototype.slice.call(arguments));
return new (Function.prototype.bind.apply(_ol_format_filter_Or_, params));
};
@@ -245,9 +245,9 @@ _ol_format_filter_.between = function(propertyName, lowerBoundary, upperBoundary
* @api
*/
_ol_format_filter_.like = function(propertyName, pattern,
opt_wildCard, opt_singleChar, opt_escapeChar, opt_matchCase) {
opt_wildCard, opt_singleChar, opt_escapeChar, opt_matchCase) {
return new _ol_format_filter_IsLike_(propertyName, pattern,
opt_wildCard, opt_singleChar, opt_escapeChar, opt_matchCase);
opt_wildCard, opt_singleChar, opt_escapeChar, opt_matchCase);
};
+2 -2
View File
@@ -13,8 +13,8 @@ import LogicalNary from '../filter/LogicalNary.js';
* @param {...ol.format.filter.Filter} conditions Conditions.
* @extends {ol.format.filter.LogicalNary}
*/
var And = function(conditions) {
var params = ['And'].concat(Array.prototype.slice.call(arguments));
const And = function(conditions) {
const params = ['And'].concat(Array.prototype.slice.call(arguments));
LogicalNary.apply(this, params);
};
+1 -1
View File
@@ -17,7 +17,7 @@ import Filter from '../filter/Filter.js';
* @extends {ol.format.filter.Filter}
* @api
*/
var Bbox = function(geometryName, extent, opt_srsName) {
const Bbox = function(geometryName, extent, opt_srsName) {
Filter.call(this, 'BBOX');
+1 -1
View File
@@ -15,7 +15,7 @@ import Filter from '../filter/Filter.js';
* @param {!string} propertyName Name of the context property to compare.
* @extends {ol.format.filter.Filter}
*/
var Comparison = function(tagName, propertyName) {
const Comparison = function(tagName, propertyName) {
Filter.call(this, tagName);
+1 -1
View File
@@ -17,7 +17,7 @@ import Comparison from '../filter/Comparison.js';
* @param {boolean=} opt_matchCase Case-sensitive?
* @extends {ol.format.filter.Comparison}
*/
var ComparisonBinary = function(tagName, propertyName, expression, opt_matchCase) {
const ComparisonBinary = function(tagName, propertyName, expression, opt_matchCase) {
Comparison.call(this, tagName, propertyName);
+1 -1
View File
@@ -17,7 +17,7 @@ import Spatial from '../filter/Spatial.js';
* @extends {ol.format.filter.Spatial}
* @api
*/
var Contains = function(geometryName, geometry, opt_srsName) {
const Contains = function(geometryName, geometry, opt_srsName) {
Spatial.call(this, 'Contains', geometryName, geometry, opt_srsName);
+1 -1
View File
@@ -15,7 +15,7 @@ import Comparison from '../filter/Comparison.js';
* @extends {ol.format.filter.Comparison}
* @api
*/
var During = function(propertyName, begin, end) {
const During = function(propertyName, begin, end) {
Comparison.call(this, 'During', propertyName);
/**
+1 -1
View File
@@ -15,7 +15,7 @@ import ComparisonBinary from '../filter/ComparisonBinary.js';
* @extends {ol.format.filter.ComparisonBinary}
* @api
*/
var EqualTo = function(propertyName, expression, opt_matchCase) {
const EqualTo = function(propertyName, expression, opt_matchCase) {
ComparisonBinary.call(this, 'PropertyIsEqualTo', propertyName, expression, opt_matchCase);
};
+1 -1
View File
@@ -13,7 +13,7 @@
* @param {!string} tagName The XML tag name for this filter.
* @struct
*/
var Filter = function(tagName) {
const Filter = function(tagName) {
/**
* @private
+1 -1
View File
@@ -14,7 +14,7 @@ import ComparisonBinary from '../filter/ComparisonBinary.js';
* @extends {ol.format.filter.ComparisonBinary}
* @api
*/
var GreaterThan = function(propertyName, expression) {
const GreaterThan = function(propertyName, expression) {
ComparisonBinary.call(this, 'PropertyIsGreaterThan', propertyName, expression);
};
+1 -1
View File
@@ -14,7 +14,7 @@ import ComparisonBinary from '../filter/ComparisonBinary.js';
* @extends {ol.format.filter.ComparisonBinary}
* @api
*/
var GreaterThanOrEqualTo = function(propertyName, expression) {
const GreaterThanOrEqualTo = function(propertyName, expression) {
ComparisonBinary.call(this, 'PropertyIsGreaterThanOrEqualTo', propertyName, expression);
};
+1 -1
View File
@@ -17,7 +17,7 @@ import Spatial from '../filter/Spatial.js';
* @extends {ol.format.filter.Spatial}
* @api
*/
var Intersects = function(geometryName, geometry, opt_srsName) {
const Intersects = function(geometryName, geometry, opt_srsName) {
Spatial.call(this, 'Intersects', geometryName, geometry, opt_srsName);
+1 -1
View File
@@ -15,7 +15,7 @@ import Comparison from '../filter/Comparison.js';
* @extends {ol.format.filter.Comparison}
* @api
*/
var IsBetween = function(propertyName, lowerBoundary, upperBoundary) {
const IsBetween = function(propertyName, lowerBoundary, upperBoundary) {
Comparison.call(this, 'PropertyIsBetween', propertyName);
/**
+1 -1
View File
@@ -21,7 +21,7 @@ import Comparison from '../filter/Comparison.js';
* @extends {ol.format.filter.Comparison}
* @api
*/
var IsLike = function(propertyName, pattern, opt_wildCard, opt_singleChar, opt_escapeChar, opt_matchCase) {
const IsLike = function(propertyName, pattern, opt_wildCard, opt_singleChar, opt_escapeChar, opt_matchCase) {
Comparison.call(this, 'PropertyIsLike', propertyName);
/**
+1 -1
View File
@@ -13,7 +13,7 @@ import Comparison from '../filter/Comparison.js';
* @extends {ol.format.filter.Comparison}
* @api
*/
var IsNull = function(propertyName) {
const IsNull = function(propertyName) {
Comparison.call(this, 'PropertyIsNull', propertyName);
};
+1 -1
View File
@@ -14,7 +14,7 @@ import ComparisonBinary from '../filter/ComparisonBinary.js';
* @extends {ol.format.filter.ComparisonBinary}
* @api
*/
var LessThan = function(propertyName, expression) {
const LessThan = function(propertyName, expression) {
ComparisonBinary.call(this, 'PropertyIsLessThan', propertyName, expression);
};
+1 -1
View File
@@ -14,7 +14,7 @@ import ComparisonBinary from '../filter/ComparisonBinary.js';
* @extends {ol.format.filter.ComparisonBinary}
* @api
*/
var LessThanOrEqualTo = function(propertyName, expression) {
const LessThanOrEqualTo = function(propertyName, expression) {
ComparisonBinary.call(this, 'PropertyIsLessThanOrEqualTo', propertyName, expression);
};
+1 -1
View File
@@ -16,7 +16,7 @@ import Filter from '../filter/Filter.js';
* @param {...ol.format.filter.Filter} conditions Conditions.
* @extends {ol.format.filter.Filter}
*/
var LogicalNary = function(tagName, conditions) {
const LogicalNary = function(tagName, conditions) {
Filter.call(this, tagName);
+1 -1
View File
@@ -13,7 +13,7 @@ import Filter from '../filter/Filter.js';
* @extends {ol.format.filter.Filter}
* @api
*/
var Not = function(condition) {
const Not = function(condition) {
Filter.call(this, 'Not');
+1 -1
View File
@@ -15,7 +15,7 @@ import ComparisonBinary from '../filter/ComparisonBinary.js';
* @extends {ol.format.filter.ComparisonBinary}
* @api
*/
var NotEqualTo = function(propertyName, expression, opt_matchCase) {
const NotEqualTo = function(propertyName, expression, opt_matchCase) {
ComparisonBinary.call(this, 'PropertyIsNotEqualTo', propertyName, expression, opt_matchCase);
};
+2 -2
View File
@@ -13,8 +13,8 @@ import LogicalNary from '../filter/LogicalNary.js';
* @extends {ol.format.filter.LogicalNary}
* @api
*/
var Or = function(conditions) {
var params = ['Or'].concat(Array.prototype.slice.call(arguments));
const Or = function(conditions) {
const params = ['Or'].concat(Array.prototype.slice.call(arguments));
LogicalNary.apply(this, params);
};
+1 -1
View File
@@ -19,7 +19,7 @@ import Filter from '../filter/Filter.js';
* set on geometries when this is not provided.
* @extends {ol.format.filter.Filter}
*/
var Spatial = function(tagName, geometryName, geometry, opt_srsName) {
const Spatial = function(tagName, geometryName, geometry, opt_srsName) {
Filter.call(this, tagName);
+1 -1
View File
@@ -17,7 +17,7 @@ import Spatial from '../filter/Spatial.js';
* @extends {ol.format.filter.Spatial}
* @api
*/
var Within = function(geometryName, geometry, opt_srsName) {
const Within = function(geometryName, geometry, opt_srsName) {
Spatial.call(this, 'Within', geometryName, geometry, opt_srsName);