User Tools

Site Tools


api:dk11:delphi:gisclasses.tgis_fieldinfo



TGIS_FieldInfo class

DK for Delphi | GisClasses.TGIS_FieldInfo | Classes | Constructors | Methods | Properties

Describes field schema information and field behavior flags.

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

Syntax

// Delphi
type
  TGIS_FieldInfo = class( TGIS_Object )
  end;
// C++ Builder
class PASCALIMPLEMENTATION TGIS_FieldInfo : public TGIS_Object
{
};

Inheritance

Constructors

Inherited Overrides Protected
Name Visibility Description
Create public Create an instance.

Methods

Inherited Overrides Protected
Name Visibility Description
checkFlags protected Validates field settings and updates cumulative flags.
Clone public Creates a copy of this field information object.

Properties

Inherited Protected
Name Visibility Description
Binary public Binary width for TAB/DAT files.
Decimal public Number of decimal places as stored in the saved layer.
Deleted public Indicates whether the field should be deleted on save.
ExportName public Name of the field to use during export.
FieldType public Type of field.
FileFormat public Indicates whether the field is specific to a file format and should not be visible.
Flags public Set of cumulative field flags.
Formula public Formula to calculate a value.
Hidden public Indicates whether the field is hidden in controls.
IsUID public Indicates whether the field is used as GIS_UID and will be exported.
Name public Field name as stored in the saved layer.
NewDecimal public New number of decimal places to use after schema changes.
NewName public New field name to use after renaming.
NewWidth public New field width to use after schema changes.
ReadOnly public Indicates whether the field value cannot be modified.
Rules public Field rules object associated with this field.
Saved public Indicates whether the field exists in the saved disk-based layer.
Temporary public Indicates whether the field is temporary and not stored in a file.
Width public Field width as stored in the saved layer.

Remarks

Calculated field

To set a calculated field, you must assign the Formula property a formula in the SQL query format (compabible with TGIS_SqlQuery) that calculates the value for that field, e.g.

fld.Formula = "num*10"

After saving a layer, the formula definition will be saved to the .fld file. Example file definition :

[TatukGIS Field Formulas]
CALC=num*float/10
 
[TatukGIS Fields]

Example

procedure CreateFieldFormula ;
var
  shp : TGIS_Shape ;
  lv  : TGIS_LayerVector ;
  fld : TGIS_FieldInfo ;
  val : Double ;
begin
  // create a layer and fields definition
  lv := TGIS_LayerVector.Create ;
  try
    lv.Open ;
    lv.AddField( 'name', TGIS_FieldType.String, 1, 0 ) ;
    lv.AddField( 'num', TGIS_FieldType.Number, 5, 0 ) ;
    lv.AddField( 'float', TGIS_FieldType.Float, 10, 5 ) ;
    lv.AddField( 'calc', TGIS_FieldType.Float, 10, 5 ) ;
 
    // create a formula for a calculated field
    fld := lv.FieldInfo( lv.Fields.Count-1 ) ;
    fld.Formula := TGIS_FieldFormula.Create( 'num*float/10' ) ;
 
    // create a shape to store field values
    shp := lv.CreateShape( TGIS_ShapeType.Point ) ;
    shp.AddPart ;
    shp.AddPoint( GisPoint(1,1) ) ;
    shp.SetField( 'num', 5 ) ;
    shp.SetField( 'float', 1.1 ) ;
 
    // get a calculated value
    val := VarToDouble( shp.GetField( 'calc' ) ) ;
    Assert.AreEqual( 0.55, val ) ;
 
    // Save and reopen .fld file to restore the formula
    lv.Path := OUTPUT_TEST_PATH + 'test.shp';
    lv.PrepareExportFieldNames( 32 ) ;
    lv.ExportStructureToFLD ;
    lv.ReadFieldDefinition ;    
 
    val := VarToDouble( shp.GetField( 'calc' ) ) ;
    Assert.AreEqual( 0.55, val ) ;    
  finally
    FreeObject( lv ) ;
  end;
end ;

2026/09/20 23:47

Page Tools