Remove the mixin approach and give the Point class a projection.

This commit is contained in:
Marc Jansen
2012-06-20 11:18:07 +02:00
parent 073c636cb2
commit aec8f953e5
5 changed files with 119 additions and 55 deletions

View File

@@ -1,7 +1,6 @@
goog.provide('ol.geom.Geometry');
goog.require('ol.Bounds');
goog.require('ol.mixins.coordinate');
/**
* Creates ol.Geometry objects.

View File

@@ -1,7 +1,9 @@
goog.provide('ol.geom.Point');
goog.provide('ol.geom.Point');
goog.require('ol.geom.Geometry');
goog.require('ol.mixins.coordinate');
goog.require('ol.interfaces.coordinateAccessor');
goog.require('ol.Projection');
goog.require('ol.coord.AccessorInterface');
/**
* Creates ol.geom.Point objects.
@@ -10,12 +12,13 @@ goog.require('ol.interfaces.coordinateAccessor');
* @param {number} x X.
* @param {number} y Y.
* @param {number=} opt_z Z.
* @param {ol.Projection=} opt_projection Projection.
*
* @implements {ol.interfaces.coordinateAccessor}
* @implements {ol.coord.AccessorInterface}
*
* @constructor
*/
ol.geom.Point = function(x, y, opt_z) {
ol.geom.Point = function(x, y, opt_z, opt_projection) {
/**
* @private
* @type {number}
@@ -33,33 +36,73 @@ ol.geom.Point = function(x, y, opt_z) {
* @type {number|undefined}
*/
this.z_ = opt_z;
/**
* @private
* @type {ol.Projection}
*/
this.projection_ = goog.isDef(opt_projection) ? opt_projection : null;
};
goog.inherits(ol.geom.Point, ol.geom.Geometry);
goog.mixin(ol.geom.Point.prototype, ol.mixins.coordinate);
/**
* @return {number} X.
*/
ol.geom.Point.prototype.getX = function() {
return this.x_;
};
/**
* @return {number} Y.
*/
ol.geom.Point.prototype.getY = function() {
return this.y_;
};
/**
* @return {number|undefined} Z.
*/
ol.geom.Point.prototype.getZ = function() {
return this.z_;
};
/**
* @return {ol.Projection|undefined} Projection.
*/
ol.geom.Point.prototype.getProjection = function() {
return this.projection_;
};
/**
* @param {ol.Projection} projection Projection.
*/
ol.geom.Point.prototype.setProjection = function(projection) {
this.projection_ = projection;
};
/**
* @param {number} x X.
*/
ol.geom.Point.prototype.setX = function(x) {
this.x_ = x;
};
/**
* @param {number} y Y.
*/
ol.geom.Point.prototype.setY = function(y) {
this.y_ = y;
};
/**
* @param {number|undefined} z Z.
*/
ol.geom.Point.prototype.setZ = function(z) {
this.z_ = z;
};
///**
// * @override
// */
//ol.geom.Point.prototype.getX = ol.geom.Point.prototype.getX;
///**
// * @override
// */
//ol.geom.Point.prototype.setX = ol.geom.Point.prototype.setX;
///**
// * @override
// */
//ol.geom.Point.prototype.getY = ol.geom.Point.prototype.getY;
///**
// * @override
// */
//ol.geom.Point.prototype.setY = ol.geom.Point.prototype.setY;
///**
// * @override
// */
//ol.geom.Point.prototype.getZ = ol.geom.Point.prototype.getZ;
///**
// * @override
// */
//ol.geom.Point.prototype.setZ = ol.geom.Point.prototype.setZ;