2

WKT ジオメトリが別のジオメトリと交差しているかどうかを (Cypher 経由で) チェックすることはできますか?

たとえば、それらに対して空間検索を行って、特定の境界ボックスと交差するものを返すにはどうすればよいでしょうか?

たとえば、空間的にインデックス付けされたノードがある場合:

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

およびそのような 2 つのインスタンス:

{ 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")

両方を返します。

誰か助けてくれませんか?

4

1 に答える 1

0

わかりました、おそらくここに質問に対する答えがあります。

neo4j-spatial コードを見ると、ファイル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 なぜ SearchIntersectWindow ではなく SearchWithin なのか?」に注目してください。プラグインの元の作成者も同様の考えを持っていたようです。

于 2015-01-09T20:59:10.153 に答える