Line data Source code
1 : /****************************************************************************** 2 : * $Id$ 3 : * 4 : * Project: Idrisi Translator 5 : * Purpose: Definition of classes for OGR Idrisi driver. 6 : * Author: Even Rouault, even dot rouault at spatialys.com 7 : * 8 : ****************************************************************************** 9 : * Copyright (c) 2011-2012, Even Rouault <even dot rouault at spatialys.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 : #ifndef OGR_IDRISI_H_INCLUDED 31 : #define OGR_IDRISI_H_INCLUDED 32 : 33 : #include "ogrsf_frmts.h" 34 : 35 : /************************************************************************/ 36 : /* OGRIdrisiLayer */ 37 : /************************************************************************/ 38 : 39 : class OGRIdrisiLayer final : public OGRLayer, 40 : public OGRGetNextFeatureThroughRaw<OGRIdrisiLayer> 41 : { 42 : protected: 43 : OGRFeatureDefn *poFeatureDefn; 44 : OGRSpatialReference *poSRS; 45 : OGRwkbGeometryType eGeomType; 46 : 47 : VSILFILE *fp; 48 : VSILFILE *fpAVL; 49 : bool bEOF; 50 : 51 : int nNextFID; 52 : 53 : bool bExtentValid; 54 : double dfMinX; 55 : double dfMinY; 56 : double dfMaxX; 57 : double dfMaxY; 58 : 59 : unsigned int nTotalFeatures; 60 : 61 : bool Detect_AVL_ADC(const char *pszFilename); 62 : void ReadAVLLine(OGRFeature *poFeature); 63 : 64 : OGRFeature *GetNextRawFeature(); 65 : 66 : public: 67 : OGRIdrisiLayer(const char *pszFilename, const char *pszLayerName, 68 : VSILFILE *fp, OGRwkbGeometryType eGeomType, 69 : const char *pszWTKString); 70 : virtual ~OGRIdrisiLayer(); 71 : 72 : virtual void ResetReading() override; 73 10 : DEFINE_GET_NEXT_FEATURE_THROUGH_RAW(OGRIdrisiLayer) 74 : 75 11 : virtual OGRFeatureDefn *GetLayerDefn() override 76 : { 77 11 : return poFeatureDefn; 78 : } 79 : 80 : virtual int TestCapability(const char *) override; 81 : 82 : void SetExtent(double dfMinX, double dfMinY, double dfMaxX, double dfMaxY); 83 : virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE) override; 84 : 85 3 : virtual OGRErr GetExtent(int iGeomField, OGREnvelope *psExtent, 86 : int bForce) override 87 : { 88 3 : return OGRLayer::GetExtent(iGeomField, psExtent, bForce); 89 : } 90 : 91 : virtual GIntBig GetFeatureCount(int bForce = TRUE) override; 92 : }; 93 : 94 : /************************************************************************/ 95 : /* OGRIdrisiDataSource */ 96 : /************************************************************************/ 97 : 98 : class OGRIdrisiDataSource final : public OGRDataSource 99 : { 100 : char *pszName; 101 : 102 : OGRLayer **papoLayers; 103 : int nLayers; 104 : 105 : public: 106 : OGRIdrisiDataSource(); 107 : virtual ~OGRIdrisiDataSource(); 108 : 109 : int Open(const char *pszFilename); 110 : 111 3 : virtual const char *GetName() override 112 : { 113 3 : return pszName; 114 : } 115 : 116 0 : virtual int GetLayerCount() override 117 : { 118 0 : return nLayers; 119 : } 120 : 121 : virtual OGRLayer *GetLayer(int) override; 122 : 123 : virtual int TestCapability(const char *) override; 124 : }; 125 : 126 : /************************************************************************/ 127 : /* OGRIdrisiDriver */ 128 : /************************************************************************/ 129 : 130 : class OGRIdrisiDriver final : public OGRSFDriver 131 : { 132 : public: 133 : virtual ~OGRIdrisiDriver(); 134 : 135 : virtual const char *GetName() override; 136 : virtual OGRDataSource *Open(const char *, int) override; 137 : virtual int TestCapability(const char *) override; 138 : }; 139 : 140 : #endif // ndef OGR_IDRISI_H_INCLUDED