首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Openlayers4中Geoserver WPS的显示光栅结果

Openlayers4中Geoserver WPS的显示光栅结果
EN

Stack Overflow用户
提问于 2018-05-17 09:15:08
回答 1查看 694关注 0票数 2

对于交互式web应用程序,我使用Open层4.6.5Geoserver 2.13.0

希望通过使用Geoserver WPS对用户选择的输入数据点启用动态处理。我已经用来自SourceForge的统计软件包扩展了WPS功能,并希望对所选点的集合运行KernelDensity分析。KernelDensity处理的结果将在我的地图中显示为光栅层。

我正在使用Javascript的提取功能向WPS发送一个请求。

代码语言:javascript
复制
<wps:Execute version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wfs="http://www.opengis.net/wfs" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd"><ows:Identifier>statistics:KernelDensity</ows:Identifier><wps:DataInputs><wps:Input><ows:Identifier>inputFeatures</ows:Identifier><wps:Data><wps:ComplexData mimeType="application/json"><![CDATA[{"type":"FeatureCollection","totalFeatures":2,"features":[{"type":"Feature","id":"alllocations.fid-57f369ef_1636c6c3947_-5ddb","geometry":{"type":"Point","coordinates":[100.330936,5.41626549]},"geometry_name":"geom","properties":{"idstorylocation":344,"idstory":27,"story":"HOUN","idlocation":203,"location_role":"reference","actions":"The walking stick left behind by young Dr Mortimer is of the sort which is called \"Penang Lawyer\".","name":"Penang ","country_today":"Malaysia","reference_to":"city","reality":"real","certainty":"good","accuracy":"high","county":"","state_country":"","city":"Penang","idcountry":298,"idpoints":99,"idperson":40,"initial":null,"lastname":"Mortimer","firstname":"James","nationality":null}},{"type":"Feature","id":"alllocations.fid-57f369ef_1636c6c3947_-5dda","geometry":{"type":"Point","coordinates":[100.330936,5.41626549]},"geometry_name":"geom","properties":{"idstorylocation":1519,"idstory":15,"story":"SILV","idlocation":203,"location_role":"reference","actions":"The stick of Fitzroy Simpson, which was a Penang-lawyer weighted with lead, was was just such a weapon as might, by repeated blows, have inflicted the terrible injuries to which the trainer had succumbed. ","name":"Penang ","country_today":"Malaysia","reference_to":"city","reality":"real","certainty":"good","accuracy":"high","county":"","state_country":"","city":"Penang","idcountry":298,"idpoints":99,"idperson":0,"initial":null,"lastname":null,"firstname":null,"nationality":null}}],"crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG::4326"}}}]]></wps:ComplexData></wps:Data></wps:Input><wps:Input><ows:Identifier>kernelType</ows:Identifier><wps:Data><LiteralData>Quadratic</LiteralData></wps:Data></wps:Input><wps:Input><ows:Identifier>populationField</ows:Identifier><wps:Data><wps:LiteralData>icount</wps:LiteralData></wps:Data></wps:Input><wps:Input><ows:Identifier>searchRadius</ows:Identifier><wps:Data><wps:LiteralData>5</wps:LiteralData></wps:Data></wps:Input><wps:Input><ows:Identifier>cellSize</ows:Identifier><wps:Data><wps:LiteralData>20</wps:LiteralData></wps:Data></wps:Input><wps:Input><ows:Identifier>extent</ows:Identifier><wps:Data><wps:BoundingBoxData crs="EPSG:4326" dimension="2"><ows:LowerCorner>-180.0 -90.0</ows:LowerCorner><ows:UpperCorner>180.0 90.0</ows:UpperCorner></wps:BoundingBoxData></wps:Data></wps:Input></wps:DataInputs><wps:ResponseForm><wps:RawDataOutput mimeType="image/tiff"><ows:Identifier>result</ows:Identifier></wps:RawDataOutput></wps:ResponseForm></wps:Execute>

输入jsonstring是收集的事件从选定的点数据,输出应该是图像/tiff

然而,我不知道如何将a)从响应中获取光栅,以及( b)光栅作为图层进入我的地图.

代码语言:javascript
复制
function calculateKernelDensity(jsonstring){

xml = createKernelDensityRequest(jsonstring);

fetch('http://localhost:8080/geoserver/Sherlock/wps', {
    method: 'POST',
    body: xml
})
// tried my luck with blob to use it later on as image layer
.then(function(response){
    var blob = response.blob(); 
    return blob;
})
.then(function(blob){
    console.log(blob.size + " " + blob.type);
});
// something here to put it as layer into the map...
};  

对于基于向量的请求(collectEvents、convexHull),我做了一件非常类似的事情,并将response.json作为矢量特性添加到地图中,这很好:

代码语言:javascript
复制
function collectEvents(jsonstring){

xml = createCollectEventsRequest(jsonstring);

fetch('http://localhost:8080/geoserver/Sherlock/wps',{
    method: 'POST',
    body: xml
})
.then(function(response){
    jsonresults = response.json();
    return jsonresults;
})
.then(function(jsonresults){
    jsonstring = JSON.stringify(jsonresults);
    results = new ol.format.GeoJSON({geometryName:'geom'}).readFeatures(jsonresults,{
        dataProjection: 'EPSG:4326',
        featureProjection: 'EPSG:3857'
    });
    vectorSource.clear(results);
    vectorSource.addFeatures(results);
});
};

我找不到任何关于OpenLayers 4的好文档,也找不到如何与Geoserver一起使用它。API文档对于使用Raster和Image资源也没有任何帮助。我确实了解ol.source.ImageWMS,但是由于我试图动态地生成和显示光栅,而不是从WMS中检索光栅,所以这里没有选择。

有没有办法从WPS中获取生成的光栅图像并在OpenLayers地图上显示?

EN

回答 1

Stack Overflow用户

发布于 2018-05-18 12:18:57

这个问题的回答来看,不可能在OpenLayers中直接显示GeoTiff,因为它使用浏览器的本机显示功能来进行显示。

可能对您有用的一个选项是将WPS输出保存到GeoServer,然后使用WMS请求获取结果。在GeoS卷积的WPS训练中有一个如何做到这一点的例子。这个回答也为此目的提到了StoreCoverage过程,但是我找不到任何其他的引用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50387677

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档