<?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: Subqueries using Features/Polygons in ArcGIS JS in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/subqueries-using-features-polygons-in-arcgis-js/m-p/601016#M56223</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you get the expected results from your first query? &amp;nbsp;Thats where I would start.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I put up a fiddle of how I do nested queries here:&amp;nbsp;&lt;A class="link-titled" href="https://jsfiddle.net/afarrar3/akbo6v21/" title="https://jsfiddle.net/afarrar3/akbo6v21/"&gt;JS_Search - JSFiddle&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(note that the services don't work, since JSFiddle requires &lt;A href="https://,"&gt;https://,&lt;/A&gt;&amp;nbsp;but I promise the app works normally.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The fiddle searches for attributes using a findTask, then grabs the geometry from the results and uses that to perform a spatial search for polygon attributes. &amp;nbsp;not exactly what you are trying to do, but similar.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 13 Feb 2017 16:04:42 GMT</pubDate>
    <dc:creator>AndrewFarrar</dc:creator>
    <dc:date>2017-02-13T16:04:42Z</dc:date>
    <item>
      <title>Subqueries using Features/Polygons in ArcGIS JS</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/subqueries-using-features-polygons-in-arcgis-js/m-p/601015#M56222</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Essentially, I'm trying to perform a second spatial query on a set of returned results from a previous query. The source runs, but it doesn't return any results for &lt;STRONG&gt;floodCalcs.business &lt;/STRONG&gt;in the second for-loop. I do not get any errors from this and I do check to make sure that polygons have been loaded into&amp;nbsp;&lt;STRONG&gt;polygons&lt;/STRONG&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just realized I don;t know how to insert formatted code in here. Help?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;queryShapes = function () {&lt;BR /&gt; for (var v = 0; v &amp;lt; shapes.length; v++) {&lt;BR /&gt; &lt;BR /&gt; query = new Query(); &lt;BR /&gt; select = shapes&lt;V&gt;;&lt;BR /&gt; query.geometry = shapes&lt;V&gt;.getExtent();&lt;BR /&gt; query.returnGeometry = true;&lt;BR /&gt; &lt;BR /&gt; businessLayer.queryFeatures(query, selectBusiness);&lt;BR /&gt; //featureLayer.queryFeatures(query, selectInBuffer);&lt;/V&gt;&lt;/V&gt;&lt;/P&gt;&lt;P&gt;//perform query on business layer using user drawn shape's bounding box (extent)&lt;BR /&gt; function selectBusiness(response) {&lt;BR /&gt; var feature;&lt;BR /&gt; var features = response.features;&lt;BR /&gt; var floodFeatures = [];&lt;BR /&gt; var floodFeature;&lt;BR /&gt; var inBuffer = [];&lt;BR /&gt; var floodBuffer = [];&lt;/P&gt;&lt;P&gt;var q = new Query();&lt;BR /&gt; q.geometry = shapes&lt;V&gt;.getExtent();&lt;BR /&gt; q.where = "1=1";&lt;BR /&gt; q.outSpatialReference = map.spatialReference;&lt;BR /&gt; q.outFields = ["*"];&lt;BR /&gt; q.returnGeometry = true;&lt;BR /&gt;&lt;SPAN&gt; var qTask = new QueryTask("url");&lt;/SPAN&gt;&lt;BR /&gt; qTask.execute(q);&lt;BR /&gt; qTask.on("complete", queryBlock);&lt;BR /&gt; //query flood layer using user drawn shapes and cast the returned features as polygons&lt;BR /&gt; function queryBlock(f) { &lt;BR /&gt; for (var i = 0; i &amp;lt; f.featureSet.features.length; i++) {&lt;BR /&gt; polygons.push(new Polygon({ "rings": f.featureSet.features&lt;I&gt;.geometry.rings, "spatialReference": f.featureSet.features&lt;I&gt;.geometry.spatialReference }));&lt;BR /&gt; } &lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; //filter out features that are not actually in buffer, since we got all points in the buffer's bounding box&lt;BR /&gt; for (var c = 0; c &amp;lt; features.length; c++) {&lt;BR /&gt; feature = features&lt;C&gt;;&lt;BR /&gt; if (shapes&lt;V&gt;.contains(feature.geometry)) {&lt;BR /&gt; inBuffer.push(feature.attributes[businessLayer.objectIdField]);&lt;BR /&gt; }&lt;BR /&gt; //use flood polygons that were returned in queryBlock function to find points in flood zones&lt;BR /&gt; for (var b = 0; b &amp;lt; polygons.length; b++) {&lt;BR /&gt; var poly = polygons&lt;B&gt;;&lt;BR /&gt; if (poly.contains(feature.geometry)) {&lt;BR /&gt; floodCalcs.businessF += 1;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;/B&gt;&lt;/V&gt;&lt;/C&gt;&lt;/I&gt;&lt;/I&gt;&lt;/V&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var subQuery = new Query();&lt;BR /&gt; subQuery.objectIds = inBuffer;&lt;BR /&gt; //use a fast objectIds selection query (should not need to go to the server)&lt;BR /&gt; featureLayer.selectFeatures(subQuery, FeatureLayer.SELECTION_NEW, function (results) {&lt;BR /&gt; floodCalcs.business += sumPopulation(results); &lt;BR /&gt; });&lt;BR /&gt; &lt;BR /&gt; }&lt;BR /&gt; function sumPopulation(features) {&lt;BR /&gt; var popTotal = 0;&lt;BR /&gt; popTotal = features.length;&lt;BR /&gt; return popTotal;&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; }&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Feb 2017 05:08:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/subqueries-using-features-polygons-in-arcgis-js/m-p/601015#M56222</guid>
      <dc:creator>NickRobles2</dc:creator>
      <dc:date>2017-02-13T05:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: Subqueries using Features/Polygons in ArcGIS JS</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/subqueries-using-features-polygons-in-arcgis-js/m-p/601016#M56223</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you get the expected results from your first query? &amp;nbsp;Thats where I would start.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I put up a fiddle of how I do nested queries here:&amp;nbsp;&lt;A class="link-titled" href="https://jsfiddle.net/afarrar3/akbo6v21/" title="https://jsfiddle.net/afarrar3/akbo6v21/"&gt;JS_Search - JSFiddle&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(note that the services don't work, since JSFiddle requires &lt;A href="https://,"&gt;https://,&lt;/A&gt;&amp;nbsp;but I promise the app works normally.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The fiddle searches for attributes using a findTask, then grabs the geometry from the results and uses that to perform a spatial search for polygon attributes. &amp;nbsp;not exactly what you are trying to do, but similar.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Feb 2017 16:04:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/subqueries-using-features-polygons-in-arcgis-js/m-p/601016#M56223</guid>
      <dc:creator>AndrewFarrar</dc:creator>
      <dc:date>2017-02-13T16:04:42Z</dc:date>
    </item>
    <item>
      <title>Re: Subqueries using Features/Polygons in ArcGIS JS</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/subqueries-using-features-polygons-in-arcgis-js/m-p/601017#M56224</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;I actually figured it out. I simply did a simple logical statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;if (select.contains(feature.geometry) &amp;amp;&amp;amp; polygon.contains(feature.geometry)) {&lt;BR /&gt; floodCalcs.businessF += 1;&lt;BR /&gt; }&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My only issue now is totally different. Is there a way to convert a feature layer (of polygons) to an array of polygons?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Feb 2017 19:39:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/subqueries-using-features-polygons-in-arcgis-js/m-p/601017#M56224</guid>
      <dc:creator>NickRobles2</dc:creator>
      <dc:date>2017-02-13T19:39:50Z</dc:date>
    </item>
  </channel>
</rss>

