<?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: Query Features for featurelayer returns wrong Y coordinate in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-features-for-featurelayer-returns-wrong-y/m-p/1128274#M75658</link>
    <description>&lt;P&gt;Hello Dvir&lt;/P&gt;&lt;P&gt;You can use an interceptor. Essentially what it does is, that whenever your code executes a query, it replaces 'f=pbf' to 'f=json' in the url of any query, such that all queries use json instead of pbf.&amp;nbsp;&lt;/P&gt;&lt;P&gt;To achieve this I have used this piece of code in my application:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import esriConfig from "@arcgis/core/config";

esriConfig.request.interceptors?.push({
   before(params) {
     if (params.url.includes("query")) {
       params.requestOptions.query.f = 'json';
     }
   }
});
 &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using Angular as my webapplication front-end framework. So the code in the listing above, I've put that into the constructor of my app.component. If you're not using Angular, just make sure to put somewhere, such that it gets executed at start-up of your application.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Ruben&lt;/P&gt;</description>
    <pubDate>Wed, 22 Dec 2021 10:47:30 GMT</pubDate>
    <dc:creator>RubenMensink</dc:creator>
    <dc:date>2021-12-22T10:47:30Z</dc:date>
    <item>
      <title>Query Features for featurelayer returns wrong Y coordinate</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-features-for-featurelayer-returns-wrong-y/m-p/1122441#M75469</link>
      <description>&lt;P&gt;Hello everyone&lt;/P&gt;&lt;P&gt;The function &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/featurelayer-query-basic/" target="_self"&gt;queryFeatures()&lt;/A&gt; for the class FeatureLayer returns the wrong geometry, specifically the Y coordinate.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running ArcGIS Javascript Api 4.21 and I am sending my query to an on-prem ArcGIS Server running version 10.8.1.&lt;/P&gt;&lt;P&gt;My query is the following&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;public query(): void {
    let pr_t = this.baseUrl+"/FeatureServer/25";

    let layer = new FeatureLayer({
      url: pr_t,
      spatialReference: {wkid: 28992},
      hasZ: true,
      hasM: true,
      geometryType: "point",
    });

    let query = layer.createQuery();
    query.where = ""; // Return all features
    query.returnZ = true;
    query.returnM = true;
    query.returnGeometry = true;

    layer.queryFeatures(query).then(res =&amp;gt; {
      console.log("Attributes: ");
      console.log(res.features[0].attributes);
      console.log("Geometry: ");
      console.log(res.features[0].geometry);
    });
  };&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result of this query is the following:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Geometry: 
