@Override public RAMGraph createRAMGraph(InputStream in) throws IOException { int nofNodes; int nofEdges; long curTime = System.currentTimeMillis(); BufferedReader inb = new BufferedReader(new InputStreamReader(in)); String line = inb.readLine(); while (line != null && line.trim().startsWith("#")) { line = inb.readLine(); } nofNodes = line != null ? Integer.parseInt(line) : 0; line = inb.readLine(); nofEdges = line != null ? Integer.parseInt(line) : 0; RAMGraph graph = new RAMGraph(nofNodes, nofEdges); float x, y; int altID, OSMID, height; String[] splittedLine; for (int i = 0; i < nofNodes; i++) { splittedLine = COMPILE.split(inb.readLine()); // altID[i]=i; if (splittedLine.length == 5) { altID = Integer.parseInt(splittedLine[0]); OSMID = Integer.parseInt(splittedLine[1]); x = Float.parseFloat(splittedLine[2]); y = Float.parseFloat(splittedLine[3]); height = Integer.parseInt(splittedLine[4]); graph.addNode(x, y, altID, height, OSMID); if ((i % (nofNodes / 10)) == 0) { System.err.print((10 * i / (nofNodes / 10) + "% ")); } } else { nofNodes--; } } int edgeSource, edgeTarget, edgeWeight, edgeLength, edgeHeight; for (int i = 0; i < nofEdges; i++) { splittedLine = COMPILE.split(inb.readLine()); if (splittedLine.length == 4) { edgeSource = Integer.parseInt(splittedLine[0]); edgeTarget = Integer.parseInt(splittedLine[1]); edgeLength = Integer.parseInt(splittedLine[2]); edgeWeight = calcWeight(edgeLength, Integer.parseInt(splittedLine[3])); edgeHeight = graph.getHeight(edgeTarget) - graph.getHeight(edgeSource); if (edgeHeight < 0) { edgeHeight = 0; } graph.addEdge(edgeSource, edgeTarget, edgeWeight, edgeLength, edgeHeight); if ((i % (nofEdges / 10)) == 0) { System.err.print((10 * i / (nofEdges / 10) + "% ")); } } else { nofEdges--; } } if (nofNodes != graph.nofNodes() || nofEdges != graph.nofEdges()) { graph = new RAMGraph(graph, nofNodes, nofEdges); } System.err.println("Parsing took " + (System.currentTimeMillis() - curTime)); graph.setupOffsets(); System.err.println( "Read graph with " + nofNodes + " vertices and " + nofEdges + " edges in time " + (System.currentTimeMillis() - curTime) + "ms"); return graph; }