Discriminated union of all supported geometry types.
Use the type property to narrow to a specific geometry interface:
type
function describe(geom: Geometry): string { switch (geom.type) { case 'Point': return `Point at (${geom.coordinates[0]}, ${geom.coordinates[1]})`; case 'LineString': return `LineString with ${geom.coordinates.length / getStride(geom)} vertices`; // ... other cases }} Copy
function describe(geom: Geometry): string { switch (geom.type) { case 'Point': return `Point at (${geom.coordinates[0]}, ${geom.coordinates[1]})`; case 'LineString': return `LineString with ${geom.coordinates.length / getStride(geom)} vertices`; // ... other cases }}
Discriminated union of all supported geometry types.
Use the
typeproperty to narrow to a specific geometry interface: