The TerraBuilder Application Programming Interface (API) provides automated processing and access to most TerraBuilder operations, using a JavaScript script file (.js) that is run by TerraBuilder:
- Build and update projects
- Automatically start pyramid and MPT creation
- Publish MPT projects to SGS
- Publish DirectConnect projects to SGS
TerraBuilder Objects
TerraBuilder API includes nine objects, all of which can be accessed through JavaScript. The main objects are:
- TerraBuilder70 – This object is the main entry point to most TerraBuilder “service” functions. Through this object, you can manage the TerraBuilder application (e.g. open and close projects, and connect to SkylineGlobe Server).
- TBProject70 – This is the main object for managing the project including methods for saving projects, creating an MPT, and publishing an MPT and DirectConnect to SkylineGlobe Server. TBProject70 also provides access to the Layers, Polygons, and Settings objects for editing layers and polygons and setting basic project settings.
The API’s other objects are:
- Geometry (TBGeometry70)
- Layer (TBLayer70)
- Layers (TBLayers70)
- Polygon (TBPolygon70)
- Polygons (TBPolygons70)
- Settings (TBSettings70)
- SGServer (TBSGServer70)
How to Work with TerraBuilder API
To work with TerraBuilder API, perform the following steps:
- Create a JavaScript file using the TerraBuilder API objects. For example:
var project = TerraBuilder.OpenProject("C:\\TB Projects\\USA.tbp");
Project.Layers.InsertLayer("C:\\TB Sources\\NY.tif","imagery");
project.Save();
TerraBuilder.ExitWhenFinished();
- Save the script file with a js extension.
- Execute the JavaScript from the command line using the following syntax:
TerraBuilder.exe -script “…..script.js (path to script)
Note: Each line in the TB script, once executed, is recorded and displayed in the TerraBuilder log as a message (in addition to TerraBuilder.Print printouts). You can disable the code line printing by passing the DisablePrint argument:
TerraBuilder.exe -script “…..script.js (path to script)-DisablePrint