Add ol.geom.LinearRing

This commit is contained in:
Tom Payne
2013-11-30 19:28:00 +01:00
parent 1ecdd675ab
commit b2a93dcda7
3 changed files with 53 additions and 0 deletions

View File

@@ -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',

View File

@@ -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

48
src/ol/geom/linearring.js Normal file
View File

@@ -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();
};