GeoServer的WFS空间查询

在网上搜了很久,没有找到靠谱的代码,于是参考各种资料终于测试出其格式

点查询:

http://***:8060/geoserver/**/ows?service=WFS&request=GetFeature&version=1.0.0
    &typeName=图层服务名称&maxFeatures=2000&outputFormat=json&filter=
    <Filter xmlns="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml">
        <Intersects>
            <PropertyName>GEOM</PropertyName>
            <gml:Point>
                <gml:coordinates>113.8037,34.43554</gml:coordinates>
            </gml:Point>
        </Intersects>
    </Filter>

线查询:

http://***:8060/geoserver/**/ows?service=WFS&request=GetFeature&version=1.0.0
    &typeName=图层服务名称&maxFeatures=2000&outputFormat=json&filter=
    <Filter xmlns="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml">
        <Within>
            <PropertyName>GEOM</PropertyName>
            <gml:LineString>
		<gml:coordinates>113.763,34.435 113.763,34.5 113.844,34.5 113.844,34.435</gml:coordinates>
            </gml:LineString>
        </Within>
    </Filter>

面查询:

http://***:8060/geoserver/**/ows?service=WFS&request=GetFeature&version=1.0.0
	&typeName=图层服务名称&maxFeatures=2000&outputFormat=json&filter=
	<Filter xmlns="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml">
	<Intersects><PropertyName>GEOM</PropertyName><gml:Polygon>
		<gml:outerBoundaryIs>        
		    <gml:LinearRing>
			 	<gml:coordinates>113.763,34.435 113.763,34.5 113.763,34.435</gml:coordinates>
			</gml:LinearRing>
		</gml:outerBoundaryIs>
	</gml:Polygon></Intersects></Filter>

这里如果需要进行属性查询,可添加属性查询条件:

 var url = *** +'geoserver/**/ows?' 
            + 'service=WFS&request=GetFeature&version=1.0.0&typeName=图层服务名称&maxFeatures=1&outputFormat=json'
		+ '&FILTER=<Filter>' 
		+ '<And>'
		+ '<PropertyIsEqualTo><PropertyName>ST_NAME</PropertyName><Literal>' + stName + '</Literal></PropertyIsEqualTo>'
		+ '<PropertyIsEqualTo><PropertyName>NAME</PropertyName><Literal>' + setloc + '</Literal></PropertyIsEqualTo>' 
		+ '</And>'
<pre name="code" class="html">		<span style="font-family: Arial, Helvetica, sans-serif;">+ '</Filter>';</span>

转载自:https://blog.csdn.net/mengdong_zy/article/details/52171149

You may also like...