FeatureGeometry
(For high level concepts about how to use Lua to write scripted tasks, please see VR-Forces User's Guide.)
This module contains contains functions for operating on FeatureGeometry objects. FeatureGeometry objects are points, lines, or areas, and may be created and operated on whether their shape comes from features, or a simObject, or is just created by a script. They are created with the vrf functions
makeAreaGeometry from one or more Location3D objects.
makePathGeometry
makePointGeometry
FeatureGeometry objects and functions implement the Dimensionally Extended nine-Intersection Model (DE-9IM) geometry model. More information can be found at https://en.wikipedia.org/wiki/DE-9IM. Technical descriptions of the various functions (i.e. crosses vs overlaps) are described in this link.
Function List
| asArea () | Returns the geometry as an area geometry. |
| closestPointTo (geometry) | Return the closest point on this geometry to the passed in geometry (returned as a point FeatureGeometry). |
| contains (geometry) | Returns true if the geometry contains the argument geometry. |
| covers (geometry) | Returns true if the geometry covers the argument geometry. |
| crosses (geometry) | Returns true if the geometries cross. |
| description () | Return a description of the geometry. |
| equals (geometry) | Returns true if the two geometries are equal. |
| getArea () | Returns the area of the geometry (returns zero for geometries that are not areas). |
| getBoundary () | Returns the boundary of an area geometry (as a path geometry). |
| getBuffered (width) | Returns a geometry that is buffered by width (expanded in all directions). |
| getCentroid () | Returns the centroid of the geometry as a point FeatureGeometry. |
| getConvexHull () | Returns the convex hull of the geometry. |
| getDifferenceWith (geometry) | Returns a geometry which is the difference of two geometries. |
| getDimension () | Returns the dimension of the geometry (i.e. |
| getDistanceTo (geometry) | Returns the minimum distance between two geometries. |
| getExtent () | Returns the axis aligned bounding box of the geometry. |
| getIntersectionWith (geometry) | Returns a geometry which is the intersection of two geometries. |
| getLength () | Returns the length of the geometry if it is a path geometry. |
| getNumberOfGeometries () | Returns the number of subgeometries (for example holes in an area geometry). |
| getNumberOfPoints () | Returns the number of the points in the internal representation. |
| getPoints () | Returns all the points in the internal representation. |
| getPointsWithHeight () | Returns all the points in the internal representation. |
| getPointsWithoutHeight () | Returns all the points in the internal representation. |
| getSimplified (tolerance) | Returns a simplified version of the geometry with points that are at least tolerance meters apart. |
| getSinglePointWithHeight () | Returns a single point (the first) in this geometry. |
| getSubGeometries () | Returns all the subgeometries of this geometry (if there are any). |
| getType () | Return a string representation of the type of geometry. |
| getUnionWith (geometry) | Returns a geometry which is the union of two geometries. |
| getWKT () | Return a WKT (well known text, as defined by the Open Geospatial Consortium) encoding of the geometry. |
| intersects (geometry) | Returns true if the two geometries share any points. |
| isArea () | Returns true if the geometry is an area geometry. |
| isEmpty () | Returns true if the geometry is empty. |
| isPath () | Returns true if the geometry is a path geometry. |
| isPoint () | Returns true if the geometry is a point geometry. |
| isUnknown () | Returns true if the geometry is of an unknown type. |
| isValid () | Returns true if the geometry is valid. |
| overlaps (geometry) | Returns true if the geometries overlap. |
| prepare () | Does some preprocessing a geometry object which can make subsequent computations faster. |
| touches (geometry) | Returns true if the geometries touch. |
| within (geometry) | Returns true if the geometry is within the argument geometry. |
Functions
- asArea ()
-
Returns the geometry as an area geometry.
Return value:
- Geometry as an area geometry
- closestPointTo (geometry)
-
Return the closest point on this geometry to the passed in geometry (returned as a point FeatureGeometry). Also the distance as the second return value.
Parameters:
-
geometry: (FeatureGeometry) to check
Usage:
geometryPoint, distance = myGeometry:getClosestPointTo(otherGeometry)
Return values:
- Point geometry representing closest point
- Distance to point
-
- contains (geometry)
-
Returns true if the geometry contains the argument geometry.
Parameters:
-
geometry: (FeatureGeometry): geometry to check if contained by this geometry
Usage:
doesContain = myGeometry:contains(geometry)
Return value:
- True if this geometry contains inputed geometry
-
- covers (geometry)
-
Returns true if the geometry covers the argument geometry.
Parameters:
-
geometry: (FeatureGeometry): geometry to check if covered by this geometry
Usage:
doesCover = myGeometry:covers(geometry)
Return value:
- True if this geometry covers inputed geometry
-
- crosses (geometry)
-
Returns true if the geometries cross.
Parameters:
-
geometry: (FeatureGeometry): geometry to check if crosses with this geometry
Usage:
doCross = myGeometry:crosses(geometry)
Return value:
- True if the two geometries geometries cross.
-
- description ()
-
Return a description of the geometry.
Return value:
- A string giving a description of the geometry. Is it a point, line, or area
- equals (geometry)
-
Returns true if the two geometries are equal.
Parameters:
-
geometry: (FeatureGeometry): geometry to check if equal to this geometry
Usage:
isEqual = myGeometry:equals(geometry) @ return True if geometries are equivalent
-
- getArea ()
-
Returns the area of the geometry (returns zero for geometries that are not areas).
Return value:
- Area of geometry in meters squared
- getBoundary ()
-
Returns the boundary of an area geometry (as a path geometry).
Return value:
- Geometry that represents boundary of geometry as opposed to an extent
- getBuffered (width)
-
Returns a geometry that is buffered by width (expanded in all directions). If the geometry is a point or a path with < 3 vertices, then extra points will be synthesized so that the buffer operation can work on an area geometry. For a point, two points are created with a small offset from the original. For a path, a new point is created between the other two. The returned geometry will always be an area.
Parameters:
-
width: (double) Amount to buffer by.
Usage:
geometry = myGeometry:getBuffered(width)
Return value:
- A new geometry that is this geometry expanded by width in all directions
-
- getCentroid ()
-
Returns the centroid of the geometry as a point FeatureGeometry.
Return value:
- Center of the geometry as a point feature Geometry
- getConvexHull ()
-
Returns the convex hull of the geometry.
Return value:
- Geometry that is convex shell around this geometry
- getDifferenceWith (geometry)
-
Returns a geometry which is the difference of two geometries.
Parameters:
-
geometry: (FeatureGeometry) Geometry difference with.
Usage:
geometry = myGeometry:getDifferenceWith(geometry)
Return value:
- Geometry that the differce between this and inputed geometry
-
- getDimension ()
-
Returns the dimension of the geometry (i.e. 0 for emtpy, 1 for point/line, etc.)
Return value:
- Dimension of geometry
- getDistanceTo (geometry)
-
Returns the minimum distance between two geometries.
Parameters:
-
geometry: (FeatureGeometry): geometry to check distance to
Usage:
distance = myGeometry:getDistanceTo(geometry)
Return value:
- In meters, distance between this geometry and inputed geometry
-
- getExtent ()
-
Returns the axis aligned bounding box of the geometry.
Return value:
- Extent of the geometry as a feature geometry
- getIntersectionWith (geometry)
-
Returns a geometry which is the intersection of two geometries.
Parameters:
-
geometry: (FeatureGeometry) Geometry to intersect with.
Usage:
geometry = myGeometry:getIntersectionWith(geometry)
Return value:
- Geometry that is intersection of this and inputed geometry
-
- getLength ()
-
Returns the length of the geometry if it is a path geometry.
Return value:
- Length of geometry
- getNumberOfGeometries ()
-
Returns the number of subgeometries (for example holes in an area geometry).
Return value:
- The number of subgeometries
- getNumberOfPoints ()
-
Returns the number of the points in the internal representation. Note that for areas, the first point is repeated as the last point, so the number of points for a triangle for example is 4.
Return value:
- The number of points of the geometry
- getPoints ()
-
Returns all the points in the internal representation. Note that for areas, the first point is repeated as the last point, so the number of points for a triangle for example is 4.
Return value:
- A list (table) of Location3Ds of all the points-no altitude.
- getPointsWithHeight ()
-
Returns all the points in the internal representation.
Return value:
- std:vector of Location3Ds of all the points-with altitude.
- getPointsWithoutHeight ()
-
Returns all the points in the internal representation. Note that for areas, the first point is repeated as the last point, so the number of points for a triangle for example is 4. This function sets the altitude of all points to zero.
Return value:
- List (table) of Location3Ds of all the points-no altitude.
- getSimplified (tolerance)
-
Returns a simplified version of the geometry with points that are at least tolerance meters apart.
Parameters:
-
tolerance: (double) Tolerance for merging vertices.
Usage:
geometry = myGeometry:simplify(0.5)
Return value:
- A DtLuaFeatureGeometry Geometry simplified by tolerance in meters between points
-
- getSinglePointWithHeight ()
-
Returns a single point (the first) in this geometry. Also returns a second value which is the validity of the point.
Usage:
pt, valid = FeatureGeometry:singlePointWithHeight()
Return values:
- DtLocation3D First point of geometry.
- Validity of point
- getSubGeometries ()
-
Returns all the subgeometries of this geometry (if there are any).
Return value:
- All the subgeometries if there are any. Think holes in an area
- getType ()
-
Return a string representation of the type of geometry.
Return value:
- String describing type of geometry: "point", "path", or "area".
- getUnionWith (geometry)
-
Returns a geometry which is the union of two geometries.
Parameters:
-
geometry: (FeatureGeometry) geometry to union with.
Usage:
geometry = myGeometry:getUnionWith(geometry)
Return value:
- Geometry that is union between this and inputed geometry
-
- getWKT ()
-
Return a WKT (well known text, as defined by the Open Geospatial Consortium) encoding of the geometry. A WKT representation may not be available for all geometries.
Return value:
- A string description (e.g. "point", "line") followed by vertices of the geometry
- intersects (geometry)
-
Returns true if the two geometries share any points.
Parameters:
-
geometry: (FeatureGeometry): geometry to check if intersects with this geometry
Usage:
doesIntersect = myGeometry:intersects(geometry)
Return value:
- True if the two geometries share any points.
-
- isArea ()
-
Returns true if the geometry is an area geometry.
Return value:
- True if the geometry an area.
- isEmpty ()
-
Returns true if the geometry is empty.
Return value:
- True if the geometry is empty.
- isPath ()
-
Returns true if the geometry is a path geometry.
Return value:
- True if the geometry is a path.
- isPoint ()
-
Returns true if the geometry is a point geometry.
Return value:
- True if this is a point
- isUnknown ()
-
Returns true if the geometry is of an unknown type.
Return value:
- True if the geometry is unknown. Mobius strip maybe?
- isValid ()
-
Returns true if the geometry is valid.
Return value:
- True if the geometry is valid.
- overlaps (geometry)
-
Returns true if the geometries overlap.
Parameters:
-
geometry: (FeatureGeometry): geometry to check if intersects with this geometry
Usage:
doesIntersect = myGeometry:overlaps(geometry)
Return value:
- True if the two geometries geometries overlap.
-
- prepare ()
- Does some preprocessing a geometry object which can make subsequent computations faster.
- touches (geometry)
-
Returns true if the geometries touch.
Parameters:
-
geometry: (FeatureGeometry): geometry to check if touches this geometry
Usage:
doesTouch = myGeometry:touches(geometry)
Return value:
- True if this geometry touches inputed geometry
-
- within (geometry)
-
Returns true if the geometry is within the argument geometry.
Parameters:
-
geometry: (FeatureGeometry): geometry to check if covered by this geometry
Usage:
isWithin = myGeometry:within(geometry)
Return value:
- True if this geometry is within inputed geometry
-
