User Tools

Site Tools


api:dk11:delphi:gislayervector.tgis_shape.importfromwkt_string

Table of Contents



TGIS_Shape.ImportFromWKT method

DK for Delphi | GisLayerVector.TGIS_Shape.ImportFromWKT | Constructors | Fields | Methods | Properties

Replaces the current geometry by parsing Well-Known Text (WKT) in place.

Available also on: .NET | Java | ActiveX | Python.

Syntax

// Delphi
public
  procedure ImportFromWKT(
    const _wkt : String
  ); virtual;
// C++ Builder
public:
  virtual void ImportFromWKT(
    const UnicodeString _wkt
  );

Parameters

Name Type Description
_wkt String WKT text such as POINT(10 20), LINESTRING(...), or POLYGON((...)).

Remarks

PURPOSE: Replaces the current shape geometry from WKT (Well-Known Text), the OGC (Open Geospatial Consortium) standard text representation for vector geometry.

BEHAVIOR: Parses the WKT content and updates this shape in place with the decoded geometry.

CONSTRAINTS: Existing geometry is overwritten. WKT does not carry CRS (Coordinate Reference System) metadata. Malformed input raises an exception.

Example

Delphi

const
  WKTText='POLYGON((15 15,25 15,25 25,15 25,15 15),(10 10,10 20,20 20,20 10,10 10))';
var
  layerObj : TGIS_LayerVector ;
 
procedure MyClass.Shape();
var
  shp : TGIS_Shape ;
begin
  layerObj.RevertAll ;
 
  try
    // create a shape using WKT string
    shp:=layerObj.CreateShape(TGIS_ShapeType.Polygon);
    shp.ImportFromWKT( WKTText ) ;
  except
    ShowMessage( 'Bad format' ) ;
  end ;
 
  GIS.RecalcExtent ;
  GIS.FullExtent ;
  GIS.Invalidate ;
end;
2026/07/11 00:38

Page Tools