A Geometry is a description of a geographic object. Create an instance of this class with the ALKMaps.Geometry constructor. This is a base class, typical geometry types are described by subclasses of this class.
ALKMaps. | A Geometry is a description of a geographic object. |
Properties | |
id | {String} A unique identifier for this geometry. |
parent | {ALKMaps.Geometry}This is set when a Geometry is added as component of another geometry |
bounds | {ALKMaps.Bounds} The bounds of this geometry |
Constructor | |
ALKMaps. | Creates a geometry object. |
Functions | |
destroy | Destroy this geometry. |
clone | Create a clone of this geometry. |
setBounds | Set the bounds for this Geometry. |
clearBounds | Nullify this components bounds and that of its parent as well. |
extendBounds | Extend the existing bounds to include the new bounds. |
getBounds | Get the bounds for this Geometry. |
calculateBounds | Recalculate the bounds for the geometry. |
distanceTo | Calculate the closest distance between two geometries (on the x-y plane). |
getVertices | Return a list of all points in this geometry. |
atPoint | |
getLength | Calculate the length of this geometry. |
getArea | Calculate the area of this geometry. |
getCentroid | Calculate the centroid of this geometry. |
toString | Returns a text representation of the geometry. |
ALKMaps. | Generate a geometry given a Well-Known Text string. |
ALKMaps. | Determine whether two line segments intersect. |
ALKMaps. |
{ALKMaps.Geometry}This is set when a Geometry is added as component of another geometry
{ALKMaps.Bounds} The bounds of this geometry
clone: function()
Create a clone of this geometry. Does not set any non-standard properties of the cloned geometry.
{ALKMaps.Geometry} An exact clone of this geometry.
extendBounds: function( newBounds )
Extend the existing bounds to include the new bounds. If geometry’s bounds is not yet set, then set a new Bounds.
newBounds | {ALKMaps.Bounds} |
distanceTo: function( geometry, options )
Calculate the closest distance between two geometries (on the x-y plane).
geometry | {ALKMaps.Geometry} The target geometry. |
options | {Object} Optional properties for configuring the distance calculation. |
Valid options depend on the specific geometry type.
{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.
getVertices: function( nodes )
Return a list of all points in this geometry.
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. |
{Array} A list of all vertices in the geometry.
atPoint: function( lonlat, toleranceLon, toleranceLat )
Note | This is only an approximation based on the bounds of the geometry. |
lonlat | {<ALKMaps.LonLat>|Object} ALKMaps.LonLat or an object with a ‘lon’ and ‘lat’ properties. |
toleranceLon | {float} Optional tolerance in Geometric Coords |
toleranceLat | {float} Optional tolerance in Geographic Coords |
{Boolean} Whether or not the geometry is at the specified location
getCentroid: function()
Calculate the centroid of this geometry. This method is defined in subclasses.
{ALKMaps.Geometry.Point} The centroid of the collection
ALKMaps.Geometry.fromWKT = function( wkt )
Generate a geometry given a Well-Known Text string. For this method to work, you must include the ALKMaps.Format.WKT in your build explicitly.
wkt | {String} A string representing the geometry in Well-Known Text. |
{ALKMaps.Geometry} A geometry of the appropriate class.
ALKMaps.Geometry.segmentsIntersect = function( seg1, seg2, options )
Determine whether two line segments intersect. Optionally calculates and returns the intersection point. This function is optimized for cases where seg1.x2 >= seg2.x1 || seg2.x2 >= seg1.x1. In those obvious cases where there is no intersection, the function should not be called.
seg1 | {Object} Object representing a segment with 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. |
seg2 | {Object} Object representing a segment with 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. |
options | {Object} Optional properties for calculating the intersection. |
point | {Boolean} Return the intersection point. If false, the actual intersection point will not be calculated. If true and the segments intersect, the intersection point will be returned. If true and the segments do not intersect, false will be returned. If true and the segments are coincident, true will be returned. |
tolerance | {Number} If a non-null value is provided, if the segments are within the tolerance distance, this will be considered an intersection. In addition, if the point option is true and the calculated intersection is within the tolerance distance of an end point, the endpoint will be returned instead of the calculated intersection. Further, if the intersection is within the tolerance of endpoints on both segments, or if two segment endpoints are within the tolerance distance of each other (but no intersection is otherwise calculated), an endpoint on the first segment provided will be returned. |
{Boolean | ALKMaps.Geometry.Point} The two segments intersect. If the point argument is true, the return will be the intersection point or false if none exists. If point is true and the segments are coincident, return will be true (and the intersection is equal to the shorter segment).
ALKMaps.Geometry.distanceToSegment = function( point, segment )
point | {Object} An object with x and y properties representing the point coordinates. |
segment | {Object} An object with x1, y1, x2, and y2 properties representing endpoint coordinates. |
{Object} An object with distance, x, and y properties. The distance will be the shortest distance between the input point and segment. The x and y properties represent the coordinates along the segment where the shortest distance meets the segment.
Destroy this geometry.
destroy: function()
Create a clone of this geometry.
clone: function()
Set the bounds for this Geometry.
setBounds: function( bounds )
Nullify this components bounds and that of its parent as well.
clearBounds: function()
Extend the existing bounds to include the new bounds.
extendBounds: function( newBounds )
Get the bounds for this Geometry.
getBounds: function()
Recalculate the bounds for the geometry.
calculateBounds: function()
Calculate the closest distance between two geometries (on the x-y plane).
distanceTo: function( geometry, options )
Return a list of all points in this geometry.
getVertices: function( nodes )
atPoint: function( lonlat, toleranceLon, toleranceLat )
Calculate the length of this geometry.
getLength: function()
Calculate the area of this geometry.
getArea: function()
Calculate the centroid of this geometry.
getCentroid: function()
Returns a text representation of the geometry.
toString: function()
Generate a geometry given a Well-Known Text string.
ALKMaps.Geometry.fromWKT = function( wkt )
Determine whether two line segments intersect.
ALKMaps.Geometry.segmentsIntersect = function( seg1, seg2, options )
ALKMaps.Geometry.distanceToSegment = function( point, segment )