VR-Forces 5.3 Lua Function Documentation

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
makePathGeometry
makePointGeometry
from one or more Location3D objects.
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:

    (FeatureGeometry) 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). Also the distance as the second return value.

Parameters:

  • geometry: (FeatureGeometry) to check

Usage:

    geometryPoint, distance = myGeometry:getClosestPointTo(otherGeometry)

Return values:

  1. (FeatureGeometry) The point geometry representing the closest point
  2. (number) The distance to that 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:

    (boolean) True if this geometry contains the input 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:

    (boolean) True if this geometry covers the input 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:

    (boolean) True if the two geometries cross.
description ()
Return a description of the geometry.

Return value:

    (string) 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:

    (number) The area of the geometry in meters squared
getBoundary ()
Returns the boundary of an area geometry (as a path geometry).

Return value:

    (FeatureGeometry) The boundary of the 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:

    (FeatureGeometry) 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:

    (FeatureGeometry) The center of the geometry as a point FeatureGeometry
getConvexHull ()
Returns the convex hull of the geometry.

Return value:

    (FeatureGeometry) The convex hull 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:

    (FeatureGeometry) The geometry that is the difference of this and the input geometry
getDimension ()
Returns the dimension of the geometry (i.e. 0 for emtpy, 1 for point/line, etc.)

Return value:

    (number) The dimension of the 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:

    (number) The distance in meters between this geometry and the input geometry
getExtent ()
Returns the axis aligned bounding box of the geometry.

Return value:

    (FeatureGeometry) The axis-aligned bounding box of the 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:

    (FeatureGeometry) The geometry that is the intersection of this and the input geometry
getLength ()
Returns the length of the geometry if it is a path geometry.

Return value:

    (number) The length of the geometry
getNumberOfGeometries ()
Returns the number of subgeometries (for example holes in an area geometry).

Return value:

    (number) 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:

    (number) 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:

    (table) A list of Location3D points of all the points, without altitude.
getPointsWithHeight ()
Returns all the points in the internal representation.

Return value:

    (table) A list of Location3D points 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:

    (table) A list of Location3D points of all the points, without 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:

    (FeatureGeometry) A 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:

  1. (Location3D) The first point of the geometry.
  2. (boolean) The validity of the point
getSubGeometries ()
Returns all the subgeometries of this geometry (if there are any).

Return value:

    (table) 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) The type of the 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:

    (FeatureGeometry) The geometry that is the union of this and the input 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:

    (boolean) True if the two geometries share any points.
isArea ()
Returns true if the geometry is an area geometry.

Return value:

    (boolean) True if the geometry is an area.
isEmpty ()
Returns true if the geometry is empty.

Return value:

    (boolean) True if the geometry is empty.
isPath ()
Returns true if the geometry is a path geometry.

Return value:

    (boolean) True if the geometry is a path.
isPoint ()
Returns true if the geometry is a point geometry.

Return value:

    (boolean) True if this is a point
isUnknown ()
Returns true if the geometry is of an unknown type.

Return value:

    (boolean) True if the geometry is unknown. Mobius strip maybe?
isValid ()
Returns true if the geometry is valid.

Return value:

    (boolean) 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:

    (boolean) True if the two 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:

    (boolean) True if this geometry touches the input 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:

    (boolean) True if this geometry is within the input geometry

Copyright© 2026 MAK Technologies, Inc. All rights reserved.