Add a basic geometry interface
This commit is contained in:
+18
-3
@@ -1,11 +1,13 @@
|
|||||||
goog.provide('ol.geom.Geometry');
|
goog.provide('ol.geom.Geometry');
|
||||||
|
|
||||||
|
goog.require('ol.geom.IGeometry');
|
||||||
goog.require('ol.Bounds');
|
goog.require('ol.Bounds');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates ol.Geometry objects.
|
* Creates ol.Geometry objects.
|
||||||
*
|
*
|
||||||
* @export
|
* @export
|
||||||
|
* @implements {ol.geom.IGeometry}
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
ol.geom.Geometry = function() {
|
ol.geom.Geometry = function() {
|
||||||
@@ -34,10 +36,23 @@ ol.geom.Geometry.prototype.setBounds = function(bounds) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns ol.Loc
|
* Returns the centroid of the geometry.
|
||||||
|
*
|
||||||
|
* @returns {ol.geom.Point} The centroid of the geometry.
|
||||||
*/
|
*/
|
||||||
ol.geom.Geometry.prototype.getCentroid = function() {
|
ol.geom.Geometry.prototype.getCentroid = function() {
|
||||||
//FIXME: stub only to get popups working
|
// throw an error to enforce subclasses to implement it properly
|
||||||
return new ol.Loc(-76,45);
|
ol.error('ol.geom.Geometry: getCentroid must be implemented by subclasses');
|
||||||
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the area of the geometry.
|
||||||
|
*
|
||||||
|
* @returns {number} The area of the geometry.
|
||||||
|
*/
|
||||||
|
ol.geom.Geometry.prototype.getArea = function() {
|
||||||
|
// throw an error to enforce subclasses to implement it properly
|
||||||
|
ol.error('ol.geom.Geometry: getArea must be implemented by subclasses');
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
goog.provide('ol.geom.IGeometry');
|
||||||
|
|
||||||
|
//goog.require('ol.geom.Point');
|
||||||
|
//goog.require('ol.Bounds');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for geometry classes forcing ol.geom.* classes to implement
|
||||||
|
* expected functionality.
|
||||||
|
*
|
||||||
|
* @interface
|
||||||
|
*/
|
||||||
|
ol.geom.IGeometry = function(){};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol.geom.Point} The centroid of the geometry.
|
||||||
|
*/
|
||||||
|
ol.geom.IGeometry.prototype.getCentroid = function(){};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol.Bounds|undefined} The centroid of the geometry.
|
||||||
|
*/
|
||||||
|
ol.geom.IGeometry.prototype.getBounds = function(){};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {number} The area of the geometry.
|
||||||
|
*/
|
||||||
|
ol.geom.IGeometry.prototype.getArea = function(){};
|
||||||
Reference in New Issue
Block a user