Conversation
…mponent by adding commented out option for rectangular region picker, slightly altering the map center to better show that the two region picker shapes produce different aggregated stats
|
@Jakidxav is attempting to deploy a commit to the carbonplan Team on Vercel. A member of the Team first needs to authorize it. |
Shane98c
left a comment
There was a problem hiding this comment.
This looks cool! Thanks for your work here.
I think we'll need to make some updates to queryRegion in tiles.js and and getTilesOfRegion in utils.js in order to handle the rectangle shape since there are lots of circle assumptions built into the region picker flow.
A couple smaller suggestions below.
Also, might be worth checking out https://github.com/carbonplan/zarr-layer if you're building this for a project - it takes a geojson shape for query which is a lot more flexible!
| strokeDasharray='3,2' | ||
| /> | ||
|
|
||
| <g id={`radius-text-container-${id}`}> |
There was a problem hiding this comment.
should we change to show side length here?
There was a problem hiding this comment.
That is probably much more intuitive.
Then a circular region picker could be created with:
<RegionPicker
...
mode={'circle'}
minRadius={300}
maxRadius={2000}
initialRadius={1000}
/>
And a rectangular region picker with:
<RegionPicker
...
mode={'rectangle'}
minSideLength={300}
maxSideLength={2000}
initialSideLength={1000}
/>
or something similar?
We could then check to make sure that radius props are only used when mode is set to 'circle' and side length props when mode is 'rectangle'.
| export const HANDLE_RADIUS = 8 | ||
| export const SHOW_RADIUS_GUIDELINE = true | ||
|
|
||
| const POLES = [point([0, -90]), point([0, 90])] |
There was a problem hiding this comment.
might be worth moving these to somewhere shared
There was a problem hiding this comment.
SHOW_RADIUS_GUIDELINE was actually already declared in in region/region-picker/constants.js and used by the <CircleRenderer /> component. I decided to move HANDLE_RADIUS, POLES, and abbreviations there, too, since they are shared between the circle and bbox picker.
I changed the name of abbreviations to UNITS_DICT since I thought that made it easier to tell what it is used for, but I am not tied to that name.
src/region/region-picker/rectangle-picker/rectangle-renderer.js
Outdated
Show resolved
Hide resolved
|
Thank you @Shane98c for reviewing my pull request! I cleaned up the code by including most of your suggestions. I hadn't thought about what it would take to overhaul the I actually first started building this component to use with the |
… statement thrown in region picker component now fixed; strict equality checking used for all strings in region picker; circle and rectangle pickers now use same fill opacity for cutout background; moving variables shared by circle and rectangle renderers to contants file
for more information, see https://pre-commit.ci
Purpose
Supporting a rectangular, bounding box-style option for the
<RegionPicker />component. Currently, only a circular option is available.Changes
srcI added a
<RectanglePicker />component that works very similar to the<CirclePicker />that is currently used. Because some of the code between the picker components is shared, I was able to move theutilsmethods and<CursorManager />component tosrc/region/region-picker/.The
<RegionPicker />component would now accept amodeprop which defaults to'circle', but can toggle between that and the'rectangle'option when rendered within the map component. Right now, only one corner can be used to resize the rectangular region, but future work could extend this to include all corners in order to create custom rectangular region shapes.demoIn the demo app, I commented out the
modeprop for the<RegionPicker />that shows how a user could toggle between the'circle'and'rectangle'options. I also slightly modified the map's starting center location to better show that these two options produce different output when they are initially rendered.pre-commitformattingAll files in this pull request meet
pre-commitchecks. When I run:I see: