acquireTrees

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

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

Read trees for an area, returning parsed feature objects.

The same read as acquireTreesJson, parsed once.

Parameters

ParameterTypeDescription
bboxBboxThe area's bounding box in WGS84 degrees.
optionsAcquireTreesOptionsRead 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/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 _overlay_unavailable warning is added.

Parameters

ParameterTypeDescription
bboxBboxThe area's bounding box in WGS84 degrees.
optionsAcquireTreesOptionsRead 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.

Trees read for an area.

Properties

PropertyModifierTypeDescription
analysisTypereadonlystringThe analysis type the read margin was taken from.
executionTimereadonlynumberTime the read took, in seconds.
failedTilesreadonlyreadonly string\[\]Ids of the tiles whose read failed; their trees are missing from features.
featuresreadonlyReadonly<Record<string, Readonly<Record<string, unknown>>>>The tree features, keyed by tree id, after duplicates between tiles are removed.
polygonreadonlyPolygonThe polygon that was read.
readMarginMreadonlynumberHalf 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.
totalTreesreadonlynumberNumber of trees in features.

convertPointsToMeshesLocal

Import from @infrared-city/infrared-sdk.

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

ParameterTypeDescription
featureCollectionReadonly<Record<string, unknown>>A feature collection with referencePoint: [lon, lat] and features (GeoJSON Point features).
optionsPick<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.

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

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

Type Declaration

NameType
features?ReadonlyArray<Readonly<Record<string, unknown>>>
type?string

ToMeshesOptions

Import from @infrared-city/infrared-sdk.

Options for VegetationService.toMeshes.

Properties

PropertyModifierTypeDescription
converter?readonly"local"Where the conversion runs. Only "local" is supported, and it is the default.
registryJson?readonlystringReplaces the built-in tree registry document with your own, as JSON text.

treesFeatureCollection

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

treesFeatureCollection(result): Record<string, unknown>

Convert an acquired tree result into a GeoJSON FeatureCollection.

Parameters

ParameterTypeDescription
resultDirectTreesResultThe result of acquireTrees.

Returns

Record<string, unknown>

A FeatureCollection object holding the tree features.


VegetationMesh

Import from @infrared-city/infrared-sdk.

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

Extends

  • Readonly<Record<string, unknown>>

Indexable

\[key: string\]: unknown

Properties

PropertyModifierTypeDescription
coordinatesreadonlyreadonly number\[\]Flat vertex coordinates [x, y, z, ...], in metres in the local frame.
indicesreadonlyreadonly number\[\]Flat triangle vertex indices.
mesh_idreadonlynumberIdentifier of the mesh.

vegetationRegistryDocument

Import from @infrared-city/infrared-sdk.

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.

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
ParameterTypeDescription
optionsServiceOptionsTransport 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
ParameterTypeDescription
polygonPolygonThe 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?stringThe 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?numberRaises the cap on non-empty tiles (100 by default); a larger area is refused without it.
options.maxWorkers?numberNumber of tiles read at once. Default 10.
options.signal?AbortSignalStops 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
ParameterTypeDescription
latnumberCentre latitude in degrees.
lonnumberCentre longitude in degrees.
distancenumberHalf-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
ParameterTypeDescription
featureCollectionGeoJsonFeatureCollectionA feature collection with referencePoint: [lon, lat] and features (GeoJSON Point features).
optionsToMeshesOptionsOptional converter and registryJson.
Returns

VegetationMesh\[\]

One mesh per convertible tree.

Throws

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