forked from equinor/flotilla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMapMetadata.cs
91 lines (76 loc) · 2.05 KB
/
MapMetadata.cs
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
#nullable disable
using System.ComponentModel.DataAnnotations;
using Microsoft.EntityFrameworkCore;
namespace Api.Database.Models
{
[Owned]
public class MapMetadata
{
public MapMetadata()
{
MapName = "DefaultMapName";
Boundary = new Boundary();
TransformationMatrices = new TransformationMatrices();
}
public MapMetadata(MapMetadata copy)
{
MapName = copy.MapName;
Boundary = new Boundary(copy.Boundary);
TransformationMatrices = new TransformationMatrices(copy.TransformationMatrices);
}
[Required]
[MaxLength(200)]
public string MapName { get; set; }
[Required]
public Boundary Boundary { get; set; }
[Required]
public TransformationMatrices TransformationMatrices { get; set; }
}
[Owned]
public class Boundary
{
public Boundary()
{
X1 = 0;
Y1 = 0;
X2 = 0;
Y2 = 0;
Z1 = 0;
Z2 = 0;
}
public Boundary(Boundary copy)
{
X1 = copy.X1;
X2 = copy.X2;
Y1 = copy.Y1;
Y2 = copy.Y2;
Z1 = copy.Z1;
Z2 = copy.Z2;
}
public Boundary(double x1, double y1, double x2, double y2, double z1, double z2)
{
X1 = Math.Min(x1, x2);
X2 = Math.Max(x1, x2);
Y1 = Math.Min(y1, y2);
Y2 = Math.Max(y1, y2);
Z1 = Math.Min(z1, z2);
Z2 = Math.Max(z1, z2);
}
[Required]
public double X1 { get; set; }
[Required]
public double X2 { get; set; }
[Required]
public double Y1 { get; set; }
[Required]
public double Y2 { get; set; }
[Required]
public double Z1 { get; set; }
[Required]
public double Z2 { get; set; }
public List<double[]> As2DMatrix()
{
return [[X1, Y1], [X2, Y2]];
}
}
}