Skip to content
View as Markdown llms.txt

Vegetation

acquireTrees

Import from @infrared-city/infrared-sdk-ts/geodata.

acquireTrees(bbox, options?): Promise<DirectTreesResult>

Read trees for an area, returning parsed feature objects.

The same read as acquireTreesJson, parsed once.

Parameters

Parameter Type Description
bbox Bbox The area's bounding box in WGS84 degrees.
options AcquireTreesOptions Read options and bestAvailable.

Returns

Promise<DirectTreesResult>

The tree features, the contributing sources and any warnings.

Throws

when the global OpenStreetMap read fails.

Throws

when a data URL is not on the allow-list.


acquireTreesJson

Import from @infrared-city/infrared-sdk-ts/geodata.

acquireTreesJson(bbox, options?): Promise<DirectTreesJson>

Read trees for an area straight from the public data hosts, as JSON text.

Reads the global OpenStreetMap tree layer and, when the area falls inside a registered city (and bestAvailable is not false), that city's open-data overlay, in parallel. The two are normalised and merged, with the city's trees winning over coincident OpenStreetMap trees. If only the overlay fails, the result is still returned and a <city>_overlay_unavailable warning is added.

Parameters

Parameter Type Description
bbox Bbox The area's bounding box in WGS84 degrees.
options AcquireTreesOptions Read options and bestAvailable.

Returns

Promise<DirectTreesJson>

The features as JSON array text, the contributing sources and any warnings.

Throws

when the global OpenStreetMap read fails.

Throws

when a data URL is not on the allow-list.


AreaVegetation

Import from @infrared-city/infrared-sdk-ts.

Trees read for an area.

Properties

Property Modifier Type Description
analysisType readonly string The analysis type the read margin was taken from.
executionTime readonly number Time the read took, in seconds.
failedTiles readonly readonly string[] Ids of the tiles whose read failed; their trees are missing from features.
features readonly Readonly<Record<string, Readonly<Record<string, unknown>>>> The tree features, keyed by tree id, after duplicates between tiles are removed.
polygon readonly Polygon The polygon that was read.
readMarginM readonly number Half extent, in metres, of the read rectangle every tile was fetched with: 363 for the wind analyses and 544 for the others. runArea refuses a run whose analysis needs more than this.
totalTrees readonly number Number of trees in features.

convertPointsToMeshesLocal

Import from @infrared-city/infrared-sdk-ts.

convertPointsToMeshesLocal(featureCollection, options?): VegetationMesh[]

Converts tree Point features to dotbim meshes, locally.

Errors are typed and never collapse to []: an empty result means the input held no convertible trees, never that the conversion failed.

Parameters

Parameter Type Description
featureCollection Readonly<Record<string, unknown>> A feature collection with referencePoint: [lon, lat] and features (GeoJSON Point features).
options Pick<ToMeshesOptions, "registryJson"> registryJson replaces the built-in tree registry.

Returns

VegetationMesh[]

One mesh per convertible tree.

Throws

when featureCollection is not an object, has no valid referencePoint or no features array, or the conversion fails.


GeoJsonFeatureCollection

Import from @infrared-city/infrared-sdk-ts.

GeoJsonFeatureCollection = Readonly<Record<string, unknown>> & object

A GeoJSON feature collection: type is "FeatureCollection" and features holds the features.

Type Declaration

Name Type
features? ReadonlyArray<Readonly<Record<string, unknown>>>
type? string

ToMeshesOptions

Import from @infrared-city/infrared-sdk-ts.

Options for VegetationService.toMeshes.

Properties

Property Modifier Type Description
converter? readonly "local" Where the conversion runs. Only "local" is supported, and it is the default.
registryJson? readonly string Replaces the built-in tree registry document with your own, as JSON text.

treesFeatureCollection

Import from @infrared-city/infrared-sdk-ts/geodata.

treesFeatureCollection(result): Record<string, unknown>

Convert an acquired tree result into a GeoJSON FeatureCollection.

Parameters

Parameter Type Description
result DirectTreesResult The result of acquireTrees.

Returns

Record<string, unknown>

A FeatureCollection object holding the tree features.


VegetationMesh

Import from @infrared-city/infrared-sdk-ts.

One tree mesh in dotbim form: flat vertex coordinates plus triangle indices.

Extends

  • Readonly<Record<string, unknown>>

Indexable

[key: string]: unknown

Properties

Property Modifier Type Description
coordinates readonly readonly number[] Flat vertex coordinates [x, y, z, ...], in metres in the local frame.
indices readonly readonly number[] Flat triangle vertex indices.
mesh_id readonly number Identifier of the mesh.

vegetationRegistryDocument

Import from @infrared-city/infrared-sdk-ts.

vegetationRegistryDocument(): string

The built-in tree registry document, as JSON text.

Pass an edited copy as registryJson to replace it.

Returns

string

The registry document.


VegetationService

Import from @infrared-city/infrared-sdk-ts.

Reads tree locations from the public data hosts and converts them to meshes.

The service takes only the transport settings of ServiceOptions (fetch, timeoutMs, logger) and sends no API key anywhere.

Constructors

Constructor

new VegetationService(options): VegetationService

Parameters
Parameter Type Description
options ServiceOptions Transport settings: fetch, timeoutMs and logger are used for the public reads; baseUrl and auth are accepted but not used.
Returns

VegetationService

Methods

getArea()

getArea(polygon, options?): Promise<AreaVegetation>

Reads the trees over a polygon area, tile by tile.

Tiles are read concurrently, and trees found in more than one tile are listed once. A tile whose read fails is skipped and listed in failedTiles.

Parameters
Parameter Type Description
polygon Polygon The area to read: a GeoJSON Polygon with one closed ring of [longitude, latitude] positions.
options { analysisType?: string; maxTilesOverride?: number; maxWorkers?: number; signal?: AbortSignal; } maxWorkers is the number of tiles read at once (default 10), maxTilesOverride raises the tile limit, analysisType sets the tile grid and read margin, and signal cancels the read.
options.analysisType? string The analysis this read is for. It decides the tile grid and the read margin: 363 m for the two wind analyses and 544 m for every other one. Omit it for the widest margin, which is valid for every analysis.
options.maxTilesOverride? number Raises the cap on non-empty tiles (100 by default); a larger area is refused without it.
options.maxWorkers? number Number of tiles read at once. Default 10.
options.signal? AbortSignal Stops the read: requests in flight abort, and no tile starts after it.
Returns

Promise<AreaVegetation>

The trees with the read's margin and any failed tiles.

Throws

when the read of every tile fails.

Throws

when options carries the removed acquisition option.


getGeoJson()

getGeoJson(lat, lon, distance): Promise<GeoJsonFeatureCollection | null>

Reads the trees around one point.

Parameters
Parameter Type Description
lat number Centre latitude in degrees.
lon number Centre longitude in degrees.
distance number Half-width of the square to read, in metres.
Returns

Promise<GeoJsonFeatureCollection | null>

A feature collection, or null when there are no trees there. Any read warnings are listed under _warnings.


toMeshes()

toMeshes(featureCollection, options?): VegetationMesh[]

Converts tree Point features to dotbim meshes, locally.

converter accepts only "local"; any other value is an error rather than a silent local run.

Parameters
Parameter Type Description
featureCollection GeoJsonFeatureCollection A feature collection with referencePoint: [lon, lat] and features (GeoJSON Point features).
options ToMeshesOptions Optional converter and registryJson.
Returns

VegetationMesh[]

One mesh per convertible tree.

Throws

when converter is not "local", the input is malformed, or the conversion fails.