我试图通过在geoserver中使用WFS GetFeature来获取一些按日期以GML格式过滤的数据,但操作忽略了time参数,只返回包含所有数据的巨大GML文件。 这是我正在使用的查询:
http://localhost:8082/geoserver/it.geosolutions/ows?service=WFS&version=1.2.0&request=GetFeature&typeName=it.geosolutions:tsige&time=2011-07-25T00:00:00.0Z/2011-07-25T23:59:59.999Z
根据this,在WFS GetFeature操作中应该支持time参数,所以我不知道出了什么问题。 另外,我有什么方法可以用XML或JSON格式或其他一些易于解析的格式来按时间过滤数据?
答案 0 :(得分:4)
并非所有供应商实施都支持所有参数,这是使用OGC服务的乐趣之一。另请注意,GeoServer实现了WFS 1.0.0,1.1.0和2.0.0(在上面的示例中不是1.2.0)
你可以使用OGC过滤器使用(相对详细的)POST请求做你想做的事情,这可能适用于GET,但我会把它作为读者练习......
<wfs:GetFeature
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:gml="http://www.opengis.net/gml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:ows="http://www.opengis.net/ows"
xmlns:wfs="http://www.opengis.net/wfs"
xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"
service="WFS" version="1.1.0" outputFormat="JSON">
<wfs:Query typeName="it.geosolutions:tsige" srsName="EPSG:4326">
<ogc:Filter>
<ogc:And>
<ogc:PropertyIsGreaterThanOrEqualTo>
<ogc:PropertyName>your-time-variabe-here</ogc:PropertyName>
<ogc:Function name="dateParse">
<ogc:Literal>yyyy-MM-dd</ogc:Literal>
<ogc:Literal>2011-07-25</ogc:Literal>
</ogc:Function>
</ogc:PropertyIsGreaterThanOrEqualTo>
<ogc:PropertyIsLessThan>
<ogc:PropertyName>your-time-variable-here</ogc:PropertyName>
<ogc:Function name="dateParse">
<ogc:Literal>yyyy-MM-dd</ogc:Literal>
<ogc:Literal>2011-07-26</ogc:Literal>
</ogc:Function>
</ogc:PropertyIsLessThan>
</ogc:And>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>
您可以使用curl对此进行测试,请求保存为wfs.xml
curl -d @wfs.xml -H "Content-Type: application/xml" "http://localhost:8082/geoserver/it.geosolutions/ows"