-
Notifications
You must be signed in to change notification settings - Fork 133
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
Improvements related to selection of feature(s) on map when modal tools are active #217
Improvements related to selection of feature(s) on map when modal tools are active #217
Conversation
activity Signed-off-by: Nikolaos Pringouris <nprigour@gmail.com>
During Eclipse Hackathon I had a look at and have a question regarding configuration page which Attribute of a feature is used: Is it a global configuration which is used for different Layers with different FeatureTypes or layer-specific? In addition, is the configured attribute name used case-sensitive (i guess from databases the attributes are uppercases whereas other ressources can handle upper and lower cases)? Please correct me if I'm wrong, this pull request changes the behavior for Features for the selected Layer. With other words : Does it query all layers and provides features from different layers or just from the selected? |
Hi @fgdrf ,
|
for (final SimpleFeature feat : features) { | ||
MenuItem item = new MenuItem(menu, SWT.PUSH); | ||
//SimpleFeature feature=iter.next(); | ||
boolean hasNameAttrib = feat.getAttribute(ATTRIBUTE_NAME) != null |
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 guess SimpleFeature.getAttribute() is case-sensitive regarding access featureType definition. E.g. if "NAME" is configured but attribute is "Name" feat.getAttribute(ATTRIBUTE_NAME)
would return null.
Maybe its worth the effort to imlement case-insensitve access right here (by evaluating featureType attribute names toLowerCase()
and find an appropriate ATTRIBUTE_NAME.toLowerCase())). What Do you think?
it worth to think about case-insensitive
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 will have a look at it. However it will need to iterate all featureType attribute names and perform comparisons.
@nprigour Many thanks! Whenever a featureType has a attribute configured in the preferences page the value of features attribute is shown, right? If there is no attribute like configured, fid is used to present for the user. BTW, cool to have right mouse-functionalliy for selection tools as well! |
@nprigour Would you be kind and add another section to user-Documentation? I guess Selection Tools.rst would be a good page to describe behavior and configuration option |
Signed-off-by: Nikolaos Pringouris <nprigour@gmail.com>
* @return a list of actual propertyName (case sensitive). If a propertyName is not present | ||
* then it is skipped from the list | ||
*/ | ||
public static List<String> getActualPropertyName(final SimpleFeatureType featureType, final List<String> propertyNames) { |
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.
Looks like this function is never used. Do we need at for this feature?
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.
No, it is a util function for possible future usage. after all this class contains util feature functions
PlatformGIS.syncInDisplayThread(new Runnable() { | ||
@Override | ||
public void run() { | ||
final String attribName = FeatureUtils.getActualPropertyName( |
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.
Looks like it would take the first attribute that matches, in case of FeatureType DataUtilities.createType("testType", "geometry:Polygon,name:String,timestamp:java.util.Date,NAME:String");
it would return values of the first attribute name (because its in the definition before NAME), wouldn't it?
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 yes but how usual it is to have attributes with same name but different capitalization within the same featureType?
|
||
@Override | ||
public void run() { | ||
final String attribName = FeatureUtils.getActualPropertyName( |
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 created some test cases (see commit nprigour@476378a), is this the expected behavior (especially the last test method)?
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.
@fgdrf , I modify FeatureUtils.getActualPropertyName(..) to perform first a strict case sensitive checking for attribute name before resorting to a case insensitive one.
Signed-off-by: Nikolaos Pringouris <nprigour@gmail.com>
exactmatch before resorting to case insensitive comparison Signed-off-by: Nikolaos Pringouris <nprigour@gmail.com>
@nprigour Please have a look at the pull-request nprigour#2 which contributes test cases and java 1.6 compatible behavior. |
@fgdrf after merging your test pull request to this one it seems ip-validation failed due to inproper sign-off. I performed the merge directly from github web interface and expected to take my signature but something seems wrong. Can you advice? Should I revert the commit and try the merge locally from eclipse IDE? |
Looks like IP-validation fails because of the merge commit. Can you try to reset to commit a84f39f (--hard) Afterwards I can create another pull request we can try to rebase onto your branch (avoids merge commit) or even squash the commit. You can find this options on the pull request dialog ;) |
Let walk through this, I have seen that the merg commit has invalid committer id noreply@github.com I expect, if we can get rid of this merge ip validation would be fine, please try this on your local branch - if you don't have other changes made anymore!:
now local working copy should have changes while the last commit is a84f39f. Now cleanup with Afterwards, you can either cherry-pick the commit 98b6655 (my changes) and push your branch to remote branch again using the force-option: git push -f GeneralModalToolsImprovements which re-writes history on remote-branch. However, we can chat (irc://us.freenode.net/udig) tomorrow morning (CEST) and try to fix it. We will make it! |
* it is skipped from the list | ||
* @throws IllegalArgumentException if featureType and/or propertyNames is null | ||
*/ | ||
public static List<String> getActualPropertyName(final SimpleFeatureType featureType, |
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.
What is this function for? Haven't found any caller in workspace ..
Is it ok for you if we can remove it from this pull-request?
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.
As explained in a previous comment it is not current used but I included there since FeatureUtils is a generic util class and it might be handly for somebody in the future. After all it is a more generialized version of the one I am using. Checking udig code, it seems there are also similar cases in other util classes within udig project
attributeName is null Signed-off-by: Nikolaos Pringouris <nprigour@gmail.com>
69bbc2d
to
b4b2cd6
Compare
* made parameter validation java 1.6. compatible (throws IllegalArgumentException) * formatted code using extras/org.locationtech.udig.dev/codeformatter.xml Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net>
@nprigour Awesome, it looks like you managed to get rid of this merge commit! Well done! |
@fgdrf , |
/** | ||
* The radius to be used during UI single feature selection search like commands (select, edit etc.). | ||
*/ | ||
public static final String FEATURE_SELECTION_RADIUS = "featureSelectionRadius"; //$NON-NLS-1$ |
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 it your intention to define a radius in pixel or unit of measure of current CRS? I assume in pixel and if so, maybe we can make it much clearer:
- FEATURE_SELECTION_RADIUS_IN_PIXEL
- label name Selection radius (in Pixel)
Makes it easier to read code and varification of own expectations ;)
DeleteTool_confirmation_title = Confirm Delete | ||
|
||
DeleteTool_status = Click on the feature you wish to delete | ||
|
||
DeleteTool_warning = Select a different layer and try again | ||
|
||
DeleteToolPreferences_description = Delete Tool preferences | ||
|
||
DeleteToolPreferences_Delete_Radius = Delete Radius |
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.
Like for Selection Tool Deletation Tool should state the units Deletion Radius (in Pixel) I assume here either
@@ -42,6 +46,10 @@ | |||
*/ | |||
public class SetEditFeatureCommand extends AbstractCommand implements UndoableMapCommand { | |||
|
|||
// The size of the box that is searched. This is a 7x7 box of pixels by default. | |||
private int SEARCH_SIZE = Platform.getPreferencesService().getInt( | |||
ProjectUIPlugin.ID, PreferenceConstants.FEATURE_SELECTION_RADIUS, 7, null); |
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 7 the default, if nothing is set in PreferenceStore? I guess it makes sense to define a global Default which was:
store.setDefault(PreferenceConstants.P_DELETE_TOOL_RADIUS, 6);
or evenstore.setDefault(PreferenceConstants.FEATURE_SELECTION_RADIUS,6);
in PreferencesInitializer but is different to this one.
super.setActive(active); | ||
|
||
DELETE_SEARCH_SIZE = Platform.getPreferencesService().getInt( | ||
EditPlugin.ID, PreferenceConstants.P_DELETE_TOOL_RADIUS, 6, null); |
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.
Can we use global definition of Defaults here as well?
@@ -31,6 +31,8 @@ | |||
/** | |||
* Selects and drags single features. | |||
* | |||
* @deprecated {@link ArrowSelectionWithPopup} should be used instead |
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.
Thats great to keep it in the code base, SDK-Users may still use this action in their application. Thinking about moving selection tools into a separate bundle to make it possible for SDK-Users to choose preferred selection tools. The "new" bundle should provide its own preferences too.
What do you think about creation a bundle
- org.locationtech.udig.tool.select.point.simple for old code
- org.locationtech.udig.tool.select.point.featureselect for your contribution.
IMHO its a valid requirement if users of uDig SDK can choose to create their prefered application. In addition I see few other selection bundles (bbox, AOI, etc) not everybody wants to include per default.
However, my suggestions is to create another pull request that only has changes for deletion tool (radius and confirmation dialog, etc). With this pull request we can move on with the selection tool changes.
Now I'm wondering a bit about AbstractModalTool changes. Only ArrowSelectionWithPopup uses SELECTION_SEARCH_SIZE
Please help me to understand..
Just created an issue to seperate selection tools into different bundles : #249 |
* added tests for FeatureUtils.getActualPropertyName Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net> * updated javadoc, optimized attributes access Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net> * updated selection prefs behavior * added link to general tool preferences page * selection radios config on selection preferences page * fixed prefs link in editor for selection tools * tool uses correct prefs while config changed in between (by user) and tool is still active Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net> * unified pref pages and tool behavior (delete) Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net> * unified naming and added javadoc Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net> * delete confirmation dialog uses feat attribute Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net> * fixed prefs link in editor for feature delete tool Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net> * fixed NPE Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net> * delete confirmation shows attribute and id Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net> * fixed imports Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net> * added moved files Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net> * fixed imports of SelectionToolPreferencePage Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net> * [user-doc] updated tool preferences Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net> * unified preferences and docs Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net> * applied DeleteTool attrib improvement Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net> * cleanup duplicated preferences options * removed P_SHOW_ANIMATIONS from Edit Performance Preferences * updated user docs Edit Tool Performance Preferences Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net> * used defaults for commands, updated doc image Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net> * removed unused NLS keys Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net>
Anything else you like to to on this branch or can I start rebasing and merging this improvement? |
Nothing from my side. You can proceed with merging. |
@nprigour Thank you very much for this contribution and the smooth collaboration! |
The specified contribution enables selection of a feature that a modal tool action will apply in case of overlapping feature. Moreover it provides some extra preference options to control this selection behavior. All improvements are listed below (see also screenshots in attached zip file):
toolsImprovements.zip
Signed-off-by: Nikolaos Pringouris nprigour@gmail.com