Query Features for featurelayer returns wrong Y coordinate

1084
4
Jump to solution
12-03-2021 12:14 AM
RubenMensink
New Contributor II

Hello everyone

The function queryFeatures() for the class FeatureLayer returns the wrong geometry, specifically the Y coordinate. 

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.

My query is the following

 

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 => {
      console.log("Attributes: ");
      console.log(res.features[0].attributes);
      console.log("Geometry: ");
      console.log(res.features[0].geometry);
    });
  };

 

The result of this query is the following: 

 

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

 

 

The X and Z coordinates are correct, whereas the Y coordinate is not. The expected Y coordinate is 494602.43599999.

The extent of the feature server for this feature is the following:

 

Extent:
XMin: 30316.35599999875
YMin: 305022.16099999845
XMax: 285730.71599999815
YMax: 608180.932
Spatial Reference: 28992  (28992)

 

 

If I query this exact same feature with the ArcGIS rest interface I get the following result (various attributes are omitted):

 

"attributes": {
    "OBJECTID": 1,
   },
   "geometry": {
    "x": 116004.48999999836,
    "y": 494602.43600000069,
    "z": 0.58299999999871943
   }

 

which is the correct result. 

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 -67192480.85930108. It seems that when the Y coordinate gets larger than 410000 a 1-1 mapping occurs, producing a negative value. 

The function that 'gets' my correct Y coordinate is the following:  - x – 66697878.423301

Inserting the incorrect Y coordinate (-67192480.85930108), into the equation, produces this:

494602.43599999 = - (-67192480.85930108) – 66697878.423301

I have not been able to reproduce the negative numbers for X and Z value coordinates, only Y coordinates. 

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.

Thank you.

0 Kudos
1 Solution

Accepted Solutions
RubenMensink
New Contributor II

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.

My colleague suggested I use an interceptor 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.

Does anyone know where to submit such a bug report?

View solution in original post

0 Kudos
4 Replies
RubenMensink
New Contributor II

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.

My colleague suggested I use an interceptor 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.

Does anyone know where to submit such a bug report?

0 Kudos
Dvirus
by
New Contributor III

Hi, 

Same issue here.

ArcGIS 10.9.1 Enterprise

PBF return negative numbers for Y.

Json return fine.

The problem is how can I set default to use JSON instead PBF?

Or how can I control queryFeatures method to change the format?

 

Br,

Dvir. 

0 Kudos
RubenMensink
New Contributor II

Hello Dvir

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. 

To achieve this I have used this piece of code in my application:

 

import esriConfig from "@arcgis/core/config";

esriConfig.request.interceptors?.push({
   before(params) {
     if (params.url.includes("query")) {
       params.requestOptions.query.f = 'json';
     }
   }
});
 

 

 

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. 

Hope this helps.

 

Best regards,

Ruben

0 Kudos
YYC
by
New Contributor

try 

query.outSpatialReference = { wkid: 4326 }

 
0 Kudos