Geoserver-使用DWITHIN过滤点 [英] Geoserver - filtering points using DWITHIN

查看:712
本文介绍了Geoserver-使用DWITHIN过滤点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我是Geoserver和Openlayers的新手.我一直在尝试使用图层预览"页面在Geoserver端进行此工作,以使用Openlayer查看器查看我的图层.最后,我将其实现为Openlayers WFS GET请求.

First of all I am new to Geoserver and Openlayers. I have been trying to get this working on the Geoserver side using the Layer preview page to view my layer using the Openlayer viewer. I would be implementing it as an Openlayers WFS GET request in the end.

我要完成的工作是返回在不同点之间一定距离内的特征. (即距学校5公里以内)

What I am trying to accomplish is to return features that are within a certain distance of different points. (ie. within 5km of a school)

我正在使用Geoserver上的图层预览"页面.我添加了"DWITHIN(GEOM,POINT(-60.2 46.1),0.05,km)"的CQL过滤器.它限制了返回的点数,但是我不确定它是否正确过滤.

I am using the Layer preview page on Geoserver . I have added the CQL filter of "DWITHIN(GEOM, POINT(-60.2 46.1), 0.05, kilometers)". It has limited the amount of points that were returned but I am unsure if it is filtering correctly.

我的问题如下:

  1. 根据我的理解,由于存在此错误, http://jira.codehaus.org/browse/GEOS -937 我必须为我的单位使用度.如何在客户端使用javascript/openlayers 3进行转换以将5km转换为度值?
  2. 我可以添加多个DWITHIN过滤器来说明某个点是否在一个点的5公里之内,而在另一个点的10公里之内吗?
  3. 我可以基于特征类型进行过滤吗?即返回点,距离学校5公里,距离医院10公里
  1. From my understanding because of this bug http://jira.codehaus.org/browse/GEOS-937 I have to use degrees for my unit. How can I convert on client side using javascript/openlayers 3 to change 5km into a degree value?
  2. Can I add multiple DWITHIN filters to say if a point is within 5km of one point and 10km of another?
  3. Can I filter based off feature type? ie return point within 5km of a School AND 10km of a Hospital

推荐答案

花了一些时间之后,我才能回答自己的问题.

After spending some time with this I was able to answer my own question.

首先,我进行了一些搜索,确定大约为1度= 111.325公里. https://answers.yahoo.com/question/index?qid=20060905051639AAWGjH9

First of all doing some searching I determined 1 degree = 111.325 kms approximately. https://answers.yahoo.com/question/index?qid=20060905051639AAWGjH9

要添加多个DWITHIN过滤器,您要做的就是在每个过滤器之间添加一个AND.如果它是WFS格式,则可能必须添加%20AND%20,以便包含空格.

To add multiple DWITHIN filters all you have to do is add an AND between each one. If it is in the WFS format you may have to add %20AND%20 so the spaces are included.

要对某个位置进行DWITHIN,您需要将以下内容附加到wfs中.该点是经度/纬度,0.05是与该点的度数,千米是传入的单位.使用geoserver时,默认为度数作为原始问题状态中的链接.

To do a DWITHIN of a certain location you would append the following to your wfs. The point is the long/lat, 0.05 is the degrees from the point, kilometers is the unit that is passed in. When using geoserver it will default to degrees as the link in the original question states.

&CQL_FILTER=DWITHIN(GEOM,Point(-60.2 46.1),0.05,kilometers)

这将返回WFS图层中位于指定点度范围内的所有要素.

This will return any of the features from your WFS layer that are within the degrees of the point specified.

要过滤掉另一层,我使用了以下URL中的信息:

To filter off of another layer I used info from the following URL http://docs.geoserver.org/2.6.x/en/user/extensions/querylayer/index.html

请确保您必须在链接状态下将正确的querylayer模块安装到您的Geoserer版本中.

Firs you must install the proper querylayer module to your version of Geoserer as the link states.

要基于功能名称进行过滤,我使用了以下CQL_filter:

To do the filter based of feature name I used the following CQL_filter:

&CQL_FILTER=DWITHIN(GEOM,collectGeometries(queryCollection('Workspace:AssetLayer','GEOM','AssetTypeID=1')),
 .02,kilometers%29

这将返回您请求的WFS图层中位于"Workspace:AssetLayer"图层中AssetID为1的要素指定范围内的所有要素.

This will return any features from the WFS layer you are requesting that are within the degrees specified of a feature with the AssetID of 1 from the layer 'Workspace:AssetLayer'.

例如,如果学校的AssetTypeID为1,则将从"Workspace:AssetLayer"层上的学校返回0.02度以内的原始图层中的所有要素.

ie if school had an AssetTypeID of 1, this would return all features from the original layer that were within 0.02 degrees of a school on the 'Workspace:AssetLayer' layer.

"GEOM"值应为在SQL中保存几何数据的列的名称.

The "GEOM" value should be the name of column that holds your geometry data in SQL.

此外,我在CQL_Filter%29"中编码了最后一个括号,因为我发现通过openlayers发出请求时,它正在剥离该请求.

Also, I encoded the last parenthesis in the CQL_Filter "%29" because I found when making the request through openlayers it was stripping it off.

正如我所说的,我是openlayers/geoserver的新手,所以这在每种情况下可能都行不通,但这就是我想出的方式.我认为在不同的预测中可能会有一些变化.希望这能使您走上正确的轨道.

As I said I am new to openlayers/geoserver so this may not work in every case but this is how I figured it out. I am thinking in different projections there may be some changes. Hope this can get you on the right track.

这篇关于Geoserver-使用DWITHIN过滤点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