如何与Java Geotools Lib查询多边形的范围?

发布于 2025-02-10 08:01:12 字数 257 浏览 3 评论 0原文

我有很多坐标点。现在,我在地图上画了一个多边形,并查询该范围内的点,例如美国的加油站。

“在此处输入图像说明”

我所有的数据都存储在arraylist中。我该如何通过Java Geotool Lib实现这一目标

List<Point> points = new ArrayList();

I have a lot of coordinate points. Now I draw a polygon on the map and query the points within this range, such as gas stations in the United States.

enter image description here

All my data is stored in ArrayList. How can I achieve this through java geotool lib

List<Point> points = new ArrayList();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倥絔 2025-02-17 08:01:12

this a>(在更相关的 https://gis.stackexchange.com 上)显示了几种可能以不同速度解决此问题的方法。它们都基本上是使用过滤器(从您的polygon构建的)来从数据存储中返回功能(您的点)的子集合。

因此,首先,我们需要一个点功能(加油站)的数据存储理想情况下,这将是一个启用空间的数据库(因此查询是在数据库中使用索引等),但是ShapeFile或CSV可以。如果您只有几百个记录或仅进行几次查询。

拥有数据存储后,您可以获得simpleFeatUrecollection,然后使用过滤器调用subcolection方法。

创建过滤器的简便方法是使用cql.tofilter方法,该方法采用类似的字符串:

Filter filter = CQL.toFilter("intersects(the_geom,"POLYGON((1 2, 2 4...,1 2")");

This answer (on the more relevant https://gis.stackexchange.com) shows several possible ways of solving this problem with different speeds. They all come down to basically using a filter (constructed from your Polygon) to return the subcollection of features (your points) from a datastore.

So first we need a DataStore of point features (Gas Stations) ideally this would be a spatially enabled database (so the query is done in the database with indexes etc), but a shapefile or CSV would be OK if you only have a few hundred records or are only doing the query a few times.

Once you have a datastore, you can get a SimpleFeatureCollection and then you call the subCollection method with your filter.

The easy way to create a Filter is to use the CQL.toFilter method which takes a string like:

Filter filter = CQL.toFilter("intersects(the_geom,"POLYGON((1 2, 2 4...,1 2")");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文