core, editoast: add topological to geometric offset projection on /path endpoint - #17476
neigeantre wants to merge 2 commits into
Conversation
|
9ee4581 to
1ce4952
Compare
1ce4952 to
5400d80
Compare
8f804c0 to
904e545
Compare
bougue-pe
left a comment
There was a problem hiding this comment.
👍 LTGM overall, thanks for the tests.
Only comments on the form.
| #[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] | ||
| #[schema(as = CorePropertyGeometryProjection)] | ||
| pub struct GeometryProjection { | ||
| /// Topologic offsets in millimeters. |
There was a problem hiding this comment.
Looks like the en-US word is topological.
Ditto for all this PR (code + commits + github).
There was a problem hiding this comment.
done in the code, will do it in commit messages when I rebase
There was a problem hiding this comment.
I let you do a ctrl+F topologic but spotted leftovers in code, PR title, etc.
Anyway, this comment is a reminder for what's left, currently, so letting this open.
…_properties endpoint - Change `TrainPath` interface in core to access the path's partial track sections - Add property `geom_projection` to core and editoast APIs - Test the computing of `geom_projection` in core Signed-off-by: Arthur Bougeard <covillesheer@gmail.com>
5cac885 to
a9c04c1
Compare
bougue-pe
left a comment
There was a problem hiding this comment.
Waiting for the switch to haversine, but it looks good so far :)
|
|
||
| data class GeometricProjection( | ||
| @Json(name = "topo_offsets") val topoOffsets: List<Offset<PhysicsPath>>, | ||
| @Json(name = "geom_offsets") val geomOffsets: List<Offset<RJSLineString>>, |
There was a problem hiding this comment.
It's about to become RJSMutliLineString 😅
I'd say the first one merged wins (but notify the other to propagate the change)
There was a problem hiding this comment.
thanks for this, I’ll be watching if that PR is merged before this one
| for (i in 0..<(topoOffsets.size - 1)) { | ||
| assert(topoOffsets[i] <= topoOffsets[i + 1]) | ||
| assert(geomOffsets[i] <= geomOffsets[i + 1]) |
There was a problem hiding this comment.
nit: It would be nicer to trigger the loop only inside asserts (spare the loop if assert is not triggered).
I'd probably go using .zipWithNext() and .all{} to do that.
| val rangeTopoLength = range.length | ||
| val trackSectionTopoLength = range.objectLength | ||
| val trackSectionGeomLength = getTrackSectionGeometricLength(range.value.value) | ||
| topoOffsets.addLast(topoOffsets.last() + rangeTopoLength) | ||
| val proportion = rangeTopoLength / trackSectionTopoLength.distance | ||
| val rangeGeomLength = trackSectionGeomLength.distance * proportion | ||
| geomOffsets.addLast(geomOffsets.last() + rangeGeomLength) |
There was a problem hiding this comment.
nit: it would be easier to read if "stories" have as little overlap as possible (just reordering below).
| val rangeTopoLength = range.length | |
| val trackSectionTopoLength = range.objectLength | |
| val trackSectionGeomLength = getTrackSectionGeometricLength(range.value.value) | |
| topoOffsets.addLast(topoOffsets.last() + rangeTopoLength) | |
| val proportion = rangeTopoLength / trackSectionTopoLength.distance | |
| val rangeGeomLength = trackSectionGeomLength.distance * proportion | |
| geomOffsets.addLast(geomOffsets.last() + rangeGeomLength) | |
| val rangeTopoLength = range.length | |
| topoOffsets.addLast(topoOffsets.last() + rangeTopoLength) | |
| val trackSectionTopoLength = range.objectLength | |
| val proportion = rangeTopoLength / trackSectionTopoLength.distance | |
| val trackSectionGeomLength = getTrackSectionGeometricLength(range.value.value) | |
| val rangeGeomLength = trackSectionGeomLength.distance * proportion | |
| geomOffsets.addLast(geomOffsets.last() + rangeGeomLength) |
| val firstTrackRangeLength = (firstTrackRangeProportion * trackTA0GeoLength).toLong() | ||
| val secondTrackRangeLength = trackTA1GeoLength.toLong() |
There was a problem hiding this comment.
Feels like you can avoid * 1000 and .toLong() using Double.meters to get a Distance.
There was a problem hiding this comment.
I removed this part
| val chunks = rawInfra.getTrackSectionChunks(trackSection) | ||
| return chunks | ||
| .map { | ||
| Length<RJSLineString>(Distance.fromMeters(rawInfra.getTrackChunkGeom(it).length)) |
There was a problem hiding this comment.
nit: shorter
| Length<RJSLineString>(Distance.fromMeters(rawInfra.getTrackChunkGeom(it).length)) | |
| Length<RJSLineString>(rawInfra.getTrackChunkGeom(it).length.meters) |
…n /path_properties endpoint
b27f512 to
b31a832
Compare
TrainPathinterface in core to access the path's partial track sectionsgeom_projectionto core and editoast APIsgeom_projectionin corefix #9372
Important
The length computed in core for the
LineStringgeometry is not exact, so it differs from the one we compute in the front (which is exact, using@turf/lengthpackage, implementing Haversine formula).So we decided to implement the same formula in core, only for the loading of the infra, and being careful as to where we also have to make corresponding changes.