Select to view content in your preferred language

FeatureLayer and SpatialRelationship for selection geometry

1988
2
07-21-2010 03:33 AM
AxelSchaefer
Emerging Contributor
Hi.

I'm trying to select features from a FeatureLayer with a filter-geometry.

I have a FeatureLayer (named: resultLayer) with featues and a geometry as a filter-geometry (named: filterGeometry, a polygon).

I set the attribute geometry in the FeatureLayer with the filterGeometry. After that I call the update method of the layer. The results shows the features which intersect the filter-polygon from the filterLayer.

You can see in Firebug that a query is generated with that Intersetcs relationship.

Question: I have to use a contains relationsship. How can I define that for a FeatureLayer? The API doesn't show an attribute for a FeatureLayer to define the spatial relationship. It only says in the description of the geometry attribute (http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.FeatureLay...

Geometry: The geometry to apply to the spatial filter. The spatial relationship as specified by spatialRelationship is applied to this geometry while performing the query. The valid geometry types are Envelope, Point, Multipoint, Polyline, or Polygon.


So if I code:

resultLayer.Geometry = filterGeometry;
oResultLayer.Update();


It sets the filterGeometry and updates the resultLayer but filters all that are intersecting the filterGeometry.

How to set another filter?

Somethig like this doesn't exist:
oResultLayer.SpatialRelationship = SpatialRelationship.esriSpatialRelContains


  • Is this missing in the FeatureLayer class?

  • Can I use contains relationships for filtering FeatureLayers?

  • Am I using a wrong way for updating my FeatureLayer?


Thanks in advance and best regards,
Axel
0 Kudos
2 Replies
dotMorten_esri
Esri Notable Contributor
Setting relationship is not supported for FeatureLayer. If you require this, I suggest you use the QueryTask together with the GraphicsLayer.
0 Kudos
AxelSchaefer
Emerging Contributor
Thanks for your reply, Morten.

We switch to the Query and Graphics now, although the FeatureLayer made the logic in our app a bit easier. We are doing selections of external given points by polygon geometries. Perhaps it's a good enhancement to include the missing relationsships, because it seems that they are only forwarded to a query.

Well, Graphics and Queries will do right now.

Thanks and best regards,
Axel
0 Kudos