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.