-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmatio.formats.visum.pas
More file actions
59 lines (50 loc) · 1.76 KB
/
matio.formats.visum.pas
File metadata and controls
59 lines (50 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
unit matio.formats.visum;
////////////////////////////////////////////////////////////////////////////////
//
// Author: Jaap Baak
// https://github.com/transportmodelling/matio
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
interface
////////////////////////////////////////////////////////////////////////////////
Uses
SysUtils, Classes, PropSet, matio, matio.formats, matio.visum;
Type
TVisumMatrixReaderFormat = Class(TMatrixReaderFormat)
public
Function Format: String; override;
Function HasFormat(const Header: TBytes): Boolean; override;
Function CreateReader(const [ref] Properties: TPropertySet): TMatrixReader; override;
end;
////////////////////////////////////////////////////////////////////////////////
implementation
////////////////////////////////////////////////////////////////////////////////
Function TVisumMatrixReaderFormat.Format: String;
begin
Result := 'visum';
end;
Function TVisumMatrixReaderFormat.HasFormat(const Header: TBytes): Boolean;
begin
Result := false;
if Length(Header) >= 5 then
begin
if Header[0] = 3 then
if Header[1] = 0 then
if ANSIChar(Header[2]) = '$' then
if ANSIChar(Header[3]) = 'B' then
if ANSIChar(Header[4]) in ['I','K','L'] then
Result := true;
end else
Result := false;
end;
Function TVisumMatrixReaderFormat.CreateReader(const [ref] Properties: TPropertySet): TMatrixReader;
begin
if SameText(Properties[FormatProperty],Format) then
begin
var ExtendedProperties := ExtendProperties(Properties);
Result := TVisumMatrixReader.Create(ExtendedProperties.ToPath(FileProperty));
end else
raise Exception.Create('Invalid format-property');
end;
end.