<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic   SpatialFilter failing when used with feature service added to TOC in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/spatialfilter-failing-when-used-with-feature/m-p/361943#M2337</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am facing an issue with Feature service&amp;nbsp;which is added to TOC. And now i need to do a spatial query on the feature service but it is throwing an error.Although it works for Iqueryfilter but fails for Ispatialfilter. Below is code snippet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IPoint pPoint = new PointClass();&lt;BR /&gt; pPoint.X = esriPoint.X;&lt;BR /&gt; pPoint.Y = esriPoint.Y;&lt;BR /&gt; pPoint.SpatialReference = cartoMap.SpatialReference;&lt;BR /&gt; var env = pPoint.Envelope.Envelope;&lt;BR /&gt; var mapLayers = gettingalllayersfromTOC(cartoMap); //getting all layer&amp;nbsp;&lt;BR /&gt; var pLayer = mapLayers[14]; // index of feature service added to tOC&lt;BR /&gt; &lt;BR /&gt; List&amp;lt;IFeature&amp;gt; features = new List&amp;lt;IFeature&amp;gt;();&lt;BR /&gt; &lt;BR /&gt; ISpatialFilter spatialFilter = new SpatialFilterClass();&lt;BR /&gt; spatialFilter.Geometry = env;&lt;BR /&gt; spatialFilter.GeometryField = ((IFeatureLayer)pLayer).FeatureClass.ShapeFieldName;&lt;BR /&gt; spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelWithin;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; IFeatureCursor cursor = ((IFeatureLayer)pLayer).FeatureClass.Search(spatialFilter, false);&lt;BR /&gt; IFeature feature = cursor.NextFeature();&lt;BR /&gt; while (feature != null)&lt;BR /&gt; {&lt;BR /&gt; features.Add(feature);&lt;BR /&gt; feature = cursor.NextFeature();&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Error is thrown at "&lt;SPAN&gt;IFeatureCursor cursor = ((IFeatureLayer)pLayer).FeatureClass.Search(spatialFilter, false);"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;{"ERROR: code:400, Cannot perform query. Invalid query parameters., 24305: The Polygon input is not valid because the ring does not have enough distinct points. Each ring of a polygon must contain at least three distinct points., Unable to perform query. Please check your parameters., Bad syntax in request."}&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 31 Oct 2017 16:20:33 GMT</pubDate>
    <dc:creator>DianaVettori</dc:creator>
    <dc:date>2017-10-31T16:20:33Z</dc:date>
    <item>
      <title>SpatialFilter failing when used with feature service added to TOC</title>
      <link>https://community.esri.com/t5/developers-questions/spatialfilter-failing-when-used-with-feature/m-p/361943#M2337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am facing an issue with Feature service&amp;nbsp;which is added to TOC. And now i need to do a spatial query on the feature service but it is throwing an error.Although it works for Iqueryfilter but fails for Ispatialfilter. Below is code snippet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IPoint pPoint = new PointClass();&lt;BR /&gt; pPoint.X = esriPoint.X;&lt;BR /&gt; pPoint.Y = esriPoint.Y;&lt;BR /&gt; pPoint.SpatialReference = cartoMap.SpatialReference;&lt;BR /&gt; var env = pPoint.Envelope.Envelope;&lt;BR /&gt; var mapLayers = gettingalllayersfromTOC(cartoMap); //getting all layer&amp;nbsp;&lt;BR /&gt; var pLayer = mapLayers[14]; // index of feature service added to tOC&lt;BR /&gt; &lt;BR /&gt; List&amp;lt;IFeature&amp;gt; features = new List&amp;lt;IFeature&amp;gt;();&lt;BR /&gt; &lt;BR /&gt; ISpatialFilter spatialFilter = new SpatialFilterClass();&lt;BR /&gt; spatialFilter.Geometry = env;&lt;BR /&gt; spatialFilter.GeometryField = ((IFeatureLayer)pLayer).FeatureClass.ShapeFieldName;&lt;BR /&gt; spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelWithin;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; IFeatureCursor cursor = ((IFeatureLayer)pLayer).FeatureClass.Search(spatialFilter, false);&lt;BR /&gt; IFeature feature = cursor.NextFeature();&lt;BR /&gt; while (feature != null)&lt;BR /&gt; {&lt;BR /&gt; features.Add(feature);&lt;BR /&gt; feature = cursor.NextFeature();&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Error is thrown at "&lt;SPAN&gt;IFeatureCursor cursor = ((IFeatureLayer)pLayer).FeatureClass.Search(spatialFilter, false);"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;{"ERROR: code:400, Cannot perform query. Invalid query parameters., 24305: The Polygon input is not valid because the ring does not have enough distinct points. Each ring of a polygon must contain at least three distinct points., Unable to perform query. Please check your parameters., Bad syntax in request."}&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Oct 2017 16:20:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/spatialfilter-failing-when-used-with-feature/m-p/361943#M2337</guid>
      <dc:creator>DianaVettori</dc:creator>
      <dc:date>2017-10-31T16:20:33Z</dc:date>
    </item>
  </channel>
</rss>

