本文介绍了Geoserver-栅格/WMS图层的多个点/位置或边界框的GetFeatureInfo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Geoserver 2.8.1版本.我有netcdf and grib个文件,并且正在通过Geoserver extensions将它们上传到Geoserver.之后,我使用这些数据在地图上显示图层要素信息. (根据缩放比例和图像大小)我在地图上放置了箭头,以参考wind and wave方向.我通过像这样获取netcdf信息来计算箭头的定位角度.

I am using Geoserver 2.8.1 version. I have netcdf and grib files, and I am uploading those to Geoserver through Geoserver extensions. After that, I use those data to show layer feature info in the map. (According to zoom scale and image size)I put arrows in the map to reference wind and wave directions. I calculate, to which angle the arrow will be positioned, by getting netcdf info like this;

我对以上每个点仅更改bbox做出了要求(假设平均为1000倍).它正在杀死我的应用程序.我有什么办法可以在一个请求中所有单元格/点的要素信息/值?

I make above request for each point changing only bbox(Lets say 1000 times average). It is killing my application. Is there any way that I can get feature info/values for all the cells/points in one request?

我知道我现在不能用WMS - getFeatureInfo做到这一点,但是我可以接受任何建议,唯一的限制是我需要使用Java.

I know I can't do it with WMS - getFeatureInfo now, but I am open to any suggestion, only limitation is I need to use java.

注意:我不是在寻找多层中一个点的值,而是在寻找多个点的值.我已经可以获取多层的值.

Note: I am not looking for values of one point in multiple layers, I am looking for values of multiple points. I can already get values for multiple layers.

推荐答案

我尝试了多种方法解决了问题,但直到现在都没有时间在此处发布答案.

I solved the problem after trying many ways, but couldn't find the time to post the answer here until now.

首先,我正在开发自己的WPS流程.但是,在搜索代码示例期间,我发现Geoserver已经具有用于获取原始Raster数据的WPS流程.因此,我决定尝试一下.

First, I was developing my own WPS process. However, during searching for code examples, I discovered Geoserver already had a WPS process for getting original Raster data. So, I decided to try that out.

阅读步骤之前的第一个重要说明;如果您使用的是SOAP Ui或类似的测试请求,则不要尝试编写代码.您应该知道,从请求中获取响应对我来说需要毫秒,但是Soap Ui花费 10-15分钟来解析返回的json数据.因此,不必担心过程缓慢,实际上速度很快.

First important note before reading steps; If you are using SOAP Ui or sth similar to test requesting, instead of trying it with writing code. You should know that getting response from the request takes milliseconds for me, however Soap Ui takes 10-15 minutes to parse the returning json data. So, don't worry about the process being slow, it is fast actually.

  1. 通过在Geoserver中激活WPS本指南
  2. 然后转到演示-> WPS请求构建器
  3. 选择流程 gs:RasterAsPointCollection
  4. 输入栅格应该是您想要的.从那里的组合框中选择它.就我而言WindWaveModel:u10
  5. TargetCRS 作为您的;就我而言EPSG:4326
  6. 在尝试获取每个单元格的数据时,
  7. 插值必须最近
  8. 处理输出,您必须从那里的组合框中选择 application/json .如果选择其他任何GeoServer都会引发异常.
  9. 不要填充半球(我认为代表半球)和比例.
  10. 可选:如果要发现更多信息,可以按屏幕上的 DescribeProcess .
  11. 对于request bodyGeoserver在页面底部提供从过程输入/输出生成XML 按钮.您必须单击此按钮,Geoserver才能创建请求XML.首先,看一下XML并尝试理解它的含义.
  12. 首先,您将意识到,您在页面表单中填写的内容在XML中作为输入存在.然后,您将看到表格中所填内容不止于此.就像您的raster layerbounding box.它是自动从图层信息中提取的,并且 gs:RasterAsPointCollection 过程为您提供了bounding box输入.这样您就可以获取only some part of your raster layer而不是全部内容.
  13. 第二,您将看到process chaining,因为第一个<wps:input> wcs:GetCoverage 服务的输出.这对我来说有些挑战,因为我的netcdf layers中有time dimensions.并且 gs:RasterAsPointCollection 使用的是 wcs:1.1.1规范.如果您查看 wcs:1.1.1规范,您将看不到任何时间维度输入.那里有太多尝试失败的地方,我将省略详细信息,因为我将为您提供final result in the XML formtime dimension input.
  1. Activate WPS in Geoserver through this guide
  2. Then go to Demos -> WPS Request Builder
  3. Choose Process as gs:RasterAsPointCollection
  4. input raster should be the one you want. Select it from the combobox there. In my case WindWaveModel:u10
  5. TargetCRS as yours; in my case EPSG:4326
  6. interpolation must be nearest as you are trying to get data for each cell
  7. Process outputs you must select application/json from combobox there. If you select any other GeoServer throws exception.
  8. Don't fill emisphere (I think stands for hemisphere) and scale.
  9. Optional: If you want to discover more, you can press DescribeProcess on the screen.
  10. For the request body, Geoserver provides Generate XML from process inputs/outputs button at the bottom of the page. You must click this button for Geoserver to create the request XML. First, have a look at the XML and try to understand what it is.
  11. First, you will realize, what you filled in the page form is there in the XML as input. Then, you will see there is more than what filled in the form; like the bounding box of your raster layer. It is automatically extracted from layer information and gs:RasterAsPointCollection process provides you with bounding box input. So that you can get only some part of your raster layer, instead of all of it.
  12. Second, you will see there is process chaining, as the first <wps:input> is output of a wcs:GetCoverage service. Here was somewhat challenging for me, because I have time dimensions in my netcdf layers. And gs:RasterAsPointCollection was using wcs:1.1.1 specification. If you look at the wcs:1.1.1 specification you will see no time dimension input. There were so many try&fails for me there, I will skip the detail, as I will provide you with the final result in the XML form with the addition of time dimension input.


