Open up a map editing architecture in the workflow for transformation, and enables generating at non-origin
- Added a map_editing step in the workflow, after parsing element to ProcessedElement, before generating_world(...). This enables development for map transformation, e.g. translating (#29), rotating (#97), snapping to grid (#274). To define operations, edit map_editing.json, which is a list of operation config dict that will be deserialized to construct specific types of Operator. The operation is applied on i32 coordinate, and i suppose 1m resolution is accurate enough for a city.
- Enabled world generation at non-origin, which is a necessary feature for map editing.
Thanks a lot for your effort! I'll take some time to look into this to make sure that I fully understand the changes and then follow up with merging it!
update: the architecture of cartesian is slightly modified for integration of a future spherical coordinate system. Prev: src/cartesian.rs; Now: src/coordinate_system/cartesian/*; The GeoCoord and BBox in #377 can be integrated in a unified way into a submodule src/coordinate_system/spherical_or_other_preferred_names/*. Coordinate transformations, where a lot of customizations and extensions can be done, can be implemented in coordinate_system/transformation/*
Whoaaaaaa this is cool. I'll do a code review when I finish BBox PR
Thanks a lot for your time. I will response to every comment thoroughly and give you my thoughts on some of the designs when I have enough time on this, maybe on this weekend.
Overall AWESOME idea and implementation. I've left many notes because I'm passionate about this change and want to see it perfected and merged!
Note
I am a Rust noob. If some of these comments are wrong, feel free to tell me I'm wrong and hit resolve. No hard feelings :D
Overall thoughts
- I like the Operator design. Very nice and flexible. How hard would it be to add things like repetition operators (e.g., repeat a transformation/rotation several times)? Looking forward to seeing how simple adding rotation will be :D
- Please add unit tests wherever you see fit. I know they're pretty simple data structures, but it gives us additional confidence & debug info when weird edge cases arise.
- It would also be useful to be able to pass transformations via CLI arguments. Something like
--transform translate vector 500 500or something. That may be complex and not that great though so we can discuss separatelyI'm willing to approve this* if you review my comments for important suggestions first.
- I am not the maintainer so my words have 0 weight
Repetition is very simple: repetition itself is an operator, just a special one whose operation is to call another underlying operator several times.
Rotation on the elements is vector mathematics 101. The relatively trickier thing is the xzbbox. This thing needs to be rotated too. The idea is to make XZBBox an enum too, which can be Rect, Polygon, or even other shapes. The implementation is not difficult.
I try to add those tests following the style in your BBox PR.
Yes lets discuss the CLI implementation separately and currently just make it support reading a config file. Btw, if I decide to make the process highly programmable and able to run in batch, I choose to wrap it up as a python shell - everything connected to python will have the access to everything.
Woah you guys are amazing, I can't wait to see this merged! Since there are still a few open comments, ping me when you are done from your side and ready to merge. I don't have any open comments myself, @benjamin051000 you already covered most of it with your review. Big thanks to you both!
- [x] Validity check on XZBBox
- [x] Operator trait
- [x] Unit tests
- [x] CLI file name argument (separate PR)
- [x] File simplification (translator in trait style, XZPoint and XZVector keeps separate files for details clarity and safety)
- [x] JSON or TOML
I reserved the places for previously merged BBox GeoCoord modules and coordinate transformations in coordinate_system. This will be handled in a separate PR.
As you continue work on this feel free to mark my notes as "resolved" (there's a button to do this) to clean up the PR. Thanks! Excellent work so far. It seems like you are still working on various things here so I'll wait to look at your updates
A comment on BBox: I am trying to add unit test on my transformation module so I copied the example bbox coordinate in bbox test to fetch data. It failed because API did not return anything. I changed to another coordinate that has longitude > 90 and realized that this example coordinate is not in the correct order, which is instead located in the middle of Arabian Sea so of course it is returning nothing.
// Arnis, Germany (but not, this is in Arabian Sea) assert!(BBox::new(9.927928, 54.627053, 9.937563, 54.634902).is_ok());
where
pub fn new(min_lat: f64, min_lng: f64, max_lat: f64, max_lng: f64)
I changed it to the correct order and added three more cities that have longitude > 90 or < -90, two having latitude > 0, one < 0, so that will not be confusing.
OK, the operator module is changed to trait style as suggested; XZBBox is created using factory method and it checks for validity inside; all public member functions/data of XZBBox ensures its validity; tests are added for xzbbox, operators json reading, and translation.
retrigger-benchmark
⏱️ Benchmark run finished in 1m 58s 🧠 Peak memory usage: 1964 MB
📈 Compared against baseline: 130s
🧮 Delta: -12s
🔢 Commit: 922e752
✅ This PR improves generation time.
You can retrigger the benchmark by commenting retrigger-benchmark.
I think it's ready for review again. Most of the review comments are taken care of, except XZPoint and XZVector simplification, which I still think they should be in separate files and structures because of potential algorithm safety issue and the clarity when trying to tell apart their nuances for users.
retrigger-benchmark
Hi there, first of all thanks for the great work @XianlinSheng and thanks for your extensive review @benjamin051000! I wanted to review it earlier already but got sick - so sorry for the delay. There are no more comments from my side, this is amazing to build on in the future. Is this ready to merge from your side @XianlinSheng?
No problems on my side. Take your time and hope you get well soon.