Select to view content in your preferred language

About Feature layer geometry and query task

2719
4
01-24-2011 11:37 PM
MarcoRosa
Emerging Contributor
Hi,
i have this situation: i have 1 polygon selected on feature layer and query task

....
Query query = new ESRI.ArcGIS.Client.Tasks.Query();
FeatureLayer f = _Map.Layers[myLayerName] as FeatureLayer;
_currGeometry = f.Graphics[0].Geometry;
query.Geometry = _currGeometry;
....

this is ok and work fine if i have just one feature selected.

But if i have for example 2 feature selected , f.Graphics.Count is correctly = 2 , but how i can pass a geometry made with both the object selected ?

_currGeometry should be contais 2 objects instead of one.

is there any way to do this ?

thank u very much as usual.
GP
0 Kudos
4 Replies
JenniferNery
Esri Regular Contributor
You can create an Envelope geometry that Unions the two selected graphic's extent http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Geometry.E....
0 Kudos
MarcoRosa
Emerging Contributor
Hi jennifer, if i have understood it would be something like this:
For example 2 objects selected;

Envelope env0 = f.Graphics[0].Geometry.Extent;
Envelope env1 = f.Graphics[1].Geometry.Extent;

Envelope result = env0.Union(env1);
query.Geometry = result;

.. Teorically all looks like good, i don't have any errors but no objects are never selected.

Other of this .... it's necessary now to return from envelope to geometry of union of original geometries, because i'm doing a spatial query between the geometry and some points. Can happen that , for example ,some point are inside envelope but outside geometry .. and that's wrong.

There's no way to create a geometry as union of other 2 geometries ?

It' right what i'm doing ?

thanks and best regards

GP
0 Kudos
DominiqueBroux
Esri Frequent Contributor
There's no way to create a geometry as union of other 2 geometries ?

With WPF, you can use the Geometry.Combine method. But this one is not available with Silverlight.

With Silverlight you can use the .Net Geometry API to make the union by yourself but it's not that easy (basically if it's a PathGeometry, you have to get the collection of PathFigures, to get the segments inside the PathFigure and to clone them in order to add them to the first geometry.

Another option is you to execute two spatial queries (one by geometry) but for sure there is an impact on performances.

Hope this help.
0 Kudos
MarcoRosa
Emerging Contributor
Thank's Dominique, i'll support at the moment the selection of just only one object.
See u 🙂
0 Kudos