【问题标题】:How to find points within Polygon?如何在多边形内找到点?
【发布时间】:2019-10-04 09:47:28
【问题描述】:

我最近使用休眠空间,我有这样一个问题。我想得到多边形内的所有点。我该怎么做?

例如,我的距离查询看起来很简单:

    final Coordinates coordinates = Point.fromDegrees(searchDistanceParameters.getLatitude(), searchDistanceParameters.getLongitude());
    final Query fromCoordinates = SpatialQueryBuilderFromCoordinates.buildDistanceQuery(coordinates, searchDistanceParameters.getDistance(), "location");
    final FullTextSession fullTextSession = Search.getFullTextSession(session);
    final FullTextQuery textQuery = fullTextSession.createFullTextQuery(fromCoordinates, GeoPointModel.class);

我像这样创建一个多边形:

        GeometryFactory geometryFactory = new GeometryFactory();
        Polygon polygon = geometryFactory.createPolygon(coordinates);

但是我可以用什么来获取这个多边形内的点呢?

【问题讨论】:

    标签: hibernate hibernate-search hibernate-spatial


    【解决方案1】:

    Hibernate Search 5 的空间支持仅涵盖距离查询。不支持多边形内的匹配点。

    Hibernate Search 6 确实提供了a "within polygon" predicate,但是 Hibernate Search 6 中的 API 与 Search 5 中的 API 不同。 如果您对此感到满意,您可以使用最新的 Beta:http://hibernate.org/search/releases/6.0/。您可能想先看看getting started guide for Hibernate Search 6,以便在迁移之前了解新的API。

    如果您需要继续使用 Hibernate Search 5,则必须使用 lucene-spatial:按照 lucene-spatial 的预期实现到索引点的桥接,并直接使用 lucene-spatial API 生成 lucene-spatial 查询。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-24
      • 2018-02-28
      • 1970-01-01
      • 2015-03-06
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      • 1970-01-01
      相关资源
      最近更新 更多