Skip to content
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

Merged
merged 28 commits into from
Feb 1, 2022
Merged

Conversation

padawannn
Copy link
Contributor

@padawannn padawannn commented Jan 11, 2022

@coveralls
Copy link
Collaborator

coveralls commented Jan 11, 2022

Pull Request Test Coverage Report for Build 1778848646

  • 16 of 18 (88.89%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.07%) to 70.388%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/react-redux/src/slices/cartoSlice.js 4 6 66.67%
Totals Coverage Status
Change from base Build 1757917925: 0.07%
Covered Lines: 1164
Relevant Lines: 1557

💛 - Coveralls

drawingToolMode: typeof DRAW_MODES
drawingToolMode: string
Copy link
Contributor

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?

Copy link
Contributor Author

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;
Copy link
Contributor

@VictorVelarde VictorVelarde Jan 11, 2022

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?

Copy link
Contributor Author

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

Copy link
Contributor

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?

Copy link
Contributor Author

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'];
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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
Copy link
Contributor

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?.

Copy link
Contributor Author

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

Copy link
Contributor

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...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@VictorVelarde VictorVelarde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:+1

@VictorVelarde
Copy link
Contributor

VictorVelarde commented Jan 18, 2022

@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)

@padawannn
Copy link
Contributor Author

padawannn commented Jan 19, 2022

@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

@VictorVelarde
Copy link
Contributor

Ok, then adding this as 'blocked' for the moment

@padawannn padawannn changed the title Compatibility between the drawingTool and Google Maps (first part) FeatureSelection Jan 27, 2022
@padawannn padawannn changed the title FeatureSelection Feature selection Jan 27, 2022
@padawannn padawannn marked this pull request as draft January 27, 2022 10:53
Copy link
Contributor

@Josmorsot Josmorsot left a 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');
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

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

packages/react-widgets/src/layers/FeatureSelectionLayer.js Outdated Show resolved Hide resolved
Copy link
Contributor

@bbecquet bbecquet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

CHANGELOG.md Outdated Show resolved Hide resolved
@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #204565: Rename DrawingToolWidget and DrawingToolLayer.

@VictorVelarde VictorVelarde self-requested a review January 28, 2022 16:01
@padawannn padawannn marked this pull request as ready for review February 1, 2022 10:10
@padawannn padawannn removed the blocked label Feb 1, 2022
@VictorVelarde VictorVelarde self-assigned this Feb 1, 2022
@VictorVelarde VictorVelarde changed the title Feature selection Add FeatureSelection tool Feb 1, 2022
Copy link
Contributor

@VictorVelarde VictorVelarde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:rocket Well done

@VictorVelarde VictorVelarde force-pushed the drawingTool-googleMaps-compatibility branch from 97d1669 to 52b48a7 Compare February 1, 2022 14:34
@VictorVelarde VictorVelarde merged commit 5f78921 into master Feb 1, 2022
@VictorVelarde VictorVelarde deleted the drawingTool-googleMaps-compatibility branch February 1, 2022 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants