LCOV - code coverage report
Current view: directory - frmts/wms - minidriver_virtualearth.cpp (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 47 28 59.6 %
Date: 2011-12-18 Functions: 16 8 50.0 %

       1                 : /******************************************************************************
       2                 :  * $Id: minidriver_virtualearth.cpp 23033 2011-09-03 18:46:11Z rouault $
       3                 :  *
       4                 :  * Project:  WMS Client Driver
       5                 :  * Purpose:  Implementation of Dataset and RasterBand classes for WMS
       6                 :  *           and other similar services.
       7                 :  * Author:   Even Rouault
       8                 :  *
       9                 :  ******************************************************************************
      10                 :  * Copyright (c) 2011, Even Rouault
      11                 :  *
      12                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      13                 :  * copy of this software and associated documentation files (the "Software"),
      14                 :  * to deal in the Software without restriction, including without limitation
      15                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      16                 :  * and/or sell copies of the Software, and to permit persons to whom the
      17                 :  * Software is furnished to do so, subject to the following conditions:
      18                 :  *
      19                 :  * The above copyright notice and this permission notice shall be included
      20                 :  * in all copies or substantial portions of the Software.
      21                 :  *
      22                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      23                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      24                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      25                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      26                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      27                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      28                 :  * DEALINGS IN THE SOFTWARE.
      29                 :  ****************************************************************************/
      30                 : 
      31                 : #include "stdinc.h"
      32                 : 
      33            1060 : CPP_GDALWMSMiniDriverFactory(VirtualEarth)
      34                 : 
      35               1 : GDALWMSMiniDriver_VirtualEarth::GDALWMSMiniDriver_VirtualEarth()
      36                 : {
      37               1 : }
      38                 : 
      39               1 : GDALWMSMiniDriver_VirtualEarth::~GDALWMSMiniDriver_VirtualEarth()
      40                 : {
      41               1 : }
      42                 : 
      43               1 : CPLErr GDALWMSMiniDriver_VirtualEarth::Initialize(CPLXMLNode *config)
      44                 : {
      45               1 :     CPLErr ret = CE_None;
      46                 : 
      47               1 :     if (ret == CE_None) {
      48               1 :         const char *base_url = CPLGetXMLValue(config, "ServerURL", "");
      49               1 :         if (base_url[0] != '\0') {
      50               1 :             m_base_url = base_url;
      51               1 :             if (m_base_url.find("${quadkey}") == std::string::npos) {
      52                 :                 CPLError(CE_Failure, CPLE_AppDefined,
      53               0 :                          "GDALWMS, VirtualEarth mini-driver: ${quadkey} missing in ServerURL.");
      54               0 :                 ret = CE_Failure;
      55                 :             }
      56                 :         } else {
      57                 :             CPLError(CE_Failure, CPLE_AppDefined,
      58               0 :                      "GDALWMS, VirtualEarth mini-driver: ServerURL missing.");
      59               0 :             ret = CE_Failure;
      60                 :         }
      61                 :     }
      62                 : 
      63               1 :     m_parent_dataset->WMSSetDefaultBlockSize(256, 256);
      64               1 :     m_parent_dataset->WMSSetDefaultDataWindowCoordinates(-20037508.34,20037508.34,20037508.34,-20037508.34);
      65               1 :     m_parent_dataset->WMSSetDefaultTileLevel(19);
      66               1 :     m_parent_dataset->WMSSetDefaultOverviewCount(18);
      67               1 :     m_parent_dataset->WMSSetNeedsDataWindow(FALSE);
      68                 : 
      69               1 :     m_projection_wkt=ProjToWKT("EPSG:900913");
      70                 : 
      71               1 :     return ret;
      72                 : }
      73                 : 
      74               1 : void GDALWMSMiniDriver_VirtualEarth::GetCapabilities(GDALWMSMiniDriverCapabilities *caps)
      75                 : {
      76               1 :     caps->m_capabilities_version = 1;
      77               1 :     caps->m_has_arb_overviews = 0;
      78               1 :     caps->m_has_image_request = 0;
      79               1 :     caps->m_has_tiled_image_requeset = 1;
      80               1 :     caps->m_max_overview_count = 32;
      81               1 : }
      82                 : 
      83               0 : void GDALWMSMiniDriver_VirtualEarth::TiledImageRequest(CPLString *url,
      84                 :                                                        const GDALWMSImageRequestInfo &iri,
      85                 :                                                        const GDALWMSTiledImageRequestInfo &tiri)
      86                 : {
      87                 : 
      88               0 :     *url = m_base_url;
      89                 : 
      90                 :     char szTileNumber[64];
      91               0 :     int x = tiri.m_x;
      92               0 :     int y = tiri.m_y;
      93               0 :     int z = MIN(32,tiri.m_level);
      94                 : 
      95               0 :     for(int i = 0; i < z; i ++)
      96                 :     {
      97               0 :         int row = (y & 1);
      98               0 :         int col = (x & 1);
      99                 : 
     100               0 :         szTileNumber[z-1-i] = (char) ('0' + (col | (row << 1)));
     101                 : 
     102               0 :         x = x >> 1;
     103               0 :         y = y >> 1;
     104                 :     }
     105               0 :     szTileNumber[z] = 0;
     106                 : 
     107               0 :     URLSearchAndReplace(url, "${quadkey}", "%s", szTileNumber);
     108                 :     URLSearchAndReplace(url, "${server_num}", "%d",
     109               0 :                         (tiri.m_x + tiri.m_y + z) % 4);
     110               0 : }
     111                 : 
     112               1 : const char *GDALWMSMiniDriver_VirtualEarth::GetProjectionInWKT() {
     113               1 :     return m_projection_wkt.c_str();
     114                 : }

Generated by: LCOV version 1.7