Sygic / sygic-maps-kit-android

Project containing Android libraries separated into modules which are built over Sygic Maps SDK and provide rapid development of apps with Sygic maps solution.
MIT License
22 stars 3 forks source link

onComputeError (int i => 4 (UnreachableTarget)) #61

Closed rajatapporio closed 5 years ago

rajatapporio commented 5 years ago

I am making the app with your sygic sdk in android. I got an error in Routing please help to solve that. I am coding according to your documentation.

Link > https://www.sygic.com/developers/sygic-maps-sdk/android/routing

I am getting error after "mRouter.computeRoute();"

Below is my MainActivity Code ->

////////////////////////////////////////////////////////////////////////////////////////////////////////////// package com.example.sygicdemo5;

import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import com.sygic.sdk.map.MapFragment; import com.sygic.sdk.map.MapView; import com.sygic.sdk.map.listeners.OnMapInitListener; import com.sygic.sdk.online.OnlineManager; import com.sygic.sdk.position.GeoCoordinates; import com.sygic.sdk.route.RouteInfo; import com.sygic.sdk.route.RoutePlan; import com.sygic.sdk.route.Router;

public class MainActivity extends AppCompatActivity {

MapFragment mapFragment;
MapView mMapView;
RoutePlan mRoute;
Router mRouter;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

     mapFragment = (MapFragment) getSupportFragmentManager().findFragmentById(R.id.mapFragment);

    // getMapAsync() will internally wait for engine initialization
    mapFragment.getMapAsync(new OnMapInitListener() {
        @Override
        public void onMapInitializationInterrupted() {
        }

        @Override
        public void onMapReady(@NonNull MapView mapView) {
            // Now you can start work with the ready mapView object
            OnlineManager.getInstance().enableOnlineMapStreaming(true);
            setTheLocation();
        }

    });
}

public void setTheLocation(){
    mMapView = mapFragment.getMapView();

    mMapView.getCameraModel().setPosition(new GeoCoordinates(28.4595, 77.0266));
    mMapView.getCameraModel().setZoomLevel(18.5f);

    setTheRoute();
}

public void setTheRoute(){
    mRoute = new RoutePlan();
    mRoute.setStart(new GeoCoordinates(28.4595, 77.0266));
    mRoute.setDestination(new GeoCoordinates(28.4291,77.0367));

    mRouter = new Router();
    mRouter.computeRoute(mRoute, new Router.RouteComputeAdapter() {
        @Override
        public void onComputeError(Router router, int error) {
            super.onComputeError(router, error);
            // here the code stops with error code 4 (Unreachable target)

        }

        @Override
        public void onProgress(Router router, int progress, long routeId) {
            super.onProgress(router, progress, routeId);
        }

        @Override
        public void onComputeStarted(Router router) {
            super.onComputeStarted(router);
        }

        @Override
        public void onPrimaryComputeFinished(Router router, RouteInfo routes) {
            super.onPrimaryComputeFinished(router, routes);
        }

        @Override
        public void onAlternativeComputeFinished(Router router, RouteInfo routes) {
            super.onAlternativeComputeFinished(router, routes);
        }

        @Override
        public void onComputeFinished(Router router) {
            super.onComputeFinished(router);
        }

        @Override
        public void onRecomputeStarted() {
            super.onRecomputeStarted();
        }

        @Override
        public void onRecomputeFinished(RouteInfo route, int recomputeType) {
            super.onRecomputeFinished(route, recomputeType);
        }

        @Override
        public void onRecomputeError(int error) {
            super.onRecomputeError(error);
        }
    });

}

}

bio007 commented 5 years ago

Hi @rajatapporio

I have just few questions to clarify the issue:

  1. Are you using online maps (and services)? -> I can see you are calling OnlineManager.getInstance().enableOnlineMapStreaming(true); so I suppose you do. In that case see question no 2.

  2. Can you see maps loaded correctly?

  3. In the time you were doing the test, were there some road closures in the target area? That would explain unreachable error code...

I tried to compute that route myself and it has been computed successfully at around 10:30 GMT+2.

I'll check server logs for your api key in the meantime but it would be helpful if you can try it again and write me exact time you were doing the compute.

Thanks

rajatapporio commented 5 years ago

Hello @bio007 , thanks for replying

Ans 1. Yes I am using online maps

Ans 2. Yes the map loaded correctly and I redirected location to my current lat long (written hardcoded)

Ans 3. No there is no road closer (The locations I have eneterd are 4 kms far from each other) Moreover, I also tried with various lat longs of India as well as US also. I also tried with the method which is shown in the documentation

routePlan.setStart(mapView2.geoCoordinatesFromPoint(300, 300)); routePlan.setDestination(mapView2.geoCoordinatesFromPoint(600, 700)); // x,y are screen coordinates.

some times it gives error 17 too (i.e "InvalidSelection")

Exact time I did compute >

Earlier - > ( Many times between 12:30 PM to 1:30 PM IST (Indian Standard Time) )

Now - > ( 14:54:53 IST (Indian Standard Time) ) = ( 02:54 PM IST( Indian Standard Time) )

bio007 commented 5 years ago

We've found out the source of your problem. There has been a issue with a map of India for your set of services (and your API key combination)

My tests were successful because I've been using different set of maps not affected by the issue. We are deploying new maps for you right now so it should be working in no time.