[gdal-dev] GDAL WMTS Driver - How do you control the Tile Matrix Set's Tile Level?

Even Rouault even.rouault at spatialys.com
Mon Nov 7 13:29:10 PST 2016


Le lundi 07 novembre 2016 22:07:09, esacree a écrit :
> Code Snippet:
> 
> 
> GDAL_WMTS XML file – area around Cumberland River:
> 
> Code is trying to get raster tiles from the server not capabilities.  Using
> the example for the Local Service Description File here:
> http://www.gdal.org/frmt_wmts.html .
> 
> 1.  Here is the WMTS XML file generated to request tiles for the area. 
> Note there is no image size limit specified in the request below.  A WMS
> request is limited by size in the XML file.
> 
> <GDAL_WMTS>
> 
> <GetCapabilitiesUrl>http://basemap.nationalmap.gov/arcgis/rest/services/USG
> SShadedReliefOnly/MapServer/WMTS/1.0.0/WMTSCapabilities.xml</GetCapabilitie
> sUrl> <Layer>USGSShadedReliefOnly</Layer>
> 
>         <TileMatrixSet>default028mm</TileMatrixSet>
>     <DataWindow>
>         <UpperLeftX>-9664344.849763</UpperLeftX>
>         <UpperLeftY>4328551.472775</UpperLeftY>
>         <LowerRightX>-9646502.672226</LowerRightX>
>         <LowerRightY>4318753.685277</LowerRightY>
>     </DataWindow>
>     <BandsCount>4</BandsCount>
>     <Cache />
>     <UnsafeSSL>true</UnsafeSSL>
>     <ZeroBlockHttpCodes>204,404</ZeroBlockHttpCodes>
>     <ZeroBlockOnServerException>true</ZeroBlockOnServerException>
> </GDAL_WMTS>
> 
> 2.  Call to GDAL Open with the above XML file name to create the data set
> using the XML Service Request file:
> 
>   GDALDataset* pdataset = (GDALDataset*)GDALOpen(xmlPath.c_str(),
> GA_ReadOnly);
>   if (!pdataset)
>   {
> 	OutputDebugStringA("GDALOpen failure");
> 	OutputDebugStringA(CPLGetLastErrorMsg());
>     return false;
>   }
> 
> // Note:  For the WMTS request above, the full raster image size of about
> 56K x 39K is coming back GetRasterXSize and GetRasterYSize.  For the older
> GDAL_WMS the image sizes are the request size specified in the WMS XML
> Service Request File.  There is no limit on the image size in the WMTS Tile
> server request.
> 
> Here is the data setup in the info struct.  The info data is used later by
> the call back function that gets the raster data:
> 
>   info->m_width  = pdataset->GetRasterXSize();  // Returning full size
> image pixel width
>   info->m_height = pdataset->GetRasterYSize();  // Returning full size
> image pixel height
> 
> info->m_dtype = GDTByte;
> info->m_dbands = 4;
> nPixelSpace = 4; // 4 Bytes per pixel for RGBA
> nLineSpace = m_width * nPixelSpace;
> nBandSpace = 1;
> int	bandMap[] = { 1,2,3,4 };
> 
> 3.  Data Receipt:  Later Data coming into the GDAL thread call back
> function:
> 
> err = pdataset->RasterIO(	GF_Read, 0, 0,  info->m_width, info->m_height,
> 				(void*)tmpbuff, info->m_width, info->m_height,
> 				info->m_dtype,  info->m_dbands, bandMap,
> 				nPixelSpace, nLineSpace, nBandSpace);
> 
> 

OK so you are requesting a  56K x 39K  image in a single request. If that's 
too big (which is likely), then ask for smaller buffer dimensions like

 err = pdataset->RasterIO(	GF_Read, 0, 0,  info->m_width, info->m_height,
 				(void*)tmpbuff, info->m_width / 16, info->m_height / 16,
 				info->m_dtype,  info->m_dbands, bandMap,
 				nPixelSpace, nLineSpace, nBandSpace);

> Elaine
> 
> 
> 
> 
> 
> --
> View this message in context:
> http://osgeo-org.1560.x6.nabble.com/GDAL-WMTS-Driver-How-do-you-control-th
> e-Tile-Matrix-Set-s-Tile-Level-tp5294530p5294705.html Sent from the GDAL -
> Dev mailing list archive at Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list