Transformed

This commit is contained in:
Tim Schaub
2017-12-11 16:29:33 -07:00
parent 1cdb6a66f0
commit 7f47883c48
737 changed files with 22216 additions and 21609 deletions

View File

@@ -1,15 +1,15 @@
goog.provide('ol.source.BingMaps');
goog.require('ol');
goog.require('ol.TileUrlFunction');
goog.require('ol.extent');
goog.require('ol.net');
goog.require('ol.proj');
goog.require('ol.source.State');
goog.require('ol.source.TileImage');
goog.require('ol.tilecoord');
goog.require('ol.tilegrid');
/**
* @module ol/source/BingMaps
*/
import _ol_ from '../index.js';
import _ol_TileUrlFunction_ from '../TileUrlFunction.js';
import _ol_extent_ from '../extent.js';
import _ol_net_ from '../net.js';
import _ol_proj_ from '../proj.js';
import _ol_source_State_ from '../source/State.js';
import _ol_source_TileImage_ from '../source/TileImage.js';
import _ol_tilecoord_ from '../tilecoord.js';
import _ol_tilegrid_ from '../tilegrid.js';
/**
* @classdesc
@@ -20,7 +20,7 @@ goog.require('ol.tilegrid');
* @param {olx.source.BingMapsOptions} options Bing Maps options.
* @api
*/
ol.source.BingMaps = function(options) {
var _ol_source_BingMaps_ = function(options) {
/**
* @private
@@ -28,13 +28,13 @@ ol.source.BingMaps = function(options) {
*/
this.hidpi_ = options.hidpi !== undefined ? options.hidpi : false;
ol.source.TileImage.call(this, {
_ol_source_TileImage_.call(this, {
cacheSize: options.cacheSize,
crossOrigin: 'anonymous',
opaque: true,
projection: ol.proj.get('EPSG:3857'),
projection: _ol_proj_.get('EPSG:3857'),
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
state: ol.source.State.LOADING,
state: _ol_source_State_.LOADING,
tileLoadFunction: options.tileLoadFunction,
tilePixelRatio: this.hidpi_ ? 2 : 1,
wrapX: options.wrapX !== undefined ? options.wrapX : true,
@@ -70,11 +70,12 @@ ol.source.BingMaps = function(options) {
'?uriScheme=https&include=ImageryProviders&key=' + this.apiKey_ +
'&c=' + this.culture_;
ol.net.jsonp(url, this.handleImageryMetadataResponse.bind(this), undefined,
_ol_net_.jsonp(url, this.handleImageryMetadataResponse.bind(this), undefined,
'jsonp');
};
ol.inherits(ol.source.BingMaps, ol.source.TileImage);
_ol_.inherits(_ol_source_BingMaps_, _ol_source_TileImage_);
/**
@@ -84,7 +85,7 @@ ol.inherits(ol.source.BingMaps, ol.source.TileImage);
* @type {string}
* @api
*/
ol.source.BingMaps.TOS_ATTRIBUTION = '<a class="ol-attribution-bing-tos" ' +
_ol_source_BingMaps_.TOS_ATTRIBUTION = '<a class="ol-attribution-bing-tos" ' +
'href="https://www.microsoft.com/maps/product/terms.html">' +
'Terms of Use</a>';
@@ -95,7 +96,7 @@ ol.source.BingMaps.TOS_ATTRIBUTION = '<a class="ol-attribution-bing-tos" ' +
* @return {string} The api key.
* @api
*/
ol.source.BingMaps.prototype.getApiKey = function() {
_ol_source_BingMaps_.prototype.getApiKey = function() {
return this.apiKey_;
};
@@ -106,7 +107,7 @@ ol.source.BingMaps.prototype.getApiKey = function() {
* @return {string} The imagery set.
* @api
*/
ol.source.BingMaps.prototype.getImagerySet = function() {
_ol_source_BingMaps_.prototype.getImagerySet = function() {
return this.imagerySet_;
};
@@ -114,13 +115,13 @@ ol.source.BingMaps.prototype.getImagerySet = function() {
/**
* @param {BingMapsImageryMetadataResponse} response Response.
*/
ol.source.BingMaps.prototype.handleImageryMetadataResponse = function(response) {
_ol_source_BingMaps_.prototype.handleImageryMetadataResponse = function(response) {
if (response.statusCode != 200 ||
response.statusDescription != 'OK' ||
response.authenticationResultCode != 'ValidCredentials' ||
response.resourceSets.length != 1 ||
response.resourceSets[0].resources.length != 1) {
this.setState(ol.source.State.ERROR);
this.setState(_ol_source_State_.ERROR);
return;
}
@@ -133,10 +134,10 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = function(response)
var maxZoom = this.maxZoom_ == -1 ? resource.zoomMax : this.maxZoom_;
var sourceProjection = this.getProjection();
var extent = ol.tilegrid.extentFromProjection(sourceProjection);
var extent = _ol_tilegrid_.extentFromProjection(sourceProjection);
var tileSize = resource.imageWidth == resource.imageHeight ?
resource.imageWidth : [resource.imageWidth, resource.imageHeight];
var tileGrid = ol.tilegrid.createXYZ({
var tileGrid = _ol_tilegrid_.createXYZ({
extent: extent,
minZoom: resource.zoomMin,
maxZoom: maxZoom,
@@ -146,7 +147,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = function(response)
var culture = this.culture_;
var hidpi = this.hidpi_;
this.tileUrlFunction = ol.TileUrlFunction.createFromTileUrlFunctions(
this.tileUrlFunction = _ol_TileUrlFunction_.createFromTileUrlFunctions(
resource.imageUrlSubdomains.map(function(subdomain) {
var quadKeyTileCoord = [0, 0, 0];
var imageUrl = resource.imageUrl
@@ -163,21 +164,22 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = function(response)
if (!tileCoord) {
return undefined;
} else {
ol.tilecoord.createOrUpdate(tileCoord[0], tileCoord[1],
_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(
return url.replace('{quadkey}', _ol_tilecoord_.quadKey(
quadKeyTileCoord));
}
});
}
);
}));
if (resource.imageryProviders) {
var transform = ol.proj.getTransformFromProjections(
ol.proj.get('EPSG:4326'), this.getProjection());
var transform = _ol_proj_.getTransformFromProjections(
_ol_proj_.get('EPSG:4326'), this.getProjection());
this.setAttributions(function(frameState) {
var attributions = [];
@@ -190,8 +192,8 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = function(response)
if (zoom >= coverageArea.zoomMin && zoom <= coverageArea.zoomMax) {
var bbox = coverageArea.bbox;
var epsg4326Extent = [bbox[1], bbox[0], bbox[3], bbox[2]];
var extent = ol.extent.applyTransform(epsg4326Extent, transform);
if (ol.extent.intersects(extent, frameState.extent)) {
var extent = _ol_extent_.applyTransform(epsg4326Extent, transform);
if (_ol_extent_.intersects(extent, frameState.extent)) {
intersects = true;
break;
}
@@ -202,12 +204,13 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = function(response)
}
});
attributions.push(ol.source.BingMaps.TOS_ATTRIBUTION);
attributions.push(_ol_source_BingMaps_.TOS_ATTRIBUTION);
return attributions;
});
}
this.setLogo(brandLogoUri);
this.setState(ol.source.State.READY);
this.setState(_ol_source_State_.READY);
};
export default _ol_source_BingMaps_;

View File

@@ -1,10 +1,10 @@
goog.provide('ol.source.CartoDB');
goog.require('ol');
goog.require('ol.obj');
goog.require('ol.source.State');
goog.require('ol.source.XYZ');
/**
* @module ol/source/CartoDB
*/
import _ol_ from '../index.js';
import _ol_obj_ from '../obj.js';
import _ol_source_State_ from '../source/State.js';
import _ol_source_XYZ_ from '../source/XYZ.js';
/**
* @classdesc
@@ -15,7 +15,7 @@ goog.require('ol.source.XYZ');
* @param {olx.source.CartoDBOptions} options CartoDB options.
* @api
*/
ol.source.CartoDB = function(options) {
var _ol_source_CartoDB_ = function(options) {
/**
* @type {string}
@@ -41,7 +41,7 @@ ol.source.CartoDB = function(options) {
*/
this.templateCache_ = {};
ol.source.XYZ.call(this, {
_ol_source_XYZ_.call(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,
crossOrigin: options.crossOrigin,
@@ -49,12 +49,13 @@ ol.source.CartoDB = function(options) {
maxZoom: options.maxZoom !== undefined ? options.maxZoom : 18,
minZoom: options.minZoom,
projection: options.projection,
state: ol.source.State.LOADING,
state: _ol_source_State_.LOADING,
wrapX: options.wrapX
});
this.initializeMap_();
};
ol.inherits(ol.source.CartoDB, ol.source.XYZ);
_ol_.inherits(_ol_source_CartoDB_, _ol_source_XYZ_);
/**
@@ -62,7 +63,7 @@ ol.inherits(ol.source.CartoDB, ol.source.XYZ);
* @return {!Object} The current configuration.
* @api
*/
ol.source.CartoDB.prototype.getConfig = function() {
_ol_source_CartoDB_.prototype.getConfig = function() {
return this.config_;
};
@@ -73,8 +74,8 @@ ol.source.CartoDB.prototype.getConfig = function() {
* in the config.
* @api
*/
ol.source.CartoDB.prototype.updateConfig = function(config) {
ol.obj.assign(this.config_, config);
_ol_source_CartoDB_.prototype.updateConfig = function(config) {
_ol_obj_.assign(this.config_, config);
this.initializeMap_();
};
@@ -86,7 +87,7 @@ ol.source.CartoDB.prototype.updateConfig = function(config) {
* If using named maps, a key-value lookup with the template parameters.
* @api
*/
ol.source.CartoDB.prototype.setConfig = function(config) {
_ol_source_CartoDB_.prototype.setConfig = function(config) {
this.config_ = config || {};
this.initializeMap_();
};
@@ -96,7 +97,7 @@ ol.source.CartoDB.prototype.setConfig = function(config) {
* Issue a request to initialize the CartoDB map.
* @private
*/
ol.source.CartoDB.prototype.initializeMap_ = function() {
_ol_source_CartoDB_.prototype.initializeMap_ = function() {
var paramHash = JSON.stringify(this.config_);
if (this.templateCache_[paramHash]) {
this.applyTemplate_(this.templateCache_[paramHash]);
@@ -124,7 +125,7 @@ ol.source.CartoDB.prototype.initializeMap_ = function() {
* @param {Event} event Event.
* @private
*/
ol.source.CartoDB.prototype.handleInitResponse_ = function(paramHash, event) {
_ol_source_CartoDB_.prototype.handleInitResponse_ = function(paramHash, event) {
var client = /** @type {XMLHttpRequest} */ (event.target);
// status will be 0 for file:// urls
if (!client.status || client.status >= 200 && client.status < 300) {
@@ -132,14 +133,14 @@ ol.source.CartoDB.prototype.handleInitResponse_ = function(paramHash, event) {
try {
response = /** @type {CartoDBLayerInfo} */(JSON.parse(client.responseText));
} catch (err) {
this.setState(ol.source.State.ERROR);
this.setState(_ol_source_State_.ERROR);
return;
}
this.applyTemplate_(response);
this.templateCache_[paramHash] = response;
this.setState(ol.source.State.READY);
this.setState(_ol_source_State_.READY);
} else {
this.setState(ol.source.State.ERROR);
this.setState(_ol_source_State_.ERROR);
}
};
@@ -148,8 +149,8 @@ ol.source.CartoDB.prototype.handleInitResponse_ = function(paramHash, event) {
* @private
* @param {Event} event Event.
*/
ol.source.CartoDB.prototype.handleInitError_ = function(event) {
this.setState(ol.source.State.ERROR);
_ol_source_CartoDB_.prototype.handleInitError_ = function(event) {
this.setState(_ol_source_State_.ERROR);
};
@@ -158,8 +159,9 @@ ol.source.CartoDB.prototype.handleInitError_ = function(event) {
* @param {CartoDBLayerInfo} data Result of carto db call.
* @private
*/
ol.source.CartoDB.prototype.applyTemplate_ = function(data) {
_ol_source_CartoDB_.prototype.applyTemplate_ = function(data) {
var tilesUrl = 'https://' + data.cdn_url.https + '/' + this.account_ +
'/api/v1/map/' + data.layergroupid + '/{z}/{x}/{y}.png';
this.setUrl(tilesUrl);
};
export default _ol_source_CartoDB_;

View File

@@ -1,17 +1,17 @@
/**
* @module ol/source/Cluster
*/
// FIXME keep cluster cache by resolution ?
// FIXME distance not respected because of the centroid
goog.provide('ol.source.Cluster');
goog.require('ol');
goog.require('ol.asserts');
goog.require('ol.Feature');
goog.require('ol.coordinate');
goog.require('ol.events.EventType');
goog.require('ol.extent');
goog.require('ol.geom.Point');
goog.require('ol.source.Vector');
import _ol_ from '../index.js';
import _ol_asserts_ from '../asserts.js';
import _ol_Feature_ from '../Feature.js';
import _ol_coordinate_ from '../coordinate.js';
import _ol_events_EventType_ from '../events/EventType.js';
import _ol_extent_ from '../extent.js';
import _ol_geom_Point_ from '../geom/Point.js';
import _ol_source_Vector_ from '../source/Vector.js';
/**
* @classdesc
@@ -24,8 +24,8 @@ goog.require('ol.source.Vector');
* @extends {ol.source.Vector}
* @api
*/
ol.source.Cluster = function(options) {
ol.source.Vector.call(this, {
var _ol_source_Cluster_ = function(options) {
_ol_source_Vector_.call(this, {
attributions: options.attributions,
extent: options.extent,
logo: options.logo,
@@ -58,7 +58,7 @@ ol.source.Cluster = function(options) {
*/
this.geometryFunction = options.geometryFunction || function(feature) {
var geometry = /** @type {ol.geom.Point} */ (feature.getGeometry());
ol.asserts.assert(geometry instanceof ol.geom.Point,
_ol_asserts_.assert(geometry instanceof _ol_geom_Point_,
10); // The default `geometryFunction` can only handle `ol.geom.Point` geometries
return geometry;
};
@@ -69,10 +69,11 @@ ol.source.Cluster = function(options) {
*/
this.source = options.source;
this.source.on(ol.events.EventType.CHANGE,
ol.source.Cluster.prototype.refresh, this);
this.source.on(_ol_events_EventType_.CHANGE,
_ol_source_Cluster_.prototype.refresh, this);
};
ol.inherits(ol.source.Cluster, ol.source.Vector);
_ol_.inherits(_ol_source_Cluster_, _ol_source_Vector_);
/**
@@ -80,7 +81,7 @@ ol.inherits(ol.source.Cluster, ol.source.Vector);
* @return {number} Distance.
* @api
*/
ol.source.Cluster.prototype.getDistance = function() {
_ol_source_Cluster_.prototype.getDistance = function() {
return this.distance;
};
@@ -90,7 +91,7 @@ ol.source.Cluster.prototype.getDistance = function() {
* @return {ol.source.Vector} Source.
* @api
*/
ol.source.Cluster.prototype.getSource = function() {
_ol_source_Cluster_.prototype.getSource = function() {
return this.source;
};
@@ -98,7 +99,7 @@ ol.source.Cluster.prototype.getSource = function() {
/**
* @inheritDoc
*/
ol.source.Cluster.prototype.loadFeatures = function(extent, resolution,
_ol_source_Cluster_.prototype.loadFeatures = function(extent, resolution,
projection) {
this.source.loadFeatures(extent, resolution, projection);
if (resolution !== this.resolution) {
@@ -115,7 +116,7 @@ ol.source.Cluster.prototype.loadFeatures = function(extent, resolution,
* @param {number} distance The distance in pixels.
* @api
*/
ol.source.Cluster.prototype.setDistance = function(distance) {
_ol_source_Cluster_.prototype.setDistance = function(distance) {
this.distance = distance;
this.refresh();
};
@@ -125,23 +126,23 @@ ol.source.Cluster.prototype.setDistance = function(distance) {
* handle the source changing
* @override
*/
ol.source.Cluster.prototype.refresh = function() {
_ol_source_Cluster_.prototype.refresh = function() {
this.clear();
this.cluster();
this.addFeatures(this.features);
ol.source.Vector.prototype.refresh.call(this);
_ol_source_Vector_.prototype.refresh.call(this);
};
/**
* @protected
*/
ol.source.Cluster.prototype.cluster = function() {
_ol_source_Cluster_.prototype.cluster = function() {
if (this.resolution === undefined) {
return;
}
this.features.length = 0;
var extent = ol.extent.createEmpty();
var extent = _ol_extent_.createEmpty();
var mapDistance = this.distance * this.resolution;
var features = this.source.getFeatures();
@@ -152,16 +153,16 @@ ol.source.Cluster.prototype.cluster = function() {
for (var i = 0, ii = features.length; i < ii; i++) {
var feature = features[i];
if (!(ol.getUid(feature).toString() in clustered)) {
if (!(_ol_.getUid(feature).toString() in clustered)) {
var geometry = this.geometryFunction(feature);
if (geometry) {
var coordinates = geometry.getCoordinates();
ol.extent.createOrUpdateFromCoordinate(coordinates, extent);
ol.extent.buffer(extent, mapDistance, extent);
_ol_extent_.createOrUpdateFromCoordinate(coordinates, extent);
_ol_extent_.buffer(extent, mapDistance, extent);
var neighbors = this.source.getFeaturesInExtent(extent);
neighbors = neighbors.filter(function(neighbor) {
var uid = ol.getUid(neighbor).toString();
var uid = _ol_.getUid(neighbor).toString();
if (!(uid in clustered)) {
clustered[uid] = true;
return true;
@@ -181,19 +182,20 @@ ol.source.Cluster.prototype.cluster = function() {
* @return {ol.Feature} The cluster feature.
* @protected
*/
ol.source.Cluster.prototype.createCluster = function(features) {
_ol_source_Cluster_.prototype.createCluster = function(features) {
var centroid = [0, 0];
for (var i = features.length - 1; i >= 0; --i) {
var geometry = this.geometryFunction(features[i]);
if (geometry) {
ol.coordinate.add(centroid, geometry.getCoordinates());
_ol_coordinate_.add(centroid, geometry.getCoordinates());
} else {
features.splice(i, 1);
}
}
ol.coordinate.scale(centroid, 1 / features.length);
_ol_coordinate_.scale(centroid, 1 / features.length);
var cluster = new ol.Feature(new ol.geom.Point(centroid));
var cluster = new _ol_Feature_(new _ol_geom_Point_(centroid));
cluster.set('features', features);
return cluster;
};
export default _ol_source_Cluster_;

View File

@@ -1,14 +1,14 @@
goog.provide('ol.source.Image');
goog.require('ol');
goog.require('ol.ImageState');
goog.require('ol.array');
goog.require('ol.events.Event');
goog.require('ol.extent');
goog.require('ol.proj');
goog.require('ol.reproj.Image');
goog.require('ol.source.Source');
/**
* @module ol/source/Image
*/
import _ol_ from '../index.js';
import _ol_ImageState_ from '../ImageState.js';
import _ol_array_ from '../array.js';
import _ol_events_Event_ from '../events/Event.js';
import _ol_extent_ from '../extent.js';
import _ol_proj_ from '../proj.js';
import _ol_reproj_Image_ from '../reproj/Image.js';
import _ol_source_Source_ from '../source/Source.js';
/**
* @classdesc
@@ -22,8 +22,8 @@ goog.require('ol.source.Source');
* @param {ol.SourceImageOptions} options Single image source options.
* @api
*/
ol.source.Image = function(options) {
ol.source.Source.call(this, {
var _ol_source_Image_ = function(options) {
_ol_source_Source_.call(this, {
attributions: options.attributions,
extent: options.extent,
logo: options.logo,
@@ -52,14 +52,15 @@ ol.source.Image = function(options) {
*/
this.reprojectedRevision_ = 0;
};
ol.inherits(ol.source.Image, ol.source.Source);
_ol_.inherits(_ol_source_Image_, _ol_source_Source_);
/**
* @return {Array.<number>} Resolutions.
* @override
*/
ol.source.Image.prototype.getResolutions = function() {
_ol_source_Image_.prototype.getResolutions = function() {
return this.resolutions_;
};
@@ -69,9 +70,9 @@ ol.source.Image.prototype.getResolutions = function() {
* @param {number} resolution Resolution.
* @return {number} Resolution.
*/
ol.source.Image.prototype.findNearestResolution = function(resolution) {
_ol_source_Image_.prototype.findNearestResolution = function(resolution) {
if (this.resolutions_) {
var idx = ol.array.linearFindNearest(this.resolutions_, resolution, 0);
var idx = _ol_array_.linearFindNearest(this.resolutions_, resolution, 0);
resolution = this.resolutions_[idx];
}
return resolution;
@@ -85,12 +86,12 @@ ol.source.Image.prototype.findNearestResolution = function(resolution) {
* @param {ol.proj.Projection} projection Projection.
* @return {ol.ImageBase} Single image.
*/
ol.source.Image.prototype.getImage = function(extent, resolution, pixelRatio, projection) {
_ol_source_Image_.prototype.getImage = function(extent, resolution, pixelRatio, projection) {
var sourceProjection = this.getProjection();
if (!ol.ENABLE_RASTER_REPROJECTION ||
if (!_ol_.ENABLE_RASTER_REPROJECTION ||
!sourceProjection ||
!projection ||
ol.proj.equivalent(sourceProjection, projection)) {
_ol_proj_.equivalent(sourceProjection, projection)) {
if (sourceProjection) {
projection = sourceProjection;
}
@@ -98,17 +99,17 @@ ol.source.Image.prototype.getImage = function(extent, resolution, pixelRatio, pr
} else {
if (this.reprojectedImage_) {
if (this.reprojectedRevision_ == this.getRevision() &&
ol.proj.equivalent(
_ol_proj_.equivalent(
this.reprojectedImage_.getProjection(), projection) &&
this.reprojectedImage_.getResolution() == resolution &&
ol.extent.equals(this.reprojectedImage_.getExtent(), extent)) {
_ol_extent_.equals(this.reprojectedImage_.getExtent(), extent)) {
return this.reprojectedImage_;
}
this.reprojectedImage_.dispose();
this.reprojectedImage_ = null;
}
this.reprojectedImage_ = new ol.reproj.Image(
this.reprojectedImage_ = new _ol_reproj_Image_(
sourceProjection, projection, extent, resolution, pixelRatio,
function(extent, resolution, pixelRatio) {
return this.getImageInternal(extent, resolution,
@@ -130,7 +131,7 @@ ol.source.Image.prototype.getImage = function(extent, resolution, pixelRatio, pr
* @return {ol.ImageBase} Single image.
* @protected
*/
ol.source.Image.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) {};
_ol_source_Image_.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) {};
/**
@@ -138,22 +139,22 @@ ol.source.Image.prototype.getImageInternal = function(extent, resolution, pixelR
* @param {ol.events.Event} event Event.
* @protected
*/
ol.source.Image.prototype.handleImageChange = function(event) {
_ol_source_Image_.prototype.handleImageChange = function(event) {
var image = /** @type {ol.Image} */ (event.target);
switch (image.getState()) {
case ol.ImageState.LOADING:
case _ol_ImageState_.LOADING:
this.dispatchEvent(
new ol.source.Image.Event(ol.source.Image.EventType_.IMAGELOADSTART,
new _ol_source_Image_.Event(_ol_source_Image_.EventType_.IMAGELOADSTART,
image));
break;
case ol.ImageState.LOADED:
case _ol_ImageState_.LOADED:
this.dispatchEvent(
new ol.source.Image.Event(ol.source.Image.EventType_.IMAGELOADEND,
new _ol_source_Image_.Event(_ol_source_Image_.EventType_.IMAGELOADEND,
image));
break;
case ol.ImageState.ERROR:
case _ol_ImageState_.ERROR:
this.dispatchEvent(
new ol.source.Image.Event(ol.source.Image.EventType_.IMAGELOADERROR,
new _ol_source_Image_.Event(_ol_source_Image_.EventType_.IMAGELOADERROR,
image));
break;
default:
@@ -168,7 +169,7 @@ ol.source.Image.prototype.handleImageChange = function(event) {
* @param {ol.Image} image Image.
* @param {string} src Source.
*/
ol.source.Image.defaultImageLoadFunction = function(image, src) {
_ol_source_Image_.defaultImageLoadFunction = function(image, src) {
image.getImage().src = src;
};
@@ -184,9 +185,9 @@ ol.source.Image.defaultImageLoadFunction = function(image, src) {
* @param {string} type Type.
* @param {ol.Image} image The image.
*/
ol.source.Image.Event = function(type, image) {
_ol_source_Image_.Event = function(type, image) {
ol.events.Event.call(this, type);
_ol_events_Event_.call(this, type);
/**
* The image related to the event.
@@ -196,14 +197,14 @@ ol.source.Image.Event = function(type, image) {
this.image = image;
};
ol.inherits(ol.source.Image.Event, ol.events.Event);
_ol_.inherits(_ol_source_Image_.Event, _ol_events_Event_);
/**
* @enum {string}
* @private
*/
ol.source.Image.EventType_ = {
_ol_source_Image_.EventType_ = {
/**
* Triggered when an image starts loading.
@@ -227,3 +228,4 @@ ol.source.Image.EventType_ = {
IMAGELOADERROR: 'imageloaderror'
};
export default _ol_source_Image_;

View File

@@ -1,15 +1,15 @@
goog.provide('ol.source.ImageArcGISRest');
goog.require('ol');
goog.require('ol.Image');
goog.require('ol.asserts');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol.extent');
goog.require('ol.obj');
goog.require('ol.source.Image');
goog.require('ol.uri');
/**
* @module ol/source/ImageArcGISRest
*/
import _ol_ from '../index.js';
import _ol_Image_ from '../Image.js';
import _ol_asserts_ from '../asserts.js';
import _ol_events_ from '../events.js';
import _ol_events_EventType_ from '../events/EventType.js';
import _ol_extent_ from '../extent.js';
import _ol_obj_ from '../obj.js';
import _ol_source_Image_ from '../source/Image.js';
import _ol_uri_ from '../uri.js';
/**
* @classdesc
@@ -26,11 +26,11 @@ goog.require('ol.uri');
* @param {olx.source.ImageArcGISRestOptions=} opt_options Image ArcGIS Rest Options.
* @api
*/
ol.source.ImageArcGISRest = function(opt_options) {
var _ol_source_ImageArcGISRest_ = function(opt_options) {
var options = opt_options || {};
ol.source.Image.call(this, {
_ol_source_Image_.call(this, {
attributions: options.attributions,
logo: options.logo,
projection: options.projection,
@@ -61,7 +61,7 @@ ol.source.ImageArcGISRest = function(opt_options) {
* @type {ol.ImageLoadFunctionType}
*/
this.imageLoadFunction_ = options.imageLoadFunction !== undefined ?
options.imageLoadFunction : ol.source.Image.defaultImageLoadFunction;
options.imageLoadFunction : _ol_source_Image_.defaultImageLoadFunction;
/**
@@ -96,7 +96,8 @@ ol.source.ImageArcGISRest = function(opt_options) {
this.ratio_ = options.ratio !== undefined ? options.ratio : 1.5;
};
ol.inherits(ol.source.ImageArcGISRest, ol.source.Image);
_ol_.inherits(_ol_source_ImageArcGISRest_, _ol_source_Image_);
/**
@@ -105,7 +106,7 @@ ol.inherits(ol.source.ImageArcGISRest, ol.source.Image);
* @return {Object} Params.
* @api
*/
ol.source.ImageArcGISRest.prototype.getParams = function() {
_ol_source_ImageArcGISRest_.prototype.getParams = function() {
return this.params_;
};
@@ -113,7 +114,7 @@ ol.source.ImageArcGISRest.prototype.getParams = function() {
/**
* @inheritDoc
*/
ol.source.ImageArcGISRest.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) {
_ol_source_ImageArcGISRest_.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) {
if (this.url_ === undefined) {
return null;
@@ -127,7 +128,7 @@ ol.source.ImageArcGISRest.prototype.getImageInternal = function(extent, resoluti
this.renderedRevision_ == this.getRevision() &&
image.getResolution() == resolution &&
image.getPixelRatio() == pixelRatio &&
ol.extent.containsExtent(image.getExtent(), extent)) {
_ol_extent_.containsExtent(image.getExtent(), extent)) {
return image;
}
@@ -136,14 +137,14 @@ ol.source.ImageArcGISRest.prototype.getImageInternal = function(extent, resoluti
'FORMAT': 'PNG32',
'TRANSPARENT': true
};
ol.obj.assign(params, this.params_);
_ol_obj_.assign(params, this.params_);
extent = extent.slice();
var centerX = (extent[0] + extent[2]) / 2;
var centerY = (extent[1] + extent[3]) / 2;
if (this.ratio_ != 1) {
var halfWidth = this.ratio_ * ol.extent.getWidth(extent) / 2;
var halfHeight = this.ratio_ * ol.extent.getHeight(extent) / 2;
var halfWidth = this.ratio_ * _ol_extent_.getWidth(extent) / 2;
var halfHeight = this.ratio_ * _ol_extent_.getHeight(extent) / 2;
extent[0] = centerX - halfWidth;
extent[1] = centerY - halfHeight;
extent[2] = centerX + halfWidth;
@@ -153,8 +154,8 @@ ol.source.ImageArcGISRest.prototype.getImageInternal = function(extent, resoluti
var imageResolution = resolution / pixelRatio;
// Compute an integer width and height.
var width = Math.ceil(ol.extent.getWidth(extent) / imageResolution);
var height = Math.ceil(ol.extent.getHeight(extent) / imageResolution);
var width = Math.ceil(_ol_extent_.getWidth(extent) / imageResolution);
var height = Math.ceil(_ol_extent_.getHeight(extent) / imageResolution);
// Modify the extent to match the integer width and height.
extent[0] = centerX - imageResolution * width / 2;
@@ -168,12 +169,12 @@ ol.source.ImageArcGISRest.prototype.getImageInternal = function(extent, resoluti
var url = this.getRequestUrl_(extent, this.imageSize_, pixelRatio,
projection, params);
this.image_ = new ol.Image(extent, resolution, pixelRatio,
this.image_ = new _ol_Image_(extent, resolution, pixelRatio,
url, this.crossOrigin_, this.imageLoadFunction_);
this.renderedRevision_ = this.getRevision();
ol.events.listen(this.image_, ol.events.EventType.CHANGE,
_ol_events_.listen(this.image_, _ol_events_EventType_.CHANGE,
this.handleImageChange, this);
return this.image_;
@@ -186,7 +187,7 @@ ol.source.ImageArcGISRest.prototype.getImageInternal = function(extent, resoluti
* @return {ol.ImageLoadFunctionType} The image load function.
* @api
*/
ol.source.ImageArcGISRest.prototype.getImageLoadFunction = function() {
_ol_source_ImageArcGISRest_.prototype.getImageLoadFunction = function() {
return this.imageLoadFunction_;
};
@@ -200,7 +201,7 @@ ol.source.ImageArcGISRest.prototype.getImageLoadFunction = function() {
* @return {string} Request URL.
* @private
*/
ol.source.ImageArcGISRest.prototype.getRequestUrl_ = function(extent, size, pixelRatio, projection, params) {
_ol_source_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();
@@ -216,9 +217,9 @@ ol.source.ImageArcGISRest.prototype.getRequestUrl_ = function(extent, size, pixe
.replace(/MapServer\/?$/, 'MapServer/export')
.replace(/ImageServer\/?$/, 'ImageServer/exportImage');
if (modifiedUrl == url) {
ol.asserts.assert(false, 50); // `options.featureTypes` should be an Array
_ol_asserts_.assert(false, 50); // `options.featureTypes` should be an Array
}
return ol.uri.appendParams(modifiedUrl, params);
return _ol_uri_.appendParams(modifiedUrl, params);
};
@@ -227,7 +228,7 @@ ol.source.ImageArcGISRest.prototype.getRequestUrl_ = function(extent, size, pixe
* @return {string|undefined} URL.
* @api
*/
ol.source.ImageArcGISRest.prototype.getUrl = function() {
_ol_source_ImageArcGISRest_.prototype.getUrl = function() {
return this.url_;
};
@@ -237,7 +238,7 @@ ol.source.ImageArcGISRest.prototype.getUrl = function() {
* @param {ol.ImageLoadFunctionType} imageLoadFunction Image load function.
* @api
*/
ol.source.ImageArcGISRest.prototype.setImageLoadFunction = function(imageLoadFunction) {
_ol_source_ImageArcGISRest_.prototype.setImageLoadFunction = function(imageLoadFunction) {
this.image_ = null;
this.imageLoadFunction_ = imageLoadFunction;
this.changed();
@@ -249,7 +250,7 @@ ol.source.ImageArcGISRest.prototype.setImageLoadFunction = function(imageLoadFun
* @param {string|undefined} url URL.
* @api
*/
ol.source.ImageArcGISRest.prototype.setUrl = function(url) {
_ol_source_ImageArcGISRest_.prototype.setUrl = function(url) {
if (url != this.url_) {
this.url_ = url;
this.image_ = null;
@@ -263,8 +264,9 @@ ol.source.ImageArcGISRest.prototype.setUrl = function(url) {
* @param {Object} params Params.
* @api
*/
ol.source.ImageArcGISRest.prototype.updateParams = function(params) {
ol.obj.assign(this.params_, params);
_ol_source_ImageArcGISRest_.prototype.updateParams = function(params) {
_ol_obj_.assign(this.params_, params);
this.image_ = null;
this.changed();
};
export default _ol_source_ImageArcGISRest_;

View File

@@ -1,10 +1,10 @@
goog.provide('ol.source.ImageCanvas');
goog.require('ol');
goog.require('ol.ImageCanvas');
goog.require('ol.extent');
goog.require('ol.source.Image');
/**
* @module ol/source/ImageCanvas
*/
import _ol_ from '../index.js';
import _ol_ImageCanvas_ from '../ImageCanvas.js';
import _ol_extent_ from '../extent.js';
import _ol_source_Image_ from '../source/Image.js';
/**
* @classdesc
@@ -15,9 +15,9 @@ goog.require('ol.source.Image');
* @param {olx.source.ImageCanvasOptions} options Constructor options.
* @api
*/
ol.source.ImageCanvas = function(options) {
var _ol_source_ImageCanvas_ = function(options) {
ol.source.Image.call(this, {
_ol_source_Image_.call(this, {
attributions: options.attributions,
logo: options.logo,
projection: options.projection,
@@ -51,13 +51,14 @@ ol.source.ImageCanvas = function(options) {
options.ratio : 1.5;
};
ol.inherits(ol.source.ImageCanvas, ol.source.Image);
_ol_.inherits(_ol_source_ImageCanvas_, _ol_source_Image_);
/**
* @inheritDoc
*/
ol.source.ImageCanvas.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) {
_ol_source_ImageCanvas_.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) {
resolution = this.findNearestResolution(resolution);
var canvas = this.canvas_;
@@ -65,23 +66,24 @@ ol.source.ImageCanvas.prototype.getImageInternal = function(extent, resolution,
this.renderedRevision_ == this.getRevision() &&
canvas.getResolution() == resolution &&
canvas.getPixelRatio() == pixelRatio &&
ol.extent.containsExtent(canvas.getExtent(), extent)) {
_ol_extent_.containsExtent(canvas.getExtent(), extent)) {
return canvas;
}
extent = extent.slice();
ol.extent.scaleFromCenter(extent, this.ratio_);
var width = ol.extent.getWidth(extent) / resolution;
var height = ol.extent.getHeight(extent) / resolution;
_ol_extent_.scaleFromCenter(extent, this.ratio_);
var width = _ol_extent_.getWidth(extent) / resolution;
var height = _ol_extent_.getHeight(extent) / resolution;
var size = [width * pixelRatio, height * pixelRatio];
var canvasElement = this.canvasFunction_(
extent, resolution, pixelRatio, size, projection);
if (canvasElement) {
canvas = new ol.ImageCanvas(extent, resolution, pixelRatio, canvasElement);
canvas = new _ol_ImageCanvas_(extent, resolution, pixelRatio, canvasElement);
}
this.canvas_ = canvas;
this.renderedRevision_ = this.getRevision();
return canvas;
};
export default _ol_source_ImageCanvas_;

View File

@@ -1,14 +1,14 @@
goog.provide('ol.source.ImageMapGuide');
goog.require('ol');
goog.require('ol.Image');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol.extent');
goog.require('ol.obj');
goog.require('ol.source.Image');
goog.require('ol.uri');
/**
* @module ol/source/ImageMapGuide
*/
import _ol_ from '../index.js';
import _ol_Image_ from '../Image.js';
import _ol_events_ from '../events.js';
import _ol_events_EventType_ from '../events/EventType.js';
import _ol_extent_ from '../extent.js';
import _ol_obj_ from '../obj.js';
import _ol_source_Image_ from '../source/Image.js';
import _ol_uri_ from '../uri.js';
/**
* @classdesc
@@ -20,9 +20,9 @@ goog.require('ol.uri');
* @param {olx.source.ImageMapGuideOptions} options Options.
* @api
*/
ol.source.ImageMapGuide = function(options) {
var _ol_source_ImageMapGuide_ = function(options) {
ol.source.Image.call(this, {
_ol_source_Image_.call(this, {
projection: options.projection,
resolutions: options.resolutions
});
@@ -58,7 +58,7 @@ ol.source.ImageMapGuide = function(options) {
* @type {ol.ImageLoadFunctionType}
*/
this.imageLoadFunction_ = options.imageLoadFunction !== undefined ?
options.imageLoadFunction : ol.source.Image.defaultImageLoadFunction;
options.imageLoadFunction : _ol_source_Image_.defaultImageLoadFunction;
/**
* @private
@@ -99,7 +99,8 @@ ol.source.ImageMapGuide = function(options) {
this.renderedRevision_ = 0;
};
ol.inherits(ol.source.ImageMapGuide, ol.source.Image);
_ol_.inherits(_ol_source_ImageMapGuide_, _ol_source_Image_);
/**
@@ -108,7 +109,7 @@ ol.inherits(ol.source.ImageMapGuide, ol.source.Image);
* @return {Object} Params.
* @api
*/
ol.source.ImageMapGuide.prototype.getParams = function() {
_ol_source_ImageMapGuide_.prototype.getParams = function() {
return this.params_;
};
@@ -116,7 +117,7 @@ ol.source.ImageMapGuide.prototype.getParams = function() {
/**
* @inheritDoc
*/
ol.source.ImageMapGuide.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) {
_ol_source_ImageMapGuide_.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) {
resolution = this.findNearestResolution(resolution);
pixelRatio = this.hidpi_ ? pixelRatio : 1;
@@ -125,25 +126,25 @@ ol.source.ImageMapGuide.prototype.getImageInternal = function(extent, resolution
this.renderedRevision_ == this.getRevision() &&
image.getResolution() == resolution &&
image.getPixelRatio() == pixelRatio &&
ol.extent.containsExtent(image.getExtent(), extent)) {
_ol_extent_.containsExtent(image.getExtent(), extent)) {
return image;
}
if (this.ratio_ != 1) {
extent = extent.slice();
ol.extent.scaleFromCenter(extent, this.ratio_);
_ol_extent_.scaleFromCenter(extent, this.ratio_);
}
var width = ol.extent.getWidth(extent) / resolution;
var height = ol.extent.getHeight(extent) / resolution;
var width = _ol_extent_.getWidth(extent) / resolution;
var height = _ol_extent_.getHeight(extent) / resolution;
var size = [width * pixelRatio, height * pixelRatio];
if (this.url_ !== undefined) {
var imageUrl = this.getUrl(this.url_, this.params_, extent, size,
projection);
image = new ol.Image(extent, resolution, pixelRatio,
image = new _ol_Image_(extent, resolution, pixelRatio,
imageUrl, this.crossOrigin_,
this.imageLoadFunction_);
ol.events.listen(image, ol.events.EventType.CHANGE,
_ol_events_.listen(image, _ol_events_EventType_.CHANGE,
this.handleImageChange, this);
} else {
image = null;
@@ -160,7 +161,7 @@ ol.source.ImageMapGuide.prototype.getImageInternal = function(extent, resolution
* @return {ol.ImageLoadFunctionType} The image load function.
* @api
*/
ol.source.ImageMapGuide.prototype.getImageLoadFunction = function() {
_ol_source_ImageMapGuide_.prototype.getImageLoadFunction = function() {
return this.imageLoadFunction_;
};
@@ -172,9 +173,9 @@ ol.source.ImageMapGuide.prototype.getImageLoadFunction = function() {
* @param {number} dpi The display resolution.
* @return {number} The computed map scale.
*/
ol.source.ImageMapGuide.getScale = function(extent, size, metersPerUnit, dpi) {
var mcsW = ol.extent.getWidth(extent);
var mcsH = ol.extent.getHeight(extent);
_ol_source_ImageMapGuide_.getScale = function(extent, size, metersPerUnit, dpi) {
var mcsW = _ol_extent_.getWidth(extent);
var mcsH = _ol_extent_.getHeight(extent);
var devW = size[0];
var devH = size[1];
var mpp = 0.0254 / dpi;
@@ -191,8 +192,8 @@ ol.source.ImageMapGuide.getScale = function(extent, size, metersPerUnit, dpi) {
* @param {Object} params Params.
* @api
*/
ol.source.ImageMapGuide.prototype.updateParams = function(params) {
ol.obj.assign(this.params_, params);
_ol_source_ImageMapGuide_.prototype.updateParams = function(params) {
_ol_obj_.assign(this.params_, params);
this.changed();
};
@@ -205,10 +206,10 @@ ol.source.ImageMapGuide.prototype.updateParams = function(params) {
* @param {ol.proj.Projection} projection Projection.
* @return {string} The mapagent map image request URL.
*/
ol.source.ImageMapGuide.prototype.getUrl = function(baseUrl, params, extent, size, projection) {
var scale = ol.source.ImageMapGuide.getScale(extent, size,
_ol_source_ImageMapGuide_.prototype.getUrl = function(baseUrl, params, extent, size, projection) {
var scale = _ol_source_ImageMapGuide_.getScale(extent, size,
this.metersPerUnit_, this.displayDpi_);
var center = ol.extent.getCenter(extent);
var center = _ol_extent_.getCenter(extent);
var baseParams = {
'OPERATION': this.useOverlay_ ? 'GETDYNAMICMAPOVERLAYIMAGE' : 'GETMAPIMAGE',
'VERSION': '2.0.0',
@@ -222,8 +223,8 @@ ol.source.ImageMapGuide.prototype.getUrl = function(baseUrl, params, extent, siz
'SETVIEWCENTERX': center[0],
'SETVIEWCENTERY': center[1]
};
ol.obj.assign(baseParams, params);
return ol.uri.appendParams(baseUrl, baseParams);
_ol_obj_.assign(baseParams, params);
return _ol_uri_.appendParams(baseUrl, baseParams);
};
@@ -232,9 +233,10 @@ ol.source.ImageMapGuide.prototype.getUrl = function(baseUrl, params, extent, siz
* @param {ol.ImageLoadFunctionType} imageLoadFunction Image load function.
* @api
*/
ol.source.ImageMapGuide.prototype.setImageLoadFunction = function(
_ol_source_ImageMapGuide_.prototype.setImageLoadFunction = function(
imageLoadFunction) {
this.image_ = null;
this.imageLoadFunction_ = imageLoadFunction;
this.changed();
};
export default _ol_source_ImageMapGuide_;

View File

@@ -1,15 +1,15 @@
goog.provide('ol.source.ImageStatic');
goog.require('ol');
goog.require('ol.Image');
goog.require('ol.ImageState');
goog.require('ol.dom');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol.extent');
goog.require('ol.proj');
goog.require('ol.source.Image');
/**
* @module ol/source/ImageStatic
*/
import _ol_ from '../index.js';
import _ol_Image_ from '../Image.js';
import _ol_ImageState_ from '../ImageState.js';
import _ol_dom_ from '../dom.js';
import _ol_events_ from '../events.js';
import _ol_events_EventType_ from '../events/EventType.js';
import _ol_extent_ from '../extent.js';
import _ol_proj_ from '../proj.js';
import _ol_source_Image_ from '../source/Image.js';
/**
* @classdesc
@@ -20,7 +20,7 @@ goog.require('ol.source.Image');
* @param {olx.source.ImageStaticOptions} options Options.
* @api
*/
ol.source.ImageStatic = function(options) {
var _ol_source_ImageStatic_ = function(options) {
var imageExtent = options.imageExtent;
var crossOrigin = options.crossOrigin !== undefined ?
@@ -28,19 +28,19 @@ ol.source.ImageStatic = function(options) {
var /** @type {ol.ImageLoadFunctionType} */ imageLoadFunction =
options.imageLoadFunction !== undefined ?
options.imageLoadFunction : ol.source.Image.defaultImageLoadFunction;
options.imageLoadFunction : _ol_source_Image_.defaultImageLoadFunction;
ol.source.Image.call(this, {
_ol_source_Image_.call(this, {
attributions: options.attributions,
logo: options.logo,
projection: ol.proj.get(options.projection)
projection: _ol_proj_.get(options.projection)
});
/**
* @private
* @type {ol.Image}
*/
this.image_ = new ol.Image(imageExtent, undefined, 1, options.url, crossOrigin, imageLoadFunction);
this.image_ = new _ol_Image_(imageExtent, undefined, 1, options.url, crossOrigin, imageLoadFunction);
/**
* @private
@@ -48,18 +48,19 @@ ol.source.ImageStatic = function(options) {
*/
this.imageSize_ = options.imageSize ? options.imageSize : null;
ol.events.listen(this.image_, ol.events.EventType.CHANGE,
_ol_events_.listen(this.image_, _ol_events_EventType_.CHANGE,
this.handleImageChange, this);
};
ol.inherits(ol.source.ImageStatic, ol.source.Image);
_ol_.inherits(_ol_source_ImageStatic_, _ol_source_Image_);
/**
* @inheritDoc
*/
ol.source.ImageStatic.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) {
if (ol.extent.intersects(extent, this.image_.getExtent())) {
_ol_source_ImageStatic_.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) {
if (_ol_extent_.intersects(extent, this.image_.getExtent())) {
return this.image_;
}
return null;
@@ -69,8 +70,8 @@ ol.source.ImageStatic.prototype.getImageInternal = function(extent, resolution,
/**
* @inheritDoc
*/
ol.source.ImageStatic.prototype.handleImageChange = function(evt) {
if (this.image_.getState() == ol.ImageState.LOADED) {
_ol_source_ImageStatic_.prototype.handleImageChange = function(evt) {
if (this.image_.getState() == _ol_ImageState_.LOADED) {
var imageExtent = this.image_.getExtent();
var image = this.image_.getImage();
var imageWidth, imageHeight;
@@ -81,15 +82,16 @@ ol.source.ImageStatic.prototype.handleImageChange = function(evt) {
imageWidth = image.width;
imageHeight = image.height;
}
var resolution = ol.extent.getHeight(imageExtent) / imageHeight;
var targetWidth = Math.ceil(ol.extent.getWidth(imageExtent) / resolution);
var resolution = _ol_extent_.getHeight(imageExtent) / imageHeight;
var targetWidth = Math.ceil(_ol_extent_.getWidth(imageExtent) / resolution);
if (targetWidth != imageWidth) {
var context = ol.dom.createCanvasContext2D(targetWidth, imageHeight);
var context = _ol_dom_.createCanvasContext2D(targetWidth, imageHeight);
var canvas = context.canvas;
context.drawImage(image, 0, 0, imageWidth, imageHeight,
0, 0, canvas.width, canvas.height);
this.image_.setImage(canvas);
}
}
ol.source.Image.prototype.handleImageChange.call(this, evt);
_ol_source_Image_.prototype.handleImageChange.call(this, evt);
};
export default _ol_source_ImageStatic_;

View File

@@ -1,17 +1,17 @@
goog.provide('ol.source.ImageVector');
goog.require('ol');
goog.require('ol.dom');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol.ext.rbush');
goog.require('ol.extent');
goog.require('ol.render.canvas.ReplayGroup');
goog.require('ol.renderer.vector');
goog.require('ol.source.ImageCanvas');
goog.require('ol.style.Style');
goog.require('ol.transform');
/**
* @module ol/source/ImageVector
*/
import _ol_ from '../index.js';
import _ol_dom_ from '../dom.js';
import _ol_events_ from '../events.js';
import _ol_events_EventType_ from '../events/EventType.js';
import _ol_ext_rbush_ from 'rbush';
import _ol_extent_ from '../extent.js';
import _ol_render_canvas_ReplayGroup_ from '../render/canvas/ReplayGroup.js';
import _ol_renderer_vector_ from '../renderer/vector.js';
import _ol_source_ImageCanvas_ from '../source/ImageCanvas.js';
import _ol_style_Style_ from '../style/Style.js';
import _ol_transform_ from '../transform.js';
/**
* @deprecated
@@ -34,7 +34,7 @@ goog.require('ol.transform');
* @param {olx.source.ImageVectorOptions} options Options.
* @api
*/
ol.source.ImageVector = function(options) {
var _ol_source_ImageVector_ = function(options) {
/**
* @private
@@ -46,13 +46,13 @@ ol.source.ImageVector = function(options) {
* @private
* @type {ol.Transform}
*/
this.transform_ = ol.transform.create();
this.transform_ = _ol_transform_.create();
/**
* @private
* @type {CanvasRenderingContext2D}
*/
this.canvasContext_ = ol.dom.createCanvasContext2D();
this.canvasContext_ = _ol_dom_.createCanvasContext2D();
/**
* @private
@@ -64,7 +64,7 @@ ol.source.ImageVector = function(options) {
* Declutter tree.
* @private
*/
this.declutterTree_ = ol.ext.rbush(9);
this.declutterTree_ = _ol_ext_rbush_(9);
/**
* @private
@@ -78,7 +78,7 @@ ol.source.ImageVector = function(options) {
*/
this.replayGroup_ = null;
ol.source.ImageCanvas.call(this, {
_ol_source_ImageCanvas_.call(this, {
attributions: options.attributions,
canvasFunction: this.canvasFunctionInternal_.bind(this),
logo: options.logo,
@@ -104,11 +104,12 @@ ol.source.ImageVector = function(options) {
this.setStyle(options.style);
ol.events.listen(this.source_, ol.events.EventType.CHANGE,
_ol_events_.listen(this.source_, _ol_events_EventType_.CHANGE,
this.handleSourceChange_, this);
};
ol.inherits(ol.source.ImageVector, ol.source.ImageCanvas);
_ol_.inherits(_ol_source_ImageVector_, _ol_source_ImageCanvas_);
/**
@@ -120,10 +121,10 @@ ol.inherits(ol.source.ImageVector, ol.source.ImageCanvas);
* @return {HTMLCanvasElement} Canvas element.
* @private
*/
ol.source.ImageVector.prototype.canvasFunctionInternal_ = function(extent, resolution, pixelRatio, size, projection) {
_ol_source_ImageVector_.prototype.canvasFunctionInternal_ = function(extent, resolution, pixelRatio, size, projection) {
var replayGroup = new ol.render.canvas.ReplayGroup(
ol.renderer.vector.getTolerance(resolution, pixelRatio), extent,
var replayGroup = new _ol_render_canvas_ReplayGroup_(
_ol_renderer_vector_.getTolerance(resolution, pixelRatio), extent,
resolution, pixelRatio, this.source_.getOverlaps(), this.declutterTree_, this.renderBuffer_);
this.source_.loadFeatures(extent, resolution, projection);
@@ -154,7 +155,7 @@ ol.source.ImageVector.prototype.canvasFunctionInternal_ = function(extent, resol
this.declutterTree_.clear();
var transform = this.getTransform_(ol.extent.getCenter(extent),
var transform = this.getTransform_(_ol_extent_.getCenter(extent),
resolution, pixelRatio, size);
replayGroup.replay(this.canvasContext_, transform, 0, {});
@@ -167,7 +168,7 @@ ol.source.ImageVector.prototype.canvasFunctionInternal_ = function(extent, resol
/**
* @inheritDoc
*/
ol.source.ImageVector.prototype.forEachFeatureAtCoordinate = function(
_ol_source_ImageVector_.prototype.forEachFeatureAtCoordinate = function(
coordinate, resolution, rotation, hitTolerance, skippedFeatureUids, callback) {
if (!this.replayGroup_) {
return undefined;
@@ -181,7 +182,7 @@ ol.source.ImageVector.prototype.forEachFeatureAtCoordinate = function(
* @return {?} Callback result.
*/
function(feature) {
var key = ol.getUid(feature).toString();
var key = _ol_.getUid(feature).toString();
if (!(key in features)) {
features[key] = true;
return callback(feature);
@@ -197,7 +198,7 @@ ol.source.ImageVector.prototype.forEachFeatureAtCoordinate = function(
* @return {ol.source.Vector} Source.
* @api
*/
ol.source.ImageVector.prototype.getSource = function() {
_ol_source_ImageVector_.prototype.getSource = function() {
return this.source_;
};
@@ -209,7 +210,7 @@ ol.source.ImageVector.prototype.getSource = function() {
* Layer style.
* @api
*/
ol.source.ImageVector.prototype.getStyle = function() {
_ol_source_ImageVector_.prototype.getStyle = function() {
return this.style_;
};
@@ -219,7 +220,7 @@ ol.source.ImageVector.prototype.getStyle = function() {
* @return {ol.StyleFunction|undefined} Layer style function.
* @api
*/
ol.source.ImageVector.prototype.getStyleFunction = function() {
_ol_source_ImageVector_.prototype.getStyleFunction = function() {
return this.styleFunction_;
};
@@ -232,7 +233,7 @@ ol.source.ImageVector.prototype.getStyleFunction = function() {
* @return {!ol.Transform} Transform.
* @private
*/
ol.source.ImageVector.prototype.getTransform_ = function(center, resolution, pixelRatio, size) {
_ol_source_ImageVector_.prototype.getTransform_ = function(center, resolution, pixelRatio, size) {
var dx1 = size[0] / 2;
var dy1 = size[1] / 2;
var sx = pixelRatio / resolution;
@@ -240,7 +241,7 @@ ol.source.ImageVector.prototype.getTransform_ = function(center, resolution, pix
var dx2 = -center[0];
var dy2 = -center[1];
return ol.transform.compose(this.transform_, dx1, dy1, sx, sy, 0, dx2, dy2);
return _ol_transform_.compose(this.transform_, dx1, dy1, sx, sy, 0, dx2, dy2);
};
@@ -249,7 +250,7 @@ ol.source.ImageVector.prototype.getTransform_ = function(center, resolution, pix
* @param {ol.events.Event} event Image style change event.
* @private
*/
ol.source.ImageVector.prototype.handleImageChange_ = function(event) {
_ol_source_ImageVector_.prototype.handleImageChange_ = function(event) {
this.changed();
};
@@ -257,7 +258,7 @@ ol.source.ImageVector.prototype.handleImageChange_ = function(event) {
/**
* @private
*/
ol.source.ImageVector.prototype.handleSourceChange_ = function() {
_ol_source_ImageVector_.prototype.handleSourceChange_ = function() {
// setState will trigger a CHANGE event, so we always rely
// change events by calling setState.
this.setState(this.source_.getState());
@@ -272,7 +273,7 @@ ol.source.ImageVector.prototype.handleSourceChange_ = function() {
* @return {boolean} `true` if an image is loading.
* @private
*/
ol.source.ImageVector.prototype.renderFeature_ = function(feature, resolution, pixelRatio, replayGroup) {
_ol_source_ImageVector_.prototype.renderFeature_ = function(feature, resolution, pixelRatio, replayGroup) {
var styles;
var styleFunction = feature.getStyleFunction();
if (styleFunction) {
@@ -288,9 +289,9 @@ ol.source.ImageVector.prototype.renderFeature_ = function(feature, resolution, p
styles = [styles];
}
for (i = 0, ii = styles.length; i < ii; ++i) {
loading = ol.renderer.vector.renderFeature(
loading = _ol_renderer_vector_.renderFeature(
replayGroup, feature, styles[i],
ol.renderer.vector.getSquaredTolerance(resolution, pixelRatio),
_ol_renderer_vector_.getSquaredTolerance(resolution, pixelRatio),
this.handleImageChange_, this) || loading;
}
return loading;
@@ -308,9 +309,10 @@ ol.source.ImageVector.prototype.renderFeature_ = function(feature, resolution, p
* style Layer style.
* @api
*/
ol.source.ImageVector.prototype.setStyle = function(style) {
this.style_ = style !== undefined ? style : ol.style.Style.defaultFunction;
_ol_source_ImageVector_.prototype.setStyle = function(style) {
this.style_ = style !== undefined ? style : _ol_style_Style_.defaultFunction;
this.styleFunction_ = !style ?
undefined : ol.style.Style.createFunction(this.style_);
undefined : _ol_style_Style_.createFunction(this.style_);
this.changed();
};
export default _ol_source_ImageVector_;

View File

@@ -1,21 +1,21 @@
/**
* @module ol/source/ImageWMS
*/
// FIXME cannot be shared between maps with different projections
goog.provide('ol.source.ImageWMS');
goog.require('ol');
goog.require('ol.Image');
goog.require('ol.asserts');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol.extent');
goog.require('ol.obj');
goog.require('ol.proj');
goog.require('ol.reproj');
goog.require('ol.source.Image');
goog.require('ol.source.WMSServerType');
goog.require('ol.string');
goog.require('ol.uri');
import _ol_ from '../index.js';
import _ol_Image_ from '../Image.js';
import _ol_asserts_ from '../asserts.js';
import _ol_events_ from '../events.js';
import _ol_events_EventType_ from '../events/EventType.js';
import _ol_extent_ from '../extent.js';
import _ol_obj_ from '../obj.js';
import _ol_proj_ from '../proj.js';
import _ol_reproj_ from '../reproj.js';
import _ol_source_Image_ from '../source/Image.js';
import _ol_source_WMSServerType_ from '../source/WMSServerType.js';
import _ol_string_ from '../string.js';
import _ol_uri_ from '../uri.js';
/**
* @classdesc
@@ -27,11 +27,11 @@ goog.require('ol.uri');
* @param {olx.source.ImageWMSOptions=} opt_options Options.
* @api
*/
ol.source.ImageWMS = function(opt_options) {
var _ol_source_ImageWMS_ = function(opt_options) {
var options = opt_options || {};
ol.source.Image.call(this, {
_ol_source_Image_.call(this, {
attributions: options.attributions,
logo: options.logo,
projection: options.projection,
@@ -56,7 +56,7 @@ ol.source.ImageWMS = function(opt_options) {
* @type {ol.ImageLoadFunctionType}
*/
this.imageLoadFunction_ = options.imageLoadFunction !== undefined ?
options.imageLoadFunction : ol.source.Image.defaultImageLoadFunction;
options.imageLoadFunction : _ol_source_Image_.defaultImageLoadFunction;
/**
* @private
@@ -108,7 +108,8 @@ ol.source.ImageWMS = function(opt_options) {
this.ratio_ = options.ratio !== undefined ? options.ratio : 1.5;
};
ol.inherits(ol.source.ImageWMS, ol.source.Image);
_ol_.inherits(_ol_source_ImageWMS_, _ol_source_Image_);
/**
@@ -116,7 +117,7 @@ ol.inherits(ol.source.ImageWMS, ol.source.Image);
* @type {ol.Size}
* @private
*/
ol.source.ImageWMS.GETFEATUREINFO_IMAGE_SIZE_ = [101, 101];
_ol_source_ImageWMS_.GETFEATUREINFO_IMAGE_SIZE_ = [101, 101];
/**
@@ -133,31 +134,31 @@ ol.source.ImageWMS.GETFEATUREINFO_IMAGE_SIZE_ = [101, 101];
* @return {string|undefined} GetFeatureInfo URL.
* @api
*/
ol.source.ImageWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projection, params) {
_ol_source_ImageWMS_.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projection, params) {
if (this.url_ === undefined) {
return undefined;
}
var projectionObj = ol.proj.get(projection);
var projectionObj = _ol_proj_.get(projection);
var sourceProjectionObj = this.getProjection();
if (sourceProjectionObj && sourceProjectionObj !== projectionObj) {
resolution = ol.reproj.calculateSourceResolution(sourceProjectionObj, projectionObj, coordinate, resolution);
coordinate = ol.proj.transform(coordinate, projectionObj, sourceProjectionObj);
resolution = _ol_reproj_.calculateSourceResolution(sourceProjectionObj, projectionObj, coordinate, resolution);
coordinate = _ol_proj_.transform(coordinate, projectionObj, sourceProjectionObj);
}
var extent = ol.extent.getForViewAndSize(
var extent = _ol_extent_.getForViewAndSize(
coordinate, resolution, 0,
ol.source.ImageWMS.GETFEATUREINFO_IMAGE_SIZE_);
_ol_source_ImageWMS_.GETFEATUREINFO_IMAGE_SIZE_);
var baseParams = {
'SERVICE': 'WMS',
'VERSION': ol.DEFAULT_WMS_VERSION,
'VERSION': _ol_.DEFAULT_WMS_VERSION,
'REQUEST': 'GetFeatureInfo',
'FORMAT': 'image/png',
'TRANSPARENT': true,
'QUERY_LAYERS': this.params_['LAYERS']
};
ol.obj.assign(baseParams, this.params_, params);
_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);
@@ -165,7 +166,7 @@ ol.source.ImageWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolut
baseParams[this.v13_ ? 'J' : 'Y'] = y;
return this.getRequestUrl_(
extent, ol.source.ImageWMS.GETFEATUREINFO_IMAGE_SIZE_,
extent, _ol_source_ImageWMS_.GETFEATUREINFO_IMAGE_SIZE_,
1, sourceProjectionObj || projectionObj, baseParams);
};
@@ -176,7 +177,7 @@ ol.source.ImageWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolut
* @return {Object} Params.
* @api
*/
ol.source.ImageWMS.prototype.getParams = function() {
_ol_source_ImageWMS_.prototype.getParams = function() {
return this.params_;
};
@@ -184,7 +185,7 @@ ol.source.ImageWMS.prototype.getParams = function() {
/**
* @inheritDoc
*/
ol.source.ImageWMS.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) {
_ol_source_ImageWMS_.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) {
if (this.url_ === undefined) {
return null;
@@ -198,14 +199,14 @@ ol.source.ImageWMS.prototype.getImageInternal = function(extent, resolution, pix
var imageResolution = resolution / pixelRatio;
var center = ol.extent.getCenter(extent);
var viewWidth = Math.ceil(ol.extent.getWidth(extent) / imageResolution);
var viewHeight = Math.ceil(ol.extent.getHeight(extent) / imageResolution);
var viewExtent = ol.extent.getForViewAndSize(center, imageResolution, 0,
var center = _ol_extent_.getCenter(extent);
var viewWidth = Math.ceil(_ol_extent_.getWidth(extent) / imageResolution);
var viewHeight = Math.ceil(_ol_extent_.getHeight(extent) / imageResolution);
var viewExtent = _ol_extent_.getForViewAndSize(center, imageResolution, 0,
[viewWidth, viewHeight]);
var requestWidth = Math.ceil(this.ratio_ * ol.extent.getWidth(extent) / imageResolution);
var requestHeight = Math.ceil(this.ratio_ * ol.extent.getHeight(extent) / imageResolution);
var requestExtent = ol.extent.getForViewAndSize(center, imageResolution, 0,
var requestWidth = Math.ceil(this.ratio_ * _ol_extent_.getWidth(extent) / imageResolution);
var requestHeight = Math.ceil(this.ratio_ * _ol_extent_.getHeight(extent) / imageResolution);
var requestExtent = _ol_extent_.getForViewAndSize(center, imageResolution, 0,
[requestWidth, requestHeight]);
var image = this.image_;
@@ -213,31 +214,31 @@ ol.source.ImageWMS.prototype.getImageInternal = function(extent, resolution, pix
this.renderedRevision_ == this.getRevision() &&
image.getResolution() == resolution &&
image.getPixelRatio() == pixelRatio &&
ol.extent.containsExtent(image.getExtent(), viewExtent)) {
_ol_extent_.containsExtent(image.getExtent(), viewExtent)) {
return image;
}
var params = {
'SERVICE': 'WMS',
'VERSION': ol.DEFAULT_WMS_VERSION,
'VERSION': _ol_.DEFAULT_WMS_VERSION,
'REQUEST': 'GetMap',
'FORMAT': 'image/png',
'TRANSPARENT': true
};
ol.obj.assign(params, this.params_);
_ol_obj_.assign(params, this.params_);
this.imageSize_[0] = Math.round(ol.extent.getWidth(requestExtent) / imageResolution);
this.imageSize_[1] = Math.round(ol.extent.getHeight(requestExtent) / imageResolution);
this.imageSize_[0] = Math.round(_ol_extent_.getWidth(requestExtent) / imageResolution);
this.imageSize_[1] = Math.round(_ol_extent_.getHeight(requestExtent) / imageResolution);
var url = this.getRequestUrl_(requestExtent, this.imageSize_, pixelRatio,
projection, params);
this.image_ = new ol.Image(requestExtent, resolution, pixelRatio,
this.image_ = new _ol_Image_(requestExtent, resolution, pixelRatio,
url, this.crossOrigin_, this.imageLoadFunction_);
this.renderedRevision_ = this.getRevision();
ol.events.listen(this.image_, ol.events.EventType.CHANGE,
_ol_events_.listen(this.image_, _ol_events_EventType_.CHANGE,
this.handleImageChange, this);
return this.image_;
@@ -250,7 +251,7 @@ ol.source.ImageWMS.prototype.getImageInternal = function(extent, resolution, pix
* @return {ol.ImageLoadFunctionType} The image load function.
* @api
*/
ol.source.ImageWMS.prototype.getImageLoadFunction = function() {
_ol_source_ImageWMS_.prototype.getImageLoadFunction = function() {
return this.imageLoadFunction_;
};
@@ -264,9 +265,9 @@ ol.source.ImageWMS.prototype.getImageLoadFunction = function() {
* @return {string} Request URL.
* @private
*/
ol.source.ImageWMS.prototype.getRequestUrl_ = function(extent, size, pixelRatio, projection, params) {
_ol_source_ImageWMS_.prototype.getRequestUrl_ = function(extent, size, pixelRatio, projection, params) {
ol.asserts.assert(this.url_ !== undefined, 9); // `url` must be configured or set using `#setUrl()`
_ol_asserts_.assert(this.url_ !== undefined, 9); // `url` must be configured or set using `#setUrl()`
params[this.v13_ ? 'CRS' : 'SRS'] = projection.getCode();
@@ -276,7 +277,7 @@ ol.source.ImageWMS.prototype.getRequestUrl_ = function(extent, size, pixelRatio,
if (pixelRatio != 1) {
switch (this.serverType_) {
case ol.source.WMSServerType.GEOSERVER:
case _ol_source_WMSServerType_.GEOSERVER:
var dpi = (90 * pixelRatio + 0.5) | 0;
if ('FORMAT_OPTIONS' in params) {
params['FORMAT_OPTIONS'] += ';dpi:' + dpi;
@@ -284,15 +285,15 @@ ol.source.ImageWMS.prototype.getRequestUrl_ = function(extent, size, pixelRatio,
params['FORMAT_OPTIONS'] = 'dpi:' + dpi;
}
break;
case ol.source.WMSServerType.MAPSERVER:
case _ol_source_WMSServerType_.MAPSERVER:
params['MAP_RESOLUTION'] = 90 * pixelRatio;
break;
case ol.source.WMSServerType.CARMENTA_SERVER:
case ol.source.WMSServerType.QGIS:
case _ol_source_WMSServerType_.CARMENTA_SERVER:
case _ol_source_WMSServerType_.QGIS:
params['DPI'] = 90 * pixelRatio;
break;
default:
ol.asserts.assert(false, 8); // Unknown `serverType` configured
_ol_asserts_.assert(false, 8); // Unknown `serverType` configured
break;
}
}
@@ -309,7 +310,7 @@ ol.source.ImageWMS.prototype.getRequestUrl_ = function(extent, size, pixelRatio,
}
params['BBOX'] = bbox.join(',');
return ol.uri.appendParams(/** @type {string} */ (this.url_), params);
return _ol_uri_.appendParams(/** @type {string} */ (this.url_), params);
};
@@ -318,7 +319,7 @@ ol.source.ImageWMS.prototype.getRequestUrl_ = function(extent, size, pixelRatio,
* @return {string|undefined} URL.
* @api
*/
ol.source.ImageWMS.prototype.getUrl = function() {
_ol_source_ImageWMS_.prototype.getUrl = function() {
return this.url_;
};
@@ -328,7 +329,7 @@ ol.source.ImageWMS.prototype.getUrl = function() {
* @param {ol.ImageLoadFunctionType} imageLoadFunction Image load function.
* @api
*/
ol.source.ImageWMS.prototype.setImageLoadFunction = function(
_ol_source_ImageWMS_.prototype.setImageLoadFunction = function(
imageLoadFunction) {
this.image_ = null;
this.imageLoadFunction_ = imageLoadFunction;
@@ -341,7 +342,7 @@ ol.source.ImageWMS.prototype.setImageLoadFunction = function(
* @param {string|undefined} url URL.
* @api
*/
ol.source.ImageWMS.prototype.setUrl = function(url) {
_ol_source_ImageWMS_.prototype.setUrl = function(url) {
if (url != this.url_) {
this.url_ = url;
this.image_ = null;
@@ -355,8 +356,8 @@ ol.source.ImageWMS.prototype.setUrl = function(url) {
* @param {Object} params Params.
* @api
*/
ol.source.ImageWMS.prototype.updateParams = function(params) {
ol.obj.assign(this.params_, params);
_ol_source_ImageWMS_.prototype.updateParams = function(params) {
_ol_obj_.assign(this.params_, params);
this.updateV13_();
this.image_ = null;
this.changed();
@@ -366,7 +367,8 @@ ol.source.ImageWMS.prototype.updateParams = function(params) {
/**
* @private
*/
ol.source.ImageWMS.prototype.updateV13_ = function() {
var version = this.params_['VERSION'] || ol.DEFAULT_WMS_VERSION;
this.v13_ = ol.string.compareVersions(version, '1.3') >= 0;
_ol_source_ImageWMS_.prototype.updateV13_ = function() {
var version = this.params_['VERSION'] || _ol_.DEFAULT_WMS_VERSION;
this.v13_ = _ol_string_.compareVersions(version, '1.3') >= 0;
};
export default _ol_source_ImageWMS_;

View File

@@ -1,8 +1,8 @@
goog.provide('ol.source.OSM');
goog.require('ol');
goog.require('ol.source.XYZ');
/**
* @module ol/source/OSM
*/
import _ol_ from '../index.js';
import _ol_source_XYZ_ from '../source/XYZ.js';
/**
* @classdesc
@@ -13,7 +13,7 @@ goog.require('ol.source.XYZ');
* @param {olx.source.OSMOptions=} opt_options Open Street Map options.
* @api
*/
ol.source.OSM = function(opt_options) {
var _ol_source_OSM_ = function(opt_options) {
var options = opt_options || {};
@@ -21,7 +21,7 @@ ol.source.OSM = function(opt_options) {
if (options.attributions !== undefined) {
attributions = options.attributions;
} else {
attributions = [ol.source.OSM.ATTRIBUTION];
attributions = [_ol_source_OSM_.ATTRIBUTION];
}
var crossOrigin = options.crossOrigin !== undefined ?
@@ -30,7 +30,7 @@ ol.source.OSM = function(opt_options) {
var url = options.url !== undefined ?
options.url : 'https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png';
ol.source.XYZ.call(this, {
_ol_source_XYZ_.call(this, {
attributions: attributions,
cacheSize: options.cacheSize,
crossOrigin: crossOrigin,
@@ -43,7 +43,8 @@ ol.source.OSM = function(opt_options) {
});
};
ol.inherits(ol.source.OSM, ol.source.XYZ);
_ol_.inherits(_ol_source_OSM_, _ol_source_XYZ_);
/**
@@ -53,6 +54,7 @@ ol.inherits(ol.source.OSM, ol.source.XYZ);
* @type {string}
* @api
*/
ol.source.OSM.ATTRIBUTION = '&copy; ' +
_ol_source_OSM_.ATTRIBUTION = '&copy; ' +
'<a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> ' +
'contributors.';
export default _ol_source_OSM_;

View File

@@ -1,25 +1,25 @@
goog.provide('ol.source.Raster');
goog.require('ol');
goog.require('ol.ImageCanvas');
goog.require('ol.TileQueue');
goog.require('ol.dom');
goog.require('ol.events');
goog.require('ol.events.Event');
goog.require('ol.events.EventType');
goog.require('ol.ext.pixelworks.Processor');
goog.require('ol.extent');
goog.require('ol.layer.Image');
goog.require('ol.layer.Tile');
goog.require('ol.obj');
goog.require('ol.renderer.canvas.ImageLayer');
goog.require('ol.renderer.canvas.TileLayer');
goog.require('ol.source.Image');
goog.require('ol.source.RasterOperationType');
goog.require('ol.source.State');
goog.require('ol.source.Tile');
goog.require('ol.transform');
/**
* @module ol/source/Raster
*/
import _ol_ from '../index.js';
import _ol_ImageCanvas_ from '../ImageCanvas.js';
import _ol_TileQueue_ from '../TileQueue.js';
import _ol_dom_ from '../dom.js';
import _ol_events_ from '../events.js';
import _ol_events_Event_ from '../events/Event.js';
import _ol_events_EventType_ from '../events/EventType.js';
import {Processor as _ol_ext_pixelworks_Processor_} from 'pixelworks';
import _ol_extent_ from '../extent.js';
import _ol_layer_Image_ from '../layer/Image.js';
import _ol_layer_Tile_ from '../layer/Tile.js';
import _ol_obj_ from '../obj.js';
import _ol_renderer_canvas_ImageLayer_ from '../renderer/canvas/ImageLayer.js';
import _ol_renderer_canvas_TileLayer_ from '../renderer/canvas/TileLayer.js';
import _ol_source_Image_ from '../source/Image.js';
import _ol_source_RasterOperationType_ from '../source/RasterOperationType.js';
import _ol_source_State_ from '../source/State.js';
import _ol_source_Tile_ from '../source/Tile.js';
import _ol_transform_ from '../transform.js';
/**
* @classdesc
@@ -33,7 +33,7 @@ goog.require('ol.transform');
* @param {olx.source.RasterOptions} options Options.
* @api
*/
ol.source.Raster = function(options) {
var _ol_source_Raster_ = function(options) {
/**
* @private
@@ -46,7 +46,7 @@ ol.source.Raster = function(options) {
* @type {ol.source.RasterOperationType}
*/
this.operationType_ = options.operationType !== undefined ?
options.operationType : ol.source.RasterOperationType.PIXEL;
options.operationType : _ol_source_RasterOperationType_.PIXEL;
/**
* @private
@@ -58,10 +58,10 @@ ol.source.Raster = function(options) {
* @private
* @type {Array.<ol.renderer.canvas.Layer>}
*/
this.renderers_ = ol.source.Raster.createRenderers_(options.sources);
this.renderers_ = _ol_source_Raster_.createRenderers_(options.sources);
for (var r = 0, rr = this.renderers_.length; r < rr; ++r) {
ol.events.listen(this.renderers_[r], ol.events.EventType.CHANGE,
_ol_events_.listen(this.renderers_[r], _ol_events_EventType_.CHANGE,
this.changed, this);
}
@@ -69,16 +69,16 @@ ol.source.Raster = function(options) {
* @private
* @type {ol.TileQueue}
*/
this.tileQueue_ = new ol.TileQueue(
this.tileQueue_ = new _ol_TileQueue_(
function() {
return 1;
},
this.changed.bind(this));
var layerStatesArray = ol.source.Raster.getLayerStatesArray_(this.renderers_);
var layerStatesArray = _ol_source_Raster_.getLayerStatesArray_(this.renderers_);
var layerStates = {};
for (var i = 0, ii = layerStatesArray.length; i < ii; ++i) {
layerStates[ol.getUid(layerStatesArray[i].layer)] = layerStatesArray[i];
layerStates[_ol_.getUid(layerStatesArray[i].layer)] = layerStatesArray[i];
}
/**
@@ -107,7 +107,7 @@ ol.source.Raster = function(options) {
*/
this.frameState_ = {
animate: false,
coordinateToPixelTransform: ol.transform.create(),
coordinateToPixelTransform: _ol_transform_.create(),
extent: null,
focus: null,
index: 0,
@@ -115,7 +115,7 @@ ol.source.Raster = function(options) {
layerStatesArray: layerStatesArray,
logos: {},
pixelRatio: 1,
pixelToCoordinateTransform: ol.transform.create(),
pixelToCoordinateTransform: _ol_transform_.create(),
postRenderFunctions: [],
size: [0, 0],
skippedFeatureUids: {},
@@ -129,14 +129,15 @@ ol.source.Raster = function(options) {
wantedTiles: {}
};
ol.source.Image.call(this, {});
_ol_source_Image_.call(this, {});
if (options.operation !== undefined) {
this.setOperation(options.operation, options.lib);
}
};
ol.inherits(ol.source.Raster, ol.source.Image);
_ol_.inherits(_ol_source_Raster_, _ol_source_Image_);
/**
@@ -146,10 +147,10 @@ ol.inherits(ol.source.Raster, ol.source.Image);
* in a worker.
* @api
*/
ol.source.Raster.prototype.setOperation = function(operation, opt_lib) {
this.worker_ = new ol.ext.pixelworks.Processor({
_ol_source_Raster_.prototype.setOperation = function(operation, opt_lib) {
this.worker_ = new _ol_ext_pixelworks_Processor_({
operation: operation,
imageOps: this.operationType_ === ol.source.RasterOperationType.IMAGE,
imageOps: this.operationType_ === _ol_source_RasterOperationType_.IMAGE,
queue: 1,
lib: opt_lib,
threads: this.threads_
@@ -166,20 +167,20 @@ ol.source.Raster.prototype.setOperation = function(operation, opt_lib) {
* @return {olx.FrameState} The updated frame state.
* @private
*/
ol.source.Raster.prototype.updateFrameState_ = function(extent, resolution, projection) {
_ol_source_Raster_.prototype.updateFrameState_ = function(extent, resolution, projection) {
var frameState = /** @type {olx.FrameState} */ (
ol.obj.assign({}, this.frameState_));
_ol_obj_.assign({}, this.frameState_));
frameState.viewState = /** @type {olx.ViewState} */ (
ol.obj.assign({}, frameState.viewState));
_ol_obj_.assign({}, frameState.viewState));
var center = ol.extent.getCenter(extent);
var center = _ol_extent_.getCenter(extent);
frameState.extent = extent.slice();
frameState.focus = center;
frameState.size[0] = Math.round(ol.extent.getWidth(extent) / resolution);
frameState.size[1] = Math.round(ol.extent.getHeight(extent) / resolution);
frameState.size[0] = Math.round(_ol_extent_.getWidth(extent) / resolution);
frameState.size[1] = Math.round(_ol_extent_.getHeight(extent) / resolution);
frameState.time = Date.now();
frameState.animate = false;
@@ -196,12 +197,12 @@ ol.source.Raster.prototype.updateFrameState_ = function(extent, resolution, proj
* @return {boolean} All sources are ready.
* @private
*/
ol.source.Raster.prototype.allSourcesReady_ = function() {
_ol_source_Raster_.prototype.allSourcesReady_ = function() {
var ready = true;
var source;
for (var i = 0, ii = this.renderers_.length; i < ii; ++i) {
source = this.renderers_[i].getLayer().getSource();
if (source.getState() !== ol.source.State.READY) {
if (source.getState() !== _ol_source_State_.READY) {
ready = false;
break;
}
@@ -213,7 +214,7 @@ ol.source.Raster.prototype.allSourcesReady_ = function() {
/**
* @inheritDoc
*/
ol.source.Raster.prototype.getImage = function(extent, resolution, pixelRatio, projection) {
_ol_source_Raster_.prototype.getImage = function(extent, resolution, pixelRatio, projection) {
if (!this.allSourcesReady_()) {
return null;
}
@@ -225,7 +226,7 @@ ol.source.Raster.prototype.getImage = function(extent, resolution, pixelRatio, p
if (this.renderedImageCanvas_) {
var renderedResolution = this.renderedImageCanvas_.getResolution();
var renderedExtent = this.renderedImageCanvas_.getExtent();
if (resolution !== renderedResolution || !ol.extent.equals(extent, renderedExtent)) {
if (resolution !== renderedResolution || !_ol_extent_.equals(extent, renderedExtent)) {
this.renderedImageCanvas_ = null;
}
}
@@ -248,12 +249,12 @@ ol.source.Raster.prototype.getImage = function(extent, resolution, pixelRatio, p
* Start processing source data.
* @private
*/
ol.source.Raster.prototype.processSources_ = function() {
_ol_source_Raster_.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 = ol.source.Raster.getImageData_(
var imageData = _ol_source_Raster_.getImageData_(
this.renderers_[i], frameState, frameState.layerStatesArray[i]);
if (imageData) {
imageDatas[i] = imageData;
@@ -263,8 +264,8 @@ ol.source.Raster.prototype.processSources_ = function() {
}
var data = {};
this.dispatchEvent(new ol.source.Raster.Event(
ol.source.Raster.EventType_.BEFOREOPERATIONS, frameState, data));
this.dispatchEvent(new _ol_source_Raster_.Event(
_ol_source_Raster_.EventType_.BEFOREOPERATIONS, frameState, data));
this.worker_.process(imageDatas, data,
this.onWorkerComplete_.bind(this, frameState));
};
@@ -278,7 +279,7 @@ ol.source.Raster.prototype.processSources_ = function() {
* @param {Object} data The user data.
* @private
*/
ol.source.Raster.prototype.onWorkerComplete_ = function(frameState, err, output, data) {
_ol_source_Raster_.prototype.onWorkerComplete_ = function(frameState, err, output, data) {
if (err || !output) {
return;
}
@@ -287,7 +288,7 @@ ol.source.Raster.prototype.onWorkerComplete_ = function(frameState, err, output,
var extent = frameState.extent;
var resolution = frameState.viewState.resolution;
if (resolution !== this.requestedFrameState_.viewState.resolution ||
!ol.extent.equals(extent, this.requestedFrameState_.extent)) {
!_ol_extent_.equals(extent, this.requestedFrameState_.extent)) {
return;
}
@@ -295,18 +296,18 @@ ol.source.Raster.prototype.onWorkerComplete_ = function(frameState, err, output,
if (this.renderedImageCanvas_) {
context = this.renderedImageCanvas_.getImage().getContext('2d');
} else {
var width = Math.round(ol.extent.getWidth(extent) / resolution);
var height = Math.round(ol.extent.getHeight(extent) / resolution);
context = ol.dom.createCanvasContext2D(width, height);
this.renderedImageCanvas_ = new ol.ImageCanvas(extent, resolution, 1, context.canvas);
var width = Math.round(_ol_extent_.getWidth(extent) / resolution);
var height = Math.round(_ol_extent_.getHeight(extent) / resolution);
context = _ol_dom_.createCanvasContext2D(width, height);
this.renderedImageCanvas_ = new _ol_ImageCanvas_(extent, resolution, 1, context.canvas);
}
context.putImageData(output, 0, 0);
this.changed();
this.renderedRevision_ = this.getRevision();
this.dispatchEvent(new ol.source.Raster.Event(
ol.source.Raster.EventType_.AFTEROPERATIONS, frameState, data));
this.dispatchEvent(new _ol_source_Raster_.Event(
_ol_source_Raster_.EventType_.AFTEROPERATIONS, frameState, data));
};
@@ -318,24 +319,24 @@ ol.source.Raster.prototype.onWorkerComplete_ = function(frameState, err, output,
* @return {ImageData} The image data.
* @private
*/
ol.source.Raster.getImageData_ = function(renderer, frameState, layerState) {
_ol_source_Raster_.getImageData_ = function(renderer, frameState, layerState) {
if (!renderer.prepareFrame(frameState, layerState)) {
return null;
}
var width = frameState.size[0];
var height = frameState.size[1];
if (!ol.source.Raster.context_) {
ol.source.Raster.context_ = ol.dom.createCanvasContext2D(width, height);
if (!_ol_source_Raster_.context_) {
_ol_source_Raster_.context_ = _ol_dom_.createCanvasContext2D(width, height);
} else {
var canvas = ol.source.Raster.context_.canvas;
var canvas = _ol_source_Raster_.context_.canvas;
if (canvas.width !== width || canvas.height !== height) {
ol.source.Raster.context_ = ol.dom.createCanvasContext2D(width, height);
_ol_source_Raster_.context_ = _ol_dom_.createCanvasContext2D(width, height);
} else {
ol.source.Raster.context_.clearRect(0, 0, width, height);
_ol_source_Raster_.context_.clearRect(0, 0, width, height);
}
}
renderer.composeFrame(frameState, layerState, ol.source.Raster.context_);
return ol.source.Raster.context_.getImageData(0, 0, width, height);
renderer.composeFrame(frameState, layerState, _ol_source_Raster_.context_);
return _ol_source_Raster_.context_.getImageData(0, 0, width, height);
};
@@ -344,7 +345,7 @@ ol.source.Raster.getImageData_ = function(renderer, frameState, layerState) {
* @type {CanvasRenderingContext2D}
* @private
*/
ol.source.Raster.context_ = null;
_ol_source_Raster_.context_ = null;
/**
@@ -353,7 +354,7 @@ ol.source.Raster.context_ = null;
* @return {Array.<ol.LayerState>} The layer states.
* @private
*/
ol.source.Raster.getLayerStatesArray_ = function(renderers) {
_ol_source_Raster_.getLayerStatesArray_ = function(renderers) {
return renderers.map(function(renderer) {
return renderer.getLayer().getLayerState();
});
@@ -366,11 +367,11 @@ ol.source.Raster.getLayerStatesArray_ = function(renderers) {
* @return {Array.<ol.renderer.canvas.Layer>} Array of layer renderers.
* @private
*/
ol.source.Raster.createRenderers_ = function(sources) {
_ol_source_Raster_.createRenderers_ = function(sources) {
var len = sources.length;
var renderers = new Array(len);
for (var i = 0; i < len; ++i) {
renderers[i] = ol.source.Raster.createRenderer_(sources[i]);
renderers[i] = _ol_source_Raster_.createRenderer_(sources[i]);
}
return renderers;
};
@@ -382,12 +383,12 @@ ol.source.Raster.createRenderers_ = function(sources) {
* @return {ol.renderer.canvas.Layer} The renderer.
* @private
*/
ol.source.Raster.createRenderer_ = function(source) {
_ol_source_Raster_.createRenderer_ = function(source) {
var renderer = null;
if (source instanceof ol.source.Tile) {
renderer = ol.source.Raster.createTileRenderer_(source);
} else if (source instanceof ol.source.Image) {
renderer = ol.source.Raster.createImageRenderer_(source);
if (source instanceof _ol_source_Tile_) {
renderer = _ol_source_Raster_.createTileRenderer_(source);
} else if (source instanceof _ol_source_Image_) {
renderer = _ol_source_Raster_.createImageRenderer_(source);
}
return renderer;
};
@@ -399,9 +400,9 @@ ol.source.Raster.createRenderer_ = function(source) {
* @return {ol.renderer.canvas.Layer} The renderer.
* @private
*/
ol.source.Raster.createImageRenderer_ = function(source) {
var layer = new ol.layer.Image({source: source});
return new ol.renderer.canvas.ImageLayer(layer);
_ol_source_Raster_.createImageRenderer_ = function(source) {
var layer = new _ol_layer_Image_({source: source});
return new _ol_renderer_canvas_ImageLayer_(layer);
};
@@ -411,9 +412,9 @@ ol.source.Raster.createImageRenderer_ = function(source) {
* @return {ol.renderer.canvas.Layer} The renderer.
* @private
*/
ol.source.Raster.createTileRenderer_ = function(source) {
var layer = new ol.layer.Tile({source: source});
return new ol.renderer.canvas.TileLayer(layer);
_ol_source_Raster_.createTileRenderer_ = function(source) {
var layer = new _ol_layer_Tile_({source: source});
return new _ol_renderer_canvas_TileLayer_(layer);
};
@@ -429,8 +430,8 @@ ol.source.Raster.createTileRenderer_ = function(source) {
* @param {olx.FrameState} frameState The frame state.
* @param {Object} data An object made available to operations.
*/
ol.source.Raster.Event = function(type, frameState, data) {
ol.events.Event.call(this, type);
_ol_source_Raster_.Event = function(type, frameState, data) {
_ol_events_Event_.call(this, type);
/**
* The raster extent.
@@ -455,13 +456,13 @@ ol.source.Raster.Event = function(type, frameState, data) {
this.data = data;
};
ol.inherits(ol.source.Raster.Event, ol.events.Event);
_ol_.inherits(_ol_source_Raster_.Event, _ol_events_Event_);
/**
* @override
*/
ol.source.Raster.prototype.getImageInternal = function() {
_ol_source_Raster_.prototype.getImageInternal = function() {
return null; // not implemented
};
@@ -470,7 +471,7 @@ ol.source.Raster.prototype.getImageInternal = function() {
* @enum {string}
* @private
*/
ol.source.Raster.EventType_ = {
_ol_source_Raster_.EventType_ = {
/**
* Triggered before operations are run.
* @event ol.source.Raster.Event#beforeoperations
@@ -485,3 +486,4 @@ ol.source.Raster.EventType_ = {
*/
AFTEROPERATIONS: 'afteroperations'
};
export default _ol_source_Raster_;

View File

@@ -1,10 +1,13 @@
goog.provide('ol.source.RasterOperationType');
/**
* @module ol/source/RasterOperationType
*/
/**
* Raster operation type. Supported values are `'pixel'` and `'image'`.
* @enum {string}
*/
ol.source.RasterOperationType = {
var _ol_source_RasterOperationType_ = {
PIXEL: 'pixel',
IMAGE: 'image'
};
export default _ol_source_RasterOperationType_;

View File

@@ -1,11 +1,11 @@
goog.provide('ol.source.Source');
goog.require('ol');
goog.require('ol.Attribution');
goog.require('ol.Object');
goog.require('ol.proj');
goog.require('ol.source.State');
/**
* @module ol/source/Source
*/
import _ol_ from '../index.js';
import _ol_Attribution_ from '../Attribution.js';
import _ol_Object_ from '../Object.js';
import _ol_proj_ from '../proj.js';
import _ol_source_State_ from '../source/State.js';
/**
* @classdesc
@@ -21,15 +21,15 @@ goog.require('ol.source.State');
* @param {ol.SourceSourceOptions} options Source options.
* @api
*/
ol.source.Source = function(options) {
var _ol_source_Source_ = function(options) {
ol.Object.call(this);
_ol_Object_.call(this);
/**
* @private
* @type {ol.proj.Projection}
*/
this.projection_ = ol.proj.get(options.projection);
this.projection_ = _ol_proj_.get(options.projection);
/**
* @private
@@ -54,7 +54,7 @@ ol.source.Source = function(options) {
* @type {ol.source.State}
*/
this.state_ = options.state !== undefined ?
options.state : ol.source.State.READY;
options.state : _ol_source_State_.READY;
/**
* @private
@@ -63,7 +63,8 @@ ol.source.Source = function(options) {
this.wrapX_ = options.wrapX !== undefined ? options.wrapX : false;
};
ol.inherits(ol.source.Source, ol.Object);
_ol_.inherits(_ol_source_Source_, _ol_Object_);
/**
* Turns the attributions option into an attributions function.
@@ -71,11 +72,11 @@ ol.inherits(ol.source.Source, ol.Object);
* @param {ol.AttributionLike|undefined} attributionLike The attribution option.
* @return {?ol.Attribution2} An attribution function (or null).
*/
ol.source.Source.prototype.adaptAttributions_ = function(attributionLike) {
_ol_source_Source_.prototype.adaptAttributions_ = function(attributionLike) {
if (!attributionLike) {
return null;
}
if (attributionLike instanceof ol.Attribution) {
if (attributionLike instanceof _ol_Attribution_) {
// TODO: remove attributions_ in next major release
this.attributions_ = [attributionLike];
@@ -85,7 +86,7 @@ ol.source.Source.prototype.adaptAttributions_ = function(attributionLike) {
};
}
if (Array.isArray(attributionLike)) {
if (attributionLike[0] instanceof ol.Attribution) {
if (attributionLike[0] instanceof _ol_Attribution_) {
// TODO: remove attributions_ in next major release
this.attributions_ = attributionLike;
@@ -100,7 +101,7 @@ ol.source.Source.prototype.adaptAttributions_ = function(attributionLike) {
// TODO: remove attributions_ in next major release
this.attributions_ = attributionLike.map(function(attribution) {
return new ol.Attribution({html: attribution});
return new _ol_Attribution_({html: attribution});
});
return function(frameState) {
@@ -114,7 +115,7 @@ ol.source.Source.prototype.adaptAttributions_ = function(attributionLike) {
// TODO: remove attributions_ in next major release
this.attributions_ = [
new ol.Attribution({html: attributionLike})
new _ol_Attribution_({html: attributionLike})
];
return function(frameState) {
@@ -133,7 +134,7 @@ ol.source.Source.prototype.adaptAttributions_ = function(attributionLike) {
* @return {T|undefined} Callback result.
* @template T
*/
ol.source.Source.prototype.forEachFeatureAtCoordinate = ol.nullFunction;
_ol_source_Source_.prototype.forEachFeatureAtCoordinate = _ol_.nullFunction;
/**
@@ -141,7 +142,7 @@ ol.source.Source.prototype.forEachFeatureAtCoordinate = ol.nullFunction;
* @return {Array.<ol.Attribution>} Attributions.
* @api
*/
ol.source.Source.prototype.getAttributions = function() {
_ol_source_Source_.prototype.getAttributions = function() {
return this.attributions_;
};
@@ -150,7 +151,7 @@ ol.source.Source.prototype.getAttributions = function() {
* Get the attribution function for the source.
* @return {?ol.Attribution2} Attribution function.
*/
ol.source.Source.prototype.getAttributions2 = function() {
_ol_source_Source_.prototype.getAttributions2 = function() {
return this.attributions2_;
};
@@ -160,7 +161,7 @@ ol.source.Source.prototype.getAttributions2 = function() {
* @return {string|olx.LogoOptions|undefined} Logo.
* @api
*/
ol.source.Source.prototype.getLogo = function() {
_ol_source_Source_.prototype.getLogo = function() {
return this.logo_;
};
@@ -170,7 +171,7 @@ ol.source.Source.prototype.getLogo = function() {
* @return {ol.proj.Projection} Projection.
* @api
*/
ol.source.Source.prototype.getProjection = function() {
_ol_source_Source_.prototype.getProjection = function() {
return this.projection_;
};
@@ -179,7 +180,7 @@ ol.source.Source.prototype.getProjection = function() {
* @abstract
* @return {Array.<number>|undefined} Resolutions.
*/
ol.source.Source.prototype.getResolutions = function() {};
_ol_source_Source_.prototype.getResolutions = function() {};
/**
@@ -187,7 +188,7 @@ ol.source.Source.prototype.getResolutions = function() {};
* @return {ol.source.State} State.
* @api
*/
ol.source.Source.prototype.getState = function() {
_ol_source_Source_.prototype.getState = function() {
return this.state_;
};
@@ -195,7 +196,7 @@ ol.source.Source.prototype.getState = function() {
/**
* @return {boolean|undefined} Wrap X.
*/
ol.source.Source.prototype.getWrapX = function() {
_ol_source_Source_.prototype.getWrapX = function() {
return this.wrapX_;
};
@@ -204,7 +205,7 @@ ol.source.Source.prototype.getWrapX = function() {
* Refreshes the source and finally dispatches a 'change' event.
* @api
*/
ol.source.Source.prototype.refresh = function() {
_ol_source_Source_.prototype.refresh = function() {
this.changed();
};
@@ -216,7 +217,7 @@ ol.source.Source.prototype.refresh = function() {
* or `undefined`.
* @api
*/
ol.source.Source.prototype.setAttributions = function(attributions) {
_ol_source_Source_.prototype.setAttributions = function(attributions) {
this.attributions2_ = this.adaptAttributions_(attributions);
this.changed();
};
@@ -226,7 +227,7 @@ ol.source.Source.prototype.setAttributions = function(attributions) {
* Set the logo of the source.
* @param {string|olx.LogoOptions|undefined} logo Logo.
*/
ol.source.Source.prototype.setLogo = function(logo) {
_ol_source_Source_.prototype.setLogo = function(logo) {
this.logo_ = logo;
};
@@ -236,7 +237,8 @@ ol.source.Source.prototype.setLogo = function(logo) {
* @param {ol.source.State} state State.
* @protected
*/
ol.source.Source.prototype.setState = function(state) {
_ol_source_Source_.prototype.setState = function(state) {
this.state_ = state;
this.changed();
};
export default _ol_source_Source_;

View File

@@ -1,9 +1,9 @@
goog.provide('ol.source.Stamen');
goog.require('ol');
goog.require('ol.source.OSM');
goog.require('ol.source.XYZ');
/**
* @module ol/source/Stamen
*/
import _ol_ from '../index.js';
import _ol_source_OSM_ from '../source/OSM.js';
import _ol_source_XYZ_ from '../source/XYZ.js';
/**
* @classdesc
@@ -14,19 +14,19 @@ goog.require('ol.source.XYZ');
* @param {olx.source.StamenOptions} options Stamen options.
* @api
*/
ol.source.Stamen = function(options) {
var _ol_source_Stamen_ = function(options) {
var i = options.layer.indexOf('-');
var provider = i == -1 ? options.layer : options.layer.slice(0, i);
var providerConfig = ol.source.Stamen.ProviderConfig[provider];
var providerConfig = _ol_source_Stamen_.ProviderConfig[provider];
var layerConfig = ol.source.Stamen.LayerConfig[options.layer];
var layerConfig = _ol_source_Stamen_.LayerConfig[options.layer];
var url = options.url !== undefined ? options.url :
'https://stamen-tiles-{a-d}.a.ssl.fastly.net/' + options.layer +
'/{z}/{x}/{y}.' + layerConfig.extension;
ol.source.XYZ.call(this, {
attributions: ol.source.Stamen.ATTRIBUTIONS,
_ol_source_XYZ_.call(this, {
attributions: _ol_source_Stamen_.ATTRIBUTIONS,
cacheSize: options.cacheSize,
crossOrigin: 'anonymous',
maxZoom: options.maxZoom != undefined ? options.maxZoom : providerConfig.maxZoom,
@@ -38,24 +38,25 @@ ol.source.Stamen = function(options) {
wrapX: options.wrapX
});
};
ol.inherits(ol.source.Stamen, ol.source.XYZ);
_ol_.inherits(_ol_source_Stamen_, _ol_source_XYZ_);
/**
* @const
* @type {Array.<string>}
*/
ol.source.Stamen.ATTRIBUTIONS = [
_ol_source_Stamen_.ATTRIBUTIONS = [
'Map tiles by <a href="https://stamen.com/">Stamen Design</a>, ' +
'under <a href="https://creativecommons.org/licenses/by/3.0/">CC BY' +
' 3.0</a>.',
ol.source.OSM.ATTRIBUTION
_ol_source_OSM_.ATTRIBUTION
];
/**
* @type {Object.<string, {extension: string, opaque: boolean}>}
*/
ol.source.Stamen.LayerConfig = {
_ol_source_Stamen_.LayerConfig = {
'terrain': {
extension: 'jpg',
opaque: true
@@ -105,7 +106,7 @@ ol.source.Stamen.LayerConfig = {
/**
* @type {Object.<string, {minZoom: number, maxZoom: number}>}
*/
ol.source.Stamen.ProviderConfig = {
_ol_source_Stamen_.ProviderConfig = {
'terrain': {
minZoom: 4,
maxZoom: 18
@@ -119,3 +120,4 @@ ol.source.Stamen.ProviderConfig = {
maxZoom: 16
}
};
export default _ol_source_Stamen_;

View File

@@ -1,14 +1,15 @@
goog.provide('ol.source.State');
/**
* @module ol/source/State
*/
/**
* State of the source, one of 'undefined', 'loading', 'ready' or 'error'.
* @enum {string}
*/
ol.source.State = {
var _ol_source_State_ = {
UNDEFINED: 'undefined',
LOADING: 'loading',
READY: 'ready',
ERROR: 'error'
};
export default _ol_source_State_;

View File

@@ -1,15 +1,15 @@
goog.provide('ol.source.Tile');
goog.require('ol');
goog.require('ol.TileCache');
goog.require('ol.TileState');
goog.require('ol.events.Event');
goog.require('ol.proj');
goog.require('ol.size');
goog.require('ol.source.Source');
goog.require('ol.tilecoord');
goog.require('ol.tilegrid');
/**
* @module ol/source/Tile
*/
import _ol_ from '../index.js';
import _ol_TileCache_ from '../TileCache.js';
import _ol_TileState_ from '../TileState.js';
import _ol_events_Event_ from '../events/Event.js';
import _ol_proj_ from '../proj.js';
import _ol_size_ from '../size.js';
import _ol_source_Source_ from '../source/Source.js';
import _ol_tilecoord_ from '../tilecoord.js';
import _ol_tilegrid_ from '../tilegrid.js';
/**
* @classdesc
@@ -23,9 +23,9 @@ goog.require('ol.tilegrid');
* @param {ol.SourceTileOptions} options Tile source options.
* @api
*/
ol.source.Tile = function(options) {
var _ol_source_Tile_ = function(options) {
ol.source.Source.call(this, {
_ol_source_Source_.call(this, {
attributions: options.attributions,
extent: options.extent,
logo: options.logo,
@@ -57,7 +57,7 @@ ol.source.Tile = function(options) {
* @protected
* @type {ol.TileCache}
*/
this.tileCache = new ol.TileCache(options.cacheSize);
this.tileCache = new _ol_TileCache_(options.cacheSize);
/**
* @protected
@@ -78,13 +78,14 @@ ol.source.Tile = function(options) {
this.tileOptions = {transition: options.transition};
};
ol.inherits(ol.source.Tile, ol.source.Source);
_ol_.inherits(_ol_source_Tile_, _ol_source_Source_);
/**
* @return {boolean} Can expire cache.
*/
ol.source.Tile.prototype.canExpireCache = function() {
_ol_source_Tile_.prototype.canExpireCache = function() {
return this.tileCache.canExpireCache();
};
@@ -93,7 +94,7 @@ ol.source.Tile.prototype.canExpireCache = function() {
* @param {ol.proj.Projection} projection Projection.
* @param {Object.<string, ol.TileRange>} usedTiles Used tiles.
*/
ol.source.Tile.prototype.expireCache = function(projection, usedTiles) {
_ol_source_Tile_.prototype.expireCache = function(projection, usedTiles) {
var tileCache = this.getTileCacheForProjection(projection);
if (tileCache) {
tileCache.expireCache(usedTiles);
@@ -110,7 +111,7 @@ ol.source.Tile.prototype.expireCache = function(projection, usedTiles) {
* considered loaded.
* @return {boolean} The tile range is fully covered with loaded tiles.
*/
ol.source.Tile.prototype.forEachLoadedTile = function(projection, z, tileRange, callback) {
_ol_source_Tile_.prototype.forEachLoadedTile = function(projection, z, tileRange, callback) {
var tileCache = this.getTileCacheForProjection(projection);
if (!tileCache) {
return false;
@@ -120,11 +121,11 @@ ol.source.Tile.prototype.forEachLoadedTile = function(projection, z, tileRange,
var tile, tileCoordKey, loaded;
for (var x = tileRange.minX; x <= tileRange.maxX; ++x) {
for (var y = tileRange.minY; y <= tileRange.maxY; ++y) {
tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y);
tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y);
loaded = false;
if (tileCache.containsKey(tileCoordKey)) {
tile = /** @type {!ol.Tile} */ (tileCache.get(tileCoordKey));
loaded = tile.getState() === ol.TileState.LOADED;
loaded = tile.getState() === _ol_TileState_.LOADED;
if (loaded) {
loaded = (callback(tile) !== false);
}
@@ -142,7 +143,7 @@ ol.source.Tile.prototype.forEachLoadedTile = function(projection, z, tileRange,
* @param {ol.proj.Projection} projection Projection.
* @return {number} Gutter.
*/
ol.source.Tile.prototype.getGutter = function(projection) {
_ol_source_Tile_.prototype.getGutter = function(projection) {
return 0;
};
@@ -152,7 +153,7 @@ ol.source.Tile.prototype.getGutter = function(projection) {
* @return {string} The key for all tiles.
* @protected
*/
ol.source.Tile.prototype.getKey = function() {
_ol_source_Tile_.prototype.getKey = function() {
return this.key_;
};
@@ -162,7 +163,7 @@ ol.source.Tile.prototype.getKey = function() {
* @param {string} key The key for tiles.
* @protected
*/
ol.source.Tile.prototype.setKey = function(key) {
_ol_source_Tile_.prototype.setKey = function(key) {
if (this.key_ !== key) {
this.key_ = key;
this.changed();
@@ -174,7 +175,7 @@ ol.source.Tile.prototype.setKey = function(key) {
* @param {ol.proj.Projection} projection Projection.
* @return {boolean} Opaque.
*/
ol.source.Tile.prototype.getOpaque = function(projection) {
_ol_source_Tile_.prototype.getOpaque = function(projection) {
return this.opaque_;
};
@@ -182,7 +183,7 @@ ol.source.Tile.prototype.getOpaque = function(projection) {
/**
* @inheritDoc
*/
ol.source.Tile.prototype.getResolutions = function() {
_ol_source_Tile_.prototype.getResolutions = function() {
return this.tileGrid.getResolutions();
};
@@ -196,7 +197,7 @@ ol.source.Tile.prototype.getResolutions = function() {
* @param {ol.proj.Projection} projection Projection.
* @return {!ol.Tile} Tile.
*/
ol.source.Tile.prototype.getTile = function(z, x, y, pixelRatio, projection) {};
_ol_source_Tile_.prototype.getTile = function(z, x, y, pixelRatio, projection) {};
/**
@@ -204,7 +205,7 @@ ol.source.Tile.prototype.getTile = function(z, x, y, pixelRatio, projection) {};
* @return {ol.tilegrid.TileGrid} Tile grid.
* @api
*/
ol.source.Tile.prototype.getTileGrid = function() {
_ol_source_Tile_.prototype.getTileGrid = function() {
return this.tileGrid;
};
@@ -213,9 +214,9 @@ ol.source.Tile.prototype.getTileGrid = function() {
* @param {ol.proj.Projection} projection Projection.
* @return {!ol.tilegrid.TileGrid} Tile grid.
*/
ol.source.Tile.prototype.getTileGridForProjection = function(projection) {
_ol_source_Tile_.prototype.getTileGridForProjection = function(projection) {
if (!this.tileGrid) {
return ol.tilegrid.getForProjection(projection);
return _ol_tilegrid_.getForProjection(projection);
} else {
return this.tileGrid;
}
@@ -227,9 +228,9 @@ ol.source.Tile.prototype.getTileGridForProjection = function(projection) {
* @return {ol.TileCache} Tile cache.
* @protected
*/
ol.source.Tile.prototype.getTileCacheForProjection = function(projection) {
_ol_source_Tile_.prototype.getTileCacheForProjection = function(projection) {
var thisProj = this.getProjection();
if (thisProj && !ol.proj.equivalent(thisProj, projection)) {
if (thisProj && !_ol_proj_.equivalent(thisProj, projection)) {
return null;
} else {
return this.tileCache;
@@ -244,7 +245,7 @@ ol.source.Tile.prototype.getTileCacheForProjection = function(projection) {
* @param {number} pixelRatio Pixel ratio.
* @return {number} Tile pixel ratio.
*/
ol.source.Tile.prototype.getTilePixelRatio = function(pixelRatio) {
_ol_source_Tile_.prototype.getTilePixelRatio = function(pixelRatio) {
return this.tilePixelRatio_;
};
@@ -255,14 +256,14 @@ ol.source.Tile.prototype.getTilePixelRatio = function(pixelRatio) {
* @param {ol.proj.Projection} projection Projection.
* @return {ol.Size} Tile size.
*/
ol.source.Tile.prototype.getTilePixelSize = function(z, pixelRatio, projection) {
_ol_source_Tile_.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);
var tileSize = _ol_size_.toSize(tileGrid.getTileSize(z), this.tmpSize);
if (tilePixelRatio == 1) {
return tileSize;
} else {
return ol.size.scale(tileSize, tilePixelRatio, this.tmpSize);
return _ol_size_.scale(tileSize, tilePixelRatio, this.tmpSize);
}
};
@@ -276,21 +277,21 @@ ol.source.Tile.prototype.getTilePixelSize = function(z, pixelRatio, projection)
* @return {ol.TileCoord} Tile coordinate to be passed to the tileUrlFunction or
* null if no tile URL should be created for the passed `tileCoord`.
*/
ol.source.Tile.prototype.getTileCoordForTileUrlFunction = function(tileCoord, opt_projection) {
_ol_source_Tile_.prototype.getTileCoordForTileUrlFunction = function(tileCoord, opt_projection) {
var projection = opt_projection !== undefined ?
opt_projection : this.getProjection();
var tileGrid = this.getTileGridForProjection(projection);
if (this.getWrapX() && projection.isGlobal()) {
tileCoord = ol.tilegrid.wrapX(tileGrid, tileCoord, projection);
tileCoord = _ol_tilegrid_.wrapX(tileGrid, tileCoord, projection);
}
return ol.tilecoord.withinExtentAndZ(tileCoord, tileGrid) ? tileCoord : null;
return _ol_tilecoord_.withinExtentAndZ(tileCoord, tileGrid) ? tileCoord : null;
};
/**
* @inheritDoc
*/
ol.source.Tile.prototype.refresh = function() {
_ol_source_Tile_.prototype.refresh = function() {
this.tileCache.clear();
this.changed();
};
@@ -303,7 +304,7 @@ ol.source.Tile.prototype.refresh = function() {
* @param {number} y Tile coordinate y.
* @param {ol.proj.Projection} projection Projection.
*/
ol.source.Tile.prototype.useTile = ol.nullFunction;
_ol_source_Tile_.prototype.useTile = _ol_.nullFunction;
/**
@@ -317,9 +318,9 @@ ol.source.Tile.prototype.useTile = ol.nullFunction;
* @param {string} type Type.
* @param {ol.Tile} tile The tile.
*/
ol.source.Tile.Event = function(type, tile) {
_ol_source_Tile_.Event = function(type, tile) {
ol.events.Event.call(this, type);
_ol_events_Event_.call(this, type);
/**
* The tile related to the event.
@@ -329,4 +330,5 @@ ol.source.Tile.Event = function(type, tile) {
this.tile = tile;
};
ol.inherits(ol.source.Tile.Event, ol.events.Event);
_ol_.inherits(_ol_source_Tile_.Event, _ol_events_Event_);
export default _ol_source_Tile_;

View File

@@ -1,14 +1,14 @@
goog.provide('ol.source.TileArcGISRest');
goog.require('ol');
goog.require('ol.extent');
goog.require('ol.math');
goog.require('ol.obj');
goog.require('ol.size');
goog.require('ol.source.TileImage');
goog.require('ol.tilecoord');
goog.require('ol.uri');
/**
* @module ol/source/TileArcGISRest
*/
import _ol_ from '../index.js';
import _ol_extent_ from '../extent.js';
import _ol_math_ from '../math.js';
import _ol_obj_ from '../obj.js';
import _ol_size_ from '../size.js';
import _ol_source_TileImage_ from '../source/TileImage.js';
import _ol_tilecoord_ from '../tilecoord.js';
import _ol_uri_ from '../uri.js';
/**
* @classdesc
@@ -24,11 +24,11 @@ goog.require('ol.uri');
* options.
* @api
*/
ol.source.TileArcGISRest = function(opt_options) {
var _ol_source_TileArcGISRest_ = function(opt_options) {
var options = opt_options || {};
ol.source.TileImage.call(this, {
_ol_source_TileImage_.call(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,
crossOrigin: options.crossOrigin,
@@ -53,18 +53,19 @@ ol.source.TileArcGISRest = function(opt_options) {
* @private
* @type {ol.Extent}
*/
this.tmpExtent_ = ol.extent.createEmpty();
this.tmpExtent_ = _ol_extent_.createEmpty();
this.setKey(this.getKeyForParams_());
};
ol.inherits(ol.source.TileArcGISRest, ol.source.TileImage);
_ol_.inherits(_ol_source_TileArcGISRest_, _ol_source_TileImage_);
/**
* @private
* @return {string} The key for the current params.
*/
ol.source.TileArcGISRest.prototype.getKeyForParams_ = function() {
_ol_source_TileArcGISRest_.prototype.getKeyForParams_ = function() {
var i = 0;
var res = [];
for (var key in this.params_) {
@@ -80,7 +81,7 @@ ol.source.TileArcGISRest.prototype.getKeyForParams_ = function() {
* @return {Object} Params.
* @api
*/
ol.source.TileArcGISRest.prototype.getParams = function() {
_ol_source_TileArcGISRest_.prototype.getParams = function() {
return this.params_;
};
@@ -95,7 +96,7 @@ ol.source.TileArcGISRest.prototype.getParams = function() {
* @return {string|undefined} Request URL.
* @private
*/
ol.source.TileArcGISRest.prototype.getRequestUrl_ = function(tileCoord, tileSize, tileExtent,
_ol_source_TileArcGISRest_.prototype.getRequestUrl_ = function(tileCoord, tileSize, tileExtent,
pixelRatio, projection, params) {
var urls = this.urls;
@@ -118,21 +119,21 @@ ol.source.TileArcGISRest.prototype.getRequestUrl_ = function(tileCoord, tileSize
if (urls.length == 1) {
url = urls[0];
} else {
var index = ol.math.modulo(ol.tilecoord.hash(tileCoord), urls.length);
var index = _ol_math_.modulo(_ol_tilecoord_.hash(tileCoord), urls.length);
url = urls[index];
}
var modifiedUrl = url
.replace(/MapServer\/?$/, 'MapServer/export')
.replace(/ImageServer\/?$/, 'ImageServer/exportImage');
return ol.uri.appendParams(modifiedUrl, params);
return _ol_uri_.appendParams(modifiedUrl, params);
};
/**
* @inheritDoc
*/
ol.source.TileArcGISRest.prototype.getTilePixelRatio = function(pixelRatio) {
_ol_source_TileArcGISRest_.prototype.getTilePixelRatio = function(pixelRatio) {
return /** @type {number} */ (pixelRatio);
};
@@ -140,7 +141,7 @@ ol.source.TileArcGISRest.prototype.getTilePixelRatio = function(pixelRatio) {
/**
* @inheritDoc
*/
ol.source.TileArcGISRest.prototype.fixedTileUrlFunction = function(tileCoord, pixelRatio, projection) {
_ol_source_TileArcGISRest_.prototype.fixedTileUrlFunction = function(tileCoord, pixelRatio, projection) {
var tileGrid = this.getTileGrid();
if (!tileGrid) {
@@ -153,11 +154,11 @@ ol.source.TileArcGISRest.prototype.fixedTileUrlFunction = function(tileCoord, pi
var tileExtent = tileGrid.getTileCoordExtent(
tileCoord, this.tmpExtent_);
var tileSize = ol.size.toSize(
var tileSize = _ol_size_.toSize(
tileGrid.getTileSize(tileCoord[0]), this.tmpSize);
if (pixelRatio != 1) {
tileSize = ol.size.scale(tileSize, pixelRatio, this.tmpSize);
tileSize = _ol_size_.scale(tileSize, pixelRatio, this.tmpSize);
}
// Apply default params and override with user specified values.
@@ -166,7 +167,7 @@ ol.source.TileArcGISRest.prototype.fixedTileUrlFunction = function(tileCoord, pi
'FORMAT': 'PNG32',
'TRANSPARENT': true
};
ol.obj.assign(baseParams, this.params_);
_ol_obj_.assign(baseParams, this.params_);
return this.getRequestUrl_(tileCoord, tileSize, tileExtent,
pixelRatio, projection, baseParams);
@@ -178,7 +179,8 @@ ol.source.TileArcGISRest.prototype.fixedTileUrlFunction = function(tileCoord, pi
* @param {Object} params Params.
* @api
*/
ol.source.TileArcGISRest.prototype.updateParams = function(params) {
ol.obj.assign(this.params_, params);
_ol_source_TileArcGISRest_.prototype.updateParams = function(params) {
_ol_obj_.assign(this.params_, params);
this.setKey(this.getKeyForParams_());
};
export default _ol_source_TileArcGISRest_;

View File

@@ -1,13 +1,13 @@
goog.provide('ol.source.TileDebug');
goog.require('ol');
goog.require('ol.Tile');
goog.require('ol.TileState');
goog.require('ol.dom');
goog.require('ol.size');
goog.require('ol.source.Tile');
goog.require('ol.tilecoord');
/**
* @module ol/source/TileDebug
*/
import _ol_ from '../index.js';
import _ol_Tile_ from '../Tile.js';
import _ol_TileState_ from '../TileState.js';
import _ol_dom_ from '../dom.js';
import _ol_size_ from '../size.js';
import _ol_source_Tile_ from '../source/Tile.js';
import _ol_tilecoord_ from '../tilecoord.js';
/**
* @classdesc
@@ -22,9 +22,9 @@ goog.require('ol.tilecoord');
* @param {olx.source.TileDebugOptions} options Debug tile options.
* @api
*/
ol.source.TileDebug = function(options) {
var _ol_source_TileDebug_ = function(options) {
ol.source.Tile.call(this, {
_ol_source_Tile_.call(this, {
opaque: false,
projection: options.projection,
tileGrid: options.tileGrid,
@@ -32,23 +32,24 @@ ol.source.TileDebug = function(options) {
});
};
ol.inherits(ol.source.TileDebug, ol.source.Tile);
_ol_.inherits(_ol_source_TileDebug_, _ol_source_Tile_);
/**
* @inheritDoc
*/
ol.source.TileDebug.prototype.getTile = function(z, x, y) {
var tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y);
_ol_source_TileDebug_.prototype.getTile = function(z, x, y) {
var 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 tileSize = _ol_size_.toSize(this.tileGrid.getTileSize(z));
var tileCoord = [z, x, y];
var textTileCoord = this.getTileCoordForTileUrlFunction(tileCoord);
var text = !textTileCoord ? '' :
this.getTileCoordForTileUrlFunction(textTileCoord).toString();
var tile = new ol.source.TileDebug.Tile_(tileCoord, tileSize, text);
var tile = new _ol_source_TileDebug_.Tile_(tileCoord, tileSize, text);
this.tileCache.set(tileCoordKey, tile);
return tile;
}
@@ -63,9 +64,9 @@ ol.source.TileDebug.prototype.getTile = function(z, x, y) {
* @param {string} text Text.
* @private
*/
ol.source.TileDebug.Tile_ = function(tileCoord, tileSize, text) {
_ol_source_TileDebug_.Tile_ = function(tileCoord, tileSize, text) {
ol.Tile.call(this, tileCoord, ol.TileState.LOADED);
_ol_Tile_.call(this, tileCoord, _ol_TileState_.LOADED);
/**
* @private
@@ -86,19 +87,19 @@ ol.source.TileDebug.Tile_ = function(tileCoord, tileSize, text) {
this.canvas_ = null;
};
ol.inherits(ol.source.TileDebug.Tile_, ol.Tile);
_ol_.inherits(_ol_source_TileDebug_.Tile_, _ol_Tile_);
/**
* Get the image element for this tile.
* @return {HTMLCanvasElement} Image.
*/
ol.source.TileDebug.Tile_.prototype.getImage = function() {
_ol_source_TileDebug_.Tile_.prototype.getImage = function() {
if (this.canvas_) {
return this.canvas_;
} else {
var tileSize = this.tileSize_;
var context = ol.dom.createCanvasContext2D(tileSize[0], tileSize[1]);
var context = _ol_dom_.createCanvasContext2D(tileSize[0], tileSize[1]);
context.strokeStyle = 'black';
context.strokeRect(0.5, 0.5, tileSize[0] + 0.5, tileSize[1] + 0.5);
@@ -118,4 +119,5 @@ ol.source.TileDebug.Tile_.prototype.getImage = function() {
/**
* @override
*/
ol.source.TileDebug.Tile_.prototype.load = function() {};
_ol_source_TileDebug_.Tile_.prototype.load = function() {};
export default _ol_source_TileDebug_;

View File

@@ -1,9 +1,10 @@
goog.provide('ol.source.TileEventType');
/**
* @module ol/source/TileEventType
*/
/**
* @enum {string}
*/
ol.source.TileEventType = {
var _ol_source_TileEventType_ = {
/**
* Triggered when a tile starts loading.
@@ -28,3 +29,5 @@ ol.source.TileEventType = {
TILELOADERROR: 'tileloaderror'
};
export default _ol_source_TileEventType_;

View File

@@ -1,17 +1,17 @@
goog.provide('ol.source.TileImage');
goog.require('ol');
goog.require('ol.ImageTile');
goog.require('ol.TileCache');
goog.require('ol.TileState');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol.proj');
goog.require('ol.reproj.Tile');
goog.require('ol.source.UrlTile');
goog.require('ol.tilecoord');
goog.require('ol.tilegrid');
/**
* @module ol/source/TileImage
*/
import _ol_ from '../index.js';
import _ol_ImageTile_ from '../ImageTile.js';
import _ol_TileCache_ from '../TileCache.js';
import _ol_TileState_ from '../TileState.js';
import _ol_events_ from '../events.js';
import _ol_events_EventType_ from '../events/EventType.js';
import _ol_proj_ from '../proj.js';
import _ol_reproj_Tile_ from '../reproj/Tile.js';
import _ol_source_UrlTile_ from '../source/UrlTile.js';
import _ol_tilecoord_ from '../tilecoord.js';
import _ol_tilegrid_ from '../tilegrid.js';
/**
* @classdesc
@@ -23,9 +23,9 @@ goog.require('ol.tilegrid');
* @param {olx.source.TileImageOptions} options Image tile options.
* @api
*/
ol.source.TileImage = function(options) {
var _ol_source_TileImage_ = function(options) {
ol.source.UrlTile.call(this, {
_ol_source_UrlTile_.call(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,
extent: options.extent,
@@ -35,7 +35,7 @@ ol.source.TileImage = function(options) {
state: options.state,
tileGrid: options.tileGrid,
tileLoadFunction: options.tileLoadFunction ?
options.tileLoadFunction : ol.source.TileImage.defaultTileLoadFunction,
options.tileLoadFunction : _ol_source_TileImage_.defaultTileLoadFunction,
tilePixelRatio: options.tilePixelRatio,
tileUrlFunction: options.tileUrlFunction,
url: options.url,
@@ -57,7 +57,7 @@ ol.source.TileImage = function(options) {
* ?string, ol.TileLoadFunctionType, olx.TileOptions=)}
*/
this.tileClass = options.tileClass !== undefined ?
options.tileClass : ol.ImageTile;
options.tileClass : _ol_ImageTile_;
/**
* @protected
@@ -83,15 +83,16 @@ ol.source.TileImage = function(options) {
*/
this.renderReprojectionEdges_ = false;
};
ol.inherits(ol.source.TileImage, ol.source.UrlTile);
_ol_.inherits(_ol_source_TileImage_, _ol_source_UrlTile_);
/**
* @inheritDoc
*/
ol.source.TileImage.prototype.canExpireCache = function() {
if (!ol.ENABLE_RASTER_REPROJECTION) {
return ol.source.UrlTile.prototype.canExpireCache.call(this);
_ol_source_TileImage_.prototype.canExpireCache = function() {
if (!_ol_.ENABLE_RASTER_REPROJECTION) {
return _ol_source_UrlTile_.prototype.canExpireCache.call(this);
}
if (this.tileCache.canExpireCache()) {
return true;
@@ -109,9 +110,9 @@ ol.source.TileImage.prototype.canExpireCache = function() {
/**
* @inheritDoc
*/
ol.source.TileImage.prototype.expireCache = function(projection, usedTiles) {
if (!ol.ENABLE_RASTER_REPROJECTION) {
ol.source.UrlTile.prototype.expireCache.call(this, projection, usedTiles);
_ol_source_TileImage_.prototype.expireCache = function(projection, usedTiles) {
if (!_ol_.ENABLE_RASTER_REPROJECTION) {
_ol_source_UrlTile_.prototype.expireCache.call(this, projection, usedTiles);
return;
}
var usedTileCache = this.getTileCacheForProjection(projection);
@@ -127,10 +128,10 @@ ol.source.TileImage.prototype.expireCache = function(projection, usedTiles) {
/**
* @inheritDoc
*/
ol.source.TileImage.prototype.getGutter = function(projection) {
if (ol.ENABLE_RASTER_REPROJECTION &&
_ol_source_TileImage_.prototype.getGutter = function(projection) {
if (_ol_.ENABLE_RASTER_REPROJECTION &&
this.getProjection() && projection &&
!ol.proj.equivalent(this.getProjection(), projection)) {
!_ol_proj_.equivalent(this.getProjection(), projection)) {
return 0;
} else {
return this.getGutterInternal();
@@ -142,7 +143,7 @@ ol.source.TileImage.prototype.getGutter = function(projection) {
* @protected
* @return {number} Gutter.
*/
ol.source.TileImage.prototype.getGutterInternal = function() {
_ol_source_TileImage_.prototype.getGutterInternal = function() {
return 0;
};
@@ -150,13 +151,13 @@ ol.source.TileImage.prototype.getGutterInternal = function() {
/**
* @inheritDoc
*/
ol.source.TileImage.prototype.getOpaque = function(projection) {
if (ol.ENABLE_RASTER_REPROJECTION &&
_ol_source_TileImage_.prototype.getOpaque = function(projection) {
if (_ol_.ENABLE_RASTER_REPROJECTION &&
this.getProjection() && projection &&
!ol.proj.equivalent(this.getProjection(), projection)) {
!_ol_proj_.equivalent(this.getProjection(), projection)) {
return false;
} else {
return ol.source.UrlTile.prototype.getOpaque.call(this, projection);
return _ol_source_UrlTile_.prototype.getOpaque.call(this, projection);
}
};
@@ -164,19 +165,19 @@ ol.source.TileImage.prototype.getOpaque = function(projection) {
/**
* @inheritDoc
*/
ol.source.TileImage.prototype.getTileGridForProjection = function(projection) {
if (!ol.ENABLE_RASTER_REPROJECTION) {
return ol.source.UrlTile.prototype.getTileGridForProjection.call(this, projection);
_ol_source_TileImage_.prototype.getTileGridForProjection = function(projection) {
if (!_ol_.ENABLE_RASTER_REPROJECTION) {
return _ol_source_UrlTile_.prototype.getTileGridForProjection.call(this, projection);
}
var thisProj = this.getProjection();
if (this.tileGrid &&
(!thisProj || ol.proj.equivalent(thisProj, projection))) {
(!thisProj || _ol_proj_.equivalent(thisProj, projection))) {
return this.tileGrid;
} else {
var projKey = ol.getUid(projection).toString();
var projKey = _ol_.getUid(projection).toString();
if (!(projKey in this.tileGridForProjection)) {
this.tileGridForProjection[projKey] =
ol.tilegrid.getForProjection(projection);
_ol_tilegrid_.getForProjection(projection);
}
return /** @type {!ol.tilegrid.TileGrid} */ (this.tileGridForProjection[projKey]);
}
@@ -186,17 +187,17 @@ ol.source.TileImage.prototype.getTileGridForProjection = function(projection) {
/**
* @inheritDoc
*/
ol.source.TileImage.prototype.getTileCacheForProjection = function(projection) {
if (!ol.ENABLE_RASTER_REPROJECTION) {
return ol.source.UrlTile.prototype.getTileCacheForProjection.call(this, projection);
_ol_source_TileImage_.prototype.getTileCacheForProjection = function(projection) {
if (!_ol_.ENABLE_RASTER_REPROJECTION) {
return _ol_source_UrlTile_.prototype.getTileCacheForProjection.call(this, projection);
}
var thisProj = this.getProjection();
if (!thisProj || ol.proj.equivalent(thisProj, projection)) {
if (!thisProj || _ol_proj_.equivalent(thisProj, projection)) {
return this.tileCache;
} else {
var projKey = ol.getUid(projection).toString();
var projKey = _ol_.getUid(projection).toString();
if (!(projKey in this.tileCacheForProjection)) {
this.tileCacheForProjection[projKey] = new ol.TileCache(this.tileCache.highWaterMark);
this.tileCacheForProjection[projKey] = new _ol_TileCache_(this.tileCache.highWaterMark);
}
return this.tileCacheForProjection[projKey];
}
@@ -213,7 +214,7 @@ ol.source.TileImage.prototype.getTileCacheForProjection = function(projection) {
* @return {!ol.Tile} Tile.
* @private
*/
ol.source.TileImage.prototype.createTile_ = function(z, x, y, pixelRatio, projection, key) {
_ol_source_TileImage_.prototype.createTile_ = function(z, x, y, pixelRatio, projection, key) {
var tileCoord = [z, x, y];
var urlTileCoord = this.getTileCoordForTileUrlFunction(
tileCoord, projection);
@@ -221,13 +222,13 @@ ol.source.TileImage.prototype.createTile_ = function(z, x, y, pixelRatio, projec
this.tileUrlFunction(urlTileCoord, pixelRatio, projection) : undefined;
var tile = new this.tileClass(
tileCoord,
tileUrl !== undefined ? ol.TileState.IDLE : ol.TileState.EMPTY,
tileUrl !== undefined ? _ol_TileState_.IDLE : _ol_TileState_.EMPTY,
tileUrl !== undefined ? tileUrl : '',
this.crossOrigin,
this.tileLoadFunction,
this.tileOptions);
tile.key = key;
ol.events.listen(tile, ol.events.EventType.CHANGE,
_ol_events_.listen(tile, _ol_events_EventType_.CHANGE,
this.handleTileChange, this);
return tile;
};
@@ -236,17 +237,17 @@ ol.source.TileImage.prototype.createTile_ = function(z, x, y, pixelRatio, projec
/**
* @inheritDoc
*/
ol.source.TileImage.prototype.getTile = function(z, x, y, pixelRatio, projection) {
_ol_source_TileImage_.prototype.getTile = function(z, x, y, pixelRatio, projection) {
var sourceProjection = /** @type {!ol.proj.Projection} */ (this.getProjection());
if (!ol.ENABLE_RASTER_REPROJECTION ||
if (!_ol_.ENABLE_RASTER_REPROJECTION ||
!sourceProjection || !projection ||
ol.proj.equivalent(sourceProjection, projection)) {
_ol_proj_.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);
var tileCoordKey = _ol_tilecoord_.getKey(tileCoord);
if (cache.containsKey(tileCoordKey)) {
tile = /** @type {!ol.Tile} */ (cache.get(tileCoordKey));
}
@@ -258,7 +259,7 @@ ol.source.TileImage.prototype.getTile = function(z, x, y, pixelRatio, projection
var targetTileGrid = this.getTileGridForProjection(projection);
var wrappedTileCoord =
this.getTileCoordForTileUrlFunction(tileCoord, projection);
var newTile = new ol.reproj.Tile(
var newTile = new _ol_reproj_Tile_(
sourceProjection, sourceTileGrid,
projection, targetTileGrid,
tileCoord, wrappedTileCoord, this.getTilePixelRatio(pixelRatio),
@@ -291,9 +292,9 @@ ol.source.TileImage.prototype.getTile = function(z, x, y, pixelRatio, projection
* @return {!ol.Tile} Tile.
* @protected
*/
ol.source.TileImage.prototype.getTileInternal = function(z, x, y, pixelRatio, projection) {
_ol_source_TileImage_.prototype.getTileInternal = function(z, x, y, pixelRatio, projection) {
var tile = null;
var tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y);
var tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y);
var key = this.getKey();
if (!this.tileCache.containsKey(tileCoordKey)) {
tile = this.createTile_(z, x, y, pixelRatio, projection, key);
@@ -308,7 +309,7 @@ ol.source.TileImage.prototype.getTileInternal = function(z, x, y, pixelRatio, pr
tile = this.createTile_(z, x, y, pixelRatio, projection, key);
//make the new tile the head of the list,
if (interimTile.getState() == ol.TileState.IDLE) {
if (interimTile.getState() == _ol_TileState_.IDLE) {
//the old tile hasn't begun loading yet, and is now outdated, so we can simply discard it
tile.interimTile = interimTile.interimTile;
} else {
@@ -327,8 +328,8 @@ ol.source.TileImage.prototype.getTileInternal = function(z, x, y, pixelRatio, pr
* @param {boolean} render Render the edges.
* @api
*/
ol.source.TileImage.prototype.setRenderReprojectionEdges = function(render) {
if (!ol.ENABLE_RASTER_REPROJECTION ||
_ol_source_TileImage_.prototype.setRenderReprojectionEdges = function(render) {
if (!_ol_.ENABLE_RASTER_REPROJECTION ||
this.renderReprojectionEdges_ == render) {
return;
}
@@ -352,11 +353,11 @@ ol.source.TileImage.prototype.setRenderReprojectionEdges = function(render) {
* @param {ol.tilegrid.TileGrid} tilegrid Tile grid to use for the projection.
* @api
*/
ol.source.TileImage.prototype.setTileGridForProjection = function(projection, tilegrid) {
if (ol.ENABLE_RASTER_REPROJECTION) {
var proj = ol.proj.get(projection);
_ol_source_TileImage_.prototype.setTileGridForProjection = function(projection, tilegrid) {
if (_ol_.ENABLE_RASTER_REPROJECTION) {
var proj = _ol_proj_.get(projection);
if (proj) {
var projKey = ol.getUid(proj).toString();
var projKey = _ol_.getUid(proj).toString();
if (!(projKey in this.tileGridForProjection)) {
this.tileGridForProjection[projKey] = tilegrid;
}
@@ -369,6 +370,7 @@ ol.source.TileImage.prototype.setTileGridForProjection = function(projection, ti
* @param {ol.ImageTile} imageTile Image tile.
* @param {string} src Source.
*/
ol.source.TileImage.defaultTileLoadFunction = function(imageTile, src) {
_ol_source_TileImage_.defaultTileLoadFunction = function(imageTile, src) {
imageTile.getImage().src = src;
};
export default _ol_source_TileImage_;

View File

@@ -1,21 +1,21 @@
/**
* @module ol/source/TileJSON
*/
// FIXME check order of async callbacks
/**
* @see http://mapbox.com/developers/api/
*/
goog.provide('ol.source.TileJSON');
goog.require('ol');
goog.require('ol.TileUrlFunction');
goog.require('ol.asserts');
goog.require('ol.extent');
goog.require('ol.net');
goog.require('ol.proj');
goog.require('ol.source.State');
goog.require('ol.source.TileImage');
goog.require('ol.tilegrid');
import _ol_ from '../index.js';
import _ol_TileUrlFunction_ from '../TileUrlFunction.js';
import _ol_asserts_ from '../asserts.js';
import _ol_extent_ from '../extent.js';
import _ol_net_ from '../net.js';
import _ol_proj_ from '../proj.js';
import _ol_source_State_ from '../source/State.js';
import _ol_source_TileImage_ from '../source/TileImage.js';
import _ol_tilegrid_ from '../tilegrid.js';
/**
* @classdesc
@@ -26,7 +26,7 @@ goog.require('ol.tilegrid');
* @param {olx.source.TileJSONOptions} options TileJSON options.
* @api
*/
ol.source.TileJSON = function(options) {
var _ol_source_TileJSON_ = function(options) {
/**
* @type {TileJSON}
@@ -34,13 +34,13 @@ ol.source.TileJSON = function(options) {
*/
this.tileJSON_ = null;
ol.source.TileImage.call(this, {
_ol_source_TileImage_.call(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,
crossOrigin: options.crossOrigin,
projection: ol.proj.get('EPSG:3857'),
projection: _ol_proj_.get('EPSG:3857'),
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
state: ol.source.State.LOADING,
state: _ol_source_State_.LOADING,
tileLoadFunction: options.tileLoadFunction,
wrapX: options.wrapX !== undefined ? options.wrapX : true,
transition: options.transition
@@ -48,7 +48,7 @@ ol.source.TileJSON = function(options) {
if (options.url) {
if (options.jsonp) {
ol.net.jsonp(options.url, this.handleTileJSONResponse.bind(this),
_ol_net_.jsonp(options.url, this.handleTileJSONResponse.bind(this),
this.handleTileJSONError.bind(this));
} else {
var client = new XMLHttpRequest();
@@ -60,18 +60,19 @@ ol.source.TileJSON = function(options) {
} else if (options.tileJSON) {
this.handleTileJSONResponse(options.tileJSON);
} else {
ol.asserts.assert(false, 51); // Either `url` or `tileJSON` options must be provided
_ol_asserts_.assert(false, 51); // Either `url` or `tileJSON` options must be provided
}
};
ol.inherits(ol.source.TileJSON, ol.source.TileImage);
_ol_.inherits(_ol_source_TileJSON_, _ol_source_TileImage_);
/**
* @private
* @param {Event} event The load event.
*/
ol.source.TileJSON.prototype.onXHRLoad_ = function(event) {
_ol_source_TileJSON_.prototype.onXHRLoad_ = function(event) {
var client = /** @type {XMLHttpRequest} */ (event.target);
// status will be 0 for file:// urls
if (!client.status || client.status >= 200 && client.status < 300) {
@@ -93,7 +94,7 @@ ol.source.TileJSON.prototype.onXHRLoad_ = function(event) {
* @private
* @param {Event} event The error event.
*/
ol.source.TileJSON.prototype.onXHRError_ = function(event) {
_ol_source_TileJSON_.prototype.onXHRError_ = function(event) {
this.handleTileJSONError();
};
@@ -102,7 +103,7 @@ ol.source.TileJSON.prototype.onXHRError_ = function(event) {
* @return {TileJSON} The tilejson object.
* @api
*/
ol.source.TileJSON.prototype.getTileJSON = function() {
_ol_source_TileJSON_.prototype.getTileJSON = function() {
return this.tileJSON_;
};
@@ -111,36 +112,36 @@ ol.source.TileJSON.prototype.getTileJSON = function() {
* @protected
* @param {TileJSON} tileJSON Tile JSON.
*/
ol.source.TileJSON.prototype.handleTileJSONResponse = function(tileJSON) {
_ol_source_TileJSON_.prototype.handleTileJSONResponse = function(tileJSON) {
var epsg4326Projection = ol.proj.get('EPSG:4326');
var epsg4326Projection = _ol_proj_.get('EPSG:4326');
var sourceProjection = this.getProjection();
var extent;
if (tileJSON.bounds !== undefined) {
var transform = ol.proj.getTransformFromProjections(
var transform = _ol_proj_.getTransformFromProjections(
epsg4326Projection, sourceProjection);
extent = ol.extent.applyTransform(tileJSON.bounds, transform);
extent = _ol_extent_.applyTransform(tileJSON.bounds, transform);
}
var minZoom = tileJSON.minzoom || 0;
var maxZoom = tileJSON.maxzoom || 22;
var tileGrid = ol.tilegrid.createXYZ({
extent: ol.tilegrid.extentFromProjection(sourceProjection),
var tileGrid = _ol_tilegrid_.createXYZ({
extent: _ol_tilegrid_.extentFromProjection(sourceProjection),
maxZoom: maxZoom,
minZoom: minZoom
});
this.tileGrid = tileGrid;
this.tileUrlFunction =
ol.TileUrlFunction.createFromTemplates(tileJSON.tiles, tileGrid);
_ol_TileUrlFunction_.createFromTemplates(tileJSON.tiles, tileGrid);
if (tileJSON.attribution !== undefined && !this.getAttributions2()) {
var attributionExtent = extent !== undefined ?
extent : epsg4326Projection.getExtent();
this.setAttributions(function(frameState) {
if (ol.extent.intersects(attributionExtent, frameState.extent)) {
if (_ol_extent_.intersects(attributionExtent, frameState.extent)) {
return [tileJSON.attribution];
}
return null;
@@ -148,7 +149,7 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function(tileJSON) {
}
this.tileJSON_ = tileJSON;
this.setState(ol.source.State.READY);
this.setState(_ol_source_State_.READY);
};
@@ -156,6 +157,7 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function(tileJSON) {
/**
* @protected
*/
ol.source.TileJSON.prototype.handleTileJSONError = function() {
this.setState(ol.source.State.ERROR);
_ol_source_TileJSON_.prototype.handleTileJSONError = function() {
this.setState(_ol_source_State_.ERROR);
};
export default _ol_source_TileJSON_;

View File

@@ -1,20 +1,20 @@
goog.provide('ol.source.TileUTFGrid');
goog.require('ol');
goog.require('ol.Tile');
goog.require('ol.TileState');
goog.require('ol.TileUrlFunction');
goog.require('ol.asserts');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol.extent');
goog.require('ol.net');
goog.require('ol.proj');
goog.require('ol.source.State');
goog.require('ol.source.Tile');
goog.require('ol.tilecoord');
goog.require('ol.tilegrid');
/**
* @module ol/source/TileUTFGrid
*/
import _ol_ from '../index.js';
import _ol_Tile_ from '../Tile.js';
import _ol_TileState_ from '../TileState.js';
import _ol_TileUrlFunction_ from '../TileUrlFunction.js';
import _ol_asserts_ from '../asserts.js';
import _ol_events_ from '../events.js';
import _ol_events_EventType_ from '../events/EventType.js';
import _ol_extent_ from '../extent.js';
import _ol_net_ from '../net.js';
import _ol_proj_ from '../proj.js';
import _ol_source_State_ from '../source/State.js';
import _ol_source_Tile_ from '../source/Tile.js';
import _ol_tilecoord_ from '../tilecoord.js';
import _ol_tilegrid_ from '../tilegrid.js';
/**
* @classdesc
@@ -25,10 +25,10 @@ goog.require('ol.tilegrid');
* @param {olx.source.TileUTFGridOptions} options Source options.
* @api
*/
ol.source.TileUTFGrid = function(options) {
ol.source.Tile.call(this, {
projection: ol.proj.get('EPSG:3857'),
state: ol.source.State.LOADING
var _ol_source_TileUTFGrid_ = function(options) {
_ol_source_Tile_.call(this, {
projection: _ol_proj_.get('EPSG:3857'),
state: _ol_source_State_.LOADING
});
/**
@@ -42,7 +42,7 @@ ol.source.TileUTFGrid = function(options) {
* @private
* @type {!ol.TileUrlFunctionType}
*/
this.tileUrlFunction_ = ol.TileUrlFunction.nullTileUrlFunction;
this.tileUrlFunction_ = _ol_TileUrlFunction_.nullTileUrlFunction;
/**
* @private
@@ -58,7 +58,7 @@ ol.source.TileUTFGrid = function(options) {
if (options.url) {
if (this.jsonp_) {
ol.net.jsonp(options.url, this.handleTileJSONResponse.bind(this),
_ol_net_.jsonp(options.url, this.handleTileJSONResponse.bind(this),
this.handleTileJSONError.bind(this));
} else {
var client = new XMLHttpRequest();
@@ -70,17 +70,18 @@ ol.source.TileUTFGrid = function(options) {
} else if (options.tileJSON) {
this.handleTileJSONResponse(options.tileJSON);
} else {
ol.asserts.assert(false, 51); // Either `url` or `tileJSON` options must be provided
_ol_asserts_.assert(false, 51); // Either `url` or `tileJSON` options must be provided
}
};
ol.inherits(ol.source.TileUTFGrid, ol.source.Tile);
_ol_.inherits(_ol_source_TileUTFGrid_, _ol_source_Tile_);
/**
* @private
* @param {Event} event The load event.
*/
ol.source.TileUTFGrid.prototype.onXHRLoad_ = function(event) {
_ol_source_TileUTFGrid_.prototype.onXHRLoad_ = function(event) {
var client = /** @type {XMLHttpRequest} */ (event.target);
// status will be 0 for file:// urls
if (!client.status || client.status >= 200 && client.status < 300) {
@@ -102,7 +103,7 @@ ol.source.TileUTFGrid.prototype.onXHRLoad_ = function(event) {
* @private
* @param {Event} event The error event.
*/
ol.source.TileUTFGrid.prototype.onXHRError_ = function(event) {
_ol_source_TileUTFGrid_.prototype.onXHRError_ = function(event) {
this.handleTileJSONError();
};
@@ -112,7 +113,7 @@ ol.source.TileUTFGrid.prototype.onXHRError_ = function(event) {
* @return {string|undefined} The template from TileJSON.
* @api
*/
ol.source.TileUTFGrid.prototype.getTemplate = function() {
_ol_source_TileUTFGrid_.prototype.getTemplate = function() {
return this.template_;
};
@@ -130,7 +131,7 @@ ol.source.TileUTFGrid.prototype.getTemplate = function() {
* @template T
* @api
*/
ol.source.TileUTFGrid.prototype.forDataAtCoordinateAndResolution = function(
_ol_source_TileUTFGrid_.prototype.forDataAtCoordinateAndResolution = function(
coordinate, resolution, callback, opt_this, opt_request) {
if (this.tileGrid) {
var tileCoord = this.tileGrid.getTileCoordForCoordAndResolution(
@@ -153,8 +154,8 @@ ol.source.TileUTFGrid.prototype.forDataAtCoordinateAndResolution = function(
/**
* @protected
*/
ol.source.TileUTFGrid.prototype.handleTileJSONError = function() {
this.setState(ol.source.State.ERROR);
_ol_source_TileUTFGrid_.prototype.handleTileJSONError = function() {
this.setState(_ol_source_State_.ERROR);
};
@@ -163,22 +164,22 @@ ol.source.TileUTFGrid.prototype.handleTileJSONError = function() {
* @protected
* @param {TileJSON} tileJSON Tile JSON.
*/
ol.source.TileUTFGrid.prototype.handleTileJSONResponse = function(tileJSON) {
_ol_source_TileUTFGrid_.prototype.handleTileJSONResponse = function(tileJSON) {
var epsg4326Projection = ol.proj.get('EPSG:4326');
var epsg4326Projection = _ol_proj_.get('EPSG:4326');
var sourceProjection = this.getProjection();
var extent;
if (tileJSON.bounds !== undefined) {
var transform = ol.proj.getTransformFromProjections(
var transform = _ol_proj_.getTransformFromProjections(
epsg4326Projection, sourceProjection);
extent = ol.extent.applyTransform(tileJSON.bounds, transform);
extent = _ol_extent_.applyTransform(tileJSON.bounds, transform);
}
var minZoom = tileJSON.minzoom || 0;
var maxZoom = tileJSON.maxzoom || 22;
var tileGrid = ol.tilegrid.createXYZ({
extent: ol.tilegrid.extentFromProjection(sourceProjection),
var tileGrid = _ol_tilegrid_.createXYZ({
extent: _ol_tilegrid_.extentFromProjection(sourceProjection),
maxZoom: maxZoom,
minZoom: minZoom
});
@@ -188,26 +189,26 @@ ol.source.TileUTFGrid.prototype.handleTileJSONResponse = function(tileJSON) {
var grids = tileJSON.grids;
if (!grids) {
this.setState(ol.source.State.ERROR);
this.setState(_ol_source_State_.ERROR);
return;
}
this.tileUrlFunction_ =
ol.TileUrlFunction.createFromTemplates(grids, tileGrid);
_ol_TileUrlFunction_.createFromTemplates(grids, tileGrid);
if (tileJSON.attribution !== undefined) {
var attributionExtent = extent !== undefined ?
extent : epsg4326Projection.getExtent();
this.setAttributions(function(frameState) {
if (ol.extent.intersects(attributionExtent, frameState.extent)) {
if (_ol_extent_.intersects(attributionExtent, frameState.extent)) {
return [tileJSON.attribution];
}
return null;
});
}
this.setState(ol.source.State.READY);
this.setState(_ol_source_State_.READY);
};
@@ -215,8 +216,8 @@ ol.source.TileUTFGrid.prototype.handleTileJSONResponse = function(tileJSON) {
/**
* @inheritDoc
*/
ol.source.TileUTFGrid.prototype.getTile = function(z, x, y, pixelRatio, projection) {
var tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y);
_ol_source_TileUTFGrid_.prototype.getTile = function(z, x, y, pixelRatio, projection) {
var tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y);
if (this.tileCache.containsKey(tileCoordKey)) {
return /** @type {!ol.Tile} */ (this.tileCache.get(tileCoordKey));
} else {
@@ -224,9 +225,9 @@ ol.source.TileUTFGrid.prototype.getTile = function(z, x, y, pixelRatio, projecti
var urlTileCoord =
this.getTileCoordForTileUrlFunction(tileCoord, projection);
var tileUrl = this.tileUrlFunction_(urlTileCoord, pixelRatio, projection);
var tile = new ol.source.TileUTFGrid.Tile_(
var tile = new _ol_source_TileUTFGrid_.Tile_(
tileCoord,
tileUrl !== undefined ? ol.TileState.IDLE : ol.TileState.EMPTY,
tileUrl !== undefined ? _ol_TileState_.IDLE : _ol_TileState_.EMPTY,
tileUrl !== undefined ? tileUrl : '',
this.tileGrid.getTileCoordExtent(tileCoord),
this.preemptive_,
@@ -240,8 +241,8 @@ ol.source.TileUTFGrid.prototype.getTile = function(z, x, y, pixelRatio, projecti
/**
* @inheritDoc
*/
ol.source.TileUTFGrid.prototype.useTile = function(z, x, y) {
var tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y);
_ol_source_TileUTFGrid_.prototype.useTile = function(z, x, y) {
var tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y);
if (this.tileCache.containsKey(tileCoordKey)) {
this.tileCache.get(tileCoordKey);
}
@@ -259,9 +260,9 @@ ol.source.TileUTFGrid.prototype.useTile = function(z, x, y) {
* @param {boolean} jsonp Load the tile as a script.
* @private
*/
ol.source.TileUTFGrid.Tile_ = function(tileCoord, state, src, extent, preemptive, jsonp) {
_ol_source_TileUTFGrid_.Tile_ = function(tileCoord, state, src, extent, preemptive, jsonp) {
ol.Tile.call(this, tileCoord, state);
_ol_Tile_.call(this, tileCoord, state);
/**
* @private
@@ -307,14 +308,14 @@ ol.source.TileUTFGrid.Tile_ = function(tileCoord, state, src, extent, preemptive
this.jsonp_ = jsonp;
};
ol.inherits(ol.source.TileUTFGrid.Tile_, ol.Tile);
_ol_.inherits(_ol_source_TileUTFGrid_.Tile_, _ol_Tile_);
/**
* Get the image element for this tile.
* @return {Image} Image.
*/
ol.source.TileUTFGrid.Tile_.prototype.getImage = function() {
_ol_source_TileUTFGrid_.Tile_.prototype.getImage = function() {
return null;
};
@@ -324,7 +325,7 @@ ol.source.TileUTFGrid.Tile_.prototype.getImage = function() {
* @param {ol.Coordinate} coordinate Coordinate.
* @return {*} The data.
*/
ol.source.TileUTFGrid.Tile_.prototype.getData = function(coordinate) {
_ol_source_TileUTFGrid_.Tile_.prototype.getData = function(coordinate) {
if (!this.grid_ || !this.keys_) {
return null;
}
@@ -371,9 +372,9 @@ ol.source.TileUTFGrid.Tile_.prototype.getData = function(coordinate) {
* The tile data is requested if not yet loaded.
* @template T
*/
ol.source.TileUTFGrid.Tile_.prototype.forDataAtCoordinate = function(coordinate, callback, opt_this, opt_request) {
if (this.state == ol.TileState.IDLE && opt_request === true) {
ol.events.listenOnce(this, ol.events.EventType.CHANGE, function(e) {
_ol_source_TileUTFGrid_.Tile_.prototype.forDataAtCoordinate = function(coordinate, callback, opt_this, opt_request) {
if (this.state == _ol_TileState_.IDLE && opt_request === true) {
_ol_events_.listenOnce(this, _ol_events_EventType_.CHANGE, function(e) {
callback.call(opt_this, this.getData(coordinate));
}, this);
this.loadInternal_();
@@ -392,7 +393,7 @@ ol.source.TileUTFGrid.Tile_.prototype.forDataAtCoordinate = function(coordinate,
/**
* @inheritDoc
*/
ol.source.TileUTFGrid.Tile_.prototype.getKey = function() {
_ol_source_TileUTFGrid_.Tile_.prototype.getKey = function() {
return this.src_;
};
@@ -400,8 +401,8 @@ ol.source.TileUTFGrid.Tile_.prototype.getKey = function() {
/**
* @private
*/
ol.source.TileUTFGrid.Tile_.prototype.handleError_ = function() {
this.state = ol.TileState.ERROR;
_ol_source_TileUTFGrid_.Tile_.prototype.handleError_ = function() {
this.state = _ol_TileState_.ERROR;
this.changed();
};
@@ -410,12 +411,12 @@ ol.source.TileUTFGrid.Tile_.prototype.handleError_ = function() {
* @param {!UTFGridJSON} json UTFGrid data.
* @private
*/
ol.source.TileUTFGrid.Tile_.prototype.handleLoad_ = function(json) {
_ol_source_TileUTFGrid_.Tile_.prototype.handleLoad_ = function(json) {
this.grid_ = json.grid;
this.keys_ = json.keys;
this.data_ = json.data;
this.state = ol.TileState.EMPTY;
this.state = _ol_TileState_.EMPTY;
this.changed();
};
@@ -423,11 +424,11 @@ ol.source.TileUTFGrid.Tile_.prototype.handleLoad_ = function(json) {
/**
* @private
*/
ol.source.TileUTFGrid.Tile_.prototype.loadInternal_ = function() {
if (this.state == ol.TileState.IDLE) {
this.state = ol.TileState.LOADING;
_ol_source_TileUTFGrid_.Tile_.prototype.loadInternal_ = function() {
if (this.state == _ol_TileState_.IDLE) {
this.state = _ol_TileState_.LOADING;
if (this.jsonp_) {
ol.net.jsonp(this.src_, this.handleLoad_.bind(this),
_ol_net_.jsonp(this.src_, this.handleLoad_.bind(this),
this.handleError_.bind(this));
} else {
var client = new XMLHttpRequest();
@@ -444,7 +445,7 @@ ol.source.TileUTFGrid.Tile_.prototype.loadInternal_ = function() {
* @private
* @param {Event} event The load event.
*/
ol.source.TileUTFGrid.Tile_.prototype.onXHRLoad_ = function(event) {
_ol_source_TileUTFGrid_.Tile_.prototype.onXHRLoad_ = function(event) {
var client = /** @type {XMLHttpRequest} */ (event.target);
// status will be 0 for file:// urls
if (!client.status || client.status >= 200 && client.status < 300) {
@@ -466,7 +467,7 @@ ol.source.TileUTFGrid.Tile_.prototype.onXHRLoad_ = function(event) {
* @private
* @param {Event} event The error event.
*/
ol.source.TileUTFGrid.Tile_.prototype.onXHRError_ = function(event) {
_ol_source_TileUTFGrid_.Tile_.prototype.onXHRError_ = function(event) {
this.handleError_();
};
@@ -474,8 +475,9 @@ ol.source.TileUTFGrid.Tile_.prototype.onXHRError_ = function(event) {
/**
* @override
*/
ol.source.TileUTFGrid.Tile_.prototype.load = function() {
_ol_source_TileUTFGrid_.Tile_.prototype.load = function() {
if (this.preemptive_) {
this.loadInternal_();
}
};
export default _ol_source_TileUTFGrid_;

View File

@@ -1,22 +1,23 @@
/**
* @module ol/source/TileWMS
*/
// FIXME add minZoom support
// FIXME add date line wrap (tile coord transform)
// FIXME cannot be shared between maps with different projections
goog.provide('ol.source.TileWMS');
goog.require('ol');
goog.require('ol.asserts');
goog.require('ol.extent');
goog.require('ol.obj');
goog.require('ol.math');
goog.require('ol.proj');
goog.require('ol.reproj');
goog.require('ol.size');
goog.require('ol.source.TileImage');
goog.require('ol.source.WMSServerType');
goog.require('ol.tilecoord');
goog.require('ol.string');
goog.require('ol.uri');
import _ol_ from '../index.js';
import _ol_asserts_ from '../asserts.js';
import _ol_extent_ from '../extent.js';
import _ol_obj_ from '../obj.js';
import _ol_math_ from '../math.js';
import _ol_proj_ from '../proj.js';
import _ol_reproj_ from '../reproj.js';
import _ol_size_ from '../size.js';
import _ol_source_TileImage_ from '../source/TileImage.js';
import _ol_source_WMSServerType_ from '../source/WMSServerType.js';
import _ol_tilecoord_ from '../tilecoord.js';
import _ol_string_ from '../string.js';
import _ol_uri_ from '../uri.js';
/**
* @classdesc
@@ -27,7 +28,7 @@ goog.require('ol.uri');
* @param {olx.source.TileWMSOptions=} opt_options Tile WMS options.
* @api
*/
ol.source.TileWMS = function(opt_options) {
var _ol_source_TileWMS_ = function(opt_options) {
var options = opt_options || {};
@@ -35,7 +36,7 @@ ol.source.TileWMS = function(opt_options) {
var transparent = 'TRANSPARENT' in params ? params['TRANSPARENT'] : true;
ol.source.TileImage.call(this, {
_ol_source_TileImage_.call(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,
crossOrigin: options.crossOrigin,
@@ -86,13 +87,14 @@ ol.source.TileWMS = function(opt_options) {
* @private
* @type {ol.Extent}
*/
this.tmpExtent_ = ol.extent.createEmpty();
this.tmpExtent_ = _ol_extent_.createEmpty();
this.updateV13_();
this.setKey(this.getKeyForParams_());
};
ol.inherits(ol.source.TileWMS, ol.source.TileImage);
_ol_.inherits(_ol_source_TileWMS_, _ol_source_TileImage_);
/**
@@ -109,8 +111,8 @@ ol.inherits(ol.source.TileWMS, ol.source.TileImage);
* @return {string|undefined} GetFeatureInfo URL.
* @api
*/
ol.source.TileWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projection, params) {
var projectionObj = ol.proj.get(projection);
_ol_source_TileWMS_.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projection, params) {
var projectionObj = _ol_proj_.get(projection);
var sourceProjectionObj = this.getProjection();
var tileGrid = this.getTileGrid();
@@ -126,30 +128,30 @@ ol.source.TileWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resoluti
var tileResolution = tileGrid.getResolution(tileCoord[0]);
var tileExtent = tileGrid.getTileCoordExtent(tileCoord, this.tmpExtent_);
var tileSize = ol.size.toSize(tileGrid.getTileSize(tileCoord[0]), this.tmpSize);
var tileSize = _ol_size_.toSize(tileGrid.getTileSize(tileCoord[0]), this.tmpSize);
var gutter = this.gutter_;
if (gutter !== 0) {
tileSize = ol.size.buffer(tileSize, gutter, this.tmpSize);
tileExtent = ol.extent.buffer(tileExtent, tileResolution * gutter, tileExtent);
tileSize = _ol_size_.buffer(tileSize, gutter, this.tmpSize);
tileExtent = _ol_extent_.buffer(tileExtent, tileResolution * gutter, tileExtent);
}
if (sourceProjectionObj && sourceProjectionObj !== projectionObj) {
tileResolution = ol.reproj.calculateSourceResolution(sourceProjectionObj, projectionObj, coordinate, tileResolution);
tileExtent = ol.proj.transformExtent(tileExtent, projectionObj, sourceProjectionObj);
coordinate = ol.proj.transform(coordinate, projectionObj, sourceProjectionObj);
tileResolution = _ol_reproj_.calculateSourceResolution(sourceProjectionObj, projectionObj, coordinate, tileResolution);
tileExtent = _ol_proj_.transformExtent(tileExtent, projectionObj, sourceProjectionObj);
coordinate = _ol_proj_.transform(coordinate, projectionObj, sourceProjectionObj);
}
var baseParams = {
'SERVICE': 'WMS',
'VERSION': ol.DEFAULT_WMS_VERSION,
'VERSION': _ol_.DEFAULT_WMS_VERSION,
'REQUEST': 'GetFeatureInfo',
'FORMAT': 'image/png',
'TRANSPARENT': true,
'QUERY_LAYERS': this.params_['LAYERS']
};
ol.obj.assign(baseParams, this.params_, params);
_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);
@@ -165,7 +167,7 @@ ol.source.TileWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resoluti
/**
* @inheritDoc
*/
ol.source.TileWMS.prototype.getGutterInternal = function() {
_ol_source_TileWMS_.prototype.getGutterInternal = function() {
return this.gutter_;
};
@@ -176,7 +178,7 @@ ol.source.TileWMS.prototype.getGutterInternal = function() {
* @return {Object} Params.
* @api
*/
ol.source.TileWMS.prototype.getParams = function() {
_ol_source_TileWMS_.prototype.getParams = function() {
return this.params_;
};
@@ -191,7 +193,7 @@ ol.source.TileWMS.prototype.getParams = function() {
* @return {string|undefined} Request URL.
* @private
*/
ol.source.TileWMS.prototype.getRequestUrl_ = function(tileCoord, tileSize, tileExtent,
_ol_source_TileWMS_.prototype.getRequestUrl_ = function(tileCoord, tileSize, tileExtent,
pixelRatio, projection, params) {
var urls = this.urls;
@@ -210,7 +212,7 @@ ol.source.TileWMS.prototype.getRequestUrl_ = function(tileCoord, tileSize, tileE
if (pixelRatio != 1) {
switch (this.serverType_) {
case ol.source.WMSServerType.GEOSERVER:
case _ol_source_WMSServerType_.GEOSERVER:
var dpi = (90 * pixelRatio + 0.5) | 0;
if ('FORMAT_OPTIONS' in params) {
params['FORMAT_OPTIONS'] += ';dpi:' + dpi;
@@ -218,15 +220,15 @@ ol.source.TileWMS.prototype.getRequestUrl_ = function(tileCoord, tileSize, tileE
params['FORMAT_OPTIONS'] = 'dpi:' + dpi;
}
break;
case ol.source.WMSServerType.MAPSERVER:
case _ol_source_WMSServerType_.MAPSERVER:
params['MAP_RESOLUTION'] = 90 * pixelRatio;
break;
case ol.source.WMSServerType.CARMENTA_SERVER:
case ol.source.WMSServerType.QGIS:
case _ol_source_WMSServerType_.CARMENTA_SERVER:
case _ol_source_WMSServerType_.QGIS:
params['DPI'] = 90 * pixelRatio;
break;
default:
ol.asserts.assert(false, 52); // Unknown `serverType` configured
_ol_asserts_.assert(false, 52); // Unknown `serverType` configured
break;
}
}
@@ -248,17 +250,17 @@ ol.source.TileWMS.prototype.getRequestUrl_ = function(tileCoord, tileSize, tileE
if (urls.length == 1) {
url = urls[0];
} else {
var index = ol.math.modulo(ol.tilecoord.hash(tileCoord), urls.length);
var index = _ol_math_.modulo(_ol_tilecoord_.hash(tileCoord), urls.length);
url = urls[index];
}
return ol.uri.appendParams(url, params);
return _ol_uri_.appendParams(url, params);
};
/**
* @inheritDoc
*/
ol.source.TileWMS.prototype.getTilePixelRatio = function(pixelRatio) {
_ol_source_TileWMS_.prototype.getTilePixelRatio = function(pixelRatio) {
return (!this.hidpi_ || this.serverType_ === undefined) ? 1 :
/** @type {number} */ (pixelRatio);
};
@@ -268,7 +270,7 @@ ol.source.TileWMS.prototype.getTilePixelRatio = function(pixelRatio) {
* @private
* @return {string} The key for the current params.
*/
ol.source.TileWMS.prototype.getKeyForParams_ = function() {
_ol_source_TileWMS_.prototype.getKeyForParams_ = function() {
var i = 0;
var res = [];
for (var key in this.params_) {
@@ -281,7 +283,7 @@ ol.source.TileWMS.prototype.getKeyForParams_ = function() {
/**
* @inheritDoc
*/
ol.source.TileWMS.prototype.fixedTileUrlFunction = function(tileCoord, pixelRatio, projection) {
_ol_source_TileWMS_.prototype.fixedTileUrlFunction = function(tileCoord, pixelRatio, projection) {
var tileGrid = this.getTileGrid();
if (!tileGrid) {
@@ -298,28 +300,28 @@ ol.source.TileWMS.prototype.fixedTileUrlFunction = function(tileCoord, pixelRati
var tileResolution = tileGrid.getResolution(tileCoord[0]);
var tileExtent = tileGrid.getTileCoordExtent(tileCoord, this.tmpExtent_);
var tileSize = ol.size.toSize(
var tileSize = _ol_size_.toSize(
tileGrid.getTileSize(tileCoord[0]), this.tmpSize);
var gutter = this.gutter_;
if (gutter !== 0) {
tileSize = ol.size.buffer(tileSize, gutter, this.tmpSize);
tileExtent = ol.extent.buffer(tileExtent,
tileSize = _ol_size_.buffer(tileSize, gutter, this.tmpSize);
tileExtent = _ol_extent_.buffer(tileExtent,
tileResolution * gutter, tileExtent);
}
if (pixelRatio != 1) {
tileSize = ol.size.scale(tileSize, pixelRatio, this.tmpSize);
tileSize = _ol_size_.scale(tileSize, pixelRatio, this.tmpSize);
}
var baseParams = {
'SERVICE': 'WMS',
'VERSION': ol.DEFAULT_WMS_VERSION,
'VERSION': _ol_.DEFAULT_WMS_VERSION,
'REQUEST': 'GetMap',
'FORMAT': 'image/png',
'TRANSPARENT': true
};
ol.obj.assign(baseParams, this.params_);
_ol_obj_.assign(baseParams, this.params_);
return this.getRequestUrl_(tileCoord, tileSize, tileExtent,
pixelRatio, projection, baseParams);
@@ -330,8 +332,8 @@ ol.source.TileWMS.prototype.fixedTileUrlFunction = function(tileCoord, pixelRati
* @param {Object} params Params.
* @api
*/
ol.source.TileWMS.prototype.updateParams = function(params) {
ol.obj.assign(this.params_, params);
_ol_source_TileWMS_.prototype.updateParams = function(params) {
_ol_obj_.assign(this.params_, params);
this.updateV13_();
this.setKey(this.getKeyForParams_());
};
@@ -340,7 +342,8 @@ ol.source.TileWMS.prototype.updateParams = function(params) {
/**
* @private
*/
ol.source.TileWMS.prototype.updateV13_ = function() {
var version = this.params_['VERSION'] || ol.DEFAULT_WMS_VERSION;
this.v13_ = ol.string.compareVersions(version, '1.3') >= 0;
_ol_source_TileWMS_.prototype.updateV13_ = function() {
var version = this.params_['VERSION'] || _ol_.DEFAULT_WMS_VERSION;
this.v13_ = _ol_string_.compareVersions(version, '1.3') >= 0;
};
export default _ol_source_TileWMS_;

View File

@@ -1,12 +1,12 @@
goog.provide('ol.source.UrlTile');
goog.require('ol');
goog.require('ol.TileState');
goog.require('ol.TileUrlFunction');
goog.require('ol.source.Tile');
goog.require('ol.source.TileEventType');
goog.require('ol.tilecoord');
/**
* @module ol/source/UrlTile
*/
import _ol_ from '../index.js';
import _ol_TileState_ from '../TileState.js';
import _ol_TileUrlFunction_ from '../TileUrlFunction.js';
import _ol_source_Tile_ from '../source/Tile.js';
import _ol_source_TileEventType_ from '../source/TileEventType.js';
import _ol_tilecoord_ from '../tilecoord.js';
/**
* @classdesc
@@ -18,9 +18,9 @@ goog.require('ol.tilecoord');
* @extends {ol.source.Tile}
* @param {ol.SourceUrlTileOptions} options Image tile options.
*/
ol.source.UrlTile = function(options) {
var _ol_source_UrlTile_ = function(options) {
ol.source.Tile.call(this, {
_ol_source_Tile_.call(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,
extent: options.extent,
@@ -46,7 +46,7 @@ ol.source.UrlTile = function(options) {
*/
this.tileUrlFunction = this.fixedTileUrlFunction ?
this.fixedTileUrlFunction.bind(this) :
ol.TileUrlFunction.nullTileUrlFunction;
_ol_TileUrlFunction_.nullTileUrlFunction;
/**
* @protected
@@ -70,21 +70,22 @@ ol.source.UrlTile = function(options) {
this.tileLoadingKeys_ = {};
};
ol.inherits(ol.source.UrlTile, ol.source.Tile);
_ol_.inherits(_ol_source_UrlTile_, _ol_source_Tile_);
/**
* @type {ol.TileUrlFunctionType|undefined}
* @protected
*/
ol.source.UrlTile.prototype.fixedTileUrlFunction;
_ol_source_UrlTile_.prototype.fixedTileUrlFunction;
/**
* Return the tile load function of the source.
* @return {ol.TileLoadFunctionType} TileLoadFunction
* @api
*/
ol.source.UrlTile.prototype.getTileLoadFunction = function() {
_ol_source_UrlTile_.prototype.getTileLoadFunction = function() {
return this.tileLoadFunction;
};
@@ -94,7 +95,7 @@ ol.source.UrlTile.prototype.getTileLoadFunction = function() {
* @return {ol.TileUrlFunctionType} TileUrlFunction
* @api
*/
ol.source.UrlTile.prototype.getTileUrlFunction = function() {
_ol_source_UrlTile_.prototype.getTileUrlFunction = function() {
return this.tileUrlFunction;
};
@@ -106,7 +107,7 @@ ol.source.UrlTile.prototype.getTileUrlFunction = function() {
* @return {!Array.<string>|null} URLs.
* @api
*/
ol.source.UrlTile.prototype.getUrls = function() {
_ol_source_UrlTile_.prototype.getUrls = function() {
return this.urls;
};
@@ -116,22 +117,22 @@ ol.source.UrlTile.prototype.getUrls = function() {
* @param {ol.events.Event} event Event.
* @protected
*/
ol.source.UrlTile.prototype.handleTileChange = function(event) {
_ol_source_UrlTile_.prototype.handleTileChange = function(event) {
var tile = /** @type {ol.Tile} */ (event.target);
var uid = ol.getUid(tile);
var uid = _ol_.getUid(tile);
var tileState = tile.getState();
var type;
if (tileState == ol.TileState.LOADING) {
if (tileState == _ol_TileState_.LOADING) {
this.tileLoadingKeys_[uid] = true;
type = ol.source.TileEventType.TILELOADSTART;
type = _ol_source_TileEventType_.TILELOADSTART;
} else if (uid in this.tileLoadingKeys_) {
delete this.tileLoadingKeys_[uid];
type = tileState == ol.TileState.ERROR ? ol.source.TileEventType.TILELOADERROR :
(tileState == ol.TileState.LOADED || tileState == ol.TileState.ABORT) ?
ol.source.TileEventType.TILELOADEND : undefined;
type = tileState == _ol_TileState_.ERROR ? _ol_source_TileEventType_.TILELOADERROR :
(tileState == _ol_TileState_.LOADED || tileState == _ol_TileState_.ABORT) ?
_ol_source_TileEventType_.TILELOADEND : undefined;
}
if (type != undefined) {
this.dispatchEvent(new ol.source.Tile.Event(type, tile));
this.dispatchEvent(new _ol_source_Tile_.Event(type, tile));
}
};
@@ -141,7 +142,7 @@ ol.source.UrlTile.prototype.handleTileChange = function(event) {
* @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function.
* @api
*/
ol.source.UrlTile.prototype.setTileLoadFunction = function(tileLoadFunction) {
_ol_source_UrlTile_.prototype.setTileLoadFunction = function(tileLoadFunction) {
this.tileCache.clear();
this.tileLoadFunction = tileLoadFunction;
this.changed();
@@ -154,7 +155,7 @@ ol.source.UrlTile.prototype.setTileLoadFunction = function(tileLoadFunction) {
* @param {string=} opt_key Optional new tile key for the source.
* @api
*/
ol.source.UrlTile.prototype.setTileUrlFunction = function(tileUrlFunction, opt_key) {
_ol_source_UrlTile_.prototype.setTileUrlFunction = function(tileUrlFunction, opt_key) {
this.tileUrlFunction = tileUrlFunction;
this.tileCache.pruneExceptNewestZ();
if (typeof opt_key !== 'undefined') {
@@ -170,11 +171,11 @@ ol.source.UrlTile.prototype.setTileUrlFunction = function(tileUrlFunction, opt_k
* @param {string} url URL.
* @api
*/
ol.source.UrlTile.prototype.setUrl = function(url) {
var urls = this.urls = ol.TileUrlFunction.expandUrl(url);
_ol_source_UrlTile_.prototype.setUrl = function(url) {
var urls = this.urls = _ol_TileUrlFunction_.expandUrl(url);
this.setTileUrlFunction(this.fixedTileUrlFunction ?
this.fixedTileUrlFunction.bind(this) :
ol.TileUrlFunction.createFromTemplates(urls, this.tileGrid), url);
_ol_TileUrlFunction_.createFromTemplates(urls, this.tileGrid), url);
};
@@ -183,21 +184,22 @@ ol.source.UrlTile.prototype.setUrl = function(url) {
* @param {Array.<string>} urls URLs.
* @api
*/
ol.source.UrlTile.prototype.setUrls = function(urls) {
_ol_source_UrlTile_.prototype.setUrls = function(urls) {
this.urls = urls;
var key = urls.join('\n');
this.setTileUrlFunction(this.fixedTileUrlFunction ?
this.fixedTileUrlFunction.bind(this) :
ol.TileUrlFunction.createFromTemplates(urls, this.tileGrid), key);
_ol_TileUrlFunction_.createFromTemplates(urls, this.tileGrid), key);
};
/**
* @inheritDoc
*/
ol.source.UrlTile.prototype.useTile = function(z, x, y) {
var tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y);
_ol_source_UrlTile_.prototype.useTile = function(z, x, y) {
var tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y);
if (this.tileCache.containsKey(tileCoordKey)) {
this.tileCache.get(tileCoordKey);
}
};
export default _ol_source_UrlTile_;

View File

@@ -1,27 +1,27 @@
/**
* @module ol/source/Vector
*/
// FIXME bulk feature upload - suppress events
// FIXME make change-detection more refined (notably, geometry hint)
goog.provide('ol.source.Vector');
goog.require('ol');
goog.require('ol.Collection');
goog.require('ol.CollectionEventType');
goog.require('ol.ObjectEventType');
goog.require('ol.array');
goog.require('ol.asserts');
goog.require('ol.events');
goog.require('ol.events.Event');
goog.require('ol.events.EventType');
goog.require('ol.extent');
goog.require('ol.featureloader');
goog.require('ol.functions');
goog.require('ol.loadingstrategy');
goog.require('ol.obj');
goog.require('ol.source.Source');
goog.require('ol.source.State');
goog.require('ol.source.VectorEventType');
goog.require('ol.structs.RBush');
import _ol_ from '../index.js';
import _ol_Collection_ from '../Collection.js';
import _ol_CollectionEventType_ from '../CollectionEventType.js';
import _ol_ObjectEventType_ from '../ObjectEventType.js';
import _ol_array_ from '../array.js';
import _ol_asserts_ from '../asserts.js';
import _ol_events_ from '../events.js';
import _ol_events_Event_ from '../events/Event.js';
import _ol_events_EventType_ from '../events/EventType.js';
import _ol_extent_ from '../extent.js';
import _ol_featureloader_ from '../featureloader.js';
import _ol_functions_ from '../functions.js';
import _ol_loadingstrategy_ from '../loadingstrategy.js';
import _ol_obj_ from '../obj.js';
import _ol_source_Source_ from '../source/Source.js';
import _ol_source_State_ from '../source/State.js';
import _ol_source_VectorEventType_ from '../source/VectorEventType.js';
import _ol_structs_RBush_ from '../structs/RBush.js';
/**
* @classdesc
@@ -35,15 +35,15 @@ goog.require('ol.structs.RBush');
* @param {olx.source.VectorOptions=} opt_options Vector source options.
* @api
*/
ol.source.Vector = function(opt_options) {
var _ol_source_Vector_ = function(opt_options) {
var options = opt_options || {};
ol.source.Source.call(this, {
_ol_source_Source_.call(this, {
attributions: options.attributions,
logo: options.logo,
projection: undefined,
state: ol.source.State.READY,
state: _ol_source_State_.READY,
wrapX: options.wrapX !== undefined ? options.wrapX : true
});
@@ -51,7 +51,7 @@ ol.source.Vector = function(opt_options) {
* @private
* @type {ol.FeatureLoader}
*/
this.loader_ = ol.nullFunction;
this.loader_ = _ol_.nullFunction;
/**
* @private
@@ -74,9 +74,9 @@ ol.source.Vector = function(opt_options) {
if (options.loader !== undefined) {
this.loader_ = options.loader;
} else if (this.url_ !== undefined) {
ol.asserts.assert(this.format_, 7); // `format` must be set when `url` is set
_ol_asserts_.assert(this.format_, 7); // `format` must be set when `url` is set
// create a XHR feature loader for "url" and "format"
this.loader_ = ol.featureloader.xhr(this.url_, /** @type {ol.format.Feature} */ (this.format_));
this.loader_ = _ol_featureloader_.xhr(this.url_, /** @type {ol.format.Feature} */ (this.format_));
}
/**
@@ -84,7 +84,7 @@ ol.source.Vector = function(opt_options) {
* @type {ol.LoadingStrategy}
*/
this.strategy_ = options.strategy !== undefined ? options.strategy :
ol.loadingstrategy.all;
_ol_loadingstrategy_.all;
var useSpatialIndex =
options.useSpatialIndex !== undefined ? options.useSpatialIndex : true;
@@ -93,13 +93,13 @@ ol.source.Vector = function(opt_options) {
* @private
* @type {ol.structs.RBush.<ol.Feature>}
*/
this.featuresRtree_ = useSpatialIndex ? new ol.structs.RBush() : null;
this.featuresRtree_ = useSpatialIndex ? new _ol_structs_RBush_() : null;
/**
* @private
* @type {ol.structs.RBush.<{extent: ol.Extent}>}
*/
this.loadedExtentsRtree_ = new ol.structs.RBush();
this.loadedExtentsRtree_ = new _ol_structs_RBush_();
/**
* @private
@@ -134,14 +134,14 @@ ol.source.Vector = function(opt_options) {
this.featuresCollection_ = null;
var collection, features;
if (options.features instanceof ol.Collection) {
if (options.features instanceof _ol_Collection_) {
collection = options.features;
features = collection.getArray();
} else if (Array.isArray(options.features)) {
features = options.features;
}
if (!useSpatialIndex && collection === undefined) {
collection = new ol.Collection(features);
collection = new _ol_Collection_(features);
}
if (features !== undefined) {
this.addFeaturesInternal(features);
@@ -151,7 +151,8 @@ ol.source.Vector = function(opt_options) {
}
};
ol.inherits(ol.source.Vector, ol.source.Source);
_ol_.inherits(_ol_source_Vector_, _ol_source_Source_);
/**
@@ -163,7 +164,7 @@ ol.inherits(ol.source.Vector, ol.source.Source);
* @param {ol.Feature} feature Feature to add.
* @api
*/
ol.source.Vector.prototype.addFeature = function(feature) {
_ol_source_Vector_.prototype.addFeature = function(feature) {
this.addFeatureInternal(feature);
this.changed();
};
@@ -174,8 +175,8 @@ ol.source.Vector.prototype.addFeature = function(feature) {
* @param {ol.Feature} feature Feature.
* @protected
*/
ol.source.Vector.prototype.addFeatureInternal = function(feature) {
var featureKey = ol.getUid(feature).toString();
_ol_source_Vector_.prototype.addFeatureInternal = function(feature) {
var featureKey = _ol_.getUid(feature).toString();
if (!this.addToIndex_(featureKey, feature)) {
return;
@@ -194,7 +195,7 @@ ol.source.Vector.prototype.addFeatureInternal = function(feature) {
}
this.dispatchEvent(
new ol.source.Vector.Event(ol.source.VectorEventType.ADDFEATURE, feature));
new _ol_source_Vector_.Event(_ol_source_VectorEventType_.ADDFEATURE, feature));
};
@@ -203,11 +204,11 @@ ol.source.Vector.prototype.addFeatureInternal = function(feature) {
* @param {ol.Feature} feature The feature.
* @private
*/
ol.source.Vector.prototype.setupChangeEvents_ = function(featureKey, feature) {
_ol_source_Vector_.prototype.setupChangeEvents_ = function(featureKey, feature) {
this.featureChangeKeys_[featureKey] = [
ol.events.listen(feature, ol.events.EventType.CHANGE,
_ol_events_.listen(feature, _ol_events_EventType_.CHANGE,
this.handleFeatureChange_, this),
ol.events.listen(feature, ol.ObjectEventType.PROPERTYCHANGE,
_ol_events_.listen(feature, _ol_ObjectEventType_.PROPERTYCHANGE,
this.handleFeatureChange_, this)
];
};
@@ -220,7 +221,7 @@ ol.source.Vector.prototype.setupChangeEvents_ = function(featureKey, feature) {
* candidate for insertion into the Rtree.
* @private
*/
ol.source.Vector.prototype.addToIndex_ = function(featureKey, feature) {
_ol_source_Vector_.prototype.addToIndex_ = function(featureKey, feature) {
var valid = true;
var id = feature.getId();
if (id !== undefined) {
@@ -230,7 +231,7 @@ ol.source.Vector.prototype.addToIndex_ = function(featureKey, feature) {
valid = false;
}
} else {
ol.asserts.assert(!(featureKey in this.undefIdIndex_),
_ol_asserts_.assert(!(featureKey in this.undefIdIndex_),
30); // The passed `feature` was already added to the source
this.undefIdIndex_[featureKey] = feature;
}
@@ -243,7 +244,7 @@ ol.source.Vector.prototype.addToIndex_ = function(featureKey, feature) {
* @param {Array.<ol.Feature>} features Features to add.
* @api
*/
ol.source.Vector.prototype.addFeatures = function(features) {
_ol_source_Vector_.prototype.addFeatures = function(features) {
this.addFeaturesInternal(features);
this.changed();
};
@@ -254,7 +255,7 @@ ol.source.Vector.prototype.addFeatures = function(features) {
* @param {Array.<ol.Feature>} features Features.
* @protected
*/
ol.source.Vector.prototype.addFeaturesInternal = function(features) {
_ol_source_Vector_.prototype.addFeaturesInternal = function(features) {
var featureKey, i, length, feature;
var extents = [];
@@ -263,7 +264,7 @@ ol.source.Vector.prototype.addFeaturesInternal = function(features) {
for (i = 0, length = features.length; i < length; i++) {
feature = features[i];
featureKey = ol.getUid(feature).toString();
featureKey = _ol_.getUid(feature).toString();
if (this.addToIndex_(featureKey, feature)) {
newFeatures.push(feature);
}
@@ -271,7 +272,7 @@ ol.source.Vector.prototype.addFeaturesInternal = function(features) {
for (i = 0, length = newFeatures.length; i < length; i++) {
feature = newFeatures[i];
featureKey = ol.getUid(feature).toString();
featureKey = _ol_.getUid(feature).toString();
this.setupChangeEvents_(featureKey, feature);
var geometry = feature.getGeometry();
@@ -288,8 +289,8 @@ ol.source.Vector.prototype.addFeaturesInternal = function(features) {
}
for (i = 0, length = newFeatures.length; i < length; i++) {
this.dispatchEvent(new ol.source.Vector.Event(
ol.source.VectorEventType.ADDFEATURE, newFeatures[i]));
this.dispatchEvent(new _ol_source_Vector_.Event(
_ol_source_VectorEventType_.ADDFEATURE, newFeatures[i]));
}
};
@@ -298,9 +299,9 @@ ol.source.Vector.prototype.addFeaturesInternal = function(features) {
* @param {!ol.Collection.<ol.Feature>} collection Collection.
* @private
*/
ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) {
_ol_source_Vector_.prototype.bindFeaturesCollection_ = function(collection) {
var modifyingCollection = false;
ol.events.listen(this, ol.source.VectorEventType.ADDFEATURE,
_ol_events_.listen(this, _ol_source_VectorEventType_.ADDFEATURE,
function(evt) {
if (!modifyingCollection) {
modifyingCollection = true;
@@ -308,7 +309,7 @@ ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) {
modifyingCollection = false;
}
});
ol.events.listen(this, ol.source.VectorEventType.REMOVEFEATURE,
_ol_events_.listen(this, _ol_source_VectorEventType_.REMOVEFEATURE,
function(evt) {
if (!modifyingCollection) {
modifyingCollection = true;
@@ -316,7 +317,7 @@ ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) {
modifyingCollection = false;
}
});
ol.events.listen(collection, ol.CollectionEventType.ADD,
_ol_events_.listen(collection, _ol_CollectionEventType_.ADD,
function(evt) {
if (!modifyingCollection) {
modifyingCollection = true;
@@ -324,7 +325,7 @@ ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) {
modifyingCollection = false;
}
}, this);
ol.events.listen(collection, ol.CollectionEventType.REMOVE,
_ol_events_.listen(collection, _ol_CollectionEventType_.REMOVE,
function(evt) {
if (!modifyingCollection) {
modifyingCollection = true;
@@ -341,11 +342,11 @@ ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) {
* @param {boolean=} opt_fast Skip dispatching of {@link removefeature} events.
* @api
*/
ol.source.Vector.prototype.clear = function(opt_fast) {
_ol_source_Vector_.prototype.clear = function(opt_fast) {
if (opt_fast) {
for (var featureId in this.featureChangeKeys_) {
var keys = this.featureChangeKeys_[featureId];
keys.forEach(ol.events.unlistenByKey);
keys.forEach(_ol_events_.unlistenByKey);
}
if (!this.featuresCollection_) {
this.featureChangeKeys_ = {};
@@ -370,7 +371,7 @@ ol.source.Vector.prototype.clear = function(opt_fast) {
this.loadedExtentsRtree_.clear();
this.nullGeometryFeatures_ = {};
var clearEvent = new ol.source.Vector.Event(ol.source.VectorEventType.CLEAR);
var clearEvent = new _ol_source_Vector_.Event(_ol_source_VectorEventType_.CLEAR);
this.dispatchEvent(clearEvent);
this.changed();
};
@@ -388,7 +389,7 @@ ol.source.Vector.prototype.clear = function(opt_fast) {
* @template T,S
* @api
*/
ol.source.Vector.prototype.forEachFeature = function(callback, opt_this) {
_ol_source_Vector_.prototype.forEachFeature = function(callback, opt_this) {
if (this.featuresRtree_) {
return this.featuresRtree_.forEach(callback, opt_this);
} else if (this.featuresCollection_) {
@@ -410,7 +411,7 @@ ol.source.Vector.prototype.forEachFeature = function(callback, opt_this) {
* @return {S|undefined} The return value from the last call to the callback.
* @template T,S
*/
ol.source.Vector.prototype.forEachFeatureAtCoordinateDirect = function(coordinate, callback, opt_this) {
_ol_source_Vector_.prototype.forEachFeatureAtCoordinateDirect = function(coordinate, callback, opt_this) {
var extent = [coordinate[0], coordinate[1], coordinate[0], coordinate[1]];
return this.forEachFeatureInExtent(extent, function(feature) {
var geometry = feature.getGeometry();
@@ -444,7 +445,7 @@ ol.source.Vector.prototype.forEachFeatureAtCoordinateDirect = function(coordinat
* @template T,S
* @api
*/
ol.source.Vector.prototype.forEachFeatureInExtent = function(extent, callback, opt_this) {
_ol_source_Vector_.prototype.forEachFeatureInExtent = function(extent, callback, opt_this) {
if (this.featuresRtree_) {
return this.featuresRtree_.forEachInExtent(extent, callback, opt_this);
} else if (this.featuresCollection_) {
@@ -470,7 +471,7 @@ ol.source.Vector.prototype.forEachFeatureInExtent = function(extent, callback, o
* @template T,S
* @api
*/
ol.source.Vector.prototype.forEachFeatureIntersectingExtent = function(extent, callback, opt_this) {
_ol_source_Vector_.prototype.forEachFeatureIntersectingExtent = function(extent, callback, opt_this) {
return this.forEachFeatureInExtent(extent,
/**
* @param {ol.Feature} feature Feature.
@@ -496,7 +497,7 @@ ol.source.Vector.prototype.forEachFeatureIntersectingExtent = function(extent, c
* @return {ol.Collection.<ol.Feature>} The collection of features.
* @api
*/
ol.source.Vector.prototype.getFeaturesCollection = function() {
_ol_source_Vector_.prototype.getFeaturesCollection = function() {
return this.featuresCollection_;
};
@@ -506,15 +507,15 @@ ol.source.Vector.prototype.getFeaturesCollection = function() {
* @return {Array.<ol.Feature>} Features.
* @api
*/
ol.source.Vector.prototype.getFeatures = function() {
_ol_source_Vector_.prototype.getFeatures = function() {
var features;
if (this.featuresCollection_) {
features = this.featuresCollection_.getArray();
} else if (this.featuresRtree_) {
features = this.featuresRtree_.getAll();
if (!ol.obj.isEmpty(this.nullGeometryFeatures_)) {
ol.array.extend(
features, ol.obj.getValues(this.nullGeometryFeatures_));
if (!_ol_obj_.isEmpty(this.nullGeometryFeatures_)) {
_ol_array_.extend(
features, _ol_obj_.getValues(this.nullGeometryFeatures_));
}
}
return /** @type {Array.<ol.Feature>} */ (features);
@@ -527,7 +528,7 @@ ol.source.Vector.prototype.getFeatures = function() {
* @return {Array.<ol.Feature>} Features.
* @api
*/
ol.source.Vector.prototype.getFeaturesAtCoordinate = function(coordinate) {
_ol_source_Vector_.prototype.getFeaturesAtCoordinate = function(coordinate) {
var features = [];
this.forEachFeatureAtCoordinateDirect(coordinate, function(feature) {
features.push(feature);
@@ -547,7 +548,7 @@ ol.source.Vector.prototype.getFeaturesAtCoordinate = function(coordinate) {
* @return {Array.<ol.Feature>} Features.
* @api
*/
ol.source.Vector.prototype.getFeaturesInExtent = function(extent) {
_ol_source_Vector_.prototype.getFeaturesInExtent = function(extent) {
return this.featuresRtree_.getInExtent(extent);
};
@@ -564,7 +565,7 @@ ol.source.Vector.prototype.getFeaturesInExtent = function(extent) {
* @return {ol.Feature} Closest feature.
* @api
*/
ol.source.Vector.prototype.getClosestFeatureToCoordinate = function(coordinate, opt_filter) {
_ol_source_Vector_.prototype.getClosestFeatureToCoordinate = function(coordinate, opt_filter) {
// Find the closest feature using branch and bound. We start searching an
// infinite extent, and find the distance from the first feature found. This
// becomes the closest feature. We then compute a smaller extent which any
@@ -578,7 +579,7 @@ ol.source.Vector.prototype.getClosestFeatureToCoordinate = function(coordinate,
var closestPoint = [NaN, NaN];
var minSquaredDistance = Infinity;
var extent = [-Infinity, -Infinity, Infinity, Infinity];
var filter = opt_filter ? opt_filter : ol.functions.TRUE;
var filter = opt_filter ? opt_filter : _ol_functions_.TRUE;
this.featuresRtree_.forEachInExtent(extent,
/**
* @param {ol.Feature} feature Feature.
@@ -617,7 +618,7 @@ ol.source.Vector.prototype.getClosestFeatureToCoordinate = function(coordinate,
* @return {ol.Extent} Extent.
* @api
*/
ol.source.Vector.prototype.getExtent = function(opt_extent) {
_ol_source_Vector_.prototype.getExtent = function(opt_extent) {
return this.featuresRtree_.getExtent(opt_extent);
};
@@ -631,7 +632,7 @@ ol.source.Vector.prototype.getExtent = function(opt_extent) {
* @return {ol.Feature} The feature (or `null` if not found).
* @api
*/
ol.source.Vector.prototype.getFeatureById = function(id) {
_ol_source_Vector_.prototype.getFeatureById = function(id) {
var feature = this.idIndex_[id.toString()];
return feature !== undefined ? feature : null;
};
@@ -643,7 +644,7 @@ ol.source.Vector.prototype.getFeatureById = function(id) {
* @return {ol.format.Feature|undefined} The feature format.
* @api
*/
ol.source.Vector.prototype.getFormat = function() {
_ol_source_Vector_.prototype.getFormat = function() {
return this.format_;
};
@@ -651,7 +652,7 @@ ol.source.Vector.prototype.getFormat = function() {
/**
* @return {boolean} The source can have overlapping geometries.
*/
ol.source.Vector.prototype.getOverlaps = function() {
_ol_source_Vector_.prototype.getOverlaps = function() {
return this.overlaps_;
};
@@ -659,7 +660,7 @@ ol.source.Vector.prototype.getOverlaps = function() {
/**
* @override
*/
ol.source.Vector.prototype.getResolutions = function() {};
_ol_source_Vector_.prototype.getResolutions = function() {};
/**
@@ -668,7 +669,7 @@ ol.source.Vector.prototype.getResolutions = function() {};
* @return {string|ol.FeatureUrlFunction|undefined} The url.
* @api
*/
ol.source.Vector.prototype.getUrl = function() {
_ol_source_Vector_.prototype.getUrl = function() {
return this.url_;
};
@@ -677,9 +678,9 @@ ol.source.Vector.prototype.getUrl = function() {
* @param {ol.events.Event} event Event.
* @private
*/
ol.source.Vector.prototype.handleFeatureChange_ = function(event) {
_ol_source_Vector_.prototype.handleFeatureChange_ = function(event) {
var feature = /** @type {ol.Feature} */ (event.target);
var featureKey = ol.getUid(feature).toString();
var featureKey = _ol_.getUid(feature).toString();
var geometry = feature.getGeometry();
if (!geometry) {
if (!(featureKey in this.nullGeometryFeatures_)) {
@@ -720,17 +721,17 @@ ol.source.Vector.prototype.handleFeatureChange_ = function(event) {
}
}
this.changed();
this.dispatchEvent(new ol.source.Vector.Event(
ol.source.VectorEventType.CHANGEFEATURE, feature));
this.dispatchEvent(new _ol_source_Vector_.Event(
_ol_source_VectorEventType_.CHANGEFEATURE, feature));
};
/**
* @return {boolean} Is empty.
*/
ol.source.Vector.prototype.isEmpty = function() {
_ol_source_Vector_.prototype.isEmpty = function() {
return this.featuresRtree_.isEmpty() &&
ol.obj.isEmpty(this.nullGeometryFeatures_);
_ol_obj_.isEmpty(this.nullGeometryFeatures_);
};
@@ -739,7 +740,7 @@ ol.source.Vector.prototype.isEmpty = function() {
* @param {number} resolution Resolution.
* @param {ol.proj.Projection} projection Projection.
*/
ol.source.Vector.prototype.loadFeatures = function(
_ol_source_Vector_.prototype.loadFeatures = function(
extent, resolution, projection) {
var loadedExtentsRtree = this.loadedExtentsRtree_;
var extentsToLoad = this.strategy_(extent, resolution);
@@ -752,7 +753,7 @@ ol.source.Vector.prototype.loadFeatures = function(
* @return {boolean} Contains.
*/
function(object) {
return ol.extent.containsExtent(object.extent, extentToLoad);
return _ol_extent_.containsExtent(object.extent, extentToLoad);
});
if (!alreadyLoaded) {
this.loader_.call(this, extentToLoad, resolution, projection);
@@ -767,11 +768,11 @@ ol.source.Vector.prototype.loadFeatures = function(
* @param {ol.Extent} extent Extent.
* @api
*/
ol.source.Vector.prototype.removeLoadedExtent = function(extent) {
_ol_source_Vector_.prototype.removeLoadedExtent = function(extent) {
var loadedExtentsRtree = this.loadedExtentsRtree_;
var obj;
loadedExtentsRtree.forEachInExtent(extent, function(object) {
if (ol.extent.equals(object.extent, extent)) {
if (_ol_extent_.equals(object.extent, extent)) {
obj = object;
return true;
}
@@ -789,8 +790,8 @@ ol.source.Vector.prototype.removeLoadedExtent = function(extent) {
* @param {ol.Feature} feature Feature to remove.
* @api
*/
ol.source.Vector.prototype.removeFeature = function(feature) {
var featureKey = ol.getUid(feature).toString();
_ol_source_Vector_.prototype.removeFeature = function(feature) {
var featureKey = _ol_.getUid(feature).toString();
if (featureKey in this.nullGeometryFeatures_) {
delete this.nullGeometryFeatures_[featureKey];
} else {
@@ -808,9 +809,9 @@ ol.source.Vector.prototype.removeFeature = function(feature) {
* @param {ol.Feature} feature Feature.
* @protected
*/
ol.source.Vector.prototype.removeFeatureInternal = function(feature) {
var featureKey = ol.getUid(feature).toString();
this.featureChangeKeys_[featureKey].forEach(ol.events.unlistenByKey);
_ol_source_Vector_.prototype.removeFeatureInternal = function(feature) {
var featureKey = _ol_.getUid(feature).toString();
this.featureChangeKeys_[featureKey].forEach(_ol_events_.unlistenByKey);
delete this.featureChangeKeys_[featureKey];
var id = feature.getId();
if (id !== undefined) {
@@ -818,8 +819,8 @@ ol.source.Vector.prototype.removeFeatureInternal = function(feature) {
} else {
delete this.undefIdIndex_[featureKey];
}
this.dispatchEvent(new ol.source.Vector.Event(
ol.source.VectorEventType.REMOVEFEATURE, feature));
this.dispatchEvent(new _ol_source_Vector_.Event(
_ol_source_VectorEventType_.REMOVEFEATURE, feature));
};
@@ -830,7 +831,7 @@ ol.source.Vector.prototype.removeFeatureInternal = function(feature) {
* @return {boolean} Removed the feature from the index.
* @private
*/
ol.source.Vector.prototype.removeFromIdIndex_ = function(feature) {
_ol_source_Vector_.prototype.removeFromIdIndex_ = function(feature) {
var removed = false;
for (var id in this.idIndex_) {
if (this.idIndex_[id] === feature) {
@@ -849,7 +850,7 @@ ol.source.Vector.prototype.removeFromIdIndex_ = function(feature) {
* @param {ol.FeatureLoader} loader The loader to set.
* @api
*/
ol.source.Vector.prototype.setLoader = function(loader) {
_ol_source_Vector_.prototype.setLoader = function(loader) {
this.loader_ = loader;
};
@@ -865,9 +866,9 @@ ol.source.Vector.prototype.setLoader = function(loader) {
* @param {string} type Type.
* @param {ol.Feature=} opt_feature Feature.
*/
ol.source.Vector.Event = function(type, opt_feature) {
_ol_source_Vector_.Event = function(type, opt_feature) {
ol.events.Event.call(this, type);
_ol_events_Event_.call(this, type);
/**
* The feature being added or removed.
@@ -877,4 +878,5 @@ ol.source.Vector.Event = function(type, opt_feature) {
this.feature = opt_feature;
};
ol.inherits(ol.source.Vector.Event, ol.events.Event);
_ol_.inherits(_ol_source_Vector_.Event, _ol_events_Event_);
export default _ol_source_Vector_;

View File

@@ -1,9 +1,10 @@
goog.provide('ol.source.VectorEventType');
/**
* @module ol/source/VectorEventType
*/
/**
* @enum {string}
*/
ol.source.VectorEventType = {
var _ol_source_VectorEventType_ = {
/**
* Triggered when a feature is added to the source.
* @event ol.source.Vector.Event#addfeature
@@ -33,3 +34,5 @@ ol.source.VectorEventType = {
*/
REMOVEFEATURE: 'removefeature'
};
export default _ol_source_VectorEventType_;

View File

@@ -1,14 +1,14 @@
goog.provide('ol.source.VectorTile');
goog.require('ol');
goog.require('ol.TileState');
goog.require('ol.VectorImageTile');
goog.require('ol.VectorTile');
goog.require('ol.size');
goog.require('ol.source.UrlTile');
goog.require('ol.tilecoord');
goog.require('ol.tilegrid');
/**
* @module ol/source/VectorTile
*/
import _ol_ from '../index.js';
import _ol_TileState_ from '../TileState.js';
import _ol_VectorImageTile_ from '../VectorImageTile.js';
import _ol_VectorTile_ from '../VectorTile.js';
import _ol_size_ from '../size.js';
import _ol_source_UrlTile_ from '../source/UrlTile.js';
import _ol_tilecoord_ from '../tilecoord.js';
import _ol_tilegrid_ from '../tilegrid.js';
/**
* @classdesc
@@ -26,19 +26,19 @@ goog.require('ol.tilegrid');
* @param {olx.source.VectorTileOptions} options Vector tile options.
* @api
*/
ol.source.VectorTile = function(options) {
var _ol_source_VectorTile_ = function(options) {
var projection = options.projection || 'EPSG:3857';
var extent = options.extent || ol.tilegrid.extentFromProjection(projection);
var extent = options.extent || _ol_tilegrid_.extentFromProjection(projection);
var tileGrid = options.tileGrid || ol.tilegrid.createXYZ({
var tileGrid = options.tileGrid || _ol_tilegrid_.createXYZ({
extent: extent,
maxZoom: options.maxZoom || 22,
minZoom: options.minZoom,
tileSize: options.tileSize || 512
});
ol.source.UrlTile.call(this, {
_ol_source_UrlTile_.call(this, {
attributions: options.attributions,
cacheSize: options.cacheSize !== undefined ? options.cacheSize : 128,
extent: extent,
@@ -48,7 +48,7 @@ ol.source.VectorTile = function(options) {
state: options.state,
tileGrid: tileGrid,
tileLoadFunction: options.tileLoadFunction ?
options.tileLoadFunction : ol.VectorImageTile.defaultLoadFunction,
options.tileLoadFunction : _ol_VectorImageTile_.defaultLoadFunction,
tileUrlFunction: options.tileUrlFunction,
url: options.url,
urls: options.urls,
@@ -79,7 +79,7 @@ ol.source.VectorTile = function(options) {
* @type {function(new: ol.VectorTile, ol.TileCoord, ol.TileState, string,
* ol.format.Feature, ol.TileLoadFunctionType)}
*/
this.tileClass = options.tileClass ? options.tileClass : ol.VectorTile;
this.tileClass = options.tileClass ? options.tileClass : _ol_VectorTile_;
/**
* @private
@@ -88,13 +88,14 @@ ol.source.VectorTile = function(options) {
this.tileGrids_ = {};
};
ol.inherits(ol.source.VectorTile, ol.source.UrlTile);
_ol_.inherits(_ol_source_VectorTile_, _ol_source_UrlTile_);
/**
* @return {boolean} The source can have overlapping geometries.
*/
ol.source.VectorTile.prototype.getOverlaps = function() {
_ol_source_VectorTile_.prototype.getOverlaps = function() {
return this.overlaps_;
};
@@ -102,7 +103,7 @@ ol.source.VectorTile.prototype.getOverlaps = function() {
* clear {@link ol.TileCache} and delete all source tiles
* @api
*/
ol.source.VectorTile.prototype.clear = function() {
_ol_source_VectorTile_.prototype.clear = function() {
this.tileCache.clear();
this.sourceTiles_ = {};
};
@@ -110,17 +111,17 @@ ol.source.VectorTile.prototype.clear = function() {
/**
* @inheritDoc
*/
ol.source.VectorTile.prototype.getTile = function(z, x, y, pixelRatio, projection) {
var tileCoordKey = ol.tilecoord.getKeyZXY(z, x, y);
_ol_source_VectorTile_.prototype.getTile = function(z, x, y, pixelRatio, projection) {
var 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 ol.VectorImageTile(
var tile = new _ol_VectorImageTile_(
tileCoord,
urlTileCoord !== null ? ol.TileState.IDLE : ol.TileState.EMPTY,
urlTileCoord !== null ? _ol_TileState_.IDLE : _ol_TileState_.EMPTY,
this.getRevision(),
this.format_, this.tileLoadFunction, urlTileCoord, this.tileUrlFunction,
this.tileGrid, this.getTileGridForProjection(projection),
@@ -137,14 +138,14 @@ ol.source.VectorTile.prototype.getTile = function(z, x, y, pixelRatio, projectio
/**
* @inheritDoc
*/
ol.source.VectorTile.prototype.getTileGridForProjection = function(projection) {
_ol_source_VectorTile_.prototype.getTileGridForProjection = function(projection) {
var code = projection.getCode();
var 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;
tileGrid = this.tileGrids_[code] = ol.tilegrid.createForProjection(projection, undefined,
tileGrid = this.tileGrids_[code] = _ol_tilegrid_.createForProjection(projection, undefined,
sourceTileGrid ? sourceTileGrid.getTileSize(sourceTileGrid.getMinZoom()) : undefined);
}
return tileGrid;
@@ -154,7 +155,7 @@ ol.source.VectorTile.prototype.getTileGridForProjection = function(projection) {
/**
* @inheritDoc
*/
ol.source.VectorTile.prototype.getTilePixelRatio = function(pixelRatio) {
_ol_source_VectorTile_.prototype.getTilePixelRatio = function(pixelRatio) {
return pixelRatio;
};
@@ -162,7 +163,8 @@ ol.source.VectorTile.prototype.getTilePixelRatio = function(pixelRatio) {
/**
* @inheritDoc
*/
ol.source.VectorTile.prototype.getTilePixelSize = function(z, pixelRatio, projection) {
var tileSize = ol.size.toSize(this.getTileGridForProjection(projection).getTileSize(z));
_ol_source_VectorTile_.prototype.getTilePixelSize = function(z, pixelRatio, projection) {
var tileSize = _ol_size_.toSize(this.getTileGridForProjection(projection).getTileSize(z));
return [Math.round(tileSize[0] * pixelRatio), Math.round(tileSize[1] * pixelRatio)];
};
export default _ol_source_VectorTile_;

View File

@@ -1,15 +1,17 @@
goog.provide('ol.source.WMSServerType');
/**
* @module ol/source/WMSServerType
*/
/**
* Available server types: `'carmentaserver'`, `'geoserver'`, `'mapserver'`,
* `'qgis'`. These are servers that have vendor parameters beyond the WMS
* specification that OpenLayers can make use of.
* @enum {string}
*/
ol.source.WMSServerType = {
var _ol_source_WMSServerType_ = {
CARMENTA_SERVER: 'carmentaserver',
GEOSERVER: 'geoserver',
MAPSERVER: 'mapserver',
QGIS: 'qgis'
};
export default _ol_source_WMSServerType_;

View File

@@ -1,16 +1,16 @@
goog.provide('ol.source.WMTS');
goog.require('ol');
goog.require('ol.TileUrlFunction');
goog.require('ol.array');
goog.require('ol.extent');
goog.require('ol.obj');
goog.require('ol.proj');
goog.require('ol.source.TileImage');
goog.require('ol.source.WMTSRequestEncoding');
goog.require('ol.tilegrid.WMTS');
goog.require('ol.uri');
/**
* @module ol/source/WMTS
*/
import _ol_ from '../index.js';
import _ol_TileUrlFunction_ from '../TileUrlFunction.js';
import _ol_array_ from '../array.js';
import _ol_extent_ from '../extent.js';
import _ol_obj_ from '../obj.js';
import _ol_proj_ from '../proj.js';
import _ol_source_TileImage_ from '../source/TileImage.js';
import _ol_source_WMTSRequestEncoding_ from '../source/WMTSRequestEncoding.js';
import _ol_tilegrid_WMTS_ from '../tilegrid/WMTS.js';
import _ol_uri_ from '../uri.js';
/**
* @classdesc
@@ -21,7 +21,7 @@ goog.require('ol.uri');
* @param {olx.source.WMTSOptions} options WMTS options.
* @api
*/
ol.source.WMTS = function(options) {
var _ol_source_WMTS_ = function(options) {
// TODO: add support for TileMatrixLimits
@@ -63,7 +63,7 @@ ol.source.WMTS = function(options) {
var urls = options.urls;
if (urls === undefined && options.url !== undefined) {
urls = ol.TileUrlFunction.expandUrl(options.url);
urls = _ol_TileUrlFunction_.expandUrl(options.url);
}
// FIXME: should we guess this requestEncoding from options.url(s)
@@ -75,7 +75,7 @@ ol.source.WMTS = function(options) {
*/
this.requestEncoding_ = options.requestEncoding !== undefined ?
/** @type {ol.source.WMTSRequestEncoding} */ (options.requestEncoding) :
ol.source.WMTSRequestEncoding.KVP;
_ol_source_WMTSRequestEncoding_.KVP;
var requestEncoding = this.requestEncoding_;
@@ -91,8 +91,8 @@ ol.source.WMTS = function(options) {
'tilematrixset': this.matrixSet_
};
if (requestEncoding == ol.source.WMTSRequestEncoding.KVP) {
ol.obj.assign(context, {
if (requestEncoding == _ol_source_WMTSRequestEncoding_.KVP) {
_ol_obj_.assign(context, {
'Service': 'WMTS',
'Request': 'GetTile',
'Version': this.version_,
@@ -113,8 +113,8 @@ ol.source.WMTS = function(options) {
// order conforms to wmts spec guidance, and so that we can avoid to escape
// special template params
template = (requestEncoding == ol.source.WMTSRequestEncoding.KVP) ?
ol.uri.appendParams(template, context) :
template = (requestEncoding == _ol_source_WMTSRequestEncoding_.KVP) ?
_ol_uri_.appendParams(template, context) :
template.replace(/\{(\w+?)\}/g, function(m, p) {
return (p.toLowerCase() in context) ? context[p.toLowerCase()] : m;
});
@@ -135,10 +135,10 @@ ol.source.WMTS = function(options) {
'TileCol': tileCoord[1],
'TileRow': -tileCoord[2] - 1
};
ol.obj.assign(localContext, dimensions);
_ol_obj_.assign(localContext, dimensions);
var url = template;
if (requestEncoding == ol.source.WMTSRequestEncoding.KVP) {
url = ol.uri.appendParams(url, localContext);
if (requestEncoding == _ol_source_WMTSRequestEncoding_.KVP) {
url = _ol_uri_.appendParams(url, localContext);
} else {
url = url.replace(/\{(\w+?)\}/g, function(m, p) {
return localContext[p];
@@ -146,15 +146,16 @@ ol.source.WMTS = function(options) {
}
return url;
}
});
}
);
};
var tileUrlFunction = (urls && urls.length > 0) ?
ol.TileUrlFunction.createFromTileUrlFunctions(
_ol_TileUrlFunction_.createFromTileUrlFunctions(
urls.map(this.createFromWMTSTemplate_)) :
ol.TileUrlFunction.nullTileUrlFunction;
_ol_TileUrlFunction_.nullTileUrlFunction;
ol.source.TileImage.call(this, {
_ol_source_TileImage_.call(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,
crossOrigin: options.crossOrigin,
@@ -174,19 +175,20 @@ ol.source.WMTS = function(options) {
this.setKey(this.getKeyForDimensions_());
};
ol.inherits(ol.source.WMTS, ol.source.TileImage);
_ol_.inherits(_ol_source_WMTS_, _ol_source_TileImage_);
/**
* Set the URLs to use for requests.
* URLs may contain OCG conform URL Template Variables: {TileMatrix}, {TileRow}, {TileCol}.
* @override
*/
ol.source.WMTS.prototype.setUrls = function(urls) {
_ol_source_WMTS_.prototype.setUrls = function(urls) {
this.urls = urls;
var key = urls.join('\n');
this.setTileUrlFunction(this.fixedTileUrlFunction ?
this.fixedTileUrlFunction.bind(this) :
ol.TileUrlFunction.createFromTileUrlFunctions(urls.map(this.createFromWMTSTemplate_.bind(this))), key);
_ol_TileUrlFunction_.createFromTileUrlFunctions(urls.map(this.createFromWMTSTemplate_.bind(this))), key);
};
/**
@@ -196,7 +198,7 @@ ol.source.WMTS.prototype.setUrls = function(urls) {
* @return {!Object} Dimensions.
* @api
*/
ol.source.WMTS.prototype.getDimensions = function() {
_ol_source_WMTS_.prototype.getDimensions = function() {
return this.dimensions_;
};
@@ -206,7 +208,7 @@ ol.source.WMTS.prototype.getDimensions = function() {
* @return {string} Format.
* @api
*/
ol.source.WMTS.prototype.getFormat = function() {
_ol_source_WMTS_.prototype.getFormat = function() {
return this.format_;
};
@@ -216,7 +218,7 @@ ol.source.WMTS.prototype.getFormat = function() {
* @return {string} Layer.
* @api
*/
ol.source.WMTS.prototype.getLayer = function() {
_ol_source_WMTS_.prototype.getLayer = function() {
return this.layer_;
};
@@ -226,7 +228,7 @@ ol.source.WMTS.prototype.getLayer = function() {
* @return {string} MatrixSet.
* @api
*/
ol.source.WMTS.prototype.getMatrixSet = function() {
_ol_source_WMTS_.prototype.getMatrixSet = function() {
return this.matrixSet_;
};
@@ -236,7 +238,7 @@ ol.source.WMTS.prototype.getMatrixSet = function() {
* @return {ol.source.WMTSRequestEncoding} Request encoding.
* @api
*/
ol.source.WMTS.prototype.getRequestEncoding = function() {
_ol_source_WMTS_.prototype.getRequestEncoding = function() {
return this.requestEncoding_;
};
@@ -246,7 +248,7 @@ ol.source.WMTS.prototype.getRequestEncoding = function() {
* @return {string} Style.
* @api
*/
ol.source.WMTS.prototype.getStyle = function() {
_ol_source_WMTS_.prototype.getStyle = function() {
return this.style_;
};
@@ -256,7 +258,7 @@ ol.source.WMTS.prototype.getStyle = function() {
* @return {string} Version.
* @api
*/
ol.source.WMTS.prototype.getVersion = function() {
_ol_source_WMTS_.prototype.getVersion = function() {
return this.version_;
};
@@ -265,7 +267,7 @@ ol.source.WMTS.prototype.getVersion = function() {
* @private
* @return {string} The key for the current dimensions.
*/
ol.source.WMTS.prototype.getKeyForDimensions_ = function() {
_ol_source_WMTS_.prototype.getKeyForDimensions_ = function() {
var i = 0;
var res = [];
for (var key in this.dimensions_) {
@@ -280,8 +282,8 @@ ol.source.WMTS.prototype.getKeyForDimensions_ = function() {
* @param {Object} dimensions Dimensions.
* @api
*/
ol.source.WMTS.prototype.updateDimensions = function(dimensions) {
ol.obj.assign(this.dimensions_, dimensions);
_ol_source_WMTS_.prototype.updateDimensions = function(dimensions) {
_ol_obj_.assign(this.dimensions_, dimensions);
this.setKey(this.getKeyForDimensions_());
};
@@ -310,9 +312,9 @@ ol.source.WMTS.prototype.updateDimensions = function(dimensions) {
* @return {?olx.source.WMTSOptions} WMTS source options object or `null` if the layer was not found.
* @api
*/
ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
_ol_source_WMTS_.optionsFromCapabilities = function(wmtsCap, config) {
var layers = wmtsCap['Contents']['Layer'];
var l = ol.array.find(layers, function(elt, index, array) {
var l = _ol_array_.find(layers, function(elt, index, array) {
return elt['Identifier'] == config['layer'];
});
if (l === null) {
@@ -322,23 +324,23 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
var idx, matrixSet, matrixLimits;
if (l['TileMatrixSetLink'].length > 1) {
if ('projection' in config) {
idx = ol.array.findIndex(l['TileMatrixSetLink'],
idx = _ol_array_.findIndex(l['TileMatrixSetLink'],
function(elt, index, array) {
var tileMatrixSet = ol.array.find(tileMatrixSets, function(el) {
var tileMatrixSet = _ol_array_.find(tileMatrixSets, function(el) {
return el['Identifier'] == elt['TileMatrixSet'];
});
var supportedCRS = tileMatrixSet['SupportedCRS'];
var proj1 = ol.proj.get(supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
ol.proj.get(supportedCRS);
var proj2 = ol.proj.get(config['projection']);
var proj1 = _ol_proj_.get(supportedCRS.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
_ol_proj_.get(supportedCRS);
var proj2 = _ol_proj_.get(config['projection']);
if (proj1 && proj2) {
return ol.proj.equivalent(proj1, proj2);
return _ol_proj_.equivalent(proj1, proj2);
} else {
return supportedCRS == config['projection'];
}
});
} else {
idx = ol.array.findIndex(l['TileMatrixSetLink'],
idx = _ol_array_.findIndex(l['TileMatrixSetLink'],
function(elt, index, array) {
return elt['TileMatrixSet'] == config['matrixSet'];
});
@@ -358,7 +360,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
if ('format' in config) {
format = config['format'];
}
idx = ol.array.findIndex(l['Style'], function(elt, index, array) {
idx = _ol_array_.findIndex(l['Style'], function(elt, index, array) {
if ('style' in config) {
return elt['Title'] == config['style'];
} else {
@@ -383,20 +385,20 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
}
var matrixSets = wmtsCap['Contents']['TileMatrixSet'];
var matrixSetObj = ol.array.find(matrixSets, function(elt, index, array) {
var matrixSetObj = _ol_array_.find(matrixSets, function(elt, index, array) {
return elt['Identifier'] == matrixSet;
});
var projection;
var code = matrixSetObj['SupportedCRS'];
if (code) {
projection = ol.proj.get(code.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
ol.proj.get(code);
projection = _ol_proj_.get(code.replace(/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, '$1:$3')) ||
_ol_proj_.get(code);
}
if ('projection' in config) {
var projConfig = ol.proj.get(config['projection']);
var projConfig = _ol_proj_.get(config['projection']);
if (projConfig) {
if (!projection || ol.proj.equivalent(projConfig, projection)) {
if (!projection || _ol_proj_.equivalent(projConfig, projection)) {
projection = projConfig;
}
}
@@ -405,22 +407,22 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
var wgs84BoundingBox = l['WGS84BoundingBox'];
var extent, wrapX;
if (wgs84BoundingBox !== undefined) {
var wgs84ProjectionExtent = ol.proj.get('EPSG:4326').getExtent();
var wgs84ProjectionExtent = _ol_proj_.get('EPSG:4326').getExtent();
wrapX = (wgs84BoundingBox[0] == wgs84ProjectionExtent[0] &&
wgs84BoundingBox[2] == wgs84ProjectionExtent[2]);
extent = ol.proj.transformExtent(
extent = _ol_proj_.transformExtent(
wgs84BoundingBox, 'EPSG:4326', projection);
var 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.
if (!ol.extent.containsExtent(projectionExtent, extent)) {
if (!_ol_extent_.containsExtent(projectionExtent, extent)) {
extent = undefined;
}
}
}
var tileGrid = ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet(
var tileGrid = _ol_tilegrid_WMTS_.createFromCapabilitiesMatrixSet(
matrixSetObj, extent, matrixLimits);
/** @type {!Array.<string>} */
@@ -433,7 +435,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
for (var i = 0, ii = gets.length; i < ii; ++i) {
if (gets[i]['Constraint']) {
var constraint = ol.array.find(gets[i]['Constraint'], function(element) {
var constraint = _ol_array_.find(gets[i]['Constraint'], function(element) {
return element['name'] == 'GetEncoding';
});
var encodings = constraint['AllowedValues']['Value'];
@@ -442,21 +444,21 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
// requestEncoding not provided, use the first encoding from the list
requestEncoding = encodings[0];
}
if (requestEncoding === ol.source.WMTSRequestEncoding.KVP) {
if (ol.array.includes(encodings, ol.source.WMTSRequestEncoding.KVP)) {
if (requestEncoding === _ol_source_WMTSRequestEncoding_.KVP) {
if (_ol_array_.includes(encodings, _ol_source_WMTSRequestEncoding_.KVP)) {
urls.push(/** @type {string} */ (gets[i]['href']));
}
} else {
break;
}
} else if (gets[i]['href']) {
requestEncoding = ol.source.WMTSRequestEncoding.KVP;
requestEncoding = _ol_source_WMTSRequestEncoding_.KVP;
urls.push(/** @type {string} */ (gets[i]['href']));
}
}
}
if (urls.length === 0) {
requestEncoding = ol.source.WMTSRequestEncoding.REST;
requestEncoding = _ol_source_WMTSRequestEncoding_.REST;
l['ResourceURL'].forEach(function(element) {
if (element['resourceType'] === 'tile') {
format = element['format'];
@@ -479,3 +481,4 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
crossOrigin: config['crossOrigin']
};
};
export default _ol_source_WMTS_;

View File

@@ -1,10 +1,13 @@
goog.provide('ol.source.WMTSRequestEncoding');
/**
* @module ol/source/WMTSRequestEncoding
*/
/**
* Request encoding. One of 'KVP', 'REST'.
* @enum {string}
*/
ol.source.WMTSRequestEncoding = {
var _ol_source_WMTSRequestEncoding_ = {
KVP: 'KVP', // see spec §8
REST: 'REST' // see spec §10
};
export default _ol_source_WMTSRequestEncoding_;

View File

@@ -1,9 +1,9 @@
goog.provide('ol.source.XYZ');
goog.require('ol');
goog.require('ol.source.TileImage');
goog.require('ol.tilegrid');
/**
* @module ol/source/XYZ
*/
import _ol_ from '../index.js';
import _ol_source_TileImage_ from '../source/TileImage.js';
import _ol_tilegrid_ from '../tilegrid.js';
/**
* @classdesc
@@ -27,20 +27,20 @@ goog.require('ol.tilegrid');
* @param {olx.source.XYZOptions=} opt_options XYZ options.
* @api
*/
ol.source.XYZ = function(opt_options) {
var _ol_source_XYZ_ = function(opt_options) {
var options = opt_options || {};
var projection = options.projection !== undefined ?
options.projection : 'EPSG:3857';
var tileGrid = options.tileGrid !== undefined ? options.tileGrid :
ol.tilegrid.createXYZ({
extent: ol.tilegrid.extentFromProjection(projection),
_ol_tilegrid_.createXYZ({
extent: _ol_tilegrid_.extentFromProjection(projection),
maxZoom: options.maxZoom,
minZoom: options.minZoom,
tileSize: options.tileSize
});
ol.source.TileImage.call(this, {
_ol_source_TileImage_.call(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,
crossOrigin: options.crossOrigin,
@@ -59,4 +59,6 @@ ol.source.XYZ = function(opt_options) {
});
};
ol.inherits(ol.source.XYZ, ol.source.TileImage);
_ol_.inherits(_ol_source_XYZ_, _ol_source_TileImage_);
export default _ol_source_XYZ_;

View File

@@ -1,16 +1,16 @@
goog.provide('ol.source.Zoomify');
goog.require('ol');
goog.require('ol.ImageTile');
goog.require('ol.TileState');
goog.require('ol.TileUrlFunction');
goog.require('ol.asserts');
goog.require('ol.dom');
goog.require('ol.extent');
goog.require('ol.size');
goog.require('ol.source.TileImage');
goog.require('ol.tilegrid.TileGrid');
/**
* @module ol/source/Zoomify
*/
import _ol_ from '../index.js';
import _ol_ImageTile_ from '../ImageTile.js';
import _ol_TileState_ from '../TileState.js';
import _ol_TileUrlFunction_ from '../TileUrlFunction.js';
import _ol_asserts_ from '../asserts.js';
import _ol_dom_ from '../dom.js';
import _ol_extent_ from '../extent.js';
import _ol_size_ from '../size.js';
import _ol_source_TileImage_ from '../source/TileImage.js';
import _ol_tilegrid_TileGrid_ from '../tilegrid/TileGrid.js';
/**
* @classdesc
@@ -22,24 +22,24 @@ goog.require('ol.tilegrid.TileGrid');
* @param {olx.source.ZoomifyOptions=} opt_options Options.
* @api
*/
ol.source.Zoomify = function(opt_options) {
var _ol_source_Zoomify_ = function(opt_options) {
var options = opt_options || {};
var size = options.size;
var tierSizeCalculation = options.tierSizeCalculation !== undefined ?
options.tierSizeCalculation :
ol.source.Zoomify.TierSizeCalculation_.DEFAULT;
_ol_source_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 || ol.DEFAULT_TILE_SIZE;
var tileSize = options.tileSize || _ol_.DEFAULT_TILE_SIZE;
var tileSizeForTierSizeCalculation = tileSize;
switch (tierSizeCalculation) {
case ol.source.Zoomify.TierSizeCalculation_.DEFAULT:
case _ol_source_Zoomify_.TierSizeCalculation_.DEFAULT:
while (imageWidth > tileSizeForTierSizeCalculation || imageHeight > tileSizeForTierSizeCalculation) {
tierSizeInTiles.push([
Math.ceil(imageWidth / tileSizeForTierSizeCalculation),
@@ -48,7 +48,7 @@ ol.source.Zoomify = function(opt_options) {
tileSizeForTierSizeCalculation += tileSizeForTierSizeCalculation;
}
break;
case ol.source.Zoomify.TierSizeCalculation_.TRUNCATED:
case _ol_source_Zoomify_.TierSizeCalculation_.TRUNCATED:
var width = imageWidth;
var height = imageHeight;
while (width > tileSizeForTierSizeCalculation || height > tileSizeForTierSizeCalculation) {
@@ -61,7 +61,7 @@ ol.source.Zoomify = function(opt_options) {
}
break;
default:
ol.asserts.assert(false, 53); // Unknown `tierSizeCalculation` configured
_ol_asserts_.assert(false, 53); // Unknown `tierSizeCalculation` configured
break;
}
@@ -80,10 +80,10 @@ ol.source.Zoomify = function(opt_options) {
}
resolutions.reverse();
var tileGrid = new ol.tilegrid.TileGrid({
var tileGrid = new _ol_tilegrid_TileGrid_({
tileSize: tileSize,
extent: extent,
origin: ol.extent.getTopLeft(extent),
origin: _ol_extent_.getTopLeft(extent),
resolutions: resolutions
});
@@ -91,7 +91,7 @@ ol.source.Zoomify = function(opt_options) {
if (url && url.indexOf('{TileGroup}') == -1 && url.indexOf('{tileIndex}') == -1) {
url += '{TileGroup}/{z}-{x}-{y}.jpg';
}
var urls = ol.TileUrlFunction.expandUrl(url);
var urls = _ol_TileUrlFunction_.expandUrl(url);
/**
* @param {string} template Template.
@@ -132,11 +132,11 @@ ol.source.Zoomify = function(opt_options) {
});
}
var tileUrlFunction = ol.TileUrlFunction.createFromTileUrlFunctions(urls.map(createFromTemplate));
var tileUrlFunction = _ol_TileUrlFunction_.createFromTileUrlFunctions(urls.map(createFromTemplate));
var ZoomifyTileClass = ol.source.Zoomify.Tile_.bind(null, tileGrid);
var ZoomifyTileClass = _ol_source_Zoomify_.Tile_.bind(null, tileGrid);
ol.source.TileImage.call(this, {
_ol_source_TileImage_.call(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,
crossOrigin: options.crossOrigin,
@@ -150,7 +150,8 @@ ol.source.Zoomify = function(opt_options) {
});
};
ol.inherits(ol.source.Zoomify, ol.source.TileImage);
_ol_.inherits(_ol_source_Zoomify_, _ol_source_TileImage_);
/**
* @constructor
@@ -164,10 +165,10 @@ ol.inherits(ol.source.Zoomify, ol.source.TileImage);
* @param {olx.TileOptions=} opt_options Tile options.
* @private
*/
ol.source.Zoomify.Tile_ = function(
_ol_source_Zoomify_.Tile_ = function(
tileGrid, tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options) {
ol.ImageTile.call(this, tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options);
_ol_ImageTile_.call(this, tileCoord, state, src, crossOrigin, tileLoadFunction, opt_options);
/**
* @private
@@ -179,26 +180,26 @@ ol.source.Zoomify.Tile_ = function(
* @private
* @type {ol.Size}
*/
this.tileSize_ = ol.size.toSize(tileGrid.getTileSize(tileCoord[0]));
this.tileSize_ = _ol_size_.toSize(tileGrid.getTileSize(tileCoord[0]));
};
ol.inherits(ol.source.Zoomify.Tile_, ol.ImageTile);
_ol_.inherits(_ol_source_Zoomify_.Tile_, _ol_ImageTile_);
/**
* @inheritDoc
*/
ol.source.Zoomify.Tile_.prototype.getImage = function() {
_ol_source_Zoomify_.Tile_.prototype.getImage = function() {
if (this.zoomifyImage_) {
return this.zoomifyImage_;
}
var image = ol.ImageTile.prototype.getImage.call(this);
if (this.state == ol.TileState.LOADED) {
var image = _ol_ImageTile_.prototype.getImage.call(this);
if (this.state == _ol_TileState_.LOADED) {
var tileSize = this.tileSize_;
if (image.width == tileSize[0] && image.height == tileSize[1]) {
this.zoomifyImage_ = image;
return image;
} else {
var context = ol.dom.createCanvasContext2D(tileSize[0], tileSize[1]);
var context = _ol_dom_.createCanvasContext2D(tileSize[0], tileSize[1]);
context.drawImage(image, 0, 0);
this.zoomifyImage_ = context.canvas;
return context.canvas;
@@ -212,7 +213,8 @@ ol.source.Zoomify.Tile_.prototype.getImage = function() {
* @enum {string}
* @private
*/
ol.source.Zoomify.TierSizeCalculation_ = {
_ol_source_Zoomify_.TierSizeCalculation_ = {
DEFAULT: 'default',
TRUNCATED: 'truncated'
};
export default _ol_source_Zoomify_;