ITopobase.FormatLoadFromFile

Fore Syntax

FormatLoadFromFile(SourceFormat: TopobaseFormat; FileName: String);

Fore.NET Syntax

FormatSaveToFile(SourceFormat: Prognoz.Platform.Interop.Topobase.TopobaseFormat; FileName: System.String);

Parameters

SourceFormat .Topobase format.

FileName.The path and the file name.

Description

The FormatLoadFromFile method loads the topobase from a file.

Fore Example

Executing the example requires a map with the OBJ6878 identifier, the Regions layer and five topobase files with .Tbs, .Svg, .Google, .Triangulate, .Vml extensions and the ru2 names on the C disc. Create a form, add the Button1 button to it, the MapBox component named MapBox1, the UiMap component named UiMap1, select the UiMap1 as a source for the MapBox1 component, add the IntegerEdit component named IntegerEdit1, the Memo component named Memo1, select the Tbs - 1, Svg - 2, Google - 4, Triangulate - 8, Vml - 16 values of the Text property of Memo1 component, and add links to the MathFin, Drawing, Metabase and Topobase system assemblies in the module assembly inspector.

Var Count: Integer;

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 OBJ6879Form: Form
    MapBox1: MapBox;
    UiMap1: UiMap;
    Button1: Button;
    Memo1: Memo;
    IntegerEdit1: IntegerEdit;
    mb: IMetabase;
    Map: IMap;
    Top: IMapTopobase;
    Itop: ITopobase;
    
    Sub CreateLayer(m: IMap);
    Var StartC, EndC: IGxColor;
        Color: IMapVisualColorProperty;
        Scale: IMapColorScale;
        AreaVisual: IMapAreaVisual;
        Layer: IMapLayer;
    Begin
        Layer := M.Layers.FindByName("Regions");
        M.Color := New GxColor.CreateARGB(100100100100);
        M.Refresh;
        AreaVisual:= Layer.Visuals.AddAreaVisual;
        AreaVisual.DataAdapter := New VisualDataAdapter.Create As IMapDynamicDataAdapter;
        Count := 5;
        Color := AreaVisual.Color;
        Color.DataAdapter := AreaVisual.DataAdapter;
        Scale := New DxMapColorScale.Create As IMapColorScale;
        StartC := GxColor.FromName("Red");
        EndC := GxColor.FromName("Blue");
        Scale.AutoSetup(Layer, AreaVisual.DataAdapter, StartC, EndC);
        Color.Scale := Scale;
        M.Refresh;
    End Sub CreateLayer;
    
    Sub OBJ6879FormOnCreate(Sender: Object; Args: IEventArgs);
    Begin
        mb := MetabaseClass.Active;
        Map := UiMap1.Map;
        Top := mb.FetchItemById("OBJ6878").Edit As IMapTopobase;
        Itop := Top As ITopobase;
        Map.Topobase := Itop As IMapTopobase;
        CreateLayer(Map);
    End Sub OBJ6879FormOnCreate;

    Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
    Begin
        Itop.FormatLoadFromFile((IntegerEdit1.Value) As TopobaseFormat, "C:\ru2");
        (Itop As IMetabaseObject).Save;
        Map.Topobase := Itop As IMapTopobase;
        CreateLayer(Map)
    End Sub Button1OnClick;

    End Class OBJ6879Form;

Set value of one of the topobase formats in the IntegerEdit1 component. After executing the example the Format topobase specified in IntegerEdit1 is loaded from the file on clicking the Button1 button.

Fore.NET Example

Executing the example requires a map with the OBJ6878 identifier, the Regions layer and five topobase files with .Tbs, .Svg, .Google, .Triangulate, .Vml extensions and the ru2 names on the C disc. Create the form, add the Button1 button to it, the mapBoxNet component named mapBoxNet1, the uiMapNet component named uiMapNet1, select the uiMapNet1 as a source for the mapBoxNet1 component, add the numericUpDown component named numericUpDown1, add links to the MathFin, Drawing, Metabase and Topobase system assemblies.

