Easier getter/setter for geom.point.

This commit is contained in:
Marc Jansen
2012-06-20 15:42:10 +02:00
parent 0ccbb8e6d0
commit 6b8cd1216f
2 changed files with 132 additions and 41 deletions

View File

@@ -47,4 +47,67 @@ ol.geom.point = function(opt_arg){
var p = new ol.geom.Point(x,y,z,projection);
return p;
};
goog.inherits(ol.geom.point, ol.geom.geometry);
goog.inherits(ol.geom.point, ol.geom.geometry);
/**
* @export
* @param {number=} opt_arg X.
* @return {ol.geom.Point|number} Result.
*/
ol.geom.Point.prototype.x = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setX(opt_arg);
return this;
}
else {
return this.getX();
}
};
/**
* @export
* @param {number=} opt_arg Y.
* @return {ol.geom.Point|number} Result.
*/
ol.geom.Point.prototype.y = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setY(opt_arg);
return this;
}
else {
return this.getY();
}
};
/**
* @export
* @param {number=} opt_arg Z.
* @return {ol.geom.Point|number|undefined} Result.
*/
ol.geom.Point.prototype.z = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setZ(opt_arg);
return this;
}
else {
return this.getZ();
}
};
/**
* @export
* @param {ol.Projection=} opt_arg Projection.
* @return {ol.geom.Point|ol.Projection|undefined} Result.
*/
ol.geom.Point.prototype.projection = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setProjection(ol.projection(opt_arg));
return this;
}
else {
return this.getProjection();
}
};