Select to view content in your preferred language

World route service for Android not returning results

460
1
04-17-2013 05:12 AM
SriramV
Emerging Contributor
Hi,
Iam using the arcGIS Android SDK v10.1.1. I want to plot the route between 2 points in the European region. Iam using the World Route service (as per http://blogs.esri.com/esri/arcgis/2013/04/08/legacy-geocoding-and-routing-services-at-httptasks-arcg...) to get route info. But the server does not respond (nor times out) when solve is called.
Following is a snippet:


RoutingParameters routeParams = new RoutingParameters();
routeParams.setImpedanceAttributeName("Length");
String routeTaskURL = "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World";

//Prepare user credentials
UserCredentials userCredentials = new UserCredentials();
userCredentials.setAuthenticationType(AuthenticationType.TOKEN);
userCredentials.setSSLRequired(false);
userCredentials.setUserAccount(<userName>, <psswd>);
userCredentials.setUserToken(<user_token>, <referer>);


RoutingTask routeTask = new RoutingTask(routeTaskURL, userCredentials);

Point point1 = (Point) GeometryEngine.project(p1, mOutSpacialRef, mMap.getSpatialReference());//Spatial reference 4326
StopGraphic startPnt = new StopGraphic(point1);

Point point2 = (Point) GeometryEngine.project(p2, mOutSpacialRef, mMap.getSpatialReference());
StopGraphic endPnt = new StopGraphic(point2);

naFeatures.setFeatures(new Graphic[] { startPnt, endPnt });

NAFeaturesAsFeature naFeatures = new NAFeaturesAsFeature();
naFeatures.setSpatialReference(mMap.getSpatialReference());
naFeatures.setCompressedRequest(true);
routeParams.setStops(naFeatures);
routeParams.setOutSpatialReference(mOutSpacialRef);
try
{
  mResults = routeTask.solve(routeParams);//hangs here. no response and no timeout
} catch (Exception e)
{
  e.printStackTrace();
  return null;
}

The app hangs after calling solve, meaning there's no response from the server and hence waits forever. Can anyone please point out the mistake?


Thanks,
V. Sriram
0 Kudos
1 Reply
SriramV
Emerging Contributor
Found the issue.
1. The account to be used to create application and generare token must be created from http://www.esri.com/software/arcgis/arcgisonline/evaluate. Click on "Create a NEW Esri Account" button.
2. The outspatialreference to be set to 102100 everywhere. Following is the modification required.
   // Create the stop points from point geometry
   StopGraphic startPnt = new StopGraphic(GeometryEngine.project(startPoint, SpatialReference.create(4326), SpatialReference.create(102100)));
   StopGraphic endPnt = new StopGraphic(GeometryEngine.project(endPoint, SpatialReference.create(4326), SpatialReference.create(102100)));

   // set features on routing feature class
   naFeatures.setFeatures(new Graphic[] { startPnt, endPnt });
   naFeatures.setSpatialReference(SpatialReference.create(102100));
                        routeParams.setOutSpatialReference(SpatialReference.create(102100));


Thanks,
V. Sriram
0 Kudos