FormatSaveToStream(SourceFormat: TopobaseFormat; Stream: IIOStream);
FormatSaveToStream(SourceFormat: Prognoz.Platform.Interop.Topobase.TopobaseFormat; Stream: System.IO.Stream);
SourceFormat .Topobase format.
Stream. The stream, to which the topobase is saved.
The FormatSaveToStream method saves the topobase to the stream.
Executing the example requires a map with the OBJ6878 identifier and the Regions layer. Create a form, add to buttons named Button1 and Button2, two MapBox components named MapBox1 and MapBox2, two UiMap components named UiMap1 and UiMap2, select the UiMap1 and UiMap2 as a source for the MapBox1 and MapBox2 components respectively, add the IntegerEdit component named IntegerEdit1, the Memo component named Memo1, select the Tbs - 1, Svg - 2, Google - 4, Triangulate - 8, Vml - 16 values for the Text property of the Memo1 component, add links to the MathFin, Drawing, Metabase and Topobase system assembly in the module assembly inspector.
Var Count: Integer;
Class VisualDataAdapter: Object, IMapDynamicDataAdapter
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;
Button2: Button;
UiMap2: UiMap;
MapBox2: MapBox;
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(100, 100, 100, 100);
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;
StreamG: IMemoryStream;
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Begin
StreamG := New MemoryStream.Create;
(UiMap1.Map.Topobase As ITopobase).FormatSaveToStream((IntegerEdit1.Value) As TopobaseFormat, StreamG);
End Sub Button1OnClick;
Sub Button2OnClick(Sender: Object; Args: IMouseEventArgs);
Begin
StreamG.Seek(0, SeekOrigin.Beginning);
UiMap2.Map.Topobase := mb.FetchItemById("OBJ2910").Bind As IMapTopobase;
(UiMap2.Map.Topobase As ITopobase).FormatLoadFromStream((IntegerEdit1.Value)As TopobaseFormat, StreamG);
CreateLayer(UiMap2.Map);
End Sub Button2OnClick;
End Class OBJ6879Form;
Set value of one of the topobase formats in the IntegerEdit1 component. After executing the example on clicking the Button1 button the topobase is saved to the stream in the format defined in the IntegerEdit1 component and loaded from the stream on clicking the Button2 button.
Executing the example requires a map with the OBJ6878 identifier and the Regions layer. Create the form, add two buttons named Button1 and Button2 to that form, two mapBoxNet components named mapBoxNet1 and mapBoxNet2, two uiMapNet components named uiMapNet1 and uiMapNet2, select the uiMapNet1 and uiMapNet2 as a source for the mapBoxNet1 and mapBoxNet2 components respectively, add the numericUpDown component named numericUpDown1, add links to the MathFin, Drawing, Metabase, Topobase and ForeSystem 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;
Imports Prognoz.Platform.Interop.ForeSystem;
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(100, 100, 100, 100);
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;
StreamG: System.IO.MemoryStream;
Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Begin
StreamG := New System.IO.MemoryStream();
(UiMapNet1.Map.Topobase As ITopobase).FormatSaveToStream((Convert.ToInt32(numericUpDown1.Value)) As TopobaseFormat, StreamG);
End Sub;
Private Sub button2_Click(sender: System.Object; e: System.EventArgs);
Begin
StreamG.Seek(0, System.io.SeekOrigin.@Begin);
UiMapNet2.Map.Topobase := mb.ItemById["OBJ6878"].Bind() As DxMapTopobase;
(UiMapNet2.Map.Topobase As ITopobase).FormatLoadFromStream((Convert.ToInt32(numericUpDown1.Value)) As TopobaseFormat, StreamG);
CreateLayer(UiMapNet2.Map);
End Sub;
End Class;
Set value of one of the topobase formats in the numericUpDown1 component. After executing the example on clicking the Button1 button the topobase is saved to the stream in the format specified in the numericUpDown1 component loaded from the stream on clicking the Button2 button.
See also: