diff --git a/src/ol/geom/geometry.js b/src/ol/geom/geometry.js index bed5760b08..334d43c701 100644 --- a/src/ol/geom/geometry.js +++ b/src/ol/geom/geometry.js @@ -16,6 +16,7 @@ goog.require('ol.geom.flat'); ol.geom.Type = { POINT: 'Point', LINE_STRING: 'LineString', + LINEAR_RING: 'LinearRing', POLYGON: 'Polygon', MULTI_POINT: 'MultiPoint', MULTI_LINE_STRING: 'MultiLineString', diff --git a/src/ol/geom/linearring.exports b/src/ol/geom/linearring.exports new file mode 100644 index 0000000000..59792c22b9 --- /dev/null +++ b/src/ol/geom/linearring.exports @@ -0,0 +1,4 @@ +@exportSymbol ol.geom.LinearRing +@exportProperty ol.geom.LinearRing.prototype.getCoordinates +@exportProperty ol.geom.LinearRing.prototype.getType +@exportProperty ol.geom.LinearRing.prototype.setCoordinates diff --git a/src/ol/geom/linearring.js b/src/ol/geom/linearring.js new file mode 100644 index 0000000000..555c91d516 --- /dev/null +++ b/src/ol/geom/linearring.js @@ -0,0 +1,48 @@ +goog.provide('ol.geom.LinearRing'); + +goog.require('ol.geom.Geometry'); +goog.require('ol.geom.flat'); + + + +/** + * @constructor + * @extends {ol.geom.Geometry} + * @param {ol.geom.RawLinearRing} coordinates Coordinates. + * @param {ol.geom.Layout=} opt_layout Layout. + */ +ol.geom.LinearRing = function(coordinates, opt_layout) { + goog.base(this); + this.setCoordinates(coordinates, opt_layout); +}; +goog.inherits(ol.geom.LinearRing, ol.geom.Geometry); + + +/** + * @return {ol.geom.RawLinearRing} Coordinates. + */ +ol.geom.LinearRing.prototype.getCoordinates = function() { + return ol.geom.flat.inflateCoordinates( + this.flatCoordinates, 0, this.flatCoordinates.length, this.stride); +}; + + +/** + * @inheritDoc + */ +ol.geom.LinearRing.prototype.getType = function() { + return ol.geom.Type.LINEAR_RING; +}; + + +/** + * @param {ol.geom.RawLinearRing} coordinates Coordinates. + * @param {ol.geom.Layout=} opt_layout Layout. + */ +ol.geom.LinearRing.prototype.setCoordinates = + function(coordinates, opt_layout) { + this.setLayout(opt_layout, coordinates, 1); + ol.geom.flat.deflateCoordinates( + this.flatCoordinates, 0, coordinates, this.stride); + this.dispatchChangeEvent(); +};