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:
Tim Schaub
2014-07-07 23:05:12 -06:00
parent 7bbd27e68e
commit caa0b568ad
20 changed files with 5 additions and 235 deletions

View File

@@ -2622,7 +2622,6 @@ olx.source.BingMapsOptions.prototype.tileLoadFunction;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* extent: (ol.Extent|undefined),
* format: ol.format.Feature,
* logo: (string|olx.LogoOptions|undefined),
* projection: ol.proj.ProjectionLike}}
@@ -2638,13 +2637,6 @@ olx.source.FormatVectorOptions;
olx.source.FormatVectorOptions.prototype.attributions;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.FormatVectorOptions.prototype.extent;
/**
* Format.
* @type {ol.format.Feature}
@@ -2669,7 +2661,6 @@ olx.source.FormatVectorOptions.prototype.projection;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* defaultProjection: ol.proj.ProjectionLike,
* extent: (ol.Extent|undefined),
* logo: (string|olx.LogoOptions|undefined),
* object: (GeoJSONObject|undefined),
* projection: ol.proj.ProjectionLike,
@@ -2695,13 +2686,6 @@ olx.source.GeoJSONOptions.prototype.attributions;
olx.source.GeoJSONOptions.prototype.defaultProjection;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.GeoJSONOptions.prototype.extent;
/**
* Logo.
* @type{string|olx.LogoOptions|undefined}
@@ -2748,7 +2732,6 @@ olx.source.GeoJSONOptions.prototype.urls;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* doc: (Document|undefined),
* extent: (ol.Extent|undefined),
* logo: (string|olx.LogoOptions|undefined),
* node: (Node|undefined),
* projection: ol.proj.ProjectionLike,
@@ -2774,13 +2757,6 @@ olx.source.GPXOptions.prototype.attributions;
olx.source.GPXOptions.prototype.doc;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.GPXOptions.prototype.extent;
/**
* Logo.
* @type{string|olx.LogoOptions|undefined}
@@ -2827,7 +2803,6 @@ olx.source.GPXOptions.prototype.urls;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* crossOrigin: (null|string|undefined),
* extent: (ol.Extent|undefined),
* logo: (string|olx.LogoOptions|undefined),
* opaque: (boolean|undefined),
* projection: ol.proj.ProjectionLike,
@@ -2857,13 +2832,6 @@ olx.source.TileImageOptions.prototype.attributions;
olx.source.TileImageOptions.prototype.crossOrigin;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.TileImageOptions.prototype.extent;
/**
* Logo.
* @type{string|olx.LogoOptions|undefined}
@@ -2928,7 +2896,6 @@ olx.source.TileImageOptions.prototype.tileUrlFunction;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* defaultProjection: ol.proj.ProjectionLike,
* extent: (ol.Extent|undefined),
* format: ol.format.Feature,
* logo: (string|olx.LogoOptions|undefined),
* object: (GeoJSONObject|undefined),
@@ -2956,13 +2923,6 @@ olx.source.TileVectorOptions.prototype.attributions;
olx.source.TileVectorOptions.prototype.defaultProjection;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.TileVectorOptions.prototype.extent;
/**
* Format.
* @type {ol.format.Feature}
@@ -3024,7 +2984,6 @@ olx.source.TileVectorOptions.prototype.urls;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* defaultProjection: ol.proj.ProjectionLike,
* extent: (ol.Extent|undefined),
* logo: (string|olx.LogoOptions|undefined),
* object: (GeoJSONObject|undefined),
* projection: ol.proj.ProjectionLike,
@@ -3049,13 +3008,6 @@ olx.source.TopoJSONOptions.prototype.attributions;
olx.source.TopoJSONOptions.prototype.defaultProjection;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.TopoJSONOptions.prototype.extent;
/**
* Logo.
* @type{string|olx.LogoOptions|undefined}
@@ -3144,7 +3096,6 @@ olx.source.IGCOptions.prototype.urls;
* @typedef {{url: (string|undefined),
* displayDpi: (number|undefined),
* metersPerUnit: (number|undefined),
* extent: (ol.Extent|undefined),
* hidpi: (boolean|undefined),
* useOverlay: (boolean|undefined),
* projection: ol.proj.ProjectionLike,
@@ -3177,13 +3128,6 @@ olx.source.MapGuideOptions.prototype.displayDpi;
olx.source.MapGuideOptions.prototype.metersPerUnit;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.MapGuideOptions.prototype.extent;
/**
* Use the `ol.Map#pixelRatio` value when requesting the image from the remote
* server. Default is `true`.
@@ -3232,7 +3176,6 @@ olx.source.MapGuideOptions.prototype.params;
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* defaultStyle: (Array.<ol.style.Style>|undefined),
* doc: (Document|undefined),
* extent: (ol.Extent|undefined),
* logo: (string|olx.LogoOptions|undefined),
* node: (Node|undefined),
* projection: ol.proj.ProjectionLike,
@@ -3265,13 +3208,6 @@ olx.source.KMLOptions.prototype.defaultStyle;
olx.source.KMLOptions.prototype.doc;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.KMLOptions.prototype.extent;
/**
* Logo.
* @type{string|olx.LogoOptions|undefined}
@@ -3338,21 +3274,13 @@ olx.source.MapQuestOptions.prototype.tileLoadFunction;
/**
* @typedef {{extent: (ol.Extent|undefined),
* projection: ol.proj.ProjectionLike,
* @typedef {{projection: ol.proj.ProjectionLike,
* tileGrid: (ol.tilegrid.TileGrid|undefined)}}
* @api
*/
olx.source.TileDebugOptions;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.TileDebugOptions.prototype.extent;
/**
* Projection.
* @type {ol.proj.ProjectionLike}
@@ -3418,7 +3346,6 @@ olx.source.OSMOptions.prototype.url;
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* defaultStyle: (Array.<ol.style.Style>|undefined),
* doc: (Document|undefined),
* extent: (ol.Extent|undefined),
* logo: (string|olx.LogoOptions|undefined),
* node: (Node|undefined),
* projection: ol.proj.ProjectionLike,
@@ -3452,13 +3379,6 @@ olx.source.OSMXMLOptions.prototype.defaultStyle;
olx.source.OSMXMLOptions.prototype.doc;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.OSMXMLOptions.prototype.extent;
/**
* Logo.
* @type{string|olx.LogoOptions|undefined}
@@ -3511,7 +3431,6 @@ olx.source.OSMXMLOptions.prototype.urls;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* canvasFunction: ol.CanvasFunctionType,
* extent: (ol.Extent|undefined),
* logo: (string|olx.LogoOptions|undefined),
* projection: ol.proj.ProjectionLike,
* ratio: (number|undefined),
@@ -3543,13 +3462,6 @@ olx.source.ImageCanvasOptions.prototype.attributions;
olx.source.ImageCanvasOptions.prototype.canvasFunction;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.ImageCanvasOptions.prototype.extent;
/**
* Logo.
* @type{string|olx.LogoOptions|undefined}
@@ -3589,7 +3501,6 @@ olx.source.ImageCanvasOptions.prototype.state;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* extent: (ol.Extent|undefined),
* logo: (string|olx.LogoOptions|undefined),
* projection: ol.proj.ProjectionLike,
* ratio: (number|undefined),
@@ -3608,13 +3519,6 @@ olx.source.ImageVectorOptions;
olx.source.ImageVectorOptions.prototype.attributions;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.ImageVectorOptions.prototype.extent;
/**
* Logo.
* @type{string|olx.LogoOptions|undefined}
@@ -3663,7 +3567,6 @@ olx.source.ImageVectorOptions.prototype.style;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* crossOrigin: (null|string|undefined),
* extent: (ol.Extent|undefined),
* hidpi: (boolean|undefined),
* serverType: (ol.source.wms.ServerType|string|undefined),
* logo: (string|olx.LogoOptions|undefined),
@@ -3691,13 +3594,6 @@ olx.source.ImageWMSOptions.prototype.attributions;
olx.source.ImageWMSOptions.prototype.crossOrigin;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.ImageWMSOptions.prototype.extent;
/**
* Use the `ol.Map#pixelRatio` value when requesting the image from the remote
* server. Default is `true`.
@@ -3816,7 +3712,6 @@ olx.source.StamenOptions.prototype.url;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* crossOrigin: (null|string|undefined),
* extent: (ol.Extent|undefined),
* imageExtent: (ol.Extent|undefined),
* imageSize: (ol.Size|undefined),
* logo: (string|olx.LogoOptions|undefined),
@@ -3841,13 +3736,6 @@ olx.source.ImageStaticOptions.prototype.attributions;
olx.source.ImageStaticOptions.prototype.crossOrigin;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.ImageStaticOptions.prototype.extent;
/**
* Extent of the image.
* @type {ol.Extent|undefined}
@@ -3885,7 +3773,6 @@ olx.source.ImageStaticOptions.prototype.url;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* extent: (ol.Extent|undefined),
* format: ol.format.Feature,
* loader: function(this: ol.source.ServerVector, ol.Extent, number, ol.proj.Projection),
* strategy: (function(ol.Extent, number): Array.<ol.Extent>|undefined),
@@ -3903,13 +3790,6 @@ olx.source.ServerVectorOptions;
olx.source.ServerVectorOptions.prototype.attributions;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.ServerVectorOptions.prototype.extent;
/**
* Format.
* @type {ol.format.Feature}
@@ -3980,7 +3860,6 @@ olx.source.TileJSONOptions.prototype.url;
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* params: Object.<string,*>,
* crossOrigin: (null|string|undefined),
* extent: (ol.Extent|undefined),
* gutter: (number|undefined),
* hidpi: (boolean|undefined),
* logo: (string|olx.LogoOptions|undefined),
@@ -4019,13 +3898,6 @@ olx.source.TileWMSOptions.prototype.params;
olx.source.TileWMSOptions.prototype.crossOrigin;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.TileWMSOptions.prototype.extent;
/**
* The size in pixels of the gutter around image tiles to ignore. By setting
* this property to a non-zero value, images will be requested that are wider
@@ -4112,7 +3984,6 @@ olx.source.TileWMSOptions.prototype.urls;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* extent: (ol.Extent|undefined),
* features: (Array.<ol.Feature>|undefined),
* logo: (string|olx.LogoOptions|undefined),
* projection: ol.proj.ProjectionLike,
@@ -4129,13 +4000,6 @@ olx.source.VectorOptions;
olx.source.VectorOptions.prototype.attributions;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.VectorOptions.prototype.extent;
/**
* Features.
* @type {Array.<ol.Feature>|undefined}
@@ -4168,7 +4032,6 @@ olx.source.VectorOptions.prototype.state;
* @typedef {{arrayBuffer: (ArrayBuffer|undefined),
* attributions: (Array.<ol.Attribution>|undefined),
* doc: (Document|undefined),
* extent: (ol.Extent|undefined),
* format: ol.format.Feature,
* logo: (string|olx.LogoOptions|undefined),
* node: (Node|undefined),
@@ -4203,13 +4066,6 @@ olx.source.StaticVectorOptions.prototype.attributions;
olx.source.StaticVectorOptions.prototype.doc;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.StaticVectorOptions.prototype.extent;
/**
* Format.
* @type {ol.format.Feature}
@@ -4269,7 +4125,6 @@ olx.source.StaticVectorOptions.prototype.urls;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* crossOrigin: (string|null|undefined),
* extent: (ol.Extent|undefined),
* logo: (string|olx.LogoOptions|undefined),
* tileGrid: ol.tilegrid.WMTS,
* projection: ol.proj.ProjectionLike,
@@ -4304,13 +4159,6 @@ olx.source.WMTSOptions.prototype.attributions;
olx.source.WMTSOptions.prototype.crossOrigin;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.WMTSOptions.prototype.extent;
/**
* Logo.
* @type{string|olx.LogoOptions|undefined}
@@ -4422,7 +4270,6 @@ olx.source.WMTSOptions.prototype.urls;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* crossOrigin: (null|string|undefined),
* extent: (ol.Extent|undefined),
* logo: (string|olx.LogoOptions|undefined),
* projection: ol.proj.ProjectionLike,
* maxZoom: (number|undefined),
@@ -4452,13 +4299,6 @@ olx.source.XYZOptions.prototype.attributions;
olx.source.XYZOptions.prototype.crossOrigin;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.XYZOptions.prototype.extent;
/**
* Logo.
* @type{string|olx.LogoOptions|undefined}

View File

@@ -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

View File

@@ -33,7 +33,6 @@ ol.source.FormatVector = function(options) {
goog.base(this, {
attributions: options.attributions,
extent: options.extent,
logo: options.logo,
projection: options.projection
});

View File

@@ -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,

View File

@@ -31,7 +31,6 @@ ol.source.ImageStatic = function(options) {
goog.base(this, {
attributions: attributions,
extent: options.extent,
logo: options.logo,
projection: projection,
resolutions: [imageResolution]

View File

@@ -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,

View File

@@ -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

View File

@@ -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
}),

View File

@@ -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
});

View File

@@ -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,

View File

@@ -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

View File

@@ -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.
*/

View File

@@ -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

View File

@@ -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)) {

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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
*/

View File

@@ -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,

View File

@@ -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
});

View File

@@ -126,22 +126,6 @@ describe('ol.source.TileWMS', function() {
expect(queryData.get('BBOX')).to.be('-45,-45,0,0');
});
it('does not return a tile if it touches layers extent', function() {
options.extent = [-80, -40, -45, -10];
var source = new ol.source.TileWMS(options);
var tileCoord = new ol.TileCoord(3, 3, 1);
var url = source.tileUrlFunction(tileCoord, 1, ol.proj.get('EPSG:4326'));
expect(url).to.be(undefined);
});
it('does not return a tile outside of layers extent', function() {
options.extent = [-80, -40, -45, -10];
var source = new ol.source.TileWMS(options);
var tileCoord = new ol.TileCoord(3, 4, 2);
var url = source.tileUrlFunction(tileCoord, 1, ol.proj.get('EPSG:4326'));
expect(url).to.be(undefined);
});
});
describe('#getGetFeatureInfo', function() {