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
Regular Contributor
Posts: 248
Registered: ‎05-01-2016

$GP.selectedFeatures.add to select only from one Feature (parcels)

[ Edited ]

I am trying to use $GP.selectedFeatures.add to select only parcel features (from the many different features displayed on my map) based on a line or a polygon that the user draws.

Can you not provide both a geometry type to select by (point, line polygon rectangle) as well as a feature you are interested in selecting?

Do  i need to do redlining instead and get the geometry of what I've drawn and then do a spatial intersection of that geometry with my feature of interest?  I have done this for a point  user enters where i then make a circular bufferzone around it and then do a query with a spatial filter but i don't know how to get the coordinates of the line or polygon that gets drawn.  

My end goal is to list all the selected parcels in the dataview at the bottom of the SDK window.

The SDK already provides a select by point, line, and area but i only want one feature type to be selected and i need to display the selected features in the dataview as records so user can zoom to them or display the properties of each or export to a csv.

 

Staff
Posts: 46
Registered: ‎02-16-2017

Re: $GP.selectedFeatures.add to select only from one Feature (parcels)

Hi, If you know the actual feature class name which is the parcel feature then you can pass the  "featureClassId  : <featureclass name>". to 

select the area features only in the SelectedFeatures.Add. Also once you have the feature object from selected features, may be try the get_Json method to give the feature type on the geojson. would that help?

 

Vishnu

Regular Contributor
Posts: 248
Registered: ‎05-01-2016

Re: $GP.selectedFeatures.add to select only from one Feature (parcels)

my code is:

 

function SelectByLine()
{
$GP.selectedFeatures.add({
type: "LineString"
// featureClassId: "34644522FD66F454EFD7A34AC7AA1F373C41D430|Parcels_with_Labels"
}, function (result) {

var coords = result.feature[0][0].get_geoJSON().geometry.coordinates;
$GP.ui.info(coords[0][0]);
$GP.ui.info(coords[1][0]);
});
}

 

I commented out the featureClassid because if i included the code crashes...i was trying have only parcels be selected.

It is not necessary though that i limit what is selected...if i could just get the coordinates of the line the user draws i would be all set.

 

The code i use to get the first coordinate (see above) of the line is not right   - is it result.feature[0][0] or ????

If i could just get all the x,y coordinates of the linestring i would be able to use these to do just what i want.

I know how to get the coordinates of a point from the geoJSON but is there an example to show how to get them for a LineString (and Polygon)    The linestring would be very simple (generated by a few user clicks) as would be the polygon.

Staff
Posts: 46
Registered: ‎02-16-2017

Re: $GP.selectedFeatures.add to select only from one Feature (parcels)

Hi would you try using the following for the featureClass ID instead

 

featureClassId: "{http://www.intergraph.com/geomedia/gml}Parcels_with_Labels".

 

Assuming Parcels_with_Labels is your feature class from a WFS ? And see if this works?

 

As for the linestring, geojson, you'd get an array of coordinate pairs right? Did you try sdump or  deseialize to see how the coodinates are? that should give you better idea how to get the x,y pairs of linestrings ? If this is to simply to populate the name of the feature classes based on type, then Features.type should give you if its an area or linestring right? And once you add this to dataview based on the type it should handle the Zoom To on its own you dont need to get the coords of individual points?

 

Vishnu

 

Regular Contributor
Posts: 248
Registered: ‎05-01-2016

Re: $GP.selectedFeatures.add to select only from one Feature (parcels)

Thanks - I want to get the coordinates so i can do a query with a spatial filter to get all parcel features that overlay the line or the area.

I will try to figure out the code to extract the coodinates from the geojson which would have all features in it - not just the parcels.

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