AvailableFormats: Integer;
The AvailableFormats property returns the combination of values of the formats, to which the topobase was converted.
Topobase format values can be determined using the TopobaseFormat enumeration.
Executing the example requires that the repository contains:
A map with the MAP identifier containing the Regions layer.
A form containing:
Two Button components named Button1 and Button2.
Two UiMap components named UiMap1 and UiMap2 that are data sources for MapBox1 and MapBox2, respectively.
Two MapBox components named MapBox1 and MapBox2. Select the UiMap1 and the UiMap2 data sources for the components in the Source property, respectively.
Two IntegerEdit components named IntegerEdit1 and IntegerEdit2. Set the start topobase format value and the output topobase format value for the components in the Value property. Use values of the TopobaseFormat enumeration as topobase format values.
Add links to the Drawing, Map, MathFin, Metabase, and Topobase system assemblies.
Var
Count: Integer;
int: integer;
// Get information about dynamic indicators
// in different temporary points on map layer
Class VisualDataAdapter: Object, IMapTimeDynamicDataAdapter
Function Get_PartCount(Attribute: Variant; TimePoint: Integer): Integer;
Begin
Return Count;
End Function Get_PartCount;
Function Get_TimePointName(TimePoint: Integer): String;
Begin
Return "TimePoint " + TimePoint.ToString;
End Function Get_TimePointName;
Function Get_TimePointsCount: Integer;
Begin
Return 4;
End Function Get_TimePointsCount;
Function Get_Data(Attribute: Variant; PartvIndex: Integer; TimePoint: Integer): Variant;
Var
t: Integer;
i: Integer;
Begin
t := 1;
For i := 0 To TimePoint Do
t := t + 10;
End For;
Return Math.Rand * 10 * t;
End Function Get_Data;
Function Get_CustomFormat: String;
Begin
Return "#0,000";
End Function Get_CustomFormat;
End Class VisualDataAdapter;
Class ITOPOBASE_AVAILABLEFORMATSForm: Form
Button1: Button;
Button2: Button;
MapBox1: MapBox;
MapBox2: MapBox;
UiMap1: UiMap;
UiMap2: UiMap;
IntegerEdit1: IntegerEdit;
IntegerEdit2: IntegerEdit;
mb: IMetabase;
Map: IMap;
Top: IMapTopobase;
Itop: ITopobase;
Sub CreateLayer(CurrentMap: IMap);
Var
StartC, EndC: IGxColor;
Color: IMapVisualColorProperty;
Scale: IMapColorScale;
AreaVisual: IMapAreaVisual;
Layer: IMapLayer;
Begin
// Get map layer named Regions
Layer := CurrentMap.Layers.FindByName("Regions");
// Set map background color
CurrentMap.Color := New GxColor.CreateARGB(100, 100, 100, 100);
// Refresh map
CurrentMap.Refresh;
// Get map indicator
AreaVisual := Layer.Visuals.AddAreaVisual;
// Create a data source for indicator
AreaVisual.DataAdapter := New VisualDataAdapter.Create As IMapTimeDynamicDataAdapter;
Count := 5;
// Get indicator fill parameters
Color := AreaVisual.Color;
// Determine a data source for fill
Color.DataAdapter := AreaVisual.DataAdapter;
// Create a color scale
Scale := New DxMapColorScale.Create As IMapColorScale;
// Set start gradient color
StartC := GxColor.FromName("Red");
// Set end gradient color
EndC := GxColor.FromName("Blue");
// Set up color scale
Scale.AutoSetup(Layer, AreaVisual.DataAdapter, StartC, EndC);
// Set color scale for indicator fill
Color.Scale := Scale;
// Refresh map
CurrentMap.Refresh;
End Sub CreateLayer;
Sub ITOPOBASE_AVAILABLEFORMATSFormOnCreate(Sender: Object; Args: IEventArgs);
Begin
// Get repository
mb := MetabaseClass.Active;
// Get map
Map := UiMap1.Map;
// Get map topobase
Top := mb.FetchItemById("OBJ14878_COPY2").Edit As IMapTopobase;
// Set topobase
Map.Topobase := Top;
// Save topobase
Itop := Top As ITopobase;
// Display map
CreateLayer(Map);
End Sub ITOPOBASE_AVAILABLEFORMATSFormOnCreate;
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Begin
// Convert topobase from one format into other
Itop.Convert((IntegerEdit1.Value) As TopobaseFormat, (IntegerEdit2.Value) As TopobaseFormat);
// Set topobase
UiMap2.Map.Topobase := Itop As IMapTopobase;
// Display map with source topobase
CreateLayer(UiMap1.Map);
// Display map with converted topobase
CreateLayer(UiMap2.Map);
End Sub Button1OnClick;
Sub Button2OnClick(Sender: Object; Args: IMouseEventArgs);
Var
Topo: ITopobase;
Begin
Topo := Itop;
// Display list of formats in the console,
// into which topobase was converted
If (Topo.AvailableFormats And TopobaseFormat.Tbs) <> 0 Then
Debug.WriteLine("Tbs");
End If;
If (Topo.AvailableFormats And TopobaseFormat.Svg) <> 0 Then
Debug.WriteLine("Svg");
End If;
If (Topo.AvailableFormats And TopobaseFormat.Google) <> 0 Then
Debug.WriteLine("Google");
End If;
If (Topo.AvailableFormats And TopobaseFormat.Triangulate) <> 0 Then
Debug.WriteLine("Triangulate");
End If;
End Sub Button2OnClick;
End Class ITOPOBASE_AVAILABLEFORMATSForm;
After executing the example:
Clicking the Button1 button will convert the topobase into the specified format.
Clicking the Button2 button will display the list of formats, into which the topobase was converted, in the console.
See also: