Отображение растрового результата из Geoserver WPS в Openlayers4 - PullRequest
0 голосов
/ 17 мая 2018

Для интерактивного веб-приложения я использую Openlayers 4.6.5 с Geoserver 2.13.0 .

хочу включить динамическую обработку выбранного пользователемвведите точки данных с помощью Geoserver WPS .Я расширил функциональность WPS с помощью пакета статистики из SourceForge и хочу выполнить анализ KernelDensity для набора выбранных точек.Результат KernelDensity должен отображаться на моей карте как растровый слой .

Я использую функцию Javascript fetch для отправкиXML-запрос к WPS .:

<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 - собранные события из выбранных данных точек, вывод должен быть image / tiff .

Однако я не могу понять, как получить a) растр из ответа и b) растр как слой на моей карте.

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, convxHull) и добавил response.json в качестве векторных объектов на карту, что прекрасно работает:

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 WPS.Документы API по использованию источников Raster и Image на самом деле тоже не помогают.Я действительно знаю о ol.source.ImageWMS, но поскольку я пытаюсь динамически генерировать и отображать растр, а не извлекать растр из WMS, это не вариант здесь.

Есть ли способполучить сгенерированное растровое изображение из WPS и отобразить его на карте OpenLayers?

1 Ответ

0 голосов
/ 18 мая 2018

Судя по ответам на этот вопрос , невозможно напрямую отобразить GeoTiff в OpenLayers, так как он использует собственные возможности браузера для отображения.

Один из вариантов, который может вам пригодиться, - сохранить выходные данные WPS на GeoServer и затем извлечь результаты с помощью запроса WMS. Пример того, как это сделать, можно найти в тренинге GeoSolution по WPS . В этом ответе также упоминается процесс StoreCoverage для этой цели, но я не могу найти никакой другой ссылки на него.

...