Package org.neo4j.gis.spatial.rtree

Examples of org.neo4j.gis.spatial.rtree.Envelope


    } else if (filter instanceof AndImpl && inspectAndFilters) {
      AndImpl andFilter = (AndImpl) filter;
      Iterator children = andFilter.getFilterIterator();
      while (children.hasNext()) {
        Filter child = (Filter) children.next();
        Envelope result = extractEnvelopeFromFilter(child, false);
        if (result != null) {
          return result;
        }
      }
    }
View Full Code Here


      return null;
    }
  }
 
    private static Envelope extractEnvelopeFromBBox(BBOXImpl bbox) {
      return new Envelope(bbox.getMinX(), bbox.getMaxX(), bbox.getMinY(), bbox.getMaxY());
    }
View Full Code Here

    // TODO: Consider merits of using dependency data in target/osm,
    // downloaded by maven, as done in TestSpatial, versus the test data
    // commited to source code as done here
    printDatabaseStats();
    loadTestOsmData(osmFile, 1000);
    Envelope bbox = checkLayer(osmFile);
    printDatabaseStats();
    //bbox.expandBy(-0.1);
    bbox = scale(bbox, 0.2);

        // Define dynamic layers
        ArrayList<Layer> layers = new ArrayList<Layer>();
        try (Transaction tx = graphDb().beginTx()) {
            SpatialDatabaseService spatialService = new SpatialDatabaseService(graphDb());
            OSMLayer osmLayer = (OSMLayer) spatialService.getLayer(osmFile);
            LinearRing ring = osmLayer.getGeometryFactory().createLinearRing(
                    new Coordinate[] { new Coordinate(bbox.getMinX(), bbox.getMinY()), new Coordinate(bbox.getMinX(), bbox.getMaxY()),
                            new Coordinate(bbox.getMaxX(), bbox.getMaxY()), new Coordinate(bbox.getMaxX(), bbox.getMinY()),
                            new Coordinate(bbox.getMinX(), bbox.getMinY()) });
            Polygon polygon = osmLayer.getGeometryFactory().createPolygon(ring, null);
            layers.add(osmLayer.addLayerConfig("CQL1-highway", GTYPE_LINESTRING, "highway is not null and geometryType(the_geom) = 'LineString'"));
            layers.add(osmLayer.addLayerConfig("CQL2-residential", GTYPE_LINESTRING, "highway = 'residential' and geometryType(the_geom) = 'LineString'"));
            layers.add(osmLayer.addLayerConfig("CQL3-natural", GTYPE_POLYGON, "natural is not null and geometryType(the_geom) = 'Polygon'"));
            layers.add(osmLayer.addLayerConfig("CQL4-water", GTYPE_POLYGON, "natural = 'water' and geometryType(the_geom) = 'Polygon'"));
View Full Code Here

  }

  private Envelope scale(Envelope bbox, double fraction) {
    double xoff = bbox.getWidth() * (1.0 - fraction) / 2.0;
    double yoff = bbox.getHeight() * (1.0 - fraction)/ 2.0;
    return new Envelope(bbox.getMinX() + xoff, bbox.getMaxX() - xoff, bbox.getMinY() + yoff, bbox.getMaxY() - yoff);
  }
View Full Code Here

  private Envelope checkLayer(String layerName) {
    SpatialDatabaseService spatialService = new SpatialDatabaseService(graphDb());
    Layer layer = spatialService.getLayer(layerName);
    assertNotNull("Layer index should not be null", layer.getIndex());
    assertNotNull("Layer index envelope should not be null", layer.getIndex().getBoundingBox());
    Envelope bbox = layer.getIndex().getBoundingBox();
    System.out.println("Layer has bounding box: " + bbox);
    debugIndexTree((RTreeIndex) layer.getIndex());
    return bbox;
  }
