LCOV - code coverage report
Current view: top level - frmts/wms - minidriver_tileservice.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 14 21 66.7 %
Date: 2024-11-21 22:18:42 Functions: 4 5 80.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  WMS Client Driver
       4             :  * Purpose:  Implementation of Dataset and RasterBand classes for WMS
       5             :  *           and other similar services.
       6             :  * Author:   Adam Nowacki, nowak@xpam.de
       7             :  *
       8             :  ******************************************************************************
       9             :  * Copyright (c) 2007, Adam Nowacki
      10             :  *
      11             :  * SPDX-License-Identifier: MIT
      12             :  ****************************************************************************/
      13             : 
      14             : #include "wmsdriver.h"
      15             : #include "minidriver_tileservice.h"
      16             : 
      17           1 : WMSMiniDriver_TileService::WMSMiniDriver_TileService()
      18             : {
      19           1 : }
      20             : 
      21           2 : WMSMiniDriver_TileService::~WMSMiniDriver_TileService()
      22             : {
      23           2 : }
      24             : 
      25           1 : CPLErr WMSMiniDriver_TileService::Initialize(CPLXMLNode *config,
      26             :                                              CPL_UNUSED char **papszOpenOptions)
      27             : {
      28           1 :     CPLErr ret = CE_None;
      29             : 
      30             :     // Try both spellings
      31             :     m_base_url = CPLGetXMLValue(config, "ServerURL",
      32           1 :                                 CPLGetXMLValue(config, "ServerUrl", ""));
      33             : 
      34           1 :     if (m_base_url.empty())
      35             :     {
      36           0 :         CPLError(CE_Failure, CPLE_AppDefined,
      37             :                  "GDALWMS, TileService mini-driver: ServerURL missing.");
      38           0 :         ret = CE_Failure;
      39             :     }
      40             :     else
      41             :     {  // Prepare the url, leave it ready for extra arguments
      42           1 :         URLPrepare(m_base_url);
      43           1 :         const char *dataset = CPLGetXMLValue(config, "Dataset", "");
      44           1 :         const char *version = CPLGetXMLValue(config, "Version", "1");
      45           2 :         m_base_url += CPLOPrintf("interface=map&version=%s&dataset=%s&",
      46           1 :                                  version, dataset);
      47             :     }
      48             : 
      49           1 :     return ret;
      50             : }
      51             : 
      52           0 : CPLErr WMSMiniDriver_TileService::TiledImageRequest(
      53             :     WMSHTTPRequest &request, CPL_UNUSED const GDALWMSImageRequestInfo &iri,
      54             :     const GDALWMSTiledImageRequestInfo &tiri)
      55             : {
      56             :     // http://s0.tileservice.worldwindcentral.com/getTile?interface=map&version=1&dataset=bmng.topo.bathy.200401&level=5&x=18&y=6
      57           0 :     CPLString &url = request.URL;
      58           0 :     url = m_base_url;
      59           0 :     url += CPLOPrintf("level=%d&x=%d&y=%d", tiri.m_level, tiri.m_x, tiri.m_y);
      60           0 :     return CE_None;
      61             : }

Generated by: LCOV version 1.14