Merge pull request #2316 from tschaub/layer-extent

Support for layers with limited extent.
This commit is contained in:
Tim Schaub
2014-07-24 10:41:01 -06:00
41 changed files with 313 additions and 272 deletions
+2 -2
View File
@@ -15,6 +15,7 @@ var bounds = [
var map = new ol.Map({ var map = new ol.Map({
layers: [ layers: [
new ol.layer.Image({ new ol.layer.Image({
extent: bounds,
source: new ol.source.MapGuide({ source: new ol.source.MapGuide({
projection: 'EPSG:4326', projection: 'EPSG:4326',
url: agentUrl, url: agentUrl,
@@ -24,8 +25,7 @@ var map = new ol.Map({
MAPDEFINITION: mdf, MAPDEFINITION: mdf,
FORMAT: 'PNG' FORMAT: 'PNG'
}, },
ratio: 2, ratio: 2
extent: bounds
}) })
}) })
], ],
+2 -2
View File
@@ -44,6 +44,7 @@ ol.proj.addCoordinateTransforms('EPSG:4326', projection,
var extent = [420000, 30000, 900000, 350000]; var extent = [420000, 30000, 900000, 350000];
var layers = [ var layers = [
new ol.layer.Tile({ new ol.layer.Tile({
extent: extent,
source: new ol.source.TileWMS({ source: new ol.source.TileWMS({
url: 'http://wms.geo.admin.ch/', url: 'http://wms.geo.admin.ch/',
crossOrigin: 'anonymous', crossOrigin: 'anonymous',
@@ -57,11 +58,11 @@ var layers = [
'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale', 'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale',
'FORMAT': 'image/jpeg' 'FORMAT': 'image/jpeg'
}, },
extent: extent,
serverType: 'mapserver' serverType: 'mapserver'
}) })
}), }),
new ol.layer.Tile({ new ol.layer.Tile({
extent: extent,
source: new ol.source.TileWMS({ source: new ol.source.TileWMS({
url: 'http://wms.geo.admin.ch/', url: 'http://wms.geo.admin.ch/',
crossOrigin: 'anonymous', crossOrigin: 'anonymous',
@@ -72,7 +73,6 @@ var layers = [
'National parks / geo.admin.ch</a>' 'National parks / geo.admin.ch</a>'
})], })],
params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'}, params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'},
extent: extent,
serverType: 'mapserver' serverType: 'mapserver'
}) })
}) })
+4 -4
View File
@@ -24,6 +24,7 @@ projection.setExtent([485869.5728, 76443.1884, 837076.5648, 299941.7864]);
var extent = [420000, 30000, 900000, 350000]; var extent = [420000, 30000, 900000, 350000];
var layers = [ var layers = [
new ol.layer.Image({ new ol.layer.Image({
extent: extent,
source: new ol.source.ImageWMS({ source: new ol.source.ImageWMS({
url: 'http://wms.geo.admin.ch/', url: 'http://wms.geo.admin.ch/',
crossOrigin: 'anonymous', crossOrigin: 'anonymous',
@@ -37,11 +38,11 @@ var layers = [
'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale', 'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale',
'FORMAT': 'image/jpeg' 'FORMAT': 'image/jpeg'
}, },
serverType: /** @type {ol.source.wms.ServerType} */ ('mapserver'), serverType: /** @type {ol.source.wms.ServerType} */ ('mapserver')
extent: extent
}) })
}), }),
new ol.layer.Image({ new ol.layer.Image({
extent: extent,
source: new ol.source.ImageWMS({ source: new ol.source.ImageWMS({
url: 'http://wms.geo.admin.ch/', url: 'http://wms.geo.admin.ch/',
crossOrigin: 'anonymous', crossOrigin: 'anonymous',
@@ -52,8 +53,7 @@ var layers = [
'National parks / geo.admin.ch</a>' 'National parks / geo.admin.ch</a>'
})], })],
params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'}, params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'},
serverType: /** @type {ol.source.wms.ServerType} */ ('mapserver'), serverType: /** @type {ol.source.wms.ServerType} */ ('mapserver')
extent: extent
}) })
}) })
]; ];
+2 -2
View File
@@ -11,11 +11,11 @@ var layers = [
source: new ol.source.MapQuest({layer: 'sat'}) source: new ol.source.MapQuest({layer: 'sat'})
}), }),
new ol.layer.Image({ new ol.layer.Image({
extent: [-13884991, 2870341, -7455066, 6338219],
source: new ol.source.ImageWMS({ source: new ol.source.ImageWMS({
url: 'http://demo.opengeo.org/geoserver/wms', url: 'http://demo.opengeo.org/geoserver/wms',
params: {'LAYERS': 'topp:states'}, params: {'LAYERS': 'topp:states'},
serverType: 'geoserver', serverType: 'geoserver'
extent: [-13884991, 2870341, -7455066, 6338219]
}) })
}) })
]; ];
+1 -1
View File
@@ -10,10 +10,10 @@ var layers = [
source: new ol.source.MapQuest({layer: 'sat'}) source: new ol.source.MapQuest({layer: 'sat'})
}), }),
new ol.layer.Tile({ new ol.layer.Tile({
extent: [-13884991, 2870341, -7455066, 6338219],
source: new ol.source.TileWMS(/** @type {olx.source.TileWMSOptions} */ ({ source: new ol.source.TileWMS(/** @type {olx.source.TileWMSOptions} */ ({
url: 'http://demo.opengeo.org/geoserver/wms', url: 'http://demo.opengeo.org/geoserver/wms',
params: {'LAYERS': 'topp:states', 'TILED': true}, params: {'LAYERS': 'topp:states', 'TILED': true},
extent: [-13884991, 2870341, -7455066, 6338219],
serverType: 'geoserver' serverType: 'geoserver'
})) }))
}) })
+5
View File
@@ -9,6 +9,11 @@
<link rel="stylesheet" href="../resources/layout.css" type="text/css"> <link rel="stylesheet" href="../resources/layout.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css"> <link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<title>WMTS HiDPI example</title> <title>WMTS HiDPI example</title>
<style>
.map {
background: white;
}
</style>
</head> </head>
<body> <body>
+1 -1
View File
@@ -23,7 +23,6 @@ var urls = [
var hiDPI = ol.BrowserFeature.DEVICE_PIXEL_RATIO > 1; var hiDPI = ol.BrowserFeature.DEVICE_PIXEL_RATIO > 1;
var source = new ol.source.WMTS({ var source = new ol.source.WMTS({
extent: [977844.377599999, 5837774.6617, 1915609.8654, 6295560.8122],
projection: 'EPSG:3857', projection: 'EPSG:3857',
layer: hiDPI ? 'bmaphidpi' : 'geolandbasemap', layer: hiDPI ? 'bmaphidpi' : 'geolandbasemap',
tilePixelRatio: hiDPI ? 2 : 1, tilePixelRatio: hiDPI ? 2 : 1,
@@ -64,6 +63,7 @@ var source = new ol.source.WMTS({
var map = new ol.Map({ var map = new ol.Map({
layers: [ layers: [
new ol.layer.Tile({ new ol.layer.Tile({
extent: [977844.377599999, 5837774.6617, 1915609.8654, 6295560.8122],
source: source source: source
}) })
], ],
+1 -1
View File
@@ -35,6 +35,7 @@ var map = new ol.Map({
}), }),
new ol.layer.Tile({ new ol.layer.Tile({
opacity: 0.7, opacity: 0.7,
extent: projectionExtent,
source: new ol.source.WMTS({ source: new ol.source.WMTS({
attributions: [attribution], attributions: [attribution],
url: 'http://services.arcgisonline.com/arcgis/rest/' + url: 'http://services.arcgisonline.com/arcgis/rest/' +
@@ -48,7 +49,6 @@ var map = new ol.Map({
resolutions: resolutions, resolutions: resolutions,
matrixIds: matrixIds matrixIds: matrixIds
}), }),
extent: projectionExtent,
style: 'default' style: 'default'
}) })
}) })
+54 -161
View File
@@ -1969,6 +1969,7 @@ olx.interaction.SelectOptions.prototype.toggleCondition;
* opacity: (number|undefined), * opacity: (number|undefined),
* saturation: (number|undefined), * saturation: (number|undefined),
* visible: (boolean|undefined), * visible: (boolean|undefined),
* extent: (ol.Extent|undefined),
* minResolution: (number|undefined), * minResolution: (number|undefined),
* maxResolution: (number|undefined)}} * maxResolution: (number|undefined)}}
* @api * @api
@@ -2018,6 +2019,14 @@ olx.layer.BaseOptions.prototype.saturation;
olx.layer.BaseOptions.prototype.visible; olx.layer.BaseOptions.prototype.visible;
/**
* The bounding extent for layer rendering. The layer will not be rendered
* outside of this extent.
* @type {ol.Extent|undefined}
*/
olx.layer.BaseOptions.prototype.extent;
/** /**
* The minimum resolution (inclusive) at which this layer will be visible. * The minimum resolution (inclusive) at which this layer will be visible.
* @type {number|undefined} * @type {number|undefined}
@@ -2040,6 +2049,7 @@ olx.layer.BaseOptions.prototype.maxResolution;
* saturation: (number|undefined), * saturation: (number|undefined),
* source: ol.source.Source, * source: ol.source.Source,
* visible: (boolean|undefined), * visible: (boolean|undefined),
* extent: (ol.Extent|undefined),
* minResolution: (number|undefined), * minResolution: (number|undefined),
* maxResolution: (number|undefined)}} * maxResolution: (number|undefined)}}
* @api * @api
@@ -2096,6 +2106,14 @@ olx.layer.LayerOptions.prototype.source;
olx.layer.LayerOptions.prototype.visible; olx.layer.LayerOptions.prototype.visible;
/**
* The bounding extent for layer rendering. The layer will not be rendered
* outside of this extent.
* @type {ol.Extent|undefined}
*/
olx.layer.LayerOptions.prototype.extent;
/** /**
* The minimum resolution (inclusive) at which this layer will be visible. * The minimum resolution (inclusive) at which this layer will be visible.
* @type {number|undefined} * @type {number|undefined}
@@ -2117,6 +2135,7 @@ olx.layer.LayerOptions.prototype.maxResolution;
* opacity: (number|undefined), * opacity: (number|undefined),
* saturation: (number|undefined), * saturation: (number|undefined),
* visible: (boolean|undefined), * visible: (boolean|undefined),
* extent: (ol.Extent|undefined),
* minResolution: (number|undefined), * minResolution: (number|undefined),
* maxResolution: (number|undefined), * maxResolution: (number|undefined),
* layers: (Array.<ol.layer.Base>|ol.Collection|undefined)}} * layers: (Array.<ol.layer.Base>|ol.Collection|undefined)}}
@@ -2167,6 +2186,14 @@ olx.layer.GroupOptions.prototype.saturation;
olx.layer.GroupOptions.prototype.visible; olx.layer.GroupOptions.prototype.visible;
/**
* The bounding extent for layer rendering. The layer will not be rendered
* outside of this extent.
* @type {ol.Extent|undefined}
*/
olx.layer.GroupOptions.prototype.extent;
/** /**
* The minimum resolution (inclusive) at which this layer will be visible. * The minimum resolution (inclusive) at which this layer will be visible.
* @type {number|undefined} * @type {number|undefined}
@@ -2197,6 +2224,7 @@ olx.layer.GroupOptions.prototype.layers;
* blur: (number|undefined), * blur: (number|undefined),
* shadow: (number|undefined), * shadow: (number|undefined),
* weight: (string|function(ol.Feature):number|undefined), * weight: (string|function(ol.Feature):number|undefined),
* extent: (ol.Extent|undefined),
* minResolution: (number|undefined), * minResolution: (number|undefined),
* maxResolution: (number|undefined), * maxResolution: (number|undefined),
* opacity: (number|undefined), * opacity: (number|undefined),
@@ -2267,6 +2295,14 @@ olx.layer.HeatmapOptions.prototype.shadow;
olx.layer.HeatmapOptions.prototype.weight; olx.layer.HeatmapOptions.prototype.weight;
/**
* The bounding extent for layer rendering. The layer will not be rendered
* outside of this extent.
* @type {ol.Extent|undefined}
*/
olx.layer.HeatmapOptions.prototype.extent;
/** /**
* The minimum resolution (inclusive) at which this layer will be visible. * The minimum resolution (inclusive) at which this layer will be visible.
* @type {number|undefined} * @type {number|undefined}
@@ -2318,6 +2354,7 @@ olx.layer.HeatmapOptions.prototype.visible;
* saturation: (number|undefined), * saturation: (number|undefined),
* source: ol.source.Source, * source: ol.source.Source,
* visible: (boolean|undefined), * visible: (boolean|undefined),
* extent: (ol.Extent|undefined),
* minResolution: (number|undefined), * minResolution: (number|undefined),
* maxResolution: (number|undefined), * maxResolution: (number|undefined),
* useInterimTilesOnError: (boolean|undefined)}} * useInterimTilesOnError: (boolean|undefined)}}
@@ -2382,6 +2419,14 @@ olx.layer.TileOptions.prototype.source;
olx.layer.TileOptions.prototype.visible; olx.layer.TileOptions.prototype.visible;
/**
* The bounding extent for layer rendering. The layer will not be rendered
* outside of this extent.
* @type {ol.Extent|undefined}
*/
olx.layer.TileOptions.prototype.extent;
/** /**
* The minimum resolution (inclusive) at which this layer will be visible. * The minimum resolution (inclusive) at which this layer will be visible.
* @type {number|undefined} * @type {number|undefined}
@@ -2450,6 +2495,14 @@ olx.layer.VectorOptions.prototype.renderOrder;
olx.layer.VectorOptions.prototype.hue; olx.layer.VectorOptions.prototype.hue;
/**
* The bounding extent for layer rendering. The layer will not be rendered
* outside of this extent.
* @type {ol.Extent|undefined}
*/
olx.layer.VectorOptions.prototype.extent;
/** /**
* The minimum resolution (inclusive) at which this layer will be visible. * The minimum resolution (inclusive) at which this layer will be visible.
* @type {number|undefined} * @type {number|undefined}
@@ -2569,7 +2622,6 @@ olx.source.BingMapsOptions.prototype.tileLoadFunction;
/** /**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* extent: (ol.Extent|undefined),
* format: ol.format.Feature, * format: ol.format.Feature,
* logo: (string|olx.LogoOptions|undefined), * logo: (string|olx.LogoOptions|undefined),
* projection: ol.proj.ProjectionLike}} * projection: ol.proj.ProjectionLike}}
@@ -2585,13 +2637,6 @@ olx.source.FormatVectorOptions;
olx.source.FormatVectorOptions.prototype.attributions; olx.source.FormatVectorOptions.prototype.attributions;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.FormatVectorOptions.prototype.extent;
/** /**
* Format. * Format.
* @type {ol.format.Feature} * @type {ol.format.Feature}
@@ -2616,7 +2661,6 @@ olx.source.FormatVectorOptions.prototype.projection;
/** /**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* defaultProjection: ol.proj.ProjectionLike, * defaultProjection: ol.proj.ProjectionLike,
* extent: (ol.Extent|undefined),
* logo: (string|olx.LogoOptions|undefined), * logo: (string|olx.LogoOptions|undefined),
* object: (GeoJSONObject|undefined), * object: (GeoJSONObject|undefined),
* projection: ol.proj.ProjectionLike, * projection: ol.proj.ProjectionLike,
@@ -2642,13 +2686,6 @@ olx.source.GeoJSONOptions.prototype.attributions;
olx.source.GeoJSONOptions.prototype.defaultProjection; olx.source.GeoJSONOptions.prototype.defaultProjection;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.GeoJSONOptions.prototype.extent;
/** /**
* Logo. * Logo.
* @type{string|olx.LogoOptions|undefined} * @type{string|olx.LogoOptions|undefined}
@@ -2695,7 +2732,6 @@ olx.source.GeoJSONOptions.prototype.urls;
/** /**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* doc: (Document|undefined), * doc: (Document|undefined),
* extent: (ol.Extent|undefined),
* logo: (string|olx.LogoOptions|undefined), * logo: (string|olx.LogoOptions|undefined),
* node: (Node|undefined), * node: (Node|undefined),
* projection: ol.proj.ProjectionLike, * projection: ol.proj.ProjectionLike,
@@ -2721,13 +2757,6 @@ olx.source.GPXOptions.prototype.attributions;
olx.source.GPXOptions.prototype.doc; olx.source.GPXOptions.prototype.doc;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.GPXOptions.prototype.extent;
/** /**
* Logo. * Logo.
* @type{string|olx.LogoOptions|undefined} * @type{string|olx.LogoOptions|undefined}
@@ -2774,7 +2803,6 @@ olx.source.GPXOptions.prototype.urls;
/** /**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* crossOrigin: (null|string|undefined), * crossOrigin: (null|string|undefined),
* extent: (ol.Extent|undefined),
* logo: (string|olx.LogoOptions|undefined), * logo: (string|olx.LogoOptions|undefined),
* opaque: (boolean|undefined), * opaque: (boolean|undefined),
* projection: ol.proj.ProjectionLike, * projection: ol.proj.ProjectionLike,
@@ -2804,13 +2832,6 @@ olx.source.TileImageOptions.prototype.attributions;
olx.source.TileImageOptions.prototype.crossOrigin; olx.source.TileImageOptions.prototype.crossOrigin;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.TileImageOptions.prototype.extent;
/** /**
* Logo. * Logo.
* @type{string|olx.LogoOptions|undefined} * @type{string|olx.LogoOptions|undefined}
@@ -2875,7 +2896,6 @@ olx.source.TileImageOptions.prototype.tileUrlFunction;
/** /**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* defaultProjection: ol.proj.ProjectionLike, * defaultProjection: ol.proj.ProjectionLike,
* extent: (ol.Extent|undefined),
* format: ol.format.Feature, * format: ol.format.Feature,
* logo: (string|olx.LogoOptions|undefined), * logo: (string|olx.LogoOptions|undefined),
* object: (GeoJSONObject|undefined), * object: (GeoJSONObject|undefined),
@@ -2903,13 +2923,6 @@ olx.source.TileVectorOptions.prototype.attributions;
olx.source.TileVectorOptions.prototype.defaultProjection; olx.source.TileVectorOptions.prototype.defaultProjection;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.TileVectorOptions.prototype.extent;
/** /**
* Format. * Format.
* @type {ol.format.Feature} * @type {ol.format.Feature}
@@ -2971,7 +2984,6 @@ olx.source.TileVectorOptions.prototype.urls;
/** /**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* defaultProjection: ol.proj.ProjectionLike, * defaultProjection: ol.proj.ProjectionLike,
* extent: (ol.Extent|undefined),
* logo: (string|olx.LogoOptions|undefined), * logo: (string|olx.LogoOptions|undefined),
* object: (GeoJSONObject|undefined), * object: (GeoJSONObject|undefined),
* projection: ol.proj.ProjectionLike, * projection: ol.proj.ProjectionLike,
@@ -2996,13 +3008,6 @@ olx.source.TopoJSONOptions.prototype.attributions;
olx.source.TopoJSONOptions.prototype.defaultProjection; olx.source.TopoJSONOptions.prototype.defaultProjection;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.TopoJSONOptions.prototype.extent;
/** /**
* Logo. * Logo.
* @type{string|olx.LogoOptions|undefined} * @type{string|olx.LogoOptions|undefined}
@@ -3091,7 +3096,6 @@ olx.source.IGCOptions.prototype.urls;
* @typedef {{url: (string|undefined), * @typedef {{url: (string|undefined),
* displayDpi: (number|undefined), * displayDpi: (number|undefined),
* metersPerUnit: (number|undefined), * metersPerUnit: (number|undefined),
* extent: (ol.Extent|undefined),
* hidpi: (boolean|undefined), * hidpi: (boolean|undefined),
* useOverlay: (boolean|undefined), * useOverlay: (boolean|undefined),
* projection: ol.proj.ProjectionLike, * projection: ol.proj.ProjectionLike,
@@ -3124,13 +3128,6 @@ olx.source.MapGuideOptions.prototype.displayDpi;
olx.source.MapGuideOptions.prototype.metersPerUnit; 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 * Use the `ol.Map#pixelRatio` value when requesting the image from the remote
* server. Default is `true`. * server. Default is `true`.
@@ -3179,7 +3176,6 @@ olx.source.MapGuideOptions.prototype.params;
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* defaultStyle: (Array.<ol.style.Style>|undefined), * defaultStyle: (Array.<ol.style.Style>|undefined),
* doc: (Document|undefined), * doc: (Document|undefined),
* extent: (ol.Extent|undefined),
* logo: (string|olx.LogoOptions|undefined), * logo: (string|olx.LogoOptions|undefined),
* node: (Node|undefined), * node: (Node|undefined),
* projection: ol.proj.ProjectionLike, * projection: ol.proj.ProjectionLike,
@@ -3212,13 +3208,6 @@ olx.source.KMLOptions.prototype.defaultStyle;
olx.source.KMLOptions.prototype.doc; olx.source.KMLOptions.prototype.doc;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.KMLOptions.prototype.extent;
/** /**
* Logo. * Logo.
* @type{string|olx.LogoOptions|undefined} * @type{string|olx.LogoOptions|undefined}
@@ -3285,21 +3274,13 @@ olx.source.MapQuestOptions.prototype.tileLoadFunction;
/** /**
* @typedef {{extent: (ol.Extent|undefined), * @typedef {{projection: ol.proj.ProjectionLike,
* projection: ol.proj.ProjectionLike,
* tileGrid: (ol.tilegrid.TileGrid|undefined)}} * tileGrid: (ol.tilegrid.TileGrid|undefined)}}
* @api * @api
*/ */
olx.source.TileDebugOptions; olx.source.TileDebugOptions;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.TileDebugOptions.prototype.extent;
/** /**
* Projection. * Projection.
* @type {ol.proj.ProjectionLike} * @type {ol.proj.ProjectionLike}
@@ -3365,7 +3346,6 @@ olx.source.OSMOptions.prototype.url;
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* defaultStyle: (Array.<ol.style.Style>|undefined), * defaultStyle: (Array.<ol.style.Style>|undefined),
* doc: (Document|undefined), * doc: (Document|undefined),
* extent: (ol.Extent|undefined),
* logo: (string|olx.LogoOptions|undefined), * logo: (string|olx.LogoOptions|undefined),
* node: (Node|undefined), * node: (Node|undefined),
* projection: ol.proj.ProjectionLike, * projection: ol.proj.ProjectionLike,
@@ -3399,13 +3379,6 @@ olx.source.OSMXMLOptions.prototype.defaultStyle;
olx.source.OSMXMLOptions.prototype.doc; olx.source.OSMXMLOptions.prototype.doc;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.OSMXMLOptions.prototype.extent;
/** /**
* Logo. * Logo.
* @type{string|olx.LogoOptions|undefined} * @type{string|olx.LogoOptions|undefined}
@@ -3458,7 +3431,6 @@ olx.source.OSMXMLOptions.prototype.urls;
/** /**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* canvasFunction: ol.CanvasFunctionType, * canvasFunction: ol.CanvasFunctionType,
* extent: (ol.Extent|undefined),
* logo: (string|olx.LogoOptions|undefined), * logo: (string|olx.LogoOptions|undefined),
* projection: ol.proj.ProjectionLike, * projection: ol.proj.ProjectionLike,
* ratio: (number|undefined), * ratio: (number|undefined),
@@ -3490,13 +3462,6 @@ olx.source.ImageCanvasOptions.prototype.attributions;
olx.source.ImageCanvasOptions.prototype.canvasFunction; olx.source.ImageCanvasOptions.prototype.canvasFunction;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.ImageCanvasOptions.prototype.extent;
/** /**
* Logo. * Logo.
* @type{string|olx.LogoOptions|undefined} * @type{string|olx.LogoOptions|undefined}
@@ -3536,7 +3501,6 @@ olx.source.ImageCanvasOptions.prototype.state;
/** /**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* extent: (ol.Extent|undefined),
* logo: (string|olx.LogoOptions|undefined), * logo: (string|olx.LogoOptions|undefined),
* projection: ol.proj.ProjectionLike, * projection: ol.proj.ProjectionLike,
* ratio: (number|undefined), * ratio: (number|undefined),
@@ -3555,13 +3519,6 @@ olx.source.ImageVectorOptions;
olx.source.ImageVectorOptions.prototype.attributions; olx.source.ImageVectorOptions.prototype.attributions;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.ImageVectorOptions.prototype.extent;
/** /**
* Logo. * Logo.
* @type{string|olx.LogoOptions|undefined} * @type{string|olx.LogoOptions|undefined}
@@ -3610,7 +3567,6 @@ olx.source.ImageVectorOptions.prototype.style;
/** /**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* crossOrigin: (null|string|undefined), * crossOrigin: (null|string|undefined),
* extent: (ol.Extent|undefined),
* hidpi: (boolean|undefined), * hidpi: (boolean|undefined),
* serverType: (ol.source.wms.ServerType|string|undefined), * serverType: (ol.source.wms.ServerType|string|undefined),
* logo: (string|olx.LogoOptions|undefined), * logo: (string|olx.LogoOptions|undefined),
@@ -3638,13 +3594,6 @@ olx.source.ImageWMSOptions.prototype.attributions;
olx.source.ImageWMSOptions.prototype.crossOrigin; 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 * Use the `ol.Map#pixelRatio` value when requesting the image from the remote
* server. Default is `true`. * server. Default is `true`.
@@ -3763,7 +3712,6 @@ olx.source.StamenOptions.prototype.url;
/** /**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* crossOrigin: (null|string|undefined), * crossOrigin: (null|string|undefined),
* extent: (ol.Extent|undefined),
* imageExtent: (ol.Extent|undefined), * imageExtent: (ol.Extent|undefined),
* imageSize: (ol.Size|undefined), * imageSize: (ol.Size|undefined),
* logo: (string|olx.LogoOptions|undefined), * logo: (string|olx.LogoOptions|undefined),
@@ -3788,13 +3736,6 @@ olx.source.ImageStaticOptions.prototype.attributions;
olx.source.ImageStaticOptions.prototype.crossOrigin; olx.source.ImageStaticOptions.prototype.crossOrigin;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.ImageStaticOptions.prototype.extent;
/** /**
* Extent of the image. * Extent of the image.
* @type {ol.Extent|undefined} * @type {ol.Extent|undefined}
@@ -3832,7 +3773,6 @@ olx.source.ImageStaticOptions.prototype.url;
/** /**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* extent: (ol.Extent|undefined),
* format: ol.format.Feature, * format: ol.format.Feature,
* loader: function(this: ol.source.ServerVector, ol.Extent, number, ol.proj.Projection), * loader: function(this: ol.source.ServerVector, ol.Extent, number, ol.proj.Projection),
* strategy: (function(ol.Extent, number): Array.<ol.Extent>|undefined), * strategy: (function(ol.Extent, number): Array.<ol.Extent>|undefined),
@@ -3850,13 +3790,6 @@ olx.source.ServerVectorOptions;
olx.source.ServerVectorOptions.prototype.attributions; olx.source.ServerVectorOptions.prototype.attributions;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.ServerVectorOptions.prototype.extent;
/** /**
* Format. * Format.
* @type {ol.format.Feature} * @type {ol.format.Feature}
@@ -3927,7 +3860,6 @@ olx.source.TileJSONOptions.prototype.url;
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* params: Object.<string,*>, * params: Object.<string,*>,
* crossOrigin: (null|string|undefined), * crossOrigin: (null|string|undefined),
* extent: (ol.Extent|undefined),
* gutter: (number|undefined), * gutter: (number|undefined),
* hidpi: (boolean|undefined), * hidpi: (boolean|undefined),
* logo: (string|olx.LogoOptions|undefined), * logo: (string|olx.LogoOptions|undefined),
@@ -3966,13 +3898,6 @@ olx.source.TileWMSOptions.prototype.params;
olx.source.TileWMSOptions.prototype.crossOrigin; 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 * 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 * this property to a non-zero value, images will be requested that are wider
@@ -4059,7 +3984,6 @@ olx.source.TileWMSOptions.prototype.urls;
/** /**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* extent: (ol.Extent|undefined),
* features: (Array.<ol.Feature>|undefined), * features: (Array.<ol.Feature>|undefined),
* logo: (string|olx.LogoOptions|undefined), * logo: (string|olx.LogoOptions|undefined),
* projection: ol.proj.ProjectionLike, * projection: ol.proj.ProjectionLike,
@@ -4076,13 +4000,6 @@ olx.source.VectorOptions;
olx.source.VectorOptions.prototype.attributions; olx.source.VectorOptions.prototype.attributions;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.VectorOptions.prototype.extent;
/** /**
* Features. * Features.
* @type {Array.<ol.Feature>|undefined} * @type {Array.<ol.Feature>|undefined}
@@ -4115,7 +4032,6 @@ olx.source.VectorOptions.prototype.state;
* @typedef {{arrayBuffer: (ArrayBuffer|undefined), * @typedef {{arrayBuffer: (ArrayBuffer|undefined),
* attributions: (Array.<ol.Attribution>|undefined), * attributions: (Array.<ol.Attribution>|undefined),
* doc: (Document|undefined), * doc: (Document|undefined),
* extent: (ol.Extent|undefined),
* format: ol.format.Feature, * format: ol.format.Feature,
* logo: (string|olx.LogoOptions|undefined), * logo: (string|olx.LogoOptions|undefined),
* node: (Node|undefined), * node: (Node|undefined),
@@ -4150,13 +4066,6 @@ olx.source.StaticVectorOptions.prototype.attributions;
olx.source.StaticVectorOptions.prototype.doc; olx.source.StaticVectorOptions.prototype.doc;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.StaticVectorOptions.prototype.extent;
/** /**
* Format. * Format.
* @type {ol.format.Feature} * @type {ol.format.Feature}
@@ -4216,7 +4125,6 @@ olx.source.StaticVectorOptions.prototype.urls;
/** /**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* crossOrigin: (string|null|undefined), * crossOrigin: (string|null|undefined),
* extent: (ol.Extent|undefined),
* logo: (string|olx.LogoOptions|undefined), * logo: (string|olx.LogoOptions|undefined),
* tileGrid: ol.tilegrid.WMTS, * tileGrid: ol.tilegrid.WMTS,
* projection: ol.proj.ProjectionLike, * projection: ol.proj.ProjectionLike,
@@ -4251,13 +4159,6 @@ olx.source.WMTSOptions.prototype.attributions;
olx.source.WMTSOptions.prototype.crossOrigin; olx.source.WMTSOptions.prototype.crossOrigin;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.WMTSOptions.prototype.extent;
/** /**
* Logo. * Logo.
* @type{string|olx.LogoOptions|undefined} * @type{string|olx.LogoOptions|undefined}
@@ -4369,7 +4270,6 @@ olx.source.WMTSOptions.prototype.urls;
/** /**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* crossOrigin: (null|string|undefined), * crossOrigin: (null|string|undefined),
* extent: (ol.Extent|undefined),
* logo: (string|olx.LogoOptions|undefined), * logo: (string|olx.LogoOptions|undefined),
* projection: ol.proj.ProjectionLike, * projection: ol.proj.ProjectionLike,
* maxZoom: (number|undefined), * maxZoom: (number|undefined),
@@ -4399,13 +4299,6 @@ olx.source.XYZOptions.prototype.attributions;
olx.source.XYZOptions.prototype.crossOrigin; olx.source.XYZOptions.prototype.crossOrigin;
/**
* Extent.
* @type {ol.Extent|undefined}
*/
olx.source.XYZOptions.prototype.extent;
/** /**
* Logo. * Logo.
* @type{string|olx.LogoOptions|undefined} * @type{string|olx.LogoOptions|undefined}
+43 -6
View File
@@ -418,7 +418,11 @@ ol.extent.extendXY = function(extent, x, y) {
* @return {number} Area. * @return {number} Area.
*/ */
ol.extent.getArea = function(extent) { ol.extent.getArea = function(extent) {
return ol.extent.getWidth(extent) * ol.extent.getHeight(extent); var area = 0;
if (!ol.extent.isEmpty(extent)) {
area = ol.extent.getWidth(extent) * ol.extent.getHeight(extent);
}
return area;
}; };
@@ -511,11 +515,44 @@ ol.extent.getHeight = function(extent) {
* @return {number} Intersection area. * @return {number} Intersection area.
*/ */
ol.extent.getIntersectionArea = function(extent1, extent2) { ol.extent.getIntersectionArea = function(extent1, extent2) {
var minX = Math.max(extent1[0], extent2[0]); var intersection = ol.extent.getIntersection(extent1, extent2);
var minY = Math.max(extent1[1], extent2[1]); return ol.extent.getArea(intersection);
var maxX = Math.min(extent1[2], extent2[2]); };
var maxY = Math.min(extent1[3], extent2[3]);
return Math.max(0, maxX - minX) * Math.max(0, maxY - minY);
/**
* Get the intersection of two extents.
* @param {ol.Extent} extent1 Extent 1.
* @param {ol.Extent} extent2 Extent 2.
* @param {ol.Extent=} opt_extent Optional extent to populate with intersection.
* @return {ol.Extent} Intersecting extent.
*/
ol.extent.getIntersection = function(extent1, extent2, opt_extent) {
var intersection = goog.isDef(opt_extent) ?
opt_extent : ol.extent.createEmpty();
if (ol.extent.intersects(extent1, extent2)) {
if (extent1[0] > extent2[0]) {
intersection[0] = extent1[0];
} else {
intersection[0] = extent2[0];
}
if (extent1[1] > extent2[1]) {
intersection[1] = extent1[1];
} else {
intersection[1] = extent2[1];
}
if (extent1[2] < extent2[2]) {
intersection[2] = extent1[2];
} else {
intersection[2] = extent2[2];
}
if (extent1[3] < extent2[3]) {
intersection[3] = extent1[3];
} else {
intersection[3] = extent2[3];
}
}
return intersection;
}; };
+35
View File
@@ -19,6 +19,7 @@ ol.layer.LayerProperty = {
OPACITY: 'opacity', OPACITY: 'opacity',
SATURATION: 'saturation', SATURATION: 'saturation',
VISIBLE: 'visible', VISIBLE: 'visible',
EXTENT: 'extent',
MAX_RESOLUTION: 'maxResolution', MAX_RESOLUTION: 'maxResolution',
MIN_RESOLUTION: 'minResolution' MIN_RESOLUTION: 'minResolution'
}; };
@@ -33,6 +34,7 @@ ol.layer.LayerProperty = {
* saturation: number, * saturation: number,
* sourceState: ol.source.State, * sourceState: ol.source.State,
* visible: boolean, * visible: boolean,
* extent: (ol.Extent|undefined),
* maxResolution: number, * maxResolution: number,
* minResolution: number}} * minResolution: number}}
*/ */
@@ -141,6 +143,7 @@ ol.layer.Base.prototype.getLayerState = function() {
var saturation = this.getSaturation(); var saturation = this.getSaturation();
var sourceState = this.getSourceState(); var sourceState = this.getSourceState();
var visible = this.getVisible(); var visible = this.getVisible();
var extent = this.getExtent();
var maxResolution = this.getMaxResolution(); var maxResolution = this.getMaxResolution();
var minResolution = this.getMinResolution(); var minResolution = this.getMinResolution();
return { return {
@@ -152,6 +155,7 @@ ol.layer.Base.prototype.getLayerState = function() {
saturation: goog.isDef(saturation) ? Math.max(saturation, 0) : 1, saturation: goog.isDef(saturation) ? Math.max(saturation, 0) : 1,
sourceState: sourceState, sourceState: sourceState,
visible: goog.isDef(visible) ? !!visible : true, visible: goog.isDef(visible) ? !!visible : true,
extent: extent,
maxResolution: goog.isDef(maxResolution) ? maxResolution : Infinity, maxResolution: goog.isDef(maxResolution) ? maxResolution : Infinity,
minResolution: goog.isDef(minResolution) ? Math.max(minResolution, 0) : 0 minResolution: goog.isDef(minResolution) ? Math.max(minResolution, 0) : 0
}; };
@@ -174,6 +178,21 @@ ol.layer.Base.prototype.getLayersArray = goog.abstractMethod;
ol.layer.Base.prototype.getLayerStatesArray = goog.abstractMethod; ol.layer.Base.prototype.getLayerStatesArray = goog.abstractMethod;
/**
* @return {ol.Extent|undefined} The layer extent.
* @observable
* @api
*/
ol.layer.Base.prototype.getExtent = function() {
return /** @type {ol.Extent|undefined} */ (
this.get(ol.layer.LayerProperty.EXTENT));
};
goog.exportProperty(
ol.layer.Base.prototype,
'getExtent',
ol.layer.Base.prototype.getExtent);
/** /**
* @return {number|undefined} The maximum resolution of the layer. * @return {number|undefined} The maximum resolution of the layer.
* @observable * @observable
@@ -320,6 +339,22 @@ goog.exportProperty(
ol.layer.Base.prototype.setHue); ol.layer.Base.prototype.setHue);
/**
* Set the extent at which the layer is visible. If `undefined`, the layer
* will be visible at all extents.
* @param {ol.Extent|undefined} extent The extent of the layer.
* @observable
* @api
*/
ol.layer.Base.prototype.setExtent = function(extent) {
this.set(ol.layer.LayerProperty.EXTENT, extent);
};
goog.exportProperty(
ol.layer.Base.prototype,
'setExtent',
ol.layer.Base.prototype.setExtent);
/** /**
* @param {number|undefined} maxResolution The maximum resolution of the layer. * @param {number|undefined} maxResolution The maximum resolution of the layer.
* @observable * @observable
+5
View File
@@ -11,6 +11,7 @@ goog.require('ol.CollectionEvent');
goog.require('ol.CollectionEventType'); goog.require('ol.CollectionEventType');
goog.require('ol.Object'); goog.require('ol.Object');
goog.require('ol.ObjectEventType'); goog.require('ol.ObjectEventType');
goog.require('ol.extent');
goog.require('ol.layer.Base'); goog.require('ol.layer.Base');
goog.require('ol.source.State'); goog.require('ol.source.State');
@@ -211,6 +212,10 @@ ol.layer.Group.prototype.getLayerStatesArray = function(opt_states) {
layerState.maxResolution, ownLayerState.maxResolution); layerState.maxResolution, ownLayerState.maxResolution);
layerState.minResolution = Math.max( layerState.minResolution = Math.max(
layerState.minResolution, ownLayerState.minResolution); layerState.minResolution, ownLayerState.minResolution);
if (goog.isDef(ownLayerState.extent) && goog.isDef(layerState.extent)) {
layerState.extent = ol.extent.getIntersection(
layerState.extent, ownLayerState.extent);
}
} }
return states; return states;
@@ -7,6 +7,7 @@ goog.require('goog.vec.Mat4');
goog.require('ol.ImageBase'); goog.require('ol.ImageBase');
goog.require('ol.ImageState'); goog.require('ol.ImageState');
goog.require('ol.ViewHint'); goog.require('ol.ViewHint');
goog.require('ol.extent');
goog.require('ol.layer.Image'); goog.require('ol.layer.Image');
goog.require('ol.renderer.Map'); goog.require('ol.renderer.Map');
goog.require('ol.renderer.canvas.Layer'); goog.require('ol.renderer.canvas.Layer');
@@ -102,9 +103,16 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame =
var hints = frameState.viewHints; var hints = frameState.viewHints;
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING]) { var renderedExtent = frameState.extent;
if (goog.isDef(layerState.extent)) {
renderedExtent = ol.extent.getIntersection(
renderedExtent, layerState.extent);
}
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING] &&
!ol.extent.isEmpty(renderedExtent)) {
image = imageSource.getImage( image = imageSource.getImage(
frameState.extent, viewResolution, pixelRatio, viewState.projection); renderedExtent, viewResolution, pixelRatio, viewState.projection);
if (!goog.isNull(image)) { if (!goog.isNull(image)) {
var imageState = image.getState(); var imageState = image.getState();
if (imageState == ol.ImageState.IDLE) { if (imageState == ol.ImageState.IDLE) {
@@ -193,6 +193,11 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
} else { } else {
extent = frameState.extent; extent = frameState.extent;
} }
if (goog.isDef(layerState.extent)) {
extent = ol.extent.getIntersection(extent, layerState.extent);
}
var tileRange = tileGrid.getTileRangeForExtentAndResolution( var tileRange = tileGrid.getTileRangeForExtentAndResolution(
extent, tileResolution); extent, tileResolution);
@@ -233,6 +238,11 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
if (z != this.renderedCanvasZ_ || if (z != this.renderedCanvasZ_ ||
!this.renderedCanvasTileRange_.containsTileRange(tileRange)) { !this.renderedCanvasTileRange_.containsTileRange(tileRange)) {
this.renderedCanvasTileRange_ = null; this.renderedCanvasTileRange_ = null;
// Due to limited layer extent, we may be rendering tiles on a small
// portion of the canvas.
if (z < this.renderedCanvasZ_) {
this.context_.clearRect(0, 0, canvasWidth, canvasHeight);
}
} }
} }
} }
+10 -2
View File
@@ -10,6 +10,7 @@ goog.require('ol.ImageBase');
goog.require('ol.ImageState'); goog.require('ol.ImageState');
goog.require('ol.ViewHint'); goog.require('ol.ViewHint');
goog.require('ol.dom'); goog.require('ol.dom');
goog.require('ol.extent');
goog.require('ol.layer.Image'); goog.require('ol.layer.Image');
goog.require('ol.renderer.dom.Layer'); goog.require('ol.renderer.dom.Layer');
goog.require('ol.source.Image'); goog.require('ol.source.Image');
@@ -89,8 +90,15 @@ ol.renderer.dom.ImageLayer.prototype.prepareFrame =
var hints = frameState.viewHints; var hints = frameState.viewHints;
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING]) { var renderedExtent = frameState.extent;
var image_ = imageSource.getImage(frameState.extent, viewResolution, if (goog.isDef(layerState.extent)) {
renderedExtent = ol.extent.getIntersection(
renderedExtent, layerState.extent);
}
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING] &&
!ol.extent.isEmpty(renderedExtent)) {
var image_ = imageSource.getImage(renderedExtent, viewResolution,
frameState.pixelRatio, viewState.projection); frameState.pixelRatio, viewState.projection);
if (!goog.isNull(image_)) { if (!goog.isNull(image_)) {
var imageState = image_.getState(); var imageState = image_.getState();
@@ -109,6 +109,11 @@ ol.renderer.dom.TileLayer.prototype.prepareFrame =
} else { } else {
extent = frameState.extent; extent = frameState.extent;
} }
if (goog.isDef(layerState.extent)) {
extent = ol.extent.getIntersection(extent, layerState.extent);
}
var tileRange = tileGrid.getTileRangeForExtentAndResolution( var tileRange = tileGrid.getTileRangeForExtentAndResolution(
extent, tileResolution); extent, tileResolution);
@@ -10,6 +10,7 @@ goog.require('ol.Extent');
goog.require('ol.ImageBase'); goog.require('ol.ImageBase');
goog.require('ol.ImageState'); goog.require('ol.ImageState');
goog.require('ol.ViewHint'); goog.require('ol.ViewHint');
goog.require('ol.extent');
goog.require('ol.layer.Image'); goog.require('ol.layer.Image');
goog.require('ol.renderer.webgl.Layer'); goog.require('ol.renderer.webgl.Layer');
goog.require('ol.source.Image'); goog.require('ol.source.Image');
@@ -119,8 +120,14 @@ ol.renderer.webgl.ImageLayer.prototype.prepareFrame =
var hints = frameState.viewHints; var hints = frameState.viewHints;
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING]) { var renderedExtent = frameState.extent;
var image_ = imageSource.getImage(frameState.extent, viewResolution, if (goog.isDef(layerState.extent)) {
renderedExtent = ol.extent.getIntersection(
renderedExtent, layerState.extent);
}
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING] &&
!ol.extent.isEmpty(renderedExtent)) {
var image_ = imageSource.getImage(renderedExtent, viewResolution,
frameState.pixelRatio, viewState.projection); frameState.pixelRatio, viewState.projection);
if (!goog.isNull(image_)) { if (!goog.isNull(image_)) {
var imageState = image_.getState(); var imageState = image_.getState();
@@ -207,11 +207,18 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame =
var allTilesLoaded = true; var allTilesLoaded = true;
var tmpExtent = ol.extent.createEmpty(); var tmpExtent = ol.extent.createEmpty();
var tmpTileRange = new ol.TileRange(0, 0, 0, 0); var tmpTileRange = new ol.TileRange(0, 0, 0, 0);
var childTileRange, fullyLoaded, tile, tileState, x, y; var childTileRange, fullyLoaded, tile, tileState, x, y, tileExtent;
for (x = tileRange.minX; x <= tileRange.maxX; ++x) { for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
for (y = tileRange.minY; y <= tileRange.maxY; ++y) { for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
tile = tileSource.getTile(z, x, y, pixelRatio, projection); tile = tileSource.getTile(z, x, y, pixelRatio, projection);
if (goog.isDef(layerState.extent)) {
// ignore tiles outside layer extent
tileExtent = tileGrid.getTileCoordExtent(tile.tileCoord, tmpExtent);
if (!ol.extent.intersects(tileExtent, layerState.extent)) {
continue;
}
}
tileState = tile.getState(); tileState = tile.getState();
if (tileState == ol.TileState.LOADED) { if (tileState == ol.TileState.LOADED) {
if (mapRenderer.isTileTextureLoaded(tile)) { if (mapRenderer.isTileTextureLoaded(tile)) {
@@ -243,7 +250,7 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame =
var zs = goog.array.map(goog.object.getKeys(tilesToDrawByZ), Number); var zs = goog.array.map(goog.object.getKeys(tilesToDrawByZ), Number);
goog.array.sort(zs); goog.array.sort(zs);
var u_tileOffset = goog.vec.Vec4.createFloat32(); var u_tileOffset = goog.vec.Vec4.createFloat32();
var i, ii, sx, sy, tileExtent, tileKey, tilesToDraw, tx, ty; var i, ii, sx, sy, tileKey, tilesToDraw, tx, ty;
for (i = 0, ii = zs.length; i < ii; ++i) { for (i = 0, ii = zs.length; i < ii; ++i) {
tilesToDraw = tilesToDrawByZ[zs[i]]; tilesToDraw = tilesToDrawByZ[zs[i]];
for (tileKey in tilesToDraw) { for (tileKey in tilesToDraw) {
-1
View File
@@ -89,7 +89,6 @@ ol.DebugTile_.prototype.getImage = function(opt_context) {
ol.source.TileDebug = function(options) { ol.source.TileDebug = function(options) {
goog.base(this, { goog.base(this, {
extent: options.extent,
opaque: false, opaque: false,
projection: options.projection, projection: options.projection,
tileGrid: options.tileGrid tileGrid: options.tileGrid
-1
View File
@@ -33,7 +33,6 @@ ol.source.FormatVector = function(options) {
goog.base(this, { goog.base(this, {
attributions: options.attributions, attributions: options.attributions,
extent: options.extent,
logo: options.logo, logo: options.logo,
projection: options.projection projection: options.projection
}); });
-1
View File
@@ -20,7 +20,6 @@ ol.source.ImageCanvas = function(options) {
goog.base(this, { goog.base(this, {
attributions: options.attributions, attributions: options.attributions,
extent: options.extent,
logo: options.logo, logo: options.logo,
projection: options.projection, projection: options.projection,
resolutions: options.resolutions, resolutions: options.resolutions,
-1
View File
@@ -31,7 +31,6 @@ ol.source.ImageStatic = function(options) {
goog.base(this, { goog.base(this, {
attributions: attributions, attributions: attributions,
extent: options.extent,
logo: options.logo, logo: options.logo,
projection: projection, projection: projection,
resolutions: [imageResolution] resolutions: [imageResolution]
-1
View File
@@ -75,7 +75,6 @@ ol.source.ImageVector = function(options) {
goog.base(this, { goog.base(this, {
attributions: options.attributions, attributions: options.attributions,
canvasFunction: goog.bind(this.canvasFunctionInternal_, this), canvasFunction: goog.bind(this.canvasFunctionInternal_, this),
extent: options.extent,
logo: options.logo, logo: options.logo,
projection: options.projection, projection: options.projection,
ratio: options.ratio, ratio: options.ratio,
-1
View File
@@ -31,7 +31,6 @@ ol.source.ImageWMS = function(opt_options) {
goog.base(this, { goog.base(this, {
attributions: options.attributions, attributions: options.attributions,
extent: options.extent,
logo: options.logo, logo: options.logo,
projection: options.projection, projection: options.projection,
resolutions: options.resolutions resolutions: options.resolutions
-1
View File
@@ -22,7 +22,6 @@ ol.source.KML = function(opt_options) {
goog.base(this, { goog.base(this, {
attributions: options.attributions, attributions: options.attributions,
doc: options.doc, doc: options.doc,
extent: options.extent,
format: new ol.format.KML({ format: new ol.format.KML({
defaultStyle: options.defaultStyle defaultStyle: options.defaultStyle
}), }),
-1
View File
@@ -21,7 +21,6 @@ goog.require('ol.source.Image');
ol.source.MapGuide = function(options) { ol.source.MapGuide = function(options) {
goog.base(this, { goog.base(this, {
extent: options.extent,
projection: options.projection, projection: options.projection,
resolutions: options.resolutions resolutions: options.resolutions
}); });
-1
View File
@@ -22,7 +22,6 @@ ol.source.OSMXML = function(opt_options) {
goog.base(this, { goog.base(this, {
attributions: options.attributions, attributions: options.attributions,
doc: options.doc, doc: options.doc,
extent: options.extent,
format: new ol.format.OSMXML(), format: new ol.format.OSMXML(),
logo: options.logo, logo: options.logo,
node: options.node, node: options.node,
-1
View File
@@ -23,7 +23,6 @@ ol.source.ServerVector = function(options) {
goog.base(this, { goog.base(this, {
attributions: options.attributions, attributions: options.attributions,
extent: options.extent,
format: options.format, format: options.format,
logo: options.logo, logo: options.logo,
projection: options.projection projection: options.projection
-25
View File
@@ -22,7 +22,6 @@ ol.source.State = {
/** /**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* extent: (ol.Extent|undefined),
* logo: (string|olx.LogoOptions|undefined), * logo: (string|olx.LogoOptions|undefined),
* projection: ol.proj.ProjectionLike, * projection: ol.proj.ProjectionLike,
* state: (ol.source.State|string|undefined)}} * state: (ol.source.State|string|undefined)}}
@@ -52,14 +51,6 @@ ol.source.Source = function(options) {
*/ */
this.projection_ = ol.proj.get(options.projection); 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 * @private
* @type {Array.<ol.Attribution>} * @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. * @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. * @param {string|olx.LogoOptions|undefined} logo Logo.
*/ */
-1
View File
@@ -22,7 +22,6 @@ ol.source.StaticVector = function(options) {
goog.base(this, { goog.base(this, {
attributions: options.attributions, attributions: options.attributions,
extent: options.extent,
format: options.format, format: options.format,
logo: options.logo, logo: options.logo,
projection: options.projection projection: options.projection
-1
View File
@@ -59,7 +59,6 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function(tileJSON) {
var transform = ol.proj.getTransformFromProjections( var transform = ol.proj.getTransformFromProjections(
epsg4326Projection, this.getProjection()); epsg4326Projection, this.getProjection());
extent = ol.extent.applyTransform(tileJSON.bounds, transform); extent = ol.extent.applyTransform(tileJSON.bounds, transform);
this.setExtent(extent);
} }
if (goog.isDef(tileJSON.scheme)) { if (goog.isDef(tileJSON.scheme)) {
+1 -4
View File
@@ -24,7 +24,6 @@ ol.source.TileVector = function(options) {
goog.base(this, { goog.base(this, {
attributions: options.attributions, attributions: options.attributions,
extent: options.extent,
format: options.format, format: options.format,
logo: options.logo, logo: options.logo,
projection: options.projection projection: options.projection
@@ -48,9 +47,7 @@ ol.source.TileVector = function(options) {
* @private * @private
* @type {ol.TileCoordTransformType} * @type {ol.TileCoordTransformType}
*/ */
this.tileCoordTransform_ = tileGrid.createTileCoordTransform({ this.tileCoordTransform_ = tileGrid.createTileCoordTransform();
extent: options.extent
});
/** /**
* @private * @private
-7
View File
@@ -40,7 +40,6 @@ ol.source.TileWMS = function(opt_options) {
goog.base(this, { goog.base(this, {
attributions: options.attributions, attributions: options.attributions,
crossOrigin: options.crossOrigin, crossOrigin: options.crossOrigin,
extent: options.extent,
logo: options.logo, logo: options.logo,
opaque: !transparent, opaque: !transparent,
projection: options.projection, projection: options.projection,
@@ -394,12 +393,6 @@ ol.source.TileWMS.prototype.tileUrlFunction_ =
tileResolution * gutter, tileExtent); 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) { if (pixelRatio != 1) {
tileSize = (tileSize * pixelRatio + 0.5) | 0; tileSize = (tileSize * pixelRatio + 0.5) | 0;
} }
+1 -1
View File
@@ -54,7 +54,6 @@ ol.source.Vector = function(opt_options) {
goog.base(this, { goog.base(this, {
attributions: options.attributions, attributions: options.attributions,
extent: options.extent,
logo: options.logo, logo: options.logo,
projection: options.projection, projection: options.projection,
state: options.state 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. * @return {ol.Extent} Extent.
* @api * @api
*/ */
+2 -7
View File
@@ -154,13 +154,9 @@ ol.source.WMTS = function(options) {
var x = tileCoord.x; var x = tileCoord.x;
var y = -tileCoord.y - 1; var y = -tileCoord.y - 1;
var tileExtent = tileGrid.getTileCoordExtent(tileCoord); var tileExtent = tileGrid.getTileCoordExtent(tileCoord);
var projectionExtent = projection.getExtent(); var extent = projection.getExtent();
var extent = goog.isDef(options.extent) ?
options.extent : projectionExtent;
if (!goog.isNull(extent) && projection.isGlobal() && if (!goog.isNull(extent) && projection.isGlobal()) {
extent[0] === projectionExtent[0] &&
extent[2] === projectionExtent[2]) {
var numCols = Math.ceil( var numCols = Math.ceil(
ol.extent.getWidth(extent) / ol.extent.getWidth(extent) /
ol.extent.getWidth(tileExtent)); ol.extent.getWidth(tileExtent));
@@ -181,7 +177,6 @@ ol.source.WMTS = function(options) {
goog.base(this, { goog.base(this, {
attributions: options.attributions, attributions: options.attributions,
crossOrigin: options.crossOrigin, crossOrigin: options.crossOrigin,
extent: options.extent,
logo: options.logo, logo: options.logo,
projection: options.projection, projection: options.projection,
tileGrid: tileGrid, tileGrid: tileGrid,
-2
View File
@@ -30,7 +30,6 @@ ol.source.XYZ = function(options) {
goog.base(this, { goog.base(this, {
attributions: options.attributions, attributions: options.attributions,
crossOrigin: options.crossOrigin, crossOrigin: options.crossOrigin,
extent: options.extent,
logo: options.logo, logo: options.logo,
projection: projection, projection: projection,
tileGrid: tileGrid, tileGrid: tileGrid,
@@ -44,7 +43,6 @@ ol.source.XYZ = function(options) {
* @type {ol.TileCoordTransformType} * @type {ol.TileCoordTransformType}
*/ */
this.tileCoordTransform_ = tileGrid.createTileCoordTransform({ this.tileCoordTransform_ = tileGrid.createTileCoordTransform({
extent: options.extent,
wrapX: options.wrapX wrapX: options.wrapX
}); });
+24
View File
@@ -24,6 +24,30 @@ describe('ol.extent', function() {
}); });
describe('getIntersection()', function() {
it('returns the intersection of two extents', function() {
var world = [-180, -90, 180, 90];
var north = [-180, 0, 180, 90];
var farNorth = [-180, 45, 180, 90];
var east = [0, -90, 180, 90];
var farEast = [90, -90, 180, 90];
var south = [-180, -90, 180, 0];
var farSouth = [-180, -90, 180, -45];
var west = [-180, -90, 0, 90];
var farWest = [-180, -90, -90, 90];
var none = ol.extent.createEmpty();
expect(ol.extent.getIntersection(world, none)).to.eql(none);
expect(ol.extent.getIntersection(world, north)).to.eql(north);
expect(ol.extent.getIntersection(world, east)).to.eql(east);
expect(ol.extent.getIntersection(world, south)).to.eql(south);
expect(ol.extent.getIntersection(world, west)).to.eql(west);
expect(ol.extent.getIntersection(farEast, farWest)).to.eql(none);
expect(ol.extent.getIntersection(farNorth, farSouth)).to.eql(none);
expect(ol.extent.getIntersection(north, west)).to.eql([-180, 0, 0, 90]);
expect(ol.extent.getIntersection(east, south)).to.eql([0, -90, 180, 0]);
});
});
describe('containsCoordinate', function() { describe('containsCoordinate', function() {
describe('positive', function() { describe('positive', function() {
+5
View File
@@ -56,6 +56,7 @@ describe('ol.layer.Layer', function() {
saturation: 1, saturation: 1,
visible: true, visible: true,
sourceState: ol.source.State.READY, sourceState: ol.source.State.READY,
extent: undefined,
maxResolution: Infinity, maxResolution: Infinity,
minResolution: 0 minResolution: 0
}); });
@@ -99,6 +100,7 @@ describe('ol.layer.Layer', function() {
saturation: 5, saturation: 5,
visible: false, visible: false,
sourceState: ol.source.State.READY, sourceState: ol.source.State.READY,
extent: undefined,
maxResolution: 500, maxResolution: 500,
minResolution: 0.25 minResolution: 0.25
}); });
@@ -191,6 +193,7 @@ describe('ol.layer.Layer', function() {
saturation: 0.3, saturation: 0.3,
visible: false, visible: false,
sourceState: ol.source.State.READY, sourceState: ol.source.State.READY,
extent: undefined,
maxResolution: 500, maxResolution: 500,
minResolution: 0.25 minResolution: 0.25
}); });
@@ -212,6 +215,7 @@ describe('ol.layer.Layer', function() {
saturation: 0, saturation: 0,
visible: false, visible: false,
sourceState: ol.source.State.READY, sourceState: ol.source.State.READY,
extent: undefined,
maxResolution: Infinity, maxResolution: Infinity,
minResolution: 0 minResolution: 0
}); });
@@ -231,6 +235,7 @@ describe('ol.layer.Layer', function() {
saturation: 42, saturation: 42,
visible: true, visible: true,
sourceState: ol.source.State.READY, sourceState: ol.source.State.READY,
extent: undefined,
maxResolution: Infinity, maxResolution: Infinity,
minResolution: 0 minResolution: 0
}); });
+58
View File
@@ -52,6 +52,7 @@ describe('ol.layer.Group', function() {
saturation: 1, saturation: 1,
visible: true, visible: true,
sourceState: ol.source.State.READY, sourceState: ol.source.State.READY,
extent: undefined,
maxResolution: Infinity, maxResolution: Infinity,
minResolution: 0 minResolution: 0
}); });
@@ -179,6 +180,7 @@ describe('ol.layer.Group', function() {
saturation: 5, saturation: 5,
visible: false, visible: false,
sourceState: ol.source.State.READY, sourceState: ol.source.State.READY,
extent: undefined,
maxResolution: 500, maxResolution: 500,
minResolution: 0.25 minResolution: 0.25
}); });
@@ -190,6 +192,56 @@ describe('ol.layer.Group', function() {
goog.dispose(layerGroup); goog.dispose(layerGroup);
}); });
it('accepts an extent option', function() {
var layer = new ol.layer.Layer({
source: new ol.source.Source({
projection: 'EPSG:4326'
})
});
var groupExtent = [-10, -5, 10, 5];
var layerGroup = new ol.layer.Group({
layers: [layer],
brightness: 0.5,
contrast: 10,
hue: 180,
opacity: 0.5,
saturation: 5,
visible: false,
extent: groupExtent,
maxResolution: 500,
minResolution: 0.25
});
expect(layerGroup.getBrightness()).to.be(0.5);
expect(layerGroup.getContrast()).to.be(10);
expect(layerGroup.getHue()).to.be(180);
expect(layerGroup.getOpacity()).to.be(0.5);
expect(layerGroup.getSaturation()).to.be(5);
expect(layerGroup.getVisible()).to.be(false);
expect(layerGroup.getExtent()).to.eql(groupExtent);
expect(layerGroup.getMaxResolution()).to.be(500);
expect(layerGroup.getMinResolution()).to.be(0.25);
expect(layerGroup.getLayerState()).to.eql({
layer: layerGroup,
brightness: 0.5,
contrast: 10,
hue: 180,
opacity: 0.5,
saturation: 5,
visible: false,
sourceState: ol.source.State.READY,
extent: groupExtent,
maxResolution: 500,
minResolution: 0.25
});
expect(layerGroup.getLayers()).to.be.a(ol.Collection);
expect(layerGroup.getLayers().getLength()).to.be(1);
expect(layerGroup.getLayers().item(0)).to.be(layer);
goog.dispose(layer);
goog.dispose(layerGroup);
});
}); });
describe('#getLayerState', function() { describe('#getLayerState', function() {
@@ -211,6 +263,8 @@ describe('ol.layer.Group', function() {
layerGroup.setOpacity(0.3); layerGroup.setOpacity(0.3);
layerGroup.setSaturation(0.3); layerGroup.setSaturation(0.3);
layerGroup.setVisible(false); layerGroup.setVisible(false);
var groupExtent = [-100, 50, 100, 50];
layerGroup.setExtent(groupExtent);
layerGroup.setMaxResolution(500); layerGroup.setMaxResolution(500);
layerGroup.setMinResolution(0.25); layerGroup.setMinResolution(0.25);
expect(layerGroup.getLayerState()).to.eql({ expect(layerGroup.getLayerState()).to.eql({
@@ -222,6 +276,7 @@ describe('ol.layer.Group', function() {
saturation: 0.3, saturation: 0.3,
visible: false, visible: false,
sourceState: ol.source.State.READY, sourceState: ol.source.State.READY,
extent: groupExtent,
maxResolution: 500, maxResolution: 500,
minResolution: 0.25 minResolution: 0.25
}); });
@@ -243,6 +298,7 @@ describe('ol.layer.Group', function() {
saturation: 0, saturation: 0,
visible: false, visible: false,
sourceState: ol.source.State.READY, sourceState: ol.source.State.READY,
extent: undefined,
maxResolution: Infinity, maxResolution: Infinity,
minResolution: 0 minResolution: 0
}); });
@@ -262,6 +318,7 @@ describe('ol.layer.Group', function() {
saturation: 42, saturation: 42,
visible: true, visible: true,
sourceState: ol.source.State.READY, sourceState: ol.source.State.READY,
extent: undefined,
maxResolution: Infinity, maxResolution: Infinity,
minResolution: 0 minResolution: 0
}); });
@@ -384,6 +441,7 @@ describe('ol.layer.Group', function() {
saturation: 25, saturation: 25,
visible: false, visible: false,
sourceState: ol.source.State.READY, sourceState: ol.source.State.READY,
extent: undefined,
maxResolution: 150, maxResolution: 150,
minResolution: 0.25 minResolution: 0.25
}); });
+14 -10
View File
@@ -20,7 +20,8 @@ describe('ol.source.Tile', function() {
var loadedTilesByZ = {}; var loadedTilesByZ = {};
var grid = source.getTileGrid(); var grid = source.getTileGrid();
var range = grid.getTileRangeForExtentAndZ(source.getExtent(), 3); var extent = [-180, -180, 180, 180];
var range = grid.getTileRangeForExtentAndZ(extent, 3);
function getTileIfLoaded(z, x, y) { function getTileIfLoaded(z, x, y) {
var tile = source.getTile(z, x, y); var tile = source.getTile(z, x, y);
@@ -42,7 +43,8 @@ describe('ol.source.Tile', function() {
var loadedTilesByZ = {}; var loadedTilesByZ = {};
var grid = source.getTileGrid(); var grid = source.getTileGrid();
var range = grid.getTileRangeForExtentAndZ(source.getExtent(), 0); var extent = [-180, -180, 180, 180];
var range = grid.getTileRangeForExtentAndZ(extent, 0);
function getTileIfLoaded(z, x, y) { function getTileIfLoaded(z, x, y) {
var tile = source.getTile(z, x, y); var tile = source.getTile(z, x, y);
@@ -66,7 +68,8 @@ describe('ol.source.Tile', function() {
var loadedTilesByZ = {}; var loadedTilesByZ = {};
var grid = source.getTileGrid(); var grid = source.getTileGrid();
var range = grid.getTileRangeForExtentAndZ(source.getExtent(), 1); var extent = [-180, -180, 180, 180];
var range = grid.getTileRangeForExtentAndZ(extent, 1);
function getTileIfLoaded(z, x, y) { function getTileIfLoaded(z, x, y) {
var tile = source.getTile(z, x, y); var tile = source.getTile(z, x, y);
@@ -92,7 +95,8 @@ describe('ol.source.Tile', function() {
var loadedTilesByZ = {}; var loadedTilesByZ = {};
var grid = source.getTileGrid(); var grid = source.getTileGrid();
var range = grid.getTileRangeForExtentAndZ(source.getExtent(), 1); var extent = [-180, -180, 180, 180];
var range = grid.getTileRangeForExtentAndZ(extent, 1);
function getTileIfLoaded(z, x, y) { function getTileIfLoaded(z, x, y) {
var tile = source.getTile(z, x, y); var tile = source.getTile(z, x, y);
return (!goog.isNull(tile) && tile.getState() === ol.TileState.LOADED) ? return (!goog.isNull(tile) && tile.getState() === ol.TileState.LOADED) ?
@@ -117,7 +121,8 @@ describe('ol.source.Tile', function() {
} }
}; };
var grid = source.getTileGrid(); var grid = source.getTileGrid();
var range = grid.getTileRangeForExtentAndZ(source.getExtent(), 1); var extent = [-180, -180, 180, 180];
var range = grid.getTileRangeForExtentAndZ(extent, 1);
function getTileIfLoaded(z, x, y) { function getTileIfLoaded(z, x, y) {
var tile = source.getTile(z, x, y); var tile = source.getTile(z, x, y);
@@ -140,7 +145,8 @@ describe('ol.source.Tile', function() {
var loadedTilesByZ = {}; var loadedTilesByZ = {};
var grid = source.getTileGrid(); var grid = source.getTileGrid();
var range = grid.getTileRangeForExtentAndZ(source.getExtent(), 1); var extent = [-180, -180, 180, 180];
var range = grid.getTileRangeForExtentAndZ(extent, 1);
function getTileIfLoaded(z, x, y) { function getTileIfLoaded(z, x, y) {
var tile = source.getTile(z, x, y); var tile = source.getTile(z, x, y);
@@ -165,7 +171,8 @@ describe('ol.source.Tile', function() {
} }
}; };
var grid = source.getTileGrid(); var grid = source.getTileGrid();
var range = grid.getTileRangeForExtentAndZ(source.getExtent(), 1); var extent = [-180, -180, 180, 180];
var range = grid.getTileRangeForExtentAndZ(extent, 1);
function getTileIfLoaded(z, x, y) { function getTileIfLoaded(z, x, y) {
var tile = source.getTile(z, x, y); var tile = source.getTile(z, x, y);
@@ -192,16 +199,13 @@ describe('ol.source.Tile', function() {
* @param {Object.<string, boolean>} loaded Lookup of already loaded tiles. * @param {Object.<string, boolean>} loaded Lookup of already loaded tiles.
*/ */
ol.test.source.TileMock = function(loaded) { ol.test.source.TileMock = function(loaded) {
var extent = [-180, -180, 180, 180];
var tileGrid = new ol.tilegrid.TileGrid({ var tileGrid = new ol.tilegrid.TileGrid({
resolutions: [360 / 256, 180 / 256, 90 / 256, 45 / 256], resolutions: [360 / 256, 180 / 256, 90 / 256, 45 / 256],
extent: extent,
origin: [-180, -180], origin: [-180, -180],
tileSize: 256 tileSize: 256
}); });
goog.base(this, { goog.base(this, {
extent: extent,
projection: ol.proj.get('EPSG:4326'), projection: ol.proj.get('EPSG:4326'),
tileGrid: tileGrid tileGrid: tileGrid
}); });
-16
View File
@@ -126,22 +126,6 @@ describe('ol.source.TileWMS', function() {
expect(queryData.get('BBOX')).to.be('-45,-45,0,0'); 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() { describe('#getGetFeatureInfo', function() {