将查询参数传递给mapserver中的查询语句

发布于 2024-10-08 13:06:19 字数 525 浏览 0 评论 0原文

我正在使用 mapserver 和 openlayers 来创建 GIS。

我正在使用 php 地图脚本,并且希望从 html 表单传递查询参数,以便只有满足查询的多边形才会在 WFS 图层中突出显示。

我是地图服务器、openlayers 的新手,也是 php 的新手,因此需要帮助来完成上述任务。

我在 php mapscript 的顶部看到以下内容:

$request = ms_newowsrequestobj();

foreach ($_GET as $k=>$v)  
 {$request->setParameter($k, $v);}  

我猜我可以用它来传递 url 上的一些变量。由于我使用的是表单,因此将改为 $_POST...对吗?

我有 2 个问题:

  1. 如何使用上面的代码将参数从 html 表单传递到地图脚本
  2. 然后如何将这些参数传递到查询语句?

希望我问的有道理

I am using mapserver and openlayers to create a GIS.

I am using a php mapscript and would like to pass the parameters for a query from a html form such that only the polygon(s) that satisfy the query are highlighted in a WFS layer.

I am a newbie with mapserver, openlayers and novice at php, so need help in trying to accomplish the above.

I see the following at the top of my php mapscript:

$request = ms_newowsrequestobj();

foreach ($_GET as $k=>$v)  
 {$request->setParameter($k, $v);}  

which I'm guessing I can use to pass some variables on the url. Since I'm using a form it'll be $_POST instead... Correct?

I have 2 questions:

  1. How do I use the above code to pass the parameters from a html form to the mapscript
  2. How do I then pass these to the query statement?

Hope what I'm asking makes sense

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

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

发布评论

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

评论(1

不爱素颜 2024-10-15 13:06:19

远离 MapScript 并直接使用 WFS 的 GetFeature 功能可能会更容易(也是更好的设计)。

您可以将过滤器传递到 WFS 图层(请参阅 http://mapserver.org/ogc/filter_encoding.html ),它可以返回与您的查询相对应的特征和属性。

确保您的 WFS 配置正确 - http:// /mapserver.org/ogc/wfs_server.html#configuring-your-mapfile-to-serve-wfs-layers

It may be easier (and a better design) to stay away from MapScript and use the GetFeature capabilities of WFS directly.

You can pass in a filter to the WFS layer (see http://mapserver.org/ogc/filter_encoding.html), and it can return the feature and attributes that correspond to your query.

Make sure your WFS is configured correctly - http://mapserver.org/ogc/wfs_server.html#configuring-your-mapfile-to-serve-wfs-layers

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文