DK for Java | tatukgis.jdk.TGIS_FieldInfo | Classes | Constructors | Methods | Properties
Field structure information.
// Java public class TGIS_FieldInfo extends TGIS_Object { };
// Oxygene type TGIS_FieldInfo = public class( TGIS_Object ) end;
→ TGIS_Object
| Name | Visibility | Description | |
|---|---|---|---|
| TGIS_FieldInfo() | public | Create an instance. | |
| Name | Visibility | Description | |
|---|---|---|---|
| checkFlags | protected | Check a field settings and set cumulative flags. | |
| Name | Visibility | Description | |
|---|---|---|---|
| Binary | public | Binary width for TAB/DAT files. | |
| Decimal | public | Decimal as represented in saved version. | |
| Deleted | public | If True file must be deleted on save. | |
| ExportName | public | Field used in exporting. | |
| FieldType | public | Type of field. | |
| FileFormat | public | If True, then field is specific to file format and should not be visible. | |
| Flags | public | Set of cumulative field flags. | |
| Formula | public | Formula to calculate a value. | |
| Hidden | public | If True, then field will not be visible in controls. | |
| IsUID | public | If True, then 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 | If True, then value of the field can not be modified. | |
| Rules | public | Field rules. | |
| Saved | public | if True the field exist in disk based image; valid only for real disk based layer like TGIS_LayerSHP, TGIS_LayerSHP etc. | |
| Temporary | public | If True, then field is temporary (not stored in a file). | |
| Width | public | Width as represented in saved version. | |
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]
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 ;