LCOV - code coverage report
Current view: top level - frmts/wms - minidriver_worldwind.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 0 26 0.0 %
Date: 2024-11-21 22:18:42 Functions: 0 5 0.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_worldwind.h"
      16             : 
      17           0 : WMSMiniDriver_WorldWind::WMSMiniDriver_WorldWind()
      18             : {
      19           0 : }
      20             : 
      21           0 : WMSMiniDriver_WorldWind::~WMSMiniDriver_WorldWind()
      22             : {
      23           0 : }
      24             : 
      25           0 : CPLErr WMSMiniDriver_WorldWind::Initialize(CPLXMLNode *config,
      26             :                                            CPL_UNUSED char **papszOpenOptions)
      27             : {
      28           0 :     CPLErr ret = CE_None;
      29             : 
      30             :     // Try both spellings
      31             :     m_base_url = CPLGetXMLValue(config, "ServerURL",
      32           0 :                                 CPLGetXMLValue(config, "ServerUrl", ""));
      33             : 
      34           0 :     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           0 :         const char *dataset = CPLGetXMLValue(config, "Layer", "");
      43           0 :         URLPrepare(m_base_url);
      44           0 :         m_base_url += CPLOPrintf("T=%s", dataset);
      45             :     }
      46             : 
      47           0 :     m_oSRS.importFromEPSG(4326);
      48           0 :     return ret;
      49             : }
      50             : 
      51           0 : CPLErr WMSMiniDriver_WorldWind::TiledImageRequest(
      52             :     WMSHTTPRequest &request, const GDALWMSImageRequestInfo &iri,
      53             :     const GDALWMSTiledImageRequestInfo &tiri)
      54             : {
      55           0 :     CPLString &url = request.URL;
      56           0 :     const GDALWMSDataWindow *data_window = m_parent_dataset->WMSGetDataWindow();
      57           0 :     int worldwind_y =
      58           0 :         static_cast<int>(floor(
      59           0 :             ((data_window->m_y1 - data_window->m_y0) / (iri.m_y1 - iri.m_y0)) +
      60           0 :             0.5)) -
      61           0 :         tiri.m_y - 1;
      62             :     // http://worldwind25.arc.nasa.gov/tile/tile.aspx?T=geocover2000&L=0&X=86&Y=39
      63           0 :     url = m_base_url +
      64           0 :           CPLOPrintf("L=%d&X=%d&Y=%d", tiri.m_level, tiri.m_x, worldwind_y);
      65           0 :     return CE_None;
      66             : }

Generated by: LCOV version 1.14