Imports System;
Imports System.Collections.Generic;
Imports System.ComponentModel;
Imports System.Data;
Imports System.Drawing;
Imports System.Text;
Imports System.Windows.Forms;
Imports Prognoz.Platform.Forms.Net;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Drawing;
Imports Prognoz.Platform.Interop.Map;
Imports Prognoz.Platform.Interop.MathFin;
Imports Prognoz.Platform.Interop.Topobase;

Class VisualDataAdapter: IMapTimeDynamicDataAdapter
            
        Public Property PartCount[Attribute: Object; TimePoint: Integer]: Integer
            Get
            Begin
                Return Count;
            End Get
            
        End Property;

        Public Property Data[Attribute: Object; PartvIndex: Integer; TimePoint: Integer]: Object
            Get
                Var Math: MathClass = New MathClass();
                    t: Integer;
                    i: Integer;
            Begin
                t := 1;
                For i := 0 To TimePoint Do
                    t := t + 10;
                End For;
                Return Math.Rand() * 10 * t;
            End Get
        End Property;

        Public Property TimePointsCount: Integer
        Get
        Begin
            Return 4;
        End Get
        End Property;
        
        Public Property TimePointName[TimePoint: Integer]: String
        Get
        Begin
            Return "TimePoint " + TimePoint.ToString();
        End Get
        End Property;
        
        Public Property CustomFormat: String
        Get
        Begin
            Return "#0,000";
        End Get
        End Property;
        
End Class;

Var Count: Integer;

Sub CreateLayer(m: IMap);
    Var StartC, EndC: GxColor;
        Color: IMapVisualColorProperty;
        Scale: DxMapColorScale;
        AreaVisual: IMapAreaVisual;
        Layer: IMapLayer;
        GxColorCls: GxColorClass_2 = New GxColorClass_2();
        GxColorCls1: GxColorClassClass = New GxColorClassClass();
    Begin
        Layer := M.Layers.FindByName["Regions"];
        GxColorCls.CreateARGB(100100100100);
        M.Color := GxColorCls;
        M.Refresh();
        AreaVisual := Layer.Visuals.AddAreaVisual();
        AreaVisual.DataAdapter := New VisualDataAdapter();
        Count := 5;
        Color := AreaVisual.Color;
        Color.DataAdapter := AreaVisual.DataAdapter;
        Scale := New DxMapColorScaleClass();
        StartC := GxColorCls1.FromName("Red");
        EndC := GxColorCls1.FromName("Blue");
        Scale.AutoSetup(Layer, AreaVisual.DataAdapter, StartC, EndC);
        Color.Scale := Scale;
        M.Refresh();
    End Sub CreateLayer;
    
Public Partial Class OBJ918Form: Prognoz.Platform.Forms.Net.ForeNetForm
    Public Constructor OBJ918Form();
    Begin
        InitializeComponent();
    End Constructor;
    
    mb: IMetabase;
    Map: IMap;
    Top: IMapTopobase;
    Itop: ITopobase;
    
    Private Sub OBJ918Form_Load(sender: System.Object; e: System.EventArgs);
    Begin
        mb := Self.Metabase;
        Map := UiMapNet1.Map;
        Top := mb.ItemById["OBJ6878"].Edit() As IMapTopobase;
        Itop := Top As ITopobase;
        Map.Topobase := Itop As DxMapTopobase;
        CreateLayer(Map);
    End Sub;

    Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
    Begin
        Itop.FormatLoadFromFile((numericUpDown1.Value As Integer) As TopobaseFormat, "C:\ru2");
        (Itop As IMetabaseObject).Save();
        Map.Topobase := Itop As DxMapTopobase;
    End Sub;

End Class;

Set value of one of the topobase formats in the numericUpDown1 component. After executing the example the Format topobase specified in numericUpDown1 is loaded from the file on clicking the Button1 button.

See also:

ITopobase