First state of a geom package.
This commit is contained in:
12
src/api/geom/geometry.js
Normal file
12
src/api/geom/geometry.js
Normal file
@@ -0,0 +1,12 @@
|
||||
goog.provide('ol.geom.geometry');
|
||||
|
||||
goog.require('ol.geom.Geometry');
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @return {ol.geom.Geometry} Geometry..
|
||||
*/
|
||||
ol.geom.geometry = function(){
|
||||
var g = new ol.geom.Geometry();
|
||||
return g;
|
||||
};
|
||||
43
src/api/geom/point.js
Normal file
43
src/api/geom/point.js
Normal file
@@ -0,0 +1,43 @@
|
||||
goog.provide('ol.geom.point');
|
||||
|
||||
goog.require('ol.geom.Point');
|
||||
|
||||
/**
|
||||
* @typedef {ol.PointLike|Array.<number>|Object} point Point.
|
||||
*/
|
||||
ol.PointLike;
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @param {ol.PointLike} opt_arg Point.
|
||||
* @return {ol.geom.Point} Point.
|
||||
*/
|
||||
ol.geom.point = function(opt_arg){
|
||||
|
||||
if (opt_arg instanceof ol.geom.Point) {
|
||||
return opt_arg;
|
||||
}
|
||||
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
var z;
|
||||
|
||||
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||
if (goog.isArray(opt_arg)) {
|
||||
x = opt_arg[0];
|
||||
y = opt_arg[1];
|
||||
z = opt_arg[2];
|
||||
} else if (goog.isObject(opt_arg)) {
|
||||
x = opt_arg.x;
|
||||
y = opt_arg.y;
|
||||
z = opt_arg.z;
|
||||
} else {
|
||||
throw new Error('ol.geom.point');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var p = new ol.geom.Point(x,y,z);
|
||||
return p;
|
||||
};
|
||||
goog.inherits(ol.geom.point, ol.geom.geometry);
|
||||
@@ -3,6 +3,7 @@ goog.require('ol.bounds');
|
||||
goog.require("ol.map");
|
||||
goog.require("ol.loc");
|
||||
goog.require("ol.projection");
|
||||
|
||||
goog.require("ol.Tile");
|
||||
goog.require("ol.TileSet");
|
||||
goog.require("ol.geom.geometry");
|
||||
goog.require("ol.geom.point");
|
||||
|
||||
52
src/ol/geom/Geometry.js
Normal file
52
src/ol/geom/Geometry.js
Normal file
@@ -0,0 +1,52 @@
|
||||
goog.provide('ol.geom.Geometry');
|
||||
|
||||
goog.require('ol.Bounds');
|
||||
goog.require('ol.mixins.coordinate');
|
||||
|
||||
/**
|
||||
* Creates ol.Geometry objects.
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
ol.geom.Geometry = function() {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.Bounds|undefined}
|
||||
*/
|
||||
this.bounds_ = undefined;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.Bounds|undefined} The ol.Bounds.
|
||||
*/
|
||||
ol.geom.Geometry.prototype.getBounds = function() {
|
||||
return this.bounds_;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {ol.Bounds} bounds The new ol.Bounds.
|
||||
* @return {ol.geom.Geometry} This.
|
||||
*/
|
||||
ol.geom.Geometry.prototype.setBounds = function(bounds) {
|
||||
this.bounds_ = bounds;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @param {ol.Bounds=} opt_arg new Bounds.
|
||||
* @return {ol.geom.Geometry|ol.Bounds|undefined} either a Geometry (when used as
|
||||
* setter) or a Bounds/undefined (if used as getter).
|
||||
*/
|
||||
ol.geom.Geometry.prototype.bounds = function(opt_arg){
|
||||
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||
return this.setBounds(opt_arg);
|
||||
} else {
|
||||
return this.getBounds();
|
||||
}
|
||||
};
|
||||
65
src/ol/geom/Point.js
Normal file
65
src/ol/geom/Point.js
Normal file
@@ -0,0 +1,65 @@
|
||||
goog.provide('ol.geom.Point');
|
||||
goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.mixins.coordinate');
|
||||
goog.require('ol.interfaces.coordinateAccessor');
|
||||
|
||||
/**
|
||||
* Creates ol.geom.Point objects.
|
||||
*
|
||||
* @extends {ol.geom.Geometry}
|
||||
* @param {number} x X.
|
||||
* @param {number} y Y.
|
||||
* @param {number=} opt_z Z.
|
||||
*
|
||||
* @implements {ol.interfaces.coordinateAccessor}
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
ol.geom.Point = function(x, y, opt_z) {
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.x_ = x;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.y_ = y;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.z_ = opt_z;
|
||||
};
|
||||
|
||||
goog.inherits(ol.geom.Point, ol.geom.Geometry);
|
||||
|
||||
goog.mixin(ol.geom.Point.prototype, ol.mixins.coordinate);
|
||||
|
||||
///**
|
||||
// * @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;
|
||||
48
src/ol/interfaces/coordinateAccessor.js
Normal file
48
src/ol/interfaces/coordinateAccessor.js
Normal file
@@ -0,0 +1,48 @@
|
||||
goog.provide('ol.interfaces.coordinateAccessor');
|
||||
|
||||
/**
|
||||
* The coordinateAccessor interface
|
||||
*
|
||||
* @lends {ol.geom.Point#}
|
||||
* @interface
|
||||
*
|
||||
* @param {number} x X.
|
||||
* @param {number} y Y.
|
||||
* @param {number=} opt_z Z.
|
||||
*/
|
||||
ol.interfaces.coordinateAccessor = function(x, y, opt_z){
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {number} X.
|
||||
*/
|
||||
ol.interfaces.coordinateAccessor.prototype.getX = function(){};
|
||||
|
||||
/**
|
||||
* @return {number} Y.
|
||||
*/
|
||||
ol.interfaces.coordinateAccessor.prototype.getY = function(){};
|
||||
|
||||
/**
|
||||
* @return {number|undefined} Z.
|
||||
*/
|
||||
ol.interfaces.coordinateAccessor.prototype.getZ = function(){};
|
||||
|
||||
/**
|
||||
* @param {number} x X.
|
||||
* @return {Object} This.
|
||||
*/
|
||||
ol.interfaces.coordinateAccessor.prototype.setX = function(x){};
|
||||
|
||||
/**
|
||||
* @param {number} y Y.
|
||||
* @return {Object} This.
|
||||
*/
|
||||
ol.interfaces.coordinateAccessor.prototype.setY = function(y){};
|
||||
|
||||
/**
|
||||
* @param {number|undefined} z Z.
|
||||
* @return {Object} This.
|
||||
*/
|
||||
ol.interfaces.coordinateAccessor.prototype.setZ = function(z){};
|
||||
31
src/ol/mixins/coordinate.js
Normal file
31
src/ol/mixins/coordinate.js
Normal file
@@ -0,0 +1,31 @@
|
||||
goog.provide('ol.mixins.coordinate');
|
||||
goog.require('goog.object');
|
||||
|
||||
goog.object.extend(ol.mixins.coordinate, {
|
||||
|
||||
getX : function() {
|
||||
return this.x_;
|
||||
},
|
||||
|
||||
getY : function() {
|
||||
return this.y_;
|
||||
},
|
||||
|
||||
getZ : function() {
|
||||
return this.z_;
|
||||
},
|
||||
|
||||
setX : function(x) {
|
||||
this.x_ = x;
|
||||
return this;
|
||||
},
|
||||
|
||||
setY : function(y) {
|
||||
this.y_ = y;
|
||||
return this;
|
||||
},
|
||||
setZ: function(z) {
|
||||
this.z_ = z;
|
||||
return this;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user