1. Query
查询通过GeoServer发布的WFS服务的属性
1.1. query.geometryPolygonQuery(spatialUrl, layerName, geomType, polygon, callback)
执行空间面查询 geoserver的wfs
Param | Type | Description |
---|---|---|
spatialUrl | String |
wfs图层链接: 'http://192.168.1.249:16080/geoserver/jssthx/wfs?SERVICE=WFS&VERSION=1.1.1&REQUEST=GetFeature&outputformat=json' |
layerName | String |
查询的图层名称 |
geomType | String |
查询的空间字段 ogc_geom,the_geom,geom,shape具体查询图层的要素属性 |
polygon | String |
空间范围 'x1,y1 x2,y2 x3,y3 ... x1,y1' |
callback | Object |
异步查询结果回调函数,成功则传入查询的geojson数据 |
Example
let url ='http://geoserver-alpha.boswinner.com/BOSGeo/ows?service=WFS&version=1.0.0&request=GetFeature&outputformat=json';
let polygon = '113.1,23.3 113.5,23.9 113.8,23.8 113.1,23.3'
let getAttri =(result)=>{
console.log(result)
}
query.geometryPolygonQuery(url,'BOSGeo:futianFjsonD','geom',polygon,getAttri)
1.2. 方法
1.2.1. query.identifyQuery(spatialUrl, layerName, geomType, position, callback)
执行点击查询 geoserver的wfs
Param | Type | Description |
---|---|---|
spatialUrl | String |
wfs图层链接: 'http://192.168.1.249:16080/geoserver/jssthx/wfs?SERVICE=WFS&VERSION=1.1.1&REQUEST=GetFeature&outputformat=json' |
layerName | String |
查询的图层名称 |
geomType | String |
查询的空间字段,常用 ogc_geom,the_geom,geom, shape具体查询图层的要素属性,需根据wfs的url确定。 |
position | Object |
经纬度坐标{x:,y:} |
callback | Object |
查询结果回调函数,成功则传入查询的geojson数据 |
Example
let url ='http://geoserver-alpha.boswinner.com/BOSGeo/ows?service=WFS&version=1.0.0&request=GetFeature&outputformat=json';
let position = {x:114.091066,y:22.565284}
let getAttri =(result)=>{
console.log(result)
}
query.identifyQuery(url,'BOSGeo:futianFjsonD','geom',position,getAttri)
1.2.2. query.bBOXQuery(spatialUrl, layerName, geomType, range, callback)
执行BBOX查询 geoserver的wfs
Param | Type | Description |
---|---|---|
spatialUrl | String |
wfs图层链接: 'http://192.168.1.249:16080/geoserver/jssthx/wfs?SERVICE=WFS&VERSION=1.1.1&REQUEST=GetFeature&outputformat=json' |
layerName | String |
查询的图层名称 |
geomType | String |
查询的空间字段,常用 ogc_geom,the_geom,geom, shape具体查询图层的要素属性,需根据wfs的url确定。 |
range | Array |
空间四角坐标 { minx, miny, maxx, maxy } |
callback | Object |
查询结果回调函数,成功则传入查询的geojson数据 |
Example
let url ='http://geoserver-alpha.boswinner.com/BOSGeo/ows?service=WFS&version=1.0.0&request=GetFeature&outputformat=json';
let position = {x:114.091066,y:22.565284}
let range = [Number(position.x)-0.0000095,Number(position.y)-0.0000095,Number(position.x) + 0.0000095,Number(position.y) + 0.0000095]
let getAttri =(result)=>{
console.log(result)
}
query.bBOXQuery(url,'BOSGeo:futianFjsonD','geom',position,getAttri)
1.2.3. query.wfsQuery(spatialUrl, layerName, callback)
查询geoserver的wfs数据
Param | Type | Description |
---|---|---|
spatialUrl | String |
wfs图层链接: 'http://192.168.1.249:16080/geoserver/jssthx/wfs?SERVICE=WFS&VERSION=1.1.1&REQUEST=GetFeature&outputformat=json' |
layerName | String |
查询的图层名称 |
callback | Object |
查询结果回调函数,成功则传入查询的geojson数据 |
Example
let url ='http://geoserver-alpha.boswinner.com/BOSGeo/ows?service=WFS&version=1.0.0&request=GetFeature&outputformat=json';
let getAttri =(result)=>{
console.log(result)
}
query.wfsQuery(url,'BOSGeo:futianFjsonD',getAttri)
1.2.4. query.filterWfsQuery(spatialUrl, layerName, filter, callback)
基于条件查询geoserver的wfs数据
Param | Type | Description |
---|---|---|
spatialUrl | String |
wfs图层链接: 'http://192.168.1.249:16080/geoserver/jssthx/wfs?SERVICE=WFS&VERSION=1.1.1&REQUEST=GetFeature&outputformat=json' |
layerName | String |
查询的图层名称 |
filter | String |
filter为服务中所要查询的条件 |
callback | Object |
查询结果回调函数,成功则传入查询的geojson数据 |
Example
let url ='http://geoserver-alpha.boswinner.com/BOSGeo/ows?service=WFS&version=1.0.0&request=GetFeature&outputformat=json';
let position = {x:113.9,y:23.1}
let filter = `Filter=<Filter xmlns="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml"><FeatureId fid='futianFjsonD.266'></FeatureId></Filter>`
let getAttri =(result)=>{
console.log(result)
}
query.bBOXQuery(url,'BOSGeo:futianFjsonD',filter,getAttri)