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
Highlighted
Regular Contributor
Posts: 186
Registered: ‎11-17-2015

GMSC/MAE : Double clic on feature to run feature attribute workflow

Hello,

 

Our goal is to double clic on a feature and run the feature attribute workflow (similar to display feature attributes in GeoMedia).

We know how to catch the double clic event (and get the X and Y coordinates) but then we are stuck with the API.

We tried to use the SpatialAnalysis as bellow:

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

We faced those problems:

  • This class is waiting for a user action whereas we already have the X and Y coordinates of the click
  • Listerner is waiting for the user to draw a rectangle on the map, not a point
  • When the rectangle is drawn, the Shape of the selectionShapeCaptured method is filled but then the relationResults of spatialAnalyseFinished is empty (those two methods belong to the SpatialAnalysisListener)

Does anyone know how to get the first feature of the first visible and activable layer under the mouse click, given X and Y coordinates?

 

Thank you.

 

 

Highlighted
Technical Evangelist
Posts: 12
Registered: ‎01-09-2019

Re: GMSC/MAE : Double clic on feature to run feature attribute workflow

Hello,

 

unfortunately the API does not support the retrieval of features given the X, Y coordinates.

 

As you already mentioned, you could use the SpatialAnalysis to achieve your goal. In order to see the relationResults inside the spatialAnalyseFinished method, the following needs to be done:

 

  1. inside the selectionShapeCaptured method you have to call the spatialAnalysis.relateWithFeatures method 
  2. the method spatialAnalysis.relateWithFeatures receives as parameter the features you are interested in e.g. all visible features (which you can get with ApplicationContext.getProject().getVisibleFeatures())

SelectionMode.Point is the right selection mode to use. The selectionShapeCaptured method will be called already after one click, as the SpatialAnalysis can not be configured to react only on double clicks.

 

Best regards,

Andreea