p {__accessor__: g, initialize: ƒ, destroy: ƒ}
destroy: ƒ value()
initialize: ƒ value()
__accessor__: g {host: p, properties: Map(12), ctorArgs: null, destroyed: false, lifecycle: 2, …}
cache: (...)
extent: (...)
hasM: (...)
hasZ: (...)
latitude: (...)
longitude: (...)
m: (...)
spatialReference: (...)
type: (...)
x: 116004.48999999464
y: -67192480.85930108
z: 0.5829999999987194
constructed: (...)
destroyed: (...)
initialized: (...)
[[Prototype]]: m&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The X and Z coordinates are correct, whereas the Y coordinate is not. The expected Y coordinate is&amp;nbsp;&lt;SPAN&gt;494602.43599999.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The extent of the feature server for this feature is the following:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markdown"&gt;Extent:
XMin: 30316.35599999875
YMin: 305022.16099999845
XMax: 285730.71599999815
YMax: 608180.932
Spatial Reference: 28992  (28992)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I query this exact same feature with the ArcGIS rest interface I get the following result (various attributes are omitted):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"attributes": {
    "OBJECTID": 1,
   },
   "geometry": {
    "x": 116004.48999999836,
    "y": 494602.43600000069,
    "z": 0.58299999999871943
   }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which is the correct result.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have afterwards manually inserted geometries with various Y coordinates. If insert a Y coordinate greater than 410000, then I get a negative value similar to&amp;nbsp;&lt;SPAN&gt;-67192480.85930108. It seems that when the Y coordinate gets larger than 410000 a 1-1 mapping occurs, producing a negative value.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The function that 'gets' my correct Y coordinate is the following:&amp;nbsp;&amp;nbsp;- x – 66697878.423301&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Inserting the incorrect Y coordinate (-67192480.85930108), into the equation, produces this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;494602.43599999 =&amp;nbsp;-&amp;nbsp;(-67192480.85930108) – 66697878.423301&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have not been able to reproduce the negative numbers for X and Z value coordinates, only Y coordinates.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I do not know a lot about GIS, therefore I assume something is wrong in the configuration of the FeatureLayer or perhaps the Extent of the ArcGIS Server is incorrect. I certainly do not know, but I hope someone in this community does.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 08:14:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-features-for-featurelayer-returns-wrong-y/m-p/1122441#M75469</guid>
      <dc:creator>RubenMensink</dc:creator>
      <dc:date>2021-12-03T08:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: Query Features for featurelayer returns wrong Y coordinate</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-features-for-featurelayer-returns-wrong-y/m-p/1122488#M75470</link>
      <description>&lt;P&gt;I have spoken to a colleague of mine, and he mentioned that PBF has only recently been introduced, and that queryFeatures() uses that instead of json.&lt;/P&gt;&lt;P&gt;My colleague suggested I use an &lt;A href="https://community.esri.com/t5/arcgis-api-for-javascript-questions/properly-change-the-format-of-queries/td-p/181646" target="_self"&gt;interceptor&lt;/A&gt; to force all queries to use json format, instead of PBF. With this I get correct queries. However, this still means that there is a bug with PBF, most likely an overflow of some kind, since there exists a 1-1 mapping.&lt;/P&gt;&lt;P&gt;Does anyone know where to submit such a bug report?&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 13:30:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-features-for-featurelayer-returns-wrong-y/m-p/1122488#M75470</guid>
      <dc:creator>RubenMensink</dc:creator>
      <dc:date>2021-12-03T13:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: Query Features for featurelayer returns wrong Y coordinate</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-features-for-featurelayer-returns-wrong-y/m-p/1128264#M75656</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Same issue here.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ArcGIS&amp;nbsp;&lt;/SPAN&gt;10.9.1 Enterprise&lt;/P&gt;&lt;P&gt;PBF return n&lt;SPAN&gt;egative numbers for Y.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Json return fine.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The problem is how can I set default to use JSON instead PBF?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Or how can I control queryFeatures method to change the format?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Br,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Dvir.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Dec 2021 09:42:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-features-for-featurelayer-returns-wrong-y/m-p/1128264#M75656</guid>
      <dc:creator>Dvirus</dc:creator>
      <dc:date>2021-12-22T09:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: Query Features for featurelayer returns wrong Y coordinate</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-features-for-featurelayer-returns-wrong-y/m-p/1128274#M75658</link>
      <description>&lt;P&gt;Hello Dvir&lt;/P&gt;&lt;P&gt;You can use an interceptor. Essentially what it does is, that whenever your code executes a query, it replaces 'f=pbf' to 'f=json' in the url of any query, such that all queries use json instead of pbf.&amp;nbsp;&lt;/P&gt;&lt;P&gt;To achieve this I have used this piece of code in my application:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import esriConfig from "@arcgis/core/config";

esriConfig.request.interceptors?.push({
   before(params) {
     if (params.url.includes("query")) {
       params.requestOptions.query.f = 'json';
     }
   }
});
 &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using Angular as my webapplication front-end framework. So the code in the listing above, I've put that into the constructor of my app.component. If you're not using Angular, just make sure to put somewhere, such that it gets executed at start-up of your application.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Ruben&lt;/P&gt;</description>
      <pubDate>Wed, 22 Dec 2021 10:47:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-features-for-featurelayer-returns-wrong-y/m-p/1128274#M75658</guid>
      <dc:creator>RubenMensink</dc:creator>
      <dc:date>2021-12-22T10:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: Query Features for featurelayer returns wrong Y coordinate</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-features-for-featurelayer-returns-wrong-y/m-p/1163367#M76988</link>
      <description>&lt;P&gt;try&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;query.outSpatialReference = { wkid: 4326 }&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 12 Apr 2022 07:55:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-features-for-featurelayer-returns-wrong-y/m-p/1163367#M76988</guid>
      <dc:creator>YYC</dc:creator>
      <dc:date>2022-04-12T07:55:39Z</dc:date>
    </item>
  </channel>
</rss>

