无法创建从一个点的路线到另一个Android版的ArcGIS [英] Cannot create route from one point to another ArcGIS Android
问题描述
我一直很努力创建两个点之间的航线(的startPoint,终端)。但我得到以下错误:
I've been trying very hard to create a route between two points(startPoint, endPoint). But i am getting the following error:
在停止位置位置1就是非定位。位置位置2中的停止就是非定位。至少需要2有效站。 停止不包含有效的输入任何路线。
我已经张贴在gis.stackexchange.com这个问题,并geonet.esri.com并没有得到除一个答复这是没有帮助的。
I've posted this question on gis.stackexchange.com and geonet.esri.com and didn't get a reply except one which was not helpful.
我的code:
private final String routeTaskURL = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/NAServer/Route";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mMapView = (MapView) findViewById(R.id.map);
mMapView.enableWrapAround(true);
new Thread(new Runnable() {
@Override
public void run() {
try {
UserCredentials userCredentials = new UserCredentials();
userCredentials.setUserToken(token, clientID);
RouteTask routeTask = RouteTask.createOnlineRouteTask(routeTaskURL, userCredentials);
RouteParameters routeParameters = routeTask.retrieveDefaultRouteTaskParameters();
NAFeaturesAsFeature naFeatures = new NAFeaturesAsFeature();
Point startPoint = new Point(36.793653, -119.866896);
Point stopPoint = new Point(36.795488, -119.853345);
StopGraphic startPnt = new StopGraphic(startPoint);
StopGraphic stopPnt = new StopGraphic(stopPoint);
naFeatures.setFeatures(new Graphic[] {startPnt, stopPnt});
routeParameters.setStops(naFeatures);
RouteResult mResults = routeTask.solve(routeParameters);
List<Route> routes = mResults.getRoutes();
System.out.println(mResults.getRoutes());
Route mRoute = routes.get(0);
Geometry geometry = mRoute.getRouteGraphic().getGeometry();
Graphic symbolGraphic = new Graphic(geometry, new SimpleLineSymbol(Color.BLUE, 3));
mGraphicsLayer.addGraphic(symbolGraphic);
System.out.println(mResults.getStops());
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
我在网上搜索。许多开发者/都面临这个问题。我已经尝试了所有解决方案,但没有一次成功。我的 routeTaskURL 在ArcGIS路由示例应用程序。这是在 文档 给出的链接ArcGIS的地图strong>如果我在浏览器中打开它给我的403错误。
I've searched the internet. Many developers were/are facing this problem. I've tried all the solutions but none of them worked. I got routeTaskURL from the ArcGIS Routing Sample app. The link which is given in the documentation of ArcGIS maps gives me the 403 error if i open it in the browser.
注意:令牌和clientID的在第一步中声明,他们都从那里我注册了我的应用程序在ArcGIS开发者控制台采取
有什么建议?
推荐答案
您的X和Y值的切换。改成这样:
Your X and Y values are switched. Change to this:
Point startPoint = new Point(-119.866896, 36.793653);
Point stopPoint = new Point(-119.853345, 36.795488);
查看<一个href=\"https://developers.arcgis.com/android/api-reference/reference/com/esri/core/geometry/Point.html\"相对=nofollow> 点
类文档了解,该构造函数的参数为(X,Y),不(Y,X)。您正在使用的航线有4326默认的空间参考,这是未投影经度和纬度。 -119.866896和-119.853345无效纬度(y)的值,但它们是有效的经度(x)的值。
See the Point
class documentation to learn that the constructor parameters are (x, y), not (y, x). The route service you're using has a default spatial reference of 4326, which is unprojected longitude and latitude. -119.866896 and -119.853345 are not valid latitude (y) values, but they are valid longitude (x) values.
这篇关于无法创建从一个点的路线到另一个Android版的ArcGIS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!