mapserv服务+gdal程序请求WCS服务

本文讲述了使用GDAL进行地图开发时遇到'Returnedtiledoesnotmatchexpectedconfiguration.'错误的原因,主要涉及到WCS数据请求中坐标精度问题和数据分块限制。提供了解决方法,包括修改mapserv源码以提高坐标精度,并针对原因2的问题提出待解决建议。
摘要由CSDN通过智能技术生成

最近用GDAL做地图开发,做重投影时遇到“Returned tile does not match expected configuration.”错误

  1. 地图服务:mapserver;
  2. c++请求:GDAL;
  3. 请求链接://GDALDataset* psrcData1 =
    (GDALDataset*)GDALOpenEx(“WCS:http://ip:port/mapserv/mapserv?map=dom.map&SERVICE=WCS&VERSION=2.0.0&REQUEST=GetCoverage&CoverageID=dom_layer&FORMAT=image/tiff”,
    GDAL_OF_RASTER, nullptr, nullptr, nullptr);

问题原因:

1.GDAL请求WCS数据时,会根据WCS请求中DescribeCoverage返回中的
gml:posx y</gml:pos>

<gml:offsetVector srsName=“http://www.opengis.net/def/crs/EPSG/0/4326”>0 0.000005</gml:offsetVector>
重新计算投影,
若mapserv发布的原始tif为地理坐标系,因为<gml:offsetVector >返回值仅仅保留6位小数,精度丢失,导致出现“Returned tile does not match expected configuration.”错误。

2.GDAL请求WCS数据时,会分块请求数据,若源数据的宽和高不能2被整除,也会出现此问题。

解决办法:

原因2的问题暂时没找到解决办法。
原因1的解决办法:修改mapserv源码。mapwcs20.c文件中msWCSCommon20_CreateDomainSe函数,将

psOrigin = xmlNewChild(psGrid, psGmlNs, BAD_CAST "origin", NULL);
      {
        if (swapAxes == MS_FALSE) {
          *snprintf(point, sizeof(point), "%f %f", x0, y0);*
        } else {
          *snprintf(point, sizeof(point), "%f %f", y0, x0);*
        }
        psOrigin = xmlNewChild(psOrigin, psGmlNs, BAD_CAST "Point", NULL);
        snprintf(id, sizeof(id), "grid_origin_%s", layer->name);
        xmlNewNsProp(psOrigin, psGmlNs, BAD_CAST "id", BAD_CAST id);
        xmlNewProp(psOrigin, BAD_CAST "srsName", BAD_CAST cm->srs_uri);

        xmlNewChild(psOrigin, psGmlNs, BAD_CAST "pos", BAD_CAST point);
      }

      if (swapAxes == MS_FALSE) {
        *snprintf(offsetVector1, sizeof(offsetVector1), "%f 0", resx);
        snprintf(offsetVector2, sizeof(offsetVector2), "0 %f", resy);*
      } else {
        *snprintf(offsetVector1, sizeof(offsetVector1), "0 %f", resx);
        snprintf(offsetVector2, sizeof(offsetVector2), "%f 0", resy);*
      }

修改为

 psOrigin = xmlNewChild(psGrid, psGmlNs, BAD_CAST "origin", NULL);
      {
        if (swapAxes == MS_FALSE) {
          *snprintf(point, sizeof(point), "%.15g %.15g", x0, y0);*
        } else {
          *snprintf(point, sizeof(point), "%.15g %.15g", y0, x0);*
        }
        psOrigin = xmlNewChild(psOrigin, psGmlNs, BAD_CAST "Point", NULL);
        snprintf(id, sizeof(id), "grid_origin_%s", layer->name);
        xmlNewNsProp(psOrigin, psGmlNs, BAD_CAST "id", BAD_CAST id);
        xmlNewProp(psOrigin, BAD_CAST "srsName", BAD_CAST cm->srs_uri);

        xmlNewChild(psOrigin, psGmlNs, BAD_CAST "pos", BAD_CAST point);
      }

      if (swapAxes == MS_FALSE) {
        *snprintf(offsetVector1, sizeof(offsetVector1), "%.15g 0", resx);
        snprintf(offsetVector2, sizeof(offsetVector2), "0 %.15g", resy);*
      } else {
        *snprintf(offsetVector1, sizeof(offsetVector1), "0 %.15g", resx);
        snprintf(offsetVector2, sizeof(offsetVector2), "%.15g 0", resy);*
      }
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值