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