feat: add p-rec-annot line-number apply preflight
This commit is contained in:
@@ -59,6 +59,7 @@ public sealed record LineNumberCandidate(string StableId, long RowId, Annotation
|
||||
public sealed record ExistingLineNumberAnnotation(string StableId, string SourceStableId, string Text);
|
||||
public sealed record LineNumberCommandOperation(string StableId, AnnotationOperationKind Kind, string? Text, AnnotationPoint Position, double Rotation, string Layer, string TextStyle, IReadOnlyList<string> Reasons);
|
||||
public sealed record LineNumberCommandPlan(IReadOnlyList<LineNumberCommandOperation> Operations);
|
||||
public sealed record LineNumberApplyPreflight(string StableId, string Text, AnnotationPoint Position, double Rotation, string Layer, string TextStyle);
|
||||
|
||||
public sealed record GeometrySnapshot
|
||||
{
|
||||
|
||||
@@ -17,4 +17,9 @@ public sealed class LineNumberCommandPlanner(ILineNumberAnnotationFormatter form
|
||||
}
|
||||
return new(result);
|
||||
}
|
||||
|
||||
public static IReadOnlyList<LineNumberApplyPreflight> PrepareApply(LineNumberCommandPlan plan) => plan.Operations
|
||||
.Where(x => x.Kind is AnnotationOperationKind.Create or AnnotationOperationKind.Update)
|
||||
.OrderBy(x => x.StableId, StringComparer.Ordinal)
|
||||
.Select(x => new LineNumberApplyPreflight(x.StableId, x.Text!, x.Position, x.Rotation, x.Layer, x.TextStyle)).ToArray();
|
||||
}
|
||||
|
||||
@@ -9,5 +9,6 @@ public sealed class LineNumberCommandPlannerTests
|
||||
var c = new LineNumberCandidate("b", 1, new(0,0), 0, "PXP", "Standard", new Dictionary<string,string?> { ["EngineeringItems.LineNumber"]="L-2" });
|
||||
var plan = new LineNumberCommandPlanner(new LineNumberAnnotationFormatter()).Build(def, [c, c, c with { StableId="a" }], [new("x", "b", "old")]);
|
||||
Assert.Collection(plan.Operations, x => Assert.Equal(AnnotationOperationKind.Create,x.Kind), x => Assert.Equal(AnnotationOperationKind.Update,x.Kind), x => Assert.Equal(AnnotationOperationKind.Conflict,x.Kind));
|
||||
Assert.Equal(new[] { "a", "b" }, LineNumberCommandPlanner.PrepareApply(plan).Select(x => x.StableId));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user