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: 253
Registered: ‎05-01-2016
Accepted Solution

Issues related to bufferzone queries

[ Edited ]

Thanks for all the help so far...making progress...

I'm able to draw a circle at a user clicked point, find all instances of a feature that intersect with the circle and display them in a custom color with tooltip pins and the datawindow for the displayed query. 

 

1) The circle is drawn with $GP.map.draw as a polygon using the 3 points of geometry shortcut.  Is there anyway to enable  the pins that have been placed and fall within the circle to highlight?  My only solution has been to draw the circle as a line string rather than as a polygon.

 

2)Is there any way to delete a query created with $GP.queries.add ?   Everytime i create a query i have to give it a new name because the query with the old name already exists. I would like instead to overwrite an existing query so there is always just one query. 

 

3) I am unclear on what data.data[0] is referring to below.  I find that the pins don't change when i rerun my code with a new query name. New features are selected and highlighted but the pins don't change.

 

 $GP.queries.find({
analysisId: result.analysisId,
}, function (result2) {
result2.analysis.getData(function (data) {
console.log(data);
renderPins(data.data[0]);
result2.analysis.addToDataView();
});

 

Thanks very much,

Jane

Highlighted
Regular Contributor
Posts: 253
Registered: ‎05-01-2016

Re: Issues related to bufferzone queries

I noticed that hotspots don't work either on features that are covered by the bufferzone circle.  Now i am numbering the plants with ID #'s and displaying the attribute information in other window so no need for the hotspots.  I am also appending a time stamp to the query name so i can create the bufferzone queries over and over and each one has a new name - i delete the latest from the legend via code before displaying the new one.

Highlighted
Technical Evangelist
Posts: 1,307
Registered: ‎09-11-2015

Re: Issues related to bufferzone queries

Hi Jane,

 

I will try to answer your first questions:

1) The circle is not a valid GeoJSON and is only understood by Portal. That means if you require to use a circle as spatial filter for some analysis you will have to use a polygon. Building octagons and similar shapes might be tricky, but I think that a workaround could be using two rectangles - one horizontal, second rotated to 90° - and use OR operator to join them together in a query.

 

2) Yes, use this code:

$GP.queries.find({
   analysisId: "knownAnalysisId",
}, function (result2) {
   result2.analysis.remove(function(callback)
      {
         // analysis removed callback
      }
   );
});

3) I don't know which sample code are you referring to. But if you need to redraw pins on different locations, you should use  $GP.map.pin.clear({}). You should use browser developer tools to traverse the data object.

 

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Highlighted
Regular Contributor
Posts: 253
Registered: ‎05-01-2016

Re: Issues related to bufferzone queries

Thank you very much!  The result2.analysis.remove(function(callback) is just what i needed.

Regarding the circle, even if i make the circle by calculating the points using sin and cos i get a slightly raggedy looking circle but the drawn circle still obscures being able to click on the pins falling within the circle - they don't change color when hovered over.  The pins outside the circle work fine.  If i place the points as a line instead of a polygon then the pins work but i can't shade in the circle.

 

The example i used to figure out the pins is the 05. Pin Layer Fancy Tooltips  - my query updates but the tooltips even when cleared first redisplay in the same positions.  I will work on this more now that I can remove my queries.  I'm not currently using the tooltips  since they become obscured by the filled in circle.

 

I have a fully working cicular bufferzone query  and very impressed with GeoSpatial Portal capabilities!