Skip to content

Commit

Permalink
Set boundaries to min and max values automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
aeshub committed Jun 9, 2023
1 parent 0805d0c commit b2b2aa5
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions backend/api/Database/Models/MissionMap.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
using System.ComponentModel.DataAnnotations;
#nullable disable
using System.ComponentModel.DataAnnotations;
using Microsoft.EntityFrameworkCore;

#nullable disable
namespace Api.Database.Models
{
[Owned]
public class MissionMap
{
public MissionMap()
{
MapName = "DefaultMapName";
Boundary = new Boundary();
TransformationMatrices = new TransformationMatrices();
}

[Required]
[MaxLength(200)]
public string MapName { get; set; }
Expand All @@ -16,26 +23,39 @@ public class MissionMap

[Required]
public TransformationMatrices TransformationMatrices { get; set; }

public MissionMap()
{
MapName = "DefaultMapName";
Boundary = new Boundary();
TransformationMatrices = new TransformationMatrices();
}
}

[Owned]
public class Boundary
{
public Boundary()
{
X1 = 0;
Y1 = 0;
X2 = 0;
Y2 = 0;
Z1 = 0;
Z2 = 0;
}

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 Y1 { get; set; }
public double X2 { get; set; }

[Required]
public double X2 { get; set; }
public double Y1 { get; set; }

[Required]
public double Y2 { get; set; }
Expand All @@ -46,29 +66,9 @@ public class Boundary
[Required]
public double Z2 { get; set; }

public Boundary()
{
X1 = 0;
Y1 = 0;
X2 = 0;
Y2 = 0;
Z1 = 0;
Z2 = 0;
}

public Boundary(double x1, double y1, double x2, double y2, double z1, double z2)
{
X1 = x1;
Y1 = y1;
X2 = x2;
Y2 = y2;
Z1 = z1;
Z2 = z2;
}

public List<double[]> As2DMatrix()
{
return new List<double[]> { new double[] { X1, Y1 }, new double[] { X2, Y2 } };
return new List<double[]> { new[] { X1, Y1 }, new[] { X2, Y2 } };
}
}
}

0 comments on commit b2b2aa5

Please sign in to comment.