<?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 QueryTask, Query and Spatial References in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/querytask-query-and-spatial-references/m-p/363587#M33742</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I noticed that after upgrading from version 3.2 to 3.3 a query task that I was running began to fail. I originally thought it was related to a different problem that I was working on: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/78905-GeometryServic-Buffer-Task-amp-Access-Control-Allow-Origin" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.arcgis.com/threads/78905-GeometryServic-Buffer-Task-amp-Access-Control-Allow-Origin&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;... however that was not true. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My query takes a buffer's geometry whose spatial reference is in web mercator, however my source data is in the geographic coordinate system. At version 3.2 the query task completed without any issues, but at 3.3 it seems that if you don't specify an 'outSpatialReference' on the Query object *and* the Query's geometry's spatial reference does not match the source data's spatial reference the query task will fail silently. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, before upgrading to 3.3 I could do this, and the query task would not fail.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
query.geometry = buffer.geometry;
queryTask.execute(query, taskCompleted, taskFailed);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; and after upgrading to 3.3, I needed to do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
query.geometry = buffer.geometry;
query.outSpatialReference = buffer.geometry.spatialReference;
queryTask.execute(query, taskCompleted, taskFailed);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is this a known issue? The docs for the Query object just say that the output will take the spatial reference of the map, if not otherwise specified:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/#Query" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/#Query&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The docs also mention that outSpatialReference is optional:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"Optional properties include outFields, outSpatialReference, and returnGeometry."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why does the query task fail if the source data being queried is geographic, but the query contains a web mercator projected polygon, and if you do not strictly specify an output spatial reference?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- Aaron&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 16:56:48 GMT</pubDate>
    <dc:creator>AaronConnolly</dc:creator>
    <dc:date>2021-12-11T16:56:48Z</dc:date>
    <item>
      <title>QueryTask, Query and Spatial References</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/querytask-query-and-spatial-references/m-p/363587#M33742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I noticed that after upgrading from version 3.2 to 3.3 a query task that I was running began to fail. I originally thought it was related to a different problem that I was working on: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/78905-GeometryServic-Buffer-Task-amp-Access-Control-Allow-Origin" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.arcgis.com/threads/78905-GeometryServic-Buffer-Task-amp-Access-Control-Allow-Origin&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;... however that was not true. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My query takes a buffer's geometry whose spatial reference is in web mercator, however my source data is in the geographic coordinate system. At version 3.2 the query task completed without any issues, but at 3.3 it seems that if you don't specify an 'outSpatialReference' on the Query object *and* the Query's geometry's spatial reference does not match the source data's spatial reference the query task will fail silently. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, before upgrading to 3.3 I could do this, and the query task would not fail.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
query.geometry = buffer.geometry;
queryTask.execute(query, taskCompleted, taskFailed);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; and after upgrading to 3.3, I needed to do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
query.geometry = buffer.geometry;
query.outSpatialReference = buffer.geometry.spatialReference;
queryTask.execute(query, taskCompleted, taskFailed);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is this a known issue? The docs for the Query object just say that the output will take the spatial reference of the map, if not otherwise specified:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/#Query" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/#Query&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The docs also mention that outSpatialReference is optional:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"Optional properties include outFields, outSpatialReference, and returnGeometry."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why does the query task fail if the source data being queried is geographic, but the query contains a web mercator projected polygon, and if you do not strictly specify an output spatial reference?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- Aaron&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:56:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/querytask-query-and-spatial-references/m-p/363587#M33742</guid>
      <dc:creator>AaronConnolly</dc:creator>
      <dc:date>2021-12-11T16:56:48Z</dc:date>
    </item>
  </channel>
</rss>

