Merge pull request #748 from twpayne/rename-projection-to-proj

Rename ol.projection to ol.proj
This commit is contained in:
Tom Payne
2013-05-31 04:34:22 -07:00
50 changed files with 345 additions and 370 deletions

View File

@@ -14,7 +14,7 @@ goog.require('ol.Pixel');
goog.require('ol.Projection');
goog.require('ol.TransformFunction');
goog.require('ol.control.Control');
goog.require('ol.projection');
goog.require('ol.proj');
@@ -44,7 +44,7 @@ ol.control.MousePosition = function(opt_options) {
* @private
* @type {ol.Projection}
*/
this.projection_ = ol.projection.get(options.projection);
this.projection_ = ol.proj.get(options.projection);
/**
* @private
@@ -75,7 +75,7 @@ ol.control.MousePosition = function(opt_options) {
* @private
* @type {ol.TransformFunction}
*/
this.transform_ = ol.projection.identityTransform;
this.transform_ = ol.proj.identityTransform;
/**
* @private
@@ -157,10 +157,10 @@ ol.control.MousePosition.prototype.updateHTML_ = function(pixel) {
if (!goog.isNull(pixel)) {
if (this.renderedProjection_ != this.mapProjection_) {
if (!goog.isNull(this.projection_)) {
this.transform_ = ol.projection.getTransformFromProjections(
this.transform_ = ol.proj.getTransformFromProjections(
this.mapProjection_, this.projection_);
} else {
this.transform_ = ol.projection.identityTransform;
this.transform_ = ol.proj.identityTransform;
}
this.renderedProjection_ = this.mapProjection_;
}

View File

@@ -12,7 +12,7 @@ goog.require('ol.ProjectionUnits');
goog.require('ol.TransformFunction');
goog.require('ol.control.Control');
goog.require('ol.css');
goog.require('ol.projection');
goog.require('ol.proj');
goog.require('ol.sphere.NORMAL');
@@ -157,8 +157,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.getTransformFromProjections(
projection, ol.projection.get('EPSG:4326'));
this.toEPSG4326_ = ol.proj.getTransformFromProjections(
projection, ol.proj.get('EPSG:4326'));
}
cosLatitude = Math.cos(goog.math.toRadians(this.toEPSG4326_(center)[1]));
var radius = ol.sphere.NORMAL.radius;

View File

@@ -9,7 +9,7 @@ goog.require('goog.math');
goog.require('ol.Coordinate');
goog.require('ol.Object');
goog.require('ol.Projection');
goog.require('ol.projection');
goog.require('ol.proj');
/**
@@ -51,7 +51,7 @@ ol.Geolocation = function(opt_options) {
* @private
* @type {ol.TransformFunction}
*/
this.transform_ = ol.projection.identityTransform;
this.transform_ = ol.proj.identityTransform;
/**
* @private
@@ -67,7 +67,7 @@ ol.Geolocation = function(opt_options) {
this.handleTrackingChanged_, false, this);
if (goog.isDef(options.projection)) {
this.setProjection(ol.projection.get(options.projection));
this.setProjection(ol.proj.get(options.projection));
}
if (goog.isDef(options.trackingOptions)) {
this.setTrackingOptions(options.trackingOptions);
@@ -95,8 +95,8 @@ ol.Geolocation.prototype.disposeInternal = function() {
ol.Geolocation.prototype.handleProjectionChanged_ = function() {
var projection = this.getProjection();
if (goog.isDefAndNotNull(projection)) {
this.transform_ = ol.projection.getTransformFromProjections(
ol.projection.get('EPSG:4326'), projection);
this.transform_ = ol.proj.getTransformFromProjections(
ol.proj.get('EPSG:4326'), projection);
if (!goog.isNull(this.position_)) {
this.set(
ol.GeolocationProperty.POSITION, this.transform_(this.position_));

View File

@@ -6,7 +6,7 @@ goog.require('goog.object');
goog.require('ol.Feature');
goog.require('ol.geom.SharedVertices');
goog.require('ol.layer.Layer');
goog.require('ol.projection');
goog.require('ol.proj');
goog.require('ol.source.Vector');
goog.require('ol.structs.RTree');
goog.require('ol.style.Style');
@@ -330,7 +330,7 @@ ol.layer.Vector.prototype.parseFeatures = function(data, parser, projection) {
var addFeatures = function(features) {
var sourceProjection = this.getSource().getProjection();
var transform = ol.projection.getTransform(sourceProjection, projection);
var transform = ol.proj.getTransform(sourceProjection, projection);
transform(
this.pointVertices_.coordinates,

View File

@@ -56,8 +56,8 @@ goog.require('ol.control.defaults');
goog.require('ol.extent');
goog.require('ol.interaction.defaults');
goog.require('ol.layer.Layer');
goog.require('ol.projection');
goog.require('ol.projection.addCommonProjections');
goog.require('ol.proj');
goog.require('ol.proj.addCommonProjections');
goog.require('ol.renderer.Map');
goog.require('ol.renderer.canvas.Map');
goog.require('ol.renderer.canvas.SUPPORTED');
@@ -1078,7 +1078,7 @@ ol.RendererHints.createFromQueryData = function(opt_queryData) {
};
ol.projection.addCommonProjections();
ol.proj.addCommonProjections();
if (goog.DEBUG) {

View File

@@ -3,7 +3,7 @@ goog.require('goog.dom.xml');
goog.require('ol.coordinate');
goog.require('ol.parser.XML');
goog.require('ol.parser.ogc.OWSCommon_v1_1_0');
goog.require('ol.projection');
goog.require('ol.proj');
@@ -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.get(obj['supportedCRS']).getAxisOrientation();
ol.proj.get(obj['supportedCRS']).getAxisOrientation();
obj['topLeftCorner'] = ol.coordinate.fromProjectedArray(
[parseFloat(coords[0]), parseFloat(coords[1])], axisOrientation);
},

3
src/ol/proj.jsdoc Normal file
View File

@@ -0,0 +1,3 @@
/**
* @namespace ol.proj
*/

23
src/ol/proj/common.js Normal file
View File

@@ -0,0 +1,23 @@
goog.provide('ol.proj.addCommonProjections');
goog.require('ol.proj');
goog.require('ol.proj.EPSG3857');
goog.require('ol.proj.EPSG4326');
/**
* FIXME empty description for jsdoc
*/
ol.proj.addCommonProjections = function() {
// Add transformations that don't alter coordinates to convert within set of
// projections with equal meaning.
ol.proj.addEquivalentProjections(ol.proj.EPSG3857.PROJECTIONS);
ol.proj.addEquivalentProjections(ol.proj.EPSG4326.PROJECTIONS);
// Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like
// coordinates and back.
ol.proj.addEquivalentTransforms(
ol.proj.EPSG4326.PROJECTIONS,
ol.proj.EPSG3857.PROJECTIONS,
ol.proj.EPSG3857.fromEPSG4326,
ol.proj.EPSG3857.toEPSG4326);
};

View File

@@ -1,11 +1,11 @@
goog.provide('ol.projection.EPSG3857');
goog.provide('ol.proj.EPSG3857');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('ol.Projection');
goog.require('ol.ProjectionUnits');
goog.require('ol.math');
goog.require('ol.projection');
goog.require('ol.proj');
@@ -14,38 +14,38 @@ goog.require('ol.projection');
* @extends {ol.Projection}
* @param {string} code Code.
*/
ol.projection.EPSG3857 = function(code) {
ol.proj.EPSG3857 = function(code) {
goog.base(this, {
code: code,
units: ol.ProjectionUnits.METERS,
extent: ol.projection.EPSG3857.EXTENT,
extent: ol.proj.EPSG3857.EXTENT,
global: true
});
};
goog.inherits(ol.projection.EPSG3857, ol.Projection);
goog.inherits(ol.proj.EPSG3857, ol.Projection);
/**
* @const
* @type {number}
*/
ol.projection.EPSG3857.RADIUS = 6378137;
ol.proj.EPSG3857.RADIUS = 6378137;
/**
* @const
* @type {number}
*/
ol.projection.EPSG3857.HALF_SIZE = Math.PI * ol.projection.EPSG3857.RADIUS;
ol.proj.EPSG3857.HALF_SIZE = Math.PI * ol.proj.EPSG3857.RADIUS;
/**
* @const
* @type {ol.Extent}
*/
ol.projection.EPSG3857.EXTENT = [
-ol.projection.EPSG3857.HALF_SIZE, ol.projection.EPSG3857.HALF_SIZE,
-ol.projection.EPSG3857.HALF_SIZE, ol.projection.EPSG3857.HALF_SIZE
ol.proj.EPSG3857.EXTENT = [
-ol.proj.EPSG3857.HALF_SIZE, ol.proj.EPSG3857.HALF_SIZE,
-ol.proj.EPSG3857.HALF_SIZE, ol.proj.EPSG3857.HALF_SIZE
];
@@ -54,7 +54,7 @@ ol.projection.EPSG3857.EXTENT = [
*
* @type {Array.<string>}
*/
ol.projection.EPSG3857.CODES = [
ol.proj.EPSG3857.CODES = [
'EPSG:3857',
'EPSG:102100',
'EPSG:102113',
@@ -69,10 +69,10 @@ ol.projection.EPSG3857.CODES = [
* @const
* @type {Array.<ol.Projection>}
*/
ol.projection.EPSG3857.PROJECTIONS = goog.array.map(
ol.projection.EPSG3857.CODES,
ol.proj.EPSG3857.PROJECTIONS = goog.array.map(
ol.proj.EPSG3857.CODES,
function(code) {
return new ol.projection.EPSG3857(code);
return new ol.proj.EPSG3857(code);
});
@@ -84,7 +84,7 @@ ol.projection.EPSG3857.PROJECTIONS = goog.array.map(
* @param {number=} opt_dimension Dimension (default is 2).
* @return {Array.<number>} Output array of coordinate values.
*/
ol.projection.EPSG3857.fromEPSG4326 = function(
ol.proj.EPSG3857.fromEPSG4326 = function(
input, opt_output, opt_dimension) {
var length = input.length,
dimension = opt_dimension > 1 ? opt_dimension : 2,
@@ -99,8 +99,8 @@ ol.projection.EPSG3857.fromEPSG4326 = function(
}
goog.asserts.assert(output.length % dimension === 0);
for (var i = 0; i < length; i += dimension) {
output[i] = ol.projection.EPSG3857.RADIUS * Math.PI * input[i] / 180;
output[i + 1] = ol.projection.EPSG3857.RADIUS *
output[i] = ol.proj.EPSG3857.RADIUS * Math.PI * input[i] / 180;
output[i + 1] = ol.proj.EPSG3857.RADIUS *
Math.log(Math.tan(Math.PI * (input[i + 1] + 90) / 360));
}
return output;
@@ -115,7 +115,7 @@ ol.projection.EPSG3857.fromEPSG4326 = function(
* @param {number=} opt_dimension Dimension (default is 2).
* @return {Array.<number>} Output array of coordinate values.
*/
ol.projection.EPSG3857.toEPSG4326 = function(input, opt_output, opt_dimension) {
ol.proj.EPSG3857.toEPSG4326 = function(input, opt_output, opt_dimension) {
var length = input.length,
dimension = opt_dimension > 1 ? opt_dimension : 2,
output = opt_output;
@@ -129,9 +129,9 @@ ol.projection.EPSG3857.toEPSG4326 = function(input, opt_output, opt_dimension) {
}
goog.asserts.assert(output.length % dimension === 0);
for (var i = 0; i < length; i += dimension) {
output[i] = 180 * input[i] / (ol.projection.EPSG3857.RADIUS * Math.PI);
output[i] = 180 * input[i] / (ol.proj.EPSG3857.RADIUS * Math.PI);
output[i + 1] = 360 * Math.atan(
Math.exp(input[i + 1] / ol.projection.EPSG3857.RADIUS)) / Math.PI - 90;
Math.exp(input[i + 1] / ol.proj.EPSG3857.RADIUS)) / Math.PI - 90;
}
return output;
};
@@ -140,7 +140,7 @@ ol.projection.EPSG3857.toEPSG4326 = function(input, opt_output, opt_dimension) {
/**
* @inheritDoc
*/
ol.projection.EPSG3857.prototype.getPointResolution =
ol.proj.EPSG3857.prototype.getPointResolution =
function(resolution, point) {
return resolution / ol.math.cosh(point[1] / ol.projection.EPSG3857.RADIUS);
return resolution / ol.math.cosh(point[1] / ol.proj.EPSG3857.RADIUS);
};

View File

@@ -0,0 +1,57 @@
goog.provide('ol.proj.EPSG4326');
goog.require('ol.Projection');
goog.require('ol.ProjectionUnits');
goog.require('ol.proj');
/**
* @constructor
* @extends {ol.Projection}
* @param {string} code Code.
* @param {string=} opt_axisOrientation Axis orientation.
*/
ol.proj.EPSG4326 = function(code, opt_axisOrientation) {
goog.base(this, {
code: code,
units: ol.ProjectionUnits.DEGREES,
extent: ol.proj.EPSG4326.EXTENT,
axisOrientation: opt_axisOrientation,
global: true
});
};
goog.inherits(ol.proj.EPSG4326, ol.Projection);
/**
* Extent of the EPSG:4326 projection which is the whole world.
*
* @const
* @type {ol.Extent}
*/
ol.proj.EPSG4326.EXTENT = [-180, 180, -90, 90];
/**
* Projections equal to EPSG:4326.
*
* @const
* @type {Array.<ol.Projection>}
*/
ol.proj.EPSG4326.PROJECTIONS = [
new ol.proj.EPSG4326('CRS:84'),
new ol.proj.EPSG4326('EPSG:4326', 'neu'),
new ol.proj.EPSG4326('urn:ogc:def:crs:EPSG:6.6:4326', 'neu'),
new ol.proj.EPSG4326('urn:ogc:def:crs:OGC:1.3:CRS84'),
new ol.proj.EPSG4326('urn:ogc:def:crs:OGC:2:84')
];
/**
* @inheritDoc
*/
ol.proj.EPSG4326.prototype.getPointResolution =
function(resolution, point) {
return resolution;
};

View File

@@ -12,11 +12,11 @@
@exportProperty ol.ProjectionUnits.FEET
@exportProperty ol.ProjectionUnits.METERS
@exportSymbol ol.projection.addProjection
@exportSymbol ol.projection.addCommonProjections
@exportSymbol ol.projection.get
@exportSymbol ol.projection.getTransform
@exportSymbol ol.projection.getTransformFromProjections
@exportSymbol ol.projection.transform
@exportSymbol ol.projection.transformWithProjections
@exportSymbol ol.projection.configureProj4jsProjection
@exportSymbol ol.proj.addProjection
@exportSymbol ol.proj.addCommonProjections
@exportSymbol ol.proj.get
@exportSymbol ol.proj.getTransform
@exportSymbol ol.proj.getTransformFromProjections
@exportSymbol ol.proj.transform
@exportSymbol ol.proj.transformWithProjections
@exportSymbol ol.proj.configureProj4jsProjection

View File

@@ -1,7 +1,7 @@
goog.provide('ol.Projection');
goog.provide('ol.ProjectionLike');
goog.provide('ol.ProjectionUnits');
goog.provide('ol.projection');
goog.provide('ol.proj');
goog.require('goog.array');
goog.require('goog.asserts');
@@ -219,8 +219,8 @@ 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.getTransformFromProjections(
this, ol.projection.getProj4jsProjectionFromCode_({
this.toEPSG4326_ = ol.proj.getTransformFromProjections(
this, ol.proj.getProj4jsProjectionFromCode_({
code: 'EPSG:4326',
extent: null
}));
@@ -259,21 +259,21 @@ ol.Proj4jsProjection_.prototype.getProj4jsProj = function() {
* @private
* @type {Object.<string, ol.Proj4jsProjection_>}
*/
ol.projection.proj4jsProjections_ = {};
ol.proj.proj4jsProjections_ = {};
/**
* @private
* @type {Object.<string, ol.Projection>}
*/
ol.projection.projections_ = {};
ol.proj.projections_ = {};
/**
* @private
* @type {Object.<string, Object.<string, ol.TransformFunction>>}
*/
ol.projection.transforms_ = {};
ol.proj.transforms_ = {};
/**
@@ -282,13 +282,12 @@ ol.projection.transforms_ = {};
*
* @param {Array.<ol.Projection>} projections Projections.
*/
ol.projection.addEquivalentProjections = function(projections) {
ol.projection.addProjections(projections);
ol.proj.addEquivalentProjections = function(projections) {
ol.proj.addProjections(projections);
goog.array.forEach(projections, function(source) {
goog.array.forEach(projections, function(destination) {
if (source !== destination) {
ol.projection.addTransform(
source, destination, ol.projection.cloneTransform);
ol.proj.addTransform(source, destination, ol.proj.cloneTransform);
}
});
});
@@ -306,12 +305,12 @@ ol.projection.addEquivalentProjections = function(projections) {
* @param {ol.TransformFunction} inverseTransform Transform from any projection
* in projection2 to any projection in projection1..
*/
ol.projection.addEquivalentTransforms =
ol.proj.addEquivalentTransforms =
function(projections1, projections2, forwardTransform, inverseTransform) {
goog.array.forEach(projections1, function(projection1) {
goog.array.forEach(projections2, function(projection2) {
ol.projection.addTransform(projection1, projection2, forwardTransform);
ol.projection.addTransform(projection2, projection1, inverseTransform);
ol.proj.addTransform(projection1, projection2, forwardTransform);
ol.proj.addTransform(projection2, projection1, inverseTransform);
});
});
};
@@ -321,8 +320,8 @@ ol.projection.addEquivalentTransforms =
* @param {ol.Proj4jsProjection_} proj4jsProjection Proj4js projection.
* @private
*/
ol.projection.addProj4jsProjection_ = function(proj4jsProjection) {
var proj4jsProjections = ol.projection.proj4jsProjections_;
ol.proj.addProj4jsProjection_ = function(proj4jsProjection) {
var proj4jsProjections = ol.proj.proj4jsProjections_;
var code = proj4jsProjection.getCode();
goog.asserts.assert(!goog.object.containsKey(proj4jsProjections, code));
proj4jsProjections[code] = proj4jsProjection;
@@ -332,21 +331,20 @@ ol.projection.addProj4jsProjection_ = function(proj4jsProjection) {
/**
* @param {ol.Projection} projection Projection.
*/
ol.projection.addProjection = function(projection) {
var projections = ol.projection.projections_;
ol.proj.addProjection = function(projection) {
var projections = ol.proj.projections_;
var code = projection.getCode();
projections[code] = projection;
ol.projection.addTransform(
projection, projection, ol.projection.cloneTransform);
ol.proj.addTransform(projection, projection, ol.proj.cloneTransform);
};
/**
* @param {Array.<ol.Projection>} projections Projections.
*/
ol.projection.addProjections = function(projections) {
ol.proj.addProjections = function(projections) {
goog.array.forEach(projections, function(projection) {
ol.projection.addProjection(projection);
ol.proj.addProjection(projection);
});
};
@@ -354,12 +352,12 @@ ol.projection.addProjections = function(projections) {
/**
* FIXME empty description for jsdoc
*/
ol.projection.clearAllProjections = function() {
ol.proj.clearAllProjections = function() {
if (ol.ENABLE_PROJ4JS) {
ol.projection.proj4jsProjections_ = {};
ol.proj.proj4jsProjections_ = {};
}
ol.projection.projections_ = {};
ol.projection.transforms_ = {};
ol.proj.projections_ = {};
ol.proj.transforms_ = {};
};
@@ -368,11 +366,11 @@ ol.projection.clearAllProjections = function() {
* @param {string} defaultCode Default code.
* @return {ol.Projection} Projection.
*/
ol.projection.createProjection = function(projection, defaultCode) {
ol.proj.createProjection = function(projection, defaultCode) {
if (!goog.isDefAndNotNull(projection)) {
return ol.projection.get(defaultCode);
return ol.proj.get(defaultCode);
} else if (goog.isString(projection)) {
return ol.projection.get(projection);
return ol.proj.get(projection);
} else {
goog.asserts.assertInstanceof(projection, ol.Projection);
return projection;
@@ -388,10 +386,10 @@ ol.projection.createProjection = function(projection, defaultCode) {
* @param {ol.Projection} destination Destination.
* @param {ol.TransformFunction} transformFn Transform.
*/
ol.projection.addTransform = function(source, destination, transformFn) {
ol.proj.addTransform = function(source, destination, transformFn) {
var sourceCode = source.getCode();
var destinationCode = destination.getCode();
var transforms = ol.projection.transforms_;
var transforms = ol.proj.transforms_;
if (!goog.object.containsKey(transforms, sourceCode)) {
transforms[sourceCode] = {};
}
@@ -408,10 +406,10 @@ ol.projection.addTransform = function(source, destination, transformFn) {
* @param {ol.Projection} destination Destination projection.
* @return {ol.TransformFunction} transformFn The unregistered transform.
*/
ol.projection.removeTransform = function(source, destination) {
ol.proj.removeTransform = function(source, destination) {
var sourceCode = source.getCode();
var destinationCode = destination.getCode();
var transforms = ol.projection.transforms_;
var transforms = ol.proj.transforms_;
goog.asserts.assert(sourceCode in transforms);
goog.asserts.assert(destinationCode in transforms[sourceCode]);
var transform = transforms[sourceCode][destinationCode];
@@ -430,15 +428,15 @@ ol.projection.removeTransform = function(source, destination) {
* existing projection object, or undefined.
* @return {ol.Projection} Projection.
*/
ol.projection.get = function(projectionLike) {
ol.proj.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];
projection = ol.proj.projections_[code];
if (ol.HAVE_PROJ4JS && !goog.isDef(projection)) {
projection = ol.projection.getProj4jsProjectionFromCode_({
projection = ol.proj.getProj4jsProjectionFromCode_({
code: code,
extent: null
});
@@ -459,9 +457,9 @@ ol.projection.get = function(projectionLike) {
* @private
* @return {ol.Proj4jsProjection_} Proj4js projection.
*/
ol.projection.getProj4jsProjectionFromCode_ = function(options) {
ol.proj.getProj4jsProjectionFromCode_ = function(options) {
var code = options.code;
var proj4jsProjections = ol.projection.proj4jsProjections_;
var proj4jsProjections = ol.proj.proj4jsProjections_;
var proj4jsProjection = proj4jsProjections[code];
if (!goog.isDef(proj4jsProjection)) {
var proj4jsProj = new Proj4js.Proj(code);
@@ -489,15 +487,15 @@ ol.projection.getProj4jsProjectionFromCode_ = function(options) {
* @param {ol.Projection} projection2 Projection 2.
* @return {boolean} Equivalent.
*/
ol.projection.equivalent = function(projection1, projection2) {
ol.proj.equivalent = function(projection1, projection2) {
if (projection1 === projection2) {
return true;
} else if (projection1.getUnits() != projection2.getUnits()) {
return false;
} else {
var transformFn = ol.projection.getTransformFromProjections(
var transformFn = ol.proj.getTransformFromProjections(
projection1, projection2);
return transformFn === ol.projection.cloneTransform;
return transformFn === ol.proj.cloneTransform;
}
};
@@ -511,10 +509,10 @@ ol.projection.equivalent = function(projection1, projection2) {
* @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(
ol.proj.getTransform = function(source, destination) {
var sourceProjection = ol.proj.get(source);
var destinationProjection = ol.proj.get(destination);
return ol.proj.getTransformFromProjections(
sourceProjection, destinationProjection);
};
@@ -527,9 +525,9 @@ ol.projection.getTransform = function(source, destination) {
* @param {ol.Projection} destinationProjection Destination projection.
* @return {ol.TransformFunction} Transform.
*/
ol.projection.getTransformFromProjections =
ol.proj.getTransformFromProjections =
function(sourceProjection, destinationProjection) {
var transforms = ol.projection.transforms_;
var transforms = ol.proj.transforms_;
var sourceCode = sourceProjection.getCode();
var destinationCode = destinationProjection.getCode();
var transform;
@@ -543,7 +541,7 @@ ol.projection.getTransformFromProjections =
proj4jsSource = sourceProjection;
} else {
proj4jsSource =
ol.projection.getProj4jsProjectionFromCode_({
ol.proj.getProj4jsProjectionFromCode_({
code: sourceCode,
extent: null
});
@@ -554,7 +552,7 @@ ol.projection.getTransformFromProjections =
proj4jsDestination = destinationProjection;
} else {
proj4jsDestination =
ol.projection.getProj4jsProjectionFromCode_({
ol.proj.getProj4jsProjectionFromCode_({
code: destinationCode,
extent: null
});
@@ -590,12 +588,11 @@ ol.projection.getTransformFromProjections =
}
return output;
};
ol.projection.addTransform(
sourceProjection, destinationProjection, transform);
ol.proj.addTransform(sourceProjection, destinationProjection, transform);
}
if (!goog.isDef(transform)) {
goog.asserts.assert(goog.isDef(transform));
transform = ol.projection.identityTransform;
transform = ol.proj.identityTransform;
}
return transform;
};
@@ -607,7 +604,7 @@ ol.projection.getTransformFromProjections =
* @param {number=} opt_dimension Dimension.
* @return {Array.<number>} Input coordinate array (same array as input).
*/
ol.projection.identityTransform = function(input, opt_output, opt_dimension) {
ol.proj.identityTransform = function(input, opt_output, opt_dimension) {
if (goog.isDef(opt_output) && input !== opt_output) {
// TODO: consider making this a warning instead
goog.asserts.fail('This should not be used internally.');
@@ -627,7 +624,7 @@ ol.projection.identityTransform = function(input, opt_output, opt_dimension) {
* @return {Array.<number>} Output coordinate array (new array, same coordinate
* values).
*/
ol.projection.cloneTransform = function(input, opt_output, opt_dimension) {
ol.proj.cloneTransform = function(input, opt_output, opt_dimension) {
var output;
if (goog.isDef(opt_output)) {
for (var i = 0, ii = input.length; i < ii; ++i) {
@@ -647,8 +644,8 @@ ol.projection.cloneTransform = function(input, opt_output, opt_dimension) {
* @param {ol.ProjectionLike} destination Destination.
* @return {ol.Coordinate} Point.
*/
ol.projection.transform = function(point, source, destination) {
var transformFn = ol.projection.getTransform(source, destination);
ol.proj.transform = function(point, source, destination) {
var transformFn = ol.proj.getTransform(source, destination);
return transformFn(point);
};
@@ -661,9 +658,9 @@ ol.projection.transform = function(point, source, destination) {
* @param {ol.Projection} destinationProjection Destination projection.
* @return {ol.Coordinate} Point.
*/
ol.projection.transformWithProjections =
ol.proj.transformWithProjections =
function(point, sourceProjection, destinationProjection) {
var transformFn = ol.projection.getTransformFromProjections(
var transformFn = ol.proj.getTransformFromProjections(
sourceProjection, destinationProjection);
return transformFn(point);
};
@@ -673,8 +670,8 @@ ol.projection.transformWithProjections =
* @param {ol.Proj4jsProjectionOptions} options Proj4js projection options.
* @return {ol.Projection} Proj4js projection.
*/
ol.projection.configureProj4jsProjection = function(options) {
ol.proj.configureProj4jsProjection = function(options) {
goog.asserts.assert(!goog.object.containsKey(
ol.projection.proj4jsProjections_, options.code));
return ol.projection.getProj4jsProjectionFromCode_(options);
ol.proj.proj4jsProjections_, options.code));
return ol.proj.getProj4jsProjectionFromCode_(options);
};

View File

@@ -1,3 +0,0 @@
/**
* @namespace ol.projection
*/

View File

@@ -1,23 +0,0 @@
goog.provide('ol.projection.addCommonProjections');
goog.require('ol.projection');
goog.require('ol.projection.EPSG3857');
goog.require('ol.projection.EPSG4326');
/**
* FIXME empty description for jsdoc
*/
ol.projection.addCommonProjections = function() {
// Add transformations that don't alter coordinates to convert within set of
// projections with equal meaning.
ol.projection.addEquivalentProjections(ol.projection.EPSG3857.PROJECTIONS);
ol.projection.addEquivalentProjections(ol.projection.EPSG4326.PROJECTIONS);
// Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like
// coordinates and back.
ol.projection.addEquivalentTransforms(
ol.projection.EPSG4326.PROJECTIONS,
ol.projection.EPSG3857.PROJECTIONS,
ol.projection.EPSG3857.fromEPSG4326,
ol.projection.EPSG3857.toEPSG4326);
};

View File

@@ -1,57 +0,0 @@
goog.provide('ol.projection.EPSG4326');
goog.require('ol.Projection');
goog.require('ol.ProjectionUnits');
goog.require('ol.projection');
/**
* @constructor
* @extends {ol.Projection}
* @param {string} code Code.
* @param {string=} opt_axisOrientation Axis orientation.
*/
ol.projection.EPSG4326 = function(code, opt_axisOrientation) {
goog.base(this, {
code: code,
units: ol.ProjectionUnits.DEGREES,
extent: ol.projection.EPSG4326.EXTENT,
axisOrientation: opt_axisOrientation,
global: true
});
};
goog.inherits(ol.projection.EPSG4326, ol.Projection);
/**
* Extent of the EPSG:4326 projection which is the whole world.
*
* @const
* @type {ol.Extent}
*/
ol.projection.EPSG4326.EXTENT = [-180, 180, -90, 90];
/**
* Projections equal to EPSG:4326.
*
* @const
* @type {Array.<ol.Projection>}
*/
ol.projection.EPSG4326.PROJECTIONS = [
new ol.projection.EPSG4326('CRS:84'),
new ol.projection.EPSG4326('EPSG:4326', 'neu'),
new ol.projection.EPSG4326('urn:ogc:def:crs:EPSG:6.6:4326', 'neu'),
new ol.projection.EPSG4326('urn:ogc:def:crs:OGC:1.3:CRS84'),
new ol.projection.EPSG4326('urn:ogc:def:crs:OGC:2:84')
];
/**
* @inheritDoc
*/
ol.projection.EPSG4326.prototype.getPointResolution =
function(resolution, point) {
return resolution;
};

View File

@@ -9,7 +9,7 @@ goog.require('ol.Size');
goog.require('ol.TileRange');
goog.require('ol.TileUrlFunction');
goog.require('ol.extent');
goog.require('ol.projection');
goog.require('ol.proj');
goog.require('ol.source.ImageTileSource');
goog.require('ol.tilegrid.XYZ');
@@ -25,7 +25,7 @@ ol.source.BingMaps = function(options) {
goog.base(this, {
crossOrigin: 'anonymous',
opaque: true,
projection: ol.projection.get('EPSG:3857')
projection: ol.proj.get('EPSG:3857')
});
/**
@@ -95,7 +95,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
* @return {string|undefined} Tile URL.
*/
function(tileCoord, projection) {
goog.asserts.assert(ol.projection.equivalent(
goog.asserts.assert(ol.proj.equivalent(
projection, this.getProjection()));
if (goog.isNull(tileCoord)) {
return undefined;
@@ -106,8 +106,8 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
});
})));
var transform = ol.projection.getTransformFromProjections(
ol.projection.get('EPSG:4326'), this.getProjection());
var transform = ol.proj.getTransformFromProjections(
ol.proj.get('EPSG:4326'), this.getProjection());
var attributions = goog.array.map(
resource.imageryProviders,
function(imageryProvider) {

View File

@@ -5,7 +5,7 @@ goog.require('goog.events.EventType');
goog.require('goog.functions');
goog.require('ol.Attribution');
goog.require('ol.Extent');
goog.require('ol.projection');
goog.require('ol.proj');
@@ -22,7 +22,7 @@ ol.source.Source = function(options) {
* @private
* @type {ol.Projection}
*/
this.projection_ = ol.projection.get(options.projection);
this.projection_ = ol.proj.get(options.projection);
/**
* @private

View File

@@ -3,7 +3,7 @@ goog.provide('ol.source.StaticImage');
goog.require('ol.Image');
goog.require('ol.ImageUrlFunctionType');
goog.require('ol.extent');
goog.require('ol.projection');
goog.require('ol.proj');
goog.require('ol.source.ImageSource');
@@ -21,7 +21,7 @@ ol.source.StaticImage = function(options) {
var imageExtent = options.imageExtent;
var imageSize = options.imageSize;
var imageResolution = (imageExtent[3] - imageExtent[2]) / imageSize.height;
var projection = ol.projection.get(options.projection);
var projection = ol.proj.get(options.projection);
goog.base(this, {
attributions: options.attributions,

View File

@@ -14,7 +14,7 @@ goog.require('ol.Attribution');
goog.require('ol.TileRange');
goog.require('ol.TileUrlFunction');
goog.require('ol.extent');
goog.require('ol.projection');
goog.require('ol.proj');
goog.require('ol.source.ImageTileSource');
goog.require('ol.tilegrid.XYZ');
@@ -45,7 +45,7 @@ ol.source.TileJSON = function(options) {
goog.base(this, {
crossOrigin: options.crossOrigin,
projection: ol.projection.get('EPSG:3857')
projection: ol.proj.get('EPSG:3857')
});
/**
@@ -72,13 +72,13 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function() {
var tileJSON = ol.tilejson.grids_.pop();
var epsg4326Projection = ol.projection.get('EPSG:4326');
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 transform = ol.projection.getTransformFromProjections(
var transform = ol.proj.getTransformFromProjections(
epsg4326Projection, this.getProjection());
extent = ol.extent.transform(epsg4326Extent, transform);
this.setExtent(extent);

View File

@@ -10,7 +10,7 @@ goog.require('ol.TileCoord');
goog.require('ol.TileUrlFunction');
goog.require('ol.TileUrlFunctionType');
goog.require('ol.extent');
goog.require('ol.projection');
goog.require('ol.proj');
goog.require('ol.source.ImageTileSource');
goog.require('ol.tilegrid.WMTS');
@@ -212,7 +212,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, layer) {
var tileGrid = ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet(
matrixSetObj);
var projection = ol.projection.get(matrixSetObj['supportedCRS']);
var projection = ol.proj.get(matrixSetObj['supportedCRS']);
var gets = wmtsCap['operationsMetadata']['GetTile']['dcp']['http']['get'];
var encodings = goog.object.getKeys(

View File

@@ -5,7 +5,7 @@ goog.require('ol.Attribution');
goog.require('ol.Projection');
goog.require('ol.TileUrlFunction');
goog.require('ol.TileUrlFunctionType');
goog.require('ol.projection');
goog.require('ol.proj');
goog.require('ol.source.ImageTileSource');
goog.require('ol.tilegrid.XYZ');
@@ -33,7 +33,7 @@ ol.source.XYZOptions;
*/
ol.source.XYZ = function(options) {
var projection = options.projection || ol.projection.get('EPSG:3857');
var projection = options.projection || ol.proj.get('EPSG:3857');
/**
* @type {ol.TileUrlFunctionType}

View File

@@ -3,7 +3,7 @@ goog.provide('ol.tilegrid.WMTS');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('ol.Size');
goog.require('ol.projection');
goog.require('ol.proj');
goog.require('ol.tilegrid.TileGrid');
@@ -67,7 +67,7 @@ ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet =
var matrixIds = [];
var origins = [];
var tileSizes = [];
var projection = ol.projection.get(matrixSet['supportedCRS']);
var projection = ol.proj.get(matrixSet['supportedCRS']);
var metersPerUnit = projection.getMetersPerUnit();
goog.array.forEach(matrixSet['matrixIds'], function(elt, index, array) {
matrixIds.push(elt['identifier']);

View File

@@ -4,8 +4,8 @@ goog.require('goog.math');
goog.require('ol.Size');
goog.require('ol.TileCoord');
goog.require('ol.TileRange');
goog.require('ol.projection');
goog.require('ol.projection.EPSG3857');
goog.require('ol.proj');
goog.require('ol.proj.EPSG3857');
goog.require('ol.tilegrid.TileGrid');
@@ -19,15 +19,14 @@ ol.tilegrid.XYZ = function(options) {
var resolutions = new Array(options.maxZoom + 1);
var z;
var size = 2 * ol.projection.EPSG3857.HALF_SIZE / ol.DEFAULT_TILE_SIZE;
var size = 2 * ol.proj.EPSG3857.HALF_SIZE / ol.DEFAULT_TILE_SIZE;
for (z = 0; z <= options.maxZoom; ++z) {
resolutions[z] = size / Math.pow(2, z);
}
goog.base(this, {
minZoom: options.minZoom,
origin: [-ol.projection.EPSG3857.HALF_SIZE,
ol.projection.EPSG3857.HALF_SIZE],
origin: [-ol.proj.EPSG3857.HALF_SIZE, ol.proj.EPSG3857.HALF_SIZE],
resolutions: resolutions,
tileSize: new ol.Size(ol.DEFAULT_TILE_SIZE, ol.DEFAULT_TILE_SIZE)
});

View File

@@ -15,7 +15,7 @@ goog.require('ol.Size');
goog.require('ol.View');
goog.require('ol.coordinate');
goog.require('ol.extent');
goog.require('ol.projection');
goog.require('ol.proj');
/**
@@ -47,7 +47,7 @@ ol.View2D = function(opt_options) {
var values = {};
values[ol.View2DProperty.CENTER] = goog.isDef(options.center) ?
options.center : null;
values[ol.View2DProperty.PROJECTION] = ol.projection.createProjection(
values[ol.View2DProperty.PROJECTION] = ol.proj.createProjection(
options.projection, 'EPSG:3857');
if (goog.isDef(options.resolution)) {
values[ol.View2DProperty.RESOLUTION] = options.resolution;
@@ -405,7 +405,7 @@ ol.View2D.createResolutionConstraint_ = function(options) {
} else {
maxResolution = options.maxResolution;
if (!goog.isDef(maxResolution)) {
var projectionExtent = ol.projection.createProjection(
var projectionExtent = ol.proj.createProjection(
options.projection, 'EPSG:3857').getExtent();
maxResolution = Math.max(
projectionExtent[1] - projectionExtent[0],