05-22 03:52:17.557: E/AndroidRuntime(700): at org.mapsforge.map.reader.MapDatabase.getMapFileInfo(MapDatabase.java:238)
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.
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
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);
      }
    }
--
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>
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