<?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 Re: Find intersecting features in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/find-intersecting-features/m-p/1282476#M80957</link>
    <description>&lt;P&gt;Another option would be to let the service perform the intersection test by passing in the dynamic feature geometry into the query; something similar to this but with all the appropriate Query parameters:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;const staticQuery = staticFeatureLayer.createQuery();
staticQuery.geometry = dfFeature.geometry;
staticFeatureLayer.queryFeatures(staticQuery).then((staticFeatureSet) =&amp;gt; {&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 25 Apr 2023 18:28:22 GMT</pubDate>
    <dc:creator>JohnGrayson</dc:creator>
    <dc:date>2023-04-25T18:28:22Z</dc:date>
    <item>
      <title>Find intersecting features</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/find-intersecting-features/m-p/1282191#M80949</link>
      <description>&lt;P&gt;I have a scenario where there are multiple FeatureLayers with static features lets call them F1,F2,F3, and F4.&lt;/P&gt;&lt;P&gt;I also have a FeatureLayer called DF that has dynamic features (because the user goes out and makes changes depending on landscape).&lt;/P&gt;&lt;P&gt;I am trying to figure out if it is possible to compare all features in DF against all features in F1,F2,F3, and F4 and return set of intersecting features or geometries.&lt;/P&gt;&lt;P&gt;Idea is then to create a FeatureLayer with these intersecting points so that the user can see all the intersecting points.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advice as to how to approach this?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 04:55:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/find-intersecting-features/m-p/1282191#M80949</guid>
      <dc:creator>Aeseir</dc:creator>
      <dc:date>2023-04-25T04:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Find intersecting features</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/find-intersecting-features/m-p/1282284#M80953</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/546199"&gt;@Aeseir&lt;/a&gt;, This should be possible with a combination of queries and &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#intersects" target="_self"&gt;geometryEngine.intersects()&lt;/A&gt;.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Use the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#queryFeatures" target="_self"&gt;queryFeatures()&lt;/A&gt; method of the Dynamic FeatureLayer (DF) to retrieve all the features. This method returns a &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-FeatureSet.html" target="_self"&gt;FeatureSet&lt;/A&gt; object.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;For each of the static FeatureLayers (F1, F2, F3, and F4), use the queryFeatures() method to retrieve all the features.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Iterate through each feature in the FeatureSet of the Dynamic FeatureLayer (DF), and for each feature, loop through all the features in the FeatureSets of the static FeatureLayers (F1, F2, F3, and F4).&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;For each pair of features (one from DF and one from a static FeatureLayer), use the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#intersects" target="_self"&gt;intersects()&lt;/A&gt; method in the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html" target="_self"&gt;geometryEngine&lt;/A&gt;&amp;nbsp; or &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html" target="_self"&gt;geometryEngineAsync&lt;/A&gt; or&amp;nbsp; to determine if they intersect. If they do intersect, add the intersecting feature or geometry to a new array of intersecting features.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Add the intersecting features to a new FeatureLayer as the source property.&amp;nbsp; There is a sample here on creating a feature layer with client-side graphics:&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/layers-featurelayer-collection/" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/sample-code/layers-featurelayer-collection/&lt;/A&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe something like this at a really high level, there may be typos below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const intersectingFeatures = [];

df.queryFeatures().then((dfFeatureSet) =&amp;gt; {
    
    // Loop through each feature in the Dynamic FeatureLayer (DF)
    dfFeatureSet.features.forEach((dfFeature) =&amp;gt; {
      
      // Loop through all features in the static FeatureLayers (F1, F2, F3, and F4)
      [f1, f2, f3, f4].forEach((staticFeatureLayer) =&amp;gt; {
        
        // Query all features from the static FeatureLayer
        staticFeatureLayer.queryFeatures().then((staticFeatureSet) =&amp;gt; {
          
          // Loop through all features in the static FeatureLayer
          staticFeatureSet.features.forEach((staticFeature) =&amp;gt; {
            
            // Determine if the features intersect
            if (geometryEngine.intersects(dfFeature.geometry, staticFeature.geometry)) {
              
              // Add intersecting feature or geometry to an array of intersecting features
              intersectingFeatures.push(new Graphic({
                 geometry: dfFeature.geometry,
                 // additional graphic properties
               }));
              
            }
          });
        });
      });
    });
  // Add the intersecting features to the map as a new feature layer
  const newFeatureLayer = new FeatureLayer({
    source: intersectingFeatures,
    // additional properties
  });
});
 &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 14:02:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/find-intersecting-features/m-p/1282284#M80953</guid>
      <dc:creator>Sage_Wall</dc:creator>
      <dc:date>2023-04-25T14:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Find intersecting features</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/find-intersecting-features/m-p/1282476#M80957</link>
      <description>&lt;P&gt;Another option would be to let the service perform the intersection test by passing in the dynamic feature geometry into the query; something similar to this but with all the appropriate Query parameters:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;const staticQuery = staticFeatureLayer.createQuery();
staticQuery.geometry = dfFeature.geometry;
staticFeatureLayer.queryFeatures(staticQuery).then((staticFeatureSet) =&amp;gt; {&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 18:28:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/find-intersecting-features/m-p/1282476#M80957</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2023-04-25T18:28:22Z</dc:date>
    </item>
  </channel>
</rss>

