Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: PlanetLabs scene driver 4 : * Purpose: PlanetLabs scene driver 5 : * Author: Even Rouault, even dot rouault at spatialys.com 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2015-2016, Planet Labs 9 : * 10 : * Permission is hereby granted, free of charge, to any person obtaining a 11 : * copy of this software and associated documentation files (the "Software"), 12 : * to deal in the Software without restriction, including without limitation 13 : * the rights to use, copy, modify, merge, publish, distribute, sublicense, 14 : * and/or sell copies of the Software, and to permit persons to whom the 15 : * Software is furnished to do so, subject to the following conditions: 16 : * 17 : * The above copyright notice and this permission notice shall be included 18 : * in all copies or substantial portions of the Software. 19 : * 20 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 21 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 23 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 25 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 26 : * DEALINGS IN THE SOFTWARE. 27 : ****************************************************************************/ 28 : 29 : #include "ogr_plscenes.h" 30 : #include "ogrplscenesdrivercore.h" 31 : 32 : /************************************************************************/ 33 : /* OGRPLScenesOpen() */ 34 : /************************************************************************/ 35 : 36 28 : static GDALDataset *OGRPLScenesOpen(GDALOpenInfo *poOpenInfo) 37 : { 38 56 : if (!OGRPLSCENESDriverIdentify(poOpenInfo) || 39 28 : poOpenInfo->eAccess == GA_Update) 40 0 : return nullptr; 41 : 42 56 : char **papszOptions = CSLTokenizeStringComplex( 43 28 : poOpenInfo->pszFilename + strlen("PLScenes:"), ",", TRUE, FALSE); 44 : CPLString osVersion = CSLFetchNameValueDef( 45 : papszOptions, "version", 46 56 : CSLFetchNameValueDef(poOpenInfo->papszOpenOptions, "VERSION", "")); 47 28 : CSLDestroy(papszOptions); 48 : 49 28 : if (EQUAL(osVersion, "v0") || EQUAL(osVersion, "v1")) 50 : { 51 0 : CPLError(CE_Failure, CPLE_AppDefined, 52 : "This API version has been removed or deprecated. " 53 : "Please use DATA_V1 API instead"); 54 0 : return nullptr; 55 : } 56 28 : else if (EQUAL(osVersion, "data_v1") || EQUAL(osVersion, "")) 57 : { 58 28 : return OGRPLScenesDataV1Dataset::Open(poOpenInfo); 59 : } 60 : else 61 : { 62 0 : CPLError(CE_Failure, CPLE_AppDefined, "Unhandled API version: %s", 63 : osVersion.c_str()); 64 0 : return nullptr; 65 : } 66 : } 67 : 68 : /************************************************************************/ 69 : /* RegisterOGRPLSCENES() */ 70 : /************************************************************************/ 71 : 72 1520 : void RegisterOGRPLSCENES() 73 : 74 : { 75 1520 : if (GDALGetDriverByName(DRIVER_NAME) != nullptr) 76 301 : return; 77 : 78 1219 : GDALDriver *poDriver = new GDALDriver(); 79 1219 : OGRPLSCENESDriverSetCommonMetadata(poDriver); 80 : 81 1219 : poDriver->pfnOpen = OGRPLScenesOpen; 82 : 83 1219 : GetGDALDriverManager()->RegisterDriver(poDriver); 84 : }