CreateFeatureLayerAsync

CreateFeatureLayerAsync loads a feature layer into the project. A feature layer is a visual representation of a geographic data set like roads, national parks, political boundaries, and rivers using geographic objects such as points, lines, and polygons and optional corresponding annotation objects.

TerraExplorer enables you to load feature layers from remote or local databases. Various file formats are supported through a set of external plug-ins. SeeFeature Layer Connection Strings" for a list of the supported connection string values and parameters. You are always connected to the data source (local or remote), and all changes to the feature layers can be saved to the original source file. You can get the latest updates to a layer source by refreshing the layer.

TerraExplorer handles differently layers that are created by loading native feature sources (Shapefiles, GeoPackage, GeoDatabase, PDF or SQLite file files, and all server inputs) and layers that are created by loading non-native feature files (e.g., DXF, ASCII and OpenFlight files). For the former, a layer object containing the geographic objects is created in the Project Tree while for the latter the geographic objects are read and put in the TerraExplorer Project Tree as a Group.

If the source file coordinate system is not the same as the MPT file Terrain Coordinate system, you can reproject it using the IFeatureLayer80.Reproject method.

CreateFeatureLayerAsync only loads a feature layer into the project. If you want to load the new layer on the terrain, use the IFeatureLayer80.Load method.

This method executes asynchronously, immediately returning an ITerraExplorerAsync80, thereby ensuring that control is promptly handed back to the calling function. The results are delivered when ready using the ITerraExplorerAsync80 object that was returned. The ITerraExplorerAsync80 object provides a callback-based mechanism similar to the JavaScript promise and the C# Task that offers the following functionality:

§   Allows for handling rejections/errors and successful resolution of the asynchronous operation (using OnReject and OnResolve).

§   Upon resolution of the query, enables the passing of an IFeatureLayer80, representing the newly created layer, to the OnResolve callback.

If you want to execute synchronously, use CreateFeatureLayer instead.

JavaScript

 

CreateFeatureLayerAsync(

       layerName,

       sConnectionString,

       GroupID)

 

C#

 

ITerraExplorerAsync80 CreateFeatureLayerAsync (

       string        layerName,

       string        sConnectionString,

       string        GroupID = "")

 

C++

 

HRESULT CreateFeatureLayerAsync (

       BSTR   layerName,

       BSTR   sConnectionString,

       BSTR   GroupID,

       ITerraExplorerAsync80 ** pITerraExplorerObject) 

Parameters

layerName

A string representing the name of the layer.

sConnectionString

Specifies information about the data source and the means of connecting to it. SeeFeature Layer Connection Strings” for a list of the supported connection string values and parameters.

GroupID

The Project Tree group in which the layer is created. If it is set to an empty string, the object is created under the root. You can obtain the GroupID by one of the following methods:

·          Create the group using IProjectTree80.CreateGroup.

·          Find the group, if you know the name, using IProjectTree80.FindItem.

·          Traverse the Tree using IProjectTree80 methods such as GetNextItem, until you come to the desired GroupID.

Return Value

pITerraExplorerObject

An ITerraExplorerAsync80 object, which provides a callback-based mechanism similar to the JavaScript promise and the C# Task that offers the following functionality:

·          Allows for handling rejections/errors and successful resolution of the asynchronous operation (using OnReject and OnResolve).

·          Upon resolution of the query, enables the passing of an IFeatureLayer80, representing the newly created layer, to the OnResolve callback.

Exceptions

See: HRESULT Return Values for a list of possible values returned by the HRESULT.