1 /****************************************************************************** 2 * $Id: ogr_cloudant.h 22f8ae3bf7bc3cccd970992655c63fc5254d3206 2018-04-08 20:13:05 +0200 Even Rouault $ 3 * 4 * Project: Cloudant Translator 5 * Purpose: Definition of classes for OGR Cloudant driver. 6 * Author: Norman Barker, norman at cloudant com 7 * Based on the CouchDB driver 8 * 9 ****************************************************************************** 10 * Copyright (c) 2014, Norman Barker <norman at cloudant com> 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 #ifndef OGR_CLOUDANT_H_INCLUDED 32 #define OGR_CLOUDANT_H_INCLUDED 33 34 #include "ogr_couchdb.h" 35 36 typedef enum 37 { 38 CLOUDANT_TABLE_LAYER 39 } CloudantLayerType; 40 41 class OGRCloudantDataSource; 42 43 /************************************************************************/ 44 /* OGRCloudantTableLayer */ 45 /************************************************************************/ 46 47 class OGRCloudantTableLayer final : public OGRCouchDBTableLayer 48 { 49 int bHasStandardSpatial; // -1, TRUE, FALSE 50 const char* pszSpatialView; 51 char* pszSpatialDDoc; 52 53 protected: GetFeaturesToFetch()54 virtual int GetFeaturesToFetch() override { 55 return atoi(CPLGetConfigOption("CLOUDANT_PAGE_SIZE", "200")); 56 } 57 58 virtual bool RunSpatialFilterQueryIfNecessary() override; 59 virtual void GetSpatialView(); 60 virtual void WriteMetadata() override; 61 virtual void LoadMetadata() override; 62 63 public: 64 OGRCloudantTableLayer( OGRCloudantDataSource* poDS, 65 const char* pszName ); 66 virtual ~OGRCloudantTableLayer(); 67 }; 68 69 /************************************************************************/ 70 /* OGRCloudantDataSource */ 71 /************************************************************************/ 72 73 class OGRCloudantDataSource final: public OGRCouchDBDataSource 74 { 75 protected: 76 OGRLayer* OpenDatabase(const char* pszLayerName = nullptr); 77 public: 78 OGRCloudantDataSource(); 79 virtual ~OGRCloudantDataSource(); 80 virtual int Open( const char * pszFilename, int bUpdateIn); 81 virtual OGRLayer *ICreateLayer( const char *pszName, 82 OGRSpatialReference *poSpatialRef = nullptr, 83 OGRwkbGeometryType eGType = wkbUnknown, 84 char ** papszOptions = nullptr ) override; 85 }; 86 87 #endif /* ndef OGR_CLOUDANT_H_INCLUDED */ 88