/src/gdal/ogr/ogrsf_frmts/pds/ogr_pds.h
Line | Count | Source |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Project: PDS Translator |
4 | | * Purpose: Definition of classes for OGR .pdstable driver. |
5 | | * Author: Even Rouault, even dot rouault at spatialys.com |
6 | | * |
7 | | ****************************************************************************** |
8 | | * Copyright (c) 2010, Even Rouault <even dot rouault at spatialys.com> |
9 | | * |
10 | | * SPDX-License-Identifier: MIT |
11 | | ****************************************************************************/ |
12 | | |
13 | | #ifndef OGR_PDS_H_INCLUDED |
14 | | #define OGR_PDS_H_INCLUDED |
15 | | |
16 | | #include "ogrsf_frmts.h" |
17 | | #include "nasakeywordhandler.h" |
18 | | |
19 | | namespace OGRPDS |
20 | | { |
21 | | |
22 | | /************************************************************************/ |
23 | | /* OGRPDSLayer */ |
24 | | /************************************************************************/ |
25 | | |
26 | | typedef enum |
27 | | { |
28 | | ASCII_REAL, |
29 | | ASCII_INTEGER, |
30 | | CHARACTER, |
31 | | MSB_INTEGER, |
32 | | MSB_UNSIGNED_INTEGER, |
33 | | IEEE_REAL, |
34 | | } FieldFormat; |
35 | | |
36 | | typedef struct |
37 | | { |
38 | | int nStartByte; |
39 | | int nByteCount; |
40 | | FieldFormat eFormat; |
41 | | int nItemBytes; |
42 | | int nItems; |
43 | | } FieldDesc; |
44 | | |
45 | | class OGRPDSLayer final : public OGRLayer, |
46 | | public OGRGetNextFeatureThroughRaw<OGRPDSLayer> |
47 | | { |
48 | | OGRFeatureDefn *poFeatureDefn; |
49 | | |
50 | | std::string osTableID; |
51 | | VSILFILE *fpPDS; |
52 | | int nRecords; |
53 | | int nStartBytes; |
54 | | int nRecordSize; |
55 | | GByte *pabyRecord; |
56 | | int nNextFID; |
57 | | int nLongitudeIndex; |
58 | | int nLatitudeIndex; |
59 | | |
60 | | FieldDesc *pasFieldDesc; |
61 | | |
62 | | void ReadStructure(const std::string &osStructureFilename); |
63 | | OGRFeature *GetNextRawFeature(); |
64 | | |
65 | | CPL_DISALLOW_COPY_ASSIGN(OGRPDSLayer) |
66 | | |
67 | | public: |
68 | | OGRPDSLayer(const std::string &osTableID, const char *pszLayerName, |
69 | | VSILFILE *fp, const std::string &osLabelFilename, |
70 | | const std::string &osStructureFilename, int nRecords, |
71 | | int nStartBytes, int nRecordSize, GByte *pabyRecord, |
72 | | bool bIsASCII); |
73 | | virtual ~OGRPDSLayer(); |
74 | | |
75 | | virtual void ResetReading() override; |
76 | | DEFINE_GET_NEXT_FEATURE_THROUGH_RAW(OGRPDSLayer) |
77 | | |
78 | | virtual OGRFeatureDefn *GetLayerDefn() override |
79 | 19.0k | { |
80 | 19.0k | return poFeatureDefn; |
81 | 19.0k | } |
82 | | |
83 | | virtual int TestCapability(const char *) override; |
84 | | |
85 | | virtual GIntBig GetFeatureCount(int bForce = TRUE) override; |
86 | | |
87 | | virtual OGRFeature *GetFeature(GIntBig nFID) override; |
88 | | |
89 | | virtual OGRErr SetNextByIndex(GIntBig nIndex) override; |
90 | | }; |
91 | | |
92 | | } // namespace OGRPDS |
93 | | |
94 | | /************************************************************************/ |
95 | | /* OGRPDSDataSource */ |
96 | | /************************************************************************/ |
97 | | |
98 | | class OGRPDSDataSource final : public GDALDataset |
99 | | { |
100 | | OGRLayer **papoLayers; |
101 | | int nLayers; |
102 | | |
103 | | NASAKeywordHandler oKeywords; |
104 | | |
105 | | CPLString osTempResult; |
106 | | const char *GetKeywordSub(const char *pszPath, int iSubscript, |
107 | | const char *pszDefault); |
108 | | |
109 | | bool LoadTable(const char *pszFilename, int nRecordSize, |
110 | | CPLString osTableID); |
111 | | |
112 | | public: |
113 | | OGRPDSDataSource(); |
114 | | virtual ~OGRPDSDataSource(); |
115 | | |
116 | | int Open(const char *pszFilename); |
117 | | |
118 | | virtual int GetLayerCount() override |
119 | 17.6k | { |
120 | 17.6k | return nLayers; |
121 | 17.6k | } |
122 | | |
123 | | virtual OGRLayer *GetLayer(int) override; |
124 | | |
125 | | static void CleanString(CPLString &osInput); |
126 | | }; |
127 | | |
128 | | #endif /* ndef OGR_PDS_H_INCLUDED */ |