-
Notifications
You must be signed in to change notification settings - Fork 4
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
Start refactoring scheme sketcher code, before moving to a library #512
Conversation
codebase. - Move interventionName into config that could be set by other users - Move the code that assigns an arbitrary scheme to new interventions
@@ -129,17 +126,7 @@ | |||
if (source.properties.waypoints) { | |||
destination.properties.waypoints = source.properties.waypoints; | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The stuff staying here isn't domain specific; it comes from the route tool
return interventionName(f as FeatureUnion); | ||
}, | ||
|
||
newPointFeature: (f: Feature<Point>) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The theme here is that these functions get a "mostly just geometry" object and then make it obey the invariants imposed by gjSchemeCollection
. Some of the logic is common,but stuff like intervention_type
and fiddling with route names is not.
| { mode: "set-image" } | ||
| { mode: "streetview" }; | ||
|
||
// Properties are guaranteed to exist, but can be anything, so TS is mostly disabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed this to be more clear. By setting the properties this way, TS assumes any key can exist, with any type. (It's what we've been doing before; there's no change, just the name makes it more clear)
This sounds great to me and should make it easier for others to use the very useful functionality, in UK and beyond! |
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
androute-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 oflib/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-widemap
anduserSetings
stores, and I need to think through how to make theSchemeCollection
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.