@urban-toolkit/autk-core / TriangulatorPolygons
Class: TriangulatorPolygons
Defined in: triangulator-polygons.ts:43
Triangulates polygonal GeoJSON features into fill and border mesh chunks.
TriangulatorPolygons accepts LineString, MultiLineString, Polygon, MultiPolygon, and GeometryCollection features containing those geometry types. Fill meshes are triangulated with earcut after translating vertices into local coordinates relative to the supplied origin. Border meshes are generated as line-index pairs, with open borders for line strings and closed rings for polygon outlines and holes. Unsupported or missing geometries are skipped with a warning.
Constructors
Constructor
new TriangulatorPolygons():
TriangulatorPolygons
Returns
TriangulatorPolygons
Methods
buildBorder()
staticbuildBorder(geojson,origin): [LayerBorder[],LayerBorderComponent[]]
Defined in: triangulator-polygons.ts:112
Builds border line geometry for a feature collection.
Parameters
geojson
FeatureCollection
Source feature collection.
origin
number[]
World-space origin used to derive local XY coordinates.
Returns
[LayerBorder[], LayerBorderComponent[]]
A tuple of border chunks and per-feature border counts.
Throws
Never throws. Unsupported features are skipped with a console warning.
Example
const [borders, borderComps] = TriangulatorPolygons.buildBorder(polyFC, origin);buildMesh()
staticbuildMesh(geojson,origin): [LayerGeometry[],LayerComponent[]]
Defined in: triangulator-polygons.ts:54
Builds triangulated fill geometry for a feature collection.
Parameters
geojson
FeatureCollection
Source feature collection.
origin
number[]
World-space origin used to derive local XY coordinates.
Returns
[LayerGeometry[], LayerComponent[]]
A tuple of mesh chunks and per-feature component counts.
Throws
Never throws. Unsupported features are skipped with a console warning.
Example
const [meshes, comps] = TriangulatorPolygons.buildMesh(polyFC, origin);geometryCollectionToBorderMesh()
staticgeometryCollectionToBorderMesh(feature,origin,featureIndex):object[]
Defined in: triangulator-polygons.ts:366
Flattens supported children of a GeometryCollection into border meshes.
Parameters
feature
Feature
Source feature with GeometryCollection geometry.
origin
number[]
World-space origin used to derive local XY coordinates.
featureIndex
number
Index of the parent feature in the source collection.
Returns
object[]
Border line meshes for all supported child geometries.
Throws
Never throws. Unsupported children are skipped with a console warning.
Example
const borders = TriangulatorPolygons.geometryCollectionToBorderMesh(gcFeature, origin, 0);geometryCollectionToMesh()
staticgeometryCollectionToMesh(feature,origin,featureIndex):object[]
Defined in: triangulator-polygons.ts:341
Flattens supported children of a GeometryCollection into fill meshes.
Parameters
feature
Feature
Source feature with GeometryCollection geometry.
origin
number[]
World-space origin used to derive local XY coordinates.
featureIndex
number
Index of the parent feature in the source collection.
Returns
object[]
Triangulated fill meshes for all supported child geometries.
Throws
Never throws. Unsupported children are skipped with a console warning.
Example
const meshes = TriangulatorPolygons.geometryCollectionToMesh(gcFeature, origin, 0);lineStringToBorderMesh()
staticlineStringToBorderMesh(feature,origin):object[]
Defined in: triangulator-polygons.ts:187
Converts a LineString feature into open border line geometry.
Parameters
feature
Feature
Source feature with LineString geometry.
origin
number[]
World-space origin used to derive local XY coordinates.
Returns
object[]
Border line meshes for the feature.
Throws
Never throws.
Example
const [border] = TriangulatorPolygons.lineStringToBorderMesh(lineFeature, origin);lineStringToMesh()
staticlineStringToMesh(feature,origin):object[]
Defined in: triangulator-polygons.ts:170
Converts a LineString feature into triangulated fill geometry.
Parameters
feature
Feature
Source feature with LineString geometry.
origin
number[]
World-space origin used to derive local XY coordinates.
Returns
object[]
Triangulated fill meshes for the feature.
Throws
Never throws.
Example
const [mesh] = TriangulatorPolygons.lineStringToMesh(lineFeature, origin);multiLineStringToBorderMesh()
staticmultiLineStringToBorderMesh(feature,origin):object[]
Defined in: triangulator-polygons.ts:225
Converts a MultiLineString feature into border line geometry.
Parameters
feature
Feature
Source feature with MultiLineString geometry.
origin
number[]
World-space origin used to derive local XY coordinates.
Returns
object[]
Border line meshes for each constituent line string.
Throws
Never throws.
Example
const borders = TriangulatorPolygons.multiLineStringToBorderMesh(mlsFeature, origin);multiLineStringToMesh()
staticmultiLineStringToMesh(feature,origin):object[]
Defined in: triangulator-polygons.ts:204
Converts a MultiLineString feature into triangulated fill geometry.
Parameters
feature
Feature
Source feature with MultiLineString geometry.
origin
number[]
World-space origin used to derive local XY coordinates.
Returns
object[]
Triangulated fill meshes for each constituent line string.
Throws
Never throws.
Example
const meshes = TriangulatorPolygons.multiLineStringToMesh(mlsFeature, origin);multiPolygonToBorderMesh()
staticmultiPolygonToBorderMesh(feature,origin):object[]
Defined in: triangulator-polygons.ts:317
Converts a MultiPolygon feature into border line geometry.
Parameters
feature
Feature
Source feature with MultiPolygon geometry.
origin
number[]
World-space origin used to derive local XY coordinates.
Returns
object[]
Border line meshes for all rings in all polygons.
Throws
Never throws.
Example
const borders = TriangulatorPolygons.multiPolygonToBorderMesh(mpFeature, origin);multiPolygonToMesh()
staticmultiPolygonToMesh(feature,origin):object[]
Defined in: triangulator-polygons.ts:289
Converts a MultiPolygon feature into triangulated fill geometry.
Parameters
feature
Feature
Source feature with MultiPolygon geometry.
origin
number[]
World-space origin used to derive local XY coordinates.
Returns
object[]
Triangulated fill meshes for each polygon in the collection.
Throws
Never throws.
Example
const meshes = TriangulatorPolygons.multiPolygonToMesh(mpFeature, origin);polygonToBorderMesh()
staticpolygonToBorderMesh(feature,origin):object[]
Defined in: triangulator-polygons.ts:270
Converts a Polygon feature into closed border line geometry.
Parameters
feature
Feature
Source feature with Polygon geometry.
origin
number[]
World-space origin used to derive local XY coordinates.
Returns
object[]
Border line meshes for all polygon rings.
Throws
Never throws.
Example
const borders = TriangulatorPolygons.polygonToBorderMesh(polyFeature, origin);polygonToMesh()
staticpolygonToMesh(feature,origin):object[]
Defined in: triangulator-polygons.ts:246
Converts a Polygon feature into triangulated fill geometry with hole support.
Parameters
feature
Feature
Source feature with Polygon geometry.
origin
number[]
World-space origin used to derive local XY coordinates.
Returns
object[]
Triangulated fill meshes for the polygon, including holes.
Throws
Never throws.
Example
const [mesh] = TriangulatorPolygons.polygonToMesh(polyFeature, origin);