forma-embedded-view-sdk
Version:
The Forma Embedded View SDK is a JavaScript library for creating custom extensions in Autodesk Forma (previously Spacemaker).
57 lines (56 loc) • 1.68 kB
JavaScript
/**
* Upload buildings, roads and property boundaries and add it to the library.
*
* @remarks
* Available via {@link auto.Forma | Forma}.{@link index.EmbeddedViewSdk.geoData | geoData}.
*/
export class GeoDataApi {
#iframeMessenger;
/** @hidden */
constructor(iframeMessenger) {
this.#iframeMessenger = iframeMessenger;
}
/**
* Uploads buldings, roads or property boundaries as geojson to forma, does some internal processing and adds the data to the library.
* Currently supports 2.5D buildings, roads and property boundaries.
* 2.5D buildings will need an elevation and height property, which defaults to 0 and 3 meters.
*
* @returns The library item for uploaded data.
*
* @example
const response = await Forma.geoData.upload({
data: {
type: "FeatureCollection",
features: [
{
type: "Feature",
properties: {
height: 10,
elevation: 0
},
geometry: {
type: "Polygon",
coordinates: [
[
[-74.0060, 40.7128],
[-74.0060, 40.7129],
[-74.0059, 40.7129],
[-74.0059, 40.7128],
[-74.0060, 40.7128]
]
]
}
}
]
},
dataType: "buildings",
geoLocation: {
srid: 4326,
refPoint: [0, 0]
}
});
*/
async upload(request) {
return await this.#iframeMessenger.sendRequest("geodata/upload", request);
}
}