Hexagon Geospatial
MENU

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 
Reply
New Contributor
Posts: 2
Registered: ‎05-22-2018

Get user selection for MapSelectionTools

Hi, 

 

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.

 

mapSelectionTools.PNG

 

 

I did not found a listener for the MapSelectionTools. 

 

 

	private MapSelectionTools mapSelectionTools;
	
	public void GetUserSelection() {
		mapSelectionTools = new MapSelectionTools();
		mapSelectionTools.setQuickPickMode(true);
		mapSelectionTools.MAPSELECTPOINT(null);    	
  	}
	

 

How can I get the feature name selected by user ?

 

Thank you,

 

Romain

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

 

@Override
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)
spatialAnalysis.relateWithFeatures(Utils.asModifyableList(ApplicationContext.getBrowser().getActiveFeature()));
}

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

Steve

Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.