ltn::save

Module perma

Source
Expand description

TODO All of this is in flux. Ultimately we should “just” use MapEdits, and squeeze partitioning into that somehow.

In the meantime, use the existing PermanentMapEdits structure. For partitioning, use “runtime reflection” magic to transform RoadIDs to OriginalRoads. Defining parallel structures manually would be too tedious.

  1. Serialize the Partitioning with RoadIDs to JSON
  2. Dynamically walk the JSON
  3. When the path of a value matches the hardcoded list of patterns in is_road_id, transform to a permanent ID
  4. Save the proposal as JSON with that ID instead
  5. Do the inverse to later load

In practice, this attempt to keep proposals compatible with future basemap updates might be futile. We’re embedding loads of details about the partitioning, but not checking that they remain valid after loading. Even splitting one road in two anywhere in the map would likely break things kind of silently.

Also, the JSON blobs are massive because of the partitioning, so compress everything.

Functions§