基于openlayer 与geoserver的 空间分析 获取图层属性

var point = new ol.geom.Point(ol.proj.fromLonLat([87.646 ,40.309], 'EPSG:4326'));
var lineT = new ol.geom.LineString([[87.646 ,40.309], [87.646 ,40.323],[87.6506 ,40.324]]);
var circleFeature = new ol.geom.Circle([87.646 ,40.309], 0.05);
var polygon = new ol.geom.Polygon.fromCircle(circleFeature); //圆转为多边形后才能进行分析
//多边形分析
var polygon = new ol.geom.Polygon([[
[84.03,40.74],
[87.37,40.72],
[86.24,39.78],
[84.03,40.74]
]]);

var featureRequest = new ol.format.WFS().writeGetFeature({
srsName: 'EPSG:4326',//坐标系统
featureNS: 'pg',//命名空间 URI
featurePrefix: 'pg',//工作区名称
featureTypes: ['pol_salt_v'],//查询图层,可以是同一个工作区下多个图层,逗号隔开
outputFormat: 'application/json',
//filter: ol.format.filter.intersects("geom",polygon)//前者是属性名,后者是对应值 单条件过滤
filter: ol.format.filter.and( //多条件过率
ol.format.filter.equalTo('at', '2020'),
ol.format.filter.intersects("geom", 点线面的要素)
)
});

fetch('http://192.168.0.164:5081/geoserver/' + 'wfs', {//geoserver wfs地址如localhost:8080/geoserver/wfs,
method: 'POST',
body: new XMLSerializer().serializeToString(featureRequest)
}).then(function(response) {
console.info(response);
console.info(response.json);
return response.json();
}).then(function(json) {
console.info(json);
var pro=json.features[0].properties;
console.info(pro);
}
上一篇:OpenLayer学习笔记——第一天


下一篇:游戏文字自动断行需要,还得从 UTF-8 讲起