Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LP-1040 and LP-1041 #1052

Merged
merged 9 commits into from
Mar 21, 2024
Prev Previous commit
Next Next commit
Fix curve with zero angle and curve direction on a livemap
  • Loading branch information
IKupriyanov-HORIS committed Mar 19, 2024
commit ab3897a94c9898ea7e35140ad375ae754bfc7b55
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ fun curve(
curvature: Double,
angle: Double,
ncp: Int
): List<DoubleVector> {
val controlPoints = calcControlPoints(start, end, curvature, angle, ncp)
return listOf(start) + controlPoints + listOf(end)
}

private fun calcControlPoints(
start: DoubleVector,
end: DoubleVector,
curvature: Double,
angle: Double,
ncp: Int
): List<DoubleVector> {
// straight line
if (curvature == 0.0 || abs(angle) !in 1.0..179.0) {
Expand Down Expand Up @@ -89,12 +100,11 @@ fun curve(
)
}

val controlPoints = indices.map { index ->
return indices.map { index ->
start.add(
cp[index].subtract(start).rotate(-beta)
)
}
return listOf(start) + controlPoints + listOf(end)
}

private fun calcOrigin(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ internal class DataPointsConverter(

val start = it.toLocation(Aes.X, Aes.Y) ?: return@process emptyList()
val end = it.toLocation(Aes.XEND, Aes.YEND) ?: return@process emptyList()
val (_, geometry) = elementHelper.createCurve(start, end, geom.curvature, -geom.angle, geom.ncp, it) ?: return@process emptyList()
val (_, geometry) = elementHelper.createCurve(start, end, geom.curvature, geom.angle, geom.ncp, it) ?: return@process emptyList()
geometry
}
}
Expand Down