I have an issue converting lat longs to UTM with the ArcGIS javscript API.
Lets say that I have a map, based on the UTM zone 29N, also known as WKID 32629.
I have a known set of coordinates from a GPS, in this format:
Latitude: 62.220596
Longitude: -6.564331
The geograpic coordinates are in WKID 4326.
To convert using javascript I have been trying to use the Geometry Service's project method.
If we look at this post in the ArcGIS forum, it is about the same issue. Here, I have tried using the same code, and adjusting the wkid of the output spatialReference to 32629
, and you see it returns only NaN
, try in the JSfiddle to change the wkid to 4326, and you will see geographic coordinates.
Edit 1
Looking at the HTTP
requests made to the server, I see this url is requested (now using the map of the Faroe Islands)
http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project?f=json&outSR=32629&inSR=4326&geometries={"geometryType":"esriGeometryPoint","geometries":[{"x":62.01387,"y":-6.7866,"spatialReference":{"wkid":4326}}]}&callback=dojo.io.script.jsonp_dojoIoScript2._jsonpCallback
This looks like a correct url, containing outSR, inSR, geometries, and callback. However, simulating requests to this url gives me either a 500 Internal Server Error
, or this string:
dojo.io.script.jsonp_dojoIoScript2._jsonpCallback({"error":{"code":400,"message":"Unable to complete Project operation.","details":["Error projecting geometries"]}});
Any ideas?
Answer
I haven't looked at your code, but in the URL you provided, your X and Y are flipped around. For Faroe Islands, X should be -6.7866 (longitude) while Y should be 62.01387 (latitude). Here's a working URL of what you're trying to do:
http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project?f=json&outSR=32629&inSR=4326&geometries={"geometryType":"esriGeometryPoint","geometries":[{"x":-6.7866,"y":62.01387,"spatialReference":{"wkid":4326}}]}&callback=dojo.io.script.jsonp_dojoIoScript2._jsonpCallback
That correctly returns:
dojo.io.script.jsonp_dojoIoScript2._jsonpCallback({"geometryType":"esriGeometryPoint","geometries":[{"x":615863.053581134,"y":6877701.89119242}]});
As for 500s, I seem to get those quite frequently with sampleserver3 as well tonight. Try using sampleserver1 instead, that one seems to be more stable.
No comments:
Post a Comment