Source updates for new extent structure
This commit is contained in:
@@ -20,7 +20,7 @@ ol.source.ImageStatic = function(options) {
|
|||||||
|
|
||||||
var imageExtent = options.imageExtent;
|
var imageExtent = options.imageExtent;
|
||||||
var imageSize = options.imageSize;
|
var imageSize = options.imageSize;
|
||||||
var imageResolution = (imageExtent[3] - imageExtent[2]) / imageSize[1];
|
var imageResolution = (imageExtent[1][1] - imageExtent[0][1]) / imageSize[1];
|
||||||
var projection = ol.proj.get(options.projection);
|
var projection = ol.proj.get(options.projection);
|
||||||
|
|
||||||
goog.base(this, {
|
goog.base(this, {
|
||||||
|
|||||||
@@ -89,8 +89,8 @@ ol.source.ImageWMS.prototype.getImage =
|
|||||||
|
|
||||||
extent = extent.slice();
|
extent = extent.slice();
|
||||||
ol.extent.scaleFromCenter(extent, this.ratio_);
|
ol.extent.scaleFromCenter(extent, this.ratio_);
|
||||||
var width = (extent[1] - extent[0]) / resolution;
|
var width = (extent[1][0] - extent[0][0]) / resolution;
|
||||||
var height = (extent[3] - extent[2]) / resolution;
|
var height = (extent[1][1] - extent[0][1]) / resolution;
|
||||||
var size = [width, height];
|
var size = [width, height];
|
||||||
|
|
||||||
this.image_ = this.createImage(extent, resolution, size, projection);
|
this.image_ = this.createImage(extent, resolution, size, projection);
|
||||||
|
|||||||
@@ -69,15 +69,15 @@ goog.inherits(ol.source.TileJSON, ol.source.TileImage);
|
|||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.source.TileJSON.prototype.handleTileJSONResponse = function() {
|
ol.source.TileJSON.prototype.handleTileJSONResponse = function() {
|
||||||
|
|
||||||
var tileJSON = ol.tilejson.grids_.pop();
|
var tileJSON = ol.tilejson.grids_.pop();
|
||||||
|
|
||||||
var epsg4326Projection = ol.proj.get('EPSG:4326');
|
var epsg4326Projection = ol.proj.get('EPSG:4326');
|
||||||
|
|
||||||
var extent;
|
var extent;
|
||||||
if (goog.isDef(tileJSON.bounds)) {
|
if (goog.isDef(tileJSON.bounds)) {
|
||||||
var bounds = tileJSON.bounds;
|
var epsg4326Extent = [
|
||||||
var epsg4326Extent = [bounds[0], bounds[2], bounds[1], bounds[3]];
|
tileJSON.bounds.slice(0, 2), tileJSON.bounds.slice(2)
|
||||||
|
];
|
||||||
var transform = ol.proj.getTransformFromProjections(
|
var transform = ol.proj.getTransformFromProjections(
|
||||||
epsg4326Projection, this.getProjection());
|
epsg4326Projection, this.getProjection());
|
||||||
extent = ol.extent.transform(epsg4326Extent, transform);
|
extent = ol.extent.transform(epsg4326Extent, transform);
|
||||||
|
|||||||
@@ -75,10 +75,11 @@ ol.source.TileWMS = function(options) {
|
|||||||
extent = goog.isDef(extent) ? extent : projectionExtent;
|
extent = goog.isDef(extent) ? extent : projectionExtent;
|
||||||
|
|
||||||
if (!goog.isNull(extent) && projection.isGlobal() &&
|
if (!goog.isNull(extent) && projection.isGlobal() &&
|
||||||
extent[0] === projectionExtent[0] &&
|
extent[0][0] === projectionExtent[0][0] &&
|
||||||
extent[1] === projectionExtent[1]) {
|
extent[1][0] === projectionExtent[1][0]) {
|
||||||
var numCols = Math.ceil(
|
var numCols = Math.ceil(
|
||||||
(extent[1] - extent[0]) / (tileExtent[1] - tileExtent[0]));
|
(extent[1][0] - extent[0][0]) /
|
||||||
|
(tileExtent[1][0] - tileExtent[0][0]));
|
||||||
x = goog.math.modulo(x, numCols);
|
x = goog.math.modulo(x, numCols);
|
||||||
tileExtent = tileGrid.getTileCoordExtent(
|
tileExtent = tileGrid.getTileCoordExtent(
|
||||||
new ol.TileCoord(tileCoord.z, x, tileCoord.y));
|
new ol.TileCoord(tileCoord.z, x, tileCoord.y));
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ ol.source.wms.getUrl =
|
|||||||
|
|
||||||
var axisOrientation = projection.getAxisOrientation();
|
var axisOrientation = projection.getAxisOrientation();
|
||||||
var bboxValues = (wms13 && axisOrientation.substr(0, 2) == 'ne') ?
|
var bboxValues = (wms13 && axisOrientation.substr(0, 2) == 'ne') ?
|
||||||
[extent[2], extent[0], extent[3], extent[1]] :
|
[extent[0][1], extent[0][0], extent[1][1], extent[1][0]] :
|
||||||
[extent[0], extent[2], extent[1], extent[3]];
|
[extent[0][0], extent[0][1], extent[1][0], extent[1][1]];
|
||||||
baseParams['BBOX'] = bboxValues.join(',');
|
baseParams['BBOX'] = bboxValues.join(',');
|
||||||
|
|
||||||
return goog.uri.utils.appendParamsFromMap(baseUrl, baseParams);
|
return goog.uri.utils.appendParamsFromMap(baseUrl, baseParams);
|
||||||
|
|||||||
@@ -154,10 +154,11 @@ ol.source.WMTS = function(options) {
|
|||||||
options.extent : projectionExtent;
|
options.extent : projectionExtent;
|
||||||
|
|
||||||
if (!goog.isNull(extent) && projection.isGlobal() &&
|
if (!goog.isNull(extent) && projection.isGlobal() &&
|
||||||
extent[0] === projectionExtent[0] &&
|
extent[0][0] === projectionExtent[0][0] &&
|
||||||
extent[1] === projectionExtent[1]) {
|
extent[1][0] === projectionExtent[1][0]) {
|
||||||
var numCols = Math.ceil(
|
var numCols = Math.ceil(
|
||||||
(extent[1] - extent[0]) / (tileExtent[1] - tileExtent[0]));
|
(extent[1][0] - extent[0][0]) /
|
||||||
|
(tileExtent[1][0] - tileExtent[0][0]));
|
||||||
x = goog.math.modulo(x, numCols);
|
x = goog.math.modulo(x, numCols);
|
||||||
tmpTileCoord.z = tileCoord.z;
|
tmpTileCoord.z = tileCoord.z;
|
||||||
tmpTileCoord.x = x;
|
tmpTileCoord.x = x;
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ 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 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,
|
extent: extent,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ describe('ol.source.Vector', function() {
|
|||||||
var layer = new ol.layer.Vector({
|
var layer = new ol.layer.Vector({
|
||||||
source: source
|
source: source
|
||||||
});
|
});
|
||||||
source.prepareFeatures(layer, [-180, 180, -90, 90],
|
source.prepareFeatures(layer, [[-180, -90], [180, 90]],
|
||||||
ol.proj.get('EPSG:4326'),
|
ol.proj.get('EPSG:4326'),
|
||||||
function() {
|
function() {
|
||||||
expect(source.loadState_).to.be(ol.source.VectorLoadState.LOADED);
|
expect(source.loadState_).to.be(ol.source.VectorLoadState.LOADED);
|
||||||
@@ -66,7 +66,7 @@ describe('ol.source.Vector', function() {
|
|||||||
var layer = new ol.layer.Vector({
|
var layer = new ol.layer.Vector({
|
||||||
source: source
|
source: source
|
||||||
});
|
});
|
||||||
source.prepareFeatures(layer, [-180, 180, -90, 90],
|
source.prepareFeatures(layer, [[-180, -90], [180, 90]],
|
||||||
ol.proj.get('EPSG:4326'),
|
ol.proj.get('EPSG:4326'),
|
||||||
function() {
|
function() {
|
||||||
expect(source.loadState_).to.be(ol.source.VectorLoadState.LOADED);
|
expect(source.loadState_).to.be(ol.source.VectorLoadState.LOADED);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ describe('ol.source.wms', function() {
|
|||||||
describe('ol.source.wms.getUrl', function() {
|
describe('ol.source.wms.getUrl', function() {
|
||||||
it('creates expected URL', function() {
|
it('creates expected URL', function() {
|
||||||
var epsg3857 = ol.proj.get('EPSG:3857');
|
var epsg3857 = ol.proj.get('EPSG:3857');
|
||||||
var extent = [-20037508.342789244, 0, -20037508.342789244, 0];
|
var extent = [[-20037508.342789244, -20037508.342789244], [0, 0]];
|
||||||
var expected = 'http://wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=' +
|
var expected = 'http://wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=' +
|
||||||
'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' +
|
'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' +
|
||||||
'foo=bar&STYLES=&CRS=EPSG%3A3857&BBOX=' +
|
'foo=bar&STYLES=&CRS=EPSG%3A3857&BBOX=' +
|
||||||
@@ -16,7 +16,7 @@ describe('ol.source.wms', function() {
|
|||||||
});
|
});
|
||||||
it('creates expected URL respecting axis orientation', function() {
|
it('creates expected URL respecting axis orientation', function() {
|
||||||
var epsg4326 = ol.proj.get('EPSG:4326');
|
var epsg4326 = ol.proj.get('EPSG:4326');
|
||||||
var extent = [-180, 0, -90, 90];
|
var extent = [[-180, -90], [0, 90]];
|
||||||
var expected = 'http://wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=' +
|
var expected = 'http://wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=' +
|
||||||
'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' +
|
'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' +
|
||||||
'foo=bar&STYLES=&CRS=EPSG%3A4326&BBOX=-90%2C-180%2C90%2C0';
|
'foo=bar&STYLES=&CRS=EPSG%3A4326&BBOX=-90%2C-180%2C90%2C0';
|
||||||
|
|||||||
Reference in New Issue
Block a user