git-svn-id: http://svn.openlayers.org/trunk/openlayers@3587 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
50 lines
1.6 KiB
JavaScript
50 lines
1.6 KiB
JavaScript
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
|
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
|
* for the full text of the license. */
|
|
|
|
/**
|
|
* @requires OpenLayers/Geometry/Curve.js
|
|
*
|
|
* Class: OpenLayers.Geometry.LineString
|
|
* A LineString is a Curve which, once two points have been added to it, can
|
|
* never be less than two points long.
|
|
*
|
|
* Inherits from:
|
|
* - <OpenLayers.Geometry.Curve>
|
|
*/
|
|
OpenLayers.Geometry.LineString = OpenLayers.Class.create();
|
|
OpenLayers.Geometry.LineString.prototype =
|
|
OpenLayers.Class.inherit(OpenLayers.Geometry.Curve, {
|
|
|
|
/**
|
|
* Constructor: OpenLayers.Geometry.LineString
|
|
* Create a new LineString geometry
|
|
*
|
|
* Parameters:
|
|
* points - {Array(<OpenLayers.Geometry.Point>)} An array of points used to
|
|
* generate the linestring
|
|
*
|
|
*/
|
|
initialize: function(points) {
|
|
OpenLayers.Geometry.Curve.prototype.initialize.apply(this, arguments);
|
|
},
|
|
|
|
/**
|
|
* APIMethod: removeComponent
|
|
* Only allows removal of a point if there are three or more points in
|
|
* the linestring. (otherwise the result would be just a single point)
|
|
*
|
|
* Parameters:
|
|
* point - {<OpenLayers.Geometry.Point>} The point to be removed
|
|
*/
|
|
removeComponent: function(point) {
|
|
if ( this.components && (this.components.length > 2)) {
|
|
OpenLayers.Geometry.Collection.prototype.removeComponent.apply(this,
|
|
arguments);
|
|
}
|
|
},
|
|
|
|
/** @final @type String */
|
|
CLASS_NAME: "OpenLayers.Geometry.LineString"
|
|
});
|