ITopobase.FormatLoadFromFile

Синтаксис Fore

FormatLoadFromFile(SourceFormat: TopobaseFormat; FileName: String);

Синтаксис Fore.NET

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

Параметры

SourceFormat .Формат топоосновы;

FileName. Путь и наименование файла.

Описание

Метод FormatLoadFromFile загружает топооснову из файла.

Пример Fore

Для выполнения примера предполагается наличие карты с идентификатором «OBJ6878», слоя с наименованием «Regions» и пяти файлов топооснов с расширениями .Tbs, .Svg, .Google, .Triangulate, .Vml и наименованиями «ru2» на диске C. Создайте форму, добавьте на нее кнопку с наименованием «Button1», компонент MapBox с наименованием «MapBox1», компонент UiMap с наименованием «UiMap1», укажите «UiMap1» в качестве источника компонента «MapBox1», добавьте компонент IntegerEdit с наименованиями «IntegerEdit1», компонент Memo с наименованием «Memo1», укажите значение «Tbs - 1, Svg - 2, Google - 4, Triangulate - 8, Vml -  16» свойства Text компонента «Memo1», в инспекторе сборок модуля добавьте ссылки на системные сборки MathFin, Drawing, Metabase и Topobase.

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;

В компоненте «IntegerEdit1» укажите значение одного из форматов топоосновы. После выполнения примера при нажатии на кнопку «Button1» из файла будет загружена топооснова формата, указанного в «IntegerEdit1».

Пример Fore.NET

Для выполнения примера предполагается наличие карты с идентификатором «OBJ6878», слоя с наименованием «Regions» и пяти файлов топооснов с расширениями .Tbs, .Svg, .Google, .Triangulate, .Vml и наименованиями «ru2» на диске C. Создайте форму, добавьте на нее кнопку с наименованием «Button1», компонент mapBoxNet с наименованием «mapBoxNet1», компонент uiMapNet с наименованием «uiMapNet1», укажите «uiMapNet1» в качестве источника компонента «mapBoxNet1», добавьте компонент numericUpDown с наименованием «numericUpDown1», добавьте ссылки на системные сборки MathFin, Drawing, Metabase и Topobase.

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;

В компоненте «numericUpDown1» укажите значение одного из форматов топоосновы. После выполнения примера при нажатии на кнопку «Button1» из файла будет загружена топооснова формата, указанного в «numericUpDown1».

См. также:

ITopobase