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();
}