Graphhopper crash in nutiteq

45 views
Skip to first unread message

don...@upande.com

unread,
May 22, 2014, 4:58:16 AM5/22/14
to nutit...@googlegroups.com
hi i am trying to use graphhopper with nutiteq sdk for offline routing but the app crashes both on emulator and device. i am seeing this error - 05-22 03:52:17.557: E/AndroidRuntime(700): Caused by: java.lang.IllegalStateException: no map file is currently opened

05-22 03:52:17.557: E/AndroidRuntime(700): at org.mapsforge.map.reader.MapDatabase.getMapFileInfo(MapDatabase.java:238)

Jaak Laineste (Nutiteq)

unread,
May 22, 2014, 7:54:40 AM5/22/14
to nutit...@googlegroups.com

To give any useful help I’d need full stacktrace, your code sample and your data file package.

Did you try same data package - was it working with AdvancedMap3D sample app? If it worked there, then the problem is probably like error tells: make sure you have opened the .map file before you call getMapFileInfo()

Jaak

On 22 May 2014, at 11:58, don...@upande.com wrote:

hi i am trying to use graphhopper with nutiteq sdk for offline routing but the app crashes both on emulator and device. i am seeing this error - 05-22 03:52:17.557: E/AndroidRuntime(700): Caused by: java.lang.IllegalStateException: no map file is currently opened

05-22 03:52:17.557: E/AndroidRuntime(700): at org.mapsforge.map.reader.MapDatabase.getMapFileInfo(MapDatabase.java:238)

--
You received this message because you are subscribed to the Google Groups "Nutiteq-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nutiteq-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted
Message has been deleted

don...@upande.com

unread,
May 22, 2014, 10:31:14 AM5/22/14
to nutit...@googlegroups.com


On Thursday, May 22, 2014 7:54:40 AM UTC-4, Jaak Laineste wrote:

To give any useful help I’d need full stacktrace, your code sample and your data file package.

Did you try same data package - was it working with AdvancedMap3D sample app? If it worked there, then the problem is probably like error tells: make sure you have opened the .map file before you call getMapFileInfo()

Jaak



Here is the full stacktrace, code of my routing class and also attached my .map file. thanks

05-22 08:25:30.507: E/AndroidRuntime(1041): FATAL EXCEPTION: main
05-22 08:25:30.507: E/AndroidRuntime(1041): java.lang.RuntimeException: Unable to start activity ComponentInfo{upande.don.
upandenav/upande.don.upandenav.GraphhopperRouteActivity}: java.lang.IllegalStateException: no map file is currently opened
05-22 08:25:30.507: E/AndroidRuntime(1041):         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
05-22 08:25:30.507: E/AndroidRuntime(1041):         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
05-22 08:25:30.507: E/AndroidRuntime(1041):         at android.app.ActivityThread.access$600(ActivityThread.java:130)
05-22 08:25:30.507: E/AndroidRuntime(1041):         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
05-22 08:25:30.507: E/AndroidRuntime(1041):         at android.os.Handler.dispatchMessage(Handler.java:99)
05-22 08:25:30.507: E/AndroidRuntime(1041):         at android.os.Looper.loop(Looper.java:137)
05-22 08:25:30.507: E/AndroidRuntime(1041):         at android.app.ActivityThread.main(ActivityThread.java:4745)
05-22 08:25:30.507: E/AndroidRuntime(1041):         at java.lang.reflect.Method.invokeNative(Native Method)
05-22 08:25:30.507: E/AndroidRuntime(1041):         at java.lang.reflect.Method.invoke(Method.java:511)
05-22 08:25:30.507: E/AndroidRuntime(1041):         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
05-22 08:25:30.507: E/AndroidRuntime(1041):         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-22 08:25:30.507: E/AndroidRuntime(1041):         at dalvik.system.NativeStart.main(Native Method)
05-22 08:25:30.507: E/AndroidRuntime(1041): Caused by: java.lang.IllegalStateException: no map file is currently opened
05-22 08:25:30.507: E/AndroidRuntime(1041):         at org.mapsforge.map.reader.MapDatabase.getMapFileInfo(MapDatabase.java:238)
05-22 08:25:30.507: E/AndroidRuntime(1041):         at upande.don.upandenav.GraphhopperRouteActivity.onCreate(GraphhopperRouteActivity.java:138)
05-22 08:25:30.507: E/AndroidRuntime(1041):         at android.app.Activity.performCreate(Activity.java:5008)
05-22 08:25:30.507: E/AndroidRuntime(1041):         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
05-22 08:25:30.507: E/AndroidRuntime(1041):         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
05-22 08:25:30.507: E/AndroidRuntime(1041):         ... 11 more

