Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: Earth Engine Data API Images driver 4 : * Purpose: Earth Engine Data API Images driver 5 : * Author: Even Rouault, even dot rouault at spatialys.com 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2017-2018, 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 : #ifndef EEDA_H_INCLUDED 30 : #define EEDA_H_INCLUDED 31 : 32 : #include "cpl_string.h" 33 : #include "gdal.h" 34 : #include "cpl_json_header.h" 35 : #undef TRUE 36 : #define TRUE 1 37 : #undef FALSE 38 : #define FALSE 0 39 : #include "gdal_priv.h" 40 : #include "cpl_http.h" 41 : #include <vector> 42 : #include <map> 43 : 44 : CPLHTTPResult *EEDAHTTPFetch(const char *pszURL, char **papszOptions); 45 : 46 : /************************************************************************/ 47 : /* EEDAIBandDesc */ 48 : /************************************************************************/ 49 : 50 : class EEDAIBandDesc 51 : { 52 : public: 53 : CPLString osName{}; 54 : CPLString osWKT{}; 55 : GDALDataType eDT{GDT_Unknown}; 56 : std::vector<double> adfGeoTransform{0.0, 1.0, 0.0, 0.0, 0.0, 1.0}; 57 : int nWidth{0}; 58 : int nHeight{0}; 59 : 60 : /* Check if it similar enough for being considered as a compatible */ 61 : /* GDAL band in the same dataset */ 62 25 : bool IsSimilar(const EEDAIBandDesc &oOther) const 63 : { 64 25 : return osWKT == oOther.osWKT && 65 25 : adfGeoTransform == oOther.adfGeoTransform && 66 50 : nWidth == oOther.nWidth && nHeight == oOther.nHeight; 67 : } 68 : }; 69 : 70 : std::vector<EEDAIBandDesc> 71 : BuildBandDescArray(json_object *poBands, 72 : std::map<CPLString, CPLString> &oMapCodeToWKT); 73 : 74 : /************************************************************************/ 75 : /* GDALEEDABaseDataset */ 76 : /************************************************************************/ 77 : 78 : class GDALEEDABaseDataset CPL_NON_FINAL : public GDALDataset 79 : { 80 : protected: 81 : bool m_bMustCleanPersistent; 82 : CPLString m_osBaseURL{}; 83 : CPLString m_osBearer{}; 84 : GIntBig m_nExpirationTime; 85 : 86 : char **GetBaseHTTPOptions(); 87 : static CPLString ConvertPathToName(const CPLString &path); 88 : 89 : public: 90 : GDALEEDABaseDataset(); 91 : virtual ~GDALEEDABaseDataset(); 92 : 93 : const CPLString &GetBaseURL() const 94 : { 95 : return m_osBaseURL; 96 : } 97 : }; 98 : 99 : #endif // EEDA_H_INCLUDED