1 /****************************************************************************** 2 * $Id: ogr_nas.h 365a72f2b5a94946e92323060b68f9963cd2dbd5 2018-05-06 22:14:36 +0200 Even Rouault $ 3 * 4 * Project: NAS Reader 5 * Purpose: Declarations for OGR wrapper classes for NAS, and NAS<->OGR 6 * translation of geometry. 7 * Author: Frank Warmerdam, warmerdam@pobox.com 8 * 9 ****************************************************************************** 10 * Copyright (c) 2002, Frank Warmerdam 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 OR 23 * 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_NAS_H_INCLUDED 32 #define OGR_NAS_H_INCLUDED 33 34 #include "ogrsf_frmts.h" 35 #include "nasreaderp.h" 36 #include "ogr_api.h" 37 #include <vector> 38 39 class OGRNASDataSource; 40 41 /************************************************************************/ 42 /* OGRNASLayer */ 43 /************************************************************************/ 44 45 class OGRNASLayer final: public OGRLayer 46 { 47 OGRFeatureDefn *poFeatureDefn; 48 49 int iNextNASId; 50 51 OGRNASDataSource *poDS; 52 53 GMLFeatureClass *poFClass; 54 55 public: 56 OGRNASLayer( const char * pszName, 57 OGRNASDataSource *poDS ); 58 59 virtual ~OGRNASLayer(); 60 61 void ResetReading() override; 62 OGRFeature * GetNextFeature() override; 63 64 GIntBig GetFeatureCount( int bForce = TRUE ) override; 65 OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE) override; GetExtent(int iGeomField,OGREnvelope * psExtent,int bForce)66 virtual OGRErr GetExtent(int iGeomField, OGREnvelope *psExtent, int bForce) override 67 { return OGRLayer::GetExtent(iGeomField, psExtent, bForce); } 68 GetLayerDefn()69 OGRFeatureDefn * GetLayerDefn() override { return poFeatureDefn; } 70 71 int TestCapability( const char * ) override; 72 }; 73 74 /************************************************************************/ 75 /* OGRNASRelationLayer */ 76 /************************************************************************/ 77 78 class OGRNASRelationLayer final: public OGRLayer 79 { 80 OGRFeatureDefn *poFeatureDefn; 81 OGRNASDataSource *poDS; 82 83 bool bPopulated; 84 int iNextFeature; 85 std::vector<CPLString> aoRelationCollection; 86 87 public: 88 explicit OGRNASRelationLayer( OGRNASDataSource *poDS ); 89 ~OGRNASRelationLayer(); 90 91 void ResetReading() override; 92 OGRFeature * GetNextFeature() override; 93 94 GIntBig GetFeatureCount( int bForce = TRUE ) override; GetLayerDefn()95 OGRFeatureDefn * GetLayerDefn() override { return poFeatureDefn; } 96 int TestCapability( const char * ) override; 97 98 // For use populating. 99 void AddRelation( const char *pszFromID, 100 const char *pszType, 101 const char *pszToID ); MarkRelationsPopulated()102 void MarkRelationsPopulated() { bPopulated = true; } 103 }; 104 105 /************************************************************************/ 106 /* OGRNASDataSource */ 107 /************************************************************************/ 108 109 class OGRNASDataSource final: public OGRDataSource 110 { 111 OGRLayer **papoLayers; 112 int nLayers; 113 114 OGRNASRelationLayer *poRelationLayer; 115 116 char *pszName; 117 118 OGRNASLayer *TranslateNASSchema( GMLFeatureClass * ); 119 120 // input related parameters. 121 IGMLReader *poReader; 122 123 void InsertHeader(); 124 125 public: 126 OGRNASDataSource(); 127 ~OGRNASDataSource(); 128 129 int Open( const char * ); 130 int Create( const char *pszFile, char **papszOptions ); 131 GetName()132 const char *GetName() override { return pszName; } GetLayerCount()133 int GetLayerCount() override { return nLayers; } 134 OGRLayer *GetLayer( int ) override; 135 136 int TestCapability( const char * ) override; 137 GetReader()138 IGMLReader *GetReader() { return poReader; } 139 140 void GrowExtents( OGREnvelope *psGeomBounds ); 141 142 void PopulateRelations(); 143 }; 144 145 #endif /* OGR_NAS_H_INCLUDED */ 146