Js调用GeoServer的wfs服务

最近开发关于wfs做空间查询的功能,网上资料有限,便整理了一下:

1.访问方式:直接通过ajax的get/post方式进行调用
    	
	var options = {
       		typename:'geo:cimmunication_manhole4326',//查询的服务图层名称
        	filter:FILTER//查询条件
        	callback:'getIdentifyroadGrid'//查询的回调函数,jsonp调用
    	};


	
	$.ajax('http://localhost:8060/geoserver/wfs',{
        	type: 'GET',
        	data: {
           		service: 'WFS',
            		version: '1.0.0',
            		request: 'GetFeature',
            		typename: options.typename,
            		outputFormat: 'json',
            		filter:options.filter
        	},
        	dataType: 'json',
        	success: function(res){
		    console.log('点击查询返回的结果如下:');
		    console.log(res);
        	}
   	});


2.条件过滤,WFS的主要查询过程就是FILTER的拼接,下面是面查询的filter

	
var 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>126.50070190429688,43.85656387037449 126.50070190429688,43.810004052427985 126.68197631835939,43.810004052427985 126.68197631835939,43.85656387037449 126.50070190429688,43.85656387037449</gml:coordinates>'+
				'</gml:LinearRing>'+
				'</gml:outerBoundaryIs></gml:Polygon>'+
				'</Intersects></Filter>';


属性查询
	
var FILTER=<Filter>'   
    		 + '<And>'  
   		 + '<PropertyIsEqualTo><PropertyName>NAME</PropertyName><Literal>测试</Literal></PropertyIsEqualTo>'   
   		 + '</And></Filter>'



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值