ol.Proj4jsProjection_ now takes a single argument

This commit is contained in:
Bruno Binet
2013-03-06 21:11:43 +01:00
parent 9d88273161
commit 0e53a3f3c9
2 changed files with 34 additions and 12 deletions

View File

@@ -160,3 +160,8 @@
@exportObjectLiteralProperty ol.ProjectionOptions.extent ol.Extent
@exportObjectLiteralProperty ol.ProjectionOptions.axisOrientation string|undefined
@exportObjectLiteralProperty ol.ProjectionOptions.global boolean|undefined
@exportObjectLiteral ol.Proj4jsProjectionOptions
@exportObjectLiteralProperty ol.Proj4jsProjectionOptions.code string
@exportObjectLiteralProperty ol.Proj4jsProjectionOptions.extent ol.Extent
@exportObjectLiteralProperty ol.Proj4jsProjectionOptions.global boolean|undefined

View File

@@ -175,20 +175,21 @@ ol.Projection.prototype.setDefaultTileGrid = function(tileGrid) {
/**
* @constructor
* @extends {ol.Projection}
* @param {string} code Code.
* @param {Proj4js.Proj} proj4jsProj Proj4js projection.
* @param {ol.Proj4jsProjectionOptions} options Projection config options.
* @private
*/
ol.Proj4jsProjection_ = function(code, proj4jsProj) {
ol.Proj4jsProjection_ = function(proj4jsProj, options) {
var units = /** @type {ol.ProjectionUnits} */ (proj4jsProj.units);
goog.base(this, {
code: code,
var config = /** @type {ol.ProjectionOptions} */ ({
units: units,
extent: null,
axisOrientation: proj4jsProj.axis
});
goog.object.extend(config, options);
goog.base(this, config);
/**
* @private
@@ -219,7 +220,10 @@ ol.Proj4jsProjection_.prototype.getPointResolution =
// average of the width and height.
if (goog.isNull(this.toEPSG4326_)) {
this.toEPSG4326_ = ol.projection.getTransform(
this, ol.projection.getProj4jsProjectionFromCode_('EPSG:4326'));
this, ol.projection.getProj4jsProjectionFromCode_({
code: 'EPSG:4326',
extent: null
}));
}
var vertices = [
point.x - resolution / 2, point.y,
@@ -433,7 +437,10 @@ ol.projection.removeTransform = function(source, destination) {
ol.projection.getFromCode = function(code) {
var projection = ol.projection.projections_[code];
if (ol.HAVE_PROJ4JS && !goog.isDef(projection)) {
projection = ol.projection.getProj4jsProjectionFromCode_(code);
projection = ol.projection.getProj4jsProjectionFromCode_({
code: code,
extent: null
});
}
if (!goog.isDef(projection)) {
goog.asserts.assert(goog.isDef(projection));
@@ -444,11 +451,12 @@ ol.projection.getFromCode = function(code) {
/**
* @param {string} code Code.
* @param {ol.Proj4jsProjectionOptions} options Projection config options.
* @private
* @return {ol.Proj4jsProjection_} Proj4js projection.
*/
ol.projection.getProj4jsProjectionFromCode_ = function(code) {
ol.projection.getProj4jsProjectionFromCode_ = function(options) {
var code = options.code;
var proj4jsProjections = ol.projection.proj4jsProjections_;
var proj4jsProjection = proj4jsProjections[code];
if (!goog.isDef(proj4jsProjection)) {
@@ -456,7 +464,10 @@ ol.projection.getProj4jsProjectionFromCode_ = function(code) {
var srsCode = proj4jsProj.srsCode;
proj4jsProjection = proj4jsProjections[srsCode];
if (!goog.isDef(proj4jsProjection)) {
proj4jsProjection = new ol.Proj4jsProjection_(srsCode, proj4jsProj);
var config = /** @type {ol.Proj4jsProjectionOptions} */
(goog.object.clone(options));
config.code = srsCode;
proj4jsProjection = new ol.Proj4jsProjection_(proj4jsProj, config);
proj4jsProjections[srsCode] = proj4jsProjection;
}
proj4jsProjections[code] = proj4jsProjection;
@@ -509,7 +520,10 @@ ol.projection.getTransform = function(source, destination) {
proj4jsSource = source;
} else {
proj4jsSource =
ol.projection.getProj4jsProjectionFromCode_(source.getCode());
ol.projection.getProj4jsProjectionFromCode_({
code: source.getCode(),
extent: null
});
}
var sourceProj4jsProj = proj4jsSource.getProj4jsProj();
var proj4jsDestination;
@@ -517,7 +531,10 @@ ol.projection.getTransform = function(source, destination) {
proj4jsDestination = destination;
} else {
proj4jsDestination =
ol.projection.getProj4jsProjectionFromCode_(destination.getCode());
ol.projection.getProj4jsProjectionFromCode_({
code: destination.getCode(),
extent: null
});
}
var destinationProj4jsProj = proj4jsDestination.getProj4jsProj();
transform =