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

front: adds warped map in simulation #4995

Merged
merged 15 commits into from
Sep 15, 2023
Merged

front: adds warped map in simulation #4995

merged 15 commits into from
Sep 15, 2023

Conversation

jacomyal
Copy link
Contributor

@jacomyal jacomyal commented Sep 7, 2023

This PR solves issue #4882 (closes #4882).

Details:

  • Adds utils/useAsyncMemo to help managing asynchronous states in React components
  • Adds src/common/Map/WarpedMap that displays a map that is warped along a given path
    • getWarping.ts is a good start to understand how the warping works
    • WarpedMap.tsx is a reusable isolated component
    • SimulationWarpedMap.tsx is a component coupled to simulation state
  • Isolates TrainHoverPosition to make it usable with a train that is not selected, and with a map that is not the "main" map
  • Updates SimulationResults to mount a SimulationWarpedMap next to the SpaceTimeChart
  • Updates SpaceTimeChart so that it properly dispatches an updateChart event when the chart changes

@jacomyal jacomyal requested a review from a team as a code owner September 7, 2023 13:57
@codecov
Copy link

codecov bot commented Sep 7, 2023

Codecov Report

Merging #4995 (a33c757) into dev (d39fab4) will decrease coverage by 0.41%.
The diff coverage is 0.05%.

@@             Coverage Diff              @@
##                dev    #4995      +/-   ##
============================================
- Coverage     22.03%   21.62%   -0.41%     
  Complexity     2455     2455              
============================================
  Files           852      863      +11     
  Lines         89224    90906    +1682     
  Branches       2483     2494      +11     
============================================
+ Hits          19658    19659       +1     
- Misses        68205    69875    +1670     
- Partials       1361     1372      +11     
Flag Coverage Δ
front 8.38% <0.05%> (-0.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
...ents/SimulationResults/ChartHelpers/defineChart.ts 0.00% <0.00%> (ø)
...ponents/SimulationResults/SimulationResultsMap.tsx 0.00% <0.00%> (ø)
...esults/SimulationResultsMap/TrainHoverPosition.tsx 0.00% <0.00%> (ø)
.../SimulationResults/SimulationResultsMap/helpers.ts 0.00% <0.00%> (ø)
...ts/SimulationResults/SimulationResultsMap/types.ts 0.00% <0.00%> (ø)
...imulationResults/SpaceTimeChart/SpaceTimeChart.jsx 0.00% <0.00%> (ø)
...ons/operationalStudies/views/SimulationResults.tsx 0.00% <0.00%> (ø)
front/src/common/Map/Layers/GeoJSONs.tsx 0.00% <0.00%> (ø)
front/src/common/Map/Layers/OSM.tsx 0.00% <0.00%> (ø)
front/src/common/Map/Layers/OrderedLayer.tsx 0.00% <0.00%> (ø)
... and 12 more

front/src/common/Map/Layers/GeoJSONs.tsx Outdated Show resolved Hide resolved
front/src/common/Map/Layers/OSM.tsx Outdated Show resolved Hide resolved
front/src/common/Map/WarpedMap/WarpedMap.tsx Outdated Show resolved Hide resolved
front/src/common/Map/Layers/OSM.tsx Outdated Show resolved Hide resolved
front/src/common/Map/WarpedMap/getWarping.ts Outdated Show resolved Hide resolved
front/src/common/Map/WarpedMap/core/grids.tsx Outdated Show resolved Hide resolved
front/src/common/Map/WarpedMap/core/grids.tsx Outdated Show resolved Hide resolved
front/src/common/Map/WarpedMap/core/grids.tsx Show resolved Hide resolved
front/src/common/Map/WarpedMap/core/grids.tsx Show resolved Hide resolved
Copy link
Contributor

@clarani clarani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, nice job !! Thank you for this great work 💪
I tested in local, 1 bug when you rotate the GET

front/src/common/Map/WarpedMap/core/grids.tsx Show resolved Hide resolved
front/src/common/Map/WarpedMap/core/grids.tsx Outdated Show resolved Hide resolved
front/src/common/Map/WarpedMap/core/grids.tsx Outdated Show resolved Hide resolved
front/src/common/Map/WarpedMap/core/grids.tsx Outdated Show resolved Hide resolved
front/src/common/Map/WarpedMap/core/grids.tsx Outdated Show resolved Hide resolved
front/src/common/Map/WarpedMap/SimulationWarpedMap.tsx Outdated Show resolved Hide resolved
front/src/common/Map/WarpedMap/SimulationWarpedMap.tsx Outdated Show resolved Hide resolved
front/src/common/Map/WarpedMap/core/helpers.ts Outdated Show resolved Hide resolved
front/src/common/Map/WarpedMap/SimulationWarpedMap.scss Outdated Show resolved Hide resolved
Copy link
Contributor

@clarani clarani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !! Great job, tested in local :)

Details:
- Lots of new utils and helpers to get a transformation that "warps" a
part of the map to something straighter
- Hacky GeoJSON data loading using an hidden map
- Drafts a rendering of the final transformed data
Details:
- Deduplicates OSM queried features
- Improves rendering and data querying
Details:
- Simplifies code structure
- Adapts new imports rules (ie "no relative import")
- WarpedMap now renders already warped data, and no more calls any data
  or method from the store
- SimulationWarpedMap loads everything it needs from the store (current
  path, selected train...), handles warping the data, and gives
  everything to a WarpedMap
Details:
- Adds utils/useAsyncMemo to simplify async data retrieving code
- Moves `getSimulationHoverPositions` and related helpers from
  SimulationResultsMap component code to new file
  SimulationResultsMap/helpers to make them reusable from elsewhere
- Uses those helpers to get similar trains to display in
  SimulationWarpedMap (after some warping magic)
Details:
- Updates SpaceTimeChart so that it calls `dispatchUpdateChart` when the
  graph is updated. I feel like it was missing, since this
  `dispatchUpdateChart` is called in `drawAllTrain` so the global chart
  is already "somehow" synchronized with the one in SpaceTimeChart
- Allows WarpedMap to be given a bounding box, in which case
  interactions are disabled
- Updates SimulationWarpedMap so that it computes a bounding box to fit
  SpaceTimeChart viewport, and gives it to WarpedMap
Details:
- TrainHoverPosition no more reads train, allowancesSettings and
  viewport from global store, and requires them in props instead (this
  allows showing not the selected train, and not in the main map)
- Adds the proper trains in the TrainPosition that are not related to
  the selected train
- Adapts SimulationWarpedMap, WarpedMap and SimulationResultsMap to
  these changes
Most of the updates are:
- Adds various comments
- Clarifies getWarping output naming
- Fixes some comment blocks syntax
@clarani clarani enabled auto-merge September 15, 2023 12:26
@clarani clarani added the area:front Work on Standard OSRD Interface modules label Sep 15, 2023
@clarani clarani added this pull request to the merge queue Sep 15, 2023
Merged via the queue into dev with commit aa4f9d6 Sep 15, 2023
@clarani clarani deleted the ajy/warping branch September 15, 2023 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:front Work on Standard OSRD Interface modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve warped map
2 participants