1 /****************************************************************************** 2 * 3 * File : pgchip.h 4 * Project: PGCHIP Driver 5 * Purpose: Main header file for POSTGIS CHIP/GDAL Driver 6 * Author: Benjamin Simon, noumayoss@gmail.com 7 * 8 ****************************************************************************** 9 * Copyright (c) 2005, Benjamin Simon, noumayoss@gmail.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 * Revision 1.1 2005/08/29 bsimon 31 * New 32 * 33 */ 34 35 #include "gdal_priv.h" 36 #include "libpq-fe.h" 37 #include "liblwgeom.h" 38 39 // External functions (what's again the reason for using explicit hex form ?) 40 extern void pgch_deparse_hex(unsigned char in, unsigned char *out); 41 extern void deparse_hex_string(unsigned char *strOut,char *strIn,int length); 42 extern void parse_hex_string(unsigned char *strOut,char *strIn,int length); 43 44 /* color types */ 45 #define PGCHIP_COLOR_TYPE_GRAY 0 46 #define PGCHIP_COLOR_TYPE_PALETTE 1 47 #define PGCHIP_COLOR_TYPE_RGB_ALPHA 4 48 49 //pg_chip color struct 50 typedef struct pgchip_color_nohex_struct 51 { 52 unsigned char red; 53 unsigned char green; 54 unsigned char blue; 55 unsigned char alpha; 56 } pgchip_color; 57 58 59 /************************************************************************/ 60 /* ==================================================================== */ 61 /* PGCHIPDataset */ 62 /* ==================================================================== */ 63 /************************************************************************/ 64 65 class PGCHIPRasterBand; 66 67 class PGCHIPDataset : public GDALDataset{ 68 69 friend class PGCHIPRasterBand; 70 71 PGconn *hPGConn; 72 char *pszTableName; 73 char *pszDSName; 74 char *pszProjection; 75 76 CHIP *PGCHIP; 77 int SRID; 78 int nBitDepth; 79 80 int nColorType; /* PGHIP_COLOR_TYPE_* */ 81 GDALColorTable *poColorTable; 82 int bHaveNoData; 83 double dfNoDataValue; 84 85 double adfGeoTransform[6]; 86 int bGeoTransformValid; 87 88 public: 89 90 PGCHIPDataset(); 91 ~PGCHIPDataset(); 92 93 static GDALDataset *Open( GDALOpenInfo * ); 94 95 static void printChipInfo(const CHIP& chip); 96 97 CPLErr GetGeoTransform( double * padfTransform ); 98 const char *GetProjectionRef(); 99 }; 100 101 /************************************************************************/ 102 /* ==================================================================== */ 103 /* PGCHIPRasterBand */ 104 /* ==================================================================== */ 105 /************************************************************************/ 106 107 class PGCHIPRasterBand : public GDALRasterBand{ 108 109 friend class PGCHIPDataset; 110 111 public: 112 113 PGCHIPRasterBand( PGCHIPDataset *, int ); 114 115 virtual CPLErr IReadBlock( int, int, void * ); 116 virtual GDALColorInterp GetColorInterpretation(); 117 virtual GDALColorTable *GetColorTable(); 118 119 }; 120