Skip to content
Browse files

Geometry type enumeration

  • Loading branch information...
1 parent 0fad239 commit 6ef2184c8352e7cd86ce49cae413dc1e1e5b7a78 @tschaub tschaub committed Jan 21, 2013
View
21 src/ol/geom/geometry.js
@@ -2,6 +2,7 @@ goog.require('ol.Extent');
goog.provide('ol.geom.Coordinate');
goog.provide('ol.geom.CoordinateArray');
goog.provide('ol.geom.Geometry');
+goog.provide('ol.geom.GeometryType');
@@ -26,6 +27,13 @@ ol.geom.Geometry.prototype.getBounds = goog.abstractMethod;
/**
+ * Get the geometry type.
+ * @return {ol.geom.GeometryType} The geometry type.
+ */
+ol.geom.Geometry.prototype.getType = function() {};
+
+
+/**
* @typedef {Array.<number>}
*/
ol.geom.Coordinate;
@@ -35,3 +43,16 @@ ol.geom.Coordinate;
* @typedef {Array.<ol.geom.Coordinate>}
*/
ol.geom.CoordinateArray;
+
+
+/**
+ * @enum {string}
+ */
+ol.geom.GeometryType = {
+ POINT: 'point',
+ LINESTRING: 'linestring',
+ POLYGON: 'polygon',
+ MULTIPOINT: 'multipoint',
+ MULTILINESTRING: 'multilinestring',
+ MULTIPOLYGON: 'multipolygon'
+};
View
9 src/ol/geom/linestring.js
@@ -5,6 +5,7 @@ goog.require('goog.vec.Float64Array');
goog.require('ol.Extent');
goog.require('ol.geom.CoordinateArray');
goog.require('ol.geom.Geometry');
+goog.require('ol.geom.GeometryType');
@@ -71,3 +72,11 @@ ol.geom.LineString.prototype.getBounds = function() {
}
return this.bounds_;
};
+
+
+/**
+ * @inheritDoc
+ */
+ol.geom.LineString.prototype.getType = function() {
+ return ol.geom.GeometryType.LINESTRING;
+};
View
9 src/ol/geom/multilinestring.js
@@ -3,6 +3,7 @@ goog.provide('ol.geom.MultiLineString');
goog.require('goog.asserts');
goog.require('ol.geom.CoordinateArray');
goog.require('ol.geom.GeometryCollection');
+goog.require('ol.geom.GeometryType');
goog.require('ol.geom.LineString');
@@ -39,3 +40,11 @@ ol.geom.MultiLineString = function(coordinates) {
};
goog.inherits(ol.geom.MultiLineString, ol.geom.GeometryCollection);
+
+
+/**
+ * @inheritDoc
+ */
+ol.geom.MultiLineString.prototype.getType = function() {
+ return ol.geom.GeometryType.MULTILINESTRING;
+};
View
8 src/ol/geom/multipoint.js
@@ -39,3 +39,11 @@ ol.geom.MultiPoint = function(coordinates) {
};
goog.inherits(ol.geom.MultiPoint, ol.geom.GeometryCollection);
+
+
+/**
+ * @inheritDoc
+ */
+ol.geom.MultiPoint.prototype.getType = function() {
+ return ol.geom.GeometryType.MULTIPOINT;
+};
View
9 src/ol/geom/multipolygon.js
@@ -3,6 +3,7 @@ goog.provide('ol.geom.MultiPolygon');
goog.require('goog.asserts');
goog.require('ol.geom.CoordinateArray');
goog.require('ol.geom.GeometryCollection');
+goog.require('ol.geom.GeometryType');
goog.require('ol.geom.Polygon');
@@ -40,3 +41,11 @@ ol.geom.MultiPolygon = function(coordinates) {
};
goog.inherits(ol.geom.MultiPolygon, ol.geom.GeometryCollection);
+
+
+/**
+ * @inheritDoc
+ */
+ol.geom.MultiPolygon.prototype.getType = function() {
+ return ol.geom.GeometryType.MULTIPOLYGON;
+};
View
9 src/ol/geom/point.js
@@ -5,6 +5,7 @@ goog.require('goog.vec.Float64Array');
goog.require('ol.Extent');
goog.require('ol.geom.Coordinate');
goog.require('ol.geom.Geometry');
+goog.require('ol.geom.GeometryType');
@@ -46,3 +47,11 @@ ol.geom.Point.prototype.getBounds = function() {
}
return this.bounds_;
};
+
+
+/**
+ * @inheritDoc
+ */
+ol.geom.Point.prototype.getType = function() {
+ return ol.geom.GeometryType.POINT;
+};
View
9 src/ol/geom/polygon.js
@@ -5,6 +5,7 @@ goog.require('goog.vec.Float64Array');
goog.require('ol.Extent');
goog.require('ol.geom.CoordinateArray');
goog.require('ol.geom.Geometry');
+goog.require('ol.geom.GeometryType');
goog.require('ol.geom.LinearRing');
@@ -54,3 +55,11 @@ ol.geom.Polygon = function(coordinates) {
ol.geom.Polygon.prototype.getBounds = function() {
return this.rings[0].getBounds();
};
+
+
+/**
+ * @inheritDoc
+ */
+ol.geom.Polygon.prototype.getType = function() {
+ return ol.geom.GeometryType.POLYGON;
+};

0 comments on commit 6ef2184

Please sign in to comment.
Something went wrong with that request. Please try again.