<?xml version="1.0" encoding="UTF-8"?><wps:Execute version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/wps/1.0.0" 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:wcs="http://www.opengis.net/wcs/1.1.1" 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>gs:RasterAsPointCollection</ows:Identifier>
  <wps:DataInputs>
    <wps:Input>
      <ows:Identifier>data</ows:Identifier>
      <wps:Reference mimeType="image/tiff" xlink:href="http://geoserver/wcs" method="POST">
        <wps:Body>
          <wcs:GetCoverage service="WCS" version="1.1.1">
            <ows:Identifier>yourWorkspace:yourRasterLayer(e.g. it.geosolutions:u10)</ows:Identifier>
            <wcs:DomainSubset>
              <ows:BoundingBox crs="http://www.opengis.net/gml/srs/epsg.xml#4326">
                <ows:LowerCorner>minLon minLat(e.g. 20.0 30.0)</ows:LowerCorner>
                <ows:UpperCorner>maxLon maxLat(e.g. 55.0 48.0)</ows:UpperCorner>
              </ows:BoundingBox>
              <wcs:TemporalSubset>
                <gml:TimePosition>yourTimeDimesion(e.g.2017-03-15T06:00:00.000Z)</gml:TimePosition>
              </wcs:TemporalSubset>
            </wcs:DomainSubset>
            <wcs:Output format="image/tiff"/>
          </wcs:GetCoverage>
        </wps:Body>
      </wps:Reference>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>targetCRS</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>EPSG:4326</wps:LiteralData>
      </wps:Data>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>interpolation</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>nearest</wps:LiteralData>
      </wps:Data>
    </wps:Input>
  </wps:DataInputs>
  <wps:ResponseForm>
    <wps:RawDataOutput mimeType="application/json">
      <ows:Identifier>result</ows:Identifier>
    </wps:RawDataOutput>
  </wps:ResponseForm>
</wps:Execute>


HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("http://localhost:8090/geoserver/ows?Service=WPS");
HttpEntity entity = new ByteArrayEntity(xmlString.getBytes("UTF-8"));
post.setEntity(entity);
HttpResponse response = client.execute(post);
// parse the json data in the response with a streaming model as it will be big

现在,我正在查询 u10 v10 栅格图层(进行2次WPS通话)以获取 eastward_wind northward_wind 值.然后,我为每个单元格计算euclidian sum,最后从结果值中创建一个颜色图.我还用类似的几何方程式计算了风向箭头.

Right now, I am querying both u10 and v10 raster layers (making 2 WPS calls) for getting eastward_wind and northward_wind values. Then I calculate euclidian sum for each cell and in the end create a color map out of result values. I also calculate wind arrow directions in a similar geometric equation.

我希望这也会对其他人有所帮助.

I hope this helps other people too.

请让我知道,如果我可以使此过程更快或者以其他任何方式对其进行优化.

Please let me know, if I can make this process faster, or optimize it any other way.

这篇关于Geoserver-栅格/WMS图层的多个点/位置或边界框的GetFeatureInfo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 02:22