@Override public void readGraph() throws IOException { if (encodingManager == null) throw new IllegalStateException("Encoding manager was not set."); if (osmFile == null) throw new IllegalStateException("No OSM file specified"); if (!osmFile.exists()) throw new IllegalStateException("Your specified OSM file does not exist:" + osmFile.getAbsolutePath()); StopWatch sw1 = new StopWatch().start(); preProcess(osmFile); sw1.stop(); StopWatch sw2 = new StopWatch().start(); writeOsm2Graph(osmFile); sw2.stop(); LOGGER.info("time pass1:" + (int) sw1.getSeconds() + "s, " + "pass2:" + (int) sw2.getSeconds() + "s, " + "total:" + (int) (sw1.getSeconds() + sw2.getSeconds()) + "s"); }
sw.stop(); logger.info("Queries| read: " + readQueries + ", no dups:" + noDuplicate.size()
void repaintRoads() { // avoid threading as there should be no updated to scale or offset while painting // (would to lead to artifacts) StopWatch sw = new StopWatch().start(); pathLayer.repaint(); roadsLayer.repaint(); mainPanel.repaint(); logger.info("roads painting took " + sw.stop().getSeconds() + " sec"); } }
GHResponse route() { StopWatch stopWatch = new StopWatch().start(); ArrayList<QueryResult> allQueryResults = new ArrayList<>(); QueryResult source = findClosest(enter, 0); QueryResult dest = findClosest(exit, 1); allQueryResults.add(source); allQueryResults.add(dest); queryGraph.lookup(Arrays.asList(source, dest)); // modifies queryGraph, source and dest! PointList startAndEndpoint = pointListFrom(Arrays.asList(source, dest)); response.addDebugInfo("idLookup:" + stopWatch.stop().getSeconds() + "s"); int startNode; int destNode; if (arriveBy) { startNode = allQueryResults.get(1).getClosestNode(); destNode = allQueryResults.get(0).getClosestNode(); } else { startNode = allQueryResults.get(0).getClosestNode(); destNode = allQueryResults.get(1).getClosestNode(); } List<List<Label.Transition>> solutions = findPaths(startNode, destNode); parseSolutionsAndAddToResponse(solutions, startAndEndpoint); return response; }
@Override protected void loadOrPrepareLM() { StopWatch sw = new StopWatch().start(); super.loadOrPrepareLM(); put(Parameters.Landmark.PREPARE + "time", sw.stop().getMillis()); }
@Override protected DataReader importData() throws IOException { StopWatch sw = new StopWatch().start(); DataReader dr = super.importData(); put("graph.import_time", sw.stop().getSeconds()); return dr; } };
private void interpolateBridgesAndOrTunnels() { if (ghStorage.getEncodingManager().supports("generic")) { final FlagEncoder genericFlagEncoder = ghStorage.getEncodingManager() .getEncoder("generic"); if (!(genericFlagEncoder instanceof DataFlagEncoder)) { throw new IllegalStateException("'generic' flag encoder for elevation interpolation of " + "bridges and tunnels is enabled but does not have the expected type " + DataFlagEncoder.class.getName() + "."); } final DataFlagEncoder dataFlagEncoder = (DataFlagEncoder) genericFlagEncoder; StopWatch sw = new StopWatch().start(); new TunnelElevationInterpolator(ghStorage, dataFlagEncoder).execute(); float tunnel = sw.stop().getSeconds(); sw = new StopWatch().start(); new BridgeElevationInterpolator(ghStorage, dataFlagEncoder).execute(); logger.info("Bridge interpolation " + (int) sw.stop().getSeconds() + "s, " + "tunnel interpolation " + (int) tunnel + "s"); } }
/** * This method removes networks that will be never be visited by this filter. See #235 for * example, small areas like parking lots are sometimes connected to the whole network through a * one-way road. This is clearly an error - but is causes the routing to fail when a point gets * connected to this small area. This routine removes all these networks from the graph. * <p> * * @return number of removed edges */ int removeDeadEndUnvisitedNetworks(final PrepEdgeFilter bothFilter) { StopWatch sw = new StopWatch(bothFilter.getEncoder() + " findComponents").start(); final EdgeFilter outFilter = DefaultEdgeFilter.outEdges(bothFilter.getEncoder()); // partition graph into strongly connected components using Tarjan's algorithm TarjansSCCAlgorithm tarjan = new TarjansSCCAlgorithm(ghStorage, outFilter, true); List<IntArrayList> components = tarjan.findComponents(); logger.info(sw.stop() + ", size:" + components.size()); return removeEdges(bothFilter, components, minOneWayNetworkSize); }
private boolean prepareNodes() { int nodes = prepareGraph.getNodes(); for (int node = 0; node < nodes; node++) { prepareGraph.setLevel(node, maxLevel); } periodicUpdateSW.start(); for (int node = 0; node < nodes; node++) { float priority = oldPriorities[node] = calculatePriority(node); sortedNodes.insert(node, priority); } periodicUpdateSW.stop(); return !sortedNodes.isEmpty(); }
@Override public void doSpecificWork() { StopWatch sw = new StopWatch().start(); LOGGER.info("Start calculating " + lms.getLandmarkCount() + " landmarks, default active lms:" + defaultActiveLandmarks + ", weighting:" + lms.getLmSelectionWeighting() + ", " + Helper.getMemInfo()); lms.createLandmarks(); lms.flush(); LOGGER.info("Calculated landmarks for " + (lms.getSubnetworksWithLandmarks() - 1) + " subnetworks, took:" + sw.stop().getSeconds() + " => " + lms.getLandmarksAsGeoJSON() + ", stored weights:" + lms.getLandmarkCount() + ", nodes:" + graph.getNodes() + ", " + Helper.getMemInfo()); }
@Override public LocationIndex prepareIndex() { if (initialized) throw new IllegalStateException("Call prepareIndex only once"); StopWatch sw = new StopWatch().start(); prepareAlgo(); // in-memory preparation InMemConstructionIndex inMem = getPrepareInMemIndex(); // compact & store to dataAccess dataAccess.create(64 * 1024); try { inMem.store(inMem.root, START_POINTER); flush(); } catch (Exception ex) { throw new IllegalStateException("Problem while storing location index. " + Helper.getMemInfo(), ex); } float entriesPerLeaf = (float) inMem.size / inMem.leafs; initialized = true; logger.info("location index created in " + sw.stop().getSeconds() + "s, size:" + Helper.nf(inMem.size) + ", leafs:" + Helper.nf(inMem.leafs) + ", precision:" + minResolutionInMeter + ", depth:" + entries.length + ", checksum:" + calcChecksum() + ", entries:" + Arrays.toString(entries) + ", entriesPerLeaf:" + entriesPerLeaf); return this; }
/** * Fill quadtree which will span a raster over the entire specified graph g. But do this in a * pre-defined resolution which is controlled via capacity. This data structure then uses approx. * capacity * 4 bytes. So maximum capacity is 2^30 where the quadtree would cover the world * boundaries every 1.3km - IMO enough for EU or US networks. */ @Override public LocationIndex prepareIndex() { initBuffer(); initAlgo(latSize, lonSize); StopWatch sw = new StopWatch().start(); GHBitSet filledIndices = fillQuadtree(latSize * lonSize); int fillQT = filledIndices.getCardinality(); float res1 = sw.stop().getSeconds(); sw = new StopWatch().start(); int counter = fillEmptyIndices(filledIndices); float fillEmpty = sw.stop().getSeconds(); logger.info("filled quadtree index array in " + res1 + "s. size is " + getCapacity() + " (" + fillQT + "). filled empty " + counter + " in " + fillEmpty + "s"); flush(); return this; }
/** * Extracts the Path from the shortest-path-tree determined by sptEntry. */ public Path extract() { if (isFound()) throw new IllegalStateException("Extract can only be called once"); extractSW.start(); SPTEntry currEdge = sptEntry; setEndNode(currEdge.adjNode); boolean nextEdgeValid = EdgeIterator.Edge.isValid(currEdge.edge); int nextEdge; while (nextEdgeValid) { // the reverse search needs the next edge nextEdgeValid = EdgeIterator.Edge.isValid(currEdge.parent.edge); nextEdge = nextEdgeValid ? currEdge.parent.edge : EdgeIterator.NO_EDGE; processEdge(currEdge.edge, currEdge.adjNode, nextEdge); currEdge = currEdge.parent; } setFromNode(currEdge.adjNode); reverseOrder(); extractSW.stop(); return setFound(true); }
protected PathWrapper doInBackground(Void... v) { StopWatch sw = new StopWatch().start(); GHRequest req = new GHRequest(fromLat, fromLon, toLat, toLon). setAlgorithm(Algorithms.DIJKSTRA_BI); req.getHints(). put(Routing.INSTRUCTIONS, "false"); GHResponse resp = hopper.route(req); time = sw.stop().getSeconds(); return resp.getBest(); }
@Override protected void prepareCH() { StopWatch sw = new StopWatch().start(); super.prepareCH(); put(Parameters.CH.PREPARE + "time", sw.stop().getMillis()); int edges = getGraphHopperStorage().getAllEdges().length(); if (getCHFactoryDecorator().hasWeightings()) { Weighting weighting = getCHFactoryDecorator().getWeightings().get(0); int edgesAndShortcuts = getGraphHopperStorage().getGraph(CHGraph.class, weighting).getEdges(); put(Parameters.CH.PREPARE + "shortcuts", edgesAndShortcuts - edges); } }
@Override public void doSpecificWork() { allSW.start(); initFromGraph(); runGraphContraction(); logger.info("took:" + (int) allSW.stop().getSeconds() + "s " + ", new shortcuts: " + nf(nodeContractor.getAddedShortcutsCount()) + ", initSize:" + nf(initSize) + ", " + prepareWeighting + ", periodic:" + params.getPeriodicUpdatesPercentage() + ", lazy:" + params.getLastNodesLazyUpdatePercentage() + ", neighbor:" + params.getNeighborUpdatePercentage() + ", " + getTimesAsString() + ", lazy-overhead: " + (int) (100 * ((checkCounter / (double) initSize) - 1)) + "%" + ", " + Helper.getMemInfo()); int edgeCount = prepareGraph.getOriginalEdges(); logger.info("graph now - num edges: {}, num nodes: {}, num shortcuts: {}", nf(edgeCount), nf(prepareGraph.getNodes()), nf(prepareGraph.getEdges() - edgeCount)); }
extractSW.stop(); return setFound(true);