private void writeOsm2Graph(File osmFile) {
        int tmp = (int) Math.max(getNodeMap().getSize() / 50, 100);
        LOGGER.info("creating graph. Found nodes (pillar+tower):" + nf(getNodeMap().getSize()) + ", " + Helper.getMemInfo());
        if (createStorage)
            ghStorage.create(tmp);

        long wayStart = -1;
        long relationStart = -1;
        long counter = 1;
        try (OSMInput in = openOsmInputFile(osmFile)) {
            LongIntMap nodeFilter = getNodeMap();

            ReaderElement item;
            while ((item = in.getNext()) != null) {
                switch (item.getType()) {
                    case ReaderElement.NODE:
                        if (nodeFilter.get(item.getId()) != EMPTY_NODE) {
                            processNode((ReaderNode) item);
                        }
                        break;

                    case ReaderElement.WAY:
                        if (wayStart < 0) {
                            LOGGER.info(nf(counter) + ", now parsing ways");
                            wayStart = counter;
                        }
                        processWay((ReaderWay) item);
                        break;
                    case ReaderElement.RELATION:
                        if (relationStart < 0) {
                            LOGGER.info(nf(counter) + ", now parsing relations");
                            relationStart = counter;
                        }
                        processRelation((ReaderRelation) item);
                        break;
                    case ReaderElement.FILEHEADER:
                        break;
                    default:
                        throw new IllegalStateException("Unknown type " + item.getType());
                }
                if (++counter % 200_000_000 == 0) {
                    LOGGER.info(nf(counter) + ", locs:" + nf(locations) + " (" + skippedLocations + ") " + Helper.getMemInfo());
                }
            }

            if (in.getUnprocessedElements() > 0)
                throw new IllegalStateException("Still unprocessed elements in reader queue " + in.getUnprocessedElements());

            // logger.info("storage nodes:" + storage.nodes() + " vs. graph nodes:" + storage.getGraph().nodes());
        } catch (Exception ex) {
            throw new RuntimeException("Couldn't process file " + osmFile + ", error: " + ex.getMessage(), ex);
        }

        finishedReading();
        if (graph.getNodes() == 0)
            throw new RuntimeException("Graph after reading OSM must not be empty. Read " + counter + " items and " + locations + " locations");
    }
private void writeOsm2Graph ( File osmFile ) { int tmp = ( int ) Math . max ( getNodeMap ( ) . getSize ( ) / 50 , 100 ) ; LOGGER . info ( "creating graph. Found nodes (pillar+tower):" + nf ( getNodeMap ( ) . getSize ( ) ) + ", " + Helper . getMemInfo ( ) ) ; if ( createStorage ) ghStorage . create ( tmp ) ; long wayStart = - 1 ; long relationStart = - 1 ; long counter = 1 ; try ( OSMInput in = openOsmInputFile ( osmFile ) ) { LongIntMap nodeFilter = getNodeMap ( ) ; ReaderElement item ; while ( ( item = in . getNext ( ) ) != null ) { switch ( item . getType ( ) ) { case ReaderElement . NODE : if ( nodeFilter . get ( item . getId ( ) ) != EMPTY_NODE ) { processNode ( ( ReaderNode ) item ) ; } break ; case ReaderElement . WAY : if ( wayStart < 0 ) { LOGGER . info ( nf ( counter ) + ", now parsing ways" ) ; wayStart = counter ; } processWay ( ( ReaderWay ) item ) ; break ; case ReaderElement . RELATION : if ( relationStart < 0 ) { LOGGER . info ( nf ( counter ) + ", now parsing relations" ) ; relationStart = counter ; } processRelation ( ( ReaderRelation ) item ) ; break ; case ReaderElement . FILEHEADER : break ; default : throw new IllegalStateException ( "Unknown type " + item . getType ( ) ) ; } if ( ++ counter % 200_000_000 == 0 ) { LOGGER . info ( nf ( counter ) + ", locs:" + nf ( locations ) + " (" + skippedLocations + ") " + Helper . getMemInfo ( ) ) ; } } if ( in . getUnprocessedElements ( ) > 0 ) throw new IllegalStateException ( "Still unprocessed elements in reader queue " + in . getUnprocessedElements ( ) ) ; } catch ( Exception ex ) { throw new RuntimeException ( "Couldn't process file " + osmFile + ", error: " + ex . getMessage ( ) , ex ) ; } finishedReading ( ) ; if ( graph . getNodes ( ) == 0 ) throw new RuntimeException ( "Graph after reading OSM must not be empty. Read " + counter + " items and " + locations + " locations" ) ; }
Creates the graph with edges and nodes from the specified osm file.