User Tools

Site Tools


api:dk11:java:tatukgis.jdk.tgis_fieldinfo

TGIS_FieldInfo class

DK for Java | tatukgis.jdk.TGIS_FieldInfo | Classes | Constructors | Methods | Properties

Describes field schema information and field behavior flags.

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

Syntax

// Java
public class TGIS_FieldInfo extends TGIS_Object {
};
// Oxygene
type
  TGIS_FieldInfo = public class( TGIS_Object )
  end;

Inheritance

→ TGIS_Object

Constructors

Inherited Overrides Protected
Name Visibility Description
TGIS_FieldInfo() 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 Decimal as represented in saved version.
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 Name as represented in saved version.
NewDecimal public New decimal size of field.
NewName public New name of field.
NewWidth public New width of field.
ReadOnly public Indicates whether the field value cannot be modified.
Rules public Field rules.
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 Width as represented in saved version.

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/07/11 01:25

Page Tools