本文介绍了无法创建从一个点到另一个 ArcGIS Android 的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直非常努力地在两点(startPoint、endPoint)之间创建一条路线.但我收到以下错误:

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.

我的代码:

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();
}

我在互联网上搜索过.许多开发人员曾经/正在面临这个问题.我已经尝试了所有的解决方案,但没有一个奏效.我从 ArcGIS Routing Sample 应用程序获得了 routeTaskURL.文档中提供的链接如果我在浏览器中打开它,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.

注意:token"和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);

参见 类文档 了解构造函数参数是 (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.

这篇关于无法创建从一个点到另一个 ArcGIS Android 的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 13:45