protected Path saveDoInBackground(Void... v) throws Exception { GraphHopper tmpHopp = new GraphHopper().forMobile(); tmpHopp.load(new File(mapsFolder, currentArea).getAbsolutePath() + "-gh"); log("found graph " + tmpHopp.getGraphHopperStorage().toString() + ", nodes:" + tmpHopp.getGraphHopperStorage().getNodes()); hopper = tmpHopp; return null; }
@Test public void testNoLoad() { GraphHopper instance = new GraphHopper(). setStoreOnFlush(false). setEncodingManager(encodingManager).setCHEnabled(false); try { instance.route(new GHRequest(42, 10.4, 42, 10)); assertTrue(false); } catch (Exception ex) { assertTrue(ex.getMessage(), ex.getMessage().startsWith("Do a successful call to load or importOrLoad before routing")); } instance = new GraphHopper().setEncodingManager(encodingManager); try { instance.route(new GHRequest(42, 10.4, 42, 10)); assertTrue(false); } catch (Exception ex) { assertTrue(ex.getMessage(), ex.getMessage().startsWith("Do a successful call to load or importOrLoad before routing")); } }
@Test public void testDisconnected179() { GraphHopperStorage graph = new GraphBuilder(encodingManager).create(); initGraph(graph); GraphHopper instance = new GraphHopper(). setStoreOnFlush(false). setEncodingManager(encodingManager).setCHEnabled(false). loadGraph(graph); GHResponse rsp = instance.route(new GHRequest(42, 10, 42, 10.4)); assertTrue(rsp.hasErrors()); try { rsp.getBest().getPoints(); assertTrue(false); } catch (Exception ex) { } instance.close(); }
graph.close(); GraphHopper hopper = new GraphHopper().setGraphHopperLocation(defaultGraphLoc).setCHEnabled(false); hopper.getLMFactoryDecorator().setEnabled(true).setWeightingsAsStrings(Arrays.asList("fastest")); assertEquals(16, hopper.getLMFactoryDecorator().getLandmarks()); hopper = new GraphHopper().setGraphHopperLocation(defaultGraphLoc).setCHEnabled(false); hopper.getLMFactoryDecorator().setEnabled(true).setWeightingsAsStrings(Arrays.asList("fastest"));
graph.close(); GraphHopper hopper = new GraphHopper().setGraphHopperLocation(defaultGraphLoc).setCHEnabled(false).importOrLoad(); EncodingManager em = hopper.getEncodingManager(); assertNotNull(em);
@Test public void testLoad() { GraphHopperStorage graph = new GraphBuilder(encodingManager).create(); initGraph(graph); // do further changes: NodeAccess na = graph.getNodeAccess(); na.setNode(4, 41.9, 10.2); graph.edge(1, 2, 10, false); graph.edge(0, 4, 40, true); graph.edge(4, 3, 40, true); GraphHopper instance = new GraphHopper(). setStoreOnFlush(false). setEncodingManager(encodingManager).setCHEnabled(false). loadGraph(graph); // 3 -> 0 GHResponse rsp = instance.route(new GHRequest(42, 10.4, 42, 10)); assertFalse(rsp.hasErrors()); PathWrapper arsp = rsp.getBest(); assertEquals(80, arsp.getDistance(), 1e-6); PointList points = arsp.getPoints(); assertEquals(42, points.getLatitude(0), 1e-5); assertEquals(10.4, points.getLongitude(0), 1e-5); assertEquals(41.9, points.getLatitude(1), 1e-5); assertEquals(10.2, points.getLongitude(1), 1e-5); assertEquals(3, points.getSize()); instance.close(); }
m_graphhopper = new GraphHopper().setEncodingManager(m_EncodingManager).forDesktop();
GraphHopper tmpHopp = new GraphHopper().forAndroid(); tmpHopp.contractionHierarchies(true); tmpHopp.load(mapsFolder + currentArea); runOnUiThread(new Runnable() { public void run() { logUser("found graph with " + tmpHopp.getGraph().nodes() + " nodes"); } }); hopper = tmpHopp; return null;
public static GraphHopper createHopper(boolean memoryMapped, String graphFolder) { GraphHopper ret = null; ret = new GraphHopper().forDesktop(); // initialise the encoders ourselves as we can use multiple // encoders for same vehicle type corresponding to different // times of day (i.e. rush hours) ret.setEncodingManager(createEncodingManager(graphFolder)); // don't need to write so disable the lock file (allows us to run out of program files) ret.setAllowWrites(false); if (memoryMapped) { ret.setMemoryMapped(); } ret.setGraphHopperLocation(graphFolder); ret.importOrLoad(); return ret; }
GraphHopper hopper = new GraphHopper().init(args); hopper.getCHFactoryDecorator().setEnabled(false); hopper.importOrLoad(); GraphHopper hopper = new GraphHopper().init(args); hopper.getCHFactoryDecorator().setEnabled(false); logger.info("loading graph from cache");