ALKMaps.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

Summary
ALKMaps.Geometry.LineStringA LineString is a Curve which, once two points have been added to it, can never be less than two points long.
Constructor
ALKMaps.Geometry.LineStringCreate a new LineString geometry
Functions
removeComponentOnly allows removal of a point if there are three or more points in the linestring.
intersectsTest for intersection between two geometries.
getSortedSegments{Array} An array of segment objects.
splitWithSegmentSplit this geometry with the given segment.
splitUse this geometry (the source) to attempt to split a target geometry.
splitWithSplit this geometry (the target) with the given geometry (the source).
getVerticesReturn a list of all points in this geometry.
distanceToCalculate the closest distance between two geometries (on the x-y plane).
simplifyThis function will return a simplified LineString.

Constructor

ALKMaps.Geometry.LineString

Create a new LineString geometry

Parameters

points{Array(ALKMaps.Geometry.Point)} An array of points used to generate the linestring

Functions

removeComponent

removeComponent: function(point)

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{ALKMaps.Geometry.Point} The point to be removed

Returns

{Boolean} The component was removed.

intersects

intersects: function(geometry)

Test for intersection between two geometries.  This is a cheapo implementation of the Bently-Ottmann algorithm.  It doesn’t really keep track of a sweep line data structure.  It is closer to the brute force method, except that segments are sorted and potential intersections are only calculated when bounding boxes intersect.

Parameters

geometry{ALKMaps.Geometry}

Returns

{Boolean} The input geometry intersects this geometry.

getSortedSegments

getSortedSegments: function()

Returns

{Array} An array of segment objects.  Segment objects have properties x1, y1, x2, and y2.  The start point is represented by x1 and y1.  The end point is represented by x2 and y2.  Start and end are ordered so that x1 < x2.

splitWithSegment

splitWithSegment: function(seg,
options)

Split this geometry with the given segment.

Parameters

seg{Object} An object with x1, y1, x2, and y2 properties referencing segment endpoint coordinates.
options{Object} Properties of this object will be used to determine how the split is conducted.

Valid options

edge{Boolean} Allow splitting when only edges intersect.  Default is true.  If false, a vertex on the source segment must be within the tolerance distance of the intersection to be considered a split.
tolerance{Number} If a non-null value is provided, intersections within the tolerance distance of one of the source segment’s endpoints will be assumed to occur at the endpoint.

Returns

{Object} An object with lines and points properties.  If the given segment intersects this linestring, the lines array will reference geometries that result from the split.  The points array will contain all intersection points.  Intersection points are sorted along the segment (in order from x1,y1 to x2,y2).

split

split: function(target,
options)

Use this geometry (the source) to attempt to split a target geometry.

Parameters

target{ALKMaps.Geometry} The target geometry.
options{Object} Properties of this object will be used to determine how the split is conducted.

Valid options

mutual{Boolean} Split the source geometry in addition to the target geometry.  Default is false.
edge{Boolean} Allow splitting when only edges intersect.  Default is true.  If false, a vertex on the source must be within the tolerance distance of the intersection to be considered a split.
tolerance{Number} If a non-null value is provided, intersections within the tolerance distance of an existing vertex on the source will be assumed to occur at the vertex.

Returns

{Array} A list of geometries (of this same type as the target) that result from splitting the target with the source geometry.  The source and target geometry will remain unmodified.  If no split results, null will be returned.  If mutual is true and a split results, return will be an array of two arrays - the first will be all geometries that result from splitting the source geometry and the second will be all geometries that result from splitting the target geometry.

splitWith

splitWith: function(geometry,
options)

Split this geometry (the target) with the given geometry (the source).

Parameters

geometry{ALKMaps.Geometry} A geometry used to split this geometry (the source).
options{Object} Properties of this object will be used to determine how the split is conducted.

Valid options

mutual{Boolean} Split the source geometry in addition to the target geometry.  Default is false.
edge{Boolean} Allow splitting when only edges intersect.  Default is true.  If false, a vertex on the source must be within the tolerance distance of the intersection to be considered a split.
tolerance{Number} If a non-null value is provided, intersections within the tolerance distance of an existing vertex on the source will be assumed to occur at the vertex.

Returns

{Array} A list of geometries (of this same type as the target) that result from splitting the target with the source geometry.  The source and target geometry will remain unmodified.  If no split results, null will be returned.  If mutual is true and a split results, return will be an array of two arrays - the first will be all geometries that result from splitting the source geometry and the second will be all geometries that result from splitting the target geometry.

getVertices

getVertices: function(nodes)

Return a list of all points in this geometry.

Parameters

nodes{Boolean} For lines, only return vertices that are endpoints.  If false, for lines, only vertices that are not endpoints will be returned.  If not provided, all vertices will be returned.

Returns

{Array} A list of all vertices in the geometry.

distanceTo

distanceTo: function(geometry,
options)

Calculate the closest distance between two geometries (on the x-y plane).

Parameters

geometry{ALKMaps.Geometry} The target geometry.
options{Object} Optional properties for configuring the distance calculation.

Valid options

details{Boolean} Return details from the distance calculation.  Default is false.
edge{Boolean} Calculate the distance from this geometry to the nearest edge of the target geometry.  Default is true.  If true, calling distanceTo from a geometry that is wholly contained within the target will result in a non-zero distance.  If false, whenever geometries intersect, calling distanceTo will return 0.  If false, details cannot be returned.

Returns

{Number | Object} The distance between this geometry and the target.  If details is true, the return will be an object with distance, x0, y0, x1, and x2 properties.  The x0 and y0 properties represent the coordinates of the closest point on this geometry.  The x1 and y1 properties represent the coordinates of the closest point on the target geometry.

simplify

simplify: function(tolerance)

This function will return a simplified LineString.  Simplification is based on the Douglas-Peucker algorithm.

Parameters

tolerance{number} threshold for simplification in map units

Returns

{ALKMaps.Geometry.LineString} the simplified LineString

removeComponent: function(point)
Only allows removal of a point if there are three or more points in the linestring.
intersects: function(geometry)
Test for intersection between two geometries.
getSortedSegments: function()
{Array} An array of segment objects.
splitWithSegment: function(seg,
options)
Split this geometry with the given segment.
split: function(target,
options)
Use this geometry (the source) to attempt to split a target geometry.
splitWith: function(geometry,
options)
Split this geometry (the target) with the given geometry (the source).
getVertices: function(nodes)
Return a list of all points in this geometry.
distanceTo: function(geometry,
options)
Calculate the closest distance between two geometries (on the x-y plane).
simplify: function(tolerance)
This function will return a simplified LineString.
A Curve is a MultiPoint, whose points are assumed to be connected.
Point geometry class.
A Geometry is a description of a geographic object.
Close