LTP GCOV extension - code coverage report
Current view: directory - frmts/wms - wmsdriver.cpp
Test: gdal_filtered.info
Date: 2010-07-12 Instrumented lines: 38
Code covered: 86.8 % Executed lines: 33

       1                 : /******************************************************************************
       2                 :  * $Id: wmsdriver.cpp 18020 2009-11-14 14:33:20Z rouault $
       3                 :  *
       4                 :  * Project:  WMS Client Driver
       5                 :  * Purpose:  Implementation of Dataset and RasterBand classes for WMS
       6                 :  *           and other similar services.
       7                 :  * Author:   Adam Nowacki, nowak@xpam.de
       8                 :  *
       9                 :  ******************************************************************************
      10                 :  * Copyright (c) 2007, Adam Nowacki
      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           10170 : GDALDataset *GDALWMSDatasetOpen(GDALOpenInfo *poOpenInfo) {
      34           10170 :     CPLXMLNode *config = NULL;
      35           10170 :     CPLErr ret = CE_None;
      36                 : 
      37           10174 :     if ((poOpenInfo->nHeaderBytes == 0) && EQUALN((const char *) poOpenInfo->pszFilename, "<GDAL_WMS>", 10)) {
      38               4 :         config = CPLParseXMLString(poOpenInfo->pszFilename);
      39           10167 :     } else if ((poOpenInfo->nHeaderBytes >= 10) && EQUALN((const char *) poOpenInfo->pabyHeader, "<GDAL_WMS>", 10)) {
      40               1 :         config = CPLParseXMLFile(poOpenInfo->pszFilename);
      41           10165 :     } else return NULL;
      42               5 :     if (config == NULL) return NULL;
      43                 :     
      44                 : /* -------------------------------------------------------------------- */
      45                 : /*      Confirm the requested access is supported.                      */
      46                 : /* -------------------------------------------------------------------- */
      47               5 :     if( poOpenInfo->eAccess == GA_Update )
      48                 :     {
      49               0 :         CPLDestroyXMLNode(config);
      50                 :         CPLError( CE_Failure, CPLE_NotSupported, 
      51                 :                   "The WMS driver does not support update access to existing"
      52               0 :                   " datasets.\n" );
      53               0 :         return NULL;
      54                 :     }
      55                 : 
      56               5 :     GDALWMSDataset *ds = new GDALWMSDataset();
      57               5 :     ret = ds->Initialize(config);
      58               5 :     if (ret != CE_None) {
      59               0 :         delete ds;
      60               0 :         ds = 0;
      61                 :     }
      62               5 :     CPLDestroyXMLNode(config);
      63                 : 
      64               5 :     return ds;
      65                 : }
      66                 : 
      67                 : /************************************************************************/
      68                 : /*                         GDALDeregister_WMS()                         */
      69                 : /************************************************************************/
      70                 : 
      71             380 : static void GDALDeregister_WMS( GDALDriver * )
      72                 : 
      73                 : {
      74             380 :     DestroyWMSMiniDriverManager();
      75             380 : }
      76                 : 
      77                 : /************************************************************************/
      78                 : /*                          GDALRegister_WMS()                          */
      79                 : /************************************************************************/
      80                 : 
      81             409 : void GDALRegister_WMS() {
      82                 :     GDALDriver *driver;
      83             409 :     if (GDALGetDriverByName("WMS") == NULL) {
      84             392 :         driver = new GDALDriver();
      85             392 :         driver->SetDescription("WMS");
      86             392 :         driver->SetMetadataItem(GDAL_DMD_LONGNAME, "OGC Web Map Service");
      87             392 :         driver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "frmt_wms.html");
      88             392 :         driver->pfnOpen = GDALWMSDatasetOpen;
      89             392 :         driver->pfnUnloadDriver = GDALDeregister_WMS;
      90             392 :         GetGDALDriverManager()->RegisterDriver(driver);
      91                 : 
      92             392 :         GDALWMSMiniDriverManager *const mdm = GetGDALWMSMiniDriverManager();
      93             784 :         mdm->Register(new GDALWMSMiniDriverFactory_WMS());
      94             784 :         mdm->Register(new GDALWMSMiniDriverFactory_TileService());
      95             784 :         mdm->Register(new GDALWMSMiniDriverFactory_WorldWind());
      96             784 :         mdm->Register(new GDALWMSMiniDriverFactory_TMS());
      97                 :     }
      98             409 : }

Generated by: LTP GCOV extension version 1.5