SDTS_AL
sdts_al.h
1 /******************************************************************************
2  * $Id: sdts_al.h 36501 2016-11-25 14:09:24Z rouault $
3  *
4  * Project: SDTS Translator
5  * Purpose: Include file for entire SDTS Abstraction Layer functions.
6  * Author: Frank Warmerdam, warmerdam@pobox.com
7  *
8  ******************************************************************************
9  * Copyright (c) 1999, Frank Warmerdam
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 SDTS_AL_H_INCLUDED
31 #define SDTS_AL_H_INCLUDED
32 
33 #include "cpl_conv.h"
34 #include "iso8211.h"
35 
36 class SDTS_IREF;
37 class SDTSModId;
38 class SDTSTransfer;
39 
40 #define SDTS_SIZEOF_SADR 8
41 
42 char **SDTSScanModuleReferences( DDFModule *, const char * );
43 
44 /************************************************************************/
45 /* SDTS_IREF */
46 /************************************************************************/
47 
53 class SDTS_IREF
54 {
55  int nDefaultSADRFormat;
56 
57  public:
58  SDTS_IREF();
59  ~SDTS_IREF();
60 
61  int Read( const char *pszFilename );
62 
63  char *pszXAxisName; /* XLBL */
64  char *pszYAxisName; /* YLBL */
65 
66  double dfXScale; /* SFAX */
67  double dfYScale; /* SFAY */
68 
69  double dfXOffset; /* XORG */
70  double dfYOffset; /* YORG */
71 
72  double dfXRes; /* XHRS */
73  double dfYRes; /* YHRS */
74 
75  char *pszCoordinateFormat; /* HFMT */
76 
77  int GetSADRCount( DDFField * );
78  int GetSADR( DDFField *, int, double *, double *, double * );
79 };
80 
81 /************************************************************************/
82 /* SDTS_XREF */
83 /************************************************************************/
84 
90 class SDTS_XREF
91 {
92  public:
93  SDTS_XREF();
94  ~SDTS_XREF();
95 
96  int Read( const char *pszFilename );
97 
101 
104  char *pszDatum;
105 
107  int nZone;
108 };
109 
110 /************************************************************************/
111 /* SDTS_CATD */
112 /************************************************************************/
113 class SDTS_CATDEntry;
114 
119 typedef enum {
120  SLTUnknown,
121  SLTPoint,
122  SLTLine,
123  SLTAttr,
124  SLTPoly,
125  SLTRaster
126 } SDTSLayerType;
127 
133 {
134  char *pszPrefixPath;
135 
136  int nEntries;
137  SDTS_CATDEntry **papoEntries;
138 
139  public:
140  SDTS_CATD();
141  ~SDTS_CATD();
142 
143  int Read( const char * pszFilename );
144 
145  const char *GetModuleFilePath( const char * pszModule );
146 
147  int GetEntryCount() { return nEntries; }
148  const char * GetEntryModule(int);
149  const char * GetEntryTypeDesc(int);
150  const char * GetEntryFilePath(int);
151  SDTSLayerType GetEntryType(int);
152 };
153 
154 /************************************************************************/
155 /* SDTSModId */
156 /************************************************************************/
157 
163 {
164  public:
165  SDTSModId() { szModule[0] = '\0';
166  nRecord = -1;
167  szOBRP[0] = '\0';
168  szName[0] = '\0'; }
169 
170  int Set( DDFField * );
171 
172  const char *GetName();
173 
175  char szModule[8];
176 
179  int nRecord;
180 
183  char szOBRP[8];
184 
186  char szName[20];
187 };
188 
189 /************************************************************************/
190 /* SDTSFeature */
191 /************************************************************************/
192 
198 {
199 public:
200 
201  SDTSFeature();
202  virtual ~SDTSFeature();
203 
206 
209 
213 
214  void ApplyATID( DDFField * );
215 
217  virtual void Dump( FILE * ) = 0;
218 };
219 
220 /************************************************************************/
221 /* SDTSIndexedReader */
222 /************************************************************************/
223 
230 {
231  int nIndexSize;
232  SDTSFeature **papoFeatures;
233 
234  int iCurrentFeature;
235 
236 protected:
237  DDFModule oDDFModule;
238 
239 public:
241  virtual ~SDTSIndexedReader();
242 
243  virtual SDTSFeature *GetNextRawFeature() = 0;
244 
246 
247  virtual void Rewind();
248 
249  void FillIndex();
250  void ClearIndex();
251  int IsIndexed();
252 
254  char ** ScanModuleReferences( const char * = "ATID" );
255 
256  DDFModule *GetModule() { return &oDDFModule; }
257 };
258 
259 /************************************************************************/
260 /* SDTSRawLine */
261 /************************************************************************/
262 
265 class SDTSRawLine : public SDTSFeature
266 {
267  public:
268  SDTSRawLine();
269  virtual ~SDTSRawLine();
270 
271  int Read( SDTS_IREF *, DDFRecord * );
272 
275 
277  double *padfX;
279  double *padfY;
281  double *padfZ;
282 
286 
290 
293  SDTSModId oStartNode; /* SNID */
294 
297  SDTSModId oEndNode; /* ENID */
298 
299  void Dump( FILE * ) override;
300 };
301 
302 /************************************************************************/
303 /* SDTSLineReader */
304 /* */
305 /* Class for reading any of the files lines. */
306 /************************************************************************/
307 
317 {
318  SDTS_IREF *poIREF;
319 
320  public:
321  explicit SDTSLineReader( SDTS_IREF * );
322  ~SDTSLineReader();
323 
324  int Open( const char * );
325  SDTSRawLine *GetNextLine();
326  void Close();
327 
328  SDTSFeature *GetNextRawFeature() override { return GetNextLine(); }
329 
330  void AttachToPolygons( SDTSTransfer *, int iPolyLayer );
331 };
332 
333 /************************************************************************/
334 /* SDTSAttrRecord */
335 /************************************************************************/
336 
347 {
348  public:
349  SDTSAttrRecord();
350  virtual ~SDTSAttrRecord();
351 
354 
359 
360  virtual void Dump( FILE * ) override;
361 };
362 
363 /************************************************************************/
364 /* SDTSAttrReader */
365 /************************************************************************/
366 
373 {
374  int bIsSecondary;
375 
376  public:
377  SDTSAttrReader();
378  virtual ~SDTSAttrReader();
379 
380  int Open( const char * );
381  DDFField *GetNextRecord( SDTSModId * = NULL,
382  DDFRecord ** = NULL,
383  int bDuplicate = FALSE );
384  SDTSAttrRecord *GetNextAttrRecord();
385  void Close();
386 
391  int IsSecondary() { return bIsSecondary; }
392 
393  SDTSFeature *GetNextRawFeature() override { return GetNextAttrRecord(); }
394 };
395 
396 /************************************************************************/
397 /* SDTSRawPoint */
398 /************************************************************************/
399 
403 class SDTSRawPoint : public SDTSFeature
404 {
405  public:
406  SDTSRawPoint();
407  virtual ~SDTSRawPoint();
408 
409  int Read( SDTS_IREF *, DDFRecord * );
410 
412  double dfX;
414  double dfY;
416  double dfZ;
417 
419  SDTSModId oAreaId; /* ARID */
420 
421  virtual void Dump( FILE * ) override;
422 };
423 
424 /************************************************************************/
425 /* SDTSPointReader */
426 /************************************************************************/
427 
434 {
435  SDTS_IREF *poIREF;
436 
437  public:
438  explicit SDTSPointReader( SDTS_IREF * );
439  virtual ~SDTSPointReader();
440 
441  int Open( const char * );
442  SDTSRawPoint *GetNextPoint();
443  void Close();
444 
445  SDTSFeature *GetNextRawFeature() override { return GetNextPoint(); }
446 };
447 
448 /************************************************************************/
449 /* SDTSRawPolygon */
450 /************************************************************************/
451 
470 {
471  void AddEdgeToRing( int, double *, double *, double *, int, int );
472 
473  public:
474  SDTSRawPolygon();
475  virtual ~SDTSRawPolygon();
476 
477  int Read( DDFRecord * );
478 
479  int nEdges;
480  SDTSRawLine **papoEdges;
481 
482  void AddEdge( SDTSRawLine * );
483 
486  int AssembleRings();
487 
489  int nRings;
495 
498  double *padfX;
501  double *padfY;
504  double *padfZ;
505 
506  virtual void Dump( FILE * ) override;
507 };
508 
509 /************************************************************************/
510 /* SDTSPolygonReader */
511 /************************************************************************/
512 
516 {
517  int bRingsAssembled;
518 
519  public:
521  virtual ~SDTSPolygonReader();
522 
523  int Open( const char * );
524  SDTSRawPolygon *GetNextPolygon();
525  void Close();
526 
527  SDTSFeature *GetNextRawFeature() override { return GetNextPolygon(); }
528 
529  void AssembleRings( SDTSTransfer *, int iPolyLayer );
530 };
531 
532 /************************************************************************/
533 /* SDTSRasterReader */
534 /************************************************************************/
535 
545 {
546  DDFModule oDDFModule;
547 
548  char szModule[20];
549 
550  int nXSize;
551  int nYSize;
552  int nXBlockSize;
553  int nYBlockSize;
554 
555  int nXStart; /* SOCI */
556  int nYStart; /* SORI */
557 
558  double adfTransform[6];
559 
560  public:
561  char szINTR[4]; /* CE is center, TL is top left */
562  char szFMT[32];
563  char szUNITS[64];
564  char szLabel[64];
565 
567  ~SDTSRasterReader();
568 
569  int Open( SDTS_CATD * poCATD, SDTS_IREF *,
570  const char * pszModule );
571  void Close();
572 
573  int GetRasterType(); /* 1 = int16, see GDAL types */
574 #define SDTS_RT_INT16 1
575 #define SDTS_RT_FLOAT32 6
576 
577  int GetTransform( double * );
578 
579  int GetMinMax( double * pdfMin, double * pdfMax,
580  double dfNoData );
581 
587  int GetXSize() { return nXSize; }
593  int GetYSize() { return nYSize; }
594 
596  int GetBlockXSize() { return nXBlockSize; }
598  int GetBlockYSize() { return nYBlockSize; }
599 
600  int GetBlock( int nXOffset, int nYOffset, void * pData );
601 };
602 
603 /************************************************************************/
604 /* SDTSTransfer */
605 /************************************************************************/
606 
616 {
617  public:
618  SDTSTransfer();
619  ~SDTSTransfer();
620 
621  int Open( const char * );
622  void Close();
623 
624  int FindLayer( const char * );
625  int GetLayerCount() { return nLayers; }
626  SDTSLayerType GetLayerType( int );
627  int GetLayerCATDEntry( int );
628 
629  SDTSLineReader *GetLayerLineReader( int );
630  SDTSPointReader *GetLayerPointReader( int );
631  SDTSPolygonReader *GetLayerPolygonReader( int );
632  SDTSAttrReader *GetLayerAttrReader( int );
634  DDFModule *GetLayerModuleReader( int );
635 
637 
643  SDTS_CATD *GetCATD() { return &oCATD ; }
644 
645  SDTS_IREF *GetIREF() { return &oIREF; }
646 
652  SDTS_XREF *GetXREF() { return &oXREF; }
653 
654  SDTSFeature *GetIndexedFeatureRef( SDTSModId *,
655  SDTSLayerType *peType = NULL);
656 
657  DDFField *GetAttr( SDTSModId * );
658 
659  int GetBounds( double *pdfMinX, double *pdfMinY,
660  double *pdfMaxX, double *pdfMaxY );
661 
662  private:
663 
664  SDTS_CATD oCATD;
665  SDTS_IREF oIREF;
666  SDTS_XREF oXREF;
667 
668  int nLayers;
669  int *panLayerCATDEntry;
670  SDTSIndexedReader **papoLayerReader;
671 };
672 
673 #endif /* ifndef SDTS_AL_H_INCLUDED */
SDTSRasterReader * GetLayerRasterReader(int)
Definition: sdtstransfer.cpp:345
Definition: sdts_al.h:53
Definition: sdts_al.h:316
double * padfY
Definition: sdts_al.h:501
Definition: sdts_al.h:433
double * padfX
Definition: sdts_al.h:498
Definition: iso8211.h:511
Definition: sdts_al.h:346
const char * GetEntryTypeDesc(int)
Definition: sdtscatd.cpp:226
int nAttributes
Definition: sdts_al.h:208
int GetTransform(double *)
Definition: sdtsrasterreader.cpp:509
int AssembleRings()
Definition: sdtspolygonreader.cpp:222
SDTSModId oModId
Definition: sdts_al.h:205
int GetBlockXSize()
Definition: sdts_al.h:596
int Open(const char *)
Definition: sdtstransfer.cpp:68
int GetLayerCATDEntry(int)
Definition: sdtstransfer.cpp:213
int GetBlockYSize()
Definition: sdts_al.h:598
int GetMinMax(double *pdfMin, double *pdfMax, double dfNoData)
Definition: sdtsrasterreader.cpp:554
SDTSModId oLeftPoly
Definition: sdts_al.h:285
SDTSFeature * GetIndexedFeatureRef(int)
Definition: sdtsindexedreader.cpp:155
double dfY
Definition: sdts_al.h:414
Definition: sdts_al.h:132
int GetBounds(double *pdfMinX, double *pdfMinY, double *pdfMaxX, double *pdfMaxY)
Definition: sdtstransfer.cpp:564
virtual void Dump(FILE *) override
Definition: sdtspointreader.cpp:106
int IsIndexed()
Definition: sdtsindexedreader.cpp:68
char ** ScanModuleReferences(const char *="ATID")
Definition: sdtsindexedreader.cpp:240
Definition: sdts_al.h:229
void AssembleRings(SDTSTransfer *, int iPolyLayer)
Definition: sdtspolygonreader.cpp:582
double * padfZ
Definition: sdts_al.h:504
DDFRecord * poWholeRecord
Definition: sdts_al.h:353
Definition: sdts_al.h:469
Definition: iso8211.h:79
SDTSLayerType GetEntryType(int)
Definition: sdtscatd.cpp:260
DDFField * poATTR
Definition: sdts_al.h:358
Definition: sdts_al.h:162
double * padfY
Definition: sdts_al.h:279
void ClearIndex()
Definition: sdtsindexedreader.cpp:85
double dfZ
Definition: sdts_al.h:416
char szModule[8]
Definition: sdts_al.h:175
int * panRingStart
Definition: sdts_al.h:494
int nVertices
Definition: sdts_al.h:274
Definition: sdtscatd.cpp:44
Definition: sdts_al.h:615
virtual void Rewind()
Definition: sdtsindexedreader.cpp:256
int GetYSize()
Definition: sdts_al.h:593
SDTSFeature * GetNextFeature()
Definition: sdtsindexedreader.cpp:119
SDTSModId oEndNode
Definition: sdts_al.h:297
int GetXSize()
Definition: sdts_al.h:587
char szOBRP[8]
Definition: sdts_al.h:183
Definition: sdts_al.h:515
char * pszSystemName
Definition: sdts_al.h:100
void FillIndex()
Definition: sdtsindexedreader.cpp:178
int nZone
Definition: sdts_al.h:107
void AttachToPolygons(SDTSTransfer *, int iPolyLayer)
Definition: sdtslinereader.cpp:266
int nVertices
Definition: sdts_al.h:491
SDTSModId * paoATID
Definition: sdts_al.h:212
int GetBlock(int nXOffset, int nYOffset, void *pData)
Definition: sdtsrasterreader.cpp:365
DDFField * GetAttr(SDTSModId *)
Definition: sdtstransfer.cpp:531
SDTSModId oStartNode
Definition: sdts_al.h:293
Definition: sdts_al.h:90
SDTS_CATD * GetCATD()
Definition: sdts_al.h:643
int GetRasterType()
Definition: sdtsrasterreader.cpp:528
Definition: sdts_al.h:372
SDTSModId oRightPoly
Definition: sdts_al.h:289
int nRecord
Definition: sdts_al.h:179
char * pszDatum
Definition: sdts_al.h:104
SDTSLayerType GetLayerType(int)
Definition: sdtstransfer.cpp:189
int FindLayer(const char *)
Definition: sdtstransfer.cpp:466
const char * GetEntryFilePath(int)
Definition: sdtscatd.cpp:303
double dfX
Definition: sdts_al.h:412
double * padfZ
Definition: sdts_al.h:281
SDTSIndexedReader * GetLayerIndexedReader(int)
Definition: sdtstransfer.cpp:422
int nRings
Definition: sdts_al.h:489
Definition: sdts_al.h:544
Definition: sdts_al.h:197
SDTSModId oAreaId
Definition: sdts_al.h:419
virtual void Dump(FILE *)=0
void Dump(FILE *) override
Definition: sdtslinereader.cpp:132
virtual void Dump(FILE *) override
Definition: sdtspolygonreader.cpp:464
Definition: iso8211.h:393
Definition: sdts_al.h:403
SDTS_XREF * GetXREF()
Definition: sdts_al.h:652
int IsSecondary()
Definition: sdts_al.h:391
double * padfX
Definition: sdts_al.h:277
Definition: sdts_al.h:265
virtual void Dump(FILE *) override
Definition: sdtsattrreader.cpp:63
char szName[20]
Definition: sdts_al.h:186