-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmatio.formats.omx.pas
More file actions
92 lines (78 loc) · 3.36 KB
/
matio.formats.omx.pas
File metadata and controls
92 lines (78 loc) · 3.36 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
unit matio.formats.omx;
////////////////////////////////////////////////////////////////////////////////
//
// Author: Jaap Baak
// https://github.com/transportmodelling/matio
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
interface
////////////////////////////////////////////////////////////////////////////////
Uses
SysUtils, Types, Propset, matio, matio.formats, matio.formats.hdf5, matio.hdf5, matio.hdf5.omx;
Type
TOMXMatrixReaderFormat = Class(THdf5MatrixReaderFormat)
public
Function Format: String; override;
Function HasFormat(const FileExtension: String): Boolean; override;
Function CreateReader(const [ref] Properties: TPropertySet): TMatrixReader; override;
Function CreateReader(const [ref] Properties: TPropertySet; const Selection: array of String): TMatrixReader; override;
end;
TOMXMatrixWriterFormat = Class(THdf5MatrixWriterFormat)
public
Function Format: String; override;
Function CreateWriter(const [ref] Properties: TPropertySet;
const FileLabel: string;
const MatrixLabels: array of String;
const Size: Integer): TMatrixWriter; override;
end;
////////////////////////////////////////////////////////////////////////////////
implementation
////////////////////////////////////////////////////////////////////////////////
Function TOMXMatrixReaderFormat.Format: String;
begin
Result := 'omx';
end;
Function TOMXMatrixReaderFormat.HasFormat(const FileExtension: String): Boolean;
begin
Result := SameText(FileExtension,'.omx');
end;
Function TOMXMatrixReaderFormat.CreateReader(const [ref] Properties: TPropertySet): TMatrixReader;
begin
if SameText(Properties[FormatProperty],Format) then
Result := TOMXMatrixReader.Create(Properties.ToPath(FileProperty))
else
raise Exception.Create('Invalid format-property');
end;
Function TOMXMatrixReaderFormat.CreateReader(const [ref] Properties: TPropertySet; const Selection: array of String): TMatrixReader;
begin
if SameText(Properties[FormatProperty],Format) then
Result := TOMXMatrixReader.Create(Properties.ToPath(FileProperty),Selection)
else
raise Exception.Create('Invalid format-property');
end;
////////////////////////////////////////////////////////////////////////////////
Function TOMXMatrixWriterFormat.Format: String;
begin
Result := 'omx';
end;
Function TOMXMatrixWriterFormat.CreateWriter(const [ref] Properties: TPropertySet;
const FileLabel: string;
const MatrixLabels: array of String;
const Size: Integer): TMatrixWriter;
begin
if SameText(Properties[FormatProperty],Format) then
begin
var ExtendedProperties := ExtendProperties(Properties);
var PrecisionPropertyValue := ExtendedProperties[PrecisionProperty];
for var Prec := low(THdf5Precision) to high(THdf5Precision) do
if SameText(PrecisionLabels[Prec],PrecisionPropertyValue) then
begin
Result := TOMXMatrixWriter.Create(ExtendedProperties.ToPath(FileProperty),FileLabel,MatrixLabels,Size,Prec);
Exit;
end;
raise Exception.Create('Invalid precision-property');
end else
raise Exception.Create('Invalid format-property');
end;
end.