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

esacree esacree at knology.net
Mon Nov 7 13:07:09 PST 2016


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/USGSShadedReliefOnly/MapServer/WMTS/1.0.0/WMTSCapabilities.xml</GetCapabilitiesUrl>
        <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);


Elaine





--
View this message in context: http://osgeo-org.1560.x6.nabble.com/GDAL-WMTS-Driver-How-do-you-control-the-Tile-Matrix-Set-s-Tile-Level-tp5294530p5294705.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.


More information about the gdal-dev mailing list