Remove extent option for sources
Most of our uses of source extent were cargo cult programming. The source extent was seldom and inconsistently used. Instead, layers can now be configured with an extent, and layer renderers limit rendering (and data requests) to the layer extent. For vector sources, the `getExtent` method returns the extent of currently loaded features (this was the case before and after this change). For tile based sources, we will likely want to allow easy construction of tile grids based on an extent (this is not possible before or after this change, but could be added later).
This commit is contained in:
@@ -89,7 +89,6 @@ ol.DebugTile_.prototype.getImage = function(opt_context) {
|
||||
ol.source.TileDebug = function(options) {
|
||||
|
||||
goog.base(this, {
|
||||
extent: options.extent,
|
||||
opaque: false,
|
||||
projection: options.projection,
|
||||
tileGrid: options.tileGrid
|
||||
|
||||
@@ -33,7 +33,6 @@ ol.source.FormatVector = function(options) {
|
||||
|
||||
goog.base(this, {
|
||||
attributions: options.attributions,
|
||||
extent: options.extent,
|
||||
logo: options.logo,
|
||||
projection: options.projection
|
||||
});
|
||||
|
||||
@@ -20,7 +20,6 @@ ol.source.ImageCanvas = function(options) {
|
||||
|
||||
goog.base(this, {
|
||||
attributions: options.attributions,
|
||||
extent: options.extent,
|
||||
logo: options.logo,
|
||||
projection: options.projection,
|
||||
resolutions: options.resolutions,
|
||||
|
||||
@@ -31,7 +31,6 @@ ol.source.ImageStatic = function(options) {
|
||||
|
||||
goog.base(this, {
|
||||
attributions: attributions,
|
||||
extent: options.extent,
|
||||
logo: options.logo,
|
||||
projection: projection,
|
||||
resolutions: [imageResolution]
|
||||
|
||||
@@ -75,7 +75,6 @@ ol.source.ImageVector = function(options) {
|
||||
goog.base(this, {
|
||||
attributions: options.attributions,
|
||||
canvasFunction: goog.bind(this.canvasFunctionInternal_, this),
|
||||
extent: options.extent,
|
||||
logo: options.logo,
|
||||
projection: options.projection,
|
||||
ratio: options.ratio,
|
||||
|
||||
@@ -31,7 +31,6 @@ ol.source.ImageWMS = function(opt_options) {
|
||||
|
||||
goog.base(this, {
|
||||
attributions: options.attributions,
|
||||
extent: options.extent,
|
||||
logo: options.logo,
|
||||
projection: options.projection,
|
||||
resolutions: options.resolutions
|
||||
|
||||
@@ -22,7 +22,6 @@ ol.source.KML = function(opt_options) {
|
||||
goog.base(this, {
|
||||
attributions: options.attributions,
|
||||
doc: options.doc,
|
||||
extent: options.extent,
|
||||
format: new ol.format.KML({
|
||||
defaultStyle: options.defaultStyle
|
||||
}),
|
||||
|
||||
@@ -21,7 +21,6 @@ goog.require('ol.source.Image');
|
||||
ol.source.MapGuide = function(options) {
|
||||
|
||||
goog.base(this, {
|
||||
extent: options.extent,
|
||||
projection: options.projection,
|
||||
resolutions: options.resolutions
|
||||
});
|
||||
|
||||
@@ -22,7 +22,6 @@ ol.source.OSMXML = function(opt_options) {
|
||||
goog.base(this, {
|
||||
attributions: options.attributions,
|
||||
doc: options.doc,
|
||||
extent: options.extent,
|
||||
format: new ol.format.OSMXML(),
|
||||
logo: options.logo,
|
||||
node: options.node,
|
||||
|
||||
@@ -23,7 +23,6 @@ ol.source.ServerVector = function(options) {
|
||||
|
||||
goog.base(this, {
|
||||
attributions: options.attributions,
|
||||
extent: options.extent,
|
||||
format: options.format,
|
||||
logo: options.logo,
|
||||
projection: options.projection
|
||||
|
||||
@@ -22,7 +22,6 @@ ol.source.State = {
|
||||
|
||||
/**
|
||||
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
|
||||
* extent: (ol.Extent|undefined),
|
||||
* logo: (string|olx.LogoOptions|undefined),
|
||||
* projection: ol.proj.ProjectionLike,
|
||||
* state: (ol.source.State|string|undefined)}}
|
||||
@@ -52,14 +51,6 @@ ol.source.Source = function(options) {
|
||||
*/
|
||||
this.projection_ = ol.proj.get(options.projection);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.Extent}
|
||||
*/
|
||||
this.extent_ = goog.isDef(options.extent) ?
|
||||
options.extent : goog.isDef(options.projection) ?
|
||||
this.projection_.getExtent() : null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<ol.Attribution>}
|
||||
@@ -106,14 +97,6 @@ ol.source.Source.prototype.getAttributions = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.Extent} Extent.
|
||||
*/
|
||||
ol.source.Source.prototype.getExtent = function() {
|
||||
return this.extent_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {string|olx.LogoOptions|undefined} Logo.
|
||||
*/
|
||||
@@ -153,14 +136,6 @@ ol.source.Source.prototype.setAttributions = function(attributions) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Extent} extent Extent.
|
||||
*/
|
||||
ol.source.Source.prototype.setExtent = function(extent) {
|
||||
this.extent_ = extent;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string|olx.LogoOptions|undefined} logo Logo.
|
||||
*/
|
||||
|
||||
@@ -22,7 +22,6 @@ ol.source.StaticVector = function(options) {
|
||||
|
||||
goog.base(this, {
|
||||
attributions: options.attributions,
|
||||
extent: options.extent,
|
||||
format: options.format,
|
||||
logo: options.logo,
|
||||
projection: options.projection
|
||||
|
||||
@@ -59,7 +59,6 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function(tileJSON) {
|
||||
var transform = ol.proj.getTransformFromProjections(
|
||||
epsg4326Projection, this.getProjection());
|
||||
extent = ol.extent.applyTransform(tileJSON.bounds, transform);
|
||||
this.setExtent(extent);
|
||||
}
|
||||
|
||||
if (goog.isDef(tileJSON.scheme)) {
|
||||
|
||||
@@ -24,7 +24,6 @@ ol.source.TileVector = function(options) {
|
||||
|
||||
goog.base(this, {
|
||||
attributions: options.attributions,
|
||||
extent: options.extent,
|
||||
format: options.format,
|
||||
logo: options.logo,
|
||||
projection: options.projection
|
||||
@@ -48,9 +47,7 @@ ol.source.TileVector = function(options) {
|
||||
* @private
|
||||
* @type {ol.TileCoordTransformType}
|
||||
*/
|
||||
this.tileCoordTransform_ = tileGrid.createTileCoordTransform({
|
||||
extent: options.extent
|
||||
});
|
||||
this.tileCoordTransform_ = tileGrid.createTileCoordTransform();
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -40,7 +40,6 @@ ol.source.TileWMS = function(opt_options) {
|
||||
goog.base(this, {
|
||||
attributions: options.attributions,
|
||||
crossOrigin: options.crossOrigin,
|
||||
extent: options.extent,
|
||||
logo: options.logo,
|
||||
opaque: !transparent,
|
||||
projection: options.projection,
|
||||
@@ -394,12 +393,6 @@ ol.source.TileWMS.prototype.tileUrlFunction_ =
|
||||
tileResolution * gutter, tileExtent);
|
||||
}
|
||||
|
||||
var extent = this.getExtent();
|
||||
if (!goog.isNull(extent) && (!ol.extent.intersects(tileExtent, extent) ||
|
||||
ol.extent.touches(tileExtent, extent))) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (pixelRatio != 1) {
|
||||
tileSize = (tileSize * pixelRatio + 0.5) | 0;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,6 @@ ol.source.Vector = function(opt_options) {
|
||||
|
||||
goog.base(this, {
|
||||
attributions: options.attributions,
|
||||
extent: options.extent,
|
||||
logo: options.logo,
|
||||
projection: options.projection,
|
||||
state: options.state
|
||||
@@ -332,6 +331,7 @@ ol.source.Vector.prototype.getClosestFeatureToCoordinate =
|
||||
|
||||
|
||||
/**
|
||||
* Get the extent of the features currently in the source.
|
||||
* @return {ol.Extent} Extent.
|
||||
* @api
|
||||
*/
|
||||
|
||||
@@ -154,13 +154,9 @@ ol.source.WMTS = function(options) {
|
||||
var x = tileCoord.x;
|
||||
var y = -tileCoord.y - 1;
|
||||
var tileExtent = tileGrid.getTileCoordExtent(tileCoord);
|
||||
var projectionExtent = projection.getExtent();
|
||||
var extent = goog.isDef(options.extent) ?
|
||||
options.extent : projectionExtent;
|
||||
var extent = projection.getExtent();
|
||||
|
||||
if (!goog.isNull(extent) && projection.isGlobal() &&
|
||||
extent[0] === projectionExtent[0] &&
|
||||
extent[2] === projectionExtent[2]) {
|
||||
if (!goog.isNull(extent) && projection.isGlobal()) {
|
||||
var numCols = Math.ceil(
|
||||
ol.extent.getWidth(extent) /
|
||||
ol.extent.getWidth(tileExtent));
|
||||
@@ -181,7 +177,6 @@ ol.source.WMTS = function(options) {
|
||||
goog.base(this, {
|
||||
attributions: options.attributions,
|
||||
crossOrigin: options.crossOrigin,
|
||||
extent: options.extent,
|
||||
logo: options.logo,
|
||||
projection: options.projection,
|
||||
tileGrid: tileGrid,
|
||||
|
||||
@@ -30,7 +30,6 @@ ol.source.XYZ = function(options) {
|
||||
goog.base(this, {
|
||||
attributions: options.attributions,
|
||||
crossOrigin: options.crossOrigin,
|
||||
extent: options.extent,
|
||||
logo: options.logo,
|
||||
projection: projection,
|
||||
tileGrid: tileGrid,
|
||||
@@ -44,7 +43,6 @@ ol.source.XYZ = function(options) {
|
||||
* @type {ol.TileCoordTransformType}
|
||||
*/
|
||||
this.tileCoordTransform_ = tileGrid.createTileCoordTransform({
|
||||
extent: options.extent,
|
||||
wrapX: options.wrapX
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user