mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 11:26:31 +00:00
76 lines
2.9 KiB
C#
76 lines
2.9 KiB
C#
using System.IO;
|
|
using System.Windows.Media;
|
|
using Azaion.Common.DTO;
|
|
using Azaion.Common.DTO.Queue;
|
|
using MessagePack;
|
|
|
|
namespace Azaion.Common.Database;
|
|
|
|
[MessagePackObject]
|
|
public class Annotation
|
|
{
|
|
[Key("n")] public string Name { get; set; } = null!;
|
|
[Key("hash")] public string MediaHash { get; set; } = null!;
|
|
[Key("mn")] public string OriginalMediaName { get; set; } = null!;
|
|
[IgnoreMember] public TimeSpan Time { get; set; }
|
|
[IgnoreMember] public string ImageExtension { get; set; } = null!;
|
|
[IgnoreMember] public DateTime CreatedDate { get; set; }
|
|
[IgnoreMember] public string CreatedEmail { get; set; } = null!;
|
|
[IgnoreMember] public RoleEnum CreatedRole { get; set; }
|
|
[IgnoreMember] public SourceEnum Source { get; set; }
|
|
[IgnoreMember] public AnnotationStatus AnnotationStatus { get; set; }
|
|
|
|
[IgnoreMember] public DateTime ValidateDate { get; set; }
|
|
[IgnoreMember] public string ValidateEmail { get; set; } = null!;
|
|
|
|
[Key("d")] public IEnumerable<Detection> Detections { get; set; } = null!;
|
|
[Key("t")] public long Milliseconds { get; set; }
|
|
|
|
[Key("lat")]public double Lat { get; set; }
|
|
[Key("lon")]public double Lon { get; set; }
|
|
|
|
#region Calculated
|
|
[IgnoreMember] public List<int> Classes => Detections.Select(x => x.ClassNumber).ToList();
|
|
[IgnoreMember] public bool IsSplit => Name.Contains(Constants.SPLIT_SUFFIX);
|
|
|
|
private CanvasLabel? _splitTile;
|
|
[IgnoreMember] public CanvasLabel? SplitTile
|
|
{
|
|
get
|
|
{
|
|
if (!IsSplit)
|
|
return null;
|
|
if (_splitTile != null)
|
|
return _splitTile;
|
|
|
|
var startCoordIndex = Name.IndexOf(Constants.SPLIT_SUFFIX, StringComparison.Ordinal) + Constants.SPLIT_SUFFIX.Length;
|
|
var coordsStr = Name.Substring(startCoordIndex, 14).Split('_');
|
|
_splitTile = new CanvasLabel
|
|
{
|
|
Left = double.Parse(coordsStr[1]),
|
|
Top = double.Parse(coordsStr[2]),
|
|
Width = double.Parse(coordsStr[0]),
|
|
Height = double.Parse(coordsStr[0])
|
|
};
|
|
return _splitTile;
|
|
}
|
|
}
|
|
|
|
[IgnoreMember] public string TimeStr => $"{Time:h\\:mm\\:ss}";
|
|
#endregion Calculated
|
|
}
|
|
|
|
[MessagePackObject]
|
|
public class AnnotationImage : Annotation
|
|
{
|
|
[Key("i")] public byte[] Image { get; set; } = null!;
|
|
}
|
|
|
|
public enum AnnotationStatus
|
|
{
|
|
None = 0,
|
|
Created = 10,
|
|
Edited = 20,
|
|
Validated = 30,
|
|
Deleted = 40
|
|
} |