Search in sources :

Example 1 with MapLoader

use of com.peterlaurence.trekadvisor.core.map.maploader.MapLoader in project TrekAdvisor by peterLaurence.

the class MapParserTest method mapTracksParse.

@Test
public void mapTracksParse() {
    if (mJsonFilesDirectory != null) {
        File[] dirs = new File[1];
        dirs[0] = mJsonFilesDirectory;
        final Map[] map = new Map[1];
        MapLoader.MapListUpdateListener mapListUpdateListener = new MapLoader.MapListUpdateListener() {

            @Override
            public void onMapListUpdate(boolean mapsFound) {
                List<Map> mapList = MapLoader.getInstance().getMaps();
                /* One map should be found */
                assertEquals(1, mapList.size());
                map[0] = mapList.get(0);
            }
        };
        MapLoader.MapRouteUpdateListener mapRouteUpdateListener = new MapLoader.MapRouteUpdateListener() {

            @Override
            public void onMapRouteUpdate() {
                /* 2 routes should be found */
                assertEquals(2, map[0].getRoutes().size());
                RouteGson.Route route = map[0].getRoutes().get(0);
                assertEquals("A test route 1", route.name);
                assertEquals(true, route.visible);
                List<MarkerGson.Marker> markers = route.route_markers;
                assertEquals(2, markers.size());
                MarkerGson.Marker marker1 = markers.get(0);
                assertEquals("marker1", marker1.name);
                assertEquals(6198798.5047565, marker1.proj_x, 0);
                MarkerGson.Marker marker2 = markers.get(1);
                assertEquals("marker2", marker2.name);
                assertEquals(-2418744.7142449305, marker2.proj_y, 0);
            }
        };
        MapLoader mapLoader = MapLoader.getInstance();
        mapLoader.setMapRouteUpdateListener(mapRouteUpdateListener);
        mapLoader.addMapListUpdateListener(mapListUpdateListener);
        mapLoader.clearAndGenerateMaps(dirs);
        mapLoader.getRoutesForMap(map[0]);
    }
}
Also used : MarkerGson(com.peterlaurence.trekadvisor.core.map.gson.MarkerGson) MapLoader(com.peterlaurence.trekadvisor.core.map.maploader.MapLoader) File(java.io.File) RouteGson(com.peterlaurence.trekadvisor.core.map.gson.RouteGson) Test(org.junit.Test)

Example 2 with MapLoader

use of com.peterlaurence.trekadvisor.core.map.maploader.MapLoader in project TrekAdvisor by peterLaurence.

the class MapImporterTest method existingMapImport.

@Test
public void existingMapImport() {
    if (mMapsDirectory != null) {
        final File libVipsMapDir = new File(mMapsDirectory, "libvips-with-json");
        if (libVipsMapDir.exists()) {
            MapLoader.MapListUpdateListener mapListUpdateListener = new MapLoader.MapListUpdateListener() {

                @Override
                public void onMapListUpdate(boolean mapsFound) {
                    assertEquals(true, mapsFound);
                    Map map = MapLoader.getInstance().getMap("La RĂ©union - Est");
                    assertNotNull(map);
                    assertEquals(3, map.getMapGson().levels.size());
                }
            };
            MapLoader mapLoader = MapLoader.getInstance();
            mapLoader.addMapListUpdateListener(mapListUpdateListener);
            MapImporter.importFromFile(libVipsMapDir, MapImporter.MapProvider.LIBVIPS, null);
        }
    }
}
Also used : MapLoader(com.peterlaurence.trekadvisor.core.map.maploader.MapLoader) File(java.io.File) Test(org.junit.Test)

Aggregations

MapLoader (com.peterlaurence.trekadvisor.core.map.maploader.MapLoader)2 File (java.io.File)2 Test (org.junit.Test)2 MarkerGson (com.peterlaurence.trekadvisor.core.map.gson.MarkerGson)1 RouteGson (com.peterlaurence.trekadvisor.core.map.gson.RouteGson)1