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:
@@ -12,9 +12,9 @@ import {VERSION, inherits} from './index.js';
|
||||
* @implements {oli.AssertionError}
|
||||
* @param {number} code Error code.
|
||||
*/
|
||||
var AssertionError = function(code) {
|
||||
const AssertionError = function(code) {
|
||||
|
||||
var path = VERSION ? VERSION.split('-')[0] : 'latest';
|
||||
const path = VERSION ? VERSION.split('-')[0] : 'latest';
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ registerMultiple(PluginType.LAYER_RENDERER, [
|
||||
* @fires ol.render.Event#precompose
|
||||
* @api
|
||||
*/
|
||||
var _ol_CanvasMap_ = function(options) {
|
||||
const _ol_CanvasMap_ = function(options) {
|
||||
options = _ol_obj_.assign({}, options);
|
||||
delete options.renderer;
|
||||
if (!options.controls) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/CenterConstraint
|
||||
*/
|
||||
import {clamp} from './math.js';
|
||||
var CenterConstraint = {};
|
||||
const CenterConstraint = {};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
+20
-20
@@ -12,7 +12,7 @@ import Event from './events/Event.js';
|
||||
* @enum {string}
|
||||
* @private
|
||||
*/
|
||||
var Property = {
|
||||
const Property = {
|
||||
LENGTH: 'length'
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ var Property = {
|
||||
/**
|
||||
* @typedef {{unique: (boolean|undefined)}}
|
||||
*/
|
||||
export var CollectionOptions;
|
||||
export let CollectionOptions;
|
||||
|
||||
|
||||
/**
|
||||
@@ -41,11 +41,11 @@ export var CollectionOptions;
|
||||
* @template T
|
||||
* @api
|
||||
*/
|
||||
var Collection = function(opt_array, opt_options) {
|
||||
const Collection = function(opt_array, opt_options) {
|
||||
|
||||
BaseObject.call(this);
|
||||
|
||||
var options = opt_options || {};
|
||||
const options = opt_options || {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -60,7 +60,7 @@ var Collection = function(opt_array, opt_options) {
|
||||
this.array_ = opt_array ? opt_array : [];
|
||||
|
||||
if (this.unique_) {
|
||||
for (var i = 0, ii = this.array_.length; i < ii; ++i) {
|
||||
for (let i = 0, ii = this.array_.length; i < ii; ++i) {
|
||||
this.assertUnique_(this.array_[i], i);
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ Collection.prototype.clear = function() {
|
||||
* @api
|
||||
*/
|
||||
Collection.prototype.extend = function(arr) {
|
||||
var i, ii;
|
||||
let i, ii;
|
||||
for (i = 0, ii = arr.length; i < ii; ++i) {
|
||||
this.push(arr[i]);
|
||||
}
|
||||
@@ -107,8 +107,8 @@ Collection.prototype.extend = function(arr) {
|
||||
* @api
|
||||
*/
|
||||
Collection.prototype.forEach = function(f) {
|
||||
var array = this.array_;
|
||||
for (var i = 0, ii = array.length; i < ii; ++i) {
|
||||
const array = this.array_;
|
||||
for (let i = 0, ii = array.length; i < ii; ++i) {
|
||||
f(array[i], i, array);
|
||||
}
|
||||
};
|
||||
@@ -162,7 +162,7 @@ Collection.prototype.insertAt = function(index, elem) {
|
||||
this.array_.splice(index, 0, elem);
|
||||
this.updateLength_();
|
||||
this.dispatchEvent(
|
||||
new Collection.Event(CollectionEventType.ADD, elem));
|
||||
new Collection.Event(CollectionEventType.ADD, elem));
|
||||
};
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ Collection.prototype.push = function(elem) {
|
||||
if (this.unique_) {
|
||||
this.assertUnique_(elem);
|
||||
}
|
||||
var n = this.getLength();
|
||||
const n = this.getLength();
|
||||
this.insertAt(n, elem);
|
||||
return this.getLength();
|
||||
};
|
||||
@@ -200,8 +200,8 @@ Collection.prototype.push = function(elem) {
|
||||
* @api
|
||||
*/
|
||||
Collection.prototype.remove = function(elem) {
|
||||
var arr = this.array_;
|
||||
var i, ii;
|
||||
const arr = this.array_;
|
||||
let i, ii;
|
||||
for (i = 0, ii = arr.length; i < ii; ++i) {
|
||||
if (arr[i] === elem) {
|
||||
return this.removeAt(i);
|
||||
@@ -219,11 +219,11 @@ Collection.prototype.remove = function(elem) {
|
||||
* @api
|
||||
*/
|
||||
Collection.prototype.removeAt = function(index) {
|
||||
var prev = this.array_[index];
|
||||
const prev = this.array_[index];
|
||||
this.array_.splice(index, 1);
|
||||
this.updateLength_();
|
||||
this.dispatchEvent(
|
||||
new Collection.Event(CollectionEventType.REMOVE, prev));
|
||||
new Collection.Event(CollectionEventType.REMOVE, prev));
|
||||
return prev;
|
||||
};
|
||||
|
||||
@@ -235,19 +235,19 @@ Collection.prototype.removeAt = function(index) {
|
||||
* @api
|
||||
*/
|
||||
Collection.prototype.setAt = function(index, elem) {
|
||||
var n = this.getLength();
|
||||
const n = this.getLength();
|
||||
if (index < n) {
|
||||
if (this.unique_) {
|
||||
this.assertUnique_(elem, index);
|
||||
}
|
||||
var prev = this.array_[index];
|
||||
const prev = this.array_[index];
|
||||
this.array_[index] = elem;
|
||||
this.dispatchEvent(
|
||||
new Collection.Event(CollectionEventType.REMOVE, prev));
|
||||
new Collection.Event(CollectionEventType.REMOVE, prev));
|
||||
this.dispatchEvent(
|
||||
new Collection.Event(CollectionEventType.ADD, elem));
|
||||
new Collection.Event(CollectionEventType.ADD, elem));
|
||||
} else {
|
||||
var j;
|
||||
let j;
|
||||
for (j = n; j < index; ++j) {
|
||||
this.insertAt(j, undefined);
|
||||
}
|
||||
@@ -270,7 +270,7 @@ Collection.prototype.updateLength_ = function() {
|
||||
* @param {number=} opt_except Optional index to ignore.
|
||||
*/
|
||||
Collection.prototype.assertUnique_ = function(elem, opt_except) {
|
||||
for (var i = 0, ii = this.array_.length; i < ii; ++i) {
|
||||
for (let i = 0, ii = this.array_.length; i < ii; ++i) {
|
||||
if (this.array_[i] === elem && i !== opt_except) {
|
||||
throw new AssertionError(58);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import {nullFunction} from './index.js';
|
||||
* Objects that need to clean up after themselves.
|
||||
* @constructor
|
||||
*/
|
||||
var Disposable = function() {};
|
||||
const Disposable = function() {};
|
||||
|
||||
/**
|
||||
* The object has already been disposed.
|
||||
|
||||
+17
-17
@@ -54,7 +54,7 @@ import Style from './style/Style.js';
|
||||
* include a Geometry associated with a `geometry` key.
|
||||
* @api
|
||||
*/
|
||||
var Feature = function(opt_geometryOrProperties) {
|
||||
const Feature = function(opt_geometryOrProperties) {
|
||||
|
||||
BaseObject.call(this);
|
||||
|
||||
@@ -91,17 +91,17 @@ var Feature = function(opt_geometryOrProperties) {
|
||||
this.geometryChangeKey_ = null;
|
||||
|
||||
_ol_events_.listen(
|
||||
this, BaseObject.getChangeEventType(this.geometryName_),
|
||||
this.handleGeometryChanged_, this);
|
||||
this, BaseObject.getChangeEventType(this.geometryName_),
|
||||
this.handleGeometryChanged_, this);
|
||||
|
||||
if (opt_geometryOrProperties !== undefined) {
|
||||
if (opt_geometryOrProperties instanceof Geometry ||
|
||||
!opt_geometryOrProperties) {
|
||||
var geometry = opt_geometryOrProperties;
|
||||
const geometry = opt_geometryOrProperties;
|
||||
this.setGeometry(geometry);
|
||||
} else {
|
||||
/** @type {Object.<string, *>} */
|
||||
var properties = opt_geometryOrProperties;
|
||||
const properties = opt_geometryOrProperties;
|
||||
this.setProperties(properties);
|
||||
}
|
||||
}
|
||||
@@ -117,13 +117,13 @@ inherits(Feature, BaseObject);
|
||||
* @api
|
||||
*/
|
||||
Feature.prototype.clone = function() {
|
||||
var clone = new Feature(this.getProperties());
|
||||
const clone = new Feature(this.getProperties());
|
||||
clone.setGeometryName(this.getGeometryName());
|
||||
var geometry = this.getGeometry();
|
||||
const geometry = this.getGeometry();
|
||||
if (geometry) {
|
||||
clone.setGeometry(geometry.clone());
|
||||
}
|
||||
var style = this.getStyle();
|
||||
const style = this.getStyle();
|
||||
if (style) {
|
||||
clone.setStyle(style);
|
||||
}
|
||||
@@ -208,10 +208,10 @@ Feature.prototype.handleGeometryChanged_ = function() {
|
||||
_ol_events_.unlistenByKey(this.geometryChangeKey_);
|
||||
this.geometryChangeKey_ = null;
|
||||
}
|
||||
var geometry = this.getGeometry();
|
||||
const geometry = this.getGeometry();
|
||||
if (geometry) {
|
||||
this.geometryChangeKey_ = _ol_events_.listen(geometry,
|
||||
EventType.CHANGE, this.handleGeometryChange_, this);
|
||||
EventType.CHANGE, this.handleGeometryChange_, this);
|
||||
}
|
||||
this.changed();
|
||||
};
|
||||
@@ -270,12 +270,12 @@ Feature.prototype.setId = function(id) {
|
||||
*/
|
||||
Feature.prototype.setGeometryName = function(name) {
|
||||
_ol_events_.unlisten(
|
||||
this, BaseObject.getChangeEventType(this.geometryName_),
|
||||
this.handleGeometryChanged_, this);
|
||||
this, BaseObject.getChangeEventType(this.geometryName_),
|
||||
this.handleGeometryChanged_, this);
|
||||
this.geometryName_ = name;
|
||||
_ol_events_.listen(
|
||||
this, BaseObject.getChangeEventType(this.geometryName_),
|
||||
this.handleGeometryChanged_, this);
|
||||
this, BaseObject.getChangeEventType(this.geometryName_),
|
||||
this.handleGeometryChanged_, this);
|
||||
this.handleGeometryChanged_();
|
||||
};
|
||||
|
||||
@@ -289,7 +289,7 @@ Feature.prototype.setGeometryName = function(name) {
|
||||
* @return {ol.FeatureStyleFunction} A style function.
|
||||
*/
|
||||
Feature.createStyleFunction = function(obj) {
|
||||
var styleFunction;
|
||||
let styleFunction;
|
||||
|
||||
if (typeof obj === 'function') {
|
||||
if (obj.length == 2) {
|
||||
@@ -303,12 +303,12 @@ Feature.createStyleFunction = function(obj) {
|
||||
/**
|
||||
* @type {Array.<ol.style.Style>}
|
||||
*/
|
||||
var styles;
|
||||
let styles;
|
||||
if (Array.isArray(obj)) {
|
||||
styles = obj;
|
||||
} else {
|
||||
assert(obj instanceof Style,
|
||||
41); // Expected an `ol.style.Style` or an array of `ol.style.Style`
|
||||
41); // Expected an `ol.style.Style` or an array of `ol.style.Style`
|
||||
styles = [obj];
|
||||
}
|
||||
styleFunction = function() {
|
||||
|
||||
+20
-20
@@ -17,7 +17,7 @@ import {get as getProjection, getTransformFromProjections, identityTransform} fr
|
||||
* trackingOptions: (GeolocationPositionOptions|undefined),
|
||||
* projection: ol.ProjectionLike}}
|
||||
*/
|
||||
export var GeolocationOptions;
|
||||
export let GeolocationOptions;
|
||||
|
||||
|
||||
/**
|
||||
@@ -53,11 +53,11 @@ export var GeolocationOptions;
|
||||
* is reported in.
|
||||
* @api
|
||||
*/
|
||||
var Geolocation = function(opt_options) {
|
||||
const Geolocation = function(opt_options) {
|
||||
|
||||
BaseObject.call(this);
|
||||
|
||||
var options = opt_options || {};
|
||||
const options = opt_options || {};
|
||||
|
||||
/**
|
||||
* The unprojected (EPSG:4326) device position.
|
||||
@@ -79,11 +79,11 @@ var Geolocation = function(opt_options) {
|
||||
this.watchId_ = undefined;
|
||||
|
||||
_ol_events_.listen(
|
||||
this, BaseObject.getChangeEventType(GeolocationProperty.PROJECTION),
|
||||
this.handleProjectionChanged_, this);
|
||||
this, BaseObject.getChangeEventType(GeolocationProperty.PROJECTION),
|
||||
this.handleProjectionChanged_, this);
|
||||
_ol_events_.listen(
|
||||
this, BaseObject.getChangeEventType(GeolocationProperty.TRACKING),
|
||||
this.handleTrackingChanged_, this);
|
||||
this, BaseObject.getChangeEventType(GeolocationProperty.TRACKING),
|
||||
this.handleTrackingChanged_, this);
|
||||
|
||||
if (options.projection !== undefined) {
|
||||
this.setProjection(options.projection);
|
||||
@@ -112,10 +112,10 @@ Geolocation.prototype.disposeInternal = function() {
|
||||
* @private
|
||||
*/
|
||||
Geolocation.prototype.handleProjectionChanged_ = function() {
|
||||
var projection = this.getProjection();
|
||||
const projection = this.getProjection();
|
||||
if (projection) {
|
||||
this.transform_ = getTransformFromProjections(
|
||||
getProjection('EPSG:4326'), projection);
|
||||
getProjection('EPSG:4326'), projection);
|
||||
if (this.position_) {
|
||||
this.set(GeolocationProperty.POSITION, this.transform_(this.position_));
|
||||
}
|
||||
@@ -128,12 +128,12 @@ Geolocation.prototype.handleProjectionChanged_ = function() {
|
||||
*/
|
||||
Geolocation.prototype.handleTrackingChanged_ = function() {
|
||||
if (_ol_has_.GEOLOCATION) {
|
||||
var tracking = this.getTracking();
|
||||
const tracking = this.getTracking();
|
||||
if (tracking && this.watchId_ === undefined) {
|
||||
this.watchId_ = navigator.geolocation.watchPosition(
|
||||
this.positionChange_.bind(this),
|
||||
this.positionError_.bind(this),
|
||||
this.getTrackingOptions());
|
||||
this.positionChange_.bind(this),
|
||||
this.positionError_.bind(this),
|
||||
this.getTrackingOptions());
|
||||
} else if (!tracking && this.watchId_ !== undefined) {
|
||||
navigator.geolocation.clearWatch(this.watchId_);
|
||||
this.watchId_ = undefined;
|
||||
@@ -147,13 +147,13 @@ Geolocation.prototype.handleTrackingChanged_ = function() {
|
||||
* @param {GeolocationPosition} position position event.
|
||||
*/
|
||||
Geolocation.prototype.positionChange_ = function(position) {
|
||||
var coords = position.coords;
|
||||
const coords = position.coords;
|
||||
this.set(GeolocationProperty.ACCURACY, coords.accuracy);
|
||||
this.set(GeolocationProperty.ALTITUDE,
|
||||
coords.altitude === null ? undefined : coords.altitude);
|
||||
coords.altitude === null ? undefined : coords.altitude);
|
||||
this.set(GeolocationProperty.ALTITUDE_ACCURACY,
|
||||
coords.altitudeAccuracy === null ?
|
||||
undefined : coords.altitudeAccuracy);
|
||||
coords.altitudeAccuracy === null ?
|
||||
undefined : coords.altitudeAccuracy);
|
||||
this.set(GeolocationProperty.HEADING, coords.heading === null ?
|
||||
undefined : toRadians(coords.heading));
|
||||
if (!this.position_) {
|
||||
@@ -162,11 +162,11 @@ Geolocation.prototype.positionChange_ = function(position) {
|
||||
this.position_[0] = coords.longitude;
|
||||
this.position_[1] = coords.latitude;
|
||||
}
|
||||
var projectedPosition = this.transform_(this.position_);
|
||||
const projectedPosition = this.transform_(this.position_);
|
||||
this.set(GeolocationProperty.POSITION, projectedPosition);
|
||||
this.set(GeolocationProperty.SPEED,
|
||||
coords.speed === null ? undefined : coords.speed);
|
||||
var geometry = circularPolygon(this.position_, coords.accuracy);
|
||||
coords.speed === null ? undefined : coords.speed);
|
||||
const geometry = circularPolygon(this.position_, coords.accuracy);
|
||||
geometry.applyTransform(this.transform_);
|
||||
this.set(GeolocationProperty.ACCURACY_GEOMETRY, geometry);
|
||||
this.changed();
|
||||
|
||||
+80
-80
@@ -20,7 +20,7 @@ import Text from './style/Text.js';
|
||||
* @private
|
||||
* @const
|
||||
*/
|
||||
var DEFAULT_STROKE_STYLE = new Stroke({
|
||||
const DEFAULT_STROKE_STYLE = new Stroke({
|
||||
color: 'rgba(0,0,0,0.2)'
|
||||
});
|
||||
|
||||
@@ -29,7 +29,7 @@ var DEFAULT_STROKE_STYLE = new Stroke({
|
||||
* @type {Array.<number>}
|
||||
* @private
|
||||
*/
|
||||
var INTERVALS = [
|
||||
const INTERVALS = [
|
||||
90, 45, 30, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, 0.01, 0.005, 0.002, 0.001
|
||||
];
|
||||
|
||||
@@ -47,7 +47,7 @@ var INTERVALS = [
|
||||
* lonLabelStyle: (ol.style.Text|undefined),
|
||||
* latLabelStyle: (ol.style.Text|undefined)}}
|
||||
*/
|
||||
export var GraticuleOptions;
|
||||
export let GraticuleOptions;
|
||||
|
||||
|
||||
/**
|
||||
@@ -119,8 +119,8 @@ export var GraticuleOptions;
|
||||
* of the viewport.
|
||||
* @api
|
||||
*/
|
||||
var Graticule = function(opt_options) {
|
||||
var options = opt_options || {};
|
||||
const Graticule = function(opt_options) {
|
||||
const options = opt_options || {};
|
||||
|
||||
/**
|
||||
* @type {ol.PluggableMap}
|
||||
@@ -244,7 +244,7 @@ var Graticule = function(opt_options) {
|
||||
this.parallelsLabels_ = null;
|
||||
|
||||
if (options.showLabels == true) {
|
||||
var degreesToString = _ol_coordinate_.degreesToStringHDMS;
|
||||
const degreesToString = _ol_coordinate_.degreesToStringHDMS;
|
||||
|
||||
/**
|
||||
* @type {null|function(number):string}
|
||||
@@ -331,11 +331,11 @@ var Graticule = function(opt_options) {
|
||||
* @private
|
||||
*/
|
||||
Graticule.prototype.addMeridian_ = function(lon, minLat, maxLat, squaredTolerance, extent, index) {
|
||||
var lineString = this.getMeridian_(lon, minLat, maxLat,
|
||||
squaredTolerance, index);
|
||||
const lineString = this.getMeridian_(lon, minLat, maxLat,
|
||||
squaredTolerance, index);
|
||||
if (intersects(lineString.getExtent(), extent)) {
|
||||
if (this.meridiansLabels_) {
|
||||
var textPoint = this.getMeridianPoint_(lineString, extent, index);
|
||||
const textPoint = this.getMeridianPoint_(lineString, extent, index);
|
||||
this.meridiansLabels_[index] = {
|
||||
geom: textPoint,
|
||||
text: this.lonLabelFormatter_(lon)
|
||||
@@ -354,14 +354,14 @@ Graticule.prototype.addMeridian_ = function(lon, minLat, maxLat, squaredToleranc
|
||||
* @private
|
||||
*/
|
||||
Graticule.prototype.getMeridianPoint_ = function(lineString, extent, index) {
|
||||
var flatCoordinates = lineString.getFlatCoordinates();
|
||||
var clampedBottom = Math.max(extent[1], flatCoordinates[1]);
|
||||
var clampedTop = Math.min(extent[3], flatCoordinates[flatCoordinates.length - 1]);
|
||||
var lat = clamp(
|
||||
extent[1] + Math.abs(extent[1] - extent[3]) * this.lonLabelPosition_,
|
||||
clampedBottom, clampedTop);
|
||||
var coordinate = [flatCoordinates[0], lat];
|
||||
var point = this.meridiansLabels_[index] !== undefined ?
|
||||
const flatCoordinates = lineString.getFlatCoordinates();
|
||||
const clampedBottom = Math.max(extent[1], flatCoordinates[1]);
|
||||
const clampedTop = Math.min(extent[3], flatCoordinates[flatCoordinates.length - 1]);
|
||||
const lat = clamp(
|
||||
extent[1] + Math.abs(extent[1] - extent[3]) * this.lonLabelPosition_,
|
||||
clampedBottom, clampedTop);
|
||||
const coordinate = [flatCoordinates[0], lat];
|
||||
const point = this.meridiansLabels_[index] !== undefined ?
|
||||
this.meridiansLabels_[index].geom : new Point(null);
|
||||
point.setCoordinates(coordinate);
|
||||
return point;
|
||||
@@ -379,11 +379,11 @@ Graticule.prototype.getMeridianPoint_ = function(lineString, extent, index) {
|
||||
* @private
|
||||
*/
|
||||
Graticule.prototype.addParallel_ = function(lat, minLon, maxLon, squaredTolerance, extent, index) {
|
||||
var lineString = this.getParallel_(lat, minLon, maxLon, squaredTolerance,
|
||||
index);
|
||||
const lineString = this.getParallel_(lat, minLon, maxLon, squaredTolerance,
|
||||
index);
|
||||
if (intersects(lineString.getExtent(), extent)) {
|
||||
if (this.parallelsLabels_) {
|
||||
var textPoint = this.getParallelPoint_(lineString, extent, index);
|
||||
const textPoint = this.getParallelPoint_(lineString, extent, index);
|
||||
this.parallelsLabels_[index] = {
|
||||
geom: textPoint,
|
||||
text: this.latLabelFormatter_(lat)
|
||||
@@ -403,14 +403,14 @@ Graticule.prototype.addParallel_ = function(lat, minLon, maxLon, squaredToleranc
|
||||
* @private
|
||||
*/
|
||||
Graticule.prototype.getParallelPoint_ = function(lineString, extent, index) {
|
||||
var flatCoordinates = lineString.getFlatCoordinates();
|
||||
var clampedLeft = Math.max(extent[0], flatCoordinates[0]);
|
||||
var clampedRight = Math.min(extent[2], flatCoordinates[flatCoordinates.length - 2]);
|
||||
var lon = clamp(
|
||||
extent[0] + Math.abs(extent[0] - extent[2]) * this.latLabelPosition_,
|
||||
clampedLeft, clampedRight);
|
||||
var coordinate = [lon, flatCoordinates[1]];
|
||||
var point = this.parallelsLabels_[index] !== undefined ?
|
||||
const flatCoordinates = lineString.getFlatCoordinates();
|
||||
const clampedLeft = Math.max(extent[0], flatCoordinates[0]);
|
||||
const clampedRight = Math.min(extent[2], flatCoordinates[flatCoordinates.length - 2]);
|
||||
const lon = clamp(
|
||||
extent[0] + Math.abs(extent[0] - extent[2]) * this.latLabelPosition_,
|
||||
clampedLeft, clampedRight);
|
||||
const coordinate = [lon, flatCoordinates[1]];
|
||||
const point = this.parallelsLabels_[index] !== undefined ?
|
||||
this.parallelsLabels_[index].geom : new Point(null);
|
||||
point.setCoordinates(coordinate);
|
||||
return point;
|
||||
@@ -426,7 +426,7 @@ Graticule.prototype.getParallelPoint_ = function(lineString, extent, index) {
|
||||
*/
|
||||
Graticule.prototype.createGraticule_ = function(extent, center, resolution, squaredTolerance) {
|
||||
|
||||
var interval = this.getInterval_(resolution);
|
||||
const interval = this.getInterval_(resolution);
|
||||
if (interval == -1) {
|
||||
this.meridians_.length = this.parallels_.length = 0;
|
||||
if (this.meridiansLabels_) {
|
||||
@@ -438,13 +438,13 @@ Graticule.prototype.createGraticule_ = function(extent, center, resolution, squa
|
||||
return;
|
||||
}
|
||||
|
||||
var centerLonLat = this.toLonLatTransform_(center);
|
||||
var centerLon = centerLonLat[0];
|
||||
var centerLat = centerLonLat[1];
|
||||
var maxLines = this.maxLines_;
|
||||
var cnt, idx, lat, lon;
|
||||
const centerLonLat = this.toLonLatTransform_(center);
|
||||
let centerLon = centerLonLat[0];
|
||||
let centerLat = centerLonLat[1];
|
||||
const maxLines = this.maxLines_;
|
||||
let cnt, idx, lat, lon;
|
||||
|
||||
var validExtent = [
|
||||
let validExtent = [
|
||||
Math.max(extent[0], this.minLonP_),
|
||||
Math.max(extent[1], this.minLatP_),
|
||||
Math.min(extent[2], this.maxLonP_),
|
||||
@@ -452,11 +452,11 @@ Graticule.prototype.createGraticule_ = function(extent, center, resolution, squa
|
||||
];
|
||||
|
||||
validExtent = transformExtent(validExtent, this.projection_,
|
||||
'EPSG:4326');
|
||||
var maxLat = validExtent[3];
|
||||
var maxLon = validExtent[2];
|
||||
var minLat = validExtent[1];
|
||||
var minLon = validExtent[0];
|
||||
'EPSG:4326');
|
||||
const maxLat = validExtent[3];
|
||||
const maxLon = validExtent[2];
|
||||
const minLat = validExtent[1];
|
||||
const minLon = validExtent[0];
|
||||
|
||||
// Create meridians
|
||||
|
||||
@@ -519,15 +519,15 @@ Graticule.prototype.createGraticule_ = function(extent, center, resolution, squa
|
||||
* @private
|
||||
*/
|
||||
Graticule.prototype.getInterval_ = function(resolution) {
|
||||
var centerLon = this.projectionCenterLonLat_[0];
|
||||
var centerLat = this.projectionCenterLonLat_[1];
|
||||
var interval = -1;
|
||||
var i, ii, delta, dist;
|
||||
var target = Math.pow(this.targetSize_ * resolution, 2);
|
||||
const centerLon = this.projectionCenterLonLat_[0];
|
||||
const centerLat = this.projectionCenterLonLat_[1];
|
||||
let interval = -1;
|
||||
let i, ii, delta, dist;
|
||||
const target = Math.pow(this.targetSize_ * resolution, 2);
|
||||
/** @type {Array.<number>} **/
|
||||
var p1 = [];
|
||||
const p1 = [];
|
||||
/** @type {Array.<number>} **/
|
||||
var p2 = [];
|
||||
const p2 = [];
|
||||
for (i = 0, ii = INTERVALS.length; i < ii; ++i) {
|
||||
delta = INTERVALS[i] / 2;
|
||||
p1[0] = centerLon - delta;
|
||||
@@ -566,10 +566,10 @@ Graticule.prototype.getMap = function() {
|
||||
* @private
|
||||
*/
|
||||
Graticule.prototype.getMeridian_ = function(lon, minLat, maxLat,
|
||||
squaredTolerance, index) {
|
||||
var flatCoordinates = _ol_geom_flat_geodesic_.meridian(lon,
|
||||
minLat, maxLat, this.projection_, squaredTolerance);
|
||||
var lineString = this.meridians_[index] !== undefined ?
|
||||
squaredTolerance, index) {
|
||||
const flatCoordinates = _ol_geom_flat_geodesic_.meridian(lon,
|
||||
minLat, maxLat, this.projection_, squaredTolerance);
|
||||
const lineString = this.meridians_[index] !== undefined ?
|
||||
this.meridians_[index] : new LineString(null);
|
||||
lineString.setFlatCoordinates(GeometryLayout.XY, flatCoordinates);
|
||||
return lineString;
|
||||
@@ -596,10 +596,10 @@ Graticule.prototype.getMeridians = function() {
|
||||
* @private
|
||||
*/
|
||||
Graticule.prototype.getParallel_ = function(lat, minLon, maxLon,
|
||||
squaredTolerance, index) {
|
||||
var flatCoordinates = _ol_geom_flat_geodesic_.parallel(lat,
|
||||
minLon, maxLon, this.projection_, squaredTolerance);
|
||||
var lineString = this.parallels_[index] !== undefined ?
|
||||
squaredTolerance, index) {
|
||||
const flatCoordinates = _ol_geom_flat_geodesic_.parallel(lat,
|
||||
minLon, maxLon, this.projection_, squaredTolerance);
|
||||
const lineString = this.parallels_[index] !== undefined ?
|
||||
this.parallels_[index] : new LineString(null);
|
||||
lineString.setFlatCoordinates(GeometryLayout.XY, flatCoordinates);
|
||||
return lineString;
|
||||
@@ -621,18 +621,18 @@ Graticule.prototype.getParallels = function() {
|
||||
* @private
|
||||
*/
|
||||
Graticule.prototype.handlePostCompose_ = function(e) {
|
||||
var vectorContext = e.vectorContext;
|
||||
var frameState = e.frameState;
|
||||
var extent = frameState.extent;
|
||||
var viewState = frameState.viewState;
|
||||
var center = viewState.center;
|
||||
var projection = viewState.projection;
|
||||
var resolution = viewState.resolution;
|
||||
var pixelRatio = frameState.pixelRatio;
|
||||
var squaredTolerance =
|
||||
const vectorContext = e.vectorContext;
|
||||
const frameState = e.frameState;
|
||||
const extent = frameState.extent;
|
||||
const viewState = frameState.viewState;
|
||||
const center = viewState.center;
|
||||
const projection = viewState.projection;
|
||||
const resolution = viewState.resolution;
|
||||
const pixelRatio = frameState.pixelRatio;
|
||||
const squaredTolerance =
|
||||
resolution * resolution / (4 * pixelRatio * pixelRatio);
|
||||
|
||||
var updateProjectionInfo = !this.projection_ ||
|
||||
const updateProjectionInfo = !this.projection_ ||
|
||||
!equivalentProjection(this.projection_, projection);
|
||||
|
||||
if (updateProjectionInfo) {
|
||||
@@ -643,7 +643,7 @@ Graticule.prototype.handlePostCompose_ = function(e) {
|
||||
|
||||
// Draw the lines
|
||||
vectorContext.setFillStrokeStyle(null, this.strokeStyle_);
|
||||
var i, l, line;
|
||||
let i, l, line;
|
||||
for (i = 0, l = this.meridians_.length; i < l; ++i) {
|
||||
line = this.meridians_[i];
|
||||
vectorContext.drawGeometry(line);
|
||||
@@ -652,7 +652,7 @@ Graticule.prototype.handlePostCompose_ = function(e) {
|
||||
line = this.parallels_[i];
|
||||
vectorContext.drawGeometry(line);
|
||||
}
|
||||
var labelData;
|
||||
let labelData;
|
||||
if (this.meridiansLabels_) {
|
||||
for (i = 0, l = this.meridiansLabels_.length; i < l; ++i) {
|
||||
labelData = this.meridiansLabels_[i];
|
||||
@@ -677,22 +677,22 @@ Graticule.prototype.handlePostCompose_ = function(e) {
|
||||
* @private
|
||||
*/
|
||||
Graticule.prototype.updateProjectionInfo_ = function(projection) {
|
||||
var epsg4326Projection = getProjection('EPSG:4326');
|
||||
const epsg4326Projection = getProjection('EPSG:4326');
|
||||
|
||||
var extent = projection.getExtent();
|
||||
var worldExtent = projection.getWorldExtent();
|
||||
var worldExtentP = transformExtent(worldExtent,
|
||||
epsg4326Projection, projection);
|
||||
const extent = projection.getExtent();
|
||||
const worldExtent = projection.getWorldExtent();
|
||||
const worldExtentP = transformExtent(worldExtent,
|
||||
epsg4326Projection, projection);
|
||||
|
||||
var maxLat = worldExtent[3];
|
||||
var maxLon = worldExtent[2];
|
||||
var minLat = worldExtent[1];
|
||||
var minLon = worldExtent[0];
|
||||
const maxLat = worldExtent[3];
|
||||
const maxLon = worldExtent[2];
|
||||
const minLat = worldExtent[1];
|
||||
const minLon = worldExtent[0];
|
||||
|
||||
var maxLatP = worldExtentP[3];
|
||||
var maxLonP = worldExtentP[2];
|
||||
var minLatP = worldExtentP[1];
|
||||
var minLonP = worldExtentP[0];
|
||||
const maxLatP = worldExtentP[3];
|
||||
const maxLonP = worldExtentP[2];
|
||||
const minLatP = worldExtentP[1];
|
||||
const minLonP = worldExtentP[0];
|
||||
|
||||
this.maxLat_ = maxLat;
|
||||
this.maxLon_ = maxLon;
|
||||
|
||||
+3
-3
@@ -18,7 +18,7 @@ import {getHeight} from './extent.js';
|
||||
* @param {?string} crossOrigin Cross origin.
|
||||
* @param {ol.ImageLoadFunctionType} imageLoadFunction Image load function.
|
||||
*/
|
||||
var _ol_Image_ = function(extent, resolution, pixelRatio, src, crossOrigin, imageLoadFunction) {
|
||||
const _ol_Image_ = function(extent, resolution, pixelRatio, src, crossOrigin, imageLoadFunction) {
|
||||
|
||||
_ol_ImageBase_.call(this, extent, resolution, pixelRatio, ImageState.IDLE);
|
||||
|
||||
@@ -109,9 +109,9 @@ _ol_Image_.prototype.load = function() {
|
||||
this.changed();
|
||||
this.imageListenerKeys_ = [
|
||||
_ol_events_.listenOnce(this.image_, EventType.ERROR,
|
||||
this.handleImageError_, this),
|
||||
this.handleImageError_, this),
|
||||
_ol_events_.listenOnce(this.image_, EventType.LOAD,
|
||||
this.handleImageLoad_, this)
|
||||
this.handleImageLoad_, this)
|
||||
];
|
||||
this.imageLoadFunction_(this, this.src_);
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ import EventType from './events/EventType.js';
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @param {ol.ImageState} state State.
|
||||
*/
|
||||
var _ol_ImageBase_ = function(extent, resolution, pixelRatio, state) {
|
||||
const _ol_ImageBase_ = function(extent, resolution, pixelRatio, state) {
|
||||
|
||||
EventTarget.call(this);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import ImageState from './ImageState.js';
|
||||
* @param {ol.ImageCanvasLoader=} opt_loader Optional loader function to
|
||||
* support asynchronous canvas drawing.
|
||||
*/
|
||||
var ImageCanvas = function(extent, resolution, pixelRatio, canvas, opt_loader) {
|
||||
const ImageCanvas = function(extent, resolution, pixelRatio, canvas, opt_loader) {
|
||||
|
||||
/**
|
||||
* Optional canvas loader function.
|
||||
@@ -24,7 +24,7 @@ var ImageCanvas = function(extent, resolution, pixelRatio, canvas, opt_loader) {
|
||||
*/
|
||||
this.loader_ = opt_loader !== undefined ? opt_loader : null;
|
||||
|
||||
var state = opt_loader !== undefined ? ImageState.IDLE : ImageState.LOADED;
|
||||
const state = opt_loader !== undefined ? ImageState.IDLE : ImageState.LOADED;
|
||||
|
||||
_ol_ImageBase_.call(this, extent, resolution, pixelRatio, state);
|
||||
|
||||
|
||||
+4
-4
@@ -18,7 +18,7 @@ import EventType from './events/EventType.js';
|
||||
* @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function.
|
||||
* @param {olx.TileOptions=} opt_options Tile options.
|
||||
*/
|
||||
var ImageTile = function(tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options) {
|
||||
const ImageTile = function(tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options) {
|
||||
|
||||
Tile.call(this, tileCoord, state, opt_options);
|
||||
|
||||
@@ -143,9 +143,9 @@ ImageTile.prototype.load = function() {
|
||||
this.changed();
|
||||
this.imageListenerKeys_ = [
|
||||
_ol_events_.listenOnce(this.image_, EventType.ERROR,
|
||||
this.handleImageError_, this),
|
||||
this.handleImageError_, this),
|
||||
_ol_events_.listenOnce(this.image_, EventType.LOAD,
|
||||
this.handleImageLoad_, this)
|
||||
this.handleImageLoad_, this)
|
||||
];
|
||||
this.tileLoadFunction_(this, this.src_);
|
||||
}
|
||||
@@ -168,7 +168,7 @@ ImageTile.prototype.unlistenImage_ = function() {
|
||||
* @return {HTMLCanvasElement} Blank image.
|
||||
*/
|
||||
ImageTile.getBlankImage = function() {
|
||||
var ctx = createCanvasContext2D(1, 1);
|
||||
const ctx = createCanvasContext2D(1, 1);
|
||||
ctx.fillStyle = 'rgba(0,0,0,0)';
|
||||
ctx.fillRect(0, 0, 1, 1);
|
||||
return ctx.canvas;
|
||||
|
||||
+7
-7
@@ -14,7 +14,7 @@
|
||||
* @struct
|
||||
* @api
|
||||
*/
|
||||
var Kinetic = function(decay, minVelocity, delay) {
|
||||
const Kinetic = function(decay, minVelocity, delay) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -82,8 +82,8 @@ Kinetic.prototype.end = function() {
|
||||
// in the array)
|
||||
return false;
|
||||
}
|
||||
var delay = Date.now() - this.delay_;
|
||||
var lastIndex = this.points_.length - 3;
|
||||
const delay = Date.now() - this.delay_;
|
||||
const lastIndex = this.points_.length - 3;
|
||||
if (this.points_[lastIndex + 2] < delay) {
|
||||
// the last tracked point is too old, which means that the user stopped
|
||||
// panning before releasing the map
|
||||
@@ -91,12 +91,12 @@ Kinetic.prototype.end = function() {
|
||||
}
|
||||
|
||||
// get the first point which still falls into the delay time
|
||||
var firstIndex = lastIndex - 3;
|
||||
let firstIndex = lastIndex - 3;
|
||||
while (firstIndex > 0 && this.points_[firstIndex + 2] > delay) {
|
||||
firstIndex -= 3;
|
||||
}
|
||||
|
||||
var duration = this.points_[lastIndex + 2] - this.points_[firstIndex + 2];
|
||||
const duration = this.points_[lastIndex + 2] - this.points_[firstIndex + 2];
|
||||
// we don't want a duration of 0 (divide by zero)
|
||||
// we also make sure the user panned for a duration of at least one frame
|
||||
// (1/60s) to compute sane displacement values
|
||||
@@ -104,8 +104,8 @@ Kinetic.prototype.end = function() {
|
||||
return false;
|
||||
}
|
||||
|
||||
var dx = this.points_[lastIndex] - this.points_[firstIndex];
|
||||
var dy = this.points_[lastIndex + 1] - this.points_[firstIndex + 1];
|
||||
const dx = this.points_[lastIndex] - this.points_[firstIndex];
|
||||
const dy = this.points_[lastIndex + 1] - this.points_[firstIndex + 1];
|
||||
this.angle_ = Math.atan2(dy, dx);
|
||||
this.initialVelocity_ = Math.sqrt(dx * dx + dy * dy) / duration;
|
||||
return this.initialVelocity_ > this.minVelocity_;
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ registerMultiple(PluginType.LAYER_RENDERER, [
|
||||
* @fires ol.render.Event#precompose
|
||||
* @api
|
||||
*/
|
||||
var Map = function(options) {
|
||||
const Map = function(options) {
|
||||
options = _ol_obj_.assign({}, options);
|
||||
if (!options.controls) {
|
||||
options.controls = defaultControls();
|
||||
|
||||
@@ -18,8 +18,8 @@ import MapEvent from './MapEvent.js';
|
||||
* @param {boolean=} opt_dragging Is the map currently being dragged?
|
||||
* @param {?olx.FrameState=} opt_frameState Frame state.
|
||||
*/
|
||||
var MapBrowserEvent = function(type, map, browserEvent, opt_dragging,
|
||||
opt_frameState) {
|
||||
const MapBrowserEvent = function(type, map, browserEvent, opt_dragging,
|
||||
opt_frameState) {
|
||||
|
||||
MapEvent.call(this, type, map, opt_frameState);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import PointerEventHandler from './pointer/PointerEventHandler.js';
|
||||
* @constructor
|
||||
* @extends {ol.events.EventTarget}
|
||||
*/
|
||||
var MapBrowserEventHandler = function(map, moveTolerance) {
|
||||
const MapBrowserEventHandler = function(map, moveTolerance) {
|
||||
|
||||
EventTarget.call(this);
|
||||
|
||||
@@ -60,7 +60,7 @@ var MapBrowserEventHandler = function(map, moveTolerance) {
|
||||
*/
|
||||
this.down_ = null;
|
||||
|
||||
var element = this.map_.getViewport();
|
||||
const element = this.map_.getViewport();
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
@@ -97,16 +97,16 @@ var MapBrowserEventHandler = function(map, moveTolerance) {
|
||||
* @private
|
||||
*/
|
||||
this.pointerdownListenerKey_ = _ol_events_.listen(this.pointerEventHandler_,
|
||||
PointerEventType.POINTERDOWN,
|
||||
this.handlePointerDown_, this);
|
||||
PointerEventType.POINTERDOWN,
|
||||
this.handlePointerDown_, this);
|
||||
|
||||
/**
|
||||
* @type {?ol.EventsKey}
|
||||
* @private
|
||||
*/
|
||||
this.relayedListenerKey_ = _ol_events_.listen(this.pointerEventHandler_,
|
||||
PointerEventType.POINTERMOVE,
|
||||
this.relayEvent_, this);
|
||||
PointerEventType.POINTERMOVE,
|
||||
this.relayEvent_, this);
|
||||
|
||||
};
|
||||
|
||||
@@ -118,22 +118,22 @@ inherits(MapBrowserEventHandler, EventTarget);
|
||||
* @private
|
||||
*/
|
||||
MapBrowserEventHandler.prototype.emulateClick_ = function(pointerEvent) {
|
||||
var newEvent = new MapBrowserPointerEvent(
|
||||
MapBrowserEventType.CLICK, this.map_, pointerEvent);
|
||||
let newEvent = new MapBrowserPointerEvent(
|
||||
MapBrowserEventType.CLICK, this.map_, pointerEvent);
|
||||
this.dispatchEvent(newEvent);
|
||||
if (this.clickTimeoutId_ !== 0) {
|
||||
// double-click
|
||||
clearTimeout(this.clickTimeoutId_);
|
||||
this.clickTimeoutId_ = 0;
|
||||
newEvent = new MapBrowserPointerEvent(
|
||||
MapBrowserEventType.DBLCLICK, this.map_, pointerEvent);
|
||||
MapBrowserEventType.DBLCLICK, this.map_, pointerEvent);
|
||||
this.dispatchEvent(newEvent);
|
||||
} else {
|
||||
// click
|
||||
this.clickTimeoutId_ = setTimeout(function() {
|
||||
this.clickTimeoutId_ = 0;
|
||||
var newEvent = new MapBrowserPointerEvent(
|
||||
MapBrowserEventType.SINGLECLICK, this.map_, pointerEvent);
|
||||
const newEvent = new MapBrowserPointerEvent(
|
||||
MapBrowserEventType.SINGLECLICK, this.map_, pointerEvent);
|
||||
this.dispatchEvent(newEvent);
|
||||
}.bind(this), 250);
|
||||
}
|
||||
@@ -147,7 +147,7 @@ MapBrowserEventHandler.prototype.emulateClick_ = function(pointerEvent) {
|
||||
* @private
|
||||
*/
|
||||
MapBrowserEventHandler.prototype.updateActivePointers_ = function(pointerEvent) {
|
||||
var event = pointerEvent;
|
||||
const event = pointerEvent;
|
||||
|
||||
if (event.type == MapBrowserEventType.POINTERUP ||
|
||||
event.type == MapBrowserEventType.POINTERCANCEL) {
|
||||
@@ -165,8 +165,8 @@ MapBrowserEventHandler.prototype.updateActivePointers_ = function(pointerEvent)
|
||||
*/
|
||||
MapBrowserEventHandler.prototype.handlePointerUp_ = function(pointerEvent) {
|
||||
this.updateActivePointers_(pointerEvent);
|
||||
var newEvent = new MapBrowserPointerEvent(
|
||||
MapBrowserEventType.POINTERUP, this.map_, pointerEvent);
|
||||
const newEvent = new MapBrowserPointerEvent(
|
||||
MapBrowserEventType.POINTERUP, this.map_, pointerEvent);
|
||||
this.dispatchEvent(newEvent);
|
||||
|
||||
// We emulate click events on left mouse button click, touch contact, and pen
|
||||
@@ -206,8 +206,8 @@ MapBrowserEventHandler.prototype.isMouseActionButton_ = function(pointerEvent) {
|
||||
*/
|
||||
MapBrowserEventHandler.prototype.handlePointerDown_ = function(pointerEvent) {
|
||||
this.updateActivePointers_(pointerEvent);
|
||||
var newEvent = new MapBrowserPointerEvent(
|
||||
MapBrowserEventType.POINTERDOWN, this.map_, pointerEvent);
|
||||
const newEvent = new MapBrowserPointerEvent(
|
||||
MapBrowserEventType.POINTERDOWN, this.map_, pointerEvent);
|
||||
this.dispatchEvent(newEvent);
|
||||
|
||||
this.down_ = pointerEvent;
|
||||
@@ -221,13 +221,13 @@ MapBrowserEventHandler.prototype.handlePointerDown_ = function(pointerEvent) {
|
||||
new PointerEventHandler(document);
|
||||
|
||||
this.dragListenerKeys_.push(
|
||||
_ol_events_.listen(this.documentPointerEventHandler_,
|
||||
MapBrowserEventType.POINTERMOVE,
|
||||
this.handlePointerMove_, this),
|
||||
_ol_events_.listen(this.documentPointerEventHandler_,
|
||||
MapBrowserEventType.POINTERUP,
|
||||
this.handlePointerUp_, this),
|
||||
/* Note that the listener for `pointercancel is set up on
|
||||
_ol_events_.listen(this.documentPointerEventHandler_,
|
||||
MapBrowserEventType.POINTERMOVE,
|
||||
this.handlePointerMove_, this),
|
||||
_ol_events_.listen(this.documentPointerEventHandler_,
|
||||
MapBrowserEventType.POINTERUP,
|
||||
this.handlePointerUp_, this),
|
||||
/* Note that the listener for `pointercancel is set up on
|
||||
* `pointerEventHandler_` and not `documentPointerEventHandler_` like
|
||||
* the `pointerup` and `pointermove` listeners.
|
||||
*
|
||||
@@ -240,9 +240,9 @@ MapBrowserEventHandler.prototype.handlePointerDown_ = function(pointerEvent) {
|
||||
* only receive a `touchcancel` from `pointerEventHandler_`, because it is
|
||||
* only registered there.
|
||||
*/
|
||||
_ol_events_.listen(this.pointerEventHandler_,
|
||||
MapBrowserEventType.POINTERCANCEL,
|
||||
this.handlePointerUp_, this)
|
||||
_ol_events_.listen(this.pointerEventHandler_,
|
||||
MapBrowserEventType.POINTERCANCEL,
|
||||
this.handlePointerUp_, this)
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -258,9 +258,9 @@ MapBrowserEventHandler.prototype.handlePointerMove_ = function(pointerEvent) {
|
||||
// moved a significant distance.
|
||||
if (this.isMoving_(pointerEvent)) {
|
||||
this.dragging_ = true;
|
||||
var newEvent = new MapBrowserPointerEvent(
|
||||
MapBrowserEventType.POINTERDRAG, this.map_, pointerEvent,
|
||||
this.dragging_);
|
||||
const newEvent = new MapBrowserPointerEvent(
|
||||
MapBrowserEventType.POINTERDRAG, this.map_, pointerEvent,
|
||||
this.dragging_);
|
||||
this.dispatchEvent(newEvent);
|
||||
}
|
||||
|
||||
@@ -279,9 +279,9 @@ MapBrowserEventHandler.prototype.handlePointerMove_ = function(pointerEvent) {
|
||||
* @private
|
||||
*/
|
||||
MapBrowserEventHandler.prototype.relayEvent_ = function(pointerEvent) {
|
||||
var dragging = !!(this.down_ && this.isMoving_(pointerEvent));
|
||||
const dragging = !!(this.down_ && this.isMoving_(pointerEvent));
|
||||
this.dispatchEvent(new MapBrowserPointerEvent(
|
||||
pointerEvent.type, this.map_, pointerEvent, dragging));
|
||||
pointerEvent.type, this.map_, pointerEvent, dragging));
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -13,11 +13,11 @@ import MapBrowserEvent from './MapBrowserEvent.js';
|
||||
* @param {boolean=} opt_dragging Is the map currently being dragged?
|
||||
* @param {?olx.FrameState=} opt_frameState Frame state.
|
||||
*/
|
||||
var MapBrowserPointerEvent = function(type, map, pointerEvent, opt_dragging,
|
||||
opt_frameState) {
|
||||
const MapBrowserPointerEvent = function(type, map, pointerEvent, opt_dragging,
|
||||
opt_frameState) {
|
||||
|
||||
MapBrowserEvent.call(this, type, map, pointerEvent.originalEvent, opt_dragging,
|
||||
opt_frameState);
|
||||
opt_frameState);
|
||||
|
||||
/**
|
||||
* @const
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ import Event from './events/Event.js';
|
||||
* @param {ol.PluggableMap} map Map.
|
||||
* @param {?olx.FrameState=} opt_frameState Frame state.
|
||||
*/
|
||||
var MapEvent = function(type, map, opt_frameState) {
|
||||
const MapEvent = function(type, map, opt_frameState) {
|
||||
|
||||
Event.call(this, type);
|
||||
|
||||
|
||||
+6
-6
@@ -52,7 +52,7 @@ import _ol_obj_ from './obj.js';
|
||||
* @fires ol.Object.Event
|
||||
* @api
|
||||
*/
|
||||
var BaseObject = function(opt_values) {
|
||||
const BaseObject = function(opt_values) {
|
||||
Observable.call(this);
|
||||
|
||||
// Call ol.getUid to ensure that the order of objects' ids is the same as
|
||||
@@ -100,7 +100,7 @@ BaseObject.getChangeEventType = function(key) {
|
||||
* @api
|
||||
*/
|
||||
BaseObject.prototype.get = function(key) {
|
||||
var value;
|
||||
let value;
|
||||
if (this.values_.hasOwnProperty(key)) {
|
||||
value = this.values_[key];
|
||||
}
|
||||
@@ -133,7 +133,7 @@ BaseObject.prototype.getProperties = function() {
|
||||
* @param {*} oldValue Old value.
|
||||
*/
|
||||
BaseObject.prototype.notify = function(key, oldValue) {
|
||||
var eventType;
|
||||
let eventType;
|
||||
eventType = BaseObject.getChangeEventType(key);
|
||||
this.dispatchEvent(new BaseObject.Event(eventType, key, oldValue));
|
||||
eventType = ObjectEventType.PROPERTYCHANGE;
|
||||
@@ -152,7 +152,7 @@ BaseObject.prototype.set = function(key, value, opt_silent) {
|
||||
if (opt_silent) {
|
||||
this.values_[key] = value;
|
||||
} else {
|
||||
var oldValue = this.values_[key];
|
||||
const oldValue = this.values_[key];
|
||||
this.values_[key] = value;
|
||||
if (oldValue !== value) {
|
||||
this.notify(key, oldValue);
|
||||
@@ -169,7 +169,7 @@ BaseObject.prototype.set = function(key, value, opt_silent) {
|
||||
* @api
|
||||
*/
|
||||
BaseObject.prototype.setProperties = function(values, opt_silent) {
|
||||
var key;
|
||||
let key;
|
||||
for (key in values) {
|
||||
this.set(key, values[key], opt_silent);
|
||||
}
|
||||
@@ -184,7 +184,7 @@ BaseObject.prototype.setProperties = function(values, opt_silent) {
|
||||
*/
|
||||
BaseObject.prototype.unset = function(key, opt_silent) {
|
||||
if (key in this.values_) {
|
||||
var oldValue = this.values_[key];
|
||||
const oldValue = this.values_[key];
|
||||
delete this.values_[key];
|
||||
if (!opt_silent) {
|
||||
this.notify(key, oldValue);
|
||||
|
||||
+11
-11
@@ -20,7 +20,7 @@ import EventType from './events/EventType.js';
|
||||
* @struct
|
||||
* @api
|
||||
*/
|
||||
var Observable = function() {
|
||||
const Observable = function() {
|
||||
|
||||
EventTarget.call(this);
|
||||
|
||||
@@ -43,7 +43,7 @@ inherits(Observable, EventTarget);
|
||||
*/
|
||||
Observable.unByKey = function(key) {
|
||||
if (Array.isArray(key)) {
|
||||
for (var i = 0, ii = key.length; i < ii; ++i) {
|
||||
for (let i = 0, ii = key.length; i < ii; ++i) {
|
||||
_ol_events_.unlistenByKey(key[i]);
|
||||
}
|
||||
} else {
|
||||
@@ -98,15 +98,15 @@ Observable.prototype.getRevision = function() {
|
||||
*/
|
||||
Observable.prototype.on = function(type, listener) {
|
||||
if (Array.isArray(type)) {
|
||||
var len = type.length;
|
||||
var keys = new Array(len);
|
||||
for (var i = 0; i < len; ++i) {
|
||||
const len = type.length;
|
||||
const keys = new Array(len);
|
||||
for (let i = 0; i < len; ++i) {
|
||||
keys[i] = _ol_events_.listen(this, type[i], listener);
|
||||
}
|
||||
return keys;
|
||||
} else {
|
||||
return _ol_events_.listen(
|
||||
this, /** @type {string} */ (type), listener);
|
||||
this, /** @type {string} */ (type), listener);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -122,15 +122,15 @@ Observable.prototype.on = function(type, listener) {
|
||||
*/
|
||||
Observable.prototype.once = function(type, listener) {
|
||||
if (Array.isArray(type)) {
|
||||
var len = type.length;
|
||||
var keys = new Array(len);
|
||||
for (var i = 0; i < len; ++i) {
|
||||
const len = type.length;
|
||||
const keys = new Array(len);
|
||||
for (let i = 0; i < len; ++i) {
|
||||
keys[i] = _ol_events_.listenOnce(this, type[i], listener);
|
||||
}
|
||||
return keys;
|
||||
} else {
|
||||
return _ol_events_.listenOnce(
|
||||
this, /** @type {string} */ (type), listener);
|
||||
this, /** @type {string} */ (type), listener);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -143,7 +143,7 @@ Observable.prototype.once = function(type, listener) {
|
||||
*/
|
||||
Observable.prototype.un = function(type, listener) {
|
||||
if (Array.isArray(type)) {
|
||||
for (var i = 0, ii = type.length; i < ii; ++i) {
|
||||
for (let i = 0, ii = type.length; i < ii; ++i) {
|
||||
_ol_events_.unlisten(this, type[i], listener);
|
||||
}
|
||||
return;
|
||||
|
||||
+45
-45
@@ -15,7 +15,7 @@ import {containsExtent} from './extent.js';
|
||||
* @enum {string}
|
||||
* @protected
|
||||
*/
|
||||
var Property = {
|
||||
const Property = {
|
||||
ELEMENT: 'element',
|
||||
MAP: 'map',
|
||||
OFFSET: 'offset',
|
||||
@@ -45,7 +45,7 @@ var Property = {
|
||||
* @param {olx.OverlayOptions} options Overlay options.
|
||||
* @api
|
||||
*/
|
||||
var Overlay = function(options) {
|
||||
const Overlay = function(options) {
|
||||
|
||||
BaseObject.call(this);
|
||||
|
||||
@@ -126,24 +126,24 @@ var Overlay = function(options) {
|
||||
this.mapPostrenderListenerKey = null;
|
||||
|
||||
_ol_events_.listen(
|
||||
this, BaseObject.getChangeEventType(Property.ELEMENT),
|
||||
this.handleElementChanged, this);
|
||||
this, BaseObject.getChangeEventType(Property.ELEMENT),
|
||||
this.handleElementChanged, this);
|
||||
|
||||
_ol_events_.listen(
|
||||
this, BaseObject.getChangeEventType(Property.MAP),
|
||||
this.handleMapChanged, this);
|
||||
this, BaseObject.getChangeEventType(Property.MAP),
|
||||
this.handleMapChanged, this);
|
||||
|
||||
_ol_events_.listen(
|
||||
this, BaseObject.getChangeEventType(Property.OFFSET),
|
||||
this.handleOffsetChanged, this);
|
||||
this, BaseObject.getChangeEventType(Property.OFFSET),
|
||||
this.handleOffsetChanged, this);
|
||||
|
||||
_ol_events_.listen(
|
||||
this, BaseObject.getChangeEventType(Property.POSITION),
|
||||
this.handlePositionChanged, this);
|
||||
this, BaseObject.getChangeEventType(Property.POSITION),
|
||||
this.handlePositionChanged, this);
|
||||
|
||||
_ol_events_.listen(
|
||||
this, BaseObject.getChangeEventType(Property.POSITIONING),
|
||||
this.handlePositioningChanged, this);
|
||||
this, BaseObject.getChangeEventType(Property.POSITIONING),
|
||||
this.handlePositioningChanged, this);
|
||||
|
||||
if (options.element !== undefined) {
|
||||
this.setElement(options.element);
|
||||
@@ -236,7 +236,7 @@ Overlay.prototype.getPositioning = function() {
|
||||
*/
|
||||
Overlay.prototype.handleElementChanged = function() {
|
||||
removeChildren(this.element);
|
||||
var element = this.getElement();
|
||||
const element = this.getElement();
|
||||
if (element) {
|
||||
this.element.appendChild(element);
|
||||
}
|
||||
@@ -252,12 +252,12 @@ Overlay.prototype.handleMapChanged = function() {
|
||||
_ol_events_.unlistenByKey(this.mapPostrenderListenerKey);
|
||||
this.mapPostrenderListenerKey = null;
|
||||
}
|
||||
var map = this.getMap();
|
||||
const map = this.getMap();
|
||||
if (map) {
|
||||
this.mapPostrenderListenerKey = _ol_events_.listen(map,
|
||||
MapEventType.POSTRENDER, this.render, this);
|
||||
MapEventType.POSTRENDER, this.render, this);
|
||||
this.updatePixelPosition();
|
||||
var container = this.stopEvent ?
|
||||
const container = this.stopEvent ?
|
||||
map.getOverlayContainerStopEvent() : map.getOverlayContainer();
|
||||
if (this.insertFirst) {
|
||||
container.insertBefore(this.element, container.childNodes[0] || null);
|
||||
@@ -355,25 +355,25 @@ Overlay.prototype.setPosition = function(position) {
|
||||
* @protected
|
||||
*/
|
||||
Overlay.prototype.panIntoView = function() {
|
||||
var map = this.getMap();
|
||||
const map = this.getMap();
|
||||
|
||||
if (!map || !map.getTargetElement()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var mapRect = this.getRect(map.getTargetElement(), map.getSize());
|
||||
var element = /** @type {!Element} */ (this.getElement());
|
||||
var overlayRect = this.getRect(element, [outerWidth(element), outerHeight(element)]);
|
||||
const mapRect = this.getRect(map.getTargetElement(), map.getSize());
|
||||
const element = /** @type {!Element} */ (this.getElement());
|
||||
const overlayRect = this.getRect(element, [outerWidth(element), outerHeight(element)]);
|
||||
|
||||
var margin = this.autoPanMargin;
|
||||
const margin = this.autoPanMargin;
|
||||
if (!containsExtent(mapRect, overlayRect)) {
|
||||
// the overlay is not completely inside the viewport, so pan the map
|
||||
var offsetLeft = overlayRect[0] - mapRect[0];
|
||||
var offsetRight = mapRect[2] - overlayRect[2];
|
||||
var offsetTop = overlayRect[1] - mapRect[1];
|
||||
var offsetBottom = mapRect[3] - overlayRect[3];
|
||||
const offsetLeft = overlayRect[0] - mapRect[0];
|
||||
const offsetRight = mapRect[2] - overlayRect[2];
|
||||
const offsetTop = overlayRect[1] - mapRect[1];
|
||||
const offsetBottom = mapRect[3] - overlayRect[3];
|
||||
|
||||
var delta = [0, 0];
|
||||
const delta = [0, 0];
|
||||
if (offsetLeft < 0) {
|
||||
// move map to the left
|
||||
delta[0] = offsetLeft - margin;
|
||||
@@ -390,9 +390,9 @@ Overlay.prototype.panIntoView = function() {
|
||||
}
|
||||
|
||||
if (delta[0] !== 0 || delta[1] !== 0) {
|
||||
var center = /** @type {ol.Coordinate} */ (map.getView().getCenter());
|
||||
var centerPx = map.getPixelFromCoordinate(center);
|
||||
var newCenterPx = [
|
||||
const center = /** @type {ol.Coordinate} */ (map.getView().getCenter());
|
||||
const centerPx = map.getPixelFromCoordinate(center);
|
||||
const newCenterPx = [
|
||||
centerPx[0] + delta[0],
|
||||
centerPx[1] + delta[1]
|
||||
];
|
||||
@@ -415,9 +415,9 @@ Overlay.prototype.panIntoView = function() {
|
||||
* @protected
|
||||
*/
|
||||
Overlay.prototype.getRect = function(element, size) {
|
||||
var box = element.getBoundingClientRect();
|
||||
var offsetX = box.left + window.pageXOffset;
|
||||
var offsetY = box.top + window.pageYOffset;
|
||||
const box = element.getBoundingClientRect();
|
||||
const offsetX = box.left + window.pageXOffset;
|
||||
const offsetY = box.top + window.pageYOffset;
|
||||
return [
|
||||
offsetX,
|
||||
offsetY,
|
||||
@@ -457,15 +457,15 @@ Overlay.prototype.setVisible = function(visible) {
|
||||
* @protected
|
||||
*/
|
||||
Overlay.prototype.updatePixelPosition = function() {
|
||||
var map = this.getMap();
|
||||
var position = this.getPosition();
|
||||
const map = this.getMap();
|
||||
const position = this.getPosition();
|
||||
if (!map || !map.isRendered() || !position) {
|
||||
this.setVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
var pixel = map.getPixelFromCoordinate(position);
|
||||
var mapSize = map.getSize();
|
||||
const pixel = map.getPixelFromCoordinate(position);
|
||||
const mapSize = map.getSize();
|
||||
this.updateRenderedPosition(pixel, mapSize);
|
||||
};
|
||||
|
||||
@@ -476,22 +476,22 @@ Overlay.prototype.updatePixelPosition = function() {
|
||||
* @protected
|
||||
*/
|
||||
Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) {
|
||||
var style = this.element.style;
|
||||
var offset = this.getOffset();
|
||||
const style = this.element.style;
|
||||
const offset = this.getOffset();
|
||||
|
||||
var positioning = this.getPositioning();
|
||||
const positioning = this.getPositioning();
|
||||
|
||||
this.setVisible(true);
|
||||
|
||||
var offsetX = offset[0];
|
||||
var offsetY = offset[1];
|
||||
let offsetX = offset[0];
|
||||
let offsetY = offset[1];
|
||||
if (positioning == OverlayPositioning.BOTTOM_RIGHT ||
|
||||
positioning == OverlayPositioning.CENTER_RIGHT ||
|
||||
positioning == OverlayPositioning.TOP_RIGHT) {
|
||||
if (this.rendered.left_ !== '') {
|
||||
this.rendered.left_ = style.left = '';
|
||||
}
|
||||
var right = Math.round(mapSize[0] - pixel[0] - offsetX) + 'px';
|
||||
const right = Math.round(mapSize[0] - pixel[0] - offsetX) + 'px';
|
||||
if (this.rendered.right_ != right) {
|
||||
this.rendered.right_ = style.right = right;
|
||||
}
|
||||
@@ -504,7 +504,7 @@ Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) {
|
||||
positioning == OverlayPositioning.TOP_CENTER) {
|
||||
offsetX -= this.element.offsetWidth / 2;
|
||||
}
|
||||
var left = Math.round(pixel[0] + offsetX) + 'px';
|
||||
const left = Math.round(pixel[0] + offsetX) + 'px';
|
||||
if (this.rendered.left_ != left) {
|
||||
this.rendered.left_ = style.left = left;
|
||||
}
|
||||
@@ -515,7 +515,7 @@ Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) {
|
||||
if (this.rendered.top_ !== '') {
|
||||
this.rendered.top_ = style.top = '';
|
||||
}
|
||||
var bottom = Math.round(mapSize[1] - pixel[1] - offsetY) + 'px';
|
||||
const bottom = Math.round(mapSize[1] - pixel[1] - offsetY) + 'px';
|
||||
if (this.rendered.bottom_ != bottom) {
|
||||
this.rendered.bottom_ = style.bottom = bottom;
|
||||
}
|
||||
@@ -528,7 +528,7 @@ Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) {
|
||||
positioning == OverlayPositioning.CENTER_RIGHT) {
|
||||
offsetY -= this.element.offsetHeight / 2;
|
||||
}
|
||||
var top = Math.round(pixel[1] + offsetY) + 'px';
|
||||
const top = Math.round(pixel[1] + offsetY) + 'px';
|
||||
if (this.rendered.top_ != top) {
|
||||
this.rendered.top_ = style.top = top;
|
||||
}
|
||||
|
||||
+156
-156
@@ -46,7 +46,7 @@ import _ol_transform_ from './transform.js';
|
||||
* target: (Element|string|undefined),
|
||||
* view: (ol.View|undefined)}}
|
||||
*/
|
||||
export var MapOptions;
|
||||
export let MapOptions;
|
||||
|
||||
|
||||
/**
|
||||
@@ -109,11 +109,11 @@ export var MapOptions;
|
||||
* @fires ol.render.Event#precompose
|
||||
* @api
|
||||
*/
|
||||
var PluggableMap = function(options) {
|
||||
const PluggableMap = function(options) {
|
||||
|
||||
BaseObject.call(this);
|
||||
|
||||
var optionsInternal = createOptionsInternal(options);
|
||||
const optionsInternal = createOptionsInternal(options);
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
@@ -229,7 +229,7 @@ var PluggableMap = function(options) {
|
||||
*/
|
||||
this.overlayContainerStopEvent_ = document.createElement('DIV');
|
||||
this.overlayContainerStopEvent_.className = 'ol-overlaycontainer-stopevent';
|
||||
var overlayEvents = [
|
||||
const overlayEvents = [
|
||||
EventType.CLICK,
|
||||
EventType.DBLCLICK,
|
||||
EventType.MOUSEDOWN,
|
||||
@@ -239,9 +239,9 @@ var PluggableMap = function(options) {
|
||||
EventType.MOUSEWHEEL,
|
||||
EventType.WHEEL
|
||||
];
|
||||
for (var i = 0, ii = overlayEvents.length; i < ii; ++i) {
|
||||
for (let i = 0, ii = overlayEvents.length; i < ii; ++i) {
|
||||
_ol_events_.listen(this.overlayContainerStopEvent_, overlayEvents[i],
|
||||
Event.stopPropagation);
|
||||
Event.stopPropagation);
|
||||
}
|
||||
this.viewport_.appendChild(this.overlayContainerStopEvent_);
|
||||
|
||||
@@ -250,9 +250,9 @@ var PluggableMap = function(options) {
|
||||
* @type {ol.MapBrowserEventHandler}
|
||||
*/
|
||||
this.mapBrowserEventHandler_ = new MapBrowserEventHandler(this, options.moveTolerance);
|
||||
for (var key in MapBrowserEventType) {
|
||||
for (const key in MapBrowserEventType) {
|
||||
_ol_events_.listen(this.mapBrowserEventHandler_, MapBrowserEventType[key],
|
||||
this.handleMapBrowserEvent, this);
|
||||
this.handleMapBrowserEvent, this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,9 +268,9 @@ var PluggableMap = function(options) {
|
||||
this.keyHandlerKeys_ = null;
|
||||
|
||||
_ol_events_.listen(this.viewport_, EventType.WHEEL,
|
||||
this.handleBrowserEvent, this);
|
||||
this.handleBrowserEvent, this);
|
||||
_ol_events_.listen(this.viewport_, EventType.MOUSEWHEEL,
|
||||
this.handleBrowserEvent, this);
|
||||
this.handleBrowserEvent, this);
|
||||
|
||||
/**
|
||||
* @type {ol.Collection.<ol.control.Control>}
|
||||
@@ -326,8 +326,8 @@ var PluggableMap = function(options) {
|
||||
* @type {ol.TileQueue}
|
||||
*/
|
||||
this.tileQueue_ = new TileQueue(
|
||||
this.getTilePriority.bind(this),
|
||||
this.handleTileChange_.bind(this));
|
||||
this.getTilePriority.bind(this),
|
||||
this.handleTileChange_.bind(this));
|
||||
|
||||
/**
|
||||
* Uids of features to skip at rendering time.
|
||||
@@ -337,91 +337,91 @@ var PluggableMap = function(options) {
|
||||
this.skippedFeatureUids_ = {};
|
||||
|
||||
_ol_events_.listen(
|
||||
this, BaseObject.getChangeEventType(MapProperty.LAYERGROUP),
|
||||
this.handleLayerGroupChanged_, this);
|
||||
this, BaseObject.getChangeEventType(MapProperty.LAYERGROUP),
|
||||
this.handleLayerGroupChanged_, this);
|
||||
_ol_events_.listen(this, BaseObject.getChangeEventType(MapProperty.VIEW),
|
||||
this.handleViewChanged_, this);
|
||||
this.handleViewChanged_, this);
|
||||
_ol_events_.listen(this, BaseObject.getChangeEventType(MapProperty.SIZE),
|
||||
this.handleSizeChanged_, this);
|
||||
this.handleSizeChanged_, this);
|
||||
_ol_events_.listen(this, BaseObject.getChangeEventType(MapProperty.TARGET),
|
||||
this.handleTargetChanged_, this);
|
||||
this.handleTargetChanged_, this);
|
||||
|
||||
// setProperties will trigger the rendering of the map if the map
|
||||
// is "defined" already.
|
||||
this.setProperties(optionsInternal.values);
|
||||
|
||||
this.controls.forEach(
|
||||
/**
|
||||
/**
|
||||
* @param {ol.control.Control} control Control.
|
||||
* @this {ol.PluggableMap}
|
||||
*/
|
||||
function(control) {
|
||||
control.setMap(this);
|
||||
}.bind(this));
|
||||
function(control) {
|
||||
control.setMap(this);
|
||||
}.bind(this));
|
||||
|
||||
_ol_events_.listen(this.controls, CollectionEventType.ADD,
|
||||
/**
|
||||
/**
|
||||
* @param {ol.Collection.Event} event Collection event.
|
||||
*/
|
||||
function(event) {
|
||||
event.element.setMap(this);
|
||||
}, this);
|
||||
function(event) {
|
||||
event.element.setMap(this);
|
||||
}, this);
|
||||
|
||||
_ol_events_.listen(this.controls, CollectionEventType.REMOVE,
|
||||
/**
|
||||
/**
|
||||
* @param {ol.Collection.Event} event Collection event.
|
||||
*/
|
||||
function(event) {
|
||||
event.element.setMap(null);
|
||||
}, this);
|
||||
function(event) {
|
||||
event.element.setMap(null);
|
||||
}, this);
|
||||
|
||||
this.interactions.forEach(
|
||||
/**
|
||||
/**
|
||||
* @param {ol.interaction.Interaction} interaction Interaction.
|
||||
* @this {ol.PluggableMap}
|
||||
*/
|
||||
function(interaction) {
|
||||
interaction.setMap(this);
|
||||
}.bind(this));
|
||||
function(interaction) {
|
||||
interaction.setMap(this);
|
||||
}.bind(this));
|
||||
|
||||
_ol_events_.listen(this.interactions, CollectionEventType.ADD,
|
||||
/**
|
||||
/**
|
||||
* @param {ol.Collection.Event} event Collection event.
|
||||
*/
|
||||
function(event) {
|
||||
event.element.setMap(this);
|
||||
}, this);
|
||||
function(event) {
|
||||
event.element.setMap(this);
|
||||
}, this);
|
||||
|
||||
_ol_events_.listen(this.interactions, CollectionEventType.REMOVE,
|
||||
/**
|
||||
/**
|
||||
* @param {ol.Collection.Event} event Collection event.
|
||||
*/
|
||||
function(event) {
|
||||
event.element.setMap(null);
|
||||
}, this);
|
||||
function(event) {
|
||||
event.element.setMap(null);
|
||||
}, this);
|
||||
|
||||
this.overlays_.forEach(this.addOverlayInternal_.bind(this));
|
||||
|
||||
_ol_events_.listen(this.overlays_, CollectionEventType.ADD,
|
||||
/**
|
||||
/**
|
||||
* @param {ol.Collection.Event} event Collection event.
|
||||
*/
|
||||
function(event) {
|
||||
this.addOverlayInternal_(/** @type {ol.Overlay} */ (event.element));
|
||||
}, this);
|
||||
function(event) {
|
||||
this.addOverlayInternal_(/** @type {ol.Overlay} */ (event.element));
|
||||
}, this);
|
||||
|
||||
_ol_events_.listen(this.overlays_, CollectionEventType.REMOVE,
|
||||
/**
|
||||
/**
|
||||
* @param {ol.Collection.Event} event Collection event.
|
||||
*/
|
||||
function(event) {
|
||||
var overlay = /** @type {ol.Overlay} */ (event.element);
|
||||
var id = overlay.getId();
|
||||
if (id !== undefined) {
|
||||
delete this.overlayIdIndex_[id.toString()];
|
||||
}
|
||||
event.element.setMap(null);
|
||||
}, this);
|
||||
function(event) {
|
||||
const overlay = /** @type {ol.Overlay} */ (event.element);
|
||||
const id = overlay.getId();
|
||||
if (id !== undefined) {
|
||||
delete this.overlayIdIndex_[id.toString()];
|
||||
}
|
||||
event.element.setMap(null);
|
||||
}, this);
|
||||
|
||||
};
|
||||
|
||||
@@ -456,7 +456,7 @@ PluggableMap.prototype.addInteraction = function(interaction) {
|
||||
* @api
|
||||
*/
|
||||
PluggableMap.prototype.addLayer = function(layer) {
|
||||
var layers = this.getLayerGroup().getLayers();
|
||||
const layers = this.getLayerGroup().getLayers();
|
||||
layers.push(layer);
|
||||
};
|
||||
|
||||
@@ -477,7 +477,7 @@ PluggableMap.prototype.addOverlay = function(overlay) {
|
||||
* @private
|
||||
*/
|
||||
PluggableMap.prototype.addOverlayInternal_ = function(overlay) {
|
||||
var id = overlay.getId();
|
||||
const id = overlay.getId();
|
||||
if (id !== undefined) {
|
||||
this.overlayIdIndex_[id.toString()] = overlay;
|
||||
}
|
||||
@@ -492,12 +492,12 @@ PluggableMap.prototype.addOverlayInternal_ = function(overlay) {
|
||||
PluggableMap.prototype.disposeInternal = function() {
|
||||
this.mapBrowserEventHandler_.dispose();
|
||||
_ol_events_.unlisten(this.viewport_, EventType.WHEEL,
|
||||
this.handleBrowserEvent, this);
|
||||
this.handleBrowserEvent, this);
|
||||
_ol_events_.unlisten(this.viewport_, EventType.MOUSEWHEEL,
|
||||
this.handleBrowserEvent, this);
|
||||
this.handleBrowserEvent, this);
|
||||
if (this.handleResize_ !== undefined) {
|
||||
window.removeEventListener(EventType.RESIZE,
|
||||
this.handleResize_, false);
|
||||
this.handleResize_, false);
|
||||
this.handleResize_ = undefined;
|
||||
}
|
||||
if (this.animationDelayKey_) {
|
||||
@@ -532,15 +532,15 @@ PluggableMap.prototype.forEachFeatureAtPixel = function(pixel, callback, opt_opt
|
||||
if (!this.frameState_) {
|
||||
return;
|
||||
}
|
||||
var coordinate = this.getCoordinateFromPixel(pixel);
|
||||
const coordinate = this.getCoordinateFromPixel(pixel);
|
||||
opt_options = opt_options !== undefined ? opt_options : {};
|
||||
var hitTolerance = opt_options.hitTolerance !== undefined ?
|
||||
const hitTolerance = opt_options.hitTolerance !== undefined ?
|
||||
opt_options.hitTolerance * this.frameState_.pixelRatio : 0;
|
||||
var layerFilter = opt_options.layerFilter !== undefined ?
|
||||
const layerFilter = opt_options.layerFilter !== undefined ?
|
||||
opt_options.layerFilter : TRUE;
|
||||
return this.renderer_.forEachFeatureAtCoordinate(
|
||||
coordinate, this.frameState_, hitTolerance, callback, null,
|
||||
layerFilter, null);
|
||||
coordinate, this.frameState_, hitTolerance, callback, null,
|
||||
layerFilter, null);
|
||||
};
|
||||
|
||||
|
||||
@@ -553,7 +553,7 @@ PluggableMap.prototype.forEachFeatureAtPixel = function(pixel, callback, opt_opt
|
||||
* @api
|
||||
*/
|
||||
PluggableMap.prototype.getFeaturesAtPixel = function(pixel, opt_options) {
|
||||
var features = null;
|
||||
let features = null;
|
||||
this.forEachFeatureAtPixel(pixel, function(feature) {
|
||||
if (!features) {
|
||||
features = [];
|
||||
@@ -591,12 +591,12 @@ PluggableMap.prototype.forEachLayerAtPixel = function(pixel, callback, opt_this,
|
||||
if (!this.frameState_) {
|
||||
return;
|
||||
}
|
||||
var thisArg = opt_this !== undefined ? opt_this : null;
|
||||
var layerFilter = opt_layerFilter !== undefined ? opt_layerFilter : TRUE;
|
||||
var thisArg2 = opt_this2 !== undefined ? opt_this2 : null;
|
||||
const thisArg = opt_this !== undefined ? opt_this : null;
|
||||
const layerFilter = opt_layerFilter !== undefined ? opt_layerFilter : TRUE;
|
||||
const thisArg2 = opt_this2 !== undefined ? opt_this2 : null;
|
||||
return this.renderer_.forEachLayerAtPixel(
|
||||
pixel, this.frameState_, callback, thisArg,
|
||||
layerFilter, thisArg2);
|
||||
pixel, this.frameState_, callback, thisArg,
|
||||
layerFilter, thisArg2);
|
||||
};
|
||||
|
||||
|
||||
@@ -613,13 +613,13 @@ PluggableMap.prototype.hasFeatureAtPixel = function(pixel, opt_options) {
|
||||
if (!this.frameState_) {
|
||||
return false;
|
||||
}
|
||||
var coordinate = this.getCoordinateFromPixel(pixel);
|
||||
const coordinate = this.getCoordinateFromPixel(pixel);
|
||||
opt_options = opt_options !== undefined ? opt_options : {};
|
||||
var layerFilter = opt_options.layerFilter !== undefined ? opt_options.layerFilter : TRUE;
|
||||
var hitTolerance = opt_options.hitTolerance !== undefined ?
|
||||
const layerFilter = opt_options.layerFilter !== undefined ? opt_options.layerFilter : TRUE;
|
||||
const hitTolerance = opt_options.hitTolerance !== undefined ?
|
||||
opt_options.hitTolerance * this.frameState_.pixelRatio : 0;
|
||||
return this.renderer_.hasFeatureAtCoordinate(
|
||||
coordinate, this.frameState_, hitTolerance, layerFilter, null);
|
||||
coordinate, this.frameState_, hitTolerance, layerFilter, null);
|
||||
};
|
||||
|
||||
|
||||
@@ -641,8 +641,8 @@ PluggableMap.prototype.getEventCoordinate = function(event) {
|
||||
* @api
|
||||
*/
|
||||
PluggableMap.prototype.getEventPixel = function(event) {
|
||||
var viewportPosition = this.viewport_.getBoundingClientRect();
|
||||
var eventPosition = event.changedTouches ? event.changedTouches[0] : event;
|
||||
const viewportPosition = this.viewport_.getBoundingClientRect();
|
||||
const eventPosition = event.changedTouches ? event.changedTouches[0] : event;
|
||||
return [
|
||||
eventPosition.clientX - viewportPosition.left,
|
||||
eventPosition.clientY - viewportPosition.top
|
||||
@@ -674,7 +674,7 @@ PluggableMap.prototype.getTarget = function() {
|
||||
* @api
|
||||
*/
|
||||
PluggableMap.prototype.getTargetElement = function() {
|
||||
var target = this.getTarget();
|
||||
const target = this.getTarget();
|
||||
if (target !== undefined) {
|
||||
return typeof target === 'string' ?
|
||||
document.getElementById(target) :
|
||||
@@ -693,7 +693,7 @@ PluggableMap.prototype.getTargetElement = function() {
|
||||
* @api
|
||||
*/
|
||||
PluggableMap.prototype.getCoordinateFromPixel = function(pixel) {
|
||||
var frameState = this.frameState_;
|
||||
const frameState = this.frameState_;
|
||||
if (!frameState) {
|
||||
return null;
|
||||
} else {
|
||||
@@ -733,7 +733,7 @@ PluggableMap.prototype.getOverlays = function() {
|
||||
* @api
|
||||
*/
|
||||
PluggableMap.prototype.getOverlayById = function(id) {
|
||||
var overlay = this.overlayIdIndex_[id.toString()];
|
||||
const overlay = this.overlayIdIndex_[id.toString()];
|
||||
return overlay !== undefined ? overlay : null;
|
||||
};
|
||||
|
||||
@@ -770,7 +770,7 @@ PluggableMap.prototype.getLayerGroup = function() {
|
||||
* @api
|
||||
*/
|
||||
PluggableMap.prototype.getLayers = function() {
|
||||
var layers = this.getLayerGroup().getLayers();
|
||||
const layers = this.getLayerGroup().getLayers();
|
||||
return layers;
|
||||
};
|
||||
|
||||
@@ -783,12 +783,12 @@ PluggableMap.prototype.getLayers = function() {
|
||||
* @api
|
||||
*/
|
||||
PluggableMap.prototype.getPixelFromCoordinate = function(coordinate) {
|
||||
var frameState = this.frameState_;
|
||||
const frameState = this.frameState_;
|
||||
if (!frameState) {
|
||||
return null;
|
||||
} else {
|
||||
return _ol_transform_.apply(frameState.coordinateToPixelTransform,
|
||||
coordinate.slice(0, 2));
|
||||
coordinate.slice(0, 2));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -873,7 +873,7 @@ PluggableMap.prototype.getOverlayContainerStopEvent = function() {
|
||||
PluggableMap.prototype.getTilePriority = function(tile, tileSourceKey, tileCenter, tileResolution) {
|
||||
// Filter out tiles at higher zoom levels than the current zoom level, or that
|
||||
// are outside the visible extent.
|
||||
var frameState = this.frameState_;
|
||||
const frameState = this.frameState_;
|
||||
if (!frameState || !(tileSourceKey in frameState.wantedTiles)) {
|
||||
return PriorityQueue.DROP;
|
||||
}
|
||||
@@ -886,8 +886,8 @@ PluggableMap.prototype.getTilePriority = function(tile, tileSourceKey, tileCente
|
||||
// between the center of the tile and the focus. The factor of 65536 means
|
||||
// that the prioritization should behave as desired for tiles up to
|
||||
// 65536 * Math.log(2) = 45426 pixels from the focus.
|
||||
var deltaX = tileCenter[0] - frameState.focus[0];
|
||||
var deltaY = tileCenter[1] - frameState.focus[1];
|
||||
const deltaX = tileCenter[0] - frameState.focus[0];
|
||||
const deltaY = tileCenter[1] - frameState.focus[1];
|
||||
return 65536 * Math.log(tileResolution) +
|
||||
Math.sqrt(deltaX * deltaX + deltaY * deltaY) / tileResolution;
|
||||
};
|
||||
@@ -898,8 +898,8 @@ PluggableMap.prototype.getTilePriority = function(tile, tileSourceKey, tileCente
|
||||
* @param {string=} opt_type Type.
|
||||
*/
|
||||
PluggableMap.prototype.handleBrowserEvent = function(browserEvent, opt_type) {
|
||||
var type = opt_type || browserEvent.type;
|
||||
var mapBrowserEvent = new MapBrowserEvent(type, this, browserEvent);
|
||||
const type = opt_type || browserEvent.type;
|
||||
const mapBrowserEvent = new MapBrowserEvent(type, this, browserEvent);
|
||||
this.handleMapBrowserEvent(mapBrowserEvent);
|
||||
};
|
||||
|
||||
@@ -915,15 +915,15 @@ PluggableMap.prototype.handleMapBrowserEvent = function(mapBrowserEvent) {
|
||||
}
|
||||
this.focus_ = mapBrowserEvent.coordinate;
|
||||
mapBrowserEvent.frameState = this.frameState_;
|
||||
var interactionsArray = this.getInteractions().getArray();
|
||||
var i;
|
||||
const interactionsArray = this.getInteractions().getArray();
|
||||
let i;
|
||||
if (this.dispatchEvent(mapBrowserEvent) !== false) {
|
||||
for (i = interactionsArray.length - 1; i >= 0; i--) {
|
||||
var interaction = interactionsArray[i];
|
||||
const interaction = interactionsArray[i];
|
||||
if (!interaction.getActive()) {
|
||||
continue;
|
||||
}
|
||||
var cont = interaction.handleEvent(mapBrowserEvent);
|
||||
const cont = interaction.handleEvent(mapBrowserEvent);
|
||||
if (!cont) {
|
||||
break;
|
||||
}
|
||||
@@ -937,7 +937,7 @@ PluggableMap.prototype.handleMapBrowserEvent = function(mapBrowserEvent) {
|
||||
*/
|
||||
PluggableMap.prototype.handlePostRender = function() {
|
||||
|
||||
var frameState = this.frameState_;
|
||||
const frameState = this.frameState_;
|
||||
|
||||
// Manage the tile queue
|
||||
// Image loads are expensive and a limited resource, so try to use them
|
||||
@@ -948,12 +948,12 @@ PluggableMap.prototype.handlePostRender = function() {
|
||||
// the maximum number of loads per frame and limit the number of parallel
|
||||
// tile loads to remain reactive to view changes and to reduce the chance of
|
||||
// loading tiles that will quickly disappear from view.
|
||||
var tileQueue = this.tileQueue_;
|
||||
const tileQueue = this.tileQueue_;
|
||||
if (!tileQueue.isEmpty()) {
|
||||
var maxTotalLoading = 16;
|
||||
var maxNewLoads = maxTotalLoading;
|
||||
let maxTotalLoading = 16;
|
||||
let maxNewLoads = maxTotalLoading;
|
||||
if (frameState) {
|
||||
var hints = frameState.viewHints;
|
||||
const hints = frameState.viewHints;
|
||||
if (hints[ViewHint.ANIMATING]) {
|
||||
maxTotalLoading = this.loadTilesWhileAnimating_ ? 8 : 0;
|
||||
maxNewLoads = 2;
|
||||
@@ -969,8 +969,8 @@ PluggableMap.prototype.handlePostRender = function() {
|
||||
}
|
||||
}
|
||||
|
||||
var postRenderFunctions = this.postRenderFunctions_;
|
||||
var i, ii;
|
||||
const postRenderFunctions = this.postRenderFunctions_;
|
||||
let i, ii;
|
||||
for (i = 0, ii = postRenderFunctions.length; i < ii; ++i) {
|
||||
postRenderFunctions[i](this, frameState);
|
||||
}
|
||||
@@ -995,13 +995,13 @@ PluggableMap.prototype.handleTargetChanged_ = function() {
|
||||
// If it's not now an Element we remove the viewport from the DOM.
|
||||
// If it's an Element we append the viewport element to it.
|
||||
|
||||
var targetElement;
|
||||
let targetElement;
|
||||
if (this.getTarget()) {
|
||||
targetElement = this.getTargetElement();
|
||||
}
|
||||
|
||||
if (this.keyHandlerKeys_) {
|
||||
for (var i = 0, ii = this.keyHandlerKeys_.length; i < ii; ++i) {
|
||||
for (let i = 0, ii = this.keyHandlerKeys_.length; i < ii; ++i) {
|
||||
_ol_events_.unlistenByKey(this.keyHandlerKeys_[i]);
|
||||
}
|
||||
this.keyHandlerKeys_ = null;
|
||||
@@ -1012,25 +1012,25 @@ PluggableMap.prototype.handleTargetChanged_ = function() {
|
||||
removeNode(this.viewport_);
|
||||
if (this.handleResize_ !== undefined) {
|
||||
window.removeEventListener(EventType.RESIZE,
|
||||
this.handleResize_, false);
|
||||
this.handleResize_, false);
|
||||
this.handleResize_ = undefined;
|
||||
}
|
||||
} else {
|
||||
targetElement.appendChild(this.viewport_);
|
||||
|
||||
var keyboardEventTarget = !this.keyboardEventTarget_ ?
|
||||
const keyboardEventTarget = !this.keyboardEventTarget_ ?
|
||||
targetElement : this.keyboardEventTarget_;
|
||||
this.keyHandlerKeys_ = [
|
||||
_ol_events_.listen(keyboardEventTarget, EventType.KEYDOWN,
|
||||
this.handleBrowserEvent, this),
|
||||
this.handleBrowserEvent, this),
|
||||
_ol_events_.listen(keyboardEventTarget, EventType.KEYPRESS,
|
||||
this.handleBrowserEvent, this)
|
||||
this.handleBrowserEvent, this)
|
||||
];
|
||||
|
||||
if (!this.handleResize_) {
|
||||
this.handleResize_ = this.updateSize.bind(this);
|
||||
window.addEventListener(EventType.RESIZE,
|
||||
this.handleResize_, false);
|
||||
this.handleResize_, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1068,15 +1068,15 @@ PluggableMap.prototype.handleViewChanged_ = function() {
|
||||
_ol_events_.unlistenByKey(this.viewChangeListenerKey_);
|
||||
this.viewChangeListenerKey_ = null;
|
||||
}
|
||||
var view = this.getView();
|
||||
const view = this.getView();
|
||||
if (view) {
|
||||
this.viewport_.setAttribute('data-view', getUid(view));
|
||||
this.viewPropertyListenerKey_ = _ol_events_.listen(
|
||||
view, ObjectEventType.PROPERTYCHANGE,
|
||||
this.handleViewPropertyChanged_, this);
|
||||
view, ObjectEventType.PROPERTYCHANGE,
|
||||
this.handleViewPropertyChanged_, this);
|
||||
this.viewChangeListenerKey_ = _ol_events_.listen(
|
||||
view, EventType.CHANGE,
|
||||
this.handleViewPropertyChanged_, this);
|
||||
view, EventType.CHANGE,
|
||||
this.handleViewPropertyChanged_, this);
|
||||
}
|
||||
this.render();
|
||||
};
|
||||
@@ -1090,15 +1090,15 @@ PluggableMap.prototype.handleLayerGroupChanged_ = function() {
|
||||
this.layerGroupPropertyListenerKeys_.forEach(_ol_events_.unlistenByKey);
|
||||
this.layerGroupPropertyListenerKeys_ = null;
|
||||
}
|
||||
var layerGroup = this.getLayerGroup();
|
||||
const layerGroup = this.getLayerGroup();
|
||||
if (layerGroup) {
|
||||
this.layerGroupPropertyListenerKeys_ = [
|
||||
_ol_events_.listen(
|
||||
layerGroup, ObjectEventType.PROPERTYCHANGE,
|
||||
this.render, this),
|
||||
layerGroup, ObjectEventType.PROPERTYCHANGE,
|
||||
this.render, this),
|
||||
_ol_events_.listen(
|
||||
layerGroup, EventType.CHANGE,
|
||||
this.render, this)
|
||||
layerGroup, EventType.CHANGE,
|
||||
this.render, this)
|
||||
];
|
||||
}
|
||||
this.render();
|
||||
@@ -1132,7 +1132,7 @@ PluggableMap.prototype.renderSync = function() {
|
||||
PluggableMap.prototype.render = function() {
|
||||
if (this.animationDelayKey_ === undefined) {
|
||||
this.animationDelayKey_ = requestAnimationFrame(
|
||||
this.animationDelay_);
|
||||
this.animationDelay_);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1169,7 +1169,7 @@ PluggableMap.prototype.removeInteraction = function(interaction) {
|
||||
* @api
|
||||
*/
|
||||
PluggableMap.prototype.removeLayer = function(layer) {
|
||||
var layers = this.getLayerGroup().getLayers();
|
||||
const layers = this.getLayerGroup().getLayers();
|
||||
return layers.remove(layer);
|
||||
};
|
||||
|
||||
@@ -1191,24 +1191,24 @@ PluggableMap.prototype.removeOverlay = function(overlay) {
|
||||
* @private
|
||||
*/
|
||||
PluggableMap.prototype.renderFrame_ = function(time) {
|
||||
var i, ii, viewState;
|
||||
let i, ii, viewState;
|
||||
|
||||
var size = this.getSize();
|
||||
var view = this.getView();
|
||||
var extent = createEmpty();
|
||||
var previousFrameState = this.frameState_;
|
||||
const size = this.getSize();
|
||||
const view = this.getView();
|
||||
const extent = createEmpty();
|
||||
const previousFrameState = this.frameState_;
|
||||
/** @type {?olx.FrameState} */
|
||||
var frameState = null;
|
||||
let frameState = null;
|
||||
if (size !== undefined && _ol_size_.hasArea(size) && view && view.isDef()) {
|
||||
var viewHints = view.getHints(this.frameState_ ? this.frameState_.viewHints : undefined);
|
||||
var layerStatesArray = this.getLayerGroup().getLayerStatesArray();
|
||||
var layerStates = {};
|
||||
const viewHints = view.getHints(this.frameState_ ? this.frameState_.viewHints : undefined);
|
||||
const layerStatesArray = this.getLayerGroup().getLayerStatesArray();
|
||||
const layerStates = {};
|
||||
for (i = 0, ii = layerStatesArray.length; i < ii; ++i) {
|
||||
layerStates[getUid(layerStatesArray[i].layer)] = layerStatesArray[i];
|
||||
}
|
||||
viewState = view.getState();
|
||||
var center = viewState.center;
|
||||
var pixelResolution = viewState.resolution / this.pixelRatio_;
|
||||
const center = viewState.center;
|
||||
const pixelResolution = viewState.resolution / this.pixelRatio_;
|
||||
center[0] = Math.round(center[0] / pixelResolution) * pixelResolution;
|
||||
center[1] = Math.round(center[1] / pixelResolution) * pixelResolution;
|
||||
frameState = /** @type {olx.FrameState} */ ({
|
||||
@@ -1235,7 +1235,7 @@ PluggableMap.prototype.renderFrame_ = function(time) {
|
||||
|
||||
if (frameState) {
|
||||
frameState.extent = getForViewAndSize(viewState.center,
|
||||
viewState.resolution, viewState.rotation, frameState.size, extent);
|
||||
viewState.resolution, viewState.rotation, frameState.size, extent);
|
||||
}
|
||||
|
||||
this.frameState_ = frameState;
|
||||
@@ -1246,33 +1246,33 @@ PluggableMap.prototype.renderFrame_ = function(time) {
|
||||
this.render();
|
||||
}
|
||||
Array.prototype.push.apply(
|
||||
this.postRenderFunctions_, frameState.postRenderFunctions);
|
||||
this.postRenderFunctions_, frameState.postRenderFunctions);
|
||||
|
||||
if (previousFrameState) {
|
||||
var moveStart = !this.previousExtent_ ||
|
||||
const moveStart = !this.previousExtent_ ||
|
||||
(!isEmpty(this.previousExtent_) &&
|
||||
!equals(frameState.extent, this.previousExtent_));
|
||||
if (moveStart) {
|
||||
this.dispatchEvent(
|
||||
new MapEvent(MapEventType.MOVESTART, this, previousFrameState));
|
||||
new MapEvent(MapEventType.MOVESTART, this, previousFrameState));
|
||||
this.previousExtent_ = createOrUpdateEmpty(this.previousExtent_);
|
||||
}
|
||||
}
|
||||
|
||||
var idle = this.previousExtent_ &&
|
||||
const idle = this.previousExtent_ &&
|
||||
!frameState.viewHints[ViewHint.ANIMATING] &&
|
||||
!frameState.viewHints[ViewHint.INTERACTING] &&
|
||||
!equals(frameState.extent, this.previousExtent_);
|
||||
|
||||
if (idle) {
|
||||
this.dispatchEvent(
|
||||
new MapEvent(MapEventType.MOVEEND, this, frameState));
|
||||
new MapEvent(MapEventType.MOVEEND, this, frameState));
|
||||
clone(frameState.extent, this.previousExtent_);
|
||||
}
|
||||
}
|
||||
|
||||
this.dispatchEvent(
|
||||
new MapEvent(MapEventType.POSTRENDER, this, frameState));
|
||||
new MapEvent(MapEventType.POSTRENDER, this, frameState));
|
||||
|
||||
setTimeout(this.handlePostRender.bind(this), 0);
|
||||
|
||||
@@ -1329,7 +1329,7 @@ PluggableMap.prototype.setView = function(view) {
|
||||
* @param {ol.Feature} feature Feature.
|
||||
*/
|
||||
PluggableMap.prototype.skipFeature = function(feature) {
|
||||
var featureUid = getUid(feature).toString();
|
||||
const featureUid = getUid(feature).toString();
|
||||
this.skippedFeatureUids_[featureUid] = true;
|
||||
this.render();
|
||||
};
|
||||
@@ -1341,12 +1341,12 @@ PluggableMap.prototype.skipFeature = function(feature) {
|
||||
* @api
|
||||
*/
|
||||
PluggableMap.prototype.updateSize = function() {
|
||||
var targetElement = this.getTargetElement();
|
||||
const targetElement = this.getTargetElement();
|
||||
|
||||
if (!targetElement) {
|
||||
this.setSize(undefined);
|
||||
} else {
|
||||
var computedStyle = getComputedStyle(targetElement);
|
||||
const computedStyle = getComputedStyle(targetElement);
|
||||
this.setSize([
|
||||
targetElement.offsetWidth -
|
||||
parseFloat(computedStyle['borderLeftWidth']) -
|
||||
@@ -1367,7 +1367,7 @@ PluggableMap.prototype.updateSize = function() {
|
||||
* @param {ol.Feature} feature Feature.
|
||||
*/
|
||||
PluggableMap.prototype.unskipFeature = function(feature) {
|
||||
var featureUid = getUid(feature).toString();
|
||||
const featureUid = getUid(feature).toString();
|
||||
delete this.skippedFeatureUids_[featureUid];
|
||||
this.render();
|
||||
};
|
||||
@@ -1377,7 +1377,7 @@ PluggableMap.prototype.unskipFeature = function(feature) {
|
||||
* @type {Array.<ol.renderer.Type>}
|
||||
* @const
|
||||
*/
|
||||
var DEFAULT_RENDERER_TYPES = [
|
||||
const DEFAULT_RENDERER_TYPES = [
|
||||
RendererType.CANVAS,
|
||||
RendererType.WEBGL
|
||||
];
|
||||
@@ -1392,7 +1392,7 @@ function createOptionsInternal(options) {
|
||||
/**
|
||||
* @type {Element|Document}
|
||||
*/
|
||||
var keyboardEventTarget = null;
|
||||
let keyboardEventTarget = null;
|
||||
if (options.keyboardEventTarget !== undefined) {
|
||||
keyboardEventTarget = typeof options.keyboardEventTarget === 'string' ?
|
||||
document.getElementById(options.keyboardEventTarget) :
|
||||
@@ -1402,9 +1402,9 @@ function createOptionsInternal(options) {
|
||||
/**
|
||||
* @type {Object.<string, *>}
|
||||
*/
|
||||
var values = {};
|
||||
const values = {};
|
||||
|
||||
var layerGroup = (options.layers instanceof LayerGroup) ?
|
||||
const layerGroup = (options.layers instanceof LayerGroup) ?
|
||||
options.layers : new LayerGroup({layers: options.layers});
|
||||
values[MapProperty.LAYERGROUP] = layerGroup;
|
||||
|
||||
@@ -1416,7 +1416,7 @@ function createOptionsInternal(options) {
|
||||
/**
|
||||
* @type {Array.<ol.renderer.Type>}
|
||||
*/
|
||||
var rendererTypes;
|
||||
let rendererTypes;
|
||||
|
||||
if (options.renderer !== undefined) {
|
||||
if (Array.isArray(options.renderer)) {
|
||||
@@ -1436,13 +1436,13 @@ function createOptionsInternal(options) {
|
||||
/**
|
||||
* @type {olx.MapRendererPlugin}
|
||||
*/
|
||||
var mapRendererPlugin;
|
||||
let mapRendererPlugin;
|
||||
|
||||
var mapRendererPlugins = getMapRendererPlugins();
|
||||
outer: for (var i = 0, ii = rendererTypes.length; i < ii; ++i) {
|
||||
var rendererType = rendererTypes[i];
|
||||
for (var j = 0, jj = mapRendererPlugins.length; j < jj; ++j) {
|
||||
var candidate = mapRendererPlugins[j];
|
||||
const mapRendererPlugins = getMapRendererPlugins();
|
||||
outer: for (let i = 0, ii = rendererTypes.length; i < ii; ++i) {
|
||||
const rendererType = rendererTypes[i];
|
||||
for (let j = 0, jj = mapRendererPlugins.length; j < jj; ++j) {
|
||||
const candidate = mapRendererPlugins[j];
|
||||
if (candidate['handles'](rendererType)) {
|
||||
mapRendererPlugin = candidate;
|
||||
break outer;
|
||||
@@ -1454,35 +1454,35 @@ function createOptionsInternal(options) {
|
||||
throw new Error('Unable to create a map renderer for types: ' + rendererTypes.join(', '));
|
||||
}
|
||||
|
||||
var controls;
|
||||
let controls;
|
||||
if (options.controls !== undefined) {
|
||||
if (Array.isArray(options.controls)) {
|
||||
controls = new Collection(options.controls.slice());
|
||||
} else {
|
||||
assert(options.controls instanceof Collection,
|
||||
47); // Expected `controls` to be an array or an `ol.Collection`
|
||||
47); // Expected `controls` to be an array or an `ol.Collection`
|
||||
controls = options.controls;
|
||||
}
|
||||
}
|
||||
|
||||
var interactions;
|
||||
let interactions;
|
||||
if (options.interactions !== undefined) {
|
||||
if (Array.isArray(options.interactions)) {
|
||||
interactions = new Collection(options.interactions.slice());
|
||||
} else {
|
||||
assert(options.interactions instanceof Collection,
|
||||
48); // Expected `interactions` to be an array or an `ol.Collection`
|
||||
48); // Expected `interactions` to be an array or an `ol.Collection`
|
||||
interactions = options.interactions;
|
||||
}
|
||||
}
|
||||
|
||||
var overlays;
|
||||
let overlays;
|
||||
if (options.overlays !== undefined) {
|
||||
if (Array.isArray(options.overlays)) {
|
||||
overlays = new Collection(options.overlays.slice());
|
||||
} else {
|
||||
assert(options.overlays instanceof Collection,
|
||||
49); // Expected `overlays` to be an array or an `ol.Collection`
|
||||
49); // Expected `overlays` to be an array or an `ol.Collection`
|
||||
overlays = options.overlays;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {linearFindNearest} from './array.js';
|
||||
import {clamp} from './math.js';
|
||||
var ResolutionConstraint = {};
|
||||
const ResolutionConstraint = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -20,11 +20,11 @@ ResolutionConstraint.createSnapToResolutions = function(resolutions) {
|
||||
*/
|
||||
function(resolution, delta, direction) {
|
||||
if (resolution !== undefined) {
|
||||
var z = linearFindNearest(resolutions, resolution, direction);
|
||||
let z = linearFindNearest(resolutions, resolution, direction);
|
||||
z = clamp(z + delta, 0, resolutions.length - 1);
|
||||
var index = Math.floor(z);
|
||||
const index = Math.floor(z);
|
||||
if (z != index && index < resolutions.length - 1) {
|
||||
var power = resolutions[index] / resolutions[index + 1];
|
||||
const power = resolutions[index] / resolutions[index + 1];
|
||||
return resolutions[index] / Math.pow(power, z - index);
|
||||
} else {
|
||||
return resolutions[index];
|
||||
@@ -53,10 +53,10 @@ ResolutionConstraint.createSnapToPower = function(power, maxResolution, opt_maxL
|
||||
*/
|
||||
function(resolution, delta, direction) {
|
||||
if (resolution !== undefined) {
|
||||
var offset = -direction / 2 + 0.5;
|
||||
var oldLevel = Math.floor(
|
||||
Math.log(maxResolution / resolution) / Math.log(power) + offset);
|
||||
var newLevel = Math.max(oldLevel + delta, 0);
|
||||
const offset = -direction / 2 + 0.5;
|
||||
const oldLevel = Math.floor(
|
||||
Math.log(maxResolution / resolution) / Math.log(power) + offset);
|
||||
let newLevel = Math.max(oldLevel + delta, 0);
|
||||
if (opt_maxLevel !== undefined) {
|
||||
newLevel = Math.min(newLevel, opt_maxLevel);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/RotationConstraint
|
||||
*/
|
||||
import {toRadians} from './math.js';
|
||||
var RotationConstraint = {};
|
||||
const RotationConstraint = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,7 @@ RotationConstraint.none = function(rotation, delta) {
|
||||
* @return {ol.RotationConstraintType} Rotation constraint.
|
||||
*/
|
||||
RotationConstraint.createSnapToN = function(n) {
|
||||
var theta = 2 * Math.PI / n;
|
||||
const theta = 2 * Math.PI / n;
|
||||
return (
|
||||
/**
|
||||
* @param {number|undefined} rotation Rotation.
|
||||
@@ -61,7 +61,7 @@ RotationConstraint.createSnapToN = function(n) {
|
||||
* @return {ol.RotationConstraintType} Rotation constraint.
|
||||
*/
|
||||
RotationConstraint.createSnapToZero = function(opt_tolerance) {
|
||||
var tolerance = opt_tolerance || toRadians(5);
|
||||
const tolerance = opt_tolerance || toRadians(5);
|
||||
return (
|
||||
/**
|
||||
* @param {number|undefined} rotation Rotation.
|
||||
|
||||
+7
-7
@@ -18,10 +18,10 @@ import EventType from './events/EventType.js';
|
||||
* @param {ol.TileState} state State.
|
||||
* @param {olx.TileOptions=} opt_options Tile options.
|
||||
*/
|
||||
var Tile = function(tileCoord, state, opt_options) {
|
||||
const Tile = function(tileCoord, state, opt_options) {
|
||||
EventTarget.call(this);
|
||||
|
||||
var options = opt_options ? opt_options : {};
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
/**
|
||||
* @type {ol.TileCoord}
|
||||
@@ -95,7 +95,7 @@ Tile.prototype.getInterimTile = function() {
|
||||
//empty chain
|
||||
return this;
|
||||
}
|
||||
var tile = this.interimTile;
|
||||
let tile = this.interimTile;
|
||||
|
||||
// find the first loaded tile and return it. Since the chain is sorted in
|
||||
// decreasing order of creation time, there is no need to search the remainder
|
||||
@@ -121,8 +121,8 @@ Tile.prototype.refreshInterimChain = function() {
|
||||
return;
|
||||
}
|
||||
|
||||
var tile = this.interimTile;
|
||||
var prev = this;
|
||||
let tile = this.interimTile;
|
||||
let prev = this;
|
||||
|
||||
do {
|
||||
if (tile.getState() == TileState.LOADED) {
|
||||
@@ -191,7 +191,7 @@ Tile.prototype.getAlpha = function(id, time) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
var start = this.transitionStarts_[id];
|
||||
let start = this.transitionStarts_[id];
|
||||
if (!start) {
|
||||
start = time;
|
||||
this.transitionStarts_[id] = start;
|
||||
@@ -199,7 +199,7 @@ Tile.prototype.getAlpha = function(id, time) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
var delta = time - start + (1000 / 60); // avoid rendering at 0
|
||||
const delta = time - start + (1000 / 60); // avoid rendering at 0
|
||||
if (delta >= this.transition_) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
+5
-5
@@ -11,7 +11,7 @@ import _ol_tilecoord_ from './tilecoord.js';
|
||||
* @param {number=} opt_highWaterMark High water mark.
|
||||
* @struct
|
||||
*/
|
||||
var TileCache = function(opt_highWaterMark) {
|
||||
const TileCache = function(opt_highWaterMark) {
|
||||
|
||||
LRUCache.call(this, opt_highWaterMark);
|
||||
|
||||
@@ -24,7 +24,7 @@ inherits(TileCache, LRUCache);
|
||||
* @param {Object.<string, ol.TileRange>} usedTiles Used tiles.
|
||||
*/
|
||||
TileCache.prototype.expireCache = function(usedTiles) {
|
||||
var tile, zKey;
|
||||
let tile, zKey;
|
||||
while (this.canExpireCache()) {
|
||||
tile = this.peekLast();
|
||||
zKey = tile.tileCoord[0].toString();
|
||||
@@ -44,9 +44,9 @@ TileCache.prototype.pruneExceptNewestZ = function() {
|
||||
if (this.getCount() === 0) {
|
||||
return;
|
||||
}
|
||||
var key = this.peekFirstKey();
|
||||
var tileCoord = _ol_tilecoord_.fromKey(key);
|
||||
var z = tileCoord[0];
|
||||
const key = this.peekFirstKey();
|
||||
const tileCoord = _ol_tilecoord_.fromKey(key);
|
||||
const z = tileCoord[0];
|
||||
this.forEach(function(tile) {
|
||||
if (tile.tileCoord[0] !== z) {
|
||||
this.remove(_ol_tilecoord_.getKey(tile.tileCoord));
|
||||
|
||||
+20
-20
@@ -16,24 +16,24 @@ import PriorityQueue from './structs/PriorityQueue.js';
|
||||
* Function called on each tile change event.
|
||||
* @struct
|
||||
*/
|
||||
var TileQueue = function(tilePriorityFunction, tileChangeCallback) {
|
||||
const TileQueue = function(tilePriorityFunction, tileChangeCallback) {
|
||||
|
||||
PriorityQueue.call(
|
||||
this,
|
||||
/**
|
||||
this,
|
||||
/**
|
||||
* @param {Array} element Element.
|
||||
* @return {number} Priority.
|
||||
*/
|
||||
function(element) {
|
||||
return tilePriorityFunction.apply(null, element);
|
||||
},
|
||||
/**
|
||||
function(element) {
|
||||
return tilePriorityFunction.apply(null, element);
|
||||
},
|
||||
/**
|
||||
* @param {Array} element Element.
|
||||
* @return {string} Key.
|
||||
*/
|
||||
function(element) {
|
||||
return /** @type {ol.Tile} */ (element[0]).getKey();
|
||||
});
|
||||
function(element) {
|
||||
return /** @type {ol.Tile} */ (element[0]).getKey();
|
||||
});
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -62,11 +62,11 @@ inherits(TileQueue, PriorityQueue);
|
||||
* @inheritDoc
|
||||
*/
|
||||
TileQueue.prototype.enqueue = function(element) {
|
||||
var added = PriorityQueue.prototype.enqueue.call(this, element);
|
||||
const added = PriorityQueue.prototype.enqueue.call(this, element);
|
||||
if (added) {
|
||||
var tile = element[0];
|
||||
const tile = element[0];
|
||||
_ol_events_.listen(tile, EventType.CHANGE,
|
||||
this.handleTileChange, this);
|
||||
this.handleTileChange, this);
|
||||
}
|
||||
return added;
|
||||
};
|
||||
@@ -85,13 +85,13 @@ TileQueue.prototype.getTilesLoading = function() {
|
||||
* @protected
|
||||
*/
|
||||
TileQueue.prototype.handleTileChange = function(event) {
|
||||
var tile = /** @type {ol.Tile} */ (event.target);
|
||||
var state = tile.getState();
|
||||
const tile = /** @type {ol.Tile} */ (event.target);
|
||||
const state = tile.getState();
|
||||
if (state === TileState.LOADED || state === TileState.ERROR ||
|
||||
state === TileState.EMPTY || state === TileState.ABORT) {
|
||||
_ol_events_.unlisten(tile, EventType.CHANGE,
|
||||
this.handleTileChange, this);
|
||||
var tileKey = tile.getKey();
|
||||
this.handleTileChange, this);
|
||||
const tileKey = tile.getKey();
|
||||
if (tileKey in this.tilesLoadingKeys_) {
|
||||
delete this.tilesLoadingKeys_[tileKey];
|
||||
--this.tilesLoading_;
|
||||
@@ -106,9 +106,9 @@ TileQueue.prototype.handleTileChange = function(event) {
|
||||
* @param {number} maxNewLoads Maximum number of new tiles to load.
|
||||
*/
|
||||
TileQueue.prototype.loadMoreTiles = function(maxTotalLoading, maxNewLoads) {
|
||||
var newLoads = 0;
|
||||
var abortedTiles = false;
|
||||
var state, tile, tileKey;
|
||||
let newLoads = 0;
|
||||
let abortedTiles = false;
|
||||
let state, tile, tileKey;
|
||||
while (this.tilesLoading_ < maxTotalLoading && newLoads < maxNewLoads &&
|
||||
this.getCount() > 0) {
|
||||
tile = /** @type {ol.Tile} */ (this.dequeue()[0]);
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
* @param {number} maxY Maximum Y.
|
||||
* @struct
|
||||
*/
|
||||
var TileRange = function(minX, maxX, minY, maxY) {
|
||||
const TileRange = function(minX, maxX, minY, maxY) {
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
|
||||
+32
-32
@@ -32,9 +32,9 @@ import {loadFeaturesXhr} from './featureloader.js';
|
||||
* Function to call when a source tile's state changes.
|
||||
* @param {olx.TileOptions=} opt_options Tile options.
|
||||
*/
|
||||
var VectorImageTile = function(tileCoord, state, sourceRevision, format,
|
||||
tileLoadFunction, urlTileCoord, tileUrlFunction, sourceTileGrid, tileGrid,
|
||||
sourceTiles, pixelRatio, projection, tileClass, handleTileChange, opt_options) {
|
||||
const VectorImageTile = function(tileCoord, state, sourceRevision, format,
|
||||
tileLoadFunction, urlTileCoord, tileUrlFunction, sourceTileGrid, tileGrid,
|
||||
sourceTiles, pixelRatio, projection, tileClass, handleTileChange, opt_options) {
|
||||
|
||||
Tile.call(this, tileCoord, state, opt_options);
|
||||
|
||||
@@ -89,29 +89,29 @@ var VectorImageTile = function(tileCoord, state, sourceRevision, format,
|
||||
this.sourceTileListenerKeys_ = [];
|
||||
|
||||
if (urlTileCoord) {
|
||||
var extent = tileGrid.getTileCoordExtent(urlTileCoord);
|
||||
var resolution = tileGrid.getResolution(tileCoord[0]);
|
||||
var sourceZ = sourceTileGrid.getZForResolution(resolution);
|
||||
const extent = tileGrid.getTileCoordExtent(urlTileCoord);
|
||||
const resolution = tileGrid.getResolution(tileCoord[0]);
|
||||
const sourceZ = sourceTileGrid.getZForResolution(resolution);
|
||||
sourceTileGrid.forEachTileCoord(extent, sourceZ, function(sourceTileCoord) {
|
||||
var sharedExtent = getIntersection(extent,
|
||||
sourceTileGrid.getTileCoordExtent(sourceTileCoord));
|
||||
var sourceExtent = sourceTileGrid.getExtent();
|
||||
let sharedExtent = getIntersection(extent,
|
||||
sourceTileGrid.getTileCoordExtent(sourceTileCoord));
|
||||
const sourceExtent = sourceTileGrid.getExtent();
|
||||
if (sourceExtent) {
|
||||
sharedExtent = getIntersection(sharedExtent, sourceExtent);
|
||||
}
|
||||
if (getWidth(sharedExtent) / resolution >= 0.5 &&
|
||||
getHeight(sharedExtent) / resolution >= 0.5) {
|
||||
// only include source tile if overlap is at least 1 pixel
|
||||
var sourceTileKey = sourceTileCoord.toString();
|
||||
var sourceTile = sourceTiles[sourceTileKey];
|
||||
const sourceTileKey = sourceTileCoord.toString();
|
||||
let sourceTile = sourceTiles[sourceTileKey];
|
||||
if (!sourceTile) {
|
||||
var tileUrl = tileUrlFunction(sourceTileCoord, pixelRatio, projection);
|
||||
const tileUrl = tileUrlFunction(sourceTileCoord, pixelRatio, projection);
|
||||
sourceTile = sourceTiles[sourceTileKey] = new tileClass(sourceTileCoord,
|
||||
tileUrl == undefined ? TileState.EMPTY : TileState.IDLE,
|
||||
tileUrl == undefined ? '' : tileUrl,
|
||||
format, tileLoadFunction);
|
||||
tileUrl == undefined ? TileState.EMPTY : TileState.IDLE,
|
||||
tileUrl == undefined ? '' : tileUrl,
|
||||
format, tileLoadFunction);
|
||||
this.sourceTileListenerKeys_.push(
|
||||
_ol_events_.listen(sourceTile, EventType.CHANGE, handleTileChange));
|
||||
_ol_events_.listen(sourceTile, EventType.CHANGE, handleTileChange));
|
||||
}
|
||||
sourceTile.consumers++;
|
||||
this.tileKeys.push(sourceTileKey);
|
||||
@@ -134,9 +134,9 @@ VectorImageTile.prototype.disposeInternal = function() {
|
||||
this.interimTile.dispose();
|
||||
}
|
||||
|
||||
for (var i = 0, ii = this.tileKeys.length; i < ii; ++i) {
|
||||
var sourceTileKey = this.tileKeys[i];
|
||||
var sourceTile = this.getTile(sourceTileKey);
|
||||
for (let i = 0, ii = this.tileKeys.length; i < ii; ++i) {
|
||||
const sourceTileKey = this.tileKeys[i];
|
||||
const sourceTile = this.getTile(sourceTileKey);
|
||||
sourceTile.consumers--;
|
||||
if (sourceTile.consumers == 0) {
|
||||
delete this.sourceTiles_[sourceTileKey];
|
||||
@@ -158,7 +158,7 @@ VectorImageTile.prototype.disposeInternal = function() {
|
||||
* @return {CanvasRenderingContext2D} The rendering context.
|
||||
*/
|
||||
VectorImageTile.prototype.getContext = function(layer) {
|
||||
var key = getUid(layer).toString();
|
||||
const key = getUid(layer).toString();
|
||||
if (!(key in this.context_)) {
|
||||
this.context_[key] = createCanvasContext2D();
|
||||
}
|
||||
@@ -182,7 +182,7 @@ VectorImageTile.prototype.getImage = function(layer) {
|
||||
* @return {ol.TileReplayState} The replay state.
|
||||
*/
|
||||
VectorImageTile.prototype.getReplayState = function(layer) {
|
||||
var key = getUid(layer).toString();
|
||||
const key = getUid(layer).toString();
|
||||
if (!(key in this.replayState_)) {
|
||||
this.replayState_[key] = {
|
||||
dirty: false,
|
||||
@@ -218,27 +218,27 @@ VectorImageTile.prototype.getTile = function(tileKey) {
|
||||
VectorImageTile.prototype.load = function() {
|
||||
// Source tiles with LOADED state - we just count them because once they are
|
||||
// loaded, we're no longer listening to state changes.
|
||||
var leftToLoad = 0;
|
||||
let leftToLoad = 0;
|
||||
// Source tiles with ERROR state - we track them because they can still have
|
||||
// an ERROR state after another load attempt.
|
||||
var errorSourceTiles = {};
|
||||
const errorSourceTiles = {};
|
||||
|
||||
if (this.state == TileState.IDLE) {
|
||||
this.setState(TileState.LOADING);
|
||||
}
|
||||
if (this.state == TileState.LOADING) {
|
||||
this.tileKeys.forEach(function(sourceTileKey) {
|
||||
var sourceTile = this.getTile(sourceTileKey);
|
||||
const sourceTile = this.getTile(sourceTileKey);
|
||||
if (sourceTile.state == TileState.IDLE) {
|
||||
sourceTile.setLoader(this.loader_);
|
||||
sourceTile.load();
|
||||
}
|
||||
if (sourceTile.state == TileState.LOADING) {
|
||||
var key = _ol_events_.listen(sourceTile, EventType.CHANGE, function(e) {
|
||||
var state = sourceTile.getState();
|
||||
const key = _ol_events_.listen(sourceTile, EventType.CHANGE, function(e) {
|
||||
const state = sourceTile.getState();
|
||||
if (state == TileState.LOADED ||
|
||||
state == TileState.ERROR) {
|
||||
var uid = getUid(sourceTile);
|
||||
const uid = getUid(sourceTile);
|
||||
if (state == TileState.ERROR) {
|
||||
errorSourceTiles[uid] = true;
|
||||
} else {
|
||||
@@ -265,10 +265,10 @@ VectorImageTile.prototype.load = function() {
|
||||
* @private
|
||||
*/
|
||||
VectorImageTile.prototype.finishLoading_ = function() {
|
||||
var loaded = this.tileKeys.length;
|
||||
var empty = 0;
|
||||
for (var i = loaded - 1; i >= 0; --i) {
|
||||
var state = this.getTile(this.tileKeys[i]).getState();
|
||||
let loaded = this.tileKeys.length;
|
||||
let empty = 0;
|
||||
for (let i = loaded - 1; i >= 0; --i) {
|
||||
const state = this.getTile(this.tileKeys[i]).getState();
|
||||
if (state != TileState.LOADED) {
|
||||
--loaded;
|
||||
}
|
||||
@@ -293,6 +293,6 @@ export default VectorImageTile;
|
||||
* @param {string} url URL.
|
||||
*/
|
||||
export function defaultLoadFunction(tile, url) {
|
||||
var loader = loadFeaturesXhr(url, tile.getFormat(), tile.onLoad.bind(tile), tile.onError.bind(tile));
|
||||
const loader = loadFeaturesXhr(url, tile.getFormat(), tile.onLoad.bind(tile), tile.onError.bind(tile));
|
||||
tile.setLoader(loader);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import TileState from './TileState.js';
|
||||
* @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function.
|
||||
* @param {olx.TileOptions=} opt_options Tile options.
|
||||
*/
|
||||
var VectorTile = function(tileCoord, state, src, format, tileLoadFunction, opt_options) {
|
||||
const VectorTile = function(tileCoord, state, src, format, tileLoadFunction, opt_options) {
|
||||
|
||||
Tile.call(this, tileCoord, state, opt_options);
|
||||
|
||||
@@ -81,7 +81,7 @@ inherits(VectorTile, Tile);
|
||||
* @const
|
||||
* @type {ol.Extent}
|
||||
*/
|
||||
var DEFAULT_EXTENT = [0, 0, 4096, 4096];
|
||||
const DEFAULT_EXTENT = [0, 0, 4096, 4096];
|
||||
|
||||
|
||||
/**
|
||||
|
||||
+154
-154
@@ -26,7 +26,7 @@ import Units from './proj/Units.js';
|
||||
/**
|
||||
* @type {number} Default min zoom level for the map view.
|
||||
*/
|
||||
var DEFAULT_MIN_ZOOM = 0;
|
||||
const DEFAULT_MIN_ZOOM = 0;
|
||||
|
||||
|
||||
/**
|
||||
@@ -86,10 +86,10 @@ var DEFAULT_MIN_ZOOM = 0;
|
||||
* @param {olx.ViewOptions=} opt_options View options.
|
||||
* @api
|
||||
*/
|
||||
var View = function(opt_options) {
|
||||
const View = function(opt_options) {
|
||||
BaseObject.call(this);
|
||||
|
||||
var options = _ol_obj_.assign({}, opt_options);
|
||||
const options = _ol_obj_.assign({}, opt_options);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -133,12 +133,12 @@ View.prototype.applyOptions_ = function(options) {
|
||||
/**
|
||||
* @type {Object.<string, *>}
|
||||
*/
|
||||
var properties = {};
|
||||
const properties = {};
|
||||
properties[ViewProperty.CENTER] = options.center !== undefined ?
|
||||
options.center : null;
|
||||
|
||||
var resolutionConstraintInfo = View.createResolutionConstraint_(
|
||||
options);
|
||||
const resolutionConstraintInfo = View.createResolutionConstraint_(
|
||||
options);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -170,9 +170,9 @@ View.prototype.applyOptions_ = function(options) {
|
||||
*/
|
||||
this.minZoom_ = resolutionConstraintInfo.minZoom;
|
||||
|
||||
var centerConstraint = View.createCenterConstraint_(options);
|
||||
var resolutionConstraint = resolutionConstraintInfo.constraint;
|
||||
var rotationConstraint = View.createRotationConstraint_(options);
|
||||
const centerConstraint = View.createCenterConstraint_(options);
|
||||
const resolutionConstraint = resolutionConstraintInfo.constraint;
|
||||
const rotationConstraint = View.createRotationConstraint_(options);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -188,12 +188,12 @@ View.prototype.applyOptions_ = function(options) {
|
||||
properties[ViewProperty.RESOLUTION] = options.resolution;
|
||||
} else if (options.zoom !== undefined) {
|
||||
properties[ViewProperty.RESOLUTION] = this.constrainResolution(
|
||||
this.maxResolution_, options.zoom - this.minZoom_);
|
||||
this.maxResolution_, options.zoom - this.minZoom_);
|
||||
|
||||
if (this.resolutions_) { // in case map zoom is out of min/max zoom range
|
||||
properties[ViewProperty.RESOLUTION] = clamp(
|
||||
Number(this.getResolution() || properties[ViewProperty.RESOLUTION]),
|
||||
this.minResolution_, this.maxResolution_);
|
||||
Number(this.getResolution() || properties[ViewProperty.RESOLUTION]),
|
||||
this.minResolution_, this.maxResolution_);
|
||||
}
|
||||
}
|
||||
properties[ViewProperty.ROTATION] =
|
||||
@@ -217,7 +217,7 @@ View.prototype.applyOptions_ = function(options) {
|
||||
* @return {olx.ViewOptions} New options updated with the current view state.
|
||||
*/
|
||||
View.prototype.getUpdatedOptions_ = function(newOptions) {
|
||||
var options = _ol_obj_.assign({}, this.options_);
|
||||
const options = _ol_obj_.assign({}, this.options_);
|
||||
|
||||
// preserve resolution (or zoom)
|
||||
if (options.resolution !== undefined) {
|
||||
@@ -270,15 +270,15 @@ View.prototype.getUpdatedOptions_ = function(newOptions) {
|
||||
* @api
|
||||
*/
|
||||
View.prototype.animate = function(var_args) {
|
||||
var animationCount = arguments.length;
|
||||
var callback;
|
||||
let animationCount = arguments.length;
|
||||
let callback;
|
||||
if (animationCount > 1 && typeof arguments[animationCount - 1] === 'function') {
|
||||
callback = arguments[animationCount - 1];
|
||||
--animationCount;
|
||||
}
|
||||
if (!this.isDef()) {
|
||||
// if view properties are not yet set, shortcut to the final state
|
||||
var state = arguments[animationCount - 1];
|
||||
const state = arguments[animationCount - 1];
|
||||
if (state.center) {
|
||||
this.setCenter(state.center);
|
||||
}
|
||||
@@ -293,15 +293,15 @@ View.prototype.animate = function(var_args) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
var start = Date.now();
|
||||
var center = this.getCenter().slice();
|
||||
var resolution = this.getResolution();
|
||||
var rotation = this.getRotation();
|
||||
var series = [];
|
||||
for (var i = 0; i < animationCount; ++i) {
|
||||
var options = /** @type {olx.AnimationOptions} */ (arguments[i]);
|
||||
let start = Date.now();
|
||||
let center = this.getCenter().slice();
|
||||
let resolution = this.getResolution();
|
||||
let rotation = this.getRotation();
|
||||
const series = [];
|
||||
for (let i = 0; i < animationCount; ++i) {
|
||||
const options = /** @type {olx.AnimationOptions} */ (arguments[i]);
|
||||
|
||||
var animation = /** @type {ol.ViewAnimation} */ ({
|
||||
const animation = /** @type {ol.ViewAnimation} */ ({
|
||||
start: start,
|
||||
complete: false,
|
||||
anchor: options.anchor,
|
||||
@@ -318,7 +318,7 @@ View.prototype.animate = function(var_args) {
|
||||
if (options.zoom !== undefined) {
|
||||
animation.sourceResolution = resolution;
|
||||
animation.targetResolution = this.constrainResolution(
|
||||
this.maxResolution_, options.zoom - this.minZoom_, 0);
|
||||
this.maxResolution_, options.zoom - this.minZoom_, 0);
|
||||
resolution = animation.targetResolution;
|
||||
} else if (options.resolution) {
|
||||
animation.sourceResolution = resolution;
|
||||
@@ -328,7 +328,7 @@ View.prototype.animate = function(var_args) {
|
||||
|
||||
if (options.rotation !== undefined) {
|
||||
animation.sourceRotation = rotation;
|
||||
var delta = modulo(options.rotation - rotation + Math.PI, 2 * Math.PI) - Math.PI;
|
||||
const delta = modulo(options.rotation - rotation + Math.PI, 2 * Math.PI) - Math.PI;
|
||||
animation.targetRotation = rotation + delta;
|
||||
rotation = animation.targetRotation;
|
||||
}
|
||||
@@ -376,8 +376,8 @@ View.prototype.getInteracting = function() {
|
||||
*/
|
||||
View.prototype.cancelAnimations = function() {
|
||||
this.setHint(ViewHint.ANIMATING, -this.hints_[ViewHint.ANIMATING]);
|
||||
for (var i = 0, ii = this.animations_.length; i < ii; ++i) {
|
||||
var series = this.animations_[i];
|
||||
for (let i = 0, ii = this.animations_.length; i < ii; ++i) {
|
||||
const series = this.animations_[i];
|
||||
if (series[0].callback) {
|
||||
series[0].callback(false);
|
||||
}
|
||||
@@ -396,51 +396,51 @@ View.prototype.updateAnimations_ = function() {
|
||||
if (!this.getAnimating()) {
|
||||
return;
|
||||
}
|
||||
var now = Date.now();
|
||||
var more = false;
|
||||
for (var i = this.animations_.length - 1; i >= 0; --i) {
|
||||
var series = this.animations_[i];
|
||||
var seriesComplete = true;
|
||||
for (var j = 0, jj = series.length; j < jj; ++j) {
|
||||
var animation = series[j];
|
||||
const now = Date.now();
|
||||
let more = false;
|
||||
for (let i = this.animations_.length - 1; i >= 0; --i) {
|
||||
const series = this.animations_[i];
|
||||
let seriesComplete = true;
|
||||
for (let j = 0, jj = series.length; j < jj; ++j) {
|
||||
const animation = series[j];
|
||||
if (animation.complete) {
|
||||
continue;
|
||||
}
|
||||
var elapsed = now - animation.start;
|
||||
var fraction = animation.duration > 0 ? elapsed / animation.duration : 1;
|
||||
const elapsed = now - animation.start;
|
||||
let fraction = animation.duration > 0 ? elapsed / animation.duration : 1;
|
||||
if (fraction >= 1) {
|
||||
animation.complete = true;
|
||||
fraction = 1;
|
||||
} else {
|
||||
seriesComplete = false;
|
||||
}
|
||||
var progress = animation.easing(fraction);
|
||||
const progress = animation.easing(fraction);
|
||||
if (animation.sourceCenter) {
|
||||
var x0 = animation.sourceCenter[0];
|
||||
var y0 = animation.sourceCenter[1];
|
||||
var x1 = animation.targetCenter[0];
|
||||
var y1 = animation.targetCenter[1];
|
||||
var x = x0 + progress * (x1 - x0);
|
||||
var y = y0 + progress * (y1 - y0);
|
||||
const x0 = animation.sourceCenter[0];
|
||||
const y0 = animation.sourceCenter[1];
|
||||
const x1 = animation.targetCenter[0];
|
||||
const y1 = animation.targetCenter[1];
|
||||
const x = x0 + progress * (x1 - x0);
|
||||
const y = y0 + progress * (y1 - y0);
|
||||
this.set(ViewProperty.CENTER, [x, y]);
|
||||
}
|
||||
if (animation.sourceResolution && animation.targetResolution) {
|
||||
var resolution = progress === 1 ?
|
||||
const resolution = progress === 1 ?
|
||||
animation.targetResolution :
|
||||
animation.sourceResolution + progress * (animation.targetResolution - animation.sourceResolution);
|
||||
if (animation.anchor) {
|
||||
this.set(ViewProperty.CENTER,
|
||||
this.calculateCenterZoom(resolution, animation.anchor));
|
||||
this.calculateCenterZoom(resolution, animation.anchor));
|
||||
}
|
||||
this.set(ViewProperty.RESOLUTION, resolution);
|
||||
}
|
||||
if (animation.sourceRotation !== undefined && animation.targetRotation !== undefined) {
|
||||
var rotation = progress === 1 ?
|
||||
const rotation = progress === 1 ?
|
||||
modulo(animation.targetRotation + Math.PI, 2 * Math.PI) - Math.PI :
|
||||
animation.sourceRotation + progress * (animation.targetRotation - animation.sourceRotation);
|
||||
if (animation.anchor) {
|
||||
this.set(ViewProperty.CENTER,
|
||||
this.calculateCenterRotate(rotation, animation.anchor));
|
||||
this.calculateCenterRotate(rotation, animation.anchor));
|
||||
}
|
||||
this.set(ViewProperty.ROTATION, rotation);
|
||||
}
|
||||
@@ -452,7 +452,7 @@ View.prototype.updateAnimations_ = function() {
|
||||
if (seriesComplete) {
|
||||
this.animations_[i] = null;
|
||||
this.setHint(ViewHint.ANIMATING, -1);
|
||||
var callback = series[0].callback;
|
||||
const callback = series[0].callback;
|
||||
if (callback) {
|
||||
callback(true);
|
||||
}
|
||||
@@ -471,8 +471,8 @@ View.prototype.updateAnimations_ = function() {
|
||||
* @return {ol.Coordinate|undefined} Center for rotation and anchor.
|
||||
*/
|
||||
View.prototype.calculateCenterRotate = function(rotation, anchor) {
|
||||
var center;
|
||||
var currentCenter = this.getCenter();
|
||||
let center;
|
||||
const currentCenter = this.getCenter();
|
||||
if (currentCenter !== undefined) {
|
||||
center = [currentCenter[0] - anchor[0], currentCenter[1] - anchor[1]];
|
||||
_ol_coordinate_.rotate(center, rotation - this.getRotation());
|
||||
@@ -488,13 +488,13 @@ View.prototype.calculateCenterRotate = function(rotation, anchor) {
|
||||
* @return {ol.Coordinate|undefined} Center for resolution and anchor.
|
||||
*/
|
||||
View.prototype.calculateCenterZoom = function(resolution, anchor) {
|
||||
var center;
|
||||
var currentCenter = this.getCenter();
|
||||
var currentResolution = this.getResolution();
|
||||
let center;
|
||||
const currentCenter = this.getCenter();
|
||||
const currentResolution = this.getResolution();
|
||||
if (currentCenter !== undefined && currentResolution !== undefined) {
|
||||
var x = anchor[0] -
|
||||
const x = anchor[0] -
|
||||
resolution * (anchor[0] - currentCenter[0]) / currentResolution;
|
||||
var y = anchor[1] -
|
||||
const y = anchor[1] -
|
||||
resolution * (anchor[1] - currentCenter[1]) / currentResolution;
|
||||
center = [x, y];
|
||||
}
|
||||
@@ -507,11 +507,11 @@ View.prototype.calculateCenterZoom = function(resolution, anchor) {
|
||||
* @return {ol.Size} Viewport size or `[100, 100]` when no viewport is found.
|
||||
*/
|
||||
View.prototype.getSizeFromViewport_ = function() {
|
||||
var size = [100, 100];
|
||||
var selector = '.ol-viewport[data-view="' + getUid(this) + '"]';
|
||||
var element = document.querySelector(selector);
|
||||
const size = [100, 100];
|
||||
const selector = '.ol-viewport[data-view="' + getUid(this) + '"]';
|
||||
const element = document.querySelector(selector);
|
||||
if (element) {
|
||||
var metrics = getComputedStyle(element);
|
||||
const metrics = getComputedStyle(element);
|
||||
size[0] = parseInt(metrics.width, 10);
|
||||
size[1] = parseInt(metrics.height, 10);
|
||||
}
|
||||
@@ -539,9 +539,9 @@ View.prototype.constrainCenter = function(center) {
|
||||
* @api
|
||||
*/
|
||||
View.prototype.constrainResolution = function(
|
||||
resolution, opt_delta, opt_direction) {
|
||||
var delta = opt_delta || 0;
|
||||
var direction = opt_direction || 0;
|
||||
resolution, opt_delta, opt_direction) {
|
||||
const delta = opt_delta || 0;
|
||||
const direction = opt_direction || 0;
|
||||
return this.constraints_.resolution(resolution, delta, direction);
|
||||
};
|
||||
|
||||
@@ -554,7 +554,7 @@ View.prototype.constrainResolution = function(
|
||||
* @api
|
||||
*/
|
||||
View.prototype.constrainRotation = function(rotation, opt_delta) {
|
||||
var delta = opt_delta || 0;
|
||||
const delta = opt_delta || 0;
|
||||
return this.constraints_.rotation(rotation, delta);
|
||||
};
|
||||
|
||||
@@ -606,12 +606,12 @@ View.prototype.getHints = function(opt_hints) {
|
||||
* @api
|
||||
*/
|
||||
View.prototype.calculateExtent = function(opt_size) {
|
||||
var size = opt_size || this.getSizeFromViewport_();
|
||||
var center = /** @type {!ol.Coordinate} */ (this.getCenter());
|
||||
const size = opt_size || this.getSizeFromViewport_();
|
||||
const center = /** @type {!ol.Coordinate} */ (this.getCenter());
|
||||
assert(center, 1); // The view center is not defined
|
||||
var resolution = /** @type {!number} */ (this.getResolution());
|
||||
const resolution = /** @type {!number} */ (this.getResolution());
|
||||
assert(resolution !== undefined, 2); // The view resolution is not defined
|
||||
var rotation = /** @type {!number} */ (this.getRotation());
|
||||
const rotation = /** @type {!number} */ (this.getRotation());
|
||||
assert(rotation !== undefined, 3); // The view rotation is not defined
|
||||
|
||||
return getForViewAndSize(center, resolution, rotation, size);
|
||||
@@ -721,9 +721,9 @@ View.prototype.getResolutions = function() {
|
||||
* @api
|
||||
*/
|
||||
View.prototype.getResolutionForExtent = function(extent, opt_size) {
|
||||
var size = opt_size || this.getSizeFromViewport_();
|
||||
var xResolution = getWidth(extent) / size[0];
|
||||
var yResolution = getHeight(extent) / size[1];
|
||||
const size = opt_size || this.getSizeFromViewport_();
|
||||
const xResolution = getWidth(extent) / size[0];
|
||||
const yResolution = getHeight(extent) / size[1];
|
||||
return Math.max(xResolution, yResolution);
|
||||
};
|
||||
|
||||
@@ -735,17 +735,17 @@ View.prototype.getResolutionForExtent = function(extent, opt_size) {
|
||||
* @return {function(number): number} Resolution for value function.
|
||||
*/
|
||||
View.prototype.getResolutionForValueFunction = function(opt_power) {
|
||||
var power = opt_power || 2;
|
||||
var maxResolution = this.maxResolution_;
|
||||
var minResolution = this.minResolution_;
|
||||
var max = Math.log(maxResolution / minResolution) / Math.log(power);
|
||||
const power = opt_power || 2;
|
||||
const maxResolution = this.maxResolution_;
|
||||
const minResolution = this.minResolution_;
|
||||
const max = Math.log(maxResolution / minResolution) / Math.log(power);
|
||||
return (
|
||||
/**
|
||||
* @param {number} value Value.
|
||||
* @return {number} Resolution.
|
||||
*/
|
||||
function(value) {
|
||||
var resolution = maxResolution / Math.pow(power, value * max);
|
||||
const resolution = maxResolution / Math.pow(power, value * max);
|
||||
return resolution;
|
||||
});
|
||||
};
|
||||
@@ -771,17 +771,17 @@ View.prototype.getRotation = function() {
|
||||
* @return {function(number): number} Value for resolution function.
|
||||
*/
|
||||
View.prototype.getValueForResolutionFunction = function(opt_power) {
|
||||
var power = opt_power || 2;
|
||||
var maxResolution = this.maxResolution_;
|
||||
var minResolution = this.minResolution_;
|
||||
var max = Math.log(maxResolution / minResolution) / Math.log(power);
|
||||
const power = opt_power || 2;
|
||||
const maxResolution = this.maxResolution_;
|
||||
const minResolution = this.minResolution_;
|
||||
const max = Math.log(maxResolution / minResolution) / Math.log(power);
|
||||
return (
|
||||
/**
|
||||
* @param {number} resolution Resolution.
|
||||
* @return {number} Value.
|
||||
*/
|
||||
function(resolution) {
|
||||
var value =
|
||||
const value =
|
||||
(Math.log(maxResolution / resolution) / Math.log(power)) / max;
|
||||
return value;
|
||||
});
|
||||
@@ -792,10 +792,10 @@ View.prototype.getValueForResolutionFunction = function(opt_power) {
|
||||
* @return {olx.ViewState} View state.
|
||||
*/
|
||||
View.prototype.getState = function() {
|
||||
var center = /** @type {ol.Coordinate} */ (this.getCenter());
|
||||
var projection = this.getProjection();
|
||||
var resolution = /** @type {number} */ (this.getResolution());
|
||||
var rotation = this.getRotation();
|
||||
const center = /** @type {ol.Coordinate} */ (this.getCenter());
|
||||
const projection = this.getProjection();
|
||||
const resolution = /** @type {number} */ (this.getResolution());
|
||||
const rotation = this.getRotation();
|
||||
return /** @type {olx.ViewState} */ ({
|
||||
center: center.slice(),
|
||||
projection: projection !== undefined ? projection : null,
|
||||
@@ -814,8 +814,8 @@ View.prototype.getState = function() {
|
||||
* @api
|
||||
*/
|
||||
View.prototype.getZoom = function() {
|
||||
var zoom;
|
||||
var resolution = this.getResolution();
|
||||
let zoom;
|
||||
const resolution = this.getResolution();
|
||||
if (resolution !== undefined) {
|
||||
zoom = this.getZoomForResolution(resolution);
|
||||
}
|
||||
@@ -830,10 +830,10 @@ View.prototype.getZoom = function() {
|
||||
* @api
|
||||
*/
|
||||
View.prototype.getZoomForResolution = function(resolution) {
|
||||
var offset = this.minZoom_ || 0;
|
||||
var max, zoomFactor;
|
||||
let offset = this.minZoom_ || 0;
|
||||
let max, zoomFactor;
|
||||
if (this.resolutions_) {
|
||||
var nearest = linearFindNearest(this.resolutions_, resolution, 1);
|
||||
const nearest = linearFindNearest(this.resolutions_, resolution, 1);
|
||||
offset = nearest;
|
||||
max = this.resolutions_[nearest];
|
||||
if (nearest == this.resolutions_.length - 1) {
|
||||
@@ -857,7 +857,7 @@ View.prototype.getZoomForResolution = function(resolution) {
|
||||
*/
|
||||
View.prototype.getResolutionForZoom = function(zoom) {
|
||||
return /** @type {number} */ (this.constrainResolution(
|
||||
this.maxResolution_, zoom - this.minZoom_, 0));
|
||||
this.maxResolution_, zoom - this.minZoom_, 0));
|
||||
};
|
||||
|
||||
|
||||
@@ -872,18 +872,18 @@ View.prototype.getResolutionForZoom = function(zoom) {
|
||||
* @api
|
||||
*/
|
||||
View.prototype.fit = function(geometryOrExtent, opt_options) {
|
||||
var options = opt_options || {};
|
||||
var size = options.size;
|
||||
const options = opt_options || {};
|
||||
let size = options.size;
|
||||
if (!size) {
|
||||
size = this.getSizeFromViewport_();
|
||||
}
|
||||
/** @type {ol.geom.SimpleGeometry} */
|
||||
var geometry;
|
||||
let geometry;
|
||||
if (!(geometryOrExtent instanceof SimpleGeometry)) {
|
||||
assert(Array.isArray(geometryOrExtent),
|
||||
24); // Invalid extent or geometry provided as `geometry`
|
||||
24); // Invalid extent or geometry provided as `geometry`
|
||||
assert(!isEmpty(geometryOrExtent),
|
||||
25); // Cannot fit empty extent provided as `geometry`
|
||||
25); // Cannot fit empty extent provided as `geometry`
|
||||
geometry = polygonFromExtent(geometryOrExtent);
|
||||
} else if (geometryOrExtent.getType() === GeometryType.CIRCLE) {
|
||||
geometryOrExtent = geometryOrExtent.getExtent();
|
||||
@@ -893,33 +893,33 @@ View.prototype.fit = function(geometryOrExtent, opt_options) {
|
||||
geometry = geometryOrExtent;
|
||||
}
|
||||
|
||||
var padding = options.padding !== undefined ? options.padding : [0, 0, 0, 0];
|
||||
var constrainResolution = options.constrainResolution !== undefined ?
|
||||
const padding = options.padding !== undefined ? options.padding : [0, 0, 0, 0];
|
||||
const constrainResolution = options.constrainResolution !== undefined ?
|
||||
options.constrainResolution : true;
|
||||
var nearest = options.nearest !== undefined ? options.nearest : false;
|
||||
var minResolution;
|
||||
const nearest = options.nearest !== undefined ? options.nearest : false;
|
||||
let minResolution;
|
||||
if (options.minResolution !== undefined) {
|
||||
minResolution = options.minResolution;
|
||||
} else if (options.maxZoom !== undefined) {
|
||||
minResolution = this.constrainResolution(
|
||||
this.maxResolution_, options.maxZoom - this.minZoom_, 0);
|
||||
this.maxResolution_, options.maxZoom - this.minZoom_, 0);
|
||||
} else {
|
||||
minResolution = 0;
|
||||
}
|
||||
var coords = geometry.getFlatCoordinates();
|
||||
const coords = geometry.getFlatCoordinates();
|
||||
|
||||
// calculate rotated extent
|
||||
var rotation = this.getRotation();
|
||||
var cosAngle = Math.cos(-rotation);
|
||||
var sinAngle = Math.sin(-rotation);
|
||||
var minRotX = +Infinity;
|
||||
var minRotY = +Infinity;
|
||||
var maxRotX = -Infinity;
|
||||
var maxRotY = -Infinity;
|
||||
var stride = geometry.getStride();
|
||||
for (var i = 0, ii = coords.length; i < ii; i += stride) {
|
||||
var rotX = coords[i] * cosAngle - coords[i + 1] * sinAngle;
|
||||
var rotY = coords[i] * sinAngle + coords[i + 1] * cosAngle;
|
||||
const rotation = this.getRotation();
|
||||
const cosAngle = Math.cos(-rotation);
|
||||
let sinAngle = Math.sin(-rotation);
|
||||
let minRotX = +Infinity;
|
||||
let minRotY = +Infinity;
|
||||
let maxRotX = -Infinity;
|
||||
let maxRotY = -Infinity;
|
||||
const stride = geometry.getStride();
|
||||
for (let i = 0, ii = coords.length; i < ii; i += stride) {
|
||||
const rotX = coords[i] * cosAngle - coords[i + 1] * sinAngle;
|
||||
const rotY = coords[i] * sinAngle + coords[i + 1] * cosAngle;
|
||||
minRotX = Math.min(minRotX, rotX);
|
||||
minRotY = Math.min(minRotY, rotY);
|
||||
maxRotX = Math.max(maxRotX, rotX);
|
||||
@@ -927,30 +927,30 @@ View.prototype.fit = function(geometryOrExtent, opt_options) {
|
||||
}
|
||||
|
||||
// calculate resolution
|
||||
var resolution = this.getResolutionForExtent(
|
||||
[minRotX, minRotY, maxRotX, maxRotY],
|
||||
[size[0] - padding[1] - padding[3], size[1] - padding[0] - padding[2]]);
|
||||
let resolution = this.getResolutionForExtent(
|
||||
[minRotX, minRotY, maxRotX, maxRotY],
|
||||
[size[0] - padding[1] - padding[3], size[1] - padding[0] - padding[2]]);
|
||||
resolution = isNaN(resolution) ? minResolution :
|
||||
Math.max(resolution, minResolution);
|
||||
if (constrainResolution) {
|
||||
var constrainedResolution = this.constrainResolution(resolution, 0, 0);
|
||||
let constrainedResolution = this.constrainResolution(resolution, 0, 0);
|
||||
if (!nearest && constrainedResolution < resolution) {
|
||||
constrainedResolution = this.constrainResolution(
|
||||
constrainedResolution, -1, 0);
|
||||
constrainedResolution, -1, 0);
|
||||
}
|
||||
resolution = constrainedResolution;
|
||||
}
|
||||
|
||||
// calculate center
|
||||
sinAngle = -sinAngle; // go back to original rotation
|
||||
var centerRotX = (minRotX + maxRotX) / 2;
|
||||
var centerRotY = (minRotY + maxRotY) / 2;
|
||||
let centerRotX = (minRotX + maxRotX) / 2;
|
||||
let centerRotY = (minRotY + maxRotY) / 2;
|
||||
centerRotX += (padding[1] - padding[3]) / 2 * resolution;
|
||||
centerRotY += (padding[0] - padding[2]) / 2 * resolution;
|
||||
var centerX = centerRotX * cosAngle - centerRotY * sinAngle;
|
||||
var centerY = centerRotY * cosAngle + centerRotX * sinAngle;
|
||||
var center = [centerX, centerY];
|
||||
var callback = options.callback ? options.callback : nullFunction;
|
||||
const centerX = centerRotX * cosAngle - centerRotY * sinAngle;
|
||||
const centerY = centerRotY * cosAngle + centerRotX * sinAngle;
|
||||
const center = [centerX, centerY];
|
||||
const callback = options.callback ? options.callback : nullFunction;
|
||||
|
||||
if (options.duration !== undefined) {
|
||||
this.animate({
|
||||
@@ -976,19 +976,19 @@ View.prototype.fit = function(geometryOrExtent, opt_options) {
|
||||
*/
|
||||
View.prototype.centerOn = function(coordinate, size, position) {
|
||||
// calculate rotated position
|
||||
var rotation = this.getRotation();
|
||||
var cosAngle = Math.cos(-rotation);
|
||||
var sinAngle = Math.sin(-rotation);
|
||||
var rotX = coordinate[0] * cosAngle - coordinate[1] * sinAngle;
|
||||
var rotY = coordinate[1] * cosAngle + coordinate[0] * sinAngle;
|
||||
var resolution = this.getResolution();
|
||||
const rotation = this.getRotation();
|
||||
const cosAngle = Math.cos(-rotation);
|
||||
let sinAngle = Math.sin(-rotation);
|
||||
let rotX = coordinate[0] * cosAngle - coordinate[1] * sinAngle;
|
||||
let rotY = coordinate[1] * cosAngle + coordinate[0] * sinAngle;
|
||||
const resolution = this.getResolution();
|
||||
rotX += (size[0] / 2 - position[0]) * resolution;
|
||||
rotY += (position[1] - size[1] / 2) * resolution;
|
||||
|
||||
// go back to original angle
|
||||
sinAngle = -sinAngle; // go back to original rotation
|
||||
var centerX = rotX * cosAngle - rotY * sinAngle;
|
||||
var centerY = rotY * cosAngle + rotX * sinAngle;
|
||||
const centerX = rotX * cosAngle - rotY * sinAngle;
|
||||
const centerY = rotY * cosAngle + rotX * sinAngle;
|
||||
|
||||
this.setCenter([centerX, centerY]);
|
||||
};
|
||||
@@ -1010,7 +1010,7 @@ View.prototype.isDef = function() {
|
||||
*/
|
||||
View.prototype.rotate = function(rotation, opt_anchor) {
|
||||
if (opt_anchor !== undefined) {
|
||||
var center = this.calculateCenterRotate(rotation, opt_anchor);
|
||||
const center = this.calculateCenterRotate(rotation, opt_anchor);
|
||||
this.setCenter(center);
|
||||
}
|
||||
this.setRotation(rotation);
|
||||
@@ -1102,46 +1102,46 @@ View.createCenterConstraint_ = function(options) {
|
||||
* minResolution: number, zoomFactor: number}} The constraint.
|
||||
*/
|
||||
View.createResolutionConstraint_ = function(options) {
|
||||
var resolutionConstraint;
|
||||
var maxResolution;
|
||||
var minResolution;
|
||||
let resolutionConstraint;
|
||||
let maxResolution;
|
||||
let minResolution;
|
||||
|
||||
// TODO: move these to be ol constants
|
||||
// see https://github.com/openlayers/openlayers/issues/2076
|
||||
var defaultMaxZoom = 28;
|
||||
var defaultZoomFactor = 2;
|
||||
const defaultMaxZoom = 28;
|
||||
const defaultZoomFactor = 2;
|
||||
|
||||
var minZoom = options.minZoom !== undefined ?
|
||||
let minZoom = options.minZoom !== undefined ?
|
||||
options.minZoom : DEFAULT_MIN_ZOOM;
|
||||
|
||||
var maxZoom = options.maxZoom !== undefined ?
|
||||
let maxZoom = options.maxZoom !== undefined ?
|
||||
options.maxZoom : defaultMaxZoom;
|
||||
|
||||
var zoomFactor = options.zoomFactor !== undefined ?
|
||||
const zoomFactor = options.zoomFactor !== undefined ?
|
||||
options.zoomFactor : defaultZoomFactor;
|
||||
|
||||
if (options.resolutions !== undefined) {
|
||||
var resolutions = options.resolutions;
|
||||
const resolutions = options.resolutions;
|
||||
maxResolution = resolutions[minZoom];
|
||||
minResolution = resolutions[maxZoom] !== undefined ?
|
||||
resolutions[maxZoom] : resolutions[resolutions.length - 1];
|
||||
resolutionConstraint = ResolutionConstraint.createSnapToResolutions(
|
||||
resolutions);
|
||||
resolutions);
|
||||
} else {
|
||||
// calculate the default min and max resolution
|
||||
var projection = createProjection(options.projection, 'EPSG:3857');
|
||||
var extent = projection.getExtent();
|
||||
var size = !extent ?
|
||||
const projection = createProjection(options.projection, 'EPSG:3857');
|
||||
const extent = projection.getExtent();
|
||||
const size = !extent ?
|
||||
// use an extent that can fit the whole world if need be
|
||||
360 * METERS_PER_UNIT[Units.DEGREES] /
|
||||
projection.getMetersPerUnit() :
|
||||
Math.max(getWidth(extent), getHeight(extent));
|
||||
|
||||
var defaultMaxResolution = size / DEFAULT_TILE_SIZE / Math.pow(
|
||||
defaultZoomFactor, DEFAULT_MIN_ZOOM);
|
||||
const defaultMaxResolution = size / DEFAULT_TILE_SIZE / Math.pow(
|
||||
defaultZoomFactor, DEFAULT_MIN_ZOOM);
|
||||
|
||||
var defaultMinResolution = defaultMaxResolution / Math.pow(
|
||||
defaultZoomFactor, defaultMaxZoom - DEFAULT_MIN_ZOOM);
|
||||
const defaultMinResolution = defaultMaxResolution / Math.pow(
|
||||
defaultZoomFactor, defaultMaxZoom - DEFAULT_MIN_ZOOM);
|
||||
|
||||
// user provided maxResolution takes precedence
|
||||
maxResolution = options.maxResolution;
|
||||
@@ -1167,11 +1167,11 @@ View.createResolutionConstraint_ = function(options) {
|
||||
|
||||
// given discrete zoom levels, minResolution may be different than provided
|
||||
maxZoom = minZoom + Math.floor(
|
||||
Math.log(maxResolution / minResolution) / Math.log(zoomFactor));
|
||||
Math.log(maxResolution / minResolution) / Math.log(zoomFactor));
|
||||
minResolution = maxResolution / Math.pow(zoomFactor, maxZoom - minZoom);
|
||||
|
||||
resolutionConstraint = ResolutionConstraint.createSnapToPower(
|
||||
zoomFactor, maxResolution, maxZoom - minZoom);
|
||||
zoomFactor, maxResolution, maxZoom - minZoom);
|
||||
}
|
||||
return {constraint: resolutionConstraint, maxResolution: maxResolution,
|
||||
minResolution: minResolution, minZoom: minZoom, zoomFactor: zoomFactor};
|
||||
@@ -1184,10 +1184,10 @@ View.createResolutionConstraint_ = function(options) {
|
||||
* @return {ol.RotationConstraintType} Rotation constraint.
|
||||
*/
|
||||
View.createRotationConstraint_ = function(options) {
|
||||
var enableRotation = options.enableRotation !== undefined ?
|
||||
const enableRotation = options.enableRotation !== undefined ?
|
||||
options.enableRotation : true;
|
||||
if (enableRotation) {
|
||||
var constrainRotation = options.constrainRotation;
|
||||
const constrainRotation = options.constrainRotation;
|
||||
if (constrainRotation === undefined || constrainRotation === true) {
|
||||
return RotationConstraint.createSnapToZero();
|
||||
} else if (constrainRotation === false) {
|
||||
|
||||
+25
-25
@@ -13,11 +13,11 @@
|
||||
* @return {number} The index of the item if found, -1 if not.
|
||||
*/
|
||||
export function binarySearch(haystack, needle, opt_comparator) {
|
||||
var mid, cmp;
|
||||
var comparator = opt_comparator || numberSafeCompareFunction;
|
||||
var low = 0;
|
||||
var high = haystack.length;
|
||||
var found = false;
|
||||
let mid, cmp;
|
||||
const comparator = opt_comparator || numberSafeCompareFunction;
|
||||
let low = 0;
|
||||
let high = haystack.length;
|
||||
let found = false;
|
||||
|
||||
while (low < high) {
|
||||
/* Note that "(low + high) >>> 1" may overflow, and results in a typecast
|
||||
@@ -71,13 +71,13 @@ export function includes(arr, obj) {
|
||||
* @return {number} Index.
|
||||
*/
|
||||
export function linearFindNearest(arr, target, direction) {
|
||||
var n = arr.length;
|
||||
const n = arr.length;
|
||||
if (arr[0] <= target) {
|
||||
return 0;
|
||||
} else if (target <= arr[n - 1]) {
|
||||
return n - 1;
|
||||
} else {
|
||||
var i;
|
||||
let i;
|
||||
if (direction > 0) {
|
||||
for (i = 1; i < n; ++i) {
|
||||
if (arr[i] < target) {
|
||||
@@ -115,7 +115,7 @@ export function linearFindNearest(arr, target, direction) {
|
||||
*/
|
||||
export function reverseSubArray(arr, begin, end) {
|
||||
while (begin < end) {
|
||||
var tmp = arr[begin];
|
||||
const tmp = arr[begin];
|
||||
arr[begin] = arr[end];
|
||||
arr[end] = tmp;
|
||||
++begin;
|
||||
@@ -131,9 +131,9 @@ export function reverseSubArray(arr, begin, end) {
|
||||
* @template VALUE
|
||||
*/
|
||||
export function extend(arr, data) {
|
||||
var i;
|
||||
var extension = Array.isArray(data) ? data : [data];
|
||||
var length = extension.length;
|
||||
let i;
|
||||
const extension = Array.isArray(data) ? data : [data];
|
||||
const length = extension.length;
|
||||
for (i = 0; i < length; i++) {
|
||||
arr[arr.length] = extension[i];
|
||||
}
|
||||
@@ -147,8 +147,8 @@ export function extend(arr, data) {
|
||||
* @return {boolean} If the element was removed.
|
||||
*/
|
||||
export function remove(arr, obj) {
|
||||
var i = arr.indexOf(obj);
|
||||
var found = i > -1;
|
||||
const i = arr.indexOf(obj);
|
||||
const found = i > -1;
|
||||
if (found) {
|
||||
arr.splice(i, 1);
|
||||
}
|
||||
@@ -163,10 +163,10 @@ export function remove(arr, obj) {
|
||||
* @return {VALUE} The element found.
|
||||
*/
|
||||
export function find(arr, func) {
|
||||
var length = arr.length >>> 0;
|
||||
var value;
|
||||
const length = arr.length >>> 0;
|
||||
let value;
|
||||
|
||||
for (var i = 0; i < length; i++) {
|
||||
for (let i = 0; i < length; i++) {
|
||||
value = arr[i];
|
||||
if (func(value, i, arr)) {
|
||||
return value;
|
||||
@@ -182,11 +182,11 @@ export function find(arr, func) {
|
||||
* @return {boolean} Whether the two arrays are equal.
|
||||
*/
|
||||
export function equals(arr1, arr2) {
|
||||
var len1 = arr1.length;
|
||||
const len1 = arr1.length;
|
||||
if (len1 !== arr2.length) {
|
||||
return false;
|
||||
}
|
||||
for (var i = 0; i < len1; i++) {
|
||||
for (let i = 0; i < len1; i++) {
|
||||
if (arr1[i] !== arr2[i]) {
|
||||
return false;
|
||||
}
|
||||
@@ -200,9 +200,9 @@ export function equals(arr1, arr2) {
|
||||
* @param {Function} compareFnc Comparison function.
|
||||
*/
|
||||
export function stableSort(arr, compareFnc) {
|
||||
var length = arr.length;
|
||||
var tmp = Array(arr.length);
|
||||
var i;
|
||||
const length = arr.length;
|
||||
const tmp = Array(arr.length);
|
||||
let i;
|
||||
for (i = 0; i < length; i++) {
|
||||
tmp[i] = {index: i, value: arr[i]};
|
||||
}
|
||||
@@ -221,8 +221,8 @@ export function stableSort(arr, compareFnc) {
|
||||
* @return {number} Return index.
|
||||
*/
|
||||
export function findIndex(arr, func) {
|
||||
var index;
|
||||
var found = !arr.every(function(el, idx) {
|
||||
let index;
|
||||
const found = !arr.every(function(el, idx) {
|
||||
index = idx;
|
||||
return !func(el, idx, arr);
|
||||
});
|
||||
@@ -237,12 +237,12 @@ export function findIndex(arr, func) {
|
||||
* @return {boolean} Return index.
|
||||
*/
|
||||
export function isSorted(arr, opt_func, opt_strict) {
|
||||
var compare = opt_func || numberSafeCompareFunction;
|
||||
const compare = opt_func || numberSafeCompareFunction;
|
||||
return arr.every(function(currentVal, index) {
|
||||
if (index === 0) {
|
||||
return true;
|
||||
}
|
||||
var res = compare(arr[index - 1], currentVal);
|
||||
const res = compare(arr[index - 1], currentVal);
|
||||
return !(res > 0 || opt_strict && res === 0);
|
||||
});
|
||||
}
|
||||
|
||||
+20
-20
@@ -11,7 +11,7 @@ import {clamp} from './math.js';
|
||||
* @type {RegExp}
|
||||
* @private
|
||||
*/
|
||||
var HEX_COLOR_RE_ = /^#(?:[0-9a-f]{3,4}){1,2}$/i;
|
||||
const HEX_COLOR_RE_ = /^#(?:[0-9a-f]{3,4}){1,2}$/i;
|
||||
|
||||
|
||||
/**
|
||||
@@ -20,7 +20,7 @@ var HEX_COLOR_RE_ = /^#(?:[0-9a-f]{3,4}){1,2}$/i;
|
||||
* @type {RegExp}
|
||||
* @private
|
||||
*/
|
||||
var NAMED_COLOR_RE_ = /^([a-z]*)$/i;
|
||||
const NAMED_COLOR_RE_ = /^([a-z]*)$/i;
|
||||
|
||||
|
||||
/**
|
||||
@@ -43,10 +43,10 @@ export function asString(color) {
|
||||
* @return {string} Rgb string.
|
||||
*/
|
||||
function fromNamed(color) {
|
||||
var el = document.createElement('div');
|
||||
const el = document.createElement('div');
|
||||
el.style.color = color;
|
||||
document.body.appendChild(el);
|
||||
var rgb = getComputedStyle(el).color;
|
||||
const rgb = getComputedStyle(el).color;
|
||||
document.body.removeChild(el);
|
||||
return rgb;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ function fromNamed(color) {
|
||||
* @param {string} s String.
|
||||
* @return {ol.Color} Color.
|
||||
*/
|
||||
export var fromString = (
|
||||
export const fromString = (
|
||||
function() {
|
||||
|
||||
// We maintain a small cache of parsed strings. To provide cheap LRU-like
|
||||
@@ -67,17 +67,17 @@ export var fromString = (
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
var MAX_CACHE_SIZE = 1024;
|
||||
const MAX_CACHE_SIZE = 1024;
|
||||
|
||||
/**
|
||||
* @type {Object.<string, ol.Color>}
|
||||
*/
|
||||
var cache = {};
|
||||
const cache = {};
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
var cacheSize = 0;
|
||||
let cacheSize = 0;
|
||||
|
||||
return (
|
||||
/**
|
||||
@@ -85,13 +85,13 @@ export var fromString = (
|
||||
* @return {ol.Color} Color.
|
||||
*/
|
||||
function(s) {
|
||||
var color;
|
||||
let color;
|
||||
if (cache.hasOwnProperty(s)) {
|
||||
color = cache[s];
|
||||
} else {
|
||||
if (cacheSize >= MAX_CACHE_SIZE) {
|
||||
var i = 0;
|
||||
var key;
|
||||
let i = 0;
|
||||
let key;
|
||||
for (key in cache) {
|
||||
if ((i++ & 3) === 0) {
|
||||
delete cache[key];
|
||||
@@ -130,21 +130,21 @@ export function asArray(color) {
|
||||
* @return {ol.Color} Color.
|
||||
*/
|
||||
function fromStringInternal_(s) {
|
||||
var r, g, b, a, color, parts;
|
||||
let r, g, b, a, color, parts;
|
||||
|
||||
if (NAMED_COLOR_RE_.exec(s)) {
|
||||
s = fromNamed(s);
|
||||
}
|
||||
|
||||
if (HEX_COLOR_RE_.exec(s)) { // hex
|
||||
var n = s.length - 1; // number of hex digits
|
||||
var d; // number of digits per channel
|
||||
const n = s.length - 1; // number of hex digits
|
||||
let d; // number of digits per channel
|
||||
if (n <= 4) {
|
||||
d = 1;
|
||||
} else {
|
||||
d = 2;
|
||||
}
|
||||
var hasAlpha = n === 4 || n === 8;
|
||||
const hasAlpha = n === 4 || n === 8;
|
||||
r = parseInt(s.substr(1 + 0 * d, d), 16);
|
||||
g = parseInt(s.substr(1 + 1 * d, d), 16);
|
||||
b = parseInt(s.substr(1 + 2 * d, d), 16);
|
||||
@@ -183,7 +183,7 @@ function fromStringInternal_(s) {
|
||||
* @return {ol.Color} Clamped color.
|
||||
*/
|
||||
export function normalize(color, opt_color) {
|
||||
var result = opt_color || [];
|
||||
const result = opt_color || [];
|
||||
result[0] = clamp((color[0] + 0.5) | 0, 0, 255);
|
||||
result[1] = clamp((color[1] + 0.5) | 0, 0, 255);
|
||||
result[2] = clamp((color[2] + 0.5) | 0, 0, 255);
|
||||
@@ -197,18 +197,18 @@ export function normalize(color, opt_color) {
|
||||
* @return {string} String.
|
||||
*/
|
||||
export function toString(color) {
|
||||
var r = color[0];
|
||||
let r = color[0];
|
||||
if (r != (r | 0)) {
|
||||
r = (r + 0.5) | 0;
|
||||
}
|
||||
var g = color[1];
|
||||
let g = color[1];
|
||||
if (g != (g | 0)) {
|
||||
g = (g + 0.5) | 0;
|
||||
}
|
||||
var b = color[2];
|
||||
let b = color[2];
|
||||
if (b != (b | 0)) {
|
||||
b = (b + 0.5) | 0;
|
||||
}
|
||||
var a = color[3] === undefined ? 1 : color[3];
|
||||
const a = color[3] === undefined ? 1 : color[3];
|
||||
return 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
|
||||
}
|
||||
|
||||
+5
-5
@@ -21,21 +21,21 @@ import Zoom from './control/Zoom.js';
|
||||
*/
|
||||
export function defaults(opt_options) {
|
||||
|
||||
var options = opt_options ? opt_options : {};
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
var controls = new Collection();
|
||||
const controls = new Collection();
|
||||
|
||||
var zoomControl = options.zoom !== undefined ? options.zoom : true;
|
||||
const zoomControl = options.zoom !== undefined ? options.zoom : true;
|
||||
if (zoomControl) {
|
||||
controls.push(new Zoom(options.zoomOptions));
|
||||
}
|
||||
|
||||
var rotateControl = options.rotate !== undefined ? options.rotate : true;
|
||||
const rotateControl = options.rotate !== undefined ? options.rotate : true;
|
||||
if (rotateControl) {
|
||||
controls.push(new Rotate(options.rotateOptions));
|
||||
}
|
||||
|
||||
var attributionControl = options.attribution !== undefined ?
|
||||
const attributionControl = options.attribution !== undefined ?
|
||||
options.attribution : true;
|
||||
if (attributionControl) {
|
||||
controls.push(new Attribution(options.attributionOptions));
|
||||
|
||||
@@ -22,9 +22,9 @@ import Layer from '../layer/Layer.js';
|
||||
* @param {olx.control.AttributionOptions=} opt_options Attribution options.
|
||||
* @api
|
||||
*/
|
||||
var Attribution = function(opt_options) {
|
||||
const Attribution = function(opt_options) {
|
||||
|
||||
var options = opt_options ? opt_options : {};
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -49,11 +49,11 @@ var Attribution = function(opt_options) {
|
||||
this.collapsed_ = false;
|
||||
}
|
||||
|
||||
var className = options.className !== undefined ? options.className : 'ol-attribution';
|
||||
const className = options.className !== undefined ? options.className : 'ol-attribution';
|
||||
|
||||
var tipLabel = options.tipLabel !== undefined ? options.tipLabel : 'Attributions';
|
||||
const tipLabel = options.tipLabel !== undefined ? options.tipLabel : 'Attributions';
|
||||
|
||||
var collapseLabel = options.collapseLabel !== undefined ? options.collapseLabel : '\u00BB';
|
||||
const collapseLabel = options.collapseLabel !== undefined ? options.collapseLabel : '\u00BB';
|
||||
|
||||
if (typeof collapseLabel === 'string') {
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ var Attribution = function(opt_options) {
|
||||
this.collapseLabel_ = collapseLabel;
|
||||
}
|
||||
|
||||
var label = options.label !== undefined ? options.label : 'i';
|
||||
const label = options.label !== undefined ? options.label : 'i';
|
||||
|
||||
if (typeof label === 'string') {
|
||||
/**
|
||||
@@ -80,24 +80,24 @@ var Attribution = function(opt_options) {
|
||||
}
|
||||
|
||||
|
||||
var activeLabel = (this.collapsible_ && !this.collapsed_) ?
|
||||
const activeLabel = (this.collapsible_ && !this.collapsed_) ?
|
||||
this.collapseLabel_ : this.label_;
|
||||
var button = document.createElement('button');
|
||||
const button = document.createElement('button');
|
||||
button.setAttribute('type', 'button');
|
||||
button.title = tipLabel;
|
||||
button.appendChild(activeLabel);
|
||||
|
||||
_ol_events_.listen(button, EventType.CLICK, this.handleClick_, this);
|
||||
|
||||
var cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL +
|
||||
const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL +
|
||||
(this.collapsed_ && this.collapsible_ ? ' ol-collapsed' : '') +
|
||||
(this.collapsible_ ? '' : ' ol-uncollapsible');
|
||||
var element = document.createElement('div');
|
||||
const element = document.createElement('div');
|
||||
element.className = cssClasses;
|
||||
element.appendChild(this.ulElement_);
|
||||
element.appendChild(button);
|
||||
|
||||
var render = options.render ? options.render : Attribution.render;
|
||||
const render = options.render ? options.render : Attribution.render;
|
||||
|
||||
Control.call(this, {
|
||||
element: element,
|
||||
@@ -134,39 +134,39 @@ Attribution.prototype.getSourceAttributions_ = function(frameState) {
|
||||
* Used to determine if an attribution already exists.
|
||||
* @type {Object.<string, boolean>}
|
||||
*/
|
||||
var lookup = {};
|
||||
const lookup = {};
|
||||
|
||||
/**
|
||||
* A list of visible attributions.
|
||||
* @type {Array.<string>}
|
||||
*/
|
||||
var visibleAttributions = [];
|
||||
const visibleAttributions = [];
|
||||
|
||||
var layerStatesArray = frameState.layerStatesArray;
|
||||
var resolution = frameState.viewState.resolution;
|
||||
for (var i = 0, ii = layerStatesArray.length; i < ii; ++i) {
|
||||
var layerState = layerStatesArray[i];
|
||||
const layerStatesArray = frameState.layerStatesArray;
|
||||
const resolution = frameState.viewState.resolution;
|
||||
for (let i = 0, ii = layerStatesArray.length; i < ii; ++i) {
|
||||
const layerState = layerStatesArray[i];
|
||||
if (!Layer.visibleAtResolution(layerState, resolution)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var source = layerState.layer.getSource();
|
||||
const source = layerState.layer.getSource();
|
||||
if (!source) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var attributionGetter = source.getAttributions();
|
||||
const attributionGetter = source.getAttributions();
|
||||
if (!attributionGetter) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var attributions = attributionGetter(frameState);
|
||||
const attributions = attributionGetter(frameState);
|
||||
if (!attributions) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Array.isArray(attributions)) {
|
||||
for (var j = 0, jj = attributions.length; j < jj; ++j) {
|
||||
for (let j = 0, jj = attributions.length; j < jj; ++j) {
|
||||
if (!(attributions[j] in lookup)) {
|
||||
visibleAttributions.push(attributions[j]);
|
||||
lookup[attributions[j]] = true;
|
||||
@@ -207,7 +207,7 @@ Attribution.prototype.updateElement_ = function(frameState) {
|
||||
return;
|
||||
}
|
||||
|
||||
var attributions = this.getSourceAttributions_(frameState);
|
||||
const attributions = this.getSourceAttributions_(frameState);
|
||||
if (equals(attributions, this.renderedAttributions_)) {
|
||||
return;
|
||||
}
|
||||
@@ -215,14 +215,14 @@ Attribution.prototype.updateElement_ = function(frameState) {
|
||||
removeChildren(this.ulElement_);
|
||||
|
||||
// append the attributions
|
||||
for (var i = 0, ii = attributions.length; i < ii; ++i) {
|
||||
var element = document.createElement('LI');
|
||||
for (let i = 0, ii = attributions.length; i < ii; ++i) {
|
||||
const element = document.createElement('LI');
|
||||
element.innerHTML = attributions[i];
|
||||
this.ulElement_.appendChild(element);
|
||||
}
|
||||
|
||||
|
||||
var visible = attributions.length > 0;
|
||||
const visible = attributions.length > 0;
|
||||
if (this.renderedVisible_ != visible) {
|
||||
this.element.style.display = visible ? '' : 'none';
|
||||
this.renderedVisible_ = visible;
|
||||
|
||||
@@ -36,7 +36,7 @@ import _ol_events_ from '../events.js';
|
||||
* @param {olx.control.ControlOptions} options Control options.
|
||||
* @api
|
||||
*/
|
||||
var Control = function(options) {
|
||||
const Control = function(options) {
|
||||
|
||||
BaseObject.call(this);
|
||||
|
||||
@@ -109,18 +109,18 @@ Control.prototype.setMap = function(map) {
|
||||
if (this.map_) {
|
||||
removeNode(this.element);
|
||||
}
|
||||
for (var i = 0, ii = this.listenerKeys.length; i < ii; ++i) {
|
||||
for (let i = 0, ii = this.listenerKeys.length; i < ii; ++i) {
|
||||
_ol_events_.unlistenByKey(this.listenerKeys[i]);
|
||||
}
|
||||
this.listenerKeys.length = 0;
|
||||
this.map_ = map;
|
||||
if (this.map_) {
|
||||
var target = this.target_ ?
|
||||
const target = this.target_ ?
|
||||
this.target_ : map.getOverlayContainerStopEvent();
|
||||
target.appendChild(this.element);
|
||||
if (this.render !== nullFunction) {
|
||||
this.listenerKeys.push(_ol_events_.listen(map,
|
||||
MapEventType.POSTRENDER, this.render, this));
|
||||
MapEventType.POSTRENDER, this.render, this));
|
||||
}
|
||||
map.render();
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ import EventType from '../events/EventType.js';
|
||||
* @param {olx.control.FullScreenOptions=} opt_options Options.
|
||||
* @api
|
||||
*/
|
||||
var FullScreen = function(opt_options) {
|
||||
const FullScreen = function(opt_options) {
|
||||
|
||||
var options = opt_options ? opt_options : {};
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -36,7 +36,7 @@ var FullScreen = function(opt_options) {
|
||||
this.cssClassName_ = options.className !== undefined ? options.className :
|
||||
'ol-full-screen';
|
||||
|
||||
var label = options.label !== undefined ? options.label : '\u2922';
|
||||
const label = options.label !== undefined ? options.label : '\u2922';
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -45,7 +45,7 @@ var FullScreen = function(opt_options) {
|
||||
this.labelNode_ = typeof label === 'string' ?
|
||||
document.createTextNode(label) : label;
|
||||
|
||||
var labelActive = options.labelActive !== undefined ? options.labelActive : '\u00d7';
|
||||
const labelActive = options.labelActive !== undefined ? options.labelActive : '\u00d7';
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -54,20 +54,20 @@ var FullScreen = function(opt_options) {
|
||||
this.labelActiveNode_ = typeof labelActive === 'string' ?
|
||||
document.createTextNode(labelActive) : labelActive;
|
||||
|
||||
var tipLabel = options.tipLabel ? options.tipLabel : 'Toggle full-screen';
|
||||
var button = document.createElement('button');
|
||||
const tipLabel = options.tipLabel ? options.tipLabel : 'Toggle full-screen';
|
||||
const button = document.createElement('button');
|
||||
button.className = this.cssClassName_ + '-' + FullScreen.isFullScreen();
|
||||
button.setAttribute('type', 'button');
|
||||
button.title = tipLabel;
|
||||
button.appendChild(this.labelNode_);
|
||||
|
||||
_ol_events_.listen(button, EventType.CLICK,
|
||||
this.handleClick_, this);
|
||||
this.handleClick_, this);
|
||||
|
||||
var cssClasses = this.cssClassName_ + ' ' + CLASS_UNSELECTABLE +
|
||||
const cssClasses = this.cssClassName_ + ' ' + CLASS_UNSELECTABLE +
|
||||
' ' + CLASS_CONTROL + ' ' +
|
||||
(!FullScreen.isFullScreenSupported() ? CLASS_UNSUPPORTED : '');
|
||||
var element = document.createElement('div');
|
||||
const element = document.createElement('div');
|
||||
element.className = cssClasses;
|
||||
element.appendChild(button);
|
||||
|
||||
@@ -110,14 +110,14 @@ FullScreen.prototype.handleFullScreen_ = function() {
|
||||
if (!FullScreen.isFullScreenSupported()) {
|
||||
return;
|
||||
}
|
||||
var map = this.getMap();
|
||||
const map = this.getMap();
|
||||
if (!map) {
|
||||
return;
|
||||
}
|
||||
if (FullScreen.isFullScreen()) {
|
||||
FullScreen.exitFullScreen();
|
||||
} else {
|
||||
var element;
|
||||
let element;
|
||||
if (this.source_) {
|
||||
element = typeof this.source_ === 'string' ?
|
||||
document.getElementById(this.source_) :
|
||||
@@ -139,8 +139,8 @@ FullScreen.prototype.handleFullScreen_ = function() {
|
||||
* @private
|
||||
*/
|
||||
FullScreen.prototype.handleFullScreenChange_ = function() {
|
||||
var button = this.element.firstElementChild;
|
||||
var map = this.getMap();
|
||||
const button = this.element.firstElementChild;
|
||||
const map = this.getMap();
|
||||
if (FullScreen.isFullScreen()) {
|
||||
button.className = this.cssClassName_ + '-true';
|
||||
replaceNode(this.labelActiveNode_, this.labelNode_);
|
||||
@@ -162,8 +162,8 @@ FullScreen.prototype.setMap = function(map) {
|
||||
Control.prototype.setMap.call(this, map);
|
||||
if (map) {
|
||||
this.listenerKeys.push(_ol_events_.listen(document,
|
||||
FullScreen.getChangeType_(),
|
||||
this.handleFullScreenChange_, this)
|
||||
FullScreen.getChangeType_(),
|
||||
this.handleFullScreenChange_, this)
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -172,7 +172,7 @@ FullScreen.prototype.setMap = function(map) {
|
||||
* @return {boolean} Fullscreen is supported by the current platform.
|
||||
*/
|
||||
FullScreen.isFullScreenSupported = function() {
|
||||
var body = document.body;
|
||||
const body = document.body;
|
||||
return !!(
|
||||
body.webkitRequestFullscreen ||
|
||||
(body.mozRequestFullScreen && document.mozFullScreenEnabled) ||
|
||||
@@ -241,10 +241,10 @@ FullScreen.exitFullScreen = function() {
|
||||
* @private
|
||||
*/
|
||||
FullScreen.getChangeType_ = (function() {
|
||||
var changeType;
|
||||
let changeType;
|
||||
return function() {
|
||||
if (!changeType) {
|
||||
var body = document.body;
|
||||
const body = document.body;
|
||||
if (body.webkitRequestFullscreen) {
|
||||
changeType = 'webkitfullscreenchange';
|
||||
} else if (body.mozRequestFullScreen) {
|
||||
|
||||
@@ -22,14 +22,14 @@ import {getTransformFromProjections, identityTransform, get as getProjection} fr
|
||||
* options.
|
||||
* @api
|
||||
*/
|
||||
var MousePosition = function(opt_options) {
|
||||
const MousePosition = function(opt_options) {
|
||||
|
||||
var options = opt_options ? opt_options : {};
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
var element = document.createElement('DIV');
|
||||
const element = document.createElement('DIV');
|
||||
element.className = options.className !== undefined ? options.className : 'ol-mouse-position';
|
||||
|
||||
var render = options.render ?
|
||||
const render = options.render ?
|
||||
options.render : MousePosition.render;
|
||||
|
||||
Control.call(this, {
|
||||
@@ -39,8 +39,8 @@ var MousePosition = function(opt_options) {
|
||||
});
|
||||
|
||||
_ol_events_.listen(this,
|
||||
BaseObject.getChangeEventType(MousePosition.Property_.PROJECTION),
|
||||
this.handleProjectionChanged_, this);
|
||||
BaseObject.getChangeEventType(MousePosition.Property_.PROJECTION),
|
||||
this.handleProjectionChanged_, this);
|
||||
|
||||
if (options.coordinateFormat) {
|
||||
this.setCoordinateFormat(options.coordinateFormat);
|
||||
@@ -91,7 +91,7 @@ inherits(MousePosition, Control);
|
||||
* @api
|
||||
*/
|
||||
MousePosition.render = function(mapEvent) {
|
||||
var frameState = mapEvent.frameState;
|
||||
const frameState = mapEvent.frameState;
|
||||
if (!frameState) {
|
||||
this.mapProjection_ = null;
|
||||
} else {
|
||||
@@ -146,7 +146,7 @@ MousePosition.prototype.getProjection = function() {
|
||||
* @protected
|
||||
*/
|
||||
MousePosition.prototype.handleMouseMove = function(event) {
|
||||
var map = this.getMap();
|
||||
const map = this.getMap();
|
||||
this.lastMouseMovePixel_ = map.getEventPixel(event);
|
||||
this.updateHTML_(this.lastMouseMovePixel_);
|
||||
};
|
||||
@@ -169,12 +169,12 @@ MousePosition.prototype.handleMouseOut = function(event) {
|
||||
MousePosition.prototype.setMap = function(map) {
|
||||
Control.prototype.setMap.call(this, map);
|
||||
if (map) {
|
||||
var viewport = map.getViewport();
|
||||
const viewport = map.getViewport();
|
||||
this.listenerKeys.push(
|
||||
_ol_events_.listen(viewport, EventType.MOUSEMOVE,
|
||||
this.handleMouseMove, this),
|
||||
_ol_events_.listen(viewport, EventType.MOUSEOUT,
|
||||
this.handleMouseOut, this)
|
||||
_ol_events_.listen(viewport, EventType.MOUSEMOVE,
|
||||
this.handleMouseMove, this),
|
||||
_ol_events_.listen(viewport, EventType.MOUSEOUT,
|
||||
this.handleMouseOut, this)
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -209,22 +209,22 @@ MousePosition.prototype.setProjection = function(projection) {
|
||||
* @private
|
||||
*/
|
||||
MousePosition.prototype.updateHTML_ = function(pixel) {
|
||||
var html = this.undefinedHTML_;
|
||||
let html = this.undefinedHTML_;
|
||||
if (pixel && this.mapProjection_) {
|
||||
if (!this.transform_) {
|
||||
var projection = this.getProjection();
|
||||
const projection = this.getProjection();
|
||||
if (projection) {
|
||||
this.transform_ = getTransformFromProjections(
|
||||
this.mapProjection_, projection);
|
||||
this.mapProjection_, projection);
|
||||
} else {
|
||||
this.transform_ = identityTransform;
|
||||
}
|
||||
}
|
||||
var map = this.getMap();
|
||||
var coordinate = map.getCoordinateFromPixel(pixel);
|
||||
const map = this.getMap();
|
||||
const coordinate = map.getCoordinateFromPixel(pixel);
|
||||
if (coordinate) {
|
||||
this.transform_(coordinate, coordinate);
|
||||
var coordinateFormat = this.getCoordinateFormat();
|
||||
const coordinateFormat = this.getCoordinateFormat();
|
||||
if (coordinateFormat) {
|
||||
html = coordinateFormat(coordinate);
|
||||
} else {
|
||||
|
||||
@@ -24,14 +24,14 @@ import {containsExtent, getBottomLeft, getBottomRight, getTopLeft, getTopRight,
|
||||
* @type {number} Maximum width and/or height extent ratio that determines
|
||||
* when the overview map should be zoomed out.
|
||||
*/
|
||||
var MAX_RATIO = 0.75;
|
||||
const MAX_RATIO = 0.75;
|
||||
|
||||
|
||||
/**
|
||||
* @type {number} Minimum width and/or height extent ratio that determines
|
||||
* when the overview map should be zoomed in.
|
||||
*/
|
||||
var MIN_RATIO = 0.1;
|
||||
const MIN_RATIO = 0.1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -42,9 +42,9 @@ var MIN_RATIO = 0.1;
|
||||
* @param {olx.control.OverviewMapOptions=} opt_options OverviewMap options.
|
||||
* @api
|
||||
*/
|
||||
var OverviewMap = function(opt_options) {
|
||||
const OverviewMap = function(opt_options) {
|
||||
|
||||
var options = opt_options ? opt_options : {};
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
@@ -63,11 +63,11 @@ var OverviewMap = function(opt_options) {
|
||||
this.collapsed_ = false;
|
||||
}
|
||||
|
||||
var className = options.className !== undefined ? options.className : 'ol-overviewmap';
|
||||
const className = options.className !== undefined ? options.className : 'ol-overviewmap';
|
||||
|
||||
var tipLabel = options.tipLabel !== undefined ? options.tipLabel : 'Overview map';
|
||||
const tipLabel = options.tipLabel !== undefined ? options.tipLabel : 'Overview map';
|
||||
|
||||
var collapseLabel = options.collapseLabel !== undefined ? options.collapseLabel : '\u00AB';
|
||||
const collapseLabel = options.collapseLabel !== undefined ? options.collapseLabel : '\u00AB';
|
||||
|
||||
if (typeof collapseLabel === 'string') {
|
||||
/**
|
||||
@@ -80,7 +80,7 @@ var OverviewMap = function(opt_options) {
|
||||
this.collapseLabel_ = collapseLabel;
|
||||
}
|
||||
|
||||
var label = options.label !== undefined ? options.label : '\u00BB';
|
||||
const label = options.label !== undefined ? options.label : '\u00BB';
|
||||
|
||||
|
||||
if (typeof label === 'string') {
|
||||
@@ -94,15 +94,15 @@ var OverviewMap = function(opt_options) {
|
||||
this.label_ = label;
|
||||
}
|
||||
|
||||
var activeLabel = (this.collapsible_ && !this.collapsed_) ?
|
||||
const activeLabel = (this.collapsible_ && !this.collapsed_) ?
|
||||
this.collapseLabel_ : this.label_;
|
||||
var button = document.createElement('button');
|
||||
const button = document.createElement('button');
|
||||
button.setAttribute('type', 'button');
|
||||
button.title = tipLabel;
|
||||
button.appendChild(activeLabel);
|
||||
|
||||
_ol_events_.listen(button, EventType.CLICK,
|
||||
this.handleClick_, this);
|
||||
this.handleClick_, this);
|
||||
|
||||
/**
|
||||
* @type {Element}
|
||||
@@ -120,19 +120,19 @@ var OverviewMap = function(opt_options) {
|
||||
interactions: new Collection(),
|
||||
view: options.view
|
||||
});
|
||||
var ovmap = this.ovmap_;
|
||||
const ovmap = this.ovmap_;
|
||||
|
||||
if (options.layers) {
|
||||
options.layers.forEach(
|
||||
/**
|
||||
/**
|
||||
* @param {ol.layer.Layer} layer Layer.
|
||||
*/
|
||||
function(layer) {
|
||||
ovmap.addLayer(layer);
|
||||
}.bind(this));
|
||||
function(layer) {
|
||||
ovmap.addLayer(layer);
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
var box = document.createElement('DIV');
|
||||
const box = document.createElement('DIV');
|
||||
box.className = 'ol-overviewmap-box';
|
||||
box.style.boxSizing = 'border-box';
|
||||
|
||||
@@ -147,15 +147,15 @@ var OverviewMap = function(opt_options) {
|
||||
});
|
||||
this.ovmap_.addOverlay(this.boxOverlay_);
|
||||
|
||||
var cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL +
|
||||
const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL +
|
||||
(this.collapsed_ && this.collapsible_ ? ' ol-collapsed' : '') +
|
||||
(this.collapsible_ ? '' : ' ol-uncollapsible');
|
||||
var element = document.createElement('div');
|
||||
const element = document.createElement('div');
|
||||
element.className = cssClasses;
|
||||
element.appendChild(this.ovmapDiv_);
|
||||
element.appendChild(button);
|
||||
|
||||
var render = options.render ? options.render : OverviewMap.render;
|
||||
const render = options.render ? options.render : OverviewMap.render;
|
||||
|
||||
Control.call(this, {
|
||||
element: element,
|
||||
@@ -165,28 +165,28 @@ var OverviewMap = function(opt_options) {
|
||||
|
||||
/* Interactive map */
|
||||
|
||||
var scope = this;
|
||||
const scope = this;
|
||||
|
||||
var overlay = this.boxOverlay_;
|
||||
var overlayBox = this.boxOverlay_.getElement();
|
||||
const overlay = this.boxOverlay_;
|
||||
const overlayBox = this.boxOverlay_.getElement();
|
||||
|
||||
/* Functions definition */
|
||||
|
||||
var computeDesiredMousePosition = function(mousePosition) {
|
||||
const computeDesiredMousePosition = function(mousePosition) {
|
||||
return {
|
||||
clientX: mousePosition.clientX - (overlayBox.offsetWidth / 2),
|
||||
clientY: mousePosition.clientY + (overlayBox.offsetHeight / 2)
|
||||
};
|
||||
};
|
||||
|
||||
var move = function(event) {
|
||||
var coordinates = ovmap.getEventCoordinate(computeDesiredMousePosition(event));
|
||||
const move = function(event) {
|
||||
const coordinates = ovmap.getEventCoordinate(computeDesiredMousePosition(event));
|
||||
|
||||
overlay.setPosition(coordinates);
|
||||
};
|
||||
|
||||
var endMoving = function(event) {
|
||||
var coordinates = ovmap.getEventCoordinate(event);
|
||||
const endMoving = function(event) {
|
||||
const coordinates = ovmap.getEventCoordinate(event);
|
||||
|
||||
scope.getMap().getView().setCenter(coordinates);
|
||||
|
||||
@@ -210,12 +210,12 @@ inherits(OverviewMap, Control);
|
||||
* @api
|
||||
*/
|
||||
OverviewMap.prototype.setMap = function(map) {
|
||||
var oldMap = this.getMap();
|
||||
const oldMap = this.getMap();
|
||||
if (map === oldMap) {
|
||||
return;
|
||||
}
|
||||
if (oldMap) {
|
||||
var oldView = oldMap.getView();
|
||||
const oldView = oldMap.getView();
|
||||
if (oldView) {
|
||||
this.unbindView_(oldView);
|
||||
}
|
||||
@@ -226,15 +226,15 @@ OverviewMap.prototype.setMap = function(map) {
|
||||
if (map) {
|
||||
this.ovmap_.setTarget(this.ovmapDiv_);
|
||||
this.listenerKeys.push(_ol_events_.listen(
|
||||
map, ObjectEventType.PROPERTYCHANGE,
|
||||
this.handleMapPropertyChange_, this));
|
||||
map, ObjectEventType.PROPERTYCHANGE,
|
||||
this.handleMapPropertyChange_, this));
|
||||
|
||||
// TODO: to really support map switching, this would need to be reworked
|
||||
if (this.ovmap_.getLayers().getLength() === 0) {
|
||||
this.ovmap_.setLayerGroup(map.getLayerGroup());
|
||||
}
|
||||
|
||||
var view = map.getView();
|
||||
const view = map.getView();
|
||||
if (view) {
|
||||
this.bindView_(view);
|
||||
if (view.isDef()) {
|
||||
@@ -253,11 +253,11 @@ OverviewMap.prototype.setMap = function(map) {
|
||||
*/
|
||||
OverviewMap.prototype.handleMapPropertyChange_ = function(event) {
|
||||
if (event.key === MapProperty.VIEW) {
|
||||
var oldView = /** @type {ol.View} */ (event.oldValue);
|
||||
const oldView = /** @type {ol.View} */ (event.oldValue);
|
||||
if (oldView) {
|
||||
this.unbindView_(oldView);
|
||||
}
|
||||
var newView = this.getMap().getView();
|
||||
const newView = this.getMap().getView();
|
||||
this.bindView_(newView);
|
||||
}
|
||||
};
|
||||
@@ -270,8 +270,8 @@ OverviewMap.prototype.handleMapPropertyChange_ = function(event) {
|
||||
*/
|
||||
OverviewMap.prototype.bindView_ = function(view) {
|
||||
_ol_events_.listen(view,
|
||||
BaseObject.getChangeEventType(ViewProperty.ROTATION),
|
||||
this.handleRotationChanged_, this);
|
||||
BaseObject.getChangeEventType(ViewProperty.ROTATION),
|
||||
this.handleRotationChanged_, this);
|
||||
};
|
||||
|
||||
|
||||
@@ -282,8 +282,8 @@ OverviewMap.prototype.bindView_ = function(view) {
|
||||
*/
|
||||
OverviewMap.prototype.unbindView_ = function(view) {
|
||||
_ol_events_.unlisten(view,
|
||||
BaseObject.getChangeEventType(ViewProperty.ROTATION),
|
||||
this.handleRotationChanged_, this);
|
||||
BaseObject.getChangeEventType(ViewProperty.ROTATION),
|
||||
this.handleRotationChanged_, this);
|
||||
};
|
||||
|
||||
|
||||
@@ -322,33 +322,33 @@ OverviewMap.render = function(mapEvent) {
|
||||
* @private
|
||||
*/
|
||||
OverviewMap.prototype.validateExtent_ = function() {
|
||||
var map = this.getMap();
|
||||
var ovmap = this.ovmap_;
|
||||
const map = this.getMap();
|
||||
const ovmap = this.ovmap_;
|
||||
|
||||
if (!map.isRendered() || !ovmap.isRendered()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var mapSize = /** @type {ol.Size} */ (map.getSize());
|
||||
const mapSize = /** @type {ol.Size} */ (map.getSize());
|
||||
|
||||
var view = map.getView();
|
||||
var extent = view.calculateExtent(mapSize);
|
||||
const view = map.getView();
|
||||
const extent = view.calculateExtent(mapSize);
|
||||
|
||||
var ovmapSize = /** @type {ol.Size} */ (ovmap.getSize());
|
||||
const ovmapSize = /** @type {ol.Size} */ (ovmap.getSize());
|
||||
|
||||
var ovview = ovmap.getView();
|
||||
var ovextent = ovview.calculateExtent(ovmapSize);
|
||||
const ovview = ovmap.getView();
|
||||
const ovextent = ovview.calculateExtent(ovmapSize);
|
||||
|
||||
var topLeftPixel =
|
||||
const topLeftPixel =
|
||||
ovmap.getPixelFromCoordinate(getTopLeft(extent));
|
||||
var bottomRightPixel =
|
||||
const bottomRightPixel =
|
||||
ovmap.getPixelFromCoordinate(getBottomRight(extent));
|
||||
|
||||
var boxWidth = Math.abs(topLeftPixel[0] - bottomRightPixel[0]);
|
||||
var boxHeight = Math.abs(topLeftPixel[1] - bottomRightPixel[1]);
|
||||
const boxWidth = Math.abs(topLeftPixel[0] - bottomRightPixel[0]);
|
||||
const boxHeight = Math.abs(topLeftPixel[1] - bottomRightPixel[1]);
|
||||
|
||||
var ovmapWidth = ovmapSize[0];
|
||||
var ovmapHeight = ovmapSize[1];
|
||||
const ovmapWidth = ovmapSize[0];
|
||||
const ovmapHeight = ovmapSize[1];
|
||||
|
||||
if (boxWidth < ovmapWidth * MIN_RATIO ||
|
||||
boxHeight < ovmapHeight * MIN_RATIO ||
|
||||
@@ -371,22 +371,22 @@ OverviewMap.prototype.resetExtent_ = function() {
|
||||
return;
|
||||
}
|
||||
|
||||
var map = this.getMap();
|
||||
var ovmap = this.ovmap_;
|
||||
const map = this.getMap();
|
||||
const ovmap = this.ovmap_;
|
||||
|
||||
var mapSize = /** @type {ol.Size} */ (map.getSize());
|
||||
const mapSize = /** @type {ol.Size} */ (map.getSize());
|
||||
|
||||
var view = map.getView();
|
||||
var extent = view.calculateExtent(mapSize);
|
||||
const view = map.getView();
|
||||
const extent = view.calculateExtent(mapSize);
|
||||
|
||||
var ovview = ovmap.getView();
|
||||
const ovview = ovmap.getView();
|
||||
|
||||
// get how many times the current map overview could hold different
|
||||
// box sizes using the min and max ratio, pick the step in the middle used
|
||||
// to calculate the extent from the main map to set it to the overview map,
|
||||
var steps = Math.log(
|
||||
MAX_RATIO / MIN_RATIO) / Math.LN2;
|
||||
var ratio = 1 / (Math.pow(2, steps / 2) * MIN_RATIO);
|
||||
const steps = Math.log(
|
||||
MAX_RATIO / MIN_RATIO) / Math.LN2;
|
||||
const ratio = 1 / (Math.pow(2, steps / 2) * MIN_RATIO);
|
||||
scaleFromCenter(extent, ratio);
|
||||
ovview.fit(extent);
|
||||
};
|
||||
@@ -398,12 +398,12 @@ OverviewMap.prototype.resetExtent_ = function() {
|
||||
* @private
|
||||
*/
|
||||
OverviewMap.prototype.recenter_ = function() {
|
||||
var map = this.getMap();
|
||||
var ovmap = this.ovmap_;
|
||||
const map = this.getMap();
|
||||
const ovmap = this.ovmap_;
|
||||
|
||||
var view = map.getView();
|
||||
const view = map.getView();
|
||||
|
||||
var ovview = ovmap.getView();
|
||||
const ovview = ovmap.getView();
|
||||
|
||||
ovview.setCenter(view.getCenter());
|
||||
};
|
||||
@@ -414,30 +414,30 @@ OverviewMap.prototype.recenter_ = function() {
|
||||
* @private
|
||||
*/
|
||||
OverviewMap.prototype.updateBox_ = function() {
|
||||
var map = this.getMap();
|
||||
var ovmap = this.ovmap_;
|
||||
const map = this.getMap();
|
||||
const ovmap = this.ovmap_;
|
||||
|
||||
if (!map.isRendered() || !ovmap.isRendered()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var mapSize = /** @type {ol.Size} */ (map.getSize());
|
||||
const mapSize = /** @type {ol.Size} */ (map.getSize());
|
||||
|
||||
var view = map.getView();
|
||||
const view = map.getView();
|
||||
|
||||
var ovview = ovmap.getView();
|
||||
const ovview = ovmap.getView();
|
||||
|
||||
var rotation = view.getRotation();
|
||||
const rotation = view.getRotation();
|
||||
|
||||
var overlay = this.boxOverlay_;
|
||||
var box = this.boxOverlay_.getElement();
|
||||
var extent = view.calculateExtent(mapSize);
|
||||
var ovresolution = ovview.getResolution();
|
||||
var bottomLeft = getBottomLeft(extent);
|
||||
var topRight = getTopRight(extent);
|
||||
const overlay = this.boxOverlay_;
|
||||
const box = this.boxOverlay_.getElement();
|
||||
const extent = view.calculateExtent(mapSize);
|
||||
const ovresolution = ovview.getResolution();
|
||||
const bottomLeft = getBottomLeft(extent);
|
||||
const topRight = getTopRight(extent);
|
||||
|
||||
// set position using bottom left coordinates
|
||||
var rotateBottomLeft = this.calculateCoordinateRotate_(rotation, bottomLeft);
|
||||
const rotateBottomLeft = this.calculateCoordinateRotate_(rotation, bottomLeft);
|
||||
overlay.setPosition(rotateBottomLeft);
|
||||
|
||||
// set box size calculated from map extent size and overview map resolution
|
||||
@@ -455,13 +455,13 @@ OverviewMap.prototype.updateBox_ = function() {
|
||||
* @private
|
||||
*/
|
||||
OverviewMap.prototype.calculateCoordinateRotate_ = function(
|
||||
rotation, coordinate) {
|
||||
var coordinateRotate;
|
||||
rotation, coordinate) {
|
||||
let coordinateRotate;
|
||||
|
||||
var map = this.getMap();
|
||||
var view = map.getView();
|
||||
const map = this.getMap();
|
||||
const view = map.getView();
|
||||
|
||||
var currentCenter = view.getCenter();
|
||||
const currentCenter = view.getCenter();
|
||||
|
||||
if (currentCenter) {
|
||||
coordinateRotate = [
|
||||
@@ -499,15 +499,15 @@ OverviewMap.prototype.handleToggle_ = function() {
|
||||
|
||||
// manage overview map if it had not been rendered before and control
|
||||
// is expanded
|
||||
var ovmap = this.ovmap_;
|
||||
const ovmap = this.ovmap_;
|
||||
if (!this.collapsed_ && !ovmap.isRendered()) {
|
||||
ovmap.updateSize();
|
||||
this.resetExtent_();
|
||||
_ol_events_.listenOnce(ovmap, MapEventType.POSTRENDER,
|
||||
function(event) {
|
||||
this.updateBox_();
|
||||
},
|
||||
this);
|
||||
function(event) {
|
||||
this.updateBox_();
|
||||
},
|
||||
this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+16
-16
@@ -20,13 +20,13 @@ import {inherits} from '../index.js';
|
||||
* @param {olx.control.RotateOptions=} opt_options Rotate options.
|
||||
* @api
|
||||
*/
|
||||
var Rotate = function(opt_options) {
|
||||
const Rotate = function(opt_options) {
|
||||
|
||||
var options = opt_options ? opt_options : {};
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
var className = options.className !== undefined ? options.className : 'ol-rotate';
|
||||
const className = options.className !== undefined ? options.className : 'ol-rotate';
|
||||
|
||||
var label = options.label !== undefined ? options.label : '\u21E7';
|
||||
const label = options.label !== undefined ? options.label : '\u21E7';
|
||||
|
||||
/**
|
||||
* @type {Element}
|
||||
@@ -43,23 +43,23 @@ var Rotate = function(opt_options) {
|
||||
this.label_.classList.add('ol-compass');
|
||||
}
|
||||
|
||||
var tipLabel = options.tipLabel ? options.tipLabel : 'Reset rotation';
|
||||
const tipLabel = options.tipLabel ? options.tipLabel : 'Reset rotation';
|
||||
|
||||
var button = document.createElement('button');
|
||||
const button = document.createElement('button');
|
||||
button.className = className + '-reset';
|
||||
button.setAttribute('type', 'button');
|
||||
button.title = tipLabel;
|
||||
button.appendChild(this.label_);
|
||||
|
||||
_ol_events_.listen(button, EventType.CLICK,
|
||||
Rotate.prototype.handleClick_, this);
|
||||
Rotate.prototype.handleClick_, this);
|
||||
|
||||
var cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL;
|
||||
var element = document.createElement('div');
|
||||
const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL;
|
||||
const element = document.createElement('div');
|
||||
element.className = cssClasses;
|
||||
element.appendChild(button);
|
||||
|
||||
var render = options.render ? options.render : Rotate.render;
|
||||
const render = options.render ? options.render : Rotate.render;
|
||||
|
||||
this.callResetNorth_ = options.resetNorth ? options.resetNorth : undefined;
|
||||
|
||||
@@ -114,8 +114,8 @@ Rotate.prototype.handleClick_ = function(event) {
|
||||
* @private
|
||||
*/
|
||||
Rotate.prototype.resetNorth_ = function() {
|
||||
var map = this.getMap();
|
||||
var view = map.getView();
|
||||
const map = this.getMap();
|
||||
const view = map.getView();
|
||||
if (!view) {
|
||||
// the map does not have a view, so we can't act
|
||||
// upon it
|
||||
@@ -142,15 +142,15 @@ Rotate.prototype.resetNorth_ = function() {
|
||||
* @api
|
||||
*/
|
||||
Rotate.render = function(mapEvent) {
|
||||
var frameState = mapEvent.frameState;
|
||||
const frameState = mapEvent.frameState;
|
||||
if (!frameState) {
|
||||
return;
|
||||
}
|
||||
var rotation = frameState.viewState.rotation;
|
||||
const rotation = frameState.viewState.rotation;
|
||||
if (rotation != this.rotation_) {
|
||||
var transform = 'rotate(' + rotation + 'rad)';
|
||||
const transform = 'rotate(' + rotation + 'rad)';
|
||||
if (this.autoHide_) {
|
||||
var contains = this.element.classList.contains(CLASS_HIDDEN);
|
||||
const contains = this.element.classList.contains(CLASS_HIDDEN);
|
||||
if (!contains && rotation === 0) {
|
||||
this.element.classList.add(CLASS_HIDDEN);
|
||||
} else if (contains && rotation !== 0) {
|
||||
|
||||
+20
-20
@@ -26,11 +26,11 @@ import Units from '../proj/Units.js';
|
||||
* @param {olx.control.ScaleLineOptions=} opt_options Scale line options.
|
||||
* @api
|
||||
*/
|
||||
var ScaleLine = function(opt_options) {
|
||||
const ScaleLine = function(opt_options) {
|
||||
|
||||
var options = opt_options ? opt_options : {};
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
var className = options.className !== undefined ? options.className : 'ol-scale-line';
|
||||
const className = options.className !== undefined ? options.className : 'ol-scale-line';
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -77,7 +77,7 @@ var ScaleLine = function(opt_options) {
|
||||
*/
|
||||
this.renderedHTML_ = '';
|
||||
|
||||
var render = options.render ? options.render : ScaleLine.render;
|
||||
const render = options.render ? options.render : ScaleLine.render;
|
||||
|
||||
Control.call(this, {
|
||||
element: this.element_,
|
||||
@@ -86,8 +86,8 @@ var ScaleLine = function(opt_options) {
|
||||
});
|
||||
|
||||
_ol_events_.listen(
|
||||
this, BaseObject.getChangeEventType(ScaleLine.Property_.UNITS),
|
||||
this.handleUnitsChanged_, this);
|
||||
this, BaseObject.getChangeEventType(ScaleLine.Property_.UNITS),
|
||||
this.handleUnitsChanged_, this);
|
||||
|
||||
this.setUnits(/** @type {ol.control.ScaleLineUnits} */ (options.units) ||
|
||||
ScaleLineUnits.METRIC);
|
||||
@@ -125,7 +125,7 @@ ScaleLine.prototype.getUnits = function() {
|
||||
* @api
|
||||
*/
|
||||
ScaleLine.render = function(mapEvent) {
|
||||
var frameState = mapEvent.frameState;
|
||||
const frameState = mapEvent.frameState;
|
||||
if (!frameState) {
|
||||
this.viewState_ = null;
|
||||
} else {
|
||||
@@ -158,7 +158,7 @@ ScaleLine.prototype.setUnits = function(units) {
|
||||
* @private
|
||||
*/
|
||||
ScaleLine.prototype.updateElement_ = function() {
|
||||
var viewState = this.viewState_;
|
||||
const viewState = this.viewState_;
|
||||
|
||||
if (!viewState) {
|
||||
if (this.renderedVisible_) {
|
||||
@@ -168,22 +168,22 @@ ScaleLine.prototype.updateElement_ = function() {
|
||||
return;
|
||||
}
|
||||
|
||||
var center = viewState.center;
|
||||
var projection = viewState.projection;
|
||||
var units = this.getUnits();
|
||||
var pointResolutionUnits = units == ScaleLineUnits.DEGREES ?
|
||||
const center = viewState.center;
|
||||
const projection = viewState.projection;
|
||||
const units = this.getUnits();
|
||||
const pointResolutionUnits = units == ScaleLineUnits.DEGREES ?
|
||||
Units.DEGREES :
|
||||
Units.METERS;
|
||||
var pointResolution =
|
||||
let pointResolution =
|
||||
getPointResolution(projection, viewState.resolution, center, pointResolutionUnits);
|
||||
if (units != ScaleLineUnits.DEGREES) {
|
||||
pointResolution *= projection.getMetersPerUnit();
|
||||
}
|
||||
|
||||
var nominalCount = this.minWidth_ * pointResolution;
|
||||
var suffix = '';
|
||||
let nominalCount = this.minWidth_ * pointResolution;
|
||||
let suffix = '';
|
||||
if (units == ScaleLineUnits.DEGREES) {
|
||||
var metersPerDegree = METERS_PER_UNIT[Units.DEGREES];
|
||||
const metersPerDegree = METERS_PER_UNIT[Units.DEGREES];
|
||||
if (projection.getUnits() == Units.DEGREES) {
|
||||
nominalCount *= metersPerDegree;
|
||||
} else {
|
||||
@@ -240,9 +240,9 @@ ScaleLine.prototype.updateElement_ = function() {
|
||||
assert(false, 33); // Invalid units
|
||||
}
|
||||
|
||||
var i = 3 * Math.floor(
|
||||
Math.log(this.minWidth_ * pointResolution) / Math.log(10));
|
||||
var count, width;
|
||||
let i = 3 * Math.floor(
|
||||
Math.log(this.minWidth_ * pointResolution) / Math.log(10));
|
||||
let count, width;
|
||||
while (true) {
|
||||
count = ScaleLine.LEADING_DIGITS[((i % 3) + 3) % 3] *
|
||||
Math.pow(10, Math.floor(i / 3));
|
||||
@@ -257,7 +257,7 @@ ScaleLine.prototype.updateElement_ = function() {
|
||||
++i;
|
||||
}
|
||||
|
||||
var html = count + ' ' + suffix;
|
||||
const html = count + ' ' + suffix;
|
||||
if (this.renderedHTML_ != html) {
|
||||
this.innerElement_.innerHTML = html;
|
||||
this.renderedHTML_ = html;
|
||||
|
||||
+20
-20
@@ -19,46 +19,46 @@ import {easeOut} from '../easing.js';
|
||||
* @param {olx.control.ZoomOptions=} opt_options Zoom options.
|
||||
* @api
|
||||
*/
|
||||
var Zoom = function(opt_options) {
|
||||
const Zoom = function(opt_options) {
|
||||
|
||||
var options = opt_options ? opt_options : {};
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
var className = options.className !== undefined ? options.className : 'ol-zoom';
|
||||
const className = options.className !== undefined ? options.className : 'ol-zoom';
|
||||
|
||||
var delta = options.delta !== undefined ? options.delta : 1;
|
||||
const delta = options.delta !== undefined ? options.delta : 1;
|
||||
|
||||
var zoomInLabel = options.zoomInLabel !== undefined ? options.zoomInLabel : '+';
|
||||
var zoomOutLabel = options.zoomOutLabel !== undefined ? options.zoomOutLabel : '\u2212';
|
||||
const zoomInLabel = options.zoomInLabel !== undefined ? options.zoomInLabel : '+';
|
||||
const zoomOutLabel = options.zoomOutLabel !== undefined ? options.zoomOutLabel : '\u2212';
|
||||
|
||||
var zoomInTipLabel = options.zoomInTipLabel !== undefined ?
|
||||
const zoomInTipLabel = options.zoomInTipLabel !== undefined ?
|
||||
options.zoomInTipLabel : 'Zoom in';
|
||||
var zoomOutTipLabel = options.zoomOutTipLabel !== undefined ?
|
||||
const zoomOutTipLabel = options.zoomOutTipLabel !== undefined ?
|
||||
options.zoomOutTipLabel : 'Zoom out';
|
||||
|
||||
var inElement = document.createElement('button');
|
||||
const inElement = document.createElement('button');
|
||||
inElement.className = className + '-in';
|
||||
inElement.setAttribute('type', 'button');
|
||||
inElement.title = zoomInTipLabel;
|
||||
inElement.appendChild(
|
||||
typeof zoomInLabel === 'string' ? document.createTextNode(zoomInLabel) : zoomInLabel
|
||||
typeof zoomInLabel === 'string' ? document.createTextNode(zoomInLabel) : zoomInLabel
|
||||
);
|
||||
|
||||
_ol_events_.listen(inElement, EventType.CLICK,
|
||||
Zoom.prototype.handleClick_.bind(this, delta));
|
||||
Zoom.prototype.handleClick_.bind(this, delta));
|
||||
|
||||
var outElement = document.createElement('button');
|
||||
const outElement = document.createElement('button');
|
||||
outElement.className = className + '-out';
|
||||
outElement.setAttribute('type', 'button');
|
||||
outElement.title = zoomOutTipLabel;
|
||||
outElement.appendChild(
|
||||
typeof zoomOutLabel === 'string' ? document.createTextNode(zoomOutLabel) : zoomOutLabel
|
||||
typeof zoomOutLabel === 'string' ? document.createTextNode(zoomOutLabel) : zoomOutLabel
|
||||
);
|
||||
|
||||
_ol_events_.listen(outElement, EventType.CLICK,
|
||||
Zoom.prototype.handleClick_.bind(this, -delta));
|
||||
Zoom.prototype.handleClick_.bind(this, -delta));
|
||||
|
||||
var cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL;
|
||||
var element = document.createElement('div');
|
||||
const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL;
|
||||
const element = document.createElement('div');
|
||||
element.className = cssClasses;
|
||||
element.appendChild(inElement);
|
||||
element.appendChild(outElement);
|
||||
@@ -95,16 +95,16 @@ Zoom.prototype.handleClick_ = function(delta, event) {
|
||||
* @private
|
||||
*/
|
||||
Zoom.prototype.zoomByDelta_ = function(delta) {
|
||||
var map = this.getMap();
|
||||
var view = map.getView();
|
||||
const map = this.getMap();
|
||||
const view = map.getView();
|
||||
if (!view) {
|
||||
// the map does not have a view, so we can't act
|
||||
// upon it
|
||||
return;
|
||||
}
|
||||
var currentResolution = view.getResolution();
|
||||
const currentResolution = view.getResolution();
|
||||
if (currentResolution) {
|
||||
var newResolution = view.constrainResolution(currentResolution, delta);
|
||||
const newResolution = view.constrainResolution(currentResolution, delta);
|
||||
if (this.duration_ > 0) {
|
||||
if (view.getAnimating()) {
|
||||
view.cancelAnimations();
|
||||
|
||||
@@ -28,9 +28,9 @@ import PointerEventHandler from '../pointer/PointerEventHandler.js';
|
||||
* @param {olx.control.ZoomSliderOptions=} opt_options Zoom slider options.
|
||||
* @api
|
||||
*/
|
||||
var ZoomSlider = function(opt_options) {
|
||||
const ZoomSlider = function(opt_options) {
|
||||
|
||||
var options = opt_options ? opt_options : {};
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
/**
|
||||
* Will hold the current resolution of the view.
|
||||
@@ -100,11 +100,11 @@ var ZoomSlider = function(opt_options) {
|
||||
*/
|
||||
this.duration_ = options.duration !== undefined ? options.duration : 200;
|
||||
|
||||
var className = options.className !== undefined ? options.className : 'ol-zoomslider';
|
||||
var thumbElement = document.createElement('button');
|
||||
const className = options.className !== undefined ? options.className : 'ol-zoomslider';
|
||||
const thumbElement = document.createElement('button');
|
||||
thumbElement.setAttribute('type', 'button');
|
||||
thumbElement.className = className + '-thumb ' + CLASS_UNSELECTABLE;
|
||||
var containerElement = document.createElement('div');
|
||||
const containerElement = document.createElement('div');
|
||||
containerElement.className = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL;
|
||||
containerElement.appendChild(thumbElement);
|
||||
/**
|
||||
@@ -114,18 +114,18 @@ var ZoomSlider = function(opt_options) {
|
||||
this.dragger_ = new PointerEventHandler(containerElement);
|
||||
|
||||
_ol_events_.listen(this.dragger_, PointerEventType.POINTERDOWN,
|
||||
this.handleDraggerStart_, this);
|
||||
this.handleDraggerStart_, this);
|
||||
_ol_events_.listen(this.dragger_, PointerEventType.POINTERMOVE,
|
||||
this.handleDraggerDrag_, this);
|
||||
this.handleDraggerDrag_, this);
|
||||
_ol_events_.listen(this.dragger_, PointerEventType.POINTERUP,
|
||||
this.handleDraggerEnd_, this);
|
||||
this.handleDraggerEnd_, this);
|
||||
|
||||
_ol_events_.listen(containerElement, EventType.CLICK,
|
||||
this.handleContainerClick_, this);
|
||||
this.handleContainerClick_, this);
|
||||
_ol_events_.listen(thumbElement, EventType.CLICK,
|
||||
Event.stopPropagation);
|
||||
Event.stopPropagation);
|
||||
|
||||
var render = options.render ? options.render : ZoomSlider.render;
|
||||
const render = options.render ? options.render : ZoomSlider.render;
|
||||
|
||||
Control.call(this, {
|
||||
element: containerElement,
|
||||
@@ -176,17 +176,17 @@ ZoomSlider.prototype.setMap = function(map) {
|
||||
* @private
|
||||
*/
|
||||
ZoomSlider.prototype.initSlider_ = function() {
|
||||
var container = this.element;
|
||||
var containerSize = {
|
||||
const container = this.element;
|
||||
const containerSize = {
|
||||
width: container.offsetWidth, height: container.offsetHeight
|
||||
};
|
||||
|
||||
var thumb = container.firstElementChild;
|
||||
var computedStyle = getComputedStyle(thumb);
|
||||
var thumbWidth = thumb.offsetWidth +
|
||||
const thumb = container.firstElementChild;
|
||||
const computedStyle = getComputedStyle(thumb);
|
||||
const thumbWidth = thumb.offsetWidth +
|
||||
parseFloat(computedStyle['marginRight']) +
|
||||
parseFloat(computedStyle['marginLeft']);
|
||||
var thumbHeight = thumb.offsetHeight +
|
||||
const thumbHeight = thumb.offsetHeight +
|
||||
parseFloat(computedStyle['marginTop']) +
|
||||
parseFloat(computedStyle['marginBottom']);
|
||||
this.thumbSize_ = [thumbWidth, thumbHeight];
|
||||
@@ -215,7 +215,7 @@ ZoomSlider.render = function(mapEvent) {
|
||||
if (!this.sliderInitialized_) {
|
||||
this.initSlider_();
|
||||
}
|
||||
var res = mapEvent.frameState.viewState.resolution;
|
||||
const res = mapEvent.frameState.viewState.resolution;
|
||||
if (res !== this.currentResolution_) {
|
||||
this.currentResolution_ = res;
|
||||
this.setThumbPosition_(res);
|
||||
@@ -228,13 +228,13 @@ ZoomSlider.render = function(mapEvent) {
|
||||
* @private
|
||||
*/
|
||||
ZoomSlider.prototype.handleContainerClick_ = function(event) {
|
||||
var view = this.getMap().getView();
|
||||
const view = this.getMap().getView();
|
||||
|
||||
var relativePosition = this.getRelativePosition_(
|
||||
event.offsetX - this.thumbSize_[0] / 2,
|
||||
event.offsetY - this.thumbSize_[1] / 2);
|
||||
const relativePosition = this.getRelativePosition_(
|
||||
event.offsetX - this.thumbSize_[0] / 2,
|
||||
event.offsetY - this.thumbSize_[1] / 2);
|
||||
|
||||
var resolution = this.getResolutionForPosition_(relativePosition);
|
||||
const resolution = this.getResolutionForPosition_(relativePosition);
|
||||
|
||||
view.animate({
|
||||
resolution: view.constrainResolution(resolution),
|
||||
@@ -267,10 +267,10 @@ ZoomSlider.prototype.handleDraggerStart_ = function(event) {
|
||||
*/
|
||||
ZoomSlider.prototype.handleDraggerDrag_ = function(event) {
|
||||
if (this.dragging_) {
|
||||
var element = this.element.firstElementChild;
|
||||
var deltaX = event.clientX - this.previousX_ + parseInt(element.style.left, 10);
|
||||
var deltaY = event.clientY - this.previousY_ + parseInt(element.style.top, 10);
|
||||
var relativePosition = this.getRelativePosition_(deltaX, deltaY);
|
||||
const element = this.element.firstElementChild;
|
||||
const deltaX = event.clientX - this.previousX_ + parseInt(element.style.left, 10);
|
||||
const deltaY = event.clientY - this.previousY_ + parseInt(element.style.top, 10);
|
||||
const relativePosition = this.getRelativePosition_(deltaX, deltaY);
|
||||
this.currentResolution_ = this.getResolutionForPosition_(relativePosition);
|
||||
this.getMap().getView().setResolution(this.currentResolution_);
|
||||
this.setThumbPosition_(this.currentResolution_);
|
||||
@@ -287,7 +287,7 @@ ZoomSlider.prototype.handleDraggerDrag_ = function(event) {
|
||||
*/
|
||||
ZoomSlider.prototype.handleDraggerEnd_ = function(event) {
|
||||
if (this.dragging_) {
|
||||
var view = this.getMap().getView();
|
||||
const view = this.getMap().getView();
|
||||
view.setHint(ViewHint.INTERACTING, -1);
|
||||
|
||||
view.animate({
|
||||
@@ -310,8 +310,8 @@ ZoomSlider.prototype.handleDraggerEnd_ = function(event) {
|
||||
* @private
|
||||
*/
|
||||
ZoomSlider.prototype.setThumbPosition_ = function(res) {
|
||||
var position = this.getPositionForResolution_(res);
|
||||
var thumb = this.element.firstElementChild;
|
||||
const position = this.getPositionForResolution_(res);
|
||||
const thumb = this.element.firstElementChild;
|
||||
|
||||
if (this.direction_ == ZoomSlider.Direction_.HORIZONTAL) {
|
||||
thumb.style.left = this.widthLimit_ * position + 'px';
|
||||
@@ -332,7 +332,7 @@ ZoomSlider.prototype.setThumbPosition_ = function(res) {
|
||||
* @private
|
||||
*/
|
||||
ZoomSlider.prototype.getRelativePosition_ = function(x, y) {
|
||||
var amount;
|
||||
let amount;
|
||||
if (this.direction_ === ZoomSlider.Direction_.HORIZONTAL) {
|
||||
amount = x / this.widthLimit_;
|
||||
} else {
|
||||
@@ -351,7 +351,7 @@ ZoomSlider.prototype.getRelativePosition_ = function(x, y) {
|
||||
* @private
|
||||
*/
|
||||
ZoomSlider.prototype.getResolutionForPosition_ = function(position) {
|
||||
var fn = this.getMap().getView().getResolutionForValueFunction();
|
||||
const fn = this.getMap().getView().getResolutionForValueFunction();
|
||||
return fn(1 - position);
|
||||
};
|
||||
|
||||
@@ -366,7 +366,7 @@ ZoomSlider.prototype.getResolutionForPosition_ = function(position) {
|
||||
* @private
|
||||
*/
|
||||
ZoomSlider.prototype.getPositionForResolution_ = function(res) {
|
||||
var fn = this.getMap().getView().getValueForResolutionFunction();
|
||||
const fn = this.getMap().getView().getValueForResolutionFunction();
|
||||
return 1 - fn(res);
|
||||
};
|
||||
export default ZoomSlider;
|
||||
|
||||
@@ -17,8 +17,8 @@ import {CLASS_CONTROL, CLASS_UNSELECTABLE} from '../css.js';
|
||||
* @param {olx.control.ZoomToExtentOptions=} opt_options Options.
|
||||
* @api
|
||||
*/
|
||||
var ZoomToExtent = function(opt_options) {
|
||||
var options = opt_options ? opt_options : {};
|
||||
const ZoomToExtent = function(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
/**
|
||||
* @type {ol.Extent}
|
||||
@@ -26,24 +26,24 @@ var ZoomToExtent = function(opt_options) {
|
||||
*/
|
||||
this.extent = options.extent ? options.extent : null;
|
||||
|
||||
var className = options.className !== undefined ? options.className :
|
||||
const className = options.className !== undefined ? options.className :
|
||||
'ol-zoom-extent';
|
||||
|
||||
var label = options.label !== undefined ? options.label : 'E';
|
||||
var tipLabel = options.tipLabel !== undefined ?
|
||||
const label = options.label !== undefined ? options.label : 'E';
|
||||
const tipLabel = options.tipLabel !== undefined ?
|
||||
options.tipLabel : 'Fit to extent';
|
||||
var button = document.createElement('button');
|
||||
const button = document.createElement('button');
|
||||
button.setAttribute('type', 'button');
|
||||
button.title = tipLabel;
|
||||
button.appendChild(
|
||||
typeof label === 'string' ? document.createTextNode(label) : label
|
||||
typeof label === 'string' ? document.createTextNode(label) : label
|
||||
);
|
||||
|
||||
_ol_events_.listen(button, EventType.CLICK,
|
||||
this.handleClick_, this);
|
||||
this.handleClick_, this);
|
||||
|
||||
var cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL;
|
||||
var element = document.createElement('div');
|
||||
const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL;
|
||||
const element = document.createElement('div');
|
||||
element.className = cssClasses;
|
||||
element.appendChild(button);
|
||||
|
||||
@@ -70,9 +70,9 @@ ZoomToExtent.prototype.handleClick_ = function(event) {
|
||||
* @protected
|
||||
*/
|
||||
ZoomToExtent.prototype.handleZoomToExtent = function() {
|
||||
var map = this.getMap();
|
||||
var view = map.getView();
|
||||
var extent = !this.extent ? view.getProjection().getExtent() : this.extent;
|
||||
const map = this.getMap();
|
||||
const view = map.getView();
|
||||
const extent = !this.extent ? view.getProjection().getExtent() : this.extent;
|
||||
view.fit(extent);
|
||||
};
|
||||
export default ZoomToExtent;
|
||||
|
||||
+42
-44
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {modulo} from './math.js';
|
||||
import _ol_string_ from './string.js';
|
||||
var _ol_coordinate_ = {};
|
||||
const _ol_coordinate_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -36,24 +36,22 @@ _ol_coordinate_.add = function(coordinate, delta) {
|
||||
* @return {ol.Coordinate} Closest point on the circumference
|
||||
*/
|
||||
_ol_coordinate_.closestOnCircle = function(coordinate, circle) {
|
||||
var r = circle.getRadius();
|
||||
var center = circle.getCenter();
|
||||
var x0 = center[0];
|
||||
var y0 = center[1];
|
||||
var x1 = coordinate[0];
|
||||
var y1 = coordinate[1];
|
||||
const r = circle.getRadius();
|
||||
const center = circle.getCenter();
|
||||
const x0 = center[0];
|
||||
const y0 = center[1];
|
||||
const x1 = coordinate[0];
|
||||
const y1 = coordinate[1];
|
||||
|
||||
var dx = x1 - x0;
|
||||
var dy = y1 - y0;
|
||||
let dx = x1 - x0;
|
||||
const dy = y1 - y0;
|
||||
if (dx === 0 && dy === 0) {
|
||||
dx = 1;
|
||||
}
|
||||
var d = Math.sqrt(dx * dx + dy * dy);
|
||||
const d = Math.sqrt(dx * dx + dy * dy);
|
||||
|
||||
var x, y;
|
||||
|
||||
x = x0 + r * dx / d;
|
||||
y = y0 + r * dy / d;
|
||||
const x = x0 + r * dx / d;
|
||||
const y = y0 + r * dy / d;
|
||||
|
||||
return [x, y];
|
||||
};
|
||||
@@ -71,19 +69,19 @@ _ol_coordinate_.closestOnCircle = function(coordinate, circle) {
|
||||
* the segment.
|
||||
*/
|
||||
_ol_coordinate_.closestOnSegment = function(coordinate, segment) {
|
||||
var x0 = coordinate[0];
|
||||
var y0 = coordinate[1];
|
||||
var start = segment[0];
|
||||
var end = segment[1];
|
||||
var x1 = start[0];
|
||||
var y1 = start[1];
|
||||
var x2 = end[0];
|
||||
var y2 = end[1];
|
||||
var dx = x2 - x1;
|
||||
var dy = y2 - y1;
|
||||
var along = (dx === 0 && dy === 0) ? 0 :
|
||||
const x0 = coordinate[0];
|
||||
const y0 = coordinate[1];
|
||||
const start = segment[0];
|
||||
const end = segment[1];
|
||||
const x1 = start[0];
|
||||
const y1 = start[1];
|
||||
const x2 = end[0];
|
||||
const y2 = end[1];
|
||||
const dx = x2 - x1;
|
||||
const dy = y2 - y1;
|
||||
const along = (dx === 0 && dy === 0) ? 0 :
|
||||
((dx * (x0 - x1)) + (dy * (y0 - y1))) / ((dx * dx + dy * dy) || 0);
|
||||
var x, y;
|
||||
let x, y;
|
||||
if (along <= 0) {
|
||||
x = x1;
|
||||
y = y1;
|
||||
@@ -142,14 +140,14 @@ _ol_coordinate_.createStringXY = function(opt_fractionDigits) {
|
||||
* @return {string} String.
|
||||
*/
|
||||
_ol_coordinate_.degreesToStringHDMS = function(hemispheres, degrees, opt_fractionDigits) {
|
||||
var normalizedDegrees = modulo(degrees + 180, 360) - 180;
|
||||
var x = Math.abs(3600 * normalizedDegrees);
|
||||
var dflPrecision = opt_fractionDigits || 0;
|
||||
var precision = Math.pow(10, dflPrecision);
|
||||
const normalizedDegrees = modulo(degrees + 180, 360) - 180;
|
||||
const x = Math.abs(3600 * normalizedDegrees);
|
||||
const dflPrecision = opt_fractionDigits || 0;
|
||||
const precision = Math.pow(10, dflPrecision);
|
||||
|
||||
var deg = Math.floor(x / 3600);
|
||||
var min = Math.floor((x - deg * 3600) / 60);
|
||||
var sec = x - (deg * 3600) - (min * 60);
|
||||
let deg = Math.floor(x / 3600);
|
||||
let min = Math.floor((x - deg * 3600) / 60);
|
||||
let sec = x - (deg * 3600) - (min * 60);
|
||||
sec = Math.ceil(sec * precision) / precision;
|
||||
|
||||
if (sec >= 60) {
|
||||
@@ -198,8 +196,8 @@ _ol_coordinate_.degreesToStringHDMS = function(hemispheres, degrees, opt_fractio
|
||||
_ol_coordinate_.format = function(coordinate, template, opt_fractionDigits) {
|
||||
if (coordinate) {
|
||||
return template
|
||||
.replace('{x}', coordinate[0].toFixed(opt_fractionDigits))
|
||||
.replace('{y}', coordinate[1].toFixed(opt_fractionDigits));
|
||||
.replace('{x}', coordinate[0].toFixed(opt_fractionDigits))
|
||||
.replace('{y}', coordinate[1].toFixed(opt_fractionDigits));
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
@@ -212,8 +210,8 @@ _ol_coordinate_.format = function(coordinate, template, opt_fractionDigits) {
|
||||
* @return {boolean} Whether the passed coordinates are equal.
|
||||
*/
|
||||
_ol_coordinate_.equals = function(coordinate1, coordinate2) {
|
||||
var equals = true;
|
||||
for (var i = coordinate1.length - 1; i >= 0; --i) {
|
||||
let equals = true;
|
||||
for (let i = coordinate1.length - 1; i >= 0; --i) {
|
||||
if (coordinate1[i] != coordinate2[i]) {
|
||||
equals = false;
|
||||
break;
|
||||
@@ -240,10 +238,10 @@ _ol_coordinate_.equals = function(coordinate1, coordinate2) {
|
||||
* @api
|
||||
*/
|
||||
_ol_coordinate_.rotate = function(coordinate, angle) {
|
||||
var cosAngle = Math.cos(angle);
|
||||
var sinAngle = Math.sin(angle);
|
||||
var x = coordinate[0] * cosAngle - coordinate[1] * sinAngle;
|
||||
var y = coordinate[1] * cosAngle + coordinate[0] * sinAngle;
|
||||
const cosAngle = Math.cos(angle);
|
||||
const sinAngle = Math.sin(angle);
|
||||
const x = coordinate[0] * cosAngle - coordinate[1] * sinAngle;
|
||||
const y = coordinate[1] * cosAngle + coordinate[0] * sinAngle;
|
||||
coordinate[0] = x;
|
||||
coordinate[1] = y;
|
||||
return coordinate;
|
||||
@@ -293,8 +291,8 @@ _ol_coordinate_.sub = function(coordinate, delta) {
|
||||
* @return {number} Squared distance between coord1 and coord2.
|
||||
*/
|
||||
_ol_coordinate_.squaredDistance = function(coord1, coord2) {
|
||||
var dx = coord1[0] - coord2[0];
|
||||
var dy = coord1[1] - coord2[1];
|
||||
const dx = coord1[0] - coord2[0];
|
||||
const dy = coord1[1] - coord2[1];
|
||||
return dx * dx + dy * dy;
|
||||
};
|
||||
|
||||
@@ -318,7 +316,7 @@ _ol_coordinate_.distance = function(coord1, coord2) {
|
||||
*/
|
||||
_ol_coordinate_.squaredDistanceToSegment = function(coordinate, segment) {
|
||||
return _ol_coordinate_.squaredDistance(coordinate,
|
||||
_ol_coordinate_.closestOnSegment(coordinate, segment));
|
||||
_ol_coordinate_.closestOnSegment(coordinate, segment));
|
||||
};
|
||||
|
||||
|
||||
|
||||
+9
-9
@@ -9,7 +9,7 @@
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
export var CLASS_HIDDEN = 'ol-hidden';
|
||||
export const CLASS_HIDDEN = 'ol-hidden';
|
||||
|
||||
|
||||
/**
|
||||
@@ -18,7 +18,7 @@ export var CLASS_HIDDEN = 'ol-hidden';
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
export var CLASS_SELECTABLE = 'ol-selectable';
|
||||
export const CLASS_SELECTABLE = 'ol-selectable';
|
||||
|
||||
|
||||
/**
|
||||
@@ -27,7 +27,7 @@ export var CLASS_SELECTABLE = 'ol-selectable';
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
export var CLASS_UNSELECTABLE = 'ol-unselectable';
|
||||
export const CLASS_UNSELECTABLE = 'ol-unselectable';
|
||||
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ export var CLASS_UNSELECTABLE = 'ol-unselectable';
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
export var CLASS_UNSUPPORTED = 'ol-unsupported';
|
||||
export const CLASS_UNSUPPORTED = 'ol-unsupported';
|
||||
|
||||
|
||||
/**
|
||||
@@ -45,7 +45,7 @@ export var CLASS_UNSUPPORTED = 'ol-unsupported';
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
export var CLASS_CONTROL = 'ol-control';
|
||||
export const CLASS_CONTROL = 'ol-control';
|
||||
|
||||
|
||||
/**
|
||||
@@ -54,16 +54,16 @@ export var CLASS_CONTROL = 'ol-control';
|
||||
* @param {string} The CSS font property.
|
||||
* @return {Object.<string>} The font families (or null if the input spec is invalid).
|
||||
*/
|
||||
export var getFontFamilies = (function() {
|
||||
var style;
|
||||
var cache = {};
|
||||
export const getFontFamilies = (function() {
|
||||
let style;
|
||||
const cache = {};
|
||||
return function(font) {
|
||||
if (!style) {
|
||||
style = document.createElement('div').style;
|
||||
}
|
||||
if (!(font in cache)) {
|
||||
style.font = font;
|
||||
var family = style.fontFamily;
|
||||
const family = style.fontFamily;
|
||||
style.font = '';
|
||||
if (!family) {
|
||||
return null;
|
||||
|
||||
+6
-6
@@ -10,7 +10,7 @@
|
||||
* @return {CanvasRenderingContext2D} The context.
|
||||
*/
|
||||
export function createCanvasContext2D(opt_width, opt_height) {
|
||||
var canvas = document.createElement('CANVAS');
|
||||
const canvas = document.createElement('CANVAS');
|
||||
if (opt_width) {
|
||||
canvas.width = opt_width;
|
||||
}
|
||||
@@ -29,8 +29,8 @@ export function createCanvasContext2D(opt_width, opt_height) {
|
||||
* @return {number} The width.
|
||||
*/
|
||||
export function outerWidth(element) {
|
||||
var width = element.offsetWidth;
|
||||
var style = getComputedStyle(element);
|
||||
let width = element.offsetWidth;
|
||||
const style = getComputedStyle(element);
|
||||
width += parseInt(style.marginLeft, 10) + parseInt(style.marginRight, 10);
|
||||
|
||||
return width;
|
||||
@@ -45,8 +45,8 @@ export function outerWidth(element) {
|
||||
* @return {number} The height.
|
||||
*/
|
||||
export function outerHeight(element) {
|
||||
var height = element.offsetHeight;
|
||||
var style = getComputedStyle(element);
|
||||
let height = element.offsetHeight;
|
||||
const style = getComputedStyle(element);
|
||||
height += parseInt(style.marginTop, 10) + parseInt(style.marginBottom, 10);
|
||||
|
||||
return height;
|
||||
@@ -57,7 +57,7 @@ export function outerHeight(element) {
|
||||
* @param {Node} oldNode The node to be replaced
|
||||
*/
|
||||
export function replaceNode(newNode, oldNode) {
|
||||
var parent = oldNode.parentNode;
|
||||
const parent = oldNode.parentNode;
|
||||
if (parent) {
|
||||
parent.replaceChild(newNode, oldNode);
|
||||
}
|
||||
|
||||
+23
-23
@@ -2,7 +2,7 @@
|
||||
* @module ol/events
|
||||
*/
|
||||
import _ol_obj_ from './obj.js';
|
||||
var _ol_events_ = {};
|
||||
const _ol_events_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -10,9 +10,9 @@ var _ol_events_ = {};
|
||||
* @return {ol.EventsListenerFunctionType} Bound listener.
|
||||
*/
|
||||
_ol_events_.bindListener_ = function(listenerObj) {
|
||||
var boundListener = function(evt) {
|
||||
var listener = listenerObj.listener;
|
||||
var bindTo = listenerObj.bindTo || listenerObj.target;
|
||||
const boundListener = function(evt) {
|
||||
const listener = listenerObj.listener;
|
||||
const bindTo = listenerObj.bindTo || listenerObj.target;
|
||||
if (listenerObj.callOnce) {
|
||||
_ol_events_.unlistenByKey(listenerObj);
|
||||
}
|
||||
@@ -36,9 +36,9 @@ _ol_events_.bindListener_ = function(listenerObj) {
|
||||
* @private
|
||||
*/
|
||||
_ol_events_.findListener_ = function(listeners, listener, opt_this,
|
||||
opt_setDeleteIndex) {
|
||||
var listenerObj;
|
||||
for (var i = 0, ii = listeners.length; i < ii; ++i) {
|
||||
opt_setDeleteIndex) {
|
||||
let listenerObj;
|
||||
for (let i = 0, ii = listeners.length; i < ii; ++i) {
|
||||
listenerObj = listeners[i];
|
||||
if (listenerObj.listener === listener &&
|
||||
listenerObj.bindTo === opt_this) {
|
||||
@@ -58,7 +58,7 @@ _ol_events_.findListener_ = function(listeners, listener, opt_this,
|
||||
* @return {Array.<ol.EventsKey>|undefined} Listeners.
|
||||
*/
|
||||
_ol_events_.getListeners = function(target, type) {
|
||||
var listenerMap = target.ol_lm;
|
||||
const listenerMap = target.ol_lm;
|
||||
return listenerMap ? listenerMap[type] : undefined;
|
||||
};
|
||||
|
||||
@@ -72,7 +72,7 @@ _ol_events_.getListeners = function(target, type) {
|
||||
* @private
|
||||
*/
|
||||
_ol_events_.getListenerMap_ = function(target) {
|
||||
var listenerMap = target.ol_lm;
|
||||
let listenerMap = target.ol_lm;
|
||||
if (!listenerMap) {
|
||||
listenerMap = target.ol_lm = {};
|
||||
}
|
||||
@@ -89,14 +89,14 @@ _ol_events_.getListenerMap_ = function(target) {
|
||||
* @private
|
||||
*/
|
||||
_ol_events_.removeListeners_ = function(target, type) {
|
||||
var listeners = _ol_events_.getListeners(target, type);
|
||||
const listeners = _ol_events_.getListeners(target, type);
|
||||
if (listeners) {
|
||||
for (var i = 0, ii = listeners.length; i < ii; ++i) {
|
||||
for (let i = 0, ii = listeners.length; i < ii; ++i) {
|
||||
target.removeEventListener(type, listeners[i].boundListener);
|
||||
_ol_obj_.clear(listeners[i]);
|
||||
}
|
||||
listeners.length = 0;
|
||||
var listenerMap = target.ol_lm;
|
||||
const listenerMap = target.ol_lm;
|
||||
if (listenerMap) {
|
||||
delete listenerMap[type];
|
||||
if (Object.keys(listenerMap).length === 0) {
|
||||
@@ -123,13 +123,13 @@ _ol_events_.removeListeners_ = function(target, type) {
|
||||
* @return {ol.EventsKey} Unique key for the listener.
|
||||
*/
|
||||
_ol_events_.listen = function(target, type, listener, opt_this, opt_once) {
|
||||
var listenerMap = _ol_events_.getListenerMap_(target);
|
||||
var listeners = listenerMap[type];
|
||||
const listenerMap = _ol_events_.getListenerMap_(target);
|
||||
let listeners = listenerMap[type];
|
||||
if (!listeners) {
|
||||
listeners = listenerMap[type] = [];
|
||||
}
|
||||
var listenerObj = _ol_events_.findListener_(listeners, listener, opt_this,
|
||||
false);
|
||||
let listenerObj = _ol_events_.findListener_(listeners, listener, opt_this,
|
||||
false);
|
||||
if (listenerObj) {
|
||||
if (!opt_once) {
|
||||
// Turn one-off listener into a permanent one.
|
||||
@@ -190,10 +190,10 @@ _ol_events_.listenOnce = function(target, type, listener, opt_this) {
|
||||
* listener. Default is the `target`.
|
||||
*/
|
||||
_ol_events_.unlisten = function(target, type, listener, opt_this) {
|
||||
var listeners = _ol_events_.getListeners(target, type);
|
||||
const listeners = _ol_events_.getListeners(target, type);
|
||||
if (listeners) {
|
||||
var listenerObj = _ol_events_.findListener_(listeners, listener, opt_this,
|
||||
true);
|
||||
const listenerObj = _ol_events_.findListener_(listeners, listener, opt_this,
|
||||
true);
|
||||
if (listenerObj) {
|
||||
_ol_events_.unlistenByKey(listenerObj);
|
||||
}
|
||||
@@ -213,9 +213,9 @@ _ol_events_.unlisten = function(target, type, listener, opt_this) {
|
||||
_ol_events_.unlistenByKey = function(key) {
|
||||
if (key && key.target) {
|
||||
key.target.removeEventListener(key.type, key.boundListener);
|
||||
var listeners = _ol_events_.getListeners(key.target, key.type);
|
||||
const listeners = _ol_events_.getListeners(key.target, key.type);
|
||||
if (listeners) {
|
||||
var i = 'deleteIndex' in key ? key.deleteIndex : listeners.indexOf(key);
|
||||
const i = 'deleteIndex' in key ? key.deleteIndex : listeners.indexOf(key);
|
||||
if (i !== -1) {
|
||||
listeners.splice(i, 1);
|
||||
}
|
||||
@@ -235,8 +235,8 @@ _ol_events_.unlistenByKey = function(key) {
|
||||
* @param {ol.EventTargetLike} target Target.
|
||||
*/
|
||||
_ol_events_.unlistenAll = function(target) {
|
||||
var listenerMap = _ol_events_.getListenerMap_(target);
|
||||
for (var type in listenerMap) {
|
||||
const listenerMap = _ol_events_.getListenerMap_(target);
|
||||
for (const type in listenerMap) {
|
||||
_ol_events_.removeListeners_(target, type);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* @implements {oli.events.Event}
|
||||
* @param {string} type Type.
|
||||
*/
|
||||
var Event = function(type) {
|
||||
const Event = function(type) {
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
|
||||
@@ -24,7 +24,7 @@ import Event from '../events/Event.js';
|
||||
* @constructor
|
||||
* @extends {ol.Disposable}
|
||||
*/
|
||||
var EventTarget = function() {
|
||||
const EventTarget = function() {
|
||||
|
||||
Disposable.call(this);
|
||||
|
||||
@@ -56,7 +56,7 @@ inherits(EventTarget, Disposable);
|
||||
* @param {ol.EventsListenerFunctionType} listener Listener.
|
||||
*/
|
||||
EventTarget.prototype.addEventListener = function(type, listener) {
|
||||
var listeners = this.listeners_[type];
|
||||
let listeners = this.listeners_[type];
|
||||
if (!listeners) {
|
||||
listeners = this.listeners_[type] = [];
|
||||
}
|
||||
@@ -74,18 +74,18 @@ EventTarget.prototype.addEventListener = function(type, listener) {
|
||||
* event object or if any of the listeners returned false.
|
||||
*/
|
||||
EventTarget.prototype.dispatchEvent = function(event) {
|
||||
var evt = typeof event === 'string' ? new Event(event) : event;
|
||||
var type = evt.type;
|
||||
const evt = typeof event === 'string' ? new Event(event) : event;
|
||||
const type = evt.type;
|
||||
evt.target = this;
|
||||
var listeners = this.listeners_[type];
|
||||
var propagate;
|
||||
const listeners = this.listeners_[type];
|
||||
let propagate;
|
||||
if (listeners) {
|
||||
if (!(type in this.dispatching_)) {
|
||||
this.dispatching_[type] = 0;
|
||||
this.pendingRemovals_[type] = 0;
|
||||
}
|
||||
++this.dispatching_[type];
|
||||
for (var i = 0, ii = listeners.length; i < ii; ++i) {
|
||||
for (let i = 0, ii = listeners.length; i < ii; ++i) {
|
||||
if (listeners[i].call(this, evt) === false || evt.propagationStopped) {
|
||||
propagate = false;
|
||||
break;
|
||||
@@ -93,7 +93,7 @@ EventTarget.prototype.dispatchEvent = function(event) {
|
||||
}
|
||||
--this.dispatching_[type];
|
||||
if (this.dispatching_[type] === 0) {
|
||||
var pendingRemovals = this.pendingRemovals_[type];
|
||||
let pendingRemovals = this.pendingRemovals_[type];
|
||||
delete this.pendingRemovals_[type];
|
||||
while (pendingRemovals--) {
|
||||
this.removeEventListener(type, nullFunction);
|
||||
@@ -142,9 +142,9 @@ EventTarget.prototype.hasListener = function(opt_type) {
|
||||
* @param {ol.EventsListenerFunctionType} listener Listener.
|
||||
*/
|
||||
EventTarget.prototype.removeEventListener = function(type, listener) {
|
||||
var listeners = this.listeners_[type];
|
||||
const listeners = this.listeners_[type];
|
||||
if (listeners) {
|
||||
var index = listeners.indexOf(listener);
|
||||
const index = listeners.indexOf(listener);
|
||||
if (type in this.pendingRemovals_) {
|
||||
// make listener a no-op, and remove later in #dispatchEvent()
|
||||
listeners[index] = nullFunction;
|
||||
|
||||
+10
-10
@@ -5,7 +5,7 @@ import MapBrowserEventType from '../MapBrowserEventType.js';
|
||||
import {assert} from '../asserts.js';
|
||||
import {TRUE, FALSE} from '../functions.js';
|
||||
import _ol_has_ from '../has.js';
|
||||
var _ol_events_condition_ = {};
|
||||
const _ol_events_condition_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -17,7 +17,7 @@ var _ol_events_condition_ = {};
|
||||
* @api
|
||||
*/
|
||||
_ol_events_condition_.altKeyOnly = function(mapBrowserEvent) {
|
||||
var originalEvent = mapBrowserEvent.originalEvent;
|
||||
const originalEvent = mapBrowserEvent.originalEvent;
|
||||
return (
|
||||
originalEvent.altKey &&
|
||||
!(originalEvent.metaKey || originalEvent.ctrlKey) &&
|
||||
@@ -34,7 +34,7 @@ _ol_events_condition_.altKeyOnly = function(mapBrowserEvent) {
|
||||
* @api
|
||||
*/
|
||||
_ol_events_condition_.altShiftKeysOnly = function(mapBrowserEvent) {
|
||||
var originalEvent = mapBrowserEvent.originalEvent;
|
||||
const originalEvent = mapBrowserEvent.originalEvent;
|
||||
return (
|
||||
originalEvent.altKey &&
|
||||
!(originalEvent.metaKey || originalEvent.ctrlKey) &&
|
||||
@@ -75,7 +75,7 @@ _ol_events_condition_.click = function(mapBrowserEvent) {
|
||||
* @return {boolean} The result.
|
||||
*/
|
||||
_ol_events_condition_.mouseActionButton = function(mapBrowserEvent) {
|
||||
var originalEvent = mapBrowserEvent.originalEvent;
|
||||
const originalEvent = mapBrowserEvent.originalEvent;
|
||||
return originalEvent.button == 0 &&
|
||||
!(_ol_has_.WEBKIT && _ol_has_.MAC && originalEvent.ctrlKey);
|
||||
};
|
||||
@@ -138,7 +138,7 @@ _ol_events_condition_.doubleClick = function(mapBrowserEvent) {
|
||||
* @api
|
||||
*/
|
||||
_ol_events_condition_.noModifierKeys = function(mapBrowserEvent) {
|
||||
var originalEvent = mapBrowserEvent.originalEvent;
|
||||
const originalEvent = mapBrowserEvent.originalEvent;
|
||||
return (
|
||||
!originalEvent.altKey &&
|
||||
!(originalEvent.metaKey || originalEvent.ctrlKey) &&
|
||||
@@ -156,7 +156,7 @@ _ol_events_condition_.noModifierKeys = function(mapBrowserEvent) {
|
||||
* @api
|
||||
*/
|
||||
_ol_events_condition_.platformModifierKeyOnly = function(mapBrowserEvent) {
|
||||
var originalEvent = mapBrowserEvent.originalEvent;
|
||||
const originalEvent = mapBrowserEvent.originalEvent;
|
||||
return !originalEvent.altKey &&
|
||||
(_ol_has_.MAC ? originalEvent.metaKey : originalEvent.ctrlKey) &&
|
||||
!originalEvent.shiftKey;
|
||||
@@ -172,7 +172,7 @@ _ol_events_condition_.platformModifierKeyOnly = function(mapBrowserEvent) {
|
||||
* @api
|
||||
*/
|
||||
_ol_events_condition_.shiftKeyOnly = function(mapBrowserEvent) {
|
||||
var originalEvent = mapBrowserEvent.originalEvent;
|
||||
const originalEvent = mapBrowserEvent.originalEvent;
|
||||
return (
|
||||
!originalEvent.altKey &&
|
||||
!(originalEvent.metaKey || originalEvent.ctrlKey) &&
|
||||
@@ -189,8 +189,8 @@ _ol_events_condition_.shiftKeyOnly = function(mapBrowserEvent) {
|
||||
* @api
|
||||
*/
|
||||
_ol_events_condition_.targetNotEditable = function(mapBrowserEvent) {
|
||||
var target = mapBrowserEvent.originalEvent.target;
|
||||
var tagName = target.tagName;
|
||||
const target = mapBrowserEvent.originalEvent.target;
|
||||
const tagName = target.tagName;
|
||||
return (
|
||||
tagName !== 'INPUT' &&
|
||||
tagName !== 'SELECT' &&
|
||||
@@ -222,7 +222,7 @@ _ol_events_condition_.mouseOnly = function(mapBrowserEvent) {
|
||||
* @api
|
||||
*/
|
||||
_ol_events_condition_.primaryAction = function(mapBrowserEvent) {
|
||||
var pointerEvent = mapBrowserEvent.pointerEvent;
|
||||
const pointerEvent = mapBrowserEvent.pointerEvent;
|
||||
return pointerEvent.isPrimary && pointerEvent.button === 0;
|
||||
};
|
||||
export default _ol_events_condition_;
|
||||
|
||||
+70
-70
@@ -14,8 +14,8 @@ import Relationship from './extent/Relationship.js';
|
||||
* @api
|
||||
*/
|
||||
export function boundingExtent(coordinates) {
|
||||
var extent = createEmpty();
|
||||
for (var i = 0, ii = coordinates.length; i < ii; ++i) {
|
||||
const extent = createEmpty();
|
||||
for (let i = 0, ii = coordinates.length; i < ii; ++i) {
|
||||
extendCoordinate(extent, coordinates[i]);
|
||||
}
|
||||
return extent;
|
||||
@@ -30,10 +30,10 @@ export function boundingExtent(coordinates) {
|
||||
* @return {ol.Extent} Extent.
|
||||
*/
|
||||
function _boundingExtentXYs(xs, ys, opt_extent) {
|
||||
var minX = Math.min.apply(null, xs);
|
||||
var minY = Math.min.apply(null, ys);
|
||||
var maxX = Math.max.apply(null, xs);
|
||||
var maxY = Math.max.apply(null, ys);
|
||||
const minX = Math.min.apply(null, xs);
|
||||
const minY = Math.min.apply(null, ys);
|
||||
const maxX = Math.max.apply(null, xs);
|
||||
const maxY = Math.max.apply(null, ys);
|
||||
return createOrUpdate(minX, minY, maxX, maxY, opt_extent);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ export function clone(extent, opt_extent) {
|
||||
* @return {number} Closest squared distance.
|
||||
*/
|
||||
export function closestSquaredDistanceXY(extent, x, y) {
|
||||
var dx, dy;
|
||||
let dx, dy;
|
||||
if (x < extent[0]) {
|
||||
dx = extent[0] - x;
|
||||
} else if (extent[2] < x) {
|
||||
@@ -163,13 +163,13 @@ export function containsXY(extent, x, y) {
|
||||
* ol.extent.Relationship).
|
||||
*/
|
||||
export function coordinateRelationship(extent, coordinate) {
|
||||
var minX = extent[0];
|
||||
var minY = extent[1];
|
||||
var maxX = extent[2];
|
||||
var maxY = extent[3];
|
||||
var x = coordinate[0];
|
||||
var y = coordinate[1];
|
||||
var relationship = Relationship.UNKNOWN;
|
||||
const minX = extent[0];
|
||||
const minY = extent[1];
|
||||
const maxX = extent[2];
|
||||
const maxY = extent[3];
|
||||
const x = coordinate[0];
|
||||
const y = coordinate[1];
|
||||
let relationship = Relationship.UNKNOWN;
|
||||
if (x < minX) {
|
||||
relationship = relationship | Relationship.LEFT;
|
||||
} else if (x > maxX) {
|
||||
@@ -226,7 +226,7 @@ export function createOrUpdate(minX, minY, maxX, maxY, opt_extent) {
|
||||
*/
|
||||
export function createOrUpdateEmpty(opt_extent) {
|
||||
return createOrUpdate(
|
||||
Infinity, Infinity, -Infinity, -Infinity, opt_extent);
|
||||
Infinity, Infinity, -Infinity, -Infinity, opt_extent);
|
||||
}
|
||||
|
||||
|
||||
@@ -236,8 +236,8 @@ export function createOrUpdateEmpty(opt_extent) {
|
||||
* @return {ol.Extent} Extent.
|
||||
*/
|
||||
export function createOrUpdateFromCoordinate(coordinate, opt_extent) {
|
||||
var x = coordinate[0];
|
||||
var y = coordinate[1];
|
||||
const x = coordinate[0];
|
||||
const y = coordinate[1];
|
||||
return createOrUpdate(x, y, x, y, opt_extent);
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ export function createOrUpdateFromCoordinate(coordinate, opt_extent) {
|
||||
* @return {ol.Extent} Extent.
|
||||
*/
|
||||
export function createOrUpdateFromCoordinates(coordinates, opt_extent) {
|
||||
var extent = createOrUpdateEmpty(opt_extent);
|
||||
const extent = createOrUpdateEmpty(opt_extent);
|
||||
return extendCoordinates(extent, coordinates);
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ export function createOrUpdateFromCoordinates(coordinates, opt_extent) {
|
||||
* @return {ol.Extent} Extent.
|
||||
*/
|
||||
export function createOrUpdateFromFlatCoordinates(flatCoordinates, offset, end, stride, opt_extent) {
|
||||
var extent = createOrUpdateEmpty(opt_extent);
|
||||
const extent = createOrUpdateEmpty(opt_extent);
|
||||
return extendFlatCoordinates(extent, flatCoordinates, offset, end, stride);
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ export function createOrUpdateFromFlatCoordinates(flatCoordinates, offset, end,
|
||||
* @return {ol.Extent} Extent.
|
||||
*/
|
||||
export function createOrUpdateFromRings(rings, opt_extent) {
|
||||
var extent = createOrUpdateEmpty(opt_extent);
|
||||
const extent = createOrUpdateEmpty(opt_extent);
|
||||
return extendRings(extent, rings);
|
||||
}
|
||||
|
||||
@@ -340,7 +340,7 @@ export function extendCoordinate(extent, coordinate) {
|
||||
* @return {ol.Extent} Extent.
|
||||
*/
|
||||
export function extendCoordinates(extent, coordinates) {
|
||||
var i, ii;
|
||||
let i, ii;
|
||||
for (i = 0, ii = coordinates.length; i < ii; ++i) {
|
||||
extendCoordinate(extent, coordinates[i]);
|
||||
}
|
||||
@@ -370,7 +370,7 @@ export function extendFlatCoordinates(extent, flatCoordinates, offset, end, stri
|
||||
* @return {ol.Extent} Extent.
|
||||
*/
|
||||
export function extendRings(extent, rings) {
|
||||
var i, ii;
|
||||
let i, ii;
|
||||
for (i = 0, ii = rings.length; i < ii; ++i) {
|
||||
extendCoordinates(extent, rings[i]);
|
||||
}
|
||||
@@ -402,7 +402,7 @@ export function extendXY(extent, x, y) {
|
||||
* @template S, T
|
||||
*/
|
||||
export function forEachCorner(extent, callback, opt_this) {
|
||||
var val;
|
||||
let val;
|
||||
val = callback.call(opt_this, getBottomLeft(extent));
|
||||
if (val) {
|
||||
return val;
|
||||
@@ -430,7 +430,7 @@ export function forEachCorner(extent, callback, opt_this) {
|
||||
* @api
|
||||
*/
|
||||
export function getArea(extent) {
|
||||
var area = 0;
|
||||
let area = 0;
|
||||
if (!isEmpty(extent)) {
|
||||
area = getWidth(extent) * getHeight(extent);
|
||||
}
|
||||
@@ -478,7 +478,7 @@ export function getCenter(extent) {
|
||||
* @return {ol.Coordinate} Corner coordinate.
|
||||
*/
|
||||
export function getCorner(extent, corner) {
|
||||
var coordinate;
|
||||
let coordinate;
|
||||
if (corner === Corner.BOTTOM_LEFT) {
|
||||
coordinate = getBottomLeft(extent);
|
||||
} else if (corner === Corner.BOTTOM_RIGHT) {
|
||||
@@ -500,10 +500,10 @@ export function getCorner(extent, corner) {
|
||||
* @return {number} Enlarged area.
|
||||
*/
|
||||
export function getEnlargedArea(extent1, extent2) {
|
||||
var minX = Math.min(extent1[0], extent2[0]);
|
||||
var minY = Math.min(extent1[1], extent2[1]);
|
||||
var maxX = Math.max(extent1[2], extent2[2]);
|
||||
var maxY = Math.max(extent1[3], extent2[3]);
|
||||
const minX = Math.min(extent1[0], extent2[0]);
|
||||
const minY = Math.min(extent1[1], extent2[1]);
|
||||
const maxX = Math.max(extent1[2], extent2[2]);
|
||||
const maxY = Math.max(extent1[3], extent2[3]);
|
||||
return (maxX - minX) * (maxY - minY);
|
||||
}
|
||||
|
||||
@@ -517,28 +517,28 @@ export function getEnlargedArea(extent1, extent2) {
|
||||
* @return {ol.Extent} Extent.
|
||||
*/
|
||||
export function getForViewAndSize(center, resolution, rotation, size, opt_extent) {
|
||||
var dx = resolution * size[0] / 2;
|
||||
var dy = resolution * size[1] / 2;
|
||||
var cosRotation = Math.cos(rotation);
|
||||
var sinRotation = Math.sin(rotation);
|
||||
var xCos = dx * cosRotation;
|
||||
var xSin = dx * sinRotation;
|
||||
var yCos = dy * cosRotation;
|
||||
var ySin = dy * sinRotation;
|
||||
var x = center[0];
|
||||
var y = center[1];
|
||||
var x0 = x - xCos + ySin;
|
||||
var x1 = x - xCos - ySin;
|
||||
var x2 = x + xCos - ySin;
|
||||
var x3 = x + xCos + ySin;
|
||||
var y0 = y - xSin - yCos;
|
||||
var y1 = y - xSin + yCos;
|
||||
var y2 = y + xSin + yCos;
|
||||
var y3 = y + xSin - yCos;
|
||||
const dx = resolution * size[0] / 2;
|
||||
const dy = resolution * size[1] / 2;
|
||||
const cosRotation = Math.cos(rotation);
|
||||
const sinRotation = Math.sin(rotation);
|
||||
const xCos = dx * cosRotation;
|
||||
const xSin = dx * sinRotation;
|
||||
const yCos = dy * cosRotation;
|
||||
const ySin = dy * sinRotation;
|
||||
const x = center[0];
|
||||
const y = center[1];
|
||||
const x0 = x - xCos + ySin;
|
||||
const x1 = x - xCos - ySin;
|
||||
const x2 = x + xCos - ySin;
|
||||
const x3 = x + xCos + ySin;
|
||||
const y0 = y - xSin - yCos;
|
||||
const y1 = y - xSin + yCos;
|
||||
const y2 = y + xSin + yCos;
|
||||
const y3 = y + xSin - yCos;
|
||||
return createOrUpdate(
|
||||
Math.min(x0, x1, x2, x3), Math.min(y0, y1, y2, y3),
|
||||
Math.max(x0, x1, x2, x3), Math.max(y0, y1, y2, y3),
|
||||
opt_extent);
|
||||
Math.min(x0, x1, x2, x3), Math.min(y0, y1, y2, y3),
|
||||
Math.max(x0, x1, x2, x3), Math.max(y0, y1, y2, y3),
|
||||
opt_extent);
|
||||
}
|
||||
|
||||
|
||||
@@ -559,7 +559,7 @@ export function getHeight(extent) {
|
||||
* @return {number} Intersection area.
|
||||
*/
|
||||
export function getIntersectionArea(extent1, extent2) {
|
||||
var intersection = getIntersection(extent1, extent2);
|
||||
const intersection = getIntersection(extent1, extent2);
|
||||
return getArea(intersection);
|
||||
}
|
||||
|
||||
@@ -573,7 +573,7 @@ export function getIntersectionArea(extent1, extent2) {
|
||||
* @api
|
||||
*/
|
||||
export function getIntersection(extent1, extent2, opt_extent) {
|
||||
var intersection = opt_extent ? opt_extent : createEmpty();
|
||||
const intersection = opt_extent ? opt_extent : createEmpty();
|
||||
if (intersects(extent1, extent2)) {
|
||||
if (extent1[0] > extent2[0]) {
|
||||
intersection[0] = extent1[0];
|
||||
@@ -702,8 +702,8 @@ export function returnOrUpdate(extent, opt_extent) {
|
||||
* @param {number} value Value.
|
||||
*/
|
||||
export function scaleFromCenter(extent, value) {
|
||||
var deltaX = ((extent[2] - extent[0]) / 2) * (value - 1);
|
||||
var deltaY = ((extent[3] - extent[1]) / 2) * (value - 1);
|
||||
const deltaX = ((extent[2] - extent[0]) / 2) * (value - 1);
|
||||
const deltaY = ((extent[3] - extent[1]) / 2) * (value - 1);
|
||||
extent[0] -= deltaX;
|
||||
extent[2] += deltaX;
|
||||
extent[1] -= deltaY;
|
||||
@@ -720,23 +720,23 @@ export function scaleFromCenter(extent, value) {
|
||||
* @return {boolean} The segment intersects the extent.
|
||||
*/
|
||||
export function intersectsSegment(extent, start, end) {
|
||||
var intersects = false;
|
||||
var startRel = coordinateRelationship(extent, start);
|
||||
var endRel = coordinateRelationship(extent, end);
|
||||
let intersects = false;
|
||||
const startRel = coordinateRelationship(extent, start);
|
||||
const endRel = coordinateRelationship(extent, end);
|
||||
if (startRel === Relationship.INTERSECTING ||
|
||||
endRel === Relationship.INTERSECTING) {
|
||||
intersects = true;
|
||||
} else {
|
||||
var minX = extent[0];
|
||||
var minY = extent[1];
|
||||
var maxX = extent[2];
|
||||
var maxY = extent[3];
|
||||
var startX = start[0];
|
||||
var startY = start[1];
|
||||
var endX = end[0];
|
||||
var endY = end[1];
|
||||
var slope = (endY - startY) / (endX - startX);
|
||||
var x, y;
|
||||
const minX = extent[0];
|
||||
const minY = extent[1];
|
||||
const maxX = extent[2];
|
||||
const maxY = extent[3];
|
||||
const startX = start[0];
|
||||
const startY = start[1];
|
||||
const endX = end[0];
|
||||
const endY = end[1];
|
||||
const slope = (endY - startY) / (endX - startX);
|
||||
let x, y;
|
||||
if (!!(endRel & Relationship.ABOVE) &&
|
||||
!(startRel & Relationship.ABOVE)) {
|
||||
// potentially intersects top
|
||||
@@ -777,14 +777,14 @@ export function intersectsSegment(extent, start, end) {
|
||||
* @api
|
||||
*/
|
||||
export function applyTransform(extent, transformFn, opt_extent) {
|
||||
var coordinates = [
|
||||
const coordinates = [
|
||||
extent[0], extent[1],
|
||||
extent[0], extent[3],
|
||||
extent[2], extent[1],
|
||||
extent[2], extent[3]
|
||||
];
|
||||
transformFn(coordinates, coordinates, 2);
|
||||
var xs = [coordinates[0], coordinates[2], coordinates[4], coordinates[6]];
|
||||
var ys = [coordinates[1], coordinates[3], coordinates[5], coordinates[7]];
|
||||
const xs = [coordinates[0], coordinates[2], coordinates[4], coordinates[6]];
|
||||
const ys = [coordinates[1], coordinates[3], coordinates[5], coordinates[7]];
|
||||
return _boundingExtentXYs(xs, ys, opt_extent);
|
||||
}
|
||||
|
||||
+10
-10
@@ -26,10 +26,10 @@ export function loadFeaturesXhr(url, format, success, failure) {
|
||||
* @this {ol.source.Vector|ol.VectorTile}
|
||||
*/
|
||||
function(extent, resolution, projection) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('GET',
|
||||
typeof url === 'function' ? url(extent, resolution, projection) : url,
|
||||
true);
|
||||
typeof url === 'function' ? url(extent, resolution, projection) : url,
|
||||
true);
|
||||
if (format.getType() == FormatType.ARRAY_BUFFER) {
|
||||
xhr.responseType = 'arraybuffer';
|
||||
}
|
||||
@@ -40,9 +40,9 @@ export function loadFeaturesXhr(url, format, success, failure) {
|
||||
xhr.onload = function(event) {
|
||||
// status will be 0 for file:// urls
|
||||
if (!xhr.status || xhr.status >= 200 && xhr.status < 300) {
|
||||
var type = format.getType();
|
||||
const type = format.getType();
|
||||
/** @type {Document|Node|Object|string|undefined} */
|
||||
var source;
|
||||
let source;
|
||||
if (type == FormatType.JSON || type == FormatType.TEXT) {
|
||||
source = xhr.responseText;
|
||||
} else if (type == FormatType.XML) {
|
||||
@@ -55,7 +55,7 @@ export function loadFeaturesXhr(url, format, success, failure) {
|
||||
}
|
||||
if (source) {
|
||||
success.call(this, format.readFeatures(source,
|
||||
{featureProjection: projection}),
|
||||
{featureProjection: projection}),
|
||||
format.readProjection(source), format.getLastExtent());
|
||||
} else {
|
||||
failure.call(this);
|
||||
@@ -87,12 +87,12 @@ export function loadFeaturesXhr(url, format, success, failure) {
|
||||
*/
|
||||
export function xhr(url, format) {
|
||||
return loadFeaturesXhr(url, format,
|
||||
/**
|
||||
/**
|
||||
* @param {Array.<ol.Feature>} features The loaded features.
|
||||
* @param {ol.proj.Projection} dataProjection Data projection.
|
||||
* @this {ol.source.Vector}
|
||||
*/
|
||||
function(features, dataProjection) {
|
||||
this.addFeatures(features);
|
||||
}, /* FIXME handle error */ nullFunction);
|
||||
function(features, dataProjection) {
|
||||
this.addFeatures(features);
|
||||
}, /* FIXME handle error */ nullFunction);
|
||||
}
|
||||
|
||||
+71
-71
@@ -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
@@ -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;
|
||||
|
||||
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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 {
|
||||
|
||||
@@ -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
File diff suppressed because it is too large
Load Diff
+43
-44
@@ -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
@@ -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
@@ -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
@@ -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;
|
||||
|
||||
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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;
|
||||
|
||||
@@ -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
@@ -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_;
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
@@ -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
@@ -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));
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* @param {!string} tagName The XML tag name for this filter.
|
||||
* @struct
|
||||
*/
|
||||
var Filter = function(tagName) {
|
||||
const Filter = function(tagName) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user