acteng / atip

Active Travel Infrastructure Platform
https://acteng.github.io/atip/
Apache License 2.0
22 stars 4 forks source link

Start refactoring scheme sketcher code, before moving to a library #512

Closed dabreegster closed 2 weeks ago

dabreegster commented 3 weeks ago

I want to move the bulk of the scheme sketcher code into a new git repo, exposed as a Sveltekit library. The goal is to more easily use pieces of this from other projects, such as the inspectorate tools. It's not an easy refactor; the bulk of the core drawing logic is already in maplibre-draw-polygon and route-snapper, but the code here manages the toolbox, switches modes, manages the store with the GeoJSON features, etc.

Roughly the split of responsibility I picture is like this. The sketch library will handle lib/draw/ and parts of lib/sidebar -- giving people the mode switching logic, multi layer (scheme) management, sidebar controls, etc. What will remain in this repo (and have a new, much simpler variation in inspectorate tools) is per-schema forms, backfilling logic, etc. So the library shouldn't really care about feature properties beyond a few of the truly common ones.

This PR is a first step that makes lib/draw/ much more self-contained and starts teasing apart the types. I think even as a standalone refactor without doing the rest, it has some value. It's not complete -- the code still pulls in repo-wide map and userSetings stores, and I need to think through how to make the SchemeCollection type more generic. Assuming tests pass and there are no comments, I'll merge next time I work on this. A next step will probably be starting the new repo and discovering more tricky complications.

robinlovelace-ate commented 3 weeks ago

This sounds great to me and should make it easier for others to use the very useful functionality, in UK and beyond!