Examples of OsmImporter


Examples of com.eugeneborshch.routecalculator.load.OsmImporter

        //Init Neo4j database
        GraphDatabaseService db = new EmbeddedGraphDatabase(NEO4J_FOLDER);


        //Import OSM data into the Neo4j database
        new OsmImporter(db).importXML(OSM_MAP);


        //Optimize previously loaded database
        GlobalGraphOperations graphOperations = GlobalGraphOperations.at(db);
        System.out.printf("BEFORE OPTIMIZE nodes =  %d  ways = %d  \n", nodesCount(graphOperations), relCount(graphOperations));
View Full Code Here

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

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

            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

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

    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

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

  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

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

  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

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

    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

Examples of org.openstreetmap.josm.io.OsmImporter

            String fileStr = (String) fileExp.evaluate(elem, XPathConstants.STRING);
            if (fileStr == null || fileStr.isEmpty()) {
                throw new IllegalDataException(tr("File name expected for layer no. {0}", support.getLayerIndex()));
            }

            OsmImporter importer = new OsmImporter();
            try (InputStream in = support.getInputStream(fileStr)) {
                OsmImporter.OsmImporterData importData = importer.loadLayer(in, support.getFile(fileStr), support.getLayerName(), progressMonitor);

                support.addPostLayersTask(importData.getPostLayerTask());
                return importData.getLayer();
            }
        } catch (XPathExpressionException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.