Rename ol.projection.getFromCode to ol.projection.get
This commit is contained in:
@@ -15,7 +15,7 @@ var layers = [
|
||||
}),
|
||||
new ol.layer.TileLayer({
|
||||
source: new ol.source.DebugTileSource({
|
||||
projection: ol.projection.getFromCode('EPSG:3857'),
|
||||
projection: ol.projection.get('EPSG:3857'),
|
||||
tileGrid: new ol.tilegrid.XYZ({
|
||||
maxZoom: 22
|
||||
})
|
||||
|
||||
@@ -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: ol.projection.get('EPSG:4326'),
|
||||
center: new ol.Coordinate(0, 0),
|
||||
zoom: 2
|
||||
})
|
||||
|
||||
@@ -177,7 +177,7 @@ 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'));
|
||||
projection, ol.projection.get('EPSG:4326'));
|
||||
}
|
||||
var vertex = [center.x, center.y];
|
||||
vertex = this.toEPSG4326_(vertex, vertex, 2);
|
||||
|
||||
@@ -77,7 +77,7 @@ ol.Geolocation.prototype.handleProjectionChanged_ = function() {
|
||||
var projection = this.getProjection();
|
||||
if (goog.isDefAndNotNull(projection)) {
|
||||
this.transformFn_ = ol.projection.getTransform(
|
||||
ol.projection.getFromCode('EPSG:4326'), projection);
|
||||
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,7 +13,7 @@
|
||||
@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.transform
|
||||
|
||||
@@ -365,9 +365,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;
|
||||
@@ -426,7 +426,7 @@ ol.projection.removeTransform = function(source, destination) {
|
||||
* such as “EPSG:4326”.
|
||||
* @return {ol.Projection} Projection.
|
||||
*/
|
||||
ol.projection.getFromCode = function(code) {
|
||||
ol.projection.get = function(code) {
|
||||
var projection = ol.projection.projections_[code];
|
||||
if (ol.HAVE_PROJ4JS && !goog.isDef(projection)) {
|
||||
projection = ol.projection.getProj4jsProjectionFromCode_({
|
||||
@@ -579,8 +579,8 @@ ol.projection.getTransform = function(source, destination) {
|
||||
* @return {ol.TransformFunction} Transform.
|
||||
*/
|
||||
ol.projection.getTransformFromCodes = function(sourceCode, destinationCode) {
|
||||
var source = ol.projection.getFromCode(sourceCode);
|
||||
var destination = ol.projection.getFromCode(destinationCode);
|
||||
var source = ol.projection.get(sourceCode);
|
||||
var destination = ol.projection.get(destinationCode);
|
||||
return ol.projection.getTransform(source, destination);
|
||||
};
|
||||
|
||||
|
||||
@@ -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')
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -112,7 +112,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
||||
})));
|
||||
|
||||
var transform = ol.projection.getTransform(
|
||||
ol.projection.getFromCode('EPSG:4326'), this.getProjection());
|
||||
ol.projection.get('EPSG:4326'), this.getProjection());
|
||||
var attributions = goog.array.map(
|
||||
resource.imageryProviders,
|
||||
function(imageryProvider) {
|
||||
|
||||
@@ -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,7 +80,7 @@ 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)) {
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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(
|
||||
@@ -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) {
|
||||
@@ -194,8 +194,8 @@ describe('ol.projection', function() {
|
||||
|
||||
describe('ol.projection.getTransform()', 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);
|
||||
@@ -331,7 +331,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