Routing activity class source code:

File path = new File(Environment.getExternalStorageDirectory(),"graphhopper/maps/nairobi.osm-gh/kenya_nairobi.map");

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.nutimap);

        Log.enableAll();
        Log.setTag("graphhopper");

        // 1. Get the MapView from the Layout xml - mandatory
        mapView = (MapView) findViewById(R.id.mapView);

        // Optional, but very useful: restore map state during device rotation,
        // it is saved in onRetainNonConfigurationInstance() below
        Components retainObject = (Components) getLastNonConfigurationInstance();
        if (retainObject != null) {
            // just restore configuration, skip other initializations
            mapView.setComponents(retainObject);
            // add event listener
            RouteMapEventListener mapListener = new RouteMapEventListener(this);
            mapView.getOptions().setMapListener(mapListener);
            return;
        } else {
            // 2. create and set MapView components - mandatory
            Components components = new Components();
            mapView.setComponents(components);
            // add event listener
            RouteMapEventListener mapListener = new RouteMapEventListener(this);
            mapView.getOptions().setMapListener(mapListener);
        }

       
        String mapFilePath =path.getPath();

        // use mapsforge as offline base map
        XmlRenderTheme renderTheme = InternalRenderTheme.OSMARENDER;
        MapDatabase mapDatabase = new MapDatabase();
        mapDatabase.closeFile();
        File mapFile = new File(mapFilePath);
        FileOpenResult fileOpenResult = mapDatabase.openFile(mapFile);
        if (fileOpenResult.isSuccess()) {
            Log.debug("MapsforgeRasterDataSource: MapDatabase opened ok: " + mapFilePath);
        }

        MapsforgeRasterDataSource dataSource = new MapsforgeRasterDataSource(new EPSG3857(), 0, 20, mapFile, mapDatabase, renderTheme, this.getApplication());
        RasterLayer mapLayer = new RasterLayer(dataSource, mapFile.hashCode());

        mapView.getLayers().setBaseLayer(mapLayer);

        // set initial map view camera from database
        MapFileInfo mapFileInfo = dataSource.getMapDatabase().getMapFileInfo();
        if(mapFileInfo != null){
            if(mapFileInfo.startPosition != null && mapFileInfo.startZoomLevel != null){
                // start position is defined
                MapPos mapCenter = new MapPos(mapFileInfo.startPosition.longitude, mapFileInfo.startPosition.latitude,mapFileInfo.startZoomLevel);
                Log.debug("center: "+mapCenter);
                mapView.setFocusPoint(mapView.getLayers().getBaseLayer().getProjection().fromWgs84(mapCenter.x,mapCenter.y));
                mapView.setZoom((float) mapCenter.z);
            }else if(mapFileInfo.boundingBox != null){
                // start position not defined, but boundingbox is defined
                MapPos boxMin = mapView.getLayers().getBaseLayer().getProjection().fromWgs84(mapFileInfo.boundingBox.minLongitude, mapFileInfo.boundingBox.minLatitude);
                MapPos boxMax = mapView.getLayers().getBaseLayer().getProjection().fromWgs84(mapFileInfo.boundingBox.maxLongitude, mapFileInfo.boundingBox.maxLatitude);
                mapView.setBoundingBox(new Bounds(boxMin.x,boxMin.y,boxMax.x,boxMax.y), true);
            }
        }

 
kenya_nairobi.map

Jaak Laineste (Nutiteq)

unread,
May 22, 2014, 4:41:22 PM5/22/14
to nutit...@googlegroups.com
Hello,

Do you have file open success in your log? Your code logs it, but your log extract does not have it. Sounds like file not found.
Message should be "MapsforgeRasterDataSource: MapDatabase opened ok"

Jaak

--
You received this message because you are subscribed to the Google Groups "Nutiteq-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nutiteq-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<kenya_nairobi.map>

Message has been deleted

don...@upande.com

unread,
May 23, 2014, 3:48:05 AM5/23/14
to nutit...@googlegroups.com


On Thursday, May 22, 2014 4:41:22 PM UTC-4, Jaak Laineste wrote:
Hello,

Do you have file open success in your log? Your code logs it, but your log extract does not have it. Sounds like file not found.
Message should be "MapsforgeRasterDataSource: MapDatabase opened ok"

Jaak

On 22 May 2014, at 17:31, don...@upande.com wrote:



 hi Jaak, it might be that the file is not being found, but what do you think is causing this yet the file is available and i have set the path correctly. thanks..
Reply all
Reply to author
Forward
0 new messages