natcap / urban-online-workflow

This repository hosts the beta implementation of the Urban Online ES Workflow. The project is intended to give urban planners the ability to create and assess scenarios using InVEST Urban models.
1 stars 5 forks source link

Wallpaper pattern sampling tool #21

Closed emlys closed 2 years ago

emlys commented 2 years ago

This PR adds a wallpaper pattern samping tool. It lives in a new tab in the edit menu called Patterns. The Patterns tab contains a button that toggles "pattern selection mode". When in pattern selection mode, a draggable box is displayed over the map. You can choose a name for the pattern and sample it by clicking the "Sample this pattern" button.

When you click that button, a request is made to create a new pattern from that geometry. The list of available patterns is then re-requested. (With a functioning API, this would include the new pattern. In this version it stays the same.) And you exit pattern sampling mode.

Draggable selector box based off this example.

emlys commented 2 years ago

@davemfish I tried to refactor according to your suggestion. I didn't move the layer to its own module since it seemed a little small for that once I separated out the part that's logically distinct. But I did move all the map and layers stuff outside of the React MapComponent. I think that helps distinguish what is controlled by the map event loop vs. react rendering. Is that like what you're thinking?

davemfish commented 2 years ago

@davemfish I tried to refactor according to your suggestion. I didn't move the layer to its own module since it seemed a little small for that once I separated out the part that's logically distinct. But I did move all the map and layers stuff outside of the React MapComponent. I think that helps distinguish what is controlled by the map event loop vs. react rendering. Is that like what you're thinking?

Yes @emlys , I think this is even better than I was thinking! It does make clearer what is controlled by react and what is not. And having the map in scope for other useEffect hooks besides the primary one is very useful; it should help me with some other things I'm working on too.