2

有没有一种有效的方法可以使用 .net core 2.2 找到类型为 NetTopologySuite.Geometries.PointPolygon 的给定多边形内的 NetTopologySuite.Geometries.Point 类型的点。我尝试遵循以下文档,但没有运气:https ://nettopologysuite.github.io/html/class_net_topology_suite_1_1_algorithm_1_1_locate_1_1_indexed_point_in_area_locator.html#ad28b305b77c52327b7787ca8016c0fd7 。

4

1 回答 1

3

一对多谓词测试使用GeoAPI.Geometries.Prepared.IPreparedGeometry. 您可以使用NetTopologySuite.Geometries.Prepared.PreparedGeometryFactory.

private IList<IPoint> Contains(IGeometry geom, IEnumerable<IPoint> points) {
    var prepGeom = new NetTopologySuite.Geometries.Prepared.PreparedGeometryFactory().Prepare(geom);
    var res = new List<IPoint>();
    foreach(var point in points) {
        if (prepGeom.Contains(point)) res.Add(point);
    }
    return res;
}

在 GitHub 上查看问题

于 2018-12-18T19:30:30.927 回答