Package org.neo4j.gis.spatial

Examples of org.neo4j.gis.spatial.SpatialDatabaseService


  public static void main(String[] args) {
    if (args.length < 4) {
      System.out.println("Usage: osmtoshp databasedir exportdir osmdataset layerspec <..layerspecs..>");
    } else {
      GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabase((new File(args[0])).getAbsolutePath());
      SpatialDatabaseService spatial = new SpatialDatabaseService(db);
      OSMLayer layer = (OSMLayer) spatial.getLayer(args[2]);
      if (layer != null) {
        ShapefileExporter exporter = new ShapefileExporter(db);
        exporter.setExportDir(args[1]+File.separator+layer.getName());
        for (int i = 3; i < args.length; i++) {
          String[] fields = args[i].split("[\\.\\-]");
View Full Code Here


    public ImportData() {
        // Create the graph db
        graphDb = new EmbeddedGraphDatabase("var/geo");
        // Wrap it as a spatial db service
        spatialDb = new SpatialDatabaseService(graphDb);
        // Create the layer to store our spatial data
        runningLayer = (EditableLayer) spatialDb.getOrCreateLayer("running", SimplePointEncoder.class, EditableLayerImpl.class, "lon:lat");
    }
View Full Code Here

        }
    }

    private static void load() throws Exception
    {
        SpatialDatabaseService spatialService = new SpatialDatabaseService( db );

        try (Transaction tx = db.beginTx()) {
            loadTestOsmData( "two-street.osm", 100 );
            osmLayer = spatialService.getLayer( "two-street.osm" );
       
          boxesLayer = (EditableLayerImpl) spatialService.getOrCreateEditableLayer( "boxes" );
          boxesLayer.setExtraPropertyNames( new String[] { "name" } );
          boxesLayer.setCoordinateReferenceSystem(DefaultEngineeringCRS.GENERIC_2D);
          WKTReader reader = new WKTReader( boxesLayer.getGeometryFactory() );
          boxesLayer.add(
                  reader.read( "POLYGON ((12 26, 12 27, 13 27, 13 26, 12 26))" ),
                  new String[] { "name" }, new Object[] { "A" } );
          boxesLayer.add( reader.read( "POLYGON ((2 3, 2 5, 6 5, 6 3, 2 3))" ),
                  new String[] { "name" }, new Object[] { "B" } );
 
          concaveLayer = (EditableLayerImpl) spatialService.getOrCreateEditableLayer( "concave" );
          concaveLayer.setCoordinateReferenceSystem(DefaultEngineeringCRS.GENERIC_2D);
          reader = new WKTReader( concaveLayer.getGeometryFactory() );
          concaveLayer.add( reader.read( "POLYGON ((0 0, 2 5, 0 10, 10 10, 10 0, 0 0))" ) );
 
          intersectionLayer = (EditableLayerImpl) spatialService.getOrCreateEditableLayer( "intersection" );
          intersectionLayer.setCoordinateReferenceSystem(DefaultEngineeringCRS.GENERIC_2D);
          reader = new WKTReader( intersectionLayer.getGeometryFactory() );
          intersectionLayer.add( reader.read( "POLYGON ((0 0, 0 5, 5 5, 5 0, 0 0))" ) );
          intersectionLayer.add( reader.read( "POLYGON ((4 4, 4 10, 10 10, 10 4, 4 4))" ) );
          intersectionLayer.add( reader.read( "POLYGON ((2 2, 2 6, 6 6, 6 2, 2 2))" ) );
 
          equalLayer = (EditableLayerImpl) spatialService.getOrCreateEditableLayer( "equal" );
          equalLayer.setExtraPropertyNames( new String[] { "id", "name" } );
          equalLayer.setCoordinateReferenceSystem(DefaultEngineeringCRS.GENERIC_2D);         
          reader = new WKTReader( intersectionLayer.getGeometryFactory() );
          equalLayer.add( reader.read( "POLYGON ((0 0, 0 5, 5 5, 5 0, 0 0))" ),
                  new String[] { "id", "name" }, new Object[] { 1, "equal" } );
          equalLayer.add( reader.read( "POLYGON ((0 0, 0.1 5, 5 5, 5 0, 0 0))" ),
                  new String[] { "id", "name" }, new Object[] { 2, "tolerance" } );
          equalLayer.add( reader.read( "POLYGON ((0 5, 5 5, 5 0, 0 0, 0 5))" ),
                  new String[] { "id", "name" }, new Object[] { 3,
                          "different order" } );
          equalLayer.add(
                  reader.read( "POLYGON ((0 0, 0 2, 0 4, 0 5, 5 5, 5 3, 5 2, 5 0, 0 0))" ),
                  new String[] { "id", "name" }, new Object[] { 4, "topo equal" } );

          linesLayer = (EditableLayerImpl) spatialService.getOrCreateEditableLayer( "lines" );
          linesLayer.setCoordinateReferenceSystem(DefaultEngineeringCRS.GENERIC_2D);         
          reader = new WKTReader( intersectionLayer.getGeometryFactory() );
          linesLayer.add( reader.read( "LINESTRING (12 26, 15 27, 18 32, 20 38, 23 34)" ) );
         
          tx.success();
View Full Code Here

  }

  private void loadSamplePointData() {
    Transaction tx = graphDb().beginTx();
    try {
      SpatialDatabaseService spatial = new SpatialDatabaseService(graphDb());
      SimplePointLayer layer = spatial.createSimplePointLayer("GeoPipesPerformanceTest");
      System.out.println("Creating database of " + records + " point records");
      for (int i = 0; i < records; i++) {
        double x = 10.0 + Math.random() * 10.0;
        double y = 10.0 + Math.random() * 10.0;
        String name = "Fake Geometry " + i;
View Full Code Here

    }
  }

  @Test
  public void testQueryPerformance() {
    SpatialDatabaseService spatial = new SpatialDatabaseService(graphDb());
        try (Transaction tx = graphDb().beginTx()) {
            Layer layer = spatial.getLayer("GeoPipesPerformanceTest");
            // String[] keys = {"id","name","address","city","state","zip"};
            String[] keys = { "id", "name" };
            Coordinate loc = new Coordinate(15.0, 15.0);
            GeoPipeline flowList = ((GeoPipeline) GeoPipeline.startNearestNeighborLatLonSearch(layer, loc, records))
                    .copyDatabaseRecordProperties(keys);
View Full Code Here

        }
  }

  @Test
  public void testPagingPerformance() {
    SpatialDatabaseService spatial = new SpatialDatabaseService(graphDb());
        try (Transaction tx = graphDb().beginTx()) {
            Layer layer = spatial.getLayer("GeoPipesPerformanceTest");
            // String[] keys = {"id","name","address","city","state","zip"};
            String[] keys = { "id", "name" };
            Coordinate loc = new Coordinate(15.0, 15.0);
            ArrayList<TimeRecord> totals = new ArrayList<TimeRecord>();
            long prevTime = System.currentTimeMillis();
View Full Code Here

    {
        this.layerName = indexName;
        this.db = db;
        this.nodeLookupIndexName = indexName + "__neo4j-spatial__LayerNodeIndex__internal__spatialNodeLookup__";
        this.idLookup = db.index().forNodes(nodeLookupIndexName);
        spatialDB = new SpatialDatabaseService( this.db );
        if ( config.containsKey( SpatialIndexProvider.GEOMETRY_TYPE )
             && POINT_GEOMETRY_TYPE.equals(config.get( SpatialIndexProvider.GEOMETRY_TYPE ))
             && config.containsKey( LayerNodeIndex.LAT_PROPERTY_KEY )
             && config.containsKey( LayerNodeIndex.LON_PROPERTY_KEY ) )
        {
View Full Code Here

        System.out.println( "Re-indexing with GraphDatabaseService: "
                            + database + " (class: " + database.getClass()
                            + ")" );

        setLogContext( "Index" );
        SpatialDatabaseService spatialDatabase = new SpatialDatabaseService(
                database );
        OSMLayer layer = (OSMLayer) spatialDatabase.getOrCreateLayer(
                layerName, OSMGeometryEncoder.class, OSMLayer.class );
        // TODO: The next line creates the relationship between the dataset and
        // layer, but this seems more like a side-effect and should be done
        // explicitly
        OSMDataset dataset = layer.getDataset( osm_dataset );
View Full Code Here

 
  public Neo4jSpatialDataStore(GraphDatabaseService database) {
    super(true);
   
    this.database = database;
        this.spatialDatabase = new SpatialDatabaseService(database);
  }
View Full Code Here

TOP

Related Classes of org.neo4j.gis.spatial.SpatialDatabaseService

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.