2015-01-09 1 views
2

WKT 지오메트리가 다른 지오메트리와 교차하는지 (Cypher를 통해) 확인할 수 있습니까?사이퍼를 통한 교차점 일치?

예를 들어 주어진 경계 상자와 교차하는 것을 반환하기 위해 어떻게 공간 검색을 수행 할 수 있습니까?

@NodeEntity 
class Route { 
    @GraphId Long id; 
    @Indexed(indexType = IndexType.POINT, indexName = "routeSpatial") String wkt 
} 

두 이러한 경우 : 나는 공간 인덱스 노드가있는 경우 예를 들어

,

{ wkt: "LINESTRING (12 10, 14 12, 17 12, 18 10) } 

{ wkt: LINESTRING (18 15, 18 12, 14 9, 14 6, 17 3, 20 3) } 

그것을 그 나타납니다

@Query("START n=node:routeSpatial('bbox:[15.000000, 20.000000, 9.000000, 16.000000]') RETURN n") 

두 줄과 교차하는 경우에도 아무 것도 반환하지 않습니다.

경계 상자가 완전히 두 기하학,

@Query("START n=node:routeSpatial('bbox:[7.000000, 24.000000, 2.000000, 17.000000]') RETURN n") 

반환을 모두 주변 반면.

누군가 나를 도와 줄 수 있습니까?

답변

0

좋아, 아마도 여기에 질문에 대한 답변이 있습니다. neo4j - 공간 코드에서 찾고

, 우리는 SpatialPlugin.java

@PluginTarget(GraphDatabaseService.class) 
@Description("search a layer for geometries in a bounding box. To achieve more complex CQL searches, pre-define the dynamic layer with addCQLDynamicLayer.") 
public Iterable<Node> findGeometriesInBBox(
     @Source GraphDatabaseService db, 
     @Description("The minimum x value of the bounding box") @Parameter(name = "minx") double minx, 
     @Description("The maximum x value of the bounding box") @Parameter(name = "maxx") double maxx, 
     @Description("The minimum y value of the bounding box") @Parameter(name = "miny") double miny, 
     @Description("The maximum y value of the bounding box") @Parameter(name = "maxy") double maxy, 
     @Description("The layer to search. Can be a dynamic layer with pre-defined CQL filter.") @Parameter(name = "layer") String layerName) { 
// System.out.println("Finding Geometries in layer '" + layerName + "'"); 
    SpatialDatabaseService spatialService = getSpatialDatabaseService(db); 

    try (Transaction tx = db.beginTx()) { 

     Layer layer = spatialService.getDynamicLayer(layerName); 
     if (layer == null) { 
      layer = spatialService.getLayer(layerName); 
     } 
     // TODO why a SearchWithin and not a SearchIntersectWindow? 

     List<Node> result = GeoPipeline 
       .startWithinSearch(layer, layer.getGeometryFactory().toGeometry(new Envelope(minx, maxx, miny, maxy))) 
       .toNodeList(); 
     tx.success(); 
     return result; 
    } 
} 

주의 사항 파일에 다음 찾아 "TODO가 왜 SearchWithin 아닌 SearchIntersectWindow?". 플러그인의 원래 작성자가 비슷한 생각을 갖고있는 것처럼 보입니다.