Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
New Contributor
Posts: 2
Registered: ‎05-22-2018

Get user selection for MapSelectionTools



I am doing a plugin and i would like to use the MapSelectionTools function.


I want to get the feature name of the user's selection contains in the list below.





I did not found a listener for the MapSelectionTools. 



	private MapSelectionTools mapSelectionTools;
	public void GetUserSelection() {
		mapSelectionTools = new MapSelectionTools();


How can I get the feature name selected by user ?


Thank you,



Technical Evangelist
Posts: 148
Registered: ‎10-20-2015

Re: Get user selection for MapSelectionTools

Hi Romain,

the selected layer will be the active layer if the spatial relate hit any geometries.


The MapSelection Tools uses the com.intergraph.web.extension.analyse.SpatialAnalysis. You can also execute this class by your own, if you want more control.


new SpatialAnalysis(yourSpatialAnalysisListener, SelectionMode.Point, null).selectWithShape();

The ISpatialAnalysisListener does the following. Every SpatialRelationResult is the result for one layer and the SpatialRelateFeatureSelection.showDialog(relationResults) call, shows the selection dialog.


public void selectionShapeCaptured(SpatialAnalysis spatialAnalysis, Shape capturedShape)
Feature activeFeature = ApplicationContext.getBrowser().getActiveFeature();
if(quickPickMode || spatialAnalysis.getSelectionMode() == SelectionMode.Geometry || activeFeature == null)
spatialAnalysis.relateWithFeatures(FeatureFilterFactory.filterFeatureList(ApplicationContext.getProject().getVisibleFeatures(), FeatureFilterFactory.getLocateableFilter()));
else if(activeFeature != null)

@Override public void spatialAnalyseFinished(SpatialAnalysis spatialAnalysis, List<SpatialRelationResult> relationResults) { if (!Assertion.isValid(relationResults)) { if (Log.isInfoEnabled()) Log.getLogger().info("no elements selected!"); ApplicationContext.getBrowser().refreshView(); return; } SpatialRelationResult selectedResult = relationResults.get(0); if (relationResults.size() > 1) selectedResult = SpatialRelateFeatureSelection.showDialog(relationResults); if (selectedResult == null) return; showSelectionInMap(selectedResult); } private void showSelectionInMap(SpatialRelationResult relationResult) { List<Object> selection = relationResult.getSelection(); int resultcount = selection.size(); if (Log.isInfoEnabled()) Log.getLogger().info("count of found elements: " + resultcount); FeatureID activeFeature = ApplicationContext.getBrowser().getActiveFeatureID(); if (activeFeature == null || !activeFeature.equals(relationResult.getFeature().getID())) relationResult.getFeature().setActive(true); ApplicationContext.getBrowser().getMapSelectionCurator().select(selection.toArray(new Object[selection.size()])); }

I hope that helps you.

Best Regards,