调整导出精度,将路径数据相关的数值精度从6位小数修改为3位小数

This commit is contained in:
tian 2026-02-06 00:36:30 +08:00
parent 9e2ce0a3bc
commit b7cdb72ff7

View File

@ -269,16 +269,16 @@ namespace NavisworksTransport
name = route.Name,
description = route.Description ?? "",
pathType = route.PathType.ToString(),
totalLength = Math.Round(route.TotalLength, exportSettings?.Precision ?? 6),
totalLength = Math.Round(route.TotalLength, exportSettings?.Precision ?? 3),
vehicleLimits = new
{
maxLength = Math.Round(route.MaxVehicleLength, exportSettings?.Precision ?? 6),
maxWidth = Math.Round(route.MaxVehicleWidth, exportSettings?.Precision ?? 6),
maxHeight = Math.Round(route.MaxVehicleHeight, exportSettings?.Precision ?? 6),
safetyMargin = Math.Round(route.SafetyMargin, exportSettings?.Precision ?? 6)
maxLength = Math.Round(route.MaxVehicleLength, exportSettings?.Precision ?? 3),
maxWidth = Math.Round(route.MaxVehicleWidth, exportSettings?.Precision ?? 3),
maxHeight = Math.Round(route.MaxVehicleHeight, exportSettings?.Precision ?? 3),
safetyMargin = Math.Round(route.SafetyMargin, exportSettings?.Precision ?? 3)
},
gridSize = Math.Round(route.GridSize, exportSettings?.Precision ?? 6),
liftHeightMeters = Math.Round(route.LiftHeightMeters, exportSettings?.Precision ?? 6),
gridSize = Math.Round(route.GridSize, exportSettings?.Precision ?? 3),
liftHeightMeters = Math.Round(route.LiftHeightMeters, exportSettings?.Precision ?? 3),
created = route.CreatedTime.ToString("yyyy-MM-ddTHH:mm:ss"),
points = route.GetSortedPoints().Select(point => new
{
@ -286,15 +286,15 @@ namespace NavisworksTransport
name = point.Name,
type = point.Type.ToString(),
index = point.Index,
x = Math.Round(point.Position.X, exportSettings?.Precision ?? 6),
y = Math.Round(point.Position.Y, exportSettings?.Precision ?? 6),
z = Math.Round(point.Position.Z, exportSettings?.Precision ?? 6),
x = Math.Round(point.Position.X, exportSettings?.Precision ?? 3),
y = Math.Round(point.Position.Y, exportSettings?.Precision ?? 3),
z = Math.Round(point.Position.Z, exportSettings?.Precision ?? 3),
created = point.CreatedTime.ToString("yyyy-MM-ddTHH:mm:ss")
}).ToArray(),
edges = route.Edges != null && route.Edges.Count > 0 ? route.Edges.Select(edge => new
{
type = edge.SegmentType.ToString().ToLower(),
physicalLength = Math.Round(edge.PhysicalLength, exportSettings?.Precision ?? 6),
physicalLength = Math.Round(edge.PhysicalLength, exportSettings?.Precision ?? 3),
trajectory = edge.SegmentType == PathSegmentType.Arc && edge.Trajectory != null ? new
{
ts = new
@ -317,7 +317,7 @@ namespace NavisworksTransport
},
requestedRadius = Math.Round(edge.Trajectory.RequestedRadius, 3),
actualRadius = Math.Round(edge.Trajectory.ActualRadius, 3),
deflectionAngle = Math.Round(edge.Trajectory.DeflectionAngle, 6),
deflectionAngle = Math.Round(edge.Trajectory.DeflectionAngle, 3),
arcLength = Math.Round(edge.Trajectory.ArcLength, 3)
} : null
}).ToArray() : null
@ -392,9 +392,9 @@ namespace NavisworksTransport
edgeIndex.ToString(),
edge.SegmentType.ToString(),
pointIndex.ToString(),
point.X.ToString("F6", CultureInfo.InvariantCulture),
point.Y.ToString("F6", CultureInfo.InvariantCulture),
point.Z.ToString("F6", CultureInfo.InvariantCulture)
point.X.ToString("F3", CultureInfo.InvariantCulture),
point.Y.ToString("F3", CultureInfo.InvariantCulture),
point.Z.ToString("F3", CultureInfo.InvariantCulture)
);
writer.WriteLine(row);
}
@ -1009,9 +1009,9 @@ namespace NavisworksTransport
pointElement.SetAttribute("name", point.Name);
pointElement.SetAttribute("type", point.Type.ToString());
pointElement.SetAttribute("index", point.Index.ToString());
pointElement.SetAttribute("x", point.Position.X.ToString("F6"));
pointElement.SetAttribute("y", point.Position.Y.ToString("F6"));
pointElement.SetAttribute("z", point.Position.Z.ToString("F6"));
pointElement.SetAttribute("x", point.Position.X.ToString("F3"));
pointElement.SetAttribute("y", point.Position.Y.ToString("F3"));
pointElement.SetAttribute("z", point.Position.Z.ToString("F3"));
pointElement.SetAttribute("created", point.CreatedTime.ToString("yyyy-MM-ddTHH:mm:ss"));
pointsElement.AppendChild(pointElement);
@ -1027,7 +1027,7 @@ namespace NavisworksTransport
{
var edgeElement = xmlDoc.CreateElement("Edge", _delmiaNamespace);
edgeElement.SetAttribute("type", edge.SegmentType.ToString().ToLower());
edgeElement.SetAttribute("physicalLength", edge.PhysicalLength.ToString("F6"));
edgeElement.SetAttribute("physicalLength", edge.PhysicalLength.ToString("F3"));
// 圆弧轨迹数据
if (edge.SegmentType == PathSegmentType.Arc && edge.Trajectory != null)
@ -1067,7 +1067,7 @@ namespace NavisworksTransport
// 偏转角
var angleElement = xmlDoc.CreateElement("DeflectionAngle", _delmiaNamespace);
angleElement.InnerText = edge.Trajectory.DeflectionAngle.ToString("F6");
angleElement.InnerText = edge.Trajectory.DeflectionAngle.ToString("F3");
trajElement.AppendChild(angleElement);
// 圆弧长度
@ -1251,9 +1251,9 @@ namespace NavisworksTransport
/// </summary>
private void AddDelmiaPointData(XmlDocument xmlDoc, XmlElement element, PathPoint point)
{
element.SetAttribute("x", point.Position.X.ToString("F6"));
element.SetAttribute("y", point.Position.Y.ToString("F6"));
element.SetAttribute("z", point.Position.Z.ToString("F6"));
element.SetAttribute("x", point.Position.X.ToString("F3"));
element.SetAttribute("y", point.Position.Y.ToString("F3"));
element.SetAttribute("z", point.Position.Z.ToString("F3"));
element.SetAttribute("name", point.Name);
element.SetAttribute("type", point.Type.ToString());
}
@ -1311,7 +1311,7 @@ namespace NavisworksTransport
/// <summary>
/// 精度(小数位数)
/// </summary>
public int Precision { get; set; } = 6;
public int Precision { get; set; } = 3;
}