User Tools

Site Tools


api:dk11:delphi:gislayervector.tgis_layervector.build_string_tgis_extent_tgis_shapetype

TGIS_LayerVector.Build(String; TGIS_Extent; TGIS_ShapeType) method

DK11 for Delphi | GisLayerVector.TGIS_LayerVector.Build | Overloads | Constructors | Fields | Methods | Properties | Events

Build new layer - prepare storage.

Available also on: .NET | Java | ActiveX.

Syntax

// Delphi
public
  procedure Build(
    const _path : String;
    const _extent : TGIS_Extent;
    const _type : TGIS_ShapeType
  ); overload; virtual;
// C++ Builder
public:
  virtual void Build(
    const UnicodeString _path,
    TGIS_Extent* const _extent,
    TGIS_ShapeType* const _type
  ) /* overload */;

Parameters

Name Type Description
_path String full path of layer to be built; a connection string for SQL base shapes;
_extent TGIS_Extent starting extent of layer - can't be zero sized
_type TGIS_ShapeType shape type supported by a layer

Remarks

Use this method to build a new layer (prepare storage). Depending on layer type different files are created or used. For GIS_LayerSHP there are .shp and .dbf, GIS_LayerSQLAbstract uses .ttkls files.

To add a new layer to the viewer simply create one, use Build method with proper params, fill needed layer properties and use the viewer Add method.

Example

Here is a simple procedure to add a new layer to the viewer.

Delphi

procedure MyClass.AddLayer;
var
  myExtent : TGIS_Extent;
  shpType : TGIS_ShapeType;
  myLayer : TGIS_LayerSHP;
  layerName : String;
  layerPath : String;
  layerFullName : String;
begin
  // Set the extent of the new layer
  myExtent:=GIS.Extent;
 
  // Set type of the shape
  shtType:=TGIS_ShapeType.Polygon;
 
  // Set a name for a layer to be created.
  layerPath:=ExtractFilePath(Application.ExeName);
  layerName:='Layer_'+IntToStr(GIS.Items.Count+1)+'.shp';
  layerFullName:=layerPath + layerName;
 
  // Create a new layer.
  myLayer:=TGIS_LayerSHP.Create ;
 
  // Build layer file and set the layer path and name.
  myLayer.Build (layerFullName, myExtent, shpType);
  myLayer.Path:=layerFullName;
  myLayer.Name:=layerName;
 
  // Add layer to the viewer.
  GIS.Add (myLayer);
 
  myLayer.AddField( "name", TGIS_FieldType.String, 255, 0 );
end;

References

2019/08/13 10:50