Rename ol.extent.transform to ol.extent.applyTransform
This gives more consistency with ol.proj.applyTransform, allowing us to add a more convenient ol.extent.transform method that takes projection-like arguments.
This commit is contained in:
@@ -714,13 +714,15 @@ ol.extent.touches = function(extent1, extent2) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Apply a transform function to the extent.
|
||||||
* @param {ol.Extent} extent Extent.
|
* @param {ol.Extent} extent Extent.
|
||||||
* @param {ol.TransformFunction} transformFn Transform function.
|
* @param {ol.TransformFunction} transformFn Transform function. Called with
|
||||||
|
* [minX, minY, maxX, maxY] extent coordinates.
|
||||||
* @param {ol.Extent=} opt_extent Destination extent.
|
* @param {ol.Extent=} opt_extent Destination extent.
|
||||||
* @return {ol.Extent} Extent.
|
* @return {ol.Extent} Extent.
|
||||||
* @todo api
|
* @todo api
|
||||||
*/
|
*/
|
||||||
ol.extent.transform = function(extent, transformFn, opt_extent) {
|
ol.extent.applyTransform = function(extent, transformFn, opt_extent) {
|
||||||
var coordinates = [
|
var coordinates = [
|
||||||
extent[0], extent[1],
|
extent[0], extent[1],
|
||||||
extent[0], extent[3],
|
extent[0], extent[3],
|
||||||
|
|||||||
@@ -139,7 +139,8 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
|||||||
var maxZ = coverageArea.zoomMax;
|
var maxZ = coverageArea.zoomMax;
|
||||||
var bbox = coverageArea.bbox;
|
var bbox = coverageArea.bbox;
|
||||||
var epsg4326Extent = [bbox[1], bbox[0], bbox[3], bbox[2]];
|
var epsg4326Extent = [bbox[1], bbox[0], bbox[3], bbox[2]];
|
||||||
var extent = ol.extent.transform(epsg4326Extent, transform);
|
var extent = ol.extent.applyTransform(
|
||||||
|
epsg4326Extent, transform);
|
||||||
var tileRange, z, zKey;
|
var tileRange, z, zKey;
|
||||||
for (z = minZ; z <= maxZ; ++z) {
|
for (z = minZ; z <= maxZ; ++z) {
|
||||||
zKey = z.toString();
|
zKey = z.toString();
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function(tileJSON) {
|
|||||||
if (goog.isDef(tileJSON.bounds)) {
|
if (goog.isDef(tileJSON.bounds)) {
|
||||||
var transform = ol.proj.getTransformFromProjections(
|
var transform = ol.proj.getTransformFromProjections(
|
||||||
epsg4326Projection, this.getProjection());
|
epsg4326Projection, this.getProjection());
|
||||||
extent = ol.extent.transform(tileJSON.bounds, transform);
|
extent = ol.extent.applyTransform(tileJSON.bounds, transform);
|
||||||
this.setExtent(extent);
|
this.setExtent(extent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -425,12 +425,13 @@ describe('ol.extent', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('transform', function() {
|
describe('#applyTransform()', function() {
|
||||||
|
|
||||||
it('does transform', function() {
|
it('does transform', function() {
|
||||||
var transformFn = ol.proj.getTransform('EPSG:4326', 'EPSG:3857');
|
var transformFn = ol.proj.getTransform('EPSG:4326', 'EPSG:3857');
|
||||||
var sourceExtent = [-15, -30, 45, 60];
|
var sourceExtent = [-15, -30, 45, 60];
|
||||||
var destinationExtent = ol.extent.transform(sourceExtent, transformFn);
|
var destinationExtent = ol.extent.applyTransform(
|
||||||
|
sourceExtent, transformFn);
|
||||||
expect(destinationExtent).not.to.be(undefined);
|
expect(destinationExtent).not.to.be(undefined);
|
||||||
expect(destinationExtent).not.to.be(null);
|
expect(destinationExtent).not.to.be(null);
|
||||||
// FIXME check values with third-party tool
|
// FIXME check values with third-party tool
|
||||||
@@ -456,7 +457,8 @@ describe('ol.extent', function() {
|
|||||||
return output;
|
return output;
|
||||||
};
|
};
|
||||||
var sourceExtent = [-15, -30, 45, 60];
|
var sourceExtent = [-15, -30, 45, 60];
|
||||||
var destinationExtent = ol.extent.transform(sourceExtent, transformFn);
|
var destinationExtent = ol.extent.applyTransform(
|
||||||
|
sourceExtent, transformFn);
|
||||||
expect(destinationExtent).not.to.be(undefined);
|
expect(destinationExtent).not.to.be(undefined);
|
||||||
expect(destinationExtent).not.to.be(null);
|
expect(destinationExtent).not.to.be(null);
|
||||||
expect(destinationExtent[0]).to.be(-45);
|
expect(destinationExtent[0]).to.be(-45);
|
||||||
|
|||||||
Reference in New Issue
Block a user