The CreateNewFeatureLayer method enables you to create a new feature layer directly from TerraExplorer. The layer can be saved as a shapefile (.shp) or SQLite (.sqlite). For a shapefile, the connection string must include “TEPlugName=OGR” and “FileName=NameOfShapeFile.shp”. When saving as SQLite, the connection string must include “TEPlugName=OGR” and “FileName=NameOfSQLiteFile.sqlite” and “LayerName=newlayername”.
Note: If the folder contains a file by the same name, the existing file is overwritten without a prompt.
Note: The Application Data folder path changes between different users and different Windows operating systems. To find the path used by your client look at the %APPDATA% environment variable.
JavaScript |
|
CreateNewFeatureLayer( layerName, LayerGeomType, sConnectionString, GroupID) |
C# |
|
IFeatureLayer66 CreateNewFeatureLayer( string layerName, LayerGeometryType LayerGeomType, string sConnectionString, [string lParentGroupID = ""]) |
C++ |
|
HRESULT CreateNewFeatureLayer( BSTR layerName, LayerGeometryType LayerGeomType, BSTR sConnectionString, BSTR GroupID, IFeatureLayer66 ** pILayer) |
Parameters
layerName
The name of the layer as it appears in the Project Tree.
LayerGeomType
An enum that determines the geometry type. The following are the possible values:
· LGT_NONE = -1
· LGT_POINT = 0
· LGT_POLYLINE = 1
· LGT_POLYGON = 2
· LGT_COLLECTION = 3
sConnectionString
A string that specifies information about the layer data source and the means of connecting to it.
Note: Only new shapefiles or SQLite files can be created using this method. For a shapefile, the connection string must include “TEPlugName=OGR” and “FileName=NameOfShapeFile.shp”. For an SQLite file, the connection string must include “TEPlugName=OGR” and “FileName=NameOfSQLiteFile.sqlite” and “LayerName=newlayername”.
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 IProjectTree66.CreateGroup.
· Find the group, if you know the name, using IProjectTree66.FindItem.
· Traverse the Tree using IProjectTree66 methods such as GetNextItem, until you come to the desired GroupID.
Return Value
pILayer
An IFeatureLayer66, representing the newly created layer.
Exceptions
See: HRESULT Return Values for a list of possible values returned by the HRESULT.