View Full Code Here

                SpatialRecord record = layer.add(coordinate);
                assertNotNull(record);
            }
            saveLayerAsImage(layer, 700, 70);

            Envelope bbox = layer.getIndex().getBoundingBox();
            double[] centre = bbox.centre();

            List<GeoPipeFlow> results = GeoPipeline
                .startNearestNeighborLatLonSearch(layer, new Coordinate(centre[0] + 0.1, centre[1]), 10.0)
                .sort("OrthodromicDistance").toList();
View Full Code Here

        tx.success();
      }
    }
    saveLayerAsImage(layerA, 700, 70);
    saveLayerAsImage(layerB, 700, 70);
    Envelope bboxA = layerA.getIndex().getBoundingBox();
    Envelope bboxB = layerB.getIndex().getBoundingBox();
    double[] centreA = bboxA.centre();
    double[] centreB = bboxB.centre();

    List<SpatialDatabaseRecord> resultsA;
    List<SpatialDatabaseRecord> resultsB;
    try (Transaction tx = db.beginTx()) {
      resultsA = GeoPipeline.startNearestNeighborLatLonSearch(layerA,
View Full Code Here

                SpatialRecord record = layer.add(point);
                assertNotNull(record);
            }
            saveLayerAsImage(layer, 300, 300);

            Envelope bbox = layer.getIndex().getBoundingBox();
            double[] centre = bbox.centre();

            List<SpatialDatabaseRecord> results = GeoPipeline
                .startNearestNeighborLatLonSearch(layer, new Coordinate(centre[0], centre[1]), 10.0)
                .toSpatialDatabaseRecordList();
            saveResultsAsImage(results, "temporary-results-layer-" + layer.getName(), 150, 150);
View Full Code Here

            currentNodeTags.remove( "created_by" ); // redundant information
            // Nodes with tags get added to the index as point geometries
            if ( allPoints || currentNodeTags.size() > 0 )
            {
                Map<String, Object> nodeProps = getNodeProperties( currentNode );
                Envelope bbox = new Envelope();
                double[] location = new double[] {
                        (Double) nodeProps.get( "lon" ),
                        (Double) nodeProps.get( "lat" ) };
                bbox.expandToInclude( location[0], location[1] );
                addNodeGeometry( currentNode, GTYPE_POINT, bbox, 1 );
                poiCount++;
            }
            addNodeTags( currentNode, currentNodeTags, "node" );
        }
View Full Code Here

            {
                createRelationship( prev_way, way, OSMRelation.NEXT );
            }
            prev_way = way;
            addNodeTags( way, wayTags, "way" );
            Envelope bbox = new Envelope();
            T firstNode = null;
            T prevNode = null;
            T prevProxy = null;
            Map<String, Object> prevProps = null;
            LinkedHashMap<String, Object> relProps = new LinkedHashMap<String, Object>();
            HashMap<String, Object> directionProps = new HashMap<String, Object>();
            directionProps.put( "oneway", true );
            for ( long nd_ref : wayNodes )
            {
                // long pointNode =
                // batchIndexService.getSingleNode("node_osm_id", nd_ref);
                T pointNode = getOSMNode( nd_ref, changesetNode );
                if ( pointNode == null )
                {
                    /*
                     * This can happen if we import not whole planet, so some referenced
                     * nodes will be unavailable
                     */
                    missingNode( nd_ref );
                    continue;
                }
                T proxyNode = createProxyNode();
                if ( firstNode == null )
                {
                    firstNode = pointNode;
                }
                if ( prevNode == pointNode )
                {
                    continue;
                }
                createRelationship( proxyNode, pointNode, OSMRelation.NODE,
                        null );
                Map<String, Object> nodeProps = getNodeProperties( pointNode );
                double[] location = new double[] {
                        (Double) nodeProps.get( "lon" ),
                        (Double) nodeProps.get( "lat" ) };
                bbox.expandToInclude( location[0], location[1] );
                if ( prevProxy == null )
                {
                    createRelationship( way, proxyNode, OSMRelation.FIRST_NODE );
                }
                else
View Full Code Here

TOP

Related Classes of org.neo4j.gis.spatial.rtree.Envelope

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.