Source updates for new extent structure

This commit is contained in:
Tim Schaub
2013-09-03 17:50:33 -06:00
parent a670b7979c
commit 75cb19d7e1
9 changed files with 21 additions and 19 deletions

View File

@@ -20,7 +20,7 @@ ol.source.ImageStatic = function(options) {
var imageExtent = options.imageExtent;
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);
goog.base(this, {

View File

@@ -89,8 +89,8 @@ ol.source.ImageWMS.prototype.getImage =
extent = extent.slice();
ol.extent.scaleFromCenter(extent, this.ratio_);
var width = (extent[1] - extent[0]) / resolution;
var height = (extent[3] - extent[2]) / resolution;
var width = (extent[1][0] - extent[0][0]) / resolution;
var height = (extent[1][1] - extent[0][1]) / resolution;
var size = [width, height];
this.image_ = this.createImage(extent, resolution, size, projection);

View File

@@ -69,15 +69,15 @@ goog.inherits(ol.source.TileJSON, ol.source.TileImage);
* @protected
*/
ol.source.TileJSON.prototype.handleTileJSONResponse = function() {
var tileJSON = ol.tilejson.grids_.pop();
var epsg4326Projection = ol.proj.get('EPSG:4326');
var extent;
if (goog.isDef(tileJSON.bounds)) {
var bounds = tileJSON.bounds;
var epsg4326Extent = [bounds[0], bounds[2], bounds[1], bounds[3]];
var epsg4326Extent = [
tileJSON.bounds.slice(0, 2), tileJSON.bounds.slice(2)
];
var transform = ol.proj.getTransformFromProjections(
epsg4326Projection, this.getProjection());
extent = ol.extent.transform(epsg4326Extent, transform);

View File

@@ -75,10 +75,11 @@ ol.source.TileWMS = function(options) {
extent = goog.isDef(extent) ? extent : projectionExtent;
if (!goog.isNull(extent) && projection.isGlobal() &&
extent[0] === projectionExtent[0] &&
extent[1] === projectionExtent[1]) {
extent[0][0] === projectionExtent[0][0] &&
extent[1][0] === projectionExtent[1][0]) {
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);
tileExtent = tileGrid.getTileCoordExtent(
new ol.TileCoord(tileCoord.z, x, tileCoord.y));

View File

@@ -54,8 +54,8 @@ ol.source.wms.getUrl =
var axisOrientation = projection.getAxisOrientation();
var bboxValues = (wms13 && axisOrientation.substr(0, 2) == 'ne') ?
[extent[2], extent[0], extent[3], extent[1]] :
[extent[0], extent[2], extent[1], extent[3]];
[extent[0][1], extent[0][0], extent[1][1], extent[1][0]] :
[extent[0][0], extent[0][1], extent[1][0], extent[1][1]];
baseParams['BBOX'] = bboxValues.join(',');
return goog.uri.utils.appendParamsFromMap(baseUrl, baseParams);

View File

@@ -154,10 +154,11 @@ ol.source.WMTS = function(options) {
options.extent : projectionExtent;
if (!goog.isNull(extent) && projection.isGlobal() &&
extent[0] === projectionExtent[0] &&
extent[1] === projectionExtent[1]) {
extent[0][0] === projectionExtent[0][0] &&
extent[1][0] === projectionExtent[1][0]) {
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);
tmpTileCoord.z = tileCoord.z;
tmpTileCoord.x = x;

View File

@@ -192,7 +192,7 @@ describe('ol.source.Tile', function() {
* @param {Object.<string, boolean>} loaded Lookup of already loaded tiles.
*/
ol.test.source.TileMock = function(loaded) {
var extent = [-180, 180, -180, 180];
var extent = [[-180, -180], [180, 180]];
var tileGrid = new ol.tilegrid.TileGrid({
resolutions: [360 / 256, 180 / 256, 90 / 256, 45 / 256],
extent: extent,

View File

@@ -20,7 +20,7 @@ describe('ol.source.Vector', function() {
var layer = new ol.layer.Vector({
source: source
});
source.prepareFeatures(layer, [-180, 180, -90, 90],
source.prepareFeatures(layer, [[-180, -90], [180, 90]],
ol.proj.get('EPSG:4326'),
function() {
expect(source.loadState_).to.be(ol.source.VectorLoadState.LOADED);
@@ -66,7 +66,7 @@ describe('ol.source.Vector', function() {
var layer = new ol.layer.Vector({
source: source
});
source.prepareFeatures(layer, [-180, 180, -90, 90],
source.prepareFeatures(layer, [[-180, -90], [180, 90]],
ol.proj.get('EPSG:4326'),
function() {
expect(source.loadState_).to.be(ol.source.VectorLoadState.LOADED);

View File

@@ -5,7 +5,7 @@ describe('ol.source.wms', function() {
describe('ol.source.wms.getUrl', function() {
it('creates expected URL', function() {
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=' +
'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' +
'foo=bar&STYLES=&CRS=EPSG%3A3857&BBOX=' +
@@ -16,7 +16,7 @@ describe('ol.source.wms', function() {
});
it('creates expected URL respecting axis orientation', function() {
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=' +
'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' +
'foo=bar&STYLES=&CRS=EPSG%3A4326&BBOX=-90%2C-180%2C90%2C0';