【问题标题】:MapServer cgi-bin get value from query string and concatenate to Postgres queryMapServer cgi-bin 从查询字符串中获取值并连接到 Postgres 查询
【发布时间】:2012-06-18 06:53:44
【问题描述】:

我正在使用 cgi-bin,我展示了一张包含 Postgres 数据库中的一些数据的地图。

但是,我需要引入一个输入,用户可以在其中选择一个日期,这个日期将过滤数据库中的结果。

我有输入并通过 URL(get 方法)发送参数,但我不知道如何从 cgi-bin 查询字符串中获取此参数以及如何将参数的值连接到数据库查询。

这是地图文件的代码部分:

LAYER
DATA "the_geom from (select * from
  vista_puntos where date > <DATE_VAR_FROM_QUERY_STRING>) as subquery
  using unique id_valor using srid=4326"

【问题讨论】:

  • 你可能想研究 geomoose,因为它是一个集成了这种功能的框架......祝你好运!

标签: cgi mapserver map-files


【解决方案1】:

DATA中使用选择查询 之后使用 FILTER *MAPSERV* 为过滤器创建 Where 子句

示例

    DATA "geom from roads"
    FILTER "type='%road1%' or type='%road2%'"

        CLASS
            NAME "Road Type1"
            EXPRESSION ('[type]' = 'type1')
            STYLE
                SIZE 10
                COLOR 255 0 0 
            END
        END

        CLASS
            NAME "Road Type2"
            EXPRESSION ('[type]' = 'type2')
            STYLE
                SIZE 10
                COLOR 0 255 0
            END
        END

查询字符串格式如下:..mapserv.exe?map=mapfile&amp;road1=type1&amp;road2=type2

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多