Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: GDAL WMTS driver 4 : * Purpose: Implement GDAL WMTS support 5 : * Author: Even Rouault, <even dot rouault at spatialys dot com> 6 : * Funded by Land Information New Zealand (LINZ) 7 : * 8 : ********************************************************************** 9 : * Copyright (c) 2015, Even Rouault <even dot rouault at spatialys dot com> 10 : * 11 : * Permission is hereby granted, free of charge, to any person obtaining a 12 : * copy of this software and associated documentation files (the "Software"), 13 : * to deal in the Software without restriction, including without limitation 14 : * the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 : * and/or sell copies of the Software, and to permit persons to whom the 16 : * Software is furnished to do so, subject to the following conditions: 17 : * 18 : * The above copyright notice and this permission notice shall be included 19 : * in all copies or substantial portions of the Software. 20 : * 21 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 22 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 27 : * DEALINGS IN THE SOFTWARE. 28 : ****************************************************************************/ 29 : 30 : #include "wmtsdrivercore.h" 31 : 32 : /************************************************************************/ 33 : /* WMTSDriverIdentify() */ 34 : /************************************************************************/ 35 : 36 49673 : int WMTSDriverIdentify(GDALOpenInfo *poOpenInfo) 37 : 38 : { 39 49673 : if (STARTS_WITH_CI(poOpenInfo->pszFilename, "WMTS:")) 40 112 : return TRUE; 41 : 42 49561 : if (STARTS_WITH_CI(poOpenInfo->pszFilename, "<GDAL_WMTS")) 43 8 : return TRUE; 44 : 45 49553 : if (poOpenInfo->nHeaderBytes == 0) 46 45595 : return FALSE; 47 : 48 3958 : if (strstr((const char *)poOpenInfo->pabyHeader, "<GDAL_WMTS")) 49 6 : return TRUE; 50 : 51 3952 : return (strstr((const char *)poOpenInfo->pabyHeader, "<Capabilities") != 52 3970 : nullptr || 53 3970 : strstr((const char *)poOpenInfo->pabyHeader, 54 7904 : "<wmts:Capabilities") != nullptr) && 55 0 : strstr((const char *)poOpenInfo->pabyHeader, 56 3952 : "http://www.opengis.net/wmts/1.0") != nullptr; 57 : } 58 : 59 : /************************************************************************/ 60 : /* WMTSDriverSetCommonMetadata() */ 61 : /************************************************************************/ 62 : 63 1216 : void WMTSDriverSetCommonMetadata(GDALDriver *poDriver) 64 : { 65 1216 : poDriver->SetDescription(DRIVER_NAME); 66 1216 : poDriver->SetMetadataItem(GDAL_DCAP_RASTER, "YES"); 67 1216 : poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "OGC Web Map Tile Service"); 68 1216 : poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/raster/wmts.html"); 69 : 70 1216 : poDriver->SetMetadataItem(GDAL_DMD_CONNECTION_PREFIX, "WMTS:"); 71 : 72 1216 : poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES"); 73 : 74 1216 : poDriver->SetMetadataItem( 75 : GDAL_DMD_OPENOPTIONLIST, 76 : "<OpenOptionList>" 77 : " <Option name='URL' type='string' description='URL that points to " 78 : "GetCapabilities response' required='YES'/>" 79 : " <Option name='LAYER' type='string' description='Layer identifier'/>" 80 : " <Option name='TILEMATRIXSET' alias='TMS' type='string' " 81 : "description='Tile matrix set identifier'/>" 82 : " <Option name='TILEMATRIX' type='string' description='Tile matrix " 83 : "identifier of maximum zoom level. Exclusive with ZOOM_LEVEL.'/>" 84 : " <Option name='ZOOM_LEVEL' alias='ZOOMLEVEL' type='int' " 85 : "description='Maximum zoom level. Exclusive with TILEMATRIX.'/>" 86 : " <Option name='STYLE' type='string' description='Style identifier'/>" 87 : " <Option name='EXTENDBEYONDDATELINE' type='boolean' " 88 : "description='Whether to enable extend-beyond-dateline behaviour' " 89 : "default='NO'/>" 90 : " <Option name='EXTENT_METHOD' type='string-select' description='How " 91 : "the raster extent is computed' default='AUTO'>" 92 : " <Value>AUTO</Value>" 93 : " <Value>LAYER_BBOX</Value>" 94 : " <Value>TILE_MATRIX_SET</Value>" 95 : " <Value>MOST_PRECISE_TILE_MATRIX</Value>" 96 : " </Option>" 97 : " <Option name='CLIP_EXTENT_WITH_MOST_PRECISE_TILE_MATRIX' " 98 : "type='boolean' description='Whether to use the implied bounds of the " 99 : "most precise tile matrix to clip the layer extent (defaults to NO if " 100 : "layer bounding box is used, YES otherwise)'/>" 101 : " <Option name='CLIP_EXTENT_WITH_MOST_PRECISE_TILE_MATRIX_LIMITS' " 102 : "type='boolean' description='Whether to use the implied bounds of the " 103 : "most precise tile matrix limits to clip the layer extent (defaults to " 104 : "NO if layer bounding box is used, YES otherwise)'/>" 105 1216 : "</OpenOptionList>"); 106 : 107 1216 : poDriver->pfnIdentify = WMTSDriverIdentify; 108 1216 : poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES"); 109 1216 : poDriver->SetMetadataItem(GDAL_DCAP_CREATECOPY, "YES"); 110 1216 : } 111 : 112 : /************************************************************************/ 113 : /* DeclareDeferredWMTSPlugin() */ 114 : /************************************************************************/ 115 : 116 : #ifdef PLUGIN_FILENAME 117 : void DeclareDeferredWMTSPlugin() 118 : { 119 : if (GDALGetDriverByName(DRIVER_NAME) != nullptr) 120 : { 121 : return; 122 : } 123 : auto poDriver = new GDALPluginDriverProxy(PLUGIN_FILENAME); 124 : #ifdef PLUGIN_INSTALLATION_MESSAGE 125 : poDriver->SetMetadataItem(GDAL_DMD_PLUGIN_INSTALLATION_MESSAGE, 126 : PLUGIN_INSTALLATION_MESSAGE); 127 : #endif 128 : WMTSDriverSetCommonMetadata(poDriver); 129 : GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver); 130 : } 131 : #endif