Merge pull request #272 from twpayne/projection-get
allow people to specify projection as a string
This commit is contained in:
@@ -25,7 +25,7 @@ var map = new ol.Map({
|
||||
// Vienna label
|
||||
var vienna = new ol.AnchoredElement({
|
||||
map: map,
|
||||
position: ol.projection.transformWithCodes(
|
||||
position: ol.projection.transform(
|
||||
new ol.Coordinate(16.3725, 48.208889), 'EPSG:4326', 'EPSG:3857'),
|
||||
element: document.getElementById('vienna')
|
||||
});
|
||||
@@ -39,7 +39,7 @@ map.addEventListener('click', function(evt) {
|
||||
var coordinate = evt.getCoordinate();
|
||||
popup.getElement().innerHTML =
|
||||
'Welcome to ol3. The location you clicked was<br>' +
|
||||
ol.Coordinate.toStringHDMS(ol.projection.transformWithCodes(
|
||||
ol.Coordinate.toStringHDMS(ol.projection.transform(
|
||||
coordinate, 'EPSG:3857', 'EPSG:4326'));
|
||||
popup.setPosition(coordinate);
|
||||
});
|
||||
|
||||
@@ -9,15 +9,15 @@ goog.require('ol.projection');
|
||||
goog.require('ol.source.OpenStreetMap');
|
||||
|
||||
|
||||
var london = ol.projection.transformWithCodes(
|
||||
var london = ol.projection.transform(
|
||||
new ol.Coordinate(-0.12755, 51.507222), 'EPSG:4326', 'EPSG:3857');
|
||||
var moscow = ol.projection.transformWithCodes(
|
||||
var moscow = ol.projection.transform(
|
||||
new ol.Coordinate(37.6178, 55.7517), 'EPSG:4326', 'EPSG:3857');
|
||||
var instanbul = ol.projection.transformWithCodes(
|
||||
var instanbul = ol.projection.transform(
|
||||
new ol.Coordinate(28.9744, 41.0128), 'EPSG:4326', 'EPSG:3857');
|
||||
var rome = ol.projection.transformWithCodes(
|
||||
var rome = ol.projection.transform(
|
||||
new ol.Coordinate(12.5, 41.9), 'EPSG:4326', 'EPSG:3857');
|
||||
var bern = ol.projection.transformWithCodes(
|
||||
var bern = ol.projection.transform(
|
||||
new ol.Coordinate(7.4458, 46.95), 'EPSG:4326', 'EPSG:3857');
|
||||
|
||||
var map = new ol.Map({
|
||||
|
||||
@@ -19,7 +19,7 @@ var map = new ol.Map({
|
||||
renderers: ol.RendererHints.createFromQueryData(),
|
||||
target: 'map',
|
||||
view: new ol.View2D({
|
||||
center: ol.projection.transformWithCodes(
|
||||
center: ol.projection.transform(
|
||||
new ol.Coordinate(-123.1, 49.25), 'EPSG:4326', 'EPSG:3857'),
|
||||
zoom: 8
|
||||
})
|
||||
|
||||
@@ -15,7 +15,7 @@ var layers = [
|
||||
}),
|
||||
new ol.layer.TileLayer({
|
||||
source: new ol.source.DebugTileSource({
|
||||
projection: ol.projection.getFromCode('EPSG:3857'),
|
||||
projection: 'EPSG:3857',
|
||||
tileGrid: new ol.tilegrid.XYZ({
|
||||
maxZoom: 22
|
||||
})
|
||||
@@ -25,7 +25,7 @@ var layers = [
|
||||
|
||||
var webglMap = new ol.Map({
|
||||
view: new ol.View2D({
|
||||
center: ol.projection.transformWithCodes(
|
||||
center: ol.projection.transform(
|
||||
new ol.Coordinate(-0.1275, 51.507222), 'EPSG:4326', 'EPSG:3857'),
|
||||
zoom: 10
|
||||
}),
|
||||
|
||||
@@ -35,7 +35,7 @@ var map = new ol.Map({
|
||||
renderers: [ol.RendererHint.CANVAS, ol.RendererHint.DOM],
|
||||
target: 'map',
|
||||
view: new ol.View2D({
|
||||
projection: ol.projection.getFromCode('EPSG:4326'),
|
||||
projection: 'EPSG:4326',
|
||||
center: new ol.Coordinate(0, 0),
|
||||
zoom: 2
|
||||
})
|
||||
|
||||
@@ -16,7 +16,7 @@ var map = new ol.Map({
|
||||
renderers: ol.RendererHints.createFromQueryData(),
|
||||
target: 'map',
|
||||
view: new ol.View2D({
|
||||
center: ol.projection.transformWithCodes(
|
||||
center: ol.projection.transform(
|
||||
new ol.Coordinate(139.6917, 35.689506), 'EPSG:4326', 'EPSG:3857'),
|
||||
zoom: 9
|
||||
})
|
||||
|
||||
@@ -13,7 +13,7 @@ var map = new ol.Map({
|
||||
controls: ol.control.defaults({}, [
|
||||
new ol.control.MousePosition({
|
||||
coordinateFormat: ol.Coordinate.toStringHDMS,
|
||||
projection: ol.projection.getFromCode('EPSG:4326'),
|
||||
projection: 'EPSG:4326',
|
||||
target: document.getElementById('mouse-position'),
|
||||
undefinedHTML: ' '
|
||||
})
|
||||
|
||||
@@ -11,9 +11,9 @@ goog.require('ol.projection');
|
||||
goog.require('ol.source.MapQuestOpenAerial');
|
||||
|
||||
|
||||
var LONDON = ol.projection.transformWithCodes(
|
||||
var LONDON = ol.projection.transform(
|
||||
new ol.Coordinate(-0.12755, 51.507222), 'EPSG:4326', 'EPSG:3857');
|
||||
var MOSCOW = ol.projection.transformWithCodes(
|
||||
var MOSCOW = ol.projection.transform(
|
||||
new ol.Coordinate(37.6178, 55.7517), 'EPSG:4326', 'EPSG:3857');
|
||||
|
||||
var layer = new ol.layer.TileLayer({
|
||||
|
||||
@@ -23,7 +23,7 @@ var map = new ol.Map({
|
||||
renderers: ol.RendererHints.createFromQueryData(),
|
||||
target: 'map',
|
||||
view: new ol.View2D({
|
||||
center: ol.projection.transformWithCodes(
|
||||
center: ol.projection.transform(
|
||||
new ol.Coordinate(-122.416667, 37.783333), 'EPSG:4326', 'EPSG:3857'),
|
||||
zoom: 12
|
||||
})
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
@exportObjectLiteralProperty ol.View2DOptions.center ol.Coordinate|undefined
|
||||
@exportObjectLiteralProperty ol.View2DOptions.maxResolution number|undefined
|
||||
@exportObjectLiteralProperty ol.View2DOptions.numZoomLevels number|undefined
|
||||
@exportObjectLiteralProperty ol.View2DOptions.projection ol.Projection|string|undefined
|
||||
@exportObjectLiteralProperty ol.View2DOptions.projection ol.ProjectionLike
|
||||
@exportObjectLiteralProperty ol.View2DOptions.resolution number|undefined
|
||||
@exportObjectLiteralProperty ol.View2DOptions.resolutions Array.<number>|undefined
|
||||
@exportObjectLiteralProperty ol.View2DOptions.rotation number|undefined
|
||||
@@ -61,7 +61,7 @@
|
||||
@exportObjectLiteral ol.control.MousePositionOptions
|
||||
@exportObjectLiteralProperty ol.control.MousePositionOptions.coordinateFormat ol.CoordinateFormatType|undefined
|
||||
@exportObjectLiteralProperty ol.control.MousePositionOptions.map ol.Map|undefined
|
||||
@exportObjectLiteralProperty ol.control.MousePositionOptions.projection ol.Projection|undefined
|
||||
@exportObjectLiteralProperty ol.control.MousePositionOptions.projection ol.ProjectionLike
|
||||
@exportObjectLiteralProperty ol.control.MousePositionOptions.target Element|undefined
|
||||
@exportObjectLiteralProperty ol.control.MousePositionOptions.undefinedHTML string|undefined
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
|
||||
@exportObjectLiteral ol.source.DebugTileSourceOptions
|
||||
@exportObjectLiteralProperty ol.source.DebugTileSourceOptions.extent ol.Extent|undefined
|
||||
@exportObjectLiteralProperty ol.source.DebugTileSourceOptions.projection ol.Projection|undefined
|
||||
@exportObjectLiteralProperty ol.source.DebugTileSourceOptions.projection ol.ProjectionLike
|
||||
@exportObjectLiteralProperty ol.source.DebugTileSourceOptions.tileGrid ol.tilegrid.TileGrid|undefined
|
||||
|
||||
@exportObjectLiteral ol.source.SingleImageWMSOptions
|
||||
@@ -111,7 +111,7 @@
|
||||
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.crossOrigin null|string|undefined
|
||||
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.extent ol.Extent|undefined
|
||||
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.params Object.<string,*>
|
||||
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.projection ol.Projection|undefined
|
||||
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.projection ol.ProjectionLike
|
||||
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.resolutions Array.<number>|undefined
|
||||
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.url string|undefined
|
||||
|
||||
@@ -128,7 +128,7 @@
|
||||
@exportObjectLiteralProperty ol.source.StaticImageOptions.extent ol.Extent|undefined
|
||||
@exportObjectLiteralProperty ol.source.StaticImageOptions.imageExtent ol.Extent|undefined
|
||||
@exportObjectLiteralProperty ol.source.StaticImageOptions.imageSize ol.Size|undefined
|
||||
@exportObjectLiteralProperty ol.source.StaticImageOptions.projection ol.Projection|undefined
|
||||
@exportObjectLiteralProperty ol.source.StaticImageOptions.projection ol.ProjectionLike
|
||||
@exportObjectLiteralProperty ol.source.StaticImageOptions.url string|undefined
|
||||
|
||||
@exportObjectLiteral ol.source.TiledWMSOptions
|
||||
@@ -138,7 +138,7 @@
|
||||
@exportObjectLiteralProperty ol.source.TiledWMSOptions.extent ol.Extent|undefined
|
||||
@exportObjectLiteralProperty ol.source.TiledWMSOptions.tileGrid ol.tilegrid.TileGrid|undefined
|
||||
@exportObjectLiteralProperty ol.source.TiledWMSOptions.maxZoom number|undefined
|
||||
@exportObjectLiteralProperty ol.source.TiledWMSOptions.projection ol.Projection|undefined
|
||||
@exportObjectLiteralProperty ol.source.TiledWMSOptions.projection ol.ProjectionLike
|
||||
@exportObjectLiteralProperty ol.source.TiledWMSOptions.url string|undefined
|
||||
@exportObjectLiteralProperty ol.source.TiledWMSOptions.urls Array.<string>|undefined
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@ ol.control.MousePosition = function(opt_options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.Projection|undefined}
|
||||
* @type {ol.Projection}
|
||||
*/
|
||||
this.projection_ = options.projection;
|
||||
this.projection_ = ol.projection.get(options.projection);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -168,8 +168,8 @@ ol.control.MousePosition.prototype.updateHTML_ = function(pixel) {
|
||||
var html = this.undefinedHTML_;
|
||||
if (!goog.isNull(pixel)) {
|
||||
if (this.renderedProjection_ != this.mapProjection_) {
|
||||
if (goog.isDef(this.projection_)) {
|
||||
this.transform_ = ol.projection.getTransform(
|
||||
if (!goog.isNull(this.projection_)) {
|
||||
this.transform_ = ol.projection.getTransformFromProjections(
|
||||
this.mapProjection_, this.projection_);
|
||||
} else {
|
||||
this.transform_ = ol.projection.identityTransform;
|
||||
|
||||
@@ -176,8 +176,8 @@ ol.control.ScaleLine.prototype.updateElement_ = function(frameState) {
|
||||
|
||||
// Convert pointResolution from meters or feet to degrees
|
||||
if (goog.isNull(this.toEPSG4326_)) {
|
||||
this.toEPSG4326_ = ol.projection.getTransform(
|
||||
projection, ol.projection.getFromCode('EPSG:4326'));
|
||||
this.toEPSG4326_ = ol.projection.getTransformFromProjections(
|
||||
projection, ol.projection.get('EPSG:4326'));
|
||||
}
|
||||
var vertex = [center.x, center.y];
|
||||
vertex = this.toEPSG4326_(vertex, vertex, 2);
|
||||
|
||||
@@ -76,8 +76,8 @@ ol.Geolocation.prototype.disposeInternal = function() {
|
||||
ol.Geolocation.prototype.handleProjectionChanged_ = function() {
|
||||
var projection = this.getProjection();
|
||||
if (goog.isDefAndNotNull(projection)) {
|
||||
this.transformFn_ = ol.projection.getTransform(
|
||||
ol.projection.getFromCode('EPSG:4326'), projection);
|
||||
this.transformFn_ = ol.projection.getTransformFromProjections(
|
||||
ol.projection.get('EPSG:4326'), projection);
|
||||
if (!goog.isNull(this.position_)) {
|
||||
var vertex = [this.position_.x, this.position_.y];
|
||||
vertex = this.transformFn_(vertex, vertex, 2);
|
||||
|
||||
@@ -79,7 +79,7 @@ ol.parser.ogc.WMTSCapabilities_v1_0_0 = function() {
|
||||
var topLeftCorner = this.getChildValue(node);
|
||||
var coords = topLeftCorner.split(' ');
|
||||
var axisOrientation =
|
||||
ol.projection.getFromCode(obj['supportedCRS']).getAxisOrientation();
|
||||
ol.projection.get(obj['supportedCRS']).getAxisOrientation();
|
||||
obj['topLeftCorner'] = ol.Coordinate.fromProjectedArray(
|
||||
[parseFloat(coords[0]), parseFloat(coords[1])], axisOrientation);
|
||||
},
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
@exportProperty ol.ProjectionUnits.METERS
|
||||
|
||||
@exportSymbol ol.projection.addProjection
|
||||
@exportSymbol ol.projection.getFromCode
|
||||
@exportSymbol ol.projection.get
|
||||
@exportSymbol ol.projection.getTransform
|
||||
@exportSymbol ol.projection.getTransformFromCodes
|
||||
@exportSymbol ol.projection.getTransformFromProjections
|
||||
@exportSymbol ol.projection.transform
|
||||
@exportSymbol ol.projection.transformWithCodes
|
||||
@exportSymbol ol.projection.transformWithProjections
|
||||
@exportSymbol ol.projection.configureProj4jsProjection
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
goog.provide('ol.Projection');
|
||||
goog.provide('ol.ProjectionLike');
|
||||
goog.provide('ol.ProjectionUnits');
|
||||
goog.provide('ol.projection');
|
||||
|
||||
@@ -23,6 +24,12 @@ ol.ENABLE_PROJ4JS = true;
|
||||
ol.HAVE_PROJ4JS = ol.ENABLE_PROJ4JS && typeof Proj4js == 'object';
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {ol.Projection|string|undefined}
|
||||
*/
|
||||
ol.ProjectionLike;
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
@@ -211,7 +218,7 @@ ol.Proj4jsProjection_.prototype.getPointResolution =
|
||||
// measuring its width and height on the normal sphere, and taking the
|
||||
// average of the width and height.
|
||||
if (goog.isNull(this.toEPSG4326_)) {
|
||||
this.toEPSG4326_ = ol.projection.getTransform(
|
||||
this.toEPSG4326_ = ol.projection.getTransformFromProjections(
|
||||
this, ol.projection.getProj4jsProjectionFromCode_({
|
||||
code: 'EPSG:4326',
|
||||
extent: null
|
||||
@@ -365,9 +372,9 @@ ol.projection.clearAllProjections = function() {
|
||||
*/
|
||||
ol.projection.createProjection = function(projection, defaultCode) {
|
||||
if (!goog.isDefAndNotNull(projection)) {
|
||||
return ol.projection.getFromCode(defaultCode);
|
||||
return ol.projection.get(defaultCode);
|
||||
} else if (goog.isString(projection)) {
|
||||
return ol.projection.getFromCode(projection);
|
||||
return ol.projection.get(projection);
|
||||
} else {
|
||||
goog.asserts.assert(projection instanceof ol.Projection);
|
||||
return projection;
|
||||
@@ -422,20 +429,29 @@ ol.projection.removeTransform = function(source, destination) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} code Code which is a combination of authority and identifier
|
||||
* such as “EPSG:4326”.
|
||||
* @param {ol.ProjectionLike} projectionLike Either a code string which is a
|
||||
* combination of authority and identifier such as "EPSG:4326", or an
|
||||
* existing projection object, or undefined.
|
||||
* @return {ol.Projection} Projection.
|
||||
*/
|
||||
ol.projection.getFromCode = function(code) {
|
||||
var projection = ol.projection.projections_[code];
|
||||
if (ol.HAVE_PROJ4JS && !goog.isDef(projection)) {
|
||||
projection = ol.projection.getProj4jsProjectionFromCode_({
|
||||
code: code,
|
||||
extent: null
|
||||
});
|
||||
}
|
||||
if (!goog.isDef(projection)) {
|
||||
goog.asserts.assert(goog.isDef(projection));
|
||||
ol.projection.get = function(projectionLike) {
|
||||
var projection;
|
||||
if (projectionLike instanceof ol.Projection) {
|
||||
projection = projectionLike;
|
||||
} else if (goog.isString(projectionLike)) {
|
||||
var code = projectionLike;
|
||||
projection = ol.projection.projections_[code];
|
||||
if (ol.HAVE_PROJ4JS && !goog.isDef(projection)) {
|
||||
projection = ol.projection.getProj4jsProjectionFromCode_({
|
||||
code: code,
|
||||
extent: null
|
||||
});
|
||||
}
|
||||
if (!goog.isDef(projection)) {
|
||||
goog.asserts.assert(goog.isDef(projection));
|
||||
projection = null;
|
||||
}
|
||||
} else {
|
||||
projection = null;
|
||||
}
|
||||
return projection;
|
||||
@@ -483,24 +499,43 @@ ol.projection.equivalent = function(projection1, projection2) {
|
||||
} else if (projection1.getUnits() != projection2.getUnits()) {
|
||||
return false;
|
||||
} else {
|
||||
var transformFn = ol.projection.getTransform(projection1, projection2);
|
||||
var transformFn = ol.projection.getTransformFromProjections(
|
||||
projection1, projection2);
|
||||
return transformFn === ol.projection.cloneTransform;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Given the projection-like objects this method searches for a transformation
|
||||
* function to convert a coordinates array from the source projection to the
|
||||
* destination projection.
|
||||
*
|
||||
* @param {ol.ProjectionLike} source Source.
|
||||
* @param {ol.ProjectionLike} destination Destination.
|
||||
* @return {ol.TransformFunction} Transform.
|
||||
*/
|
||||
ol.projection.getTransform = function(source, destination) {
|
||||
var sourceProjection = ol.projection.get(source);
|
||||
var destinationProjection = ol.projection.get(destination);
|
||||
return ol.projection.getTransformFromProjections(
|
||||
sourceProjection, destinationProjection);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Searches a function that can be used to convert coordinates from the source
|
||||
* projection to the destination projection.
|
||||
*
|
||||
* @param {ol.Projection} source Source.
|
||||
* @param {ol.Projection} destination Destination.
|
||||
* @param {ol.Projection} sourceProjection Source projection.
|
||||
* @param {ol.Projection} destinationProjection Destination projection.
|
||||
* @return {ol.TransformFunction} Transform.
|
||||
*/
|
||||
ol.projection.getTransform = function(source, destination) {
|
||||
ol.projection.getTransformFromProjections =
|
||||
function(sourceProjection, destinationProjection) {
|
||||
var transforms = ol.projection.transforms_;
|
||||
var sourceCode = source.getCode();
|
||||
var destinationCode = destination.getCode();
|
||||
var sourceCode = sourceProjection.getCode();
|
||||
var destinationCode = destinationProjection.getCode();
|
||||
var transform;
|
||||
if (goog.object.containsKey(transforms, sourceCode) &&
|
||||
goog.object.containsKey(transforms[sourceCode], destinationCode)) {
|
||||
@@ -508,23 +543,23 @@ ol.projection.getTransform = function(source, destination) {
|
||||
}
|
||||
if (ol.HAVE_PROJ4JS && !goog.isDef(transform)) {
|
||||
var proj4jsSource;
|
||||
if (source instanceof ol.Proj4jsProjection_) {
|
||||
proj4jsSource = source;
|
||||
if (sourceProjection instanceof ol.Proj4jsProjection_) {
|
||||
proj4jsSource = sourceProjection;
|
||||
} else {
|
||||
proj4jsSource =
|
||||
ol.projection.getProj4jsProjectionFromCode_({
|
||||
code: source.getCode(),
|
||||
code: sourceCode,
|
||||
extent: null
|
||||
});
|
||||
}
|
||||
var sourceProj4jsProj = proj4jsSource.getProj4jsProj();
|
||||
var proj4jsDestination;
|
||||
if (destination instanceof ol.Proj4jsProjection_) {
|
||||
proj4jsDestination = destination;
|
||||
if (destinationProjection instanceof ol.Proj4jsProjection_) {
|
||||
proj4jsDestination = destinationProjection;
|
||||
} else {
|
||||
proj4jsDestination =
|
||||
ol.projection.getProj4jsProjectionFromCode_({
|
||||
code: destination.getCode(),
|
||||
code: destinationCode,
|
||||
extent: null
|
||||
});
|
||||
}
|
||||
@@ -559,7 +594,8 @@ ol.projection.getTransform = function(source, destination) {
|
||||
}
|
||||
return output;
|
||||
};
|
||||
ol.projection.addTransform(source, destination, transform);
|
||||
ol.projection.addTransform(
|
||||
sourceProjection, destinationProjection, transform);
|
||||
}
|
||||
if (!goog.isDef(transform)) {
|
||||
goog.asserts.assert(goog.isDef(transform));
|
||||
@@ -569,22 +605,6 @@ ol.projection.getTransform = function(source, destination) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Given the projection codes this method searches for a transformation function
|
||||
* to convert a coordinates array from the source projection to the destination
|
||||
* projection.
|
||||
*
|
||||
* @param {string} sourceCode Source code.
|
||||
* @param {string} destinationCode Destination code.
|
||||
* @return {ol.TransformFunction} Transform.
|
||||
*/
|
||||
ol.projection.getTransformFromCodes = function(sourceCode, destinationCode) {
|
||||
var source = ol.projection.getFromCode(sourceCode);
|
||||
var destination = ol.projection.getFromCode(destinationCode);
|
||||
return ol.projection.getTransform(source, destination);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Array.<number>} input Input coordinate array.
|
||||
* @param {Array.<number>=} opt_output Output array of coordinate values.
|
||||
@@ -626,11 +646,9 @@ ol.projection.cloneTransform = function(input, opt_output, opt_dimension) {
|
||||
|
||||
|
||||
/**
|
||||
* Transforms the given point to the destination projection.
|
||||
*
|
||||
* @param {ol.Coordinate} point Point.
|
||||
* @param {ol.Projection} source Source.
|
||||
* @param {ol.Projection} destination Destination.
|
||||
* @param {ol.ProjectionLike} source Source.
|
||||
* @param {ol.ProjectionLike} destination Destination.
|
||||
* @return {ol.Coordinate} Point.
|
||||
*/
|
||||
ol.projection.transform = function(point, source, destination) {
|
||||
@@ -642,15 +660,17 @@ ol.projection.transform = function(point, source, destination) {
|
||||
|
||||
|
||||
/**
|
||||
* Transforms the given point to the destination projection.
|
||||
*
|
||||
* @param {ol.Coordinate} point Point.
|
||||
* @param {string} sourceCode Source code.
|
||||
* @param {string} destinationCode Destination code.
|
||||
* @param {ol.Projection} sourceProjection Source projection.
|
||||
* @param {ol.Projection} destinationProjection Destination projection.
|
||||
* @return {ol.Coordinate} Point.
|
||||
*/
|
||||
ol.projection.transformWithCodes =
|
||||
function(point, sourceCode, destinationCode) {
|
||||
var transformFn = ol.projection.getTransformFromCodes(
|
||||
sourceCode, destinationCode);
|
||||
ol.projection.transformWithProjections =
|
||||
function(point, sourceProjection, destinationProjection) {
|
||||
var transformFn = ol.projection.getTransformFromProjections(
|
||||
sourceProjection, destinationProjection);
|
||||
var vertex = [point.x, point.y];
|
||||
vertex = transformFn(vertex, vertex, 2);
|
||||
return new ol.Coordinate(vertex[0], vertex[1]);
|
||||
|
||||
@@ -24,7 +24,7 @@ ol.source.BingMaps = function(bingMapsOptions) {
|
||||
|
||||
goog.base(this, {
|
||||
opaque: true,
|
||||
projection: ol.projection.getFromCode('EPSG:3857')
|
||||
projection: ol.projection.get('EPSG:3857')
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -111,8 +111,8 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
||||
};
|
||||
})));
|
||||
|
||||
var transform = ol.projection.getTransform(
|
||||
ol.projection.getFromCode('EPSG:4326'), this.getProjection());
|
||||
var transform = ol.projection.getTransformFromProjections(
|
||||
ol.projection.get('EPSG:4326'), this.getProjection());
|
||||
var attributions = goog.array.map(
|
||||
resource.imageryProviders,
|
||||
function(imageryProvider) {
|
||||
|
||||
@@ -16,7 +16,7 @@ goog.require('ol.source.Source');
|
||||
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
|
||||
* crossOrigin: (null|string|undefined),
|
||||
* extent: (null|ol.Extent|undefined),
|
||||
* projection: (ol.Projection|undefined),
|
||||
* projection: ol.ProjectionLike,
|
||||
* resolutions: (Array.<number>|undefined),
|
||||
* imageUrlFunction: (ol.ImageUrlFunctionType|
|
||||
* undefined)}}
|
||||
|
||||
@@ -18,7 +18,7 @@ goog.require('ol.tilegrid.TileGrid');
|
||||
* crossOrigin: (null|string|undefined),
|
||||
* extent: (ol.Extent|undefined),
|
||||
* opaque: (boolean|undefined),
|
||||
* projection: (ol.Projection|undefined),
|
||||
* projection: ol.ProjectionLike,
|
||||
* tileGrid: (ol.tilegrid.TileGrid|undefined),
|
||||
* tileUrlFunction: (ol.TileUrlFunctionType|undefined)}}
|
||||
*/
|
||||
|
||||
@@ -5,13 +5,13 @@ goog.require('goog.events.EventType');
|
||||
goog.require('goog.functions');
|
||||
goog.require('ol.Attribution');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Projection');
|
||||
goog.require('ol.projection');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
|
||||
* extent: (ol.Extent|undefined),
|
||||
* projection: (ol.Projection|undefined)}}
|
||||
* projection: ol.ProjectionLike}}
|
||||
*/
|
||||
ol.source.SourceOptions;
|
||||
|
||||
@@ -30,8 +30,7 @@ ol.source.Source = function(sourceOptions) {
|
||||
* @private
|
||||
* @type {ol.Projection}
|
||||
*/
|
||||
this.projection_ = goog.isDef(sourceOptions.projection) ?
|
||||
sourceOptions.projection : null;
|
||||
this.projection_ = ol.projection.get(sourceOptions.projection);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -39,7 +38,7 @@ ol.source.Source = function(sourceOptions) {
|
||||
*/
|
||||
this.extent_ = goog.isDef(sourceOptions.extent) ?
|
||||
sourceOptions.extent : goog.isDef(sourceOptions.projection) ?
|
||||
sourceOptions.projection.getExtent() : null;
|
||||
this.projection_.getExtent() : null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -2,6 +2,7 @@ goog.provide('ol.source.StaticImage');
|
||||
|
||||
goog.require('ol.Image');
|
||||
goog.require('ol.ImageUrlFunctionType');
|
||||
goog.require('ol.projection');
|
||||
goog.require('ol.source.ImageSource');
|
||||
|
||||
|
||||
@@ -19,7 +20,7 @@ ol.source.StaticImage = function(options) {
|
||||
var imageExtent = options.imageExtent;
|
||||
var imageSize = options.imageSize;
|
||||
var imageResolution = imageExtent.getHeight() / imageSize.height;
|
||||
var projection = goog.isDef(options.projection) ? options.projection : null;
|
||||
var projection = ol.projection.get(options.projection);
|
||||
|
||||
goog.base(this, {
|
||||
attributions: options.attributions,
|
||||
|
||||
@@ -1 +1 @@
|
||||
@exportSymbol ol.source.TiledWMS
|
||||
@exportSymbol ol.source.TiledWMS
|
||||
|
||||
@@ -52,7 +52,7 @@ goog.exportSymbol('grid', grid);
|
||||
ol.source.TileJSON = function(tileJsonOptions) {
|
||||
|
||||
goog.base(this, {
|
||||
projection: ol.projection.getFromCode('EPSG:3857')
|
||||
projection: ol.projection.get('EPSG:3857')
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -80,15 +80,15 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function() {
|
||||
|
||||
var tileJSON = ol.tilejson.grids_.pop();
|
||||
|
||||
var epsg4326Projection = ol.projection.getFromCode('EPSG:4326');
|
||||
var epsg4326Projection = ol.projection.get('EPSG:4326');
|
||||
|
||||
var epsg4326Extent, extent;
|
||||
if (goog.isDef(tileJSON.bounds)) {
|
||||
var bounds = tileJSON.bounds;
|
||||
epsg4326Extent = new ol.Extent(
|
||||
bounds[0], bounds[1], bounds[2], bounds[3]);
|
||||
extent = epsg4326Extent.transform(
|
||||
ol.projection.getTransform(epsg4326Projection, this.getProjection()));
|
||||
extent = epsg4326Extent.transform(ol.projection.getTransformFromProjections(
|
||||
epsg4326Projection, this.getProjection()));
|
||||
this.setExtent(extent);
|
||||
} else {
|
||||
epsg4326Extent = null;
|
||||
|
||||
@@ -4,7 +4,6 @@ goog.provide('ol.source.TileSourceOptions');
|
||||
goog.require('goog.functions');
|
||||
goog.require('ol.Attribution');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Projection');
|
||||
goog.require('ol.Tile');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.TileRange');
|
||||
@@ -16,7 +15,7 @@ goog.require('ol.tilegrid.TileGrid');
|
||||
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
|
||||
* extent: (ol.Extent|undefined),
|
||||
* opaque: (boolean|undefined),
|
||||
* projection: (ol.Projection|undefined),
|
||||
* projection: ol.ProjectionLike,
|
||||
* tileGrid: (ol.tilegrid.TileGrid|undefined)}}
|
||||
*/
|
||||
ol.source.TileSourceOptions;
|
||||
|
||||
@@ -37,7 +37,7 @@ ol.source.XYZOptions;
|
||||
ol.source.XYZ = function(xyzOptions) {
|
||||
|
||||
var projection = xyzOptions.projection ||
|
||||
ol.projection.getFromCode('EPSG:3857');
|
||||
ol.projection.get('EPSG:3857');
|
||||
|
||||
/**
|
||||
* @type {ol.TileUrlFunctionType}
|
||||
|
||||
@@ -70,8 +70,7 @@ describe('ol.Extent', function() {
|
||||
describe('transform', function() {
|
||||
|
||||
it('does transform', function() {
|
||||
var transformFn =
|
||||
ol.projection.getTransformFromCodes('EPSG:4326', 'EPSG:3857');
|
||||
var transformFn = ol.projection.getTransform('EPSG:4326', 'EPSG:3857');
|
||||
var sourceExtent = new ol.Extent(-15, -30, 45, 60);
|
||||
var destinationExtent = sourceExtent.transform(transformFn);
|
||||
expect(destinationExtent).not.toBeUndefined();
|
||||
|
||||
@@ -9,7 +9,7 @@ describe('ol.layer.Layer', function() {
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.projection.getFromCode('EPSG:4326')
|
||||
projection: ol.projection.get('EPSG:4326')
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -53,7 +53,7 @@ describe('ol.layer.Layer', function() {
|
||||
it('accepts options', function() {
|
||||
var layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.projection.getFromCode('EPSG:4326')
|
||||
projection: ol.projection.get('EPSG:4326')
|
||||
}),
|
||||
brightness: 0.5,
|
||||
contrast: 10,
|
||||
@@ -82,7 +82,7 @@ describe('ol.layer.Layer', function() {
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.projection.getFromCode('EPSG:4326')
|
||||
projection: ol.projection.get('EPSG:4326')
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -120,7 +120,7 @@ describe('ol.layer.Layer', function() {
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.projection.getFromCode('EPSG:4326')
|
||||
projection: ol.projection.get('EPSG:4326')
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -154,7 +154,7 @@ describe('ol.layer.Layer', function() {
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.projection.getFromCode('EPSG:4326')
|
||||
projection: ol.projection.get('EPSG:4326')
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -193,7 +193,7 @@ describe('ol.layer.Layer', function() {
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.projection.getFromCode('EPSG:4326')
|
||||
projection: ol.projection.get('EPSG:4326')
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -227,7 +227,7 @@ describe('ol.layer.Layer', function() {
|
||||
beforeEach(function() {
|
||||
layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.projection.getFromCode('EPSG:4326')
|
||||
projection: ol.projection.get('EPSG:4326')
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -259,7 +259,7 @@ describe('ol.layer.Layer', function() {
|
||||
it('sets visible property', function() {
|
||||
var layer = new ol.layer.Layer({
|
||||
source: new ol.source.Source({
|
||||
projection: ol.projection.getFromCode('EPSG:4326')
|
||||
projection: ol.projection.get('EPSG:4326')
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ describe('ol.projection.EPSG3857', function() {
|
||||
|
||||
it('returns the correct point scale at the equator', function() {
|
||||
// @see http://msdn.microsoft.com/en-us/library/aa940990.aspx
|
||||
var epsg3857 = ol.projection.getFromCode('EPSG:3857');
|
||||
var epsg3857 = ol.projection.get('EPSG:3857');
|
||||
var resolution = 19.11;
|
||||
var point = new ol.Coordinate(0, 0);
|
||||
expect(epsg3857.getPointResolution(resolution, point)).
|
||||
@@ -17,8 +17,8 @@ describe('ol.projection.EPSG3857', function() {
|
||||
it('returns the correct point scale at the latitude of Toronto',
|
||||
function() {
|
||||
// @see http://msdn.microsoft.com/en-us/library/aa940990.aspx
|
||||
var epsg3857 = ol.projection.getFromCode('EPSG:3857');
|
||||
var epsg4326 = ol.projection.getFromCode('EPSG:4326');
|
||||
var epsg3857 = ol.projection.get('EPSG:3857');
|
||||
var epsg4326 = ol.projection.get('EPSG:4326');
|
||||
var resolution = 19.11;
|
||||
var point = ol.projection.transform(
|
||||
new ol.Coordinate(0, 43.65), epsg4326, epsg3857);
|
||||
@@ -28,8 +28,8 @@ describe('ol.projection.EPSG3857', function() {
|
||||
|
||||
it('returns the correct point scale at various latitudes', function() {
|
||||
// @see http://msdn.microsoft.com/en-us/library/aa940990.aspx
|
||||
var epsg3857 = ol.projection.getFromCode('EPSG:3857');
|
||||
var epsg4326 = ol.projection.getFromCode('EPSG:4326');
|
||||
var epsg3857 = ol.projection.get('EPSG:3857');
|
||||
var epsg4326 = ol.projection.get('EPSG:4326');
|
||||
var resolution = 19.11;
|
||||
var latitude;
|
||||
for (latitude = 0; latitude < 90; ++latitude) {
|
||||
|
||||
@@ -26,7 +26,7 @@ describe('ol.projection', function() {
|
||||
describe('projection equivalence', function() {
|
||||
|
||||
function _testAllEquivalent(codes) {
|
||||
var projections = goog.array.map(codes, ol.projection.getFromCode);
|
||||
var projections = goog.array.map(codes, ol.projection.get);
|
||||
goog.array.forEach(projections, function(source) {
|
||||
goog.array.forEach(projections, function(destination) {
|
||||
expect(ol.projection.equivalent(source, destination)).toBeTruthy();
|
||||
@@ -56,7 +56,7 @@ describe('ol.projection', function() {
|
||||
describe('identify transform', function() {
|
||||
|
||||
it('returns a new object, with same coord values', function() {
|
||||
var epsg4326 = ol.projection.getFromCode('EPSG:4326');
|
||||
var epsg4326 = ol.projection.get('EPSG:4326');
|
||||
var uniqueObject = {};
|
||||
var sourcePoint = new ol.Coordinate(uniqueObject, uniqueObject);
|
||||
var destinationPoint = ol.projection.transform(
|
||||
@@ -70,7 +70,7 @@ describe('ol.projection', function() {
|
||||
describe('transform 0,0 from 4326 to 3857', function() {
|
||||
|
||||
it('returns expected value', function() {
|
||||
var point = ol.projection.transformWithCodes(
|
||||
var point = ol.projection.transform(
|
||||
new ol.Coordinate(0, 0), 'EPSG:4326', 'EPSG:3857');
|
||||
expect(point).not.toBeUndefined();
|
||||
expect(point).not.toBeNull();
|
||||
@@ -81,7 +81,7 @@ describe('ol.projection', function() {
|
||||
describe('transform 0,0 from 3857 to 4326', function() {
|
||||
|
||||
it('returns expected value', function() {
|
||||
var point = ol.projection.transformWithCodes(
|
||||
var point = ol.projection.transform(
|
||||
new ol.Coordinate(0, 0), 'EPSG:3857', 'EPSG:4326');
|
||||
expect(point).not.toBeUndefined();
|
||||
expect(point).not.toBeNull();
|
||||
@@ -94,7 +94,7 @@ describe('ol.projection', function() {
|
||||
// http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/
|
||||
|
||||
it('returns expected value', function() {
|
||||
var point = ol.projection.transformWithCodes(
|
||||
var point = ol.projection.transform(
|
||||
new ol.Coordinate(-5.625, 52.4827802220782),
|
||||
'EPSG:4326',
|
||||
'EPSG:900913');
|
||||
@@ -109,7 +109,7 @@ describe('ol.projection', function() {
|
||||
// http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/
|
||||
|
||||
it('returns expected value', function() {
|
||||
var point = ol.projection.transformWithCodes(
|
||||
var point = ol.projection.transform(
|
||||
new ol.Coordinate(-626172.13571216376, 6887893.4928337997),
|
||||
'EPSG:900913',
|
||||
'EPSG:4326');
|
||||
@@ -123,7 +123,7 @@ describe('ol.projection', function() {
|
||||
describe('Proj4js integration', function() {
|
||||
|
||||
it('allows Proj4js projections to be used transparently', function() {
|
||||
var point = ol.projection.transformWithCodes(
|
||||
var point = ol.projection.transform(
|
||||
new ol.Coordinate(-626172.13571216376, 6887893.4928337997),
|
||||
'GOOGLE',
|
||||
'WGS84');
|
||||
@@ -136,7 +136,7 @@ describe('ol.projection', function() {
|
||||
'+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 ' +
|
||||
'+k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' +
|
||||
'+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs';
|
||||
var point = ol.projection.transformWithCodes(
|
||||
var point = ol.projection.transform(
|
||||
new ol.Coordinate(7.439583333333333, 46.95240555555556),
|
||||
'EPSG:4326',
|
||||
'EPSG:21781');
|
||||
@@ -151,24 +151,24 @@ describe('ol.projection', function() {
|
||||
'+towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs';
|
||||
var code = 'urn:ogc:def:crs:EPSG:21781';
|
||||
var srsCode = 'EPSG:21781';
|
||||
var proj = ol.projection.getFromCode(code);
|
||||
var proj = ol.projection.get(code);
|
||||
expect(ol.projection.proj4jsProjections_.hasOwnProperty(code))
|
||||
.toBeTruthy();
|
||||
expect(ol.projection.proj4jsProjections_.hasOwnProperty(srsCode))
|
||||
.toBeTruthy();
|
||||
var proj2 = ol.projection.getFromCode(srsCode);
|
||||
var proj2 = ol.projection.get(srsCode);
|
||||
expect(proj2).toBe(proj);
|
||||
});
|
||||
|
||||
it('numerically estimates point scale at the equator', function() {
|
||||
var googleProjection = ol.projection.getFromCode('GOOGLE');
|
||||
var googleProjection = ol.projection.get('GOOGLE');
|
||||
expect(googleProjection.getPointResolution(1, new ol.Coordinate(0, 0))).
|
||||
toRoughlyEqual(1, 1e-1);
|
||||
});
|
||||
|
||||
it('numerically estimates point scale at various latitudes', function() {
|
||||
var epsg3857Projection = ol.projection.getFromCode('EPSG:3857');
|
||||
var googleProjection = ol.projection.getFromCode('GOOGLE');
|
||||
var epsg3857Projection = ol.projection.get('EPSG:3857');
|
||||
var googleProjection = ol.projection.get('GOOGLE');
|
||||
var point, y;
|
||||
for (y = -20; y <= 20; ++y) {
|
||||
point = new ol.Coordinate(0, 1000000 * y);
|
||||
@@ -178,8 +178,8 @@ describe('ol.projection', function() {
|
||||
});
|
||||
|
||||
it('numerically estimates point scale at various points', function() {
|
||||
var epsg3857Projection = ol.projection.getFromCode('EPSG:3857');
|
||||
var googleProjection = ol.projection.getFromCode('GOOGLE');
|
||||
var epsg3857Projection = ol.projection.get('EPSG:3857');
|
||||
var googleProjection = ol.projection.get('GOOGLE');
|
||||
var point, x, y;
|
||||
for (x = -20; x <= 20; ++x) {
|
||||
for (y = -20; y <= 20; ++y) {
|
||||
@@ -192,13 +192,13 @@ describe('ol.projection', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('ol.projection.getTransform()', function() {
|
||||
describe('ol.projection.getTransformFromProjections()', function() {
|
||||
|
||||
var sm = ol.projection.getFromCode('GOOGLE');
|
||||
var gg = ol.projection.getFromCode('EPSG:4326');
|
||||
var sm = ol.projection.get('GOOGLE');
|
||||
var gg = ol.projection.get('EPSG:4326');
|
||||
|
||||
it('returns a transform function', function() {
|
||||
var transform = ol.projection.getTransform(sm, gg);
|
||||
var transform = ol.projection.getTransformFromProjections(sm, gg);
|
||||
expect(typeof transform).toBe('function');
|
||||
|
||||
var output = transform([-12000000, 5000000]);
|
||||
@@ -208,7 +208,7 @@ describe('ol.projection', function() {
|
||||
});
|
||||
|
||||
it('works for longer arrays', function() {
|
||||
var transform = ol.projection.getTransform(sm, gg);
|
||||
var transform = ol.projection.getTransformFromProjections(sm, gg);
|
||||
expect(typeof transform).toBe('function');
|
||||
|
||||
var output = transform([-12000000, 5000000, -12000000, 5000000]);
|
||||
@@ -221,17 +221,15 @@ describe('ol.projection', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('ol.projection.getTransformFromCodes()', function() {
|
||||
describe('ol.projection.getTransform()', function() {
|
||||
|
||||
it('returns a function', function() {
|
||||
var transform = ol.projection.getTransformFromCodes(
|
||||
'GOOGLE', 'EPSG:4326');
|
||||
var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326');
|
||||
expect(typeof transform).toBe('function');
|
||||
});
|
||||
|
||||
it('returns a transform function', function() {
|
||||
var transform = ol.projection.getTransformFromCodes(
|
||||
'GOOGLE', 'EPSG:4326');
|
||||
var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326');
|
||||
expect(typeof transform).toBe('function');
|
||||
|
||||
var output = transform([-626172.13571216376, 6887893.4928337997]);
|
||||
@@ -242,8 +240,7 @@ describe('ol.projection', function() {
|
||||
});
|
||||
|
||||
it('works for longer arrays of coordinate values', function() {
|
||||
var transform = ol.projection.getTransformFromCodes(
|
||||
'GOOGLE', 'EPSG:4326');
|
||||
var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326');
|
||||
expect(typeof transform).toBe('function');
|
||||
|
||||
var output = transform([
|
||||
@@ -261,8 +258,7 @@ describe('ol.projection', function() {
|
||||
});
|
||||
|
||||
it('accepts an optional destination array', function() {
|
||||
var transform = ol.projection.getTransformFromCodes(
|
||||
'EPSG:3857', 'EPSG:4326');
|
||||
var transform = ol.projection.getTransform('EPSG:3857', 'EPSG:4326');
|
||||
var input = [-12000000, 5000000];
|
||||
var output = [];
|
||||
|
||||
@@ -276,8 +272,7 @@ describe('ol.projection', function() {
|
||||
});
|
||||
|
||||
it('accepts a dimension', function() {
|
||||
var transform = ol.projection.getTransformFromCodes(
|
||||
'GOOGLE', 'EPSG:4326');
|
||||
var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326');
|
||||
expect(typeof transform).toBe('function');
|
||||
|
||||
var dimension = 3;
|
||||
@@ -331,7 +326,7 @@ describe('ol.projection', function() {
|
||||
describe('ol.Projection.prototype.getMetersPerUnit()', function() {
|
||||
|
||||
it('returns value in meters', function() {
|
||||
var epsg4326 = ol.projection.getFromCode('EPSG:4326');
|
||||
var epsg4326 = ol.projection.get('EPSG:4326');
|
||||
expect(epsg4326.getMetersPerUnit()).toEqual(111194.87428468118);
|
||||
});
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ describe('ol.source.TileSource', function() {
|
||||
describe('constructor', function() {
|
||||
it('returns a tile source', function() {
|
||||
var source = new ol.source.TileSource({
|
||||
projection: ol.projection.getFromCode('EPSG:4326')
|
||||
projection: ol.projection.get('EPSG:4326')
|
||||
});
|
||||
expect(source).toBeA(ol.source.Source);
|
||||
expect(source).toBeA(ol.source.TileSource);
|
||||
@@ -202,7 +202,7 @@ ol.test.source.MockTileSource = function(loaded) {
|
||||
|
||||
goog.base(this, {
|
||||
extent: extent,
|
||||
projection: ol.projection.getFromCode('EPSG:4326'),
|
||||
projection: ol.projection.get('EPSG:4326'),
|
||||
tileGrid: tileGrid
|
||||
});
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
describe('createForProjection', function() {
|
||||
|
||||
it('allows easier creation of a tile grid', function() {
|
||||
var projection = ol.projection.getFromCode('EPSG:3857');
|
||||
var projection = ol.projection.get('EPSG:3857');
|
||||
var grid = ol.tilegrid.createForProjection(projection);
|
||||
expect(grid).toBeA(ol.tilegrid.TileGrid);
|
||||
|
||||
@@ -173,7 +173,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
});
|
||||
|
||||
it('accepts a number of zoom levels', function() {
|
||||
var projection = ol.projection.getFromCode('EPSG:3857');
|
||||
var projection = ol.projection.get('EPSG:3857');
|
||||
var grid = ol.tilegrid.createForProjection(projection, 18);
|
||||
expect(grid).toBeA(ol.tilegrid.TileGrid);
|
||||
|
||||
@@ -182,7 +182,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
});
|
||||
|
||||
it('accepts a big number of zoom levels', function() {
|
||||
var projection = ol.projection.getFromCode('EPSG:3857');
|
||||
var projection = ol.projection.get('EPSG:3857');
|
||||
var grid = ol.tilegrid.createForProjection(projection, 23);
|
||||
expect(grid).toBeA(ol.tilegrid.TileGrid);
|
||||
|
||||
@@ -195,7 +195,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
describe('getForProjection', function() {
|
||||
|
||||
it('gets the default tile grid for a projection', function() {
|
||||
var projection = ol.projection.getFromCode('EPSG:3857');
|
||||
var projection = ol.projection.get('EPSG:3857');
|
||||
var grid = ol.tilegrid.getForProjection(projection);
|
||||
expect(grid).toBeA(ol.tilegrid.TileGrid);
|
||||
|
||||
@@ -205,7 +205,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
});
|
||||
|
||||
it('stores the default tile grid on a projection', function() {
|
||||
var projection = ol.projection.getFromCode('EPSG:3857');
|
||||
var projection = ol.projection.get('EPSG:3857');
|
||||
var grid = ol.tilegrid.getForProjection(projection);
|
||||
var gridAgain = ol.tilegrid.getForProjection(projection);
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ describe('ol.TileUrlFunction', function() {
|
||||
});
|
||||
});
|
||||
it('creates expected URL', function() {
|
||||
var epsg3857 = ol.projection.getFromCode('EPSG:3857');
|
||||
var epsg3857 = ol.projection.get('EPSG:3857');
|
||||
var tileUrlFunction = ol.TileUrlFunction.createWMSParams(
|
||||
'http://wms?foo=bar', {});
|
||||
var tileCoord = new ol.TileCoord(1, 0, 0);
|
||||
@@ -81,7 +81,7 @@ describe('ol.TileUrlFunction', function() {
|
||||
expect(tileUrl).toEqual(expected);
|
||||
});
|
||||
it('creates expected URL respecting axis orientation', function() {
|
||||
var epsg4326 = ol.projection.getFromCode('EPSG:4326');
|
||||
var epsg4326 = ol.projection.get('EPSG:4326');
|
||||
var tileUrlFunction = ol.TileUrlFunction.createWMSParams(
|
||||
'http://wms?foo=bar', {});
|
||||
var tileCoord = new ol.TileCoord(1, 0, 0);
|
||||
|
||||
Reference in New Issue
Block a user