Coverage Report

Created: 2025-11-15 08:43

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gdal/frmts/wms/minidriver_worldwind.cpp
Line
Count
Source
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
WMSMiniDriver_WorldWind::WMSMiniDriver_WorldWind()
18
0
{
19
0
}
20
21
WMSMiniDriver_WorldWind::~WMSMiniDriver_WorldWind()
22
0
{
23
0
}
24
25
CPLErr WMSMiniDriver_WorldWind::Initialize(CPLXMLNode *config,
26
                                           CPL_UNUSED char **papszOpenOptions)
27
0
{
28
0
    CPLErr ret = CE_None;
29
30
    // Try both spellings
31
0
    m_base_url = CPLGetXMLValue(config, "ServerURL",
32
0
                                CPLGetXMLValue(config, "ServerUrl", ""));
33
34
0
    if (m_base_url.empty())
35
0
    {
36
0
        CPLError(CE_Failure, CPLE_AppDefined,
37
0
                 "GDALWMS, TileService mini-driver: ServerURL missing.");
38
0
        ret = CE_Failure;
39
0
    }
40
0
    else
41
0
    {  // 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
0
    }
46
47
0
    m_oSRS.importFromEPSG(4326);
48
0
    return ret;
49
0
}
50
51
CPLErr WMSMiniDriver_WorldWind::TiledImageRequest(
52
    WMSHTTPRequest &request, const GDALWMSImageRequestInfo &iri,
53
    const GDALWMSTiledImageRequestInfo &tiri)
54
0
{
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
0
}