-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add FeatureSelection tool #271
Conversation
padawannn
commented
Jan 11, 2022
•
edited by VictorVelarde
Loading
edited by VictorVelarde
- Name refactor (https://app.shortcut.com/cartoteam/story/204565/rename-drawingtoolwidget-and-drawingtoollayer). [sc-204565]
- Google Maps compatibility.
- Mask extension integration
Pull Request Test Coverage Report for Build 1778848646
💛 - Coveralls |
packages/react-redux/src/types.d.ts
Outdated
drawingToolMode: typeof DRAW_MODES | ||
drawingToolMode: string |
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.
Why such change here? isn't it better to use a more restricted type?
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.
Because typeof DRAW_MODES
doesn't work when I integrate it in typescript project. I accept suggestions
@@ -149,3 +149,5 @@ export function setDrawingToolEnabled(enabled: boolean): { | |||
}; | |||
|
|||
export function selectSpatialFilter(state: any, sourceId?: string): object | null; | |||
|
|||
export function selectDrawingToolMode(state: any): string | false; |
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.
If 'false' is equivalent to 'None', I think it could be better to add that option to an enum or type. What do you think?
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.
selectDrawingToolMode
is a selector that return false
if the spatialFilter
is null in the store (the default state). I think that creating another enum type could be over-engineering
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 just see there are other options without adding boolean to the mix:
- a) just an enum / type: DrawingToolMode.Type1, DrawingToolMode.Type2,... + DrawingToolMode.None, or more simple
- b) just respecting the null for 'None'.
"selectDrawingToolMode" doesn't sound like a boolean to me, but a value from a predefined list. If required, we can later do in code something like this
const noFilter = selectDrawingToolMode === null
if (noFilter) ...
What do you think?
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've done the b
option
@@ -0,0 +1,30 @@ | |||
import { EditableGeoJsonLayer } from '@nebula.gl/layers'; | |||
|
|||
const EVENT_TYPES = ['anyclick', 'pointermove', 'panstart', 'panmove', 'panend', 'keyup']; |
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.
Probably a comment with a bit of explanation on this would be really useful, about how this should be better a mechanism in nebula itself, with probably a PR on that in the future
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.
Agree, I'm going to add a link to the original code and write a small explanation
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.
Done
for (const eventType of EVENT_TYPES) { | ||
eventManager.on(eventType, eventHandler, { | ||
// give nebula a higher priority so that it can stop propagation to deck.gl's map panning handlers | ||
priority: 100 |
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.
Is 100 the "top priority" or how does is work? I mean, is it an arbitrary number?.
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 really don't know XD. This code has been copied from the original nebula code
https://github.com/uber/nebula.gl/blob/master/modules/layers/src/layers/editable-layer.ts#L83
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.
XD, ok then add this link to code...
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.
Done
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.
:+1
@padawannn I'm not sure if you prefer to merge this one together with #278, but I'm ok with this one, as it is now. Is it mergeable independently? (if that's the case add changelog entry before) |
I prefer to merge #278 first due to the name refactor requested by Borja |
Ok, then adding this as 'blocked' for the moment |
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.
LGTM, just minor question/suggestion
isSelected, | ||
selectedMode | ||
}) { | ||
const isGmaps = useSelector((state) => BASEMAPS[state.carto.basemap].type === 'gmaps'); |
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.
Is not 'gmaps' in any constant? Should we move it to a new one?
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.
We don't have a constant for 'gmaps'. Move it to a new one it's not as easy as it sounds because the basemap package also uses that string so probably we would need to add it to the core package and do a refactor. @VictorVelarde maybe we could do it in another PR
}; | ||
|
||
// Set layers should be outside of the useEffect to avoid problems with layers that changes |
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.
Won't it cause useless redraws on Deck?
Also, is it normal that the useEffect
below has no dependency array?
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.
Won't it cause useless redraws on Deck?
No, in fact, Deck always should receive a new instance of all layers and it decides if it's necessary to redraw or not. The creation of the layers or setting them within a useEffect
is a common mistake. Check this example https://deck.gl/docs/get-started/using-with-react#the-deckgl-react-component
Also, is it normal that the useEffect below has no dependency array?
In this case yes although I admit that it is difficult to understand. In any case, this PR does not intend to modify that part of the code
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.
LGTM
This pull request has been linked to Shortcut Story #204565: Rename DrawingToolWidget and DrawingToolLayer. |
…toDB/carto-react into drawingTool-googleMaps-compatibility
Co-authored-by: Víctor Velarde <victor.velarde@gmail.com>
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.
:rocket Well done
97d1669
to
52b48a7
Compare