Package org.neo4j.gis.spatial.osm

Examples of org.neo4j.gis.spatial.osm.OSMImporter


    assertTrue("Start way should be most found way", way.equals(osm.getWayFromId(mostCommon)));
  }

  private void importMapOSM() throws Exception {
    // START SNIPPET: importOsm
    OSMImporter importer = new OSMImporter("map.osm");
    importer.setCharset(Charset.forName("UTF-8"));
    BatchInserter batchInserter = BatchInserters.inserter(databasePath);
    importer.importFile(batchInserter, "map.osm", false);
    batchInserter.shutdown();

    GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabase(databasePath);
    importer.reIndex(db);
    db.shutdown();
    // END SNIPPET: importOsm
  }
View Full Code Here


            throws Exception
    {
        String osmPath = "./" + layerName;
        System.out.println( "\n=== Loading layer " + layerName + " from "
                            + osmPath + " ===" );
        OSMImporter importer = new OSMImporter( layerName );
        importer.setCharset( Charset.forName( "UTF-8" ) );
        importer.importFile( db, osmPath );
        importer.reIndex( db, commitInterval );
    }
View Full Code Here

    private void loadTestOsmData(String layerName, int commitInterval, boolean useBatch) throws Exception {
        String osmPath = OSM_DIR + File.separator + layerName;
        System.out.println("\n=== Loading layer " + layerName + " from " + osmPath + " ===");
        reActivateDatabase(false, useBatch, false);
        OSMImporter importer = new OSMImporter(layerName);
    importer.setCharset(Charset.forName("UTF-8"));
        if (useBatch) {
          importer.importFile(getBatchInserter(), osmPath);
          reActivateDatabase(false, false, false);
        } else {
            importer.importFile(graphDb(), osmPath);
            reActivateDatabase(false, false, false);
        }
        importer.reIndex(graphDb(), commitInterval);
    }
View Full Code Here

  private void loadTestOsmData(String layerName, int commitInterval) throws Exception {
    String osmPath = layerName;
    System.out.println("\n=== Loading layer " + layerName + " from " + osmPath + " ===");
    reActivateDatabase(false, true, false);
    OSMImporter importer = new OSMImporter(layerName);
    importer.setCharset(Charset.forName("UTF-8"));
    importer.importFile(getBatchInserter(), osmPath, false);
    reActivateDatabase(false, false, false);
    importer.reIndex(graphDb(), commitInterval);
  }
View Full Code Here

  private void loadTestOsmData(String layerName, int commitInterval) throws Exception {
    String osmPath = layerName;
    System.out.println("\n=== Loading layer " + layerName + " from " + osmPath + " ===");
    reActivateDatabase(false, true, false);
    OSMImporter importer = new OSMImporter(layerName);
    importer.setCharset(Charset.forName("UTF-8"));
    importer.importFile(getBatchInserter(), osmPath);
    reActivateDatabase(false, false, false);
    importer.reIndex(graphDb(), commitInterval);
  }
View Full Code Here

    filterEnvelope.expandToInclude(new Coordinate(-71.70, 42.50));
    return filterEnvelope;
  }
 
  private void importOSMDatabase(String osmPath, String dbPath, String layerName) throws ParseException, IOException, XMLStreamException, InterruptedException {
    OSMImporter importer = new OSMImporter(layerName, new ConsoleListener(), makeFilterEnvelope());
    importer.setCharset(Charset.forName("UTF-8"));
        BatchInserter batchInserter = BatchInserters.inserter(dbPath, Neo4jTestCase.LARGE_CONFIG);
        //GraphDatabaseService graphDb = batchInserter.getGraphDbService();
    //importer.importFile(graphDb, osmPath, false, 10000, true);
    importer.importFile(batchInserter, osmPath, false);
    batchInserter.shutdown();
    //graphDb.shutdown();
    // Weird hack to force GC on large loads
    long start = System.currentTimeMillis();
    if (System.currentTimeMillis() - start > 300000) {
      for (int i = 0; i < 3; i++) {
        System.gc();
        Thread.sleep(1000);
      }
    }
    GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(dbPath).setConfig(Neo4jTestCase.LARGE_CONFIG ).newGraphDatabase();
    importer.reIndex(graphDb, 10000, false, false);
    TestOSMImport.checkOSMLayer(graphDb, layerName);
    graphDb.shutdown();
  }
View Full Code Here

TOP

Related Classes of org.neo4j.gis.spatial.osm.OSMImporter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.