搜索 JTS STR 树

Searching JTS STR tree

您好,我一直在学习本教程 http://googledevelopers.blogspot.com/2014/12/building-scalable-geofencing-api-on.html,这是我的问题,

我有一个经度和纬度坐标列表,我已将它们作为点添加到 JTS(Java 拓扑套件)STR 树中。

现在我想将一个圆形的区域发送到STR树,以找到落在圆形中的所有点。

    Coordinate center = new Coordinate(entity.getLongitude(), entity.getLatitude());
    GeometricShapeFactory gsf = new GeometricShapeFactory();

    gsf.setCentre(center);
    gsf.setNumPoints(20);
    **gsf.setSize(320.0);**
    Polygon poly = gsf.createCircle();
    Coordinate[] coordinates = poly.getCoordinates();


    //Create polygon from the coordinates.
    GeometryFactory fact = new GeometryFactory();

    LinearRing linear_ring = new GeometryFactory().createLinearRing(coordinates);

    Polygon polygon = new Polygon(linear_ring, null, fact);

    List<STRLeaf> items = strTree.query(polygon.getEnvelopeInternal());

然而搜索的结果返回的是经纬度树中所有的数据点。当我将圆圈的大小降低到 320 以下时,我不会从 STR 树的搜索中收到任何结果。有没有人有这方面的经验,理想情况下我想创建一个圆圈,在 ~7 英里的圆圈内找到所有点。

感谢您的宝贵时间

原来我在后端犯了一个愚蠢的错误。当我将项目添加到树中时,我混淆了 x 和 y 坐标,因此 Lat Longs 被颠倒了。切换后,我现在可以将圆的大小设置为 0.1 左右,效果很好。