Closed oliviadargel closed 2 years ago
Okey here is the Pseudo Code:
calculating the radius of every point :
// starting point for this approach : https://roadcurvature.com/how-it-works/
val coordinates //list of coordinates
val radiuses //list of radious
for (i in 0 until coordiantes.size){
val firstC = coordinates[i]
val secC = coordinates[i+1]
val thirdC = coordinates[i+2]
val a = distance(firstC, secC)
val b = distance(secC,thirdC)
val c = distance(firstC, thirdC)
// resource: https://www.mathopenref.com/trianglecircumcircle.html
val radius = (a*b*c)/(sqrt((a+b+c)*(b+c-a)*(c+a-b)*(a+b-c)))
radiuses.add(radius)
}
We now have a radius for every 3 nodes in the route. The problem is a curve is not have to only contain 3 nodes. Let's say if a curve has 9 nodes and if we filter them only by radius, our result will be like, "there are 9 curves here" but normally all of these nodes are in the same curve. OSM has segments attributes for it, it might be useful to calculate but here API doesn't have these attributes. Need to find a way to differentiate if a node group is just in an already determined curve or a new curve.
Note: Old ticket #179 was about coordinates, this one is about polylines
User story
Acceptance criteria
Definition of done