Select to view content in your preferred language

How to give routes using LatLng points?

1071
1
02-10-2017 04:06 AM
MalcolmDorn
Deactivated User

I am new to ArcGIS but have followed the guide at Find a route—ArcGIS Runtime SDK for Android | ArcGIS for Developers  to route from one location to another but the guide uses a projected coordinate system in California. I want to, ideally, be able to give route parameters using LatLng or at least be able to convert from LatLng to something else? Will the API not accept LatLng points? I want to route in the United Kingdom so, accordiing to Coordinate systems and projections for beginners — Esri UK  this would mean I need to convert WKID 4326 into WKID 102100 or 3857?

In the example I can give 2 stops as follows:

Stop stop1 = new Stop(new Point(-13046294.924, 4036100.529, SpatialReferences.getWebMercator()));
Stop stop2 = new Stop(new Point(-13046094.899, 4036273.038, SpatialReferences.getWebMercator()));

But if I give these stops, also in California, using LatLng:

Stop stop1 = new Stop(new Point(32.863797, -117.205879, SpatialReferences.getWgs84() ));
Stop stop2 = new Stop(new Point(32.902620, -117.150526, SpatialReferences.getWgs84() ));

.... no matter what spatial reference or lack of I use, it returns java.util.concurrent.ExecutionException: com.esri.arcgisruntime.io.JsonEmbeddedException: Unable to complete operation when I call RouteResult routeResult = routeResultFuture.get();

So I guess something it wrong with my query to the API? What am I supposed to do to query using LatLng? I am using the following route service proxy (minus my personal key):

http://utility.arcgis.com/usrsvcs/appservices/XXXXXXXXXXXXXXXX/rest/services/World/Route/NAServer/Ro... 

Please can someone help? It is important I use LatLng as I need the routing to be compatible with GoolgeMap and the rest of my application that is all coded to use LatLng. I don't mind converting it if I have to but I need a way to do this programatically in my app.

0 Kudos
1 Reply
AlexanderNohe1
Honored Contributor

Malcolm Dorn

I would look to converting the lat/long to what the coordinate system you are using uses.  The easiest way to do this is to use the geometry engine and project the lat/long to the coordinates of the routing system you are using:

You can construct your point using a Point object and then call the project method here:

Project(Geometry Engine)

https://developers.arcgis.com/android/latest/api-reference/reference/com/esri/arcgisruntime/geometry...

I hope this helps!

0 Kudos