Use blocked scoped variables

In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
This commit is contained in:
Tim Schaub
2018-01-11 23:32:36 -07:00
parent 0bf2b04dee
commit ad62739a6e
684 changed files with 18120 additions and 18184 deletions
+43 -43
View File
@@ -20,7 +20,7 @@ import _ol_tilegrid_ from '../tilegrid.js';
* @param {olx.source.BingMapsOptions} options Bing Maps options.
* @api
*/
var BingMaps = function(options) {
const BingMaps = function(options) {
/**
* @private
@@ -65,13 +65,13 @@ var BingMaps = function(options) {
*/
this.imagerySet_ = options.imagerySet;
var url = 'https://dev.virtualearth.net/REST/v1/Imagery/Metadata/' +
const url = 'https://dev.virtualearth.net/REST/v1/Imagery/Metadata/' +
this.imagerySet_ +
'?uriScheme=https&include=ImageryProviders&key=' + this.apiKey_ +
'&c=' + this.culture_;
_ol_net_.jsonp(url, this.handleImageryMetadataResponse.bind(this), undefined,
'jsonp');
'jsonp');
};
@@ -125,14 +125,14 @@ BingMaps.prototype.handleImageryMetadataResponse = function(response) {
return;
}
var resource = response.resourceSets[0].resources[0];
var maxZoom = this.maxZoom_ == -1 ? resource.zoomMax : this.maxZoom_;
const resource = response.resourceSets[0].resources[0];
const maxZoom = this.maxZoom_ == -1 ? resource.zoomMax : this.maxZoom_;
var sourceProjection = this.getProjection();
var extent = _ol_tilegrid_.extentFromProjection(sourceProjection);
var tileSize = resource.imageWidth == resource.imageHeight ?
const sourceProjection = this.getProjection();
const extent = _ol_tilegrid_.extentFromProjection(sourceProjection);
const tileSize = resource.imageWidth == resource.imageHeight ?
resource.imageWidth : [resource.imageWidth, resource.imageHeight];
var tileGrid = _ol_tilegrid_.createXYZ({
const tileGrid = _ol_tilegrid_.createXYZ({
extent: extent,
minZoom: resource.zoomMin,
maxZoom: maxZoom,
@@ -140,54 +140,54 @@ BingMaps.prototype.handleImageryMetadataResponse = function(response) {
});
this.tileGrid = tileGrid;
var culture = this.culture_;
var hidpi = this.hidpi_;
const culture = this.culture_;
const hidpi = this.hidpi_;
this.tileUrlFunction = createFromTileUrlFunctions(
resource.imageUrlSubdomains.map(function(subdomain) {
var quadKeyTileCoord = [0, 0, 0];
var imageUrl = resource.imageUrl
.replace('{subdomain}', subdomain)
.replace('{culture}', culture);
return (
/**
resource.imageUrlSubdomains.map(function(subdomain) {
const quadKeyTileCoord = [0, 0, 0];
const imageUrl = resource.imageUrl
.replace('{subdomain}', subdomain)
.replace('{culture}', culture);
return (
/**
* @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {number} pixelRatio Pixel ratio.
* @param {ol.proj.Projection} projection Projection.
* @return {string|undefined} Tile URL.
*/
function(tileCoord, pixelRatio, projection) {
if (!tileCoord) {
return undefined;
} else {
_ol_tilecoord_.createOrUpdate(tileCoord[0], tileCoord[1],
-tileCoord[2] - 1, quadKeyTileCoord);
var url = imageUrl;
if (hidpi) {
url += '&dpi=d1&device=mobile';
}
return url.replace('{quadkey}', _ol_tilecoord_.quadKey(
quadKeyTileCoord));
function(tileCoord, pixelRatio, projection) {
if (!tileCoord) {
return undefined;
} else {
_ol_tilecoord_.createOrUpdate(tileCoord[0], tileCoord[1],
-tileCoord[2] - 1, quadKeyTileCoord);
let url = imageUrl;
if (hidpi) {
url += '&dpi=d1&device=mobile';
}
return url.replace('{quadkey}', _ol_tilecoord_.quadKey(
quadKeyTileCoord));
}
);
}));
}
);
}));
if (resource.imageryProviders) {
var transform = getTransformFromProjections(
getProjection('EPSG:4326'), this.getProjection());
const transform = getTransformFromProjections(
getProjection('EPSG:4326'), this.getProjection());
this.setAttributions(function(frameState) {
var attributions = [];
var zoom = frameState.viewState.zoom;
const attributions = [];
const zoom = frameState.viewState.zoom;
resource.imageryProviders.map(function(imageryProvider) {
var intersecting = false;
var coverageAreas = imageryProvider.coverageAreas;
for (var i = 0, ii = coverageAreas.length; i < ii; ++i) {
var coverageArea = coverageAreas[i];
let intersecting = false;
const coverageAreas = imageryProvider.coverageAreas;
for (let i = 0, ii = coverageAreas.length; i < ii; ++i) {
const coverageArea = coverageAreas[i];
if (zoom >= coverageArea.zoomMin && zoom <= coverageArea.zoomMax) {
var bbox = coverageArea.bbox;
var epsg4326Extent = [bbox[1], bbox[0], bbox[3], bbox[2]];
var extent = applyTransform(epsg4326Extent, transform);
const bbox = coverageArea.bbox;
const epsg4326Extent = [bbox[1], bbox[0], bbox[3], bbox[2]];
const extent = applyTransform(epsg4326Extent, transform);
if (intersects(extent, frameState.extent)) {
intersecting = true;
break;
+7 -7
View File
@@ -15,7 +15,7 @@ import XYZ from '../source/XYZ.js';
* @param {olx.source.CartoDBOptions} options CartoDB options.
* @api
*/
var CartoDB = function(options) {
const CartoDB = function(options) {
/**
* @type {string}
@@ -97,18 +97,18 @@ CartoDB.prototype.setConfig = function(config) {
* @private
*/
CartoDB.prototype.initializeMap_ = function() {
var paramHash = JSON.stringify(this.config_);
const paramHash = JSON.stringify(this.config_);
if (this.templateCache_[paramHash]) {
this.applyTemplate_(this.templateCache_[paramHash]);
return;
}
var mapUrl = 'https://' + this.account_ + '.carto.com/api/v1/map';
let mapUrl = 'https://' + this.account_ + '.carto.com/api/v1/map';
if (this.mapId_) {
mapUrl += '/named/' + this.mapId_;
}
var client = new XMLHttpRequest();
const client = new XMLHttpRequest();
client.addEventListener('load', this.handleInitResponse_.bind(this, paramHash));
client.addEventListener('error', this.handleInitError_.bind(this));
client.open('POST', mapUrl);
@@ -125,10 +125,10 @@ CartoDB.prototype.initializeMap_ = function() {
* @private
*/
CartoDB.prototype.handleInitResponse_ = function(paramHash, event) {
var client = /** @type {XMLHttpRequest} */ (event.target);
const client = /** @type {XMLHttpRequest} */ (event.target);
// status will be 0 for file:// urls
if (!client.status || client.status >= 200 && client.status < 300) {
var response;
let response;
try {
response = /** @type {CartoDBLayerInfo} */(JSON.parse(client.responseText));
} catch (err) {
@@ -159,7 +159,7 @@ CartoDB.prototype.handleInitError_ = function(event) {
* @private
*/
CartoDB.prototype.applyTemplate_ = function(data) {
var tilesUrl = 'https://' + data.cdn_url.https + '/' + this.account_ +
const tilesUrl = 'https://' + data.cdn_url.https + '/' + this.account_ +
'/api/v1/map/' + data.layergroupid + '/{z}/{x}/{y}.png';
this.setUrl(tilesUrl);
};
+19 -19
View File
@@ -22,7 +22,7 @@ import VectorSource from '../source/Vector.js';
* @extends {ol.source.Vector}
* @api
*/
var Cluster = function(options) {
const Cluster = function(options) {
VectorSource.call(this, {
attributions: options.attributions,
extent: options.extent,
@@ -54,9 +54,9 @@ var Cluster = function(options) {
* @protected
*/
this.geometryFunction = options.geometryFunction || function(feature) {
var geometry = /** @type {ol.geom.Point} */ (feature.getGeometry());
const geometry = /** @type {ol.geom.Point} */ (feature.getGeometry());
assert(geometry instanceof Point,
10); // The default `geometryFunction` can only handle `ol.geom.Point` geometries
10); // The default `geometryFunction` can only handle `ol.geom.Point` geometries
return geometry;
};
@@ -67,7 +67,7 @@ var Cluster = function(options) {
this.source = options.source;
this.source.on(EventType.CHANGE,
Cluster.prototype.refresh, this);
Cluster.prototype.refresh, this);
};
inherits(Cluster, VectorSource);
@@ -97,7 +97,7 @@ Cluster.prototype.getSource = function() {
* @inheritDoc
*/
Cluster.prototype.loadFeatures = function(extent, resolution,
projection) {
projection) {
this.source.loadFeatures(extent, resolution, projection);
if (resolution !== this.resolution) {
this.clear();
@@ -139,27 +139,27 @@ Cluster.prototype.cluster = function() {
return;
}
this.features.length = 0;
var extent = createEmpty();
var mapDistance = this.distance * this.resolution;
var features = this.source.getFeatures();
const extent = createEmpty();
const mapDistance = this.distance * this.resolution;
const features = this.source.getFeatures();
/**
* @type {!Object.<string, boolean>}
*/
var clustered = {};
const clustered = {};
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 (!(getUid(feature).toString() in clustered)) {
var geometry = this.geometryFunction(feature);
const geometry = this.geometryFunction(feature);
if (geometry) {
var coordinates = geometry.getCoordinates();
const coordinates = geometry.getCoordinates();
createOrUpdateFromCoordinate(coordinates, extent);
buffer(extent, mapDistance, extent);
var neighbors = this.source.getFeaturesInExtent(extent);
let neighbors = this.source.getFeaturesInExtent(extent);
neighbors = neighbors.filter(function(neighbor) {
var uid = getUid(neighbor).toString();
const uid = getUid(neighbor).toString();
if (!(uid in clustered)) {
clustered[uid] = true;
return true;
@@ -180,9 +180,9 @@ Cluster.prototype.cluster = function() {
* @protected
*/
Cluster.prototype.createCluster = function(features) {
var centroid = [0, 0];
for (var i = features.length - 1; i >= 0; --i) {
var geometry = this.geometryFunction(features[i]);
const centroid = [0, 0];
for (let i = features.length - 1; i >= 0; --i) {
const geometry = this.geometryFunction(features[i]);
if (geometry) {
_ol_coordinate_.add(centroid, geometry.getCoordinates());
} else {
@@ -191,7 +191,7 @@ Cluster.prototype.createCluster = function(features) {
}
_ol_coordinate_.scale(centroid, 1 / features.length);
var cluster = new Feature(new Point(centroid));
const cluster = new Feature(new Point(centroid));
cluster.set('features', features);
return cluster;
};
+16 -16
View File
@@ -23,7 +23,7 @@ import Source from '../source/Source.js';
* @param {ol.SourceImageOptions} options Single image source options.
* @api
*/
var ImageSource = function(options) {
const ImageSource = function(options) {
Source.call(this, {
attributions: options.attributions,
extent: options.extent,
@@ -72,7 +72,7 @@ ImageSource.prototype.getResolutions = function() {
*/
ImageSource.prototype.findNearestResolution = function(resolution) {
if (this.resolutions_) {
var idx = linearFindNearest(this.resolutions_, resolution, 0);
const idx = linearFindNearest(this.resolutions_, resolution, 0);
resolution = this.resolutions_[idx];
}
return resolution;
@@ -87,7 +87,7 @@ ImageSource.prototype.findNearestResolution = function(resolution) {
* @return {ol.ImageBase} Single image.
*/
ImageSource.prototype.getImage = function(extent, resolution, pixelRatio, projection) {
var sourceProjection = this.getProjection();
const sourceProjection = this.getProjection();
if (!ENABLE_RASTER_REPROJECTION ||
!sourceProjection ||
!projection ||
@@ -100,7 +100,7 @@ ImageSource.prototype.getImage = function(extent, resolution, pixelRatio, projec
if (this.reprojectedImage_) {
if (this.reprojectedRevision_ == this.getRevision() &&
equivalent(
this.reprojectedImage_.getProjection(), projection) &&
this.reprojectedImage_.getProjection(), projection) &&
this.reprojectedImage_.getResolution() == resolution &&
equals(this.reprojectedImage_.getExtent(), extent)) {
return this.reprojectedImage_;
@@ -110,11 +110,11 @@ ImageSource.prototype.getImage = function(extent, resolution, pixelRatio, projec
}
this.reprojectedImage_ = new ReprojImage(
sourceProjection, projection, extent, resolution, pixelRatio,
function(extent, resolution, pixelRatio) {
return this.getImageInternal(extent, resolution,
pixelRatio, sourceProjection);
}.bind(this));
sourceProjection, projection, extent, resolution, pixelRatio,
function(extent, resolution, pixelRatio) {
return this.getImageInternal(extent, resolution,
pixelRatio, sourceProjection);
}.bind(this));
this.reprojectedRevision_ = this.getRevision();
return this.reprojectedImage_;
@@ -140,22 +140,22 @@ ImageSource.prototype.getImageInternal = function(extent, resolution, pixelRatio
* @protected
*/
ImageSource.prototype.handleImageChange = function(event) {
var image = /** @type {ol.Image} */ (event.target);
const image = /** @type {ol.Image} */ (event.target);
switch (image.getState()) {
case ImageState.LOADING:
this.dispatchEvent(
new ImageSource.Event(ImageSource.EventType_.IMAGELOADSTART,
image));
new ImageSource.Event(ImageSource.EventType_.IMAGELOADSTART,
image));
break;
case ImageState.LOADED:
this.dispatchEvent(
new ImageSource.Event(ImageSource.EventType_.IMAGELOADEND,
image));
new ImageSource.Event(ImageSource.EventType_.IMAGELOADEND,
image));
break;
case ImageState.ERROR:
this.dispatchEvent(
new ImageSource.Event(ImageSource.EventType_.IMAGELOADERROR,
image));
new ImageSource.Event(ImageSource.EventType_.IMAGELOADERROR,
image));
break;
default:
// pass
+20 -20
View File
@@ -26,9 +26,9 @@ import _ol_uri_ from '../uri.js';
* @param {olx.source.ImageArcGISRestOptions=} opt_options Image ArcGIS Rest Options.
* @api
*/
var ImageArcGISRest = function(opt_options) {
const ImageArcGISRest = function(opt_options) {
var options = opt_options || {};
const options = opt_options || {};
ImageSource.call(this, {
attributions: options.attributions,
@@ -122,7 +122,7 @@ ImageArcGISRest.prototype.getImageInternal = function(extent, resolution, pixelR
resolution = this.findNearestResolution(resolution);
pixelRatio = this.hidpi_ ? pixelRatio : 1;
var image = this.image_;
const image = this.image_;
if (image &&
this.renderedRevision_ == this.getRevision() &&
image.getResolution() == resolution &&
@@ -131,7 +131,7 @@ ImageArcGISRest.prototype.getImageInternal = function(extent, resolution, pixelR
return image;
}
var params = {
const params = {
'F': 'image',
'FORMAT': 'PNG32',
'TRANSPARENT': true
@@ -139,22 +139,22 @@ ImageArcGISRest.prototype.getImageInternal = function(extent, resolution, pixelR
_ol_obj_.assign(params, this.params_);
extent = extent.slice();
var centerX = (extent[0] + extent[2]) / 2;
var centerY = (extent[1] + extent[3]) / 2;
const centerX = (extent[0] + extent[2]) / 2;
const centerY = (extent[1] + extent[3]) / 2;
if (this.ratio_ != 1) {
var halfWidth = this.ratio_ * getWidth(extent) / 2;
var halfHeight = this.ratio_ * getHeight(extent) / 2;
const halfWidth = this.ratio_ * getWidth(extent) / 2;
const halfHeight = this.ratio_ * getHeight(extent) / 2;
extent[0] = centerX - halfWidth;
extent[1] = centerY - halfHeight;
extent[2] = centerX + halfWidth;
extent[3] = centerY + halfHeight;
}
var imageResolution = resolution / pixelRatio;
const imageResolution = resolution / pixelRatio;
// Compute an integer width and height.
var width = Math.ceil(getWidth(extent) / imageResolution);
var height = Math.ceil(getHeight(extent) / imageResolution);
const width = Math.ceil(getWidth(extent) / imageResolution);
const height = Math.ceil(getHeight(extent) / imageResolution);
// Modify the extent to match the integer width and height.
extent[0] = centerX - imageResolution * width / 2;
@@ -165,16 +165,16 @@ ImageArcGISRest.prototype.getImageInternal = function(extent, resolution, pixelR
this.imageSize_[0] = width;
this.imageSize_[1] = height;
var url = this.getRequestUrl_(extent, this.imageSize_, pixelRatio,
projection, params);
const url = this.getRequestUrl_(extent, this.imageSize_, pixelRatio,
projection, params);
this.image_ = new _ol_Image_(extent, resolution, pixelRatio,
url, this.crossOrigin_, this.imageLoadFunction_);
url, this.crossOrigin_, this.imageLoadFunction_);
this.renderedRevision_ = this.getRevision();
_ol_events_.listen(this.image_, EventType.CHANGE,
this.handleImageChange, this);
this.handleImageChange, this);
return this.image_;
@@ -202,7 +202,7 @@ ImageArcGISRest.prototype.getImageLoadFunction = function() {
*/
ImageArcGISRest.prototype.getRequestUrl_ = function(extent, size, pixelRatio, projection, params) {
// ArcGIS Server only wants the numeric portion of the projection ID.
var srid = projection.getCode().split(':').pop();
const srid = projection.getCode().split(':').pop();
params['SIZE'] = size[0] + ',' + size[1];
params['BBOX'] = extent.join(',');
@@ -210,11 +210,11 @@ ImageArcGISRest.prototype.getRequestUrl_ = function(extent, size, pixelRatio, pr
params['IMAGESR'] = srid;
params['DPI'] = Math.round(90 * pixelRatio);
var url = this.url_;
const url = this.url_;
var modifiedUrl = url
.replace(/MapServer\/?$/, 'MapServer/export')
.replace(/ImageServer\/?$/, 'ImageServer/exportImage');
const modifiedUrl = url
.replace(/MapServer\/?$/, 'MapServer/export')
.replace(/ImageServer\/?$/, 'ImageServer/exportImage');
if (modifiedUrl == url) {
assert(false, 50); // `options.featureTypes` should be an Array
}
+7 -7
View File
@@ -15,7 +15,7 @@ import ImageSource from '../source/Image.js';
* @param {olx.source.ImageCanvasOptions} options Constructor options.
* @api
*/
var ImageCanvasSource = function(options) {
const ImageCanvasSource = function(options) {
ImageSource.call(this, {
attributions: options.attributions,
@@ -60,7 +60,7 @@ inherits(ImageCanvasSource, ImageSource);
ImageCanvasSource.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) {
resolution = this.findNearestResolution(resolution);
var canvas = this.canvas_;
let canvas = this.canvas_;
if (canvas &&
this.renderedRevision_ == this.getRevision() &&
canvas.getResolution() == resolution &&
@@ -71,12 +71,12 @@ ImageCanvasSource.prototype.getImageInternal = function(extent, resolution, pixe
extent = extent.slice();
scaleFromCenter(extent, this.ratio_);
var width = getWidth(extent) / resolution;
var height = getHeight(extent) / resolution;
var size = [width * pixelRatio, height * pixelRatio];
const width = getWidth(extent) / resolution;
const height = getHeight(extent) / resolution;
const size = [width * pixelRatio, height * pixelRatio];
var canvasElement = this.canvasFunction_(
extent, resolution, pixelRatio, size, projection);
const canvasElement = this.canvasFunction_(
extent, resolution, pixelRatio, size, projection);
if (canvasElement) {
canvas = new ImageCanvas(extent, resolution, pixelRatio, canvasElement);
}
+20 -20
View File
@@ -20,7 +20,7 @@ import _ol_uri_ from '../uri.js';
* @param {olx.source.ImageMapGuideOptions} options Options.
* @api
*/
var ImageMapGuide = function(options) {
const ImageMapGuide = function(options) {
ImageSource.call(this, {
projection: options.projection,
@@ -121,7 +121,7 @@ ImageMapGuide.prototype.getImageInternal = function(extent, resolution, pixelRat
resolution = this.findNearestResolution(resolution);
pixelRatio = this.hidpi_ ? pixelRatio : 1;
var image = this.image_;
let image = this.image_;
if (image &&
this.renderedRevision_ == this.getRevision() &&
image.getResolution() == resolution &&
@@ -134,18 +134,18 @@ ImageMapGuide.prototype.getImageInternal = function(extent, resolution, pixelRat
extent = extent.slice();
scaleFromCenter(extent, this.ratio_);
}
var width = getWidth(extent) / resolution;
var height = getHeight(extent) / resolution;
var size = [width * pixelRatio, height * pixelRatio];
const width = getWidth(extent) / resolution;
const height = getHeight(extent) / resolution;
const size = [width * pixelRatio, height * pixelRatio];
if (this.url_ !== undefined) {
var imageUrl = this.getUrl(this.url_, this.params_, extent, size,
projection);
const imageUrl = this.getUrl(this.url_, this.params_, extent, size,
projection);
image = new _ol_Image_(extent, resolution, pixelRatio,
imageUrl, this.crossOrigin_,
this.imageLoadFunction_);
imageUrl, this.crossOrigin_,
this.imageLoadFunction_);
_ol_events_.listen(image, EventType.CHANGE,
this.handleImageChange, this);
this.handleImageChange, this);
} else {
image = null;
}
@@ -174,11 +174,11 @@ ImageMapGuide.prototype.getImageLoadFunction = function() {
* @return {number} The computed map scale.
*/
ImageMapGuide.getScale = function(extent, size, metersPerUnit, dpi) {
var mcsW = getWidth(extent);
var mcsH = getHeight(extent);
var devW = size[0];
var devH = size[1];
var mpp = 0.0254 / dpi;
const mcsW = getWidth(extent);
const mcsH = getHeight(extent);
const devW = size[0];
const devH = size[1];
const mpp = 0.0254 / dpi;
if (devH * mcsW > devW * mcsH) {
return mcsW * metersPerUnit / (devW * mpp); // width limited
} else {
@@ -207,10 +207,10 @@ ImageMapGuide.prototype.updateParams = function(params) {
* @return {string} The mapagent map image request URL.
*/
ImageMapGuide.prototype.getUrl = function(baseUrl, params, extent, size, projection) {
var scale = ImageMapGuide.getScale(extent, size,
this.metersPerUnit_, this.displayDpi_);
var center = getCenter(extent);
var baseParams = {
const scale = ImageMapGuide.getScale(extent, size,
this.metersPerUnit_, this.displayDpi_);
const center = getCenter(extent);
const baseParams = {
'OPERATION': this.useOverlay_ ? 'GETDYNAMICMAPOVERLAYIMAGE' : 'GETMAPIMAGE',
'VERSION': '2.0.0',
'LOCALE': 'en',
@@ -234,7 +234,7 @@ ImageMapGuide.prototype.getUrl = function(baseUrl, params, extent, size, project
* @api
*/
ImageMapGuide.prototype.setImageLoadFunction = function(
imageLoadFunction) {
imageLoadFunction) {
this.image_ = null;
this.imageLoadFunction_ = imageLoadFunction;
this.changed();
+13 -13
View File
@@ -20,13 +20,13 @@ import ImageSource from '../source/Image.js';
* @param {olx.source.ImageStaticOptions} options Options.
* @api
*/
var Static = function(options) {
var imageExtent = options.imageExtent;
const Static = function(options) {
const imageExtent = options.imageExtent;
var crossOrigin = options.crossOrigin !== undefined ?
const crossOrigin = options.crossOrigin !== undefined ?
options.crossOrigin : null;
var /** @type {ol.ImageLoadFunctionType} */ imageLoadFunction =
const /** @type {ol.ImageLoadFunctionType} */ imageLoadFunction =
options.imageLoadFunction !== undefined ?
options.imageLoadFunction : ImageSource.defaultImageLoadFunction;
@@ -48,7 +48,7 @@ var Static = function(options) {
this.imageSize_ = options.imageSize ? options.imageSize : null;
_ol_events_.listen(this.image_, EventType.CHANGE,
this.handleImageChange, this);
this.handleImageChange, this);
};
@@ -71,9 +71,9 @@ Static.prototype.getImageInternal = function(extent, resolution, pixelRatio, pro
*/
Static.prototype.handleImageChange = function(evt) {
if (this.image_.getState() == ImageState.LOADED) {
var imageExtent = this.image_.getExtent();
var image = this.image_.getImage();
var imageWidth, imageHeight;
const imageExtent = this.image_.getExtent();
const image = this.image_.getImage();
let imageWidth, imageHeight;
if (this.imageSize_) {
imageWidth = this.imageSize_[0];
imageHeight = this.imageSize_[1];
@@ -81,13 +81,13 @@ Static.prototype.handleImageChange = function(evt) {
imageWidth = image.width;
imageHeight = image.height;
}
var resolution = getHeight(imageExtent) / imageHeight;
var targetWidth = Math.ceil(getWidth(imageExtent) / resolution);
const resolution = getHeight(imageExtent) / imageHeight;
const targetWidth = Math.ceil(getWidth(imageExtent) / resolution);
if (targetWidth != imageWidth) {
var context = createCanvasContext2D(targetWidth, imageHeight);
var canvas = context.canvas;
const context = createCanvasContext2D(targetWidth, imageHeight);
const canvas = context.canvas;
context.drawImage(image, 0, 0, imageWidth, imageHeight,
0, 0, canvas.width, canvas.height);
0, 0, canvas.width, canvas.height);
this.image_.setImage(canvas);
}
}
+32 -32
View File
@@ -27,9 +27,9 @@ import _ol_uri_ from '../uri.js';
* @param {olx.source.ImageWMSOptions=} opt_options Options.
* @api
*/
var ImageWMS = function(opt_options) {
const ImageWMS = function(opt_options) {
var options = opt_options || {};
const options = opt_options || {};
ImageSource.call(this, {
attributions: options.attributions,
@@ -137,18 +137,18 @@ ImageWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, proje
if (this.url_ === undefined) {
return undefined;
}
var projectionObj = getProjection(projection);
var sourceProjectionObj = this.getProjection();
const projectionObj = getProjection(projection);
const sourceProjectionObj = this.getProjection();
if (sourceProjectionObj && sourceProjectionObj !== projectionObj) {
resolution = _ol_reproj_.calculateSourceResolution(sourceProjectionObj, projectionObj, coordinate, resolution);
coordinate = transform(coordinate, projectionObj, sourceProjectionObj);
}
var extent = getForViewAndSize(coordinate, resolution, 0,
ImageWMS.GETFEATUREINFO_IMAGE_SIZE_);
const extent = getForViewAndSize(coordinate, resolution, 0,
ImageWMS.GETFEATUREINFO_IMAGE_SIZE_);
var baseParams = {
const baseParams = {
'SERVICE': 'WMS',
'VERSION': DEFAULT_WMS_VERSION,
'REQUEST': 'GetFeatureInfo',
@@ -158,14 +158,14 @@ ImageWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, proje
};
_ol_obj_.assign(baseParams, this.params_, params);
var x = Math.floor((coordinate[0] - extent[0]) / resolution);
var y = Math.floor((extent[3] - coordinate[1]) / resolution);
const x = Math.floor((coordinate[0] - extent[0]) / resolution);
const y = Math.floor((extent[3] - coordinate[1]) / resolution);
baseParams[this.v13_ ? 'I' : 'X'] = x;
baseParams[this.v13_ ? 'J' : 'Y'] = y;
return this.getRequestUrl_(
extent, ImageWMS.GETFEATUREINFO_IMAGE_SIZE_,
1, sourceProjectionObj || projectionObj, baseParams);
extent, ImageWMS.GETFEATUREINFO_IMAGE_SIZE_,
1, sourceProjectionObj || projectionObj, baseParams);
};
@@ -195,19 +195,19 @@ ImageWMS.prototype.getImageInternal = function(extent, resolution, pixelRatio, p
pixelRatio = 1;
}
var imageResolution = resolution / pixelRatio;
const imageResolution = resolution / pixelRatio;
var center = getCenter(extent);
var viewWidth = Math.ceil(getWidth(extent) / imageResolution);
var viewHeight = Math.ceil(getHeight(extent) / imageResolution);
var viewExtent = getForViewAndSize(center, imageResolution, 0,
[viewWidth, viewHeight]);
var requestWidth = Math.ceil(this.ratio_ * getWidth(extent) / imageResolution);
var requestHeight = Math.ceil(this.ratio_ * getHeight(extent) / imageResolution);
var requestExtent = getForViewAndSize(center, imageResolution, 0,
[requestWidth, requestHeight]);
const center = getCenter(extent);
const viewWidth = Math.ceil(getWidth(extent) / imageResolution);
const viewHeight = Math.ceil(getHeight(extent) / imageResolution);
const viewExtent = getForViewAndSize(center, imageResolution, 0,
[viewWidth, viewHeight]);
const requestWidth = Math.ceil(this.ratio_ * getWidth(extent) / imageResolution);
const requestHeight = Math.ceil(this.ratio_ * getHeight(extent) / imageResolution);
const requestExtent = getForViewAndSize(center, imageResolution, 0,
[requestWidth, requestHeight]);
var image = this.image_;
const image = this.image_;
if (image &&
this.renderedRevision_ == this.getRevision() &&
image.getResolution() == resolution &&
@@ -216,7 +216,7 @@ ImageWMS.prototype.getImageInternal = function(extent, resolution, pixelRatio, p
return image;
}
var params = {
const params = {
'SERVICE': 'WMS',
'VERSION': DEFAULT_WMS_VERSION,
'REQUEST': 'GetMap',
@@ -228,16 +228,16 @@ ImageWMS.prototype.getImageInternal = function(extent, resolution, pixelRatio, p
this.imageSize_[0] = Math.round(getWidth(requestExtent) / imageResolution);
this.imageSize_[1] = Math.round(getHeight(requestExtent) / imageResolution);
var url = this.getRequestUrl_(requestExtent, this.imageSize_, pixelRatio,
projection, params);
const url = this.getRequestUrl_(requestExtent, this.imageSize_, pixelRatio,
projection, params);
this.image_ = new _ol_Image_(requestExtent, resolution, pixelRatio,
url, this.crossOrigin_, this.imageLoadFunction_);
url, this.crossOrigin_, this.imageLoadFunction_);
this.renderedRevision_ = this.getRevision();
_ol_events_.listen(this.image_, EventType.CHANGE,
this.handleImageChange, this);
this.handleImageChange, this);
return this.image_;
@@ -276,7 +276,7 @@ ImageWMS.prototype.getRequestUrl_ = function(extent, size, pixelRatio, projectio
if (pixelRatio != 1) {
switch (this.serverType_) {
case WMSServerType.GEOSERVER:
var dpi = (90 * pixelRatio + 0.5) | 0;
const dpi = (90 * pixelRatio + 0.5) | 0;
if ('FORMAT_OPTIONS' in params) {
params['FORMAT_OPTIONS'] += ';dpi:' + dpi;
} else {
@@ -299,8 +299,8 @@ ImageWMS.prototype.getRequestUrl_ = function(extent, size, pixelRatio, projectio
params['WIDTH'] = size[0];
params['HEIGHT'] = size[1];
var axisOrientation = projection.getAxisOrientation();
var bbox;
const axisOrientation = projection.getAxisOrientation();
let bbox;
if (this.v13_ && axisOrientation.substr(0, 2) == 'ne') {
bbox = [extent[1], extent[0], extent[3], extent[2]];
} else {
@@ -328,7 +328,7 @@ ImageWMS.prototype.getUrl = function() {
* @api
*/
ImageWMS.prototype.setImageLoadFunction = function(
imageLoadFunction) {
imageLoadFunction) {
this.image_ = null;
this.imageLoadFunction_ = imageLoadFunction;
this.changed();
@@ -366,7 +366,7 @@ ImageWMS.prototype.updateParams = function(params) {
* @private
*/
ImageWMS.prototype.updateV13_ = function() {
var version = this.params_['VERSION'] || DEFAULT_WMS_VERSION;
const version = this.params_['VERSION'] || DEFAULT_WMS_VERSION;
this.v13_ = _ol_string_.compareVersions(version, '1.3') >= 0;
};
export default ImageWMS;
+5 -5
View File
@@ -13,21 +13,21 @@ import XYZ from '../source/XYZ.js';
* @param {olx.source.OSMOptions=} opt_options Open Street Map options.
* @api
*/
var OSM = function(opt_options) {
const OSM = function(opt_options) {
var options = opt_options || {};
const options = opt_options || {};
var attributions;
let attributions;
if (options.attributions !== undefined) {
attributions = options.attributions;
} else {
attributions = [OSM.ATTRIBUTION];
}
var crossOrigin = options.crossOrigin !== undefined ?
const crossOrigin = options.crossOrigin !== undefined ?
options.crossOrigin : 'anonymous';
var url = options.url !== undefined ?
const url = options.url !== undefined ?
options.url : 'https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png';
XYZ.call(this, {
+41 -41
View File
@@ -25,7 +25,7 @@ import _ol_transform_ from '../transform.js';
/**
* @enum {string}
*/
var RasterEventType = {
const RasterEventType = {
/**
* Triggered before operations are run.
* @event ol.source.Raster.Event#beforeoperations
@@ -54,7 +54,7 @@ var RasterEventType = {
* @param {olx.source.RasterOptions} options Options.
* @api
*/
var RasterSource = function(options) {
const RasterSource = function(options) {
/**
* @private
@@ -81,9 +81,9 @@ var RasterSource = function(options) {
*/
this.renderers_ = createRenderers(options.sources);
for (var r = 0, rr = this.renderers_.length; r < rr; ++r) {
for (let r = 0, rr = this.renderers_.length; r < rr; ++r) {
_ol_events_.listen(this.renderers_[r], EventType.CHANGE,
this.changed, this);
this.changed, this);
}
/**
@@ -91,14 +91,14 @@ var RasterSource = function(options) {
* @type {ol.TileQueue}
*/
this.tileQueue_ = new TileQueue(
function() {
return 1;
},
this.changed.bind(this));
function() {
return 1;
},
this.changed.bind(this));
var layerStatesArray = getLayerStatesArray(this.renderers_);
var layerStates = {};
for (var i = 0, ii = layerStatesArray.length; i < ii; ++i) {
const layerStatesArray = getLayerStatesArray(this.renderers_);
const layerStates = {};
for (let i = 0, ii = layerStatesArray.length; i < ii; ++i) {
layerStates[getUid(layerStatesArray[i].layer)] = layerStatesArray[i];
}
@@ -189,13 +189,13 @@ RasterSource.prototype.setOperation = function(operation, opt_lib) {
*/
RasterSource.prototype.updateFrameState_ = function(extent, resolution, projection) {
var frameState = /** @type {olx.FrameState} */ (
const frameState = /** @type {olx.FrameState} */ (
_ol_obj_.assign({}, this.frameState_));
frameState.viewState = /** @type {olx.ViewState} */ (
_ol_obj_.assign({}, frameState.viewState));
var center = getCenter(extent);
const center = getCenter(extent);
frameState.extent = extent.slice();
frameState.focus = center;
@@ -204,7 +204,7 @@ RasterSource.prototype.updateFrameState_ = function(extent, resolution, projecti
frameState.time = Date.now();
frameState.animate = false;
var viewState = frameState.viewState;
const viewState = frameState.viewState;
viewState.center = center;
viewState.projection = projection;
viewState.resolution = resolution;
@@ -218,9 +218,9 @@ RasterSource.prototype.updateFrameState_ = function(extent, resolution, projecti
* @private
*/
RasterSource.prototype.allSourcesReady_ = function() {
var ready = true;
var source;
for (var i = 0, ii = this.renderers_.length; i < ii; ++i) {
let ready = true;
let source;
for (let i = 0, ii = this.renderers_.length; i < ii; ++i) {
source = this.renderers_[i].getLayer().getSource();
if (source.getState() !== SourceState.READY) {
ready = false;
@@ -239,13 +239,13 @@ RasterSource.prototype.getImage = function(extent, resolution, pixelRatio, proje
return null;
}
var frameState = this.updateFrameState_(extent, resolution, projection);
const frameState = this.updateFrameState_(extent, resolution, projection);
this.requestedFrameState_ = frameState;
// check if we can't reuse the existing ol.ImageCanvas
if (this.renderedImageCanvas_) {
var renderedResolution = this.renderedImageCanvas_.getResolution();
var renderedExtent = this.renderedImageCanvas_.getExtent();
const renderedResolution = this.renderedImageCanvas_.getResolution();
const renderedExtent = this.renderedImageCanvas_.getExtent();
if (resolution !== renderedResolution || !equals(extent, renderedExtent)) {
this.renderedImageCanvas_ = null;
}
@@ -270,12 +270,12 @@ RasterSource.prototype.getImage = function(extent, resolution, pixelRatio, proje
* @private
*/
RasterSource.prototype.processSources_ = function() {
var frameState = this.requestedFrameState_;
var len = this.renderers_.length;
var imageDatas = new Array(len);
for (var i = 0; i < len; ++i) {
var imageData = getImageData(
this.renderers_[i], frameState, frameState.layerStatesArray[i]);
const frameState = this.requestedFrameState_;
const len = this.renderers_.length;
const imageDatas = new Array(len);
for (let i = 0; i < len; ++i) {
const imageData = getImageData(
this.renderers_[i], frameState, frameState.layerStatesArray[i]);
if (imageData) {
imageDatas[i] = imageData;
} else {
@@ -283,7 +283,7 @@ RasterSource.prototype.processSources_ = function() {
}
}
var data = {};
const data = {};
this.dispatchEvent(new RasterSource.Event(RasterEventType.BEFOREOPERATIONS, frameState, data));
this.worker_.process(imageDatas, data, this.onWorkerComplete_.bind(this, frameState));
};
@@ -303,19 +303,19 @@ RasterSource.prototype.onWorkerComplete_ = function(frameState, err, output, dat
}
// do nothing if extent or resolution changed
var extent = frameState.extent;
var resolution = frameState.viewState.resolution;
const extent = frameState.extent;
const resolution = frameState.viewState.resolution;
if (resolution !== this.requestedFrameState_.viewState.resolution ||
!equals(extent, this.requestedFrameState_.extent)) {
return;
}
var context;
let context;
if (this.renderedImageCanvas_) {
context = this.renderedImageCanvas_.getImage().getContext('2d');
} else {
var width = Math.round(getWidth(extent) / resolution);
var height = Math.round(getHeight(extent) / resolution);
const width = Math.round(getWidth(extent) / resolution);
const height = Math.round(getHeight(extent) / resolution);
context = createCanvasContext2D(width, height);
this.renderedImageCanvas_ = new ImageCanvas(extent, resolution, 1, context.canvas);
}
@@ -339,12 +339,12 @@ function getImageData(renderer, frameState, layerState) {
if (!renderer.prepareFrame(frameState, layerState)) {
return null;
}
var width = frameState.size[0];
var height = frameState.size[1];
const width = frameState.size[0];
const height = frameState.size[1];
if (!RasterSource.context_) {
RasterSource.context_ = createCanvasContext2D(width, height);
} else {
var canvas = RasterSource.context_.canvas;
const canvas = RasterSource.context_.canvas;
if (canvas.width !== width || canvas.height !== height) {
RasterSource.context_ = createCanvasContext2D(width, height);
} else {
@@ -382,9 +382,9 @@ function getLayerStatesArray(renderers) {
* @return {Array.<ol.renderer.canvas.Layer>} Array of layer renderers.
*/
function createRenderers(sources) {
var len = sources.length;
var renderers = new Array(len);
for (var i = 0; i < len; ++i) {
const len = sources.length;
const renderers = new Array(len);
for (let i = 0; i < len; ++i) {
renderers[i] = createRenderer(sources[i]);
}
return renderers;
@@ -397,7 +397,7 @@ function createRenderers(sources) {
* @return {ol.renderer.canvas.Layer} The renderer.
*/
function createRenderer(source) {
var renderer = null;
let renderer = null;
if (source instanceof TileSource) {
renderer = createTileRenderer(source);
} else if (source instanceof ImageSource) {
@@ -413,7 +413,7 @@ function createRenderer(source) {
* @return {ol.renderer.canvas.Layer} The renderer.
*/
function createImageRenderer(source) {
var layer = new ImageLayer({source: source});
const layer = new ImageLayer({source: source});
return new CanvasImageLayerRenderer(layer);
}
@@ -424,7 +424,7 @@ function createImageRenderer(source) {
* @return {ol.renderer.canvas.Layer} The renderer.
*/
function createTileRenderer(source) {
var layer = new TileLayer({source: source});
const layer = new TileLayer({source: source});
return new CanvasTileLayerRenderer(layer);
}
+1 -1
View File
@@ -21,7 +21,7 @@ import SourceState from '../source/State.js';
* @param {ol.SourceSourceOptions} options Source options.
* @api
*/
var Source = function(options) {
const Source = function(options) {
BaseObject.call(this);
+6 -6
View File
@@ -14,14 +14,14 @@ import XYZ from '../source/XYZ.js';
* @param {olx.source.StamenOptions} options Stamen options.
* @api
*/
var Stamen = function(options) {
var i = options.layer.indexOf('-');
var provider = i == -1 ? options.layer : options.layer.slice(0, i);
var providerConfig = Stamen.ProviderConfig[provider];
const Stamen = function(options) {
const i = options.layer.indexOf('-');
const provider = i == -1 ? options.layer : options.layer.slice(0, i);
const providerConfig = Stamen.ProviderConfig[provider];
var layerConfig = Stamen.LayerConfig[options.layer];
const layerConfig = Stamen.LayerConfig[options.layer];
var url = options.url !== undefined ? options.url :
const url = options.url !== undefined ? options.url :
'https://stamen-tiles-{a-d}.a.ssl.fastly.net/' + options.layer +
'/{z}/{x}/{y}.' + layerConfig.extension;
+13 -13
View File
@@ -23,7 +23,7 @@ import _ol_tilegrid_ from '../tilegrid.js';
* @param {ol.SourceTileOptions} options Tile source options.
* @api
*/
var TileSource = function(options) {
const TileSource = function(options) {
Source.call(this, {
attributions: options.attributions,
@@ -94,7 +94,7 @@ TileSource.prototype.canExpireCache = function() {
* @param {Object.<string, ol.TileRange>} usedTiles Used tiles.
*/
TileSource.prototype.expireCache = function(projection, usedTiles) {
var tileCache = this.getTileCacheForProjection(projection);
const tileCache = this.getTileCacheForProjection(projection);
if (tileCache) {
tileCache.expireCache(usedTiles);
}
@@ -111,15 +111,15 @@ TileSource.prototype.expireCache = function(projection, usedTiles) {
* @return {boolean} The tile range is fully covered with loaded tiles.
*/
TileSource.prototype.forEachLoadedTile = function(projection, z, tileRange, callback) {
var tileCache = this.getTileCacheForProjection(projection);
const tileCache = this.getTileCacheForProjection(projection);
if (!tileCache) {
return false;
}
var covered = true;
var tile, tileCoordKey, loaded;
for (var x = tileRange.minX; x <= tileRange.maxX; ++x) {
for (var y = tileRange.minY; y <= tileRange.maxY; ++y) {
let covered = true;
let tile, tileCoordKey, loaded;
for (let x = tileRange.minX; x <= tileRange.maxX; ++x) {
for (let y = tileRange.minY; y <= tileRange.maxY; ++y) {
tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y);
loaded = false;
if (tileCache.containsKey(tileCoordKey)) {
@@ -228,7 +228,7 @@ TileSource.prototype.getTileGridForProjection = function(projection) {
* @protected
*/
TileSource.prototype.getTileCacheForProjection = function(projection) {
var thisProj = this.getProjection();
const thisProj = this.getProjection();
if (thisProj && !equivalent(thisProj, projection)) {
return null;
} else {
@@ -256,9 +256,9 @@ TileSource.prototype.getTilePixelRatio = function(pixelRatio) {
* @return {ol.Size} Tile size.
*/
TileSource.prototype.getTilePixelSize = function(z, pixelRatio, projection) {
var tileGrid = this.getTileGridForProjection(projection);
var tilePixelRatio = this.getTilePixelRatio(pixelRatio);
var tileSize = _ol_size_.toSize(tileGrid.getTileSize(z), this.tmpSize);
const tileGrid = this.getTileGridForProjection(projection);
const tilePixelRatio = this.getTilePixelRatio(pixelRatio);
const tileSize = _ol_size_.toSize(tileGrid.getTileSize(z), this.tmpSize);
if (tilePixelRatio == 1) {
return tileSize;
} else {
@@ -277,9 +277,9 @@ TileSource.prototype.getTilePixelSize = function(z, pixelRatio, projection) {
* null if no tile URL should be created for the passed `tileCoord`.
*/
TileSource.prototype.getTileCoordForTileUrlFunction = function(tileCoord, opt_projection) {
var projection = opt_projection !== undefined ?
const projection = opt_projection !== undefined ?
opt_projection : this.getProjection();
var tileGrid = this.getTileGridForProjection(projection);
const tileGrid = this.getTileGridForProjection(projection);
if (this.getWrapX() && projection.isGlobal()) {
tileCoord = _ol_tilegrid_.wrapX(tileGrid, tileCoord, projection);
}
+21 -21
View File
@@ -24,9 +24,9 @@ import _ol_uri_ from '../uri.js';
* options.
* @api
*/
var TileArcGISRest = function(opt_options) {
const TileArcGISRest = function(opt_options) {
var options = opt_options || {};
const options = opt_options || {};
TileImage.call(this, {
attributions: options.attributions,
@@ -65,9 +65,9 @@ inherits(TileArcGISRest, TileImage);
* @return {string} The key for the current params.
*/
TileArcGISRest.prototype.getKeyForParams_ = function() {
var i = 0;
var res = [];
for (var key in this.params_) {
let i = 0;
const res = [];
for (const key in this.params_) {
res[i++] = key + '-' + this.params_[key];
}
return res.join('/');
@@ -96,35 +96,35 @@ TileArcGISRest.prototype.getParams = function() {
* @private
*/
TileArcGISRest.prototype.getRequestUrl_ = function(tileCoord, tileSize, tileExtent,
pixelRatio, projection, params) {
pixelRatio, projection, params) {
var urls = this.urls;
const urls = this.urls;
if (!urls) {
return undefined;
}
// ArcGIS Server only wants the numeric portion of the projection ID.
var srid = projection.getCode().split(':').pop();
const srid = projection.getCode().split(':').pop();
params['SIZE'] = tileSize[0] + ',' + tileSize[1];
params['BBOX'] = tileExtent.join(',');
params['BBOXSR'] = srid;
params['IMAGESR'] = srid;
params['DPI'] = Math.round(
params['DPI'] ? params['DPI'] * pixelRatio : 90 * pixelRatio
params['DPI'] ? params['DPI'] * pixelRatio : 90 * pixelRatio
);
var url;
let url;
if (urls.length == 1) {
url = urls[0];
} else {
var index = modulo(_ol_tilecoord_.hash(tileCoord), urls.length);
const index = modulo(_ol_tilecoord_.hash(tileCoord), urls.length);
url = urls[index];
}
var modifiedUrl = url
.replace(/MapServer\/?$/, 'MapServer/export')
.replace(/ImageServer\/?$/, 'ImageServer/exportImage');
const modifiedUrl = url
.replace(/MapServer\/?$/, 'MapServer/export')
.replace(/ImageServer\/?$/, 'ImageServer/exportImage');
return _ol_uri_.appendParams(modifiedUrl, params);
};
@@ -142,7 +142,7 @@ TileArcGISRest.prototype.getTilePixelRatio = function(pixelRatio) {
*/
TileArcGISRest.prototype.fixedTileUrlFunction = function(tileCoord, pixelRatio, projection) {
var tileGrid = this.getTileGrid();
let tileGrid = this.getTileGrid();
if (!tileGrid) {
tileGrid = this.getTileGridForProjection(projection);
}
@@ -151,17 +151,17 @@ TileArcGISRest.prototype.fixedTileUrlFunction = function(tileCoord, pixelRatio,
return undefined;
}
var tileExtent = tileGrid.getTileCoordExtent(
tileCoord, this.tmpExtent_);
var tileSize = _ol_size_.toSize(
tileGrid.getTileSize(tileCoord[0]), this.tmpSize);
const tileExtent = tileGrid.getTileCoordExtent(
tileCoord, this.tmpExtent_);
let tileSize = _ol_size_.toSize(
tileGrid.getTileSize(tileCoord[0]), this.tmpSize);
if (pixelRatio != 1) {
tileSize = _ol_size_.scale(tileSize, pixelRatio, this.tmpSize);
}
// Apply default params and override with user specified values.
var baseParams = {
const baseParams = {
'F': 'image',
'FORMAT': 'PNG32',
'TRANSPARENT': true
@@ -169,7 +169,7 @@ TileArcGISRest.prototype.fixedTileUrlFunction = function(tileCoord, pixelRatio,
_ol_obj_.assign(baseParams, this.params_);
return this.getRequestUrl_(tileCoord, tileSize, tileExtent,
pixelRatio, projection, baseParams);
pixelRatio, projection, baseParams);
};
+9 -9
View File
@@ -22,7 +22,7 @@ import _ol_tilecoord_ from '../tilecoord.js';
* @param {olx.source.TileDebugOptions} options Debug tile options.
* @api
*/
var TileDebug = function(options) {
const TileDebug = function(options) {
TileSource.call(this, {
opaque: false,
@@ -40,16 +40,16 @@ inherits(TileDebug, TileSource);
* @inheritDoc
*/
TileDebug.prototype.getTile = function(z, x, y) {
var tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y);
const tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y);
if (this.tileCache.containsKey(tileCoordKey)) {
return /** @type {!ol.source.TileDebug.Tile_} */ (this.tileCache.get(tileCoordKey));
} else {
var tileSize = _ol_size_.toSize(this.tileGrid.getTileSize(z));
var tileCoord = [z, x, y];
var textTileCoord = this.getTileCoordForTileUrlFunction(tileCoord);
var text = !textTileCoord ? '' :
const tileSize = _ol_size_.toSize(this.tileGrid.getTileSize(z));
const tileCoord = [z, x, y];
const textTileCoord = this.getTileCoordForTileUrlFunction(tileCoord);
const text = !textTileCoord ? '' :
this.getTileCoordForTileUrlFunction(textTileCoord).toString();
var tile = new TileDebug.Tile_(tileCoord, tileSize, text);
const tile = new TileDebug.Tile_(tileCoord, tileSize, text);
this.tileCache.set(tileCoordKey, tile);
return tile;
}
@@ -98,8 +98,8 @@ TileDebug.Tile_.prototype.getImage = function() {
if (this.canvas_) {
return this.canvas_;
} else {
var tileSize = this.tileSize_;
var context = createCanvasContext2D(tileSize[0], tileSize[1]);
const tileSize = this.tileSize_;
const context = createCanvasContext2D(tileSize[0], tileSize[1]);
context.strokeStyle = 'black';
context.strokeRect(0.5, 0.5, tileSize[0] + 0.5, tileSize[1] + 0.5);
+46 -46
View File
@@ -24,7 +24,7 @@ import _ol_tilegrid_ from '../tilegrid.js';
* @param {olx.source.TileImageOptions} options Image tile options.
* @api
*/
var TileImage = function(options) {
const TileImage = function(options) {
UrlTile.call(this, {
attributions: options.attributions,
@@ -97,7 +97,7 @@ TileImage.prototype.canExpireCache = function() {
if (this.tileCache.canExpireCache()) {
return true;
} else {
for (var key in this.tileCacheForProjection) {
for (const key in this.tileCacheForProjection) {
if (this.tileCacheForProjection[key].canExpireCache()) {
return true;
}
@@ -115,11 +115,11 @@ TileImage.prototype.expireCache = function(projection, usedTiles) {
UrlTile.prototype.expireCache.call(this, projection, usedTiles);
return;
}
var usedTileCache = this.getTileCacheForProjection(projection);
const usedTileCache = this.getTileCacheForProjection(projection);
this.tileCache.expireCache(this.tileCache == usedTileCache ? usedTiles : {});
for (var id in this.tileCacheForProjection) {
var tileCache = this.tileCacheForProjection[id];
for (const id in this.tileCacheForProjection) {
const tileCache = this.tileCacheForProjection[id];
tileCache.expireCache(tileCache == usedTileCache ? usedTiles : {});
}
};
@@ -167,11 +167,11 @@ TileImage.prototype.getTileGridForProjection = function(projection) {
if (!ENABLE_RASTER_REPROJECTION) {
return UrlTile.prototype.getTileGridForProjection.call(this, projection);
}
var thisProj = this.getProjection();
const thisProj = this.getProjection();
if (this.tileGrid && (!thisProj || equivalent(thisProj, projection))) {
return this.tileGrid;
} else {
var projKey = getUid(projection).toString();
const projKey = getUid(projection).toString();
if (!(projKey in this.tileGridForProjection)) {
this.tileGridForProjection[projKey] =
_ol_tilegrid_.getForProjection(projection);
@@ -188,10 +188,10 @@ TileImage.prototype.getTileCacheForProjection = function(projection) {
if (!ENABLE_RASTER_REPROJECTION) {
return UrlTile.prototype.getTileCacheForProjection.call(this, projection);
}
var thisProj = this.getProjection(); if (!thisProj || equivalent(thisProj, projection)) {
const thisProj = this.getProjection(); if (!thisProj || equivalent(thisProj, projection)) {
return this.tileCache;
} else {
var projKey = getUid(projection).toString();
const projKey = getUid(projection).toString();
if (!(projKey in this.tileCacheForProjection)) {
this.tileCacheForProjection[projKey] = new TileCache(this.tileCache.highWaterMark);
}
@@ -211,21 +211,21 @@ TileImage.prototype.getTileCacheForProjection = function(projection) {
* @private
*/
TileImage.prototype.createTile_ = function(z, x, y, pixelRatio, projection, key) {
var tileCoord = [z, x, y];
var urlTileCoord = this.getTileCoordForTileUrlFunction(
tileCoord, projection);
var tileUrl = urlTileCoord ?
const tileCoord = [z, x, y];
const urlTileCoord = this.getTileCoordForTileUrlFunction(
tileCoord, projection);
const tileUrl = urlTileCoord ?
this.tileUrlFunction(urlTileCoord, pixelRatio, projection) : undefined;
var tile = new this.tileClass(
tileCoord,
tileUrl !== undefined ? TileState.IDLE : TileState.EMPTY,
tileUrl !== undefined ? tileUrl : '',
this.crossOrigin,
this.tileLoadFunction,
this.tileOptions);
const tile = new this.tileClass(
tileCoord,
tileUrl !== undefined ? TileState.IDLE : TileState.EMPTY,
tileUrl !== undefined ? tileUrl : '',
this.crossOrigin,
this.tileLoadFunction,
this.tileOptions);
tile.key = key;
_ol_events_.listen(tile, EventType.CHANGE,
this.handleTileChange, this);
this.handleTileChange, this);
return tile;
};
@@ -234,35 +234,35 @@ TileImage.prototype.createTile_ = function(z, x, y, pixelRatio, projection, key)
* @inheritDoc
*/
TileImage.prototype.getTile = function(z, x, y, pixelRatio, projection) {
var sourceProjection = /** @type {!ol.proj.Projection} */ (this.getProjection());
const sourceProjection = /** @type {!ol.proj.Projection} */ (this.getProjection());
if (!ENABLE_RASTER_REPROJECTION ||
!sourceProjection || !projection || equivalent(sourceProjection, projection)) {
return this.getTileInternal(z, x, y, pixelRatio, sourceProjection || projection);
} else {
var cache = this.getTileCacheForProjection(projection);
var tileCoord = [z, x, y];
var tile;
var tileCoordKey = _ol_tilecoord_.getKey(tileCoord);
const cache = this.getTileCacheForProjection(projection);
const tileCoord = [z, x, y];
let tile;
const tileCoordKey = _ol_tilecoord_.getKey(tileCoord);
if (cache.containsKey(tileCoordKey)) {
tile = /** @type {!ol.Tile} */ (cache.get(tileCoordKey));
}
var key = this.getKey();
const key = this.getKey();
if (tile && tile.key == key) {
return tile;
} else {
var sourceTileGrid = this.getTileGridForProjection(sourceProjection);
var targetTileGrid = this.getTileGridForProjection(projection);
var wrappedTileCoord =
const sourceTileGrid = this.getTileGridForProjection(sourceProjection);
const targetTileGrid = this.getTileGridForProjection(projection);
const wrappedTileCoord =
this.getTileCoordForTileUrlFunction(tileCoord, projection);
var newTile = new ReprojTile(
sourceProjection, sourceTileGrid,
projection, targetTileGrid,
tileCoord, wrappedTileCoord, this.getTilePixelRatio(pixelRatio),
this.getGutterInternal(),
function(z, x, y, pixelRatio) {
return this.getTileInternal(z, x, y, pixelRatio, sourceProjection);
}.bind(this), this.reprojectionErrorThreshold_,
this.renderReprojectionEdges_);
const newTile = new ReprojTile(
sourceProjection, sourceTileGrid,
projection, targetTileGrid,
tileCoord, wrappedTileCoord, this.getTilePixelRatio(pixelRatio),
this.getGutterInternal(),
function(z, x, y, pixelRatio) {
return this.getTileInternal(z, x, y, pixelRatio, sourceProjection);
}.bind(this), this.reprojectionErrorThreshold_,
this.renderReprojectionEdges_);
newTile.key = key;
if (tile) {
@@ -288,9 +288,9 @@ TileImage.prototype.getTile = function(z, x, y, pixelRatio, projection) {
* @protected
*/
TileImage.prototype.getTileInternal = function(z, x, y, pixelRatio, projection) {
var tile = null;
var tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y);
var key = this.getKey();
let tile = null;
const tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y);
const key = this.getKey();
if (!this.tileCache.containsKey(tileCoordKey)) {
tile = this.createTile_(z, x, y, pixelRatio, projection, key);
this.tileCache.set(tileCoordKey, tile);
@@ -300,7 +300,7 @@ TileImage.prototype.getTileInternal = function(z, x, y, pixelRatio, projection)
// The source's params changed. If the tile has an interim tile and if we
// can use it then we use it. Otherwise we create a new tile. In both
// cases we attempt to assign an interim tile to the new tile.
var interimTile = tile;
const interimTile = tile;
tile = this.createTile_(z, x, y, pixelRatio, projection, key);
//make the new tile the head of the list,
@@ -329,7 +329,7 @@ TileImage.prototype.setRenderReprojectionEdges = function(render) {
return;
}
this.renderReprojectionEdges_ = render;
for (var id in this.tileCacheForProjection) {
for (const id in this.tileCacheForProjection) {
this.tileCacheForProjection[id].clear();
}
this.changed();
@@ -350,9 +350,9 @@ TileImage.prototype.setRenderReprojectionEdges = function(render) {
*/
TileImage.prototype.setTileGridForProjection = function(projection, tilegrid) {
if (ENABLE_RASTER_REPROJECTION) {
var proj = getProjection(projection);
const proj = getProjection(projection);
if (proj) {
var projKey = getUid(proj).toString();
const projKey = getUid(proj).toString();
if (!(projKey in this.tileGridForProjection)) {
this.tileGridForProjection[projKey] = tilegrid;
}
+14 -14
View File
@@ -26,7 +26,7 @@ import _ol_tilegrid_ from '../tilegrid.js';
* @param {olx.source.TileJSONOptions} options TileJSON options.
* @api
*/
var TileJSON = function(options) {
const TileJSON = function(options) {
/**
* @type {TileJSON}
@@ -49,9 +49,9 @@ var TileJSON = function(options) {
if (options.url) {
if (options.jsonp) {
_ol_net_.jsonp(options.url, this.handleTileJSONResponse.bind(this),
this.handleTileJSONError.bind(this));
this.handleTileJSONError.bind(this));
} else {
var client = new XMLHttpRequest();
const client = new XMLHttpRequest();
client.addEventListener('load', this.onXHRLoad_.bind(this));
client.addEventListener('error', this.onXHRError_.bind(this));
client.open('GET', options.url);
@@ -73,10 +73,10 @@ inherits(TileJSON, TileImage);
* @param {Event} event The load event.
*/
TileJSON.prototype.onXHRLoad_ = function(event) {
var client = /** @type {XMLHttpRequest} */ (event.target);
const client = /** @type {XMLHttpRequest} */ (event.target);
// status will be 0 for file:// urls
if (!client.status || client.status >= 200 && client.status < 300) {
var response;
let response;
try {
response = /** @type {TileJSON} */(JSON.parse(client.responseText));
} catch (err) {
@@ -114,19 +114,19 @@ TileJSON.prototype.getTileJSON = function() {
*/
TileJSON.prototype.handleTileJSONResponse = function(tileJSON) {
var epsg4326Projection = getProjection('EPSG:4326');
const epsg4326Projection = getProjection('EPSG:4326');
var sourceProjection = this.getProjection();
var extent;
const sourceProjection = this.getProjection();
let extent;
if (tileJSON.bounds !== undefined) {
var transform = getTransformFromProjections(
epsg4326Projection, sourceProjection);
const transform = getTransformFromProjections(
epsg4326Projection, sourceProjection);
extent = applyTransform(tileJSON.bounds, transform);
}
var minZoom = tileJSON.minzoom || 0;
var maxZoom = tileJSON.maxzoom || 22;
var tileGrid = _ol_tilegrid_.createXYZ({
const minZoom = tileJSON.minzoom || 0;
const maxZoom = tileJSON.maxzoom || 22;
const tileGrid = _ol_tilegrid_.createXYZ({
extent: _ol_tilegrid_.extentFromProjection(sourceProjection),
maxZoom: maxZoom,
minZoom: minZoom
@@ -136,7 +136,7 @@ TileJSON.prototype.handleTileJSONResponse = function(tileJSON) {
this.tileUrlFunction = createFromTemplates(tileJSON.tiles, tileGrid);
if (tileJSON.attribution !== undefined && !this.getAttributions()) {
var attributionExtent = extent !== undefined ?
const attributionExtent = extent !== undefined ?
extent : epsg4326Projection.getExtent();
this.setAttributions(function(frameState) {
+42 -42
View File
@@ -25,7 +25,7 @@ import _ol_tilegrid_ from '../tilegrid.js';
* @param {olx.source.TileUTFGridOptions} options Source options.
* @api
*/
var UTFGrid = function(options) {
const UTFGrid = function(options) {
TileSource.call(this, {
projection: getProjection('EPSG:3857'),
state: SourceState.LOADING
@@ -59,9 +59,9 @@ var UTFGrid = function(options) {
if (options.url) {
if (this.jsonp_) {
_ol_net_.jsonp(options.url, this.handleTileJSONResponse.bind(this),
this.handleTileJSONError.bind(this));
this.handleTileJSONError.bind(this));
} else {
var client = new XMLHttpRequest();
const client = new XMLHttpRequest();
client.addEventListener('load', this.onXHRLoad_.bind(this));
client.addEventListener('error', this.onXHRError_.bind(this));
client.open('GET', options.url);
@@ -82,10 +82,10 @@ inherits(UTFGrid, TileSource);
* @param {Event} event The load event.
*/
UTFGrid.prototype.onXHRLoad_ = function(event) {
var client = /** @type {XMLHttpRequest} */ (event.target);
const client = /** @type {XMLHttpRequest} */ (event.target);
// status will be 0 for file:// urls
if (!client.status || client.status >= 200 && client.status < 300) {
var response;
let response;
try {
response = /** @type {TileJSON} */(JSON.parse(client.responseText));
} catch (err) {
@@ -130,12 +130,12 @@ UTFGrid.prototype.getTemplate = function() {
* @api
*/
UTFGrid.prototype.forDataAtCoordinateAndResolution = function(
coordinate, resolution, callback, opt_request) {
coordinate, resolution, callback, opt_request) {
if (this.tileGrid) {
var tileCoord = this.tileGrid.getTileCoordForCoordAndResolution(
coordinate, resolution);
var tile = /** @type {!ol.source.TileUTFGrid.Tile_} */(this.getTile(
tileCoord[0], tileCoord[1], tileCoord[2], 1, this.getProjection()));
const tileCoord = this.tileGrid.getTileCoordForCoordAndResolution(
coordinate, resolution);
const tile = /** @type {!ol.source.TileUTFGrid.Tile_} */(this.getTile(
tileCoord[0], tileCoord[1], tileCoord[2], 1, this.getProjection()));
tile.forDataAtCoordinate(coordinate, callback, null, opt_request);
} else {
if (opt_request === true) {
@@ -164,19 +164,19 @@ UTFGrid.prototype.handleTileJSONError = function() {
*/
UTFGrid.prototype.handleTileJSONResponse = function(tileJSON) {
var epsg4326Projection = getProjection('EPSG:4326');
const epsg4326Projection = getProjection('EPSG:4326');
var sourceProjection = this.getProjection();
var extent;
const sourceProjection = this.getProjection();
let extent;
if (tileJSON.bounds !== undefined) {
var transform = getTransformFromProjections(
epsg4326Projection, sourceProjection);
const transform = getTransformFromProjections(
epsg4326Projection, sourceProjection);
extent = applyTransform(tileJSON.bounds, transform);
}
var minZoom = tileJSON.minzoom || 0;
var maxZoom = tileJSON.maxzoom || 22;
var tileGrid = _ol_tilegrid_.createXYZ({
const minZoom = tileJSON.minzoom || 0;
const maxZoom = tileJSON.maxzoom || 22;
const tileGrid = _ol_tilegrid_.createXYZ({
extent: _ol_tilegrid_.extentFromProjection(sourceProjection),
maxZoom: maxZoom,
minZoom: minZoom
@@ -185,7 +185,7 @@ UTFGrid.prototype.handleTileJSONResponse = function(tileJSON) {
this.template_ = tileJSON.template;
var grids = tileJSON.grids;
const grids = tileJSON.grids;
if (!grids) {
this.setState(SourceState.ERROR);
return;
@@ -194,7 +194,7 @@ UTFGrid.prototype.handleTileJSONResponse = function(tileJSON) {
this.tileUrlFunction_ = createFromTemplates(grids, tileGrid);
if (tileJSON.attribution !== undefined) {
var attributionExtent = extent !== undefined ?
const attributionExtent = extent !== undefined ?
extent : epsg4326Projection.getExtent();
this.setAttributions(function(frameState) {
@@ -214,21 +214,21 @@ UTFGrid.prototype.handleTileJSONResponse = function(tileJSON) {
* @inheritDoc
*/
UTFGrid.prototype.getTile = function(z, x, y, pixelRatio, projection) {
var tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y);
const tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y);
if (this.tileCache.containsKey(tileCoordKey)) {
return /** @type {!ol.Tile} */ (this.tileCache.get(tileCoordKey));
} else {
var tileCoord = [z, x, y];
var urlTileCoord =
const tileCoord = [z, x, y];
const urlTileCoord =
this.getTileCoordForTileUrlFunction(tileCoord, projection);
var tileUrl = this.tileUrlFunction_(urlTileCoord, pixelRatio, projection);
var tile = new UTFGrid.Tile_(
tileCoord,
tileUrl !== undefined ? TileState.IDLE : TileState.EMPTY,
tileUrl !== undefined ? tileUrl : '',
this.tileGrid.getTileCoordExtent(tileCoord),
this.preemptive_,
this.jsonp_);
const tileUrl = this.tileUrlFunction_(urlTileCoord, pixelRatio, projection);
const tile = new UTFGrid.Tile_(
tileCoord,
tileUrl !== undefined ? TileState.IDLE : TileState.EMPTY,
tileUrl !== undefined ? tileUrl : '',
this.tileGrid.getTileCoordExtent(tileCoord),
this.preemptive_,
this.jsonp_);
this.tileCache.set(tileCoordKey, tile);
return tile;
}
@@ -239,7 +239,7 @@ UTFGrid.prototype.getTile = function(z, x, y, pixelRatio, projection) {
* @inheritDoc
*/
UTFGrid.prototype.useTile = function(z, x, y) {
var tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y);
const tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y);
if (this.tileCache.containsKey(tileCoordKey)) {
this.tileCache.get(tileCoordKey);
}
@@ -326,18 +326,18 @@ UTFGrid.Tile_.prototype.getData = function(coordinate) {
if (!this.grid_ || !this.keys_) {
return null;
}
var xRelative = (coordinate[0] - this.extent_[0]) /
const xRelative = (coordinate[0] - this.extent_[0]) /
(this.extent_[2] - this.extent_[0]);
var yRelative = (coordinate[1] - this.extent_[1]) /
const yRelative = (coordinate[1] - this.extent_[1]) /
(this.extent_[3] - this.extent_[1]);
var row = this.grid_[Math.floor((1 - yRelative) * this.grid_.length)];
const row = this.grid_[Math.floor((1 - yRelative) * this.grid_.length)];
if (typeof row !== 'string') {
return null;
}
var code = row.charCodeAt(Math.floor(xRelative * row.length));
let code = row.charCodeAt(Math.floor(xRelative * row.length));
if (code >= 93) {
code--;
}
@@ -346,9 +346,9 @@ UTFGrid.Tile_.prototype.getData = function(coordinate) {
}
code -= 32;
var data = null;
let data = null;
if (code in this.keys_) {
var id = this.keys_[code];
const id = this.keys_[code];
if (this.data_ && id in this.data_) {
data = this.data_[id];
} else {
@@ -426,9 +426,9 @@ UTFGrid.Tile_.prototype.loadInternal_ = function() {
this.state = TileState.LOADING;
if (this.jsonp_) {
_ol_net_.jsonp(this.src_, this.handleLoad_.bind(this),
this.handleError_.bind(this));
this.handleError_.bind(this));
} else {
var client = new XMLHttpRequest();
const client = new XMLHttpRequest();
client.addEventListener('load', this.onXHRLoad_.bind(this));
client.addEventListener('error', this.onXHRError_.bind(this));
client.open('GET', this.src_);
@@ -443,10 +443,10 @@ UTFGrid.Tile_.prototype.loadInternal_ = function() {
* @param {Event} event The load event.
*/
UTFGrid.Tile_.prototype.onXHRLoad_ = function(event) {
var client = /** @type {XMLHttpRequest} */ (event.target);
const client = /** @type {XMLHttpRequest} */ (event.target);
// status will be 0 for file:// urls
if (!client.status || client.status >= 200 && client.status < 300) {
var response;
let response;
try {
response = /** @type {!UTFGridJSON} */(JSON.parse(client.responseText));
} catch (err) {
+36 -36
View File
@@ -26,13 +26,13 @@ import _ol_uri_ from '../uri.js';
* @param {olx.source.TileWMSOptions=} opt_options Tile WMS options.
* @api
*/
var TileWMS = function(opt_options) {
const TileWMS = function(opt_options) {
var options = opt_options || {};
const options = opt_options || {};
var params = options.params || {};
const params = options.params || {};
var transparent = 'TRANSPARENT' in params ? params['TRANSPARENT'] : true;
const transparent = 'TRANSPARENT' in params ? params['TRANSPARENT'] : true;
TileImage.call(this, {
attributions: options.attributions,
@@ -109,26 +109,26 @@ inherits(TileWMS, TileImage);
* @api
*/
TileWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projection, params) {
var projectionObj = getProjection(projection);
var sourceProjectionObj = this.getProjection();
const projectionObj = getProjection(projection);
const sourceProjectionObj = this.getProjection();
var tileGrid = this.getTileGrid();
let tileGrid = this.getTileGrid();
if (!tileGrid) {
tileGrid = this.getTileGridForProjection(projectionObj);
}
var tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, resolution);
const tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, resolution);
if (tileGrid.getResolutions().length <= tileCoord[0]) {
return undefined;
}
var tileResolution = tileGrid.getResolution(tileCoord[0]);
var tileExtent = tileGrid.getTileCoordExtent(tileCoord, this.tmpExtent_);
var tileSize = _ol_size_.toSize(tileGrid.getTileSize(tileCoord[0]), this.tmpSize);
let tileResolution = tileGrid.getResolution(tileCoord[0]);
let tileExtent = tileGrid.getTileCoordExtent(tileCoord, this.tmpExtent_);
let tileSize = _ol_size_.toSize(tileGrid.getTileSize(tileCoord[0]), this.tmpSize);
var gutter = this.gutter_;
const gutter = this.gutter_;
if (gutter !== 0) {
tileSize = _ol_size_.buffer(tileSize, gutter, this.tmpSize);
tileExtent = buffer(tileExtent, tileResolution * gutter, tileExtent);
@@ -140,7 +140,7 @@ TileWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projec
coordinate = transform(coordinate, projectionObj, sourceProjectionObj);
}
var baseParams = {
const baseParams = {
'SERVICE': 'WMS',
'VERSION': DEFAULT_WMS_VERSION,
'REQUEST': 'GetFeatureInfo',
@@ -150,14 +150,14 @@ TileWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projec
};
_ol_obj_.assign(baseParams, this.params_, params);
var x = Math.floor((coordinate[0] - tileExtent[0]) / tileResolution);
var y = Math.floor((tileExtent[3] - coordinate[1]) / tileResolution);
const x = Math.floor((coordinate[0] - tileExtent[0]) / tileResolution);
const y = Math.floor((tileExtent[3] - coordinate[1]) / tileResolution);
baseParams[this.v13_ ? 'I' : 'X'] = x;
baseParams[this.v13_ ? 'J' : 'Y'] = y;
return this.getRequestUrl_(tileCoord, tileSize, tileExtent,
1, sourceProjectionObj || projectionObj, baseParams);
1, sourceProjectionObj || projectionObj, baseParams);
};
@@ -191,9 +191,9 @@ TileWMS.prototype.getParams = function() {
* @private
*/
TileWMS.prototype.getRequestUrl_ = function(tileCoord, tileSize, tileExtent,
pixelRatio, projection, params) {
pixelRatio, projection, params) {
var urls = this.urls;
const urls = this.urls;
if (!urls) {
return undefined;
}
@@ -210,7 +210,7 @@ TileWMS.prototype.getRequestUrl_ = function(tileCoord, tileSize, tileExtent,
if (pixelRatio != 1) {
switch (this.serverType_) {
case WMSServerType.GEOSERVER:
var dpi = (90 * pixelRatio + 0.5) | 0;
const dpi = (90 * pixelRatio + 0.5) | 0;
if ('FORMAT_OPTIONS' in params) {
params['FORMAT_OPTIONS'] += ';dpi:' + dpi;
} else {
@@ -230,10 +230,10 @@ TileWMS.prototype.getRequestUrl_ = function(tileCoord, tileSize, tileExtent,
}
}
var axisOrientation = projection.getAxisOrientation();
var bbox = tileExtent;
const axisOrientation = projection.getAxisOrientation();
const bbox = tileExtent;
if (this.v13_ && axisOrientation.substr(0, 2) == 'ne') {
var tmp;
let tmp;
tmp = tileExtent[0];
bbox[0] = tileExtent[1];
bbox[1] = tmp;
@@ -243,11 +243,11 @@ TileWMS.prototype.getRequestUrl_ = function(tileCoord, tileSize, tileExtent,
}
params['BBOX'] = bbox.join(',');
var url;
let url;
if (urls.length == 1) {
url = urls[0];
} else {
var index = modulo(_ol_tilecoord_.hash(tileCoord), urls.length);
const index = modulo(_ol_tilecoord_.hash(tileCoord), urls.length);
url = urls[index];
}
return _ol_uri_.appendParams(url, params);
@@ -268,9 +268,9 @@ TileWMS.prototype.getTilePixelRatio = function(pixelRatio) {
* @return {string} The key for the current params.
*/
TileWMS.prototype.getKeyForParams_ = function() {
var i = 0;
var res = [];
for (var key in this.params_) {
let i = 0;
const res = [];
for (const key in this.params_) {
res[i++] = key + '-' + this.params_[key];
}
return res.join('/');
@@ -282,7 +282,7 @@ TileWMS.prototype.getKeyForParams_ = function() {
*/
TileWMS.prototype.fixedTileUrlFunction = function(tileCoord, pixelRatio, projection) {
var tileGrid = this.getTileGrid();
let tileGrid = this.getTileGrid();
if (!tileGrid) {
tileGrid = this.getTileGridForProjection(projection);
}
@@ -295,12 +295,12 @@ TileWMS.prototype.fixedTileUrlFunction = function(tileCoord, pixelRatio, project
pixelRatio = 1;
}
var tileResolution = tileGrid.getResolution(tileCoord[0]);
var tileExtent = tileGrid.getTileCoordExtent(tileCoord, this.tmpExtent_);
var tileSize = _ol_size_.toSize(
tileGrid.getTileSize(tileCoord[0]), this.tmpSize);
const tileResolution = tileGrid.getResolution(tileCoord[0]);
let tileExtent = tileGrid.getTileCoordExtent(tileCoord, this.tmpExtent_);
let tileSize = _ol_size_.toSize(
tileGrid.getTileSize(tileCoord[0]), this.tmpSize);
var gutter = this.gutter_;
const gutter = this.gutter_;
if (gutter !== 0) {
tileSize = _ol_size_.buffer(tileSize, gutter, this.tmpSize);
tileExtent = buffer(tileExtent, tileResolution * gutter, tileExtent);
@@ -310,7 +310,7 @@ TileWMS.prototype.fixedTileUrlFunction = function(tileCoord, pixelRatio, project
tileSize = _ol_size_.scale(tileSize, pixelRatio, this.tmpSize);
}
var baseParams = {
const baseParams = {
'SERVICE': 'WMS',
'VERSION': DEFAULT_WMS_VERSION,
'REQUEST': 'GetMap',
@@ -320,7 +320,7 @@ TileWMS.prototype.fixedTileUrlFunction = function(tileCoord, pixelRatio, project
_ol_obj_.assign(baseParams, this.params_);
return this.getRequestUrl_(tileCoord, tileSize, tileExtent,
pixelRatio, projection, baseParams);
pixelRatio, projection, baseParams);
};
/**
@@ -339,7 +339,7 @@ TileWMS.prototype.updateParams = function(params) {
* @private
*/
TileWMS.prototype.updateV13_ = function() {
var version = this.params_['VERSION'] || DEFAULT_WMS_VERSION;
const version = this.params_['VERSION'] || DEFAULT_WMS_VERSION;
this.v13_ = _ol_string_.compareVersions(version, '1.3') >= 0;
};
export default TileWMS;
+8 -8
View File
@@ -18,7 +18,7 @@ import _ol_tilecoord_ from '../tilecoord.js';
* @extends {ol.source.Tile}
* @param {ol.SourceUrlTileOptions} options Image tile options.
*/
var UrlTile = function(options) {
const UrlTile = function(options) {
TileSource.call(this, {
attributions: options.attributions,
@@ -116,10 +116,10 @@ UrlTile.prototype.getUrls = function() {
* @protected
*/
UrlTile.prototype.handleTileChange = function(event) {
var tile = /** @type {ol.Tile} */ (event.target);
var uid = getUid(tile);
var tileState = tile.getState();
var type;
const tile = /** @type {ol.Tile} */ (event.target);
const uid = getUid(tile);
const tileState = tile.getState();
let type;
if (tileState == TileState.LOADING) {
this.tileLoadingKeys_[uid] = true;
type = TileEventType.TILELOADSTART;
@@ -170,7 +170,7 @@ UrlTile.prototype.setTileUrlFunction = function(tileUrlFunction, opt_key) {
* @api
*/
UrlTile.prototype.setUrl = function(url) {
var urls = this.urls = expandUrl(url);
const urls = this.urls = expandUrl(url);
this.setTileUrlFunction(this.fixedTileUrlFunction ?
this.fixedTileUrlFunction.bind(this) :
createFromTemplates(urls, this.tileGrid), url);
@@ -184,7 +184,7 @@ UrlTile.prototype.setUrl = function(url) {
*/
UrlTile.prototype.setUrls = function(urls) {
this.urls = urls;
var key = urls.join('\n');
const key = urls.join('\n');
this.setTileUrlFunction(this.fixedTileUrlFunction ?
this.fixedTileUrlFunction.bind(this) :
createFromTemplates(urls, this.tileGrid), key);
@@ -195,7 +195,7 @@ UrlTile.prototype.setUrls = function(urls) {
* @inheritDoc
*/
UrlTile.prototype.useTile = function(z, x, y) {
var tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y);
const tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y);
if (this.tileCache.containsKey(tileCoordKey)) {
this.tileCache.get(tileCoordKey);
}
+119 -119
View File
@@ -33,9 +33,9 @@ import RBush from '../structs/RBush.js';
* @param {olx.source.VectorOptions=} opt_options Vector source options.
* @api
*/
var VectorSource = function(opt_options) {
const VectorSource = function(opt_options) {
var options = opt_options || {};
const options = opt_options || {};
Source.call(this, {
attributions: options.attributions,
@@ -83,7 +83,7 @@ var VectorSource = function(opt_options) {
this.strategy_ = options.strategy !== undefined ? options.strategy :
_ol_loadingstrategy_.all;
var useSpatialIndex =
const useSpatialIndex =
options.useSpatialIndex !== undefined ? options.useSpatialIndex : true;
/**
@@ -130,7 +130,7 @@ var VectorSource = function(opt_options) {
*/
this.featuresCollection_ = null;
var collection, features;
let collection, features;
if (options.features instanceof Collection) {
collection = options.features;
features = collection.getArray();
@@ -173,7 +173,7 @@ VectorSource.prototype.addFeature = function(feature) {
* @protected
*/
VectorSource.prototype.addFeatureInternal = function(feature) {
var featureKey = getUid(feature).toString();
const featureKey = getUid(feature).toString();
if (!this.addToIndex_(featureKey, feature)) {
return;
@@ -181,9 +181,9 @@ VectorSource.prototype.addFeatureInternal = function(feature) {
this.setupChangeEvents_(featureKey, feature);
var geometry = feature.getGeometry();
const geometry = feature.getGeometry();
if (geometry) {
var extent = geometry.getExtent();
const extent = geometry.getExtent();
if (this.featuresRtree_) {
this.featuresRtree_.insert(extent, feature);
}
@@ -192,7 +192,7 @@ VectorSource.prototype.addFeatureInternal = function(feature) {
}
this.dispatchEvent(
new VectorSource.Event(VectorEventType.ADDFEATURE, feature));
new VectorSource.Event(VectorEventType.ADDFEATURE, feature));
};
@@ -204,9 +204,9 @@ VectorSource.prototype.addFeatureInternal = function(feature) {
VectorSource.prototype.setupChangeEvents_ = function(featureKey, feature) {
this.featureChangeKeys_[featureKey] = [
_ol_events_.listen(feature, EventType.CHANGE,
this.handleFeatureChange_, this),
this.handleFeatureChange_, this),
_ol_events_.listen(feature, ObjectEventType.PROPERTYCHANGE,
this.handleFeatureChange_, this)
this.handleFeatureChange_, this)
];
};
@@ -219,8 +219,8 @@ VectorSource.prototype.setupChangeEvents_ = function(featureKey, feature) {
* @private
*/
VectorSource.prototype.addToIndex_ = function(featureKey, feature) {
var valid = true;
var id = feature.getId();
let valid = true;
const id = feature.getId();
if (id !== undefined) {
if (!(id.toString() in this.idIndex_)) {
this.idIndex_[id.toString()] = feature;
@@ -229,7 +229,7 @@ VectorSource.prototype.addToIndex_ = function(featureKey, feature) {
}
} else {
assert(!(featureKey in this.undefIdIndex_),
30); // The passed `feature` was already added to the source
30); // The passed `feature` was already added to the source
this.undefIdIndex_[featureKey] = feature;
}
return valid;
@@ -253,11 +253,11 @@ VectorSource.prototype.addFeatures = function(features) {
* @protected
*/
VectorSource.prototype.addFeaturesInternal = function(features) {
var featureKey, i, length, feature;
let featureKey, i, length, feature;
var extents = [];
var newFeatures = [];
var geometryFeatures = [];
const extents = [];
const newFeatures = [];
const geometryFeatures = [];
for (i = 0, length = features.length; i < length; i++) {
feature = features[i];
@@ -272,9 +272,9 @@ VectorSource.prototype.addFeaturesInternal = function(features) {
featureKey = getUid(feature).toString();
this.setupChangeEvents_(featureKey, feature);
var geometry = feature.getGeometry();
const geometry = feature.getGeometry();
if (geometry) {
var extent = geometry.getExtent();
const extent = geometry.getExtent();
extents.push(extent);
geometryFeatures.push(feature);
} else {
@@ -287,7 +287,7 @@ VectorSource.prototype.addFeaturesInternal = function(features) {
for (i = 0, length = newFeatures.length; i < length; i++) {
this.dispatchEvent(new VectorSource.Event(
VectorEventType.ADDFEATURE, newFeatures[i]));
VectorEventType.ADDFEATURE, newFeatures[i]));
}
};
@@ -297,39 +297,39 @@ VectorSource.prototype.addFeaturesInternal = function(features) {
* @private
*/
VectorSource.prototype.bindFeaturesCollection_ = function(collection) {
var modifyingCollection = false;
let modifyingCollection = false;
_ol_events_.listen(this, VectorEventType.ADDFEATURE,
function(evt) {
if (!modifyingCollection) {
modifyingCollection = true;
collection.push(evt.feature);
modifyingCollection = false;
}
});
function(evt) {
if (!modifyingCollection) {
modifyingCollection = true;
collection.push(evt.feature);
modifyingCollection = false;
}
});
_ol_events_.listen(this, VectorEventType.REMOVEFEATURE,
function(evt) {
if (!modifyingCollection) {
modifyingCollection = true;
collection.remove(evt.feature);
modifyingCollection = false;
}
});
function(evt) {
if (!modifyingCollection) {
modifyingCollection = true;
collection.remove(evt.feature);
modifyingCollection = false;
}
});
_ol_events_.listen(collection, CollectionEventType.ADD,
function(evt) {
if (!modifyingCollection) {
modifyingCollection = true;
this.addFeature(/** @type {ol.Feature} */ (evt.element));
modifyingCollection = false;
}
}, this);
function(evt) {
if (!modifyingCollection) {
modifyingCollection = true;
this.addFeature(/** @type {ol.Feature} */ (evt.element));
modifyingCollection = false;
}
}, this);
_ol_events_.listen(collection, CollectionEventType.REMOVE,
function(evt) {
if (!modifyingCollection) {
modifyingCollection = true;
this.removeFeature(/** @type {ol.Feature} */ (evt.element));
modifyingCollection = false;
}
}, this);
function(evt) {
if (!modifyingCollection) {
modifyingCollection = true;
this.removeFeature(/** @type {ol.Feature} */ (evt.element));
modifyingCollection = false;
}
}, this);
this.featuresCollection_ = collection;
};
@@ -341,8 +341,8 @@ VectorSource.prototype.bindFeaturesCollection_ = function(collection) {
*/
VectorSource.prototype.clear = function(opt_fast) {
if (opt_fast) {
for (var featureId in this.featureChangeKeys_) {
var keys = this.featureChangeKeys_[featureId];
for (const featureId in this.featureChangeKeys_) {
const keys = this.featureChangeKeys_[featureId];
keys.forEach(_ol_events_.unlistenByKey);
}
if (!this.featuresCollection_) {
@@ -353,7 +353,7 @@ VectorSource.prototype.clear = function(opt_fast) {
} else {
if (this.featuresRtree_) {
this.featuresRtree_.forEach(this.removeFeatureInternal, this);
for (var id in this.nullGeometryFeatures_) {
for (const id in this.nullGeometryFeatures_) {
this.removeFeatureInternal(this.nullGeometryFeatures_[id]);
}
}
@@ -368,7 +368,7 @@ VectorSource.prototype.clear = function(opt_fast) {
this.loadedExtentsRtree_.clear();
this.nullGeometryFeatures_ = {};
var clearEvent = new VectorSource.Event(VectorEventType.CLEAR);
const clearEvent = new VectorSource.Event(VectorEventType.CLEAR);
this.dispatchEvent(clearEvent);
this.changed();
};
@@ -407,9 +407,9 @@ VectorSource.prototype.forEachFeature = function(callback) {
* @template T
*/
VectorSource.prototype.forEachFeatureAtCoordinateDirect = function(coordinate, callback) {
var extent = [coordinate[0], coordinate[1], coordinate[0], coordinate[1]];
const extent = [coordinate[0], coordinate[1], coordinate[0], coordinate[1]];
return this.forEachFeatureInExtent(extent, function(feature) {
var geometry = feature.getGeometry();
const geometry = feature.getGeometry();
if (geometry.intersectsCoordinate(coordinate)) {
return callback(feature);
} else {
@@ -466,20 +466,20 @@ VectorSource.prototype.forEachFeatureInExtent = function(extent, callback) {
*/
VectorSource.prototype.forEachFeatureIntersectingExtent = function(extent, callback) {
return this.forEachFeatureInExtent(extent,
/**
/**
* @param {ol.Feature} feature Feature.
* @return {T|undefined} The return value from the last call to the callback.
* @template T
*/
function(feature) {
var geometry = feature.getGeometry();
if (geometry.intersectsExtent(extent)) {
var result = callback(feature);
if (result) {
return result;
}
function(feature) {
const geometry = feature.getGeometry();
if (geometry.intersectsExtent(extent)) {
const result = callback(feature);
if (result) {
return result;
}
});
}
});
};
@@ -501,7 +501,7 @@ VectorSource.prototype.getFeaturesCollection = function() {
* @api
*/
VectorSource.prototype.getFeatures = function() {
var features;
let features;
if (this.featuresCollection_) {
features = this.featuresCollection_.getArray();
} else if (this.featuresRtree_) {
@@ -521,7 +521,7 @@ VectorSource.prototype.getFeatures = function() {
* @api
*/
VectorSource.prototype.getFeaturesAtCoordinate = function(coordinate) {
var features = [];
const features = [];
this.forEachFeatureAtCoordinateDirect(coordinate, function(feature) {
features.push(feature);
});
@@ -565,37 +565,37 @@ VectorSource.prototype.getClosestFeatureToCoordinate = function(coordinate, opt_
// extent, trying to find a closer feature. Every time we find a closer
// feature, we update the extent being searched so that any even closer
// feature must intersect it. We continue until we run out of features.
var x = coordinate[0];
var y = coordinate[1];
var closestFeature = null;
var closestPoint = [NaN, NaN];
var minSquaredDistance = Infinity;
var extent = [-Infinity, -Infinity, Infinity, Infinity];
var filter = opt_filter ? opt_filter : TRUE;
const x = coordinate[0];
const y = coordinate[1];
let closestFeature = null;
const closestPoint = [NaN, NaN];
let minSquaredDistance = Infinity;
const extent = [-Infinity, -Infinity, Infinity, Infinity];
const filter = opt_filter ? opt_filter : TRUE;
this.featuresRtree_.forEachInExtent(extent,
/**
/**
* @param {ol.Feature} feature Feature.
*/
function(feature) {
if (filter(feature)) {
var geometry = feature.getGeometry();
var previousMinSquaredDistance = minSquaredDistance;
minSquaredDistance = geometry.closestPointXY(
x, y, closestPoint, minSquaredDistance);
if (minSquaredDistance < previousMinSquaredDistance) {
closestFeature = feature;
// This is sneaky. Reduce the extent that it is currently being
// searched while the R-Tree traversal using this same extent object
// is still in progress. This is safe because the new extent is
// strictly contained by the old extent.
var minDistance = Math.sqrt(minSquaredDistance);
extent[0] = x - minDistance;
extent[1] = y - minDistance;
extent[2] = x + minDistance;
extent[3] = y + minDistance;
}
function(feature) {
if (filter(feature)) {
const geometry = feature.getGeometry();
const previousMinSquaredDistance = minSquaredDistance;
minSquaredDistance = geometry.closestPointXY(
x, y, closestPoint, minSquaredDistance);
if (minSquaredDistance < previousMinSquaredDistance) {
closestFeature = feature;
// This is sneaky. Reduce the extent that it is currently being
// searched while the R-Tree traversal using this same extent object
// is still in progress. This is safe because the new extent is
// strictly contained by the old extent.
const minDistance = Math.sqrt(minSquaredDistance);
extent[0] = x - minDistance;
extent[1] = y - minDistance;
extent[2] = x + minDistance;
extent[3] = y + minDistance;
}
});
}
});
return closestFeature;
};
@@ -625,7 +625,7 @@ VectorSource.prototype.getExtent = function(opt_extent) {
* @api
*/
VectorSource.prototype.getFeatureById = function(id) {
var feature = this.idIndex_[id.toString()];
const feature = this.idIndex_[id.toString()];
return feature !== undefined ? feature : null;
};
@@ -671,9 +671,9 @@ VectorSource.prototype.getUrl = function() {
* @private
*/
VectorSource.prototype.handleFeatureChange_ = function(event) {
var feature = /** @type {ol.Feature} */ (event.target);
var featureKey = getUid(feature).toString();
var geometry = feature.getGeometry();
const feature = /** @type {ol.Feature} */ (event.target);
const featureKey = getUid(feature).toString();
const geometry = feature.getGeometry();
if (!geometry) {
if (!(featureKey in this.nullGeometryFeatures_)) {
if (this.featuresRtree_) {
@@ -682,7 +682,7 @@ VectorSource.prototype.handleFeatureChange_ = function(event) {
this.nullGeometryFeatures_[featureKey] = feature;
}
} else {
var extent = geometry.getExtent();
const extent = geometry.getExtent();
if (featureKey in this.nullGeometryFeatures_) {
delete this.nullGeometryFeatures_[featureKey];
if (this.featuresRtree_) {
@@ -694,9 +694,9 @@ VectorSource.prototype.handleFeatureChange_ = function(event) {
}
}
}
var id = feature.getId();
const id = feature.getId();
if (id !== undefined) {
var sid = id.toString();
const sid = id.toString();
if (featureKey in this.undefIdIndex_) {
delete this.undefIdIndex_[featureKey];
this.idIndex_[sid] = feature;
@@ -714,7 +714,7 @@ VectorSource.prototype.handleFeatureChange_ = function(event) {
}
this.changed();
this.dispatchEvent(new VectorSource.Event(
VectorEventType.CHANGEFEATURE, feature));
VectorEventType.CHANGEFEATURE, feature));
};
@@ -733,20 +733,20 @@ VectorSource.prototype.isEmpty = function() {
* @param {ol.proj.Projection} projection Projection.
*/
VectorSource.prototype.loadFeatures = function(
extent, resolution, projection) {
var loadedExtentsRtree = this.loadedExtentsRtree_;
var extentsToLoad = this.strategy_(extent, resolution);
var i, ii;
extent, resolution, projection) {
const loadedExtentsRtree = this.loadedExtentsRtree_;
const extentsToLoad = this.strategy_(extent, resolution);
let i, ii;
for (i = 0, ii = extentsToLoad.length; i < ii; ++i) {
var extentToLoad = extentsToLoad[i];
var alreadyLoaded = loadedExtentsRtree.forEachInExtent(extentToLoad,
/**
const extentToLoad = extentsToLoad[i];
const alreadyLoaded = loadedExtentsRtree.forEachInExtent(extentToLoad,
/**
* @param {{extent: ol.Extent}} object Object.
* @return {boolean} Contains.
*/
function(object) {
return containsExtent(object.extent, extentToLoad);
});
function(object) {
return containsExtent(object.extent, extentToLoad);
});
if (!alreadyLoaded) {
this.loader_.call(this, extentToLoad, resolution, projection);
loadedExtentsRtree.insert(extentToLoad, {extent: extentToLoad.slice()});
@@ -761,8 +761,8 @@ VectorSource.prototype.loadFeatures = function(
* @api
*/
VectorSource.prototype.removeLoadedExtent = function(extent) {
var loadedExtentsRtree = this.loadedExtentsRtree_;
var obj;
const loadedExtentsRtree = this.loadedExtentsRtree_;
let obj;
loadedExtentsRtree.forEachInExtent(extent, function(object) {
if (equals(object.extent, extent)) {
obj = object;
@@ -783,7 +783,7 @@ VectorSource.prototype.removeLoadedExtent = function(extent) {
* @api
*/
VectorSource.prototype.removeFeature = function(feature) {
var featureKey = getUid(feature).toString();
const featureKey = getUid(feature).toString();
if (featureKey in this.nullGeometryFeatures_) {
delete this.nullGeometryFeatures_[featureKey];
} else {
@@ -802,17 +802,17 @@ VectorSource.prototype.removeFeature = function(feature) {
* @protected
*/
VectorSource.prototype.removeFeatureInternal = function(feature) {
var featureKey = getUid(feature).toString();
const featureKey = getUid(feature).toString();
this.featureChangeKeys_[featureKey].forEach(_ol_events_.unlistenByKey);
delete this.featureChangeKeys_[featureKey];
var id = feature.getId();
const id = feature.getId();
if (id !== undefined) {
delete this.idIndex_[id.toString()];
} else {
delete this.undefIdIndex_[featureKey];
}
this.dispatchEvent(new VectorSource.Event(
VectorEventType.REMOVEFEATURE, feature));
VectorEventType.REMOVEFEATURE, feature));
};
@@ -824,8 +824,8 @@ VectorSource.prototype.removeFeatureInternal = function(feature) {
* @private
*/
VectorSource.prototype.removeFromIdIndex_ = function(feature) {
var removed = false;
for (var id in this.idIndex_) {
let removed = false;
for (const id in this.idIndex_) {
if (this.idIndex_[id] === feature) {
delete this.idIndex_[id];
removed = true;
+22 -22
View File
@@ -26,12 +26,12 @@ import _ol_tilegrid_ from '../tilegrid.js';
* @param {olx.source.VectorTileOptions} options Vector tile options.
* @api
*/
var VectorTileSource = function(options) {
var projection = options.projection || 'EPSG:3857';
const VectorTileSource = function(options) {
const projection = options.projection || 'EPSG:3857';
var extent = options.extent || _ol_tilegrid_.extentFromProjection(projection);
const extent = options.extent || _ol_tilegrid_.extentFromProjection(projection);
var tileGrid = options.tileGrid || _ol_tilegrid_.createXYZ({
const tileGrid = options.tileGrid || _ol_tilegrid_.createXYZ({
extent: extent,
maxZoom: options.maxZoom || 22,
minZoom: options.minZoom,
@@ -110,22 +110,22 @@ VectorTileSource.prototype.clear = function() {
* @inheritDoc
*/
VectorTileSource.prototype.getTile = function(z, x, y, pixelRatio, projection) {
var tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y);
const tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y);
if (this.tileCache.containsKey(tileCoordKey)) {
return /** @type {!ol.Tile} */ (this.tileCache.get(tileCoordKey));
} else {
var tileCoord = [z, x, y];
var urlTileCoord = this.getTileCoordForTileUrlFunction(
tileCoord, projection);
var tile = new VectorImageTile(
tileCoord,
urlTileCoord !== null ? TileState.IDLE : TileState.EMPTY,
this.getRevision(),
this.format_, this.tileLoadFunction, urlTileCoord, this.tileUrlFunction,
this.tileGrid, this.getTileGridForProjection(projection),
this.sourceTiles_, pixelRatio, projection, this.tileClass,
this.handleTileChange.bind(this),
this.tileOptions);
const tileCoord = [z, x, y];
const urlTileCoord = this.getTileCoordForTileUrlFunction(
tileCoord, projection);
const tile = new VectorImageTile(
tileCoord,
urlTileCoord !== null ? TileState.IDLE : TileState.EMPTY,
this.getRevision(),
this.format_, this.tileLoadFunction, urlTileCoord, this.tileUrlFunction,
this.tileGrid, this.getTileGridForProjection(projection),
this.sourceTiles_, pixelRatio, projection, this.tileClass,
this.handleTileChange.bind(this),
this.tileOptions);
this.tileCache.set(tileCoordKey, tile);
return tile;
@@ -137,14 +137,14 @@ VectorTileSource.prototype.getTile = function(z, x, y, pixelRatio, projection) {
* @inheritDoc
*/
VectorTileSource.prototype.getTileGridForProjection = function(projection) {
var code = projection.getCode();
var tileGrid = this.tileGrids_[code];
const code = projection.getCode();
let tileGrid = this.tileGrids_[code];
if (!tileGrid) {
// A tile grid that matches the tile size of the source tile grid is more
// likely to have 1:1 relationships between source tiles and rendered tiles.
var sourceTileGrid = this.tileGrid;
const sourceTileGrid = this.tileGrid;
tileGrid = this.tileGrids_[code] = _ol_tilegrid_.createForProjection(projection, undefined,
sourceTileGrid ? sourceTileGrid.getTileSize(sourceTileGrid.getMinZoom()) : undefined);
sourceTileGrid ? sourceTileGrid.getTileSize(sourceTileGrid.getMinZoom()) : undefined);
}
return tileGrid;
};
@@ -162,7 +162,7 @@ VectorTileSource.prototype.getTilePixelRatio = function(pixelRatio) {
* @inheritDoc
*/
VectorTileSource.prototype.getTilePixelSize = function(z, pixelRatio, projection) {
var tileSize = _ol_size_.toSize(this.getTileGridForProjection(projection).getTileSize(z));
const tileSize = _ol_size_.toSize(this.getTileGridForProjection(projection).getTileSize(z));
return [Math.round(tileSize[0] * pixelRatio), Math.round(tileSize[1] * pixelRatio)];
};
export default VectorTileSource;
+57 -57
View File
@@ -21,7 +21,7 @@ import _ol_uri_ from '../uri.js';
* @param {olx.source.WMTSOptions} options WMTS options.
* @api
*/
var WMTS = function(options) {
const WMTS = function(options) {
// TODO: add support for TileMatrixLimits
@@ -61,7 +61,7 @@ var WMTS = function(options) {
*/
this.style_ = options.style;
var urls = options.urls;
let urls = options.urls;
if (urls === undefined && options.url !== undefined) {
urls = expandUrl(options.url);
}
@@ -77,15 +77,15 @@ var WMTS = function(options) {
/** @type {ol.source.WMTSRequestEncoding} */ (options.requestEncoding) :
WMTSRequestEncoding.KVP;
var requestEncoding = this.requestEncoding_;
const requestEncoding = this.requestEncoding_;
// FIXME: should we create a default tileGrid?
// we could issue a getCapabilities xhr to retrieve missing configuration
var tileGrid = options.tileGrid;
const tileGrid = options.tileGrid;
// context property names are lower case to allow for a case insensitive
// replacement as some services use different naming conventions
var context = {
const context = {
'layer': this.layer_,
'style': this.style_,
'tilematrixset': this.matrixSet_
@@ -100,7 +100,7 @@ var WMTS = function(options) {
});
}
var dimensions = this.dimensions_;
const dimensions = this.dimensions_;
/**
* @param {string} template Template.
@@ -130,13 +130,13 @@ var WMTS = function(options) {
if (!tileCoord) {
return undefined;
} else {
var localContext = {
const localContext = {
'TileMatrix': tileGrid.getMatrixId(tileCoord[0]),
'TileCol': tileCoord[1],
'TileRow': -tileCoord[2] - 1
};
_ol_obj_.assign(localContext, dimensions);
var url = template;
let url = template;
if (requestEncoding == WMTSRequestEncoding.KVP) {
url = _ol_uri_.appendParams(url, localContext);
} else {
@@ -150,7 +150,7 @@ var WMTS = function(options) {
);
};
var tileUrlFunction = (urls && urls.length > 0) ?
const tileUrlFunction = (urls && urls.length > 0) ?
createFromTileUrlFunctions(urls.map(this.createFromWMTSTemplate_)) : nullTileUrlFunction;
TileImage.call(this, {
@@ -182,7 +182,7 @@ inherits(WMTS, TileImage);
*/
WMTS.prototype.setUrls = function(urls) {
this.urls = urls;
var key = urls.join('\n');
const key = urls.join('\n');
this.setTileUrlFunction(this.fixedTileUrlFunction ?
this.fixedTileUrlFunction.bind(this) :
createFromTileUrlFunctions(urls.map(this.createFromWMTSTemplate_.bind(this))), key);
@@ -265,9 +265,9 @@ WMTS.prototype.getVersion = function() {
* @return {string} The key for the current dimensions.
*/
WMTS.prototype.getKeyForDimensions_ = function() {
var i = 0;
var res = [];
for (var key in this.dimensions_) {
let i = 0;
const res = [];
for (const key in this.dimensions_) {
res[i++] = key + '-' + this.dimensions_[key];
}
return res.join('/');
@@ -310,37 +310,37 @@ WMTS.prototype.updateDimensions = function(dimensions) {
* @api
*/
WMTS.optionsFromCapabilities = function(wmtsCap, config) {
var layers = wmtsCap['Contents']['Layer'];
var l = find(layers, function(elt, index, array) {
const layers = wmtsCap['Contents']['Layer'];
const l = find(layers, function(elt, index, array) {
return elt['Identifier'] == config['layer'];
});
if (l === null) {
return null;
}
var tileMatrixSets = wmtsCap['Contents']['TileMatrixSet'];
var idx, matrixSet, matrixLimits;
const tileMatrixSets = wmtsCap['Contents']['TileMatrixSet'];
let idx;
if (l['TileMatrixSetLink'].length > 1) {
if ('projection' in config) {
idx = findIndex(l['TileMatrixSetLink'],
function(elt, index, array) {
var tileMatrixSet = find(tileMatrixSets, function(el) {
return el['Identifier'] == elt['TileMatrixSet'];
});
var supportedCRS = tileMatrixSet['SupportedCRS'];
var proj1 = getProjection(supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
getProjection(supportedCRS);
var proj2 = getProjection(config['projection']);
if (proj1 && proj2) {
return equivalent(proj1, proj2);
} else {
return supportedCRS == config['projection'];
}
function(elt, index, array) {
const tileMatrixSet = find(tileMatrixSets, function(el) {
return el['Identifier'] == elt['TileMatrixSet'];
});
const supportedCRS = tileMatrixSet['SupportedCRS'];
const proj1 = getProjection(supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
getProjection(supportedCRS);
const proj2 = getProjection(config['projection']);
if (proj1 && proj2) {
return equivalent(proj1, proj2);
} else {
return supportedCRS == config['projection'];
}
});
} else {
idx = findIndex(l['TileMatrixSetLink'],
function(elt, index, array) {
return elt['TileMatrixSet'] == config['matrixSet'];
});
function(elt, index, array) {
return elt['TileMatrixSet'] == config['matrixSet'];
});
}
} else {
idx = 0;
@@ -348,12 +348,12 @@ WMTS.optionsFromCapabilities = function(wmtsCap, config) {
if (idx < 0) {
idx = 0;
}
matrixSet = /** @type {string} */
const matrixSet = /** @type {string} */
(l['TileMatrixSetLink'][idx]['TileMatrixSet']);
matrixLimits = /** @type {Array.<Object>} */
const matrixLimits = /** @type {Array.<Object>} */
(l['TileMatrixSetLink'][idx]['TileMatrixSetLimits']);
var format = /** @type {string} */ (l['Format'][0]);
let format = /** @type {string} */ (l['Format'][0]);
if ('format' in config) {
format = config['format'];
}
@@ -367,13 +367,13 @@ WMTS.optionsFromCapabilities = function(wmtsCap, config) {
if (idx < 0) {
idx = 0;
}
var style = /** @type {string} */ (l['Style'][idx]['Identifier']);
const style = /** @type {string} */ (l['Style'][idx]['Identifier']);
var dimensions = {};
const dimensions = {};
if ('Dimension' in l) {
l['Dimension'].forEach(function(elt, index, array) {
var key = elt['Identifier'];
var value = elt['Default'];
const key = elt['Identifier'];
let value = elt['Default'];
if (value === undefined) {
value = elt['Value'][0];
}
@@ -381,19 +381,19 @@ WMTS.optionsFromCapabilities = function(wmtsCap, config) {
});
}
var matrixSets = wmtsCap['Contents']['TileMatrixSet'];
var matrixSetObj = find(matrixSets, function(elt, index, array) {
const matrixSets = wmtsCap['Contents']['TileMatrixSet'];
const matrixSetObj = find(matrixSets, function(elt, index, array) {
return elt['Identifier'] == matrixSet;
});
var projection;
var code = matrixSetObj['SupportedCRS'];
let projection;
const code = matrixSetObj['SupportedCRS'];
if (code) {
projection = getProjection(code.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
getProjection(code);
}
if ('projection' in config) {
var projConfig = getProjection(config['projection']);
const projConfig = getProjection(config['projection']);
if (projConfig) {
if (!projection || equivalent(projConfig, projection)) {
projection = projConfig;
@@ -401,15 +401,15 @@ WMTS.optionsFromCapabilities = function(wmtsCap, config) {
}
}
var wgs84BoundingBox = l['WGS84BoundingBox'];
var extent, wrapX;
const wgs84BoundingBox = l['WGS84BoundingBox'];
let extent, wrapX;
if (wgs84BoundingBox !== undefined) {
var wgs84ProjectionExtent = getProjection('EPSG:4326').getExtent();
const wgs84ProjectionExtent = getProjection('EPSG:4326').getExtent();
wrapX = (wgs84BoundingBox[0] == wgs84ProjectionExtent[0] &&
wgs84BoundingBox[2] == wgs84ProjectionExtent[2]);
extent = transformExtent(
wgs84BoundingBox, 'EPSG:4326', projection);
var projectionExtent = projection.getExtent();
wgs84BoundingBox, 'EPSG:4326', projection);
const projectionExtent = projection.getExtent();
if (projectionExtent) {
// If possible, do a sanity check on the extent - it should never be
// bigger than the validity extent of the projection of a matrix set.
@@ -419,22 +419,22 @@ WMTS.optionsFromCapabilities = function(wmtsCap, config) {
}
}
var tileGrid = createFromCapabilitiesMatrixSet(matrixSetObj, extent, matrixLimits);
const tileGrid = createFromCapabilitiesMatrixSet(matrixSetObj, extent, matrixLimits);
/** @type {!Array.<string>} */
var urls = [];
var requestEncoding = config['requestEncoding'];
const urls = [];
let requestEncoding = config['requestEncoding'];
requestEncoding = requestEncoding !== undefined ? requestEncoding : '';
if ('OperationsMetadata' in wmtsCap && 'GetTile' in wmtsCap['OperationsMetadata']) {
var gets = wmtsCap['OperationsMetadata']['GetTile']['DCP']['HTTP']['Get'];
const gets = wmtsCap['OperationsMetadata']['GetTile']['DCP']['HTTP']['Get'];
for (var i = 0, ii = gets.length; i < ii; ++i) {
for (let i = 0, ii = gets.length; i < ii; ++i) {
if (gets[i]['Constraint']) {
var constraint = find(gets[i]['Constraint'], function(element) {
const constraint = find(gets[i]['Constraint'], function(element) {
return element['name'] == 'GetEncoding';
});
var encodings = constraint['AllowedValues']['Value'];
const encodings = constraint['AllowedValues']['Value'];
if (requestEncoding === '') {
// requestEncoding not provided, use the first encoding from the list
+4 -4
View File
@@ -27,12 +27,12 @@ import _ol_tilegrid_ from '../tilegrid.js';
* @param {olx.source.XYZOptions=} opt_options XYZ options.
* @api
*/
var XYZ = function(opt_options) {
var options = opt_options || {};
var projection = options.projection !== undefined ?
const XYZ = function(opt_options) {
const options = opt_options || {};
const projection = options.projection !== undefined ?
options.projection : 'EPSG:3857';
var tileGrid = options.tileGrid !== undefined ? options.tileGrid :
const tileGrid = options.tileGrid !== undefined ? options.tileGrid :
_ol_tilegrid_.createXYZ({
extent: _ol_tilegrid_.extentFromProjection(projection),
maxZoom: options.maxZoom,
+32 -32
View File
@@ -23,21 +23,21 @@ import TileGrid from '../tilegrid/TileGrid.js';
* @param {olx.source.ZoomifyOptions=} opt_options Options.
* @api
*/
var Zoomify = function(opt_options) {
const Zoomify = function(opt_options) {
var options = opt_options || {};
const options = opt_options || {};
var size = options.size;
var tierSizeCalculation = options.tierSizeCalculation !== undefined ?
const size = options.size;
const tierSizeCalculation = options.tierSizeCalculation !== undefined ?
options.tierSizeCalculation :
Zoomify.TierSizeCalculation_.DEFAULT;
var imageWidth = size[0];
var imageHeight = size[1];
var extent = options.extent || [0, -size[1], size[0], 0];
var tierSizeInTiles = [];
var tileSize = options.tileSize || DEFAULT_TILE_SIZE;
var tileSizeForTierSizeCalculation = tileSize;
const imageWidth = size[0];
const imageHeight = size[1];
const extent = options.extent || [0, -size[1], size[0], 0];
const tierSizeInTiles = [];
const tileSize = options.tileSize || DEFAULT_TILE_SIZE;
let tileSizeForTierSizeCalculation = tileSize;
switch (tierSizeCalculation) {
case Zoomify.TierSizeCalculation_.DEFAULT:
@@ -50,8 +50,8 @@ var Zoomify = function(opt_options) {
}
break;
case Zoomify.TierSizeCalculation_.TRUNCATED:
var width = imageWidth;
var height = imageHeight;
let width = imageWidth;
let height = imageHeight;
while (width > tileSizeForTierSizeCalculation || height > tileSizeForTierSizeCalculation) {
tierSizeInTiles.push([
Math.ceil(width / tileSizeForTierSizeCalculation),
@@ -69,30 +69,30 @@ var Zoomify = function(opt_options) {
tierSizeInTiles.push([1, 1]);
tierSizeInTiles.reverse();
var resolutions = [1];
var tileCountUpToTier = [0];
var i, ii;
const resolutions = [1];
const tileCountUpToTier = [0];
let i, ii;
for (i = 1, ii = tierSizeInTiles.length; i < ii; i++) {
resolutions.push(1 << i);
tileCountUpToTier.push(
tierSizeInTiles[i - 1][0] * tierSizeInTiles[i - 1][1] +
tierSizeInTiles[i - 1][0] * tierSizeInTiles[i - 1][1] +
tileCountUpToTier[i - 1]
);
}
resolutions.reverse();
var tileGrid = new TileGrid({
const tileGrid = new TileGrid({
tileSize: tileSize,
extent: extent,
origin: getTopLeft(extent),
resolutions: resolutions
});
var url = options.url;
let url = options.url;
if (url && url.indexOf('{TileGroup}') == -1 && url.indexOf('{tileIndex}') == -1) {
url += '{TileGroup}/{z}-{x}-{y}.jpg';
}
var urls = expandUrl(url);
const urls = expandUrl(url);
/**
* @param {string} template Template.
@@ -111,15 +111,15 @@ var Zoomify = function(opt_options) {
if (!tileCoord) {
return undefined;
} else {
var tileCoordZ = tileCoord[0];
var tileCoordX = tileCoord[1];
var tileCoordY = -tileCoord[2] - 1;
var tileIndex =
const tileCoordZ = tileCoord[0];
const tileCoordX = tileCoord[1];
const tileCoordY = -tileCoord[2] - 1;
const tileIndex =
tileCoordX +
tileCoordY * tierSizeInTiles[tileCoordZ][0];
var tileSize = tileGrid.getTileSize(tileCoordZ);
var tileGroup = ((tileIndex + tileCountUpToTier[tileCoordZ]) / tileSize) | 0;
var localContext = {
const tileSize = tileGrid.getTileSize(tileCoordZ);
const tileGroup = ((tileIndex + tileCountUpToTier[tileCoordZ]) / tileSize) | 0;
const localContext = {
'z': tileCoordZ,
'x': tileCoordX,
'y': tileCoordY,
@@ -133,9 +133,9 @@ var Zoomify = function(opt_options) {
});
}
var tileUrlFunction = createFromTileUrlFunctions(urls.map(createFromTemplate));
const tileUrlFunction = createFromTileUrlFunctions(urls.map(createFromTemplate));
var ZoomifyTileClass = Zoomify.Tile_.bind(null, tileGrid);
const ZoomifyTileClass = Zoomify.Tile_.bind(null, tileGrid);
TileImage.call(this, {
attributions: options.attributions,
@@ -166,7 +166,7 @@ inherits(Zoomify, TileImage);
* @private
*/
Zoomify.Tile_ = function(
tileGrid, tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options) {
tileGrid, tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options) {
ImageTile.call(this, tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options);
@@ -192,14 +192,14 @@ Zoomify.Tile_.prototype.getImage = function() {
if (this.zoomifyImage_) {
return this.zoomifyImage_;
}
var image = ImageTile.prototype.getImage.call(this);
const image = ImageTile.prototype.getImage.call(this);
if (this.state == TileState.LOADED) {
var tileSize = this.tileSize_;
const tileSize = this.tileSize_;
if (image.width == tileSize[0] && image.height == tileSize[1]) {
this.zoomifyImage_ = image;
return image;
} else {
var context = createCanvasContext2D(tileSize[0], tileSize[1]);
const context = createCanvasContext2D(tileSize[0], tileSize[1]);
context.drawImage(image, 0, 0);
this.zoomifyImage_ = context.canvas;
return context.canvas;
+1 -1
View File
@@ -1,4 +1,4 @@
/**
* @type {string} Default WMS version.
*/
export var DEFAULT_WMS_VERSION = '1.3.0';
export const DEFAULT_WMS_VERSION = '1.3.0';