MapEdge.cs 3.2 KB

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Rcs.Domain.Entities;

[Table("map_edges")]
public partial class MapEdge : Entity
{
    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.None)]
    [Column("edge_id")]
    public Guid EdgeId { get; set; }

    /// <summary>
    /// 地图ID(外键)
    /// </summary>
    [Column("map_id")]
    public Guid MapId { get; set; }
        
    [Required]
    [Column("edge_code")]
    [MaxLength(50)]
    public string EdgeCode { get; set; }

    [Column("from_node")]
    public Guid FromNode { get; set; }

    [Column("to_node")]
    public Guid ToNode { get; set; }

    [Column("edge_name")]
    public string? EdgeName { get; set; }

    [Column("length")] public double Length { get; set; } = 0;

    [Column("cost")]
    public double? Cost { get; set; } = 1d;

    [Column("created_at", TypeName = "timestamp")]
    public DateTime? CreatedAt { get; set; }

    [Column("active")]
    public bool Active { get; set; }
        
    /// <summary>
    /// 是否为曲线
    /// false = 直线
    /// true  = NURBS 曲线
    /// </summary>
    [Column("is_curve")]
    public bool IsCurve { get; set; }
        
    /// <summary>
    /// 半径
    /// </summary>
    [Column("radius")]
    public double? Radius { get; set; }

    /// <summary>
    /// 圆心X
    /// </summary>
    [Column("center_x")]
    public double? CenterX { get; set; }
        
    /// <summary>
    /// 圆心Y
    /// </summary>
    [Column("center_y")]
    public double? CenterY { get; set; }
        
    // ----------------------
    // NURBS 曲线参数(仅当 IsCurve = true 时有效)
    // ----------------------

    /// <summary>
    /// 曲线阶数(degree)
    /// 常用值:2(二次),3(三次)
    /// </summary>
    [Column("degree")]
    public int? Degree { get; set; } = 2;

    [Column("control_points", TypeName = "jsonb")]
    public List<Point>? ControlPoints { get; set; }
        
    [Column("weights", TypeName = "jsonb")]
    public List<double>? Weights { get; set; }
        
    [Column("knots", TypeName = "jsonb")]
    public List<double>? Knots { get; set; }
        
    /// <summary>
    /// 允许的行驶夹角角度列表(单位:弧)
    /// </summary>
    [Column("orientation_rads", TypeName = "jsonb")]
    public List<double>? OrientationRads { get; set; }

    /// <summary>
    /// 最大坐标偏移值 (单位:米)
    /// </summary>
    [Column("max_coordinate_offset")]
    public double? MaxCoordinateOffset { get; set; }

    /// <summary>
    /// 最大角度偏差值 (单位:度)
    /// </summary>
    [Column("max_rad_deviation")]
    public double? MaxRadDeviation { get; set; }

    /// <summary>
    /// 最高速度 (单位:米/秒)
    /// </summary>
    [Column("max_speed")]
    public double? MaxSpeed { get; set; }

    #region 外键 => 导航属性,ManyToOne/OneToOne

    [ForeignKey(nameof(MapId))]
    public virtual Map Maps { get; set; }

    public virtual MapNode MapNodesFromNode { get; set; }

    public virtual MapNode MapNodesToNode { get; set; }

    #endregion
}
    
public class Point
{
    public double X { get; set; }
    public double Y { get; set; }
}