SDTS_AL
sdts_al.h
1 /******************************************************************************
2  * $Id: sdts_al.h 26613 2013-11-14 17:42:08Z goatbar $
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 
102 
105  char *pszDatum;
106 
108  int nZone;
109 };
110 
111 /************************************************************************/
112 /* SDTS_CATD */
113 /************************************************************************/
114 class SDTS_CATDEntry;
115 
120 typedef enum {
121  SLTUnknown,
122  SLTPoint,
123  SLTLine,
124  SLTAttr,
125  SLTPoly,
126  SLTRaster
127 } SDTSLayerType;
128 
134 {
135  char *pszPrefixPath;
136 
137  int nEntries;
138  SDTS_CATDEntry **papoEntries;
139 
140  public:
141  SDTS_CATD();
142  ~SDTS_CATD();
143 
144  int Read( const char * pszFilename );
145 
146  const char *GetModuleFilePath( const char * pszModule );
147 
148  int GetEntryCount() { return nEntries; }
149  const char * GetEntryModule(int);
150  const char * GetEntryTypeDesc(int);
151  const char * GetEntryFilePath(int);
152  SDTSLayerType GetEntryType(int);
153 };
154 
155 /************************************************************************/
156 /* SDTSModId */
157 /************************************************************************/
158 
164 {
165  public:
166  SDTSModId() { szModule[0] = '\0';
167  nRecord = -1;
168  szOBRP[0] = '\0';
169  szName[0] = '\0'; }
170 
171  int Set( DDFField * );
172 
173  const char *GetName();
174 
176  char szModule[8];
177 
180  long nRecord;
181 
184  char szOBRP[8];
185 
187  char szName[20];
188 
189 
190 };
191 
192 /************************************************************************/
193 /* SDTSFeature */
194 /************************************************************************/
195 
201 {
202 public:
203 
204  SDTSFeature();
205  virtual ~SDTSFeature();
206 
209 
212 
216 
217  void ApplyATID( DDFField * );
218 
219 
221  virtual void Dump( FILE * ) = 0;
222 };
223 
224 /************************************************************************/
225 /* SDTSIndexedReader */
226 /************************************************************************/
227 
234 {
235  int nIndexSize;
236  SDTSFeature **papoFeatures;
237 
238  int iCurrentFeature;
239 
240 protected:
241  DDFModule oDDFModule;
242 
243 public:
245  virtual ~SDTSIndexedReader();
246 
247  virtual SDTSFeature *GetNextRawFeature() = 0;
248 
250 
251  virtual void Rewind();
252 
253  void FillIndex();
254  void ClearIndex();
255  int IsIndexed();
256 
258  char ** ScanModuleReferences( const char * = "ATID" );
259 
260  DDFModule *GetModule() { return &oDDFModule; }
261 };
262 
263 
264 /************************************************************************/
265 /* SDTSRawLine */
266 /************************************************************************/
267 
270 class SDTSRawLine : public SDTSFeature
271 {
272  public:
273  SDTSRawLine();
274  virtual ~SDTSRawLine();
275 
276  int Read( SDTS_IREF *, DDFRecord * );
277 
280 
282  double *padfX;
284  double *padfY;
286  double *padfZ;
287 
291 
295 
298  SDTSModId oStartNode; /* SNID */
299 
302  SDTSModId oEndNode; /* ENID */
303 
304  void Dump( FILE * );
305 };
306 
307 /************************************************************************/
308 /* SDTSLineReader */
309 /* */
310 /* Class for reading any of the files lines. */
311 /************************************************************************/
312 
322 {
323  SDTS_IREF *poIREF;
324 
325  public:
327  ~SDTSLineReader();
328 
329  int Open( const char * );
330  SDTSRawLine *GetNextLine( void );
331  void Close();
332 
333  SDTSFeature *GetNextRawFeature( void ) { return GetNextLine(); }
334 
335  void AttachToPolygons( SDTSTransfer *, int iPolyLayer );
336 };
337 
338 /************************************************************************/
339 /* SDTSAttrRecord */
340 /************************************************************************/
341 
352 {
353  public:
354  SDTSAttrRecord();
355  virtual ~SDTSAttrRecord();
356 
359 
364 
365  virtual void Dump( FILE * );
366 };
367 
368 /************************************************************************/
369 /* SDTSAttrReader */
370 /************************************************************************/
371 
378 {
379  SDTS_IREF *poIREF;
380 
381  int bIsSecondary;
382 
383  public:
385  virtual ~SDTSAttrReader();
386 
387  int Open( const char * );
388  DDFField *GetNextRecord( SDTSModId * = NULL,
389  DDFRecord ** = NULL,
390  int bDuplicate = FALSE );
391  SDTSAttrRecord *GetNextAttrRecord();
392  void Close();
393 
398  int IsSecondary() { return bIsSecondary; }
399 
400  SDTSFeature *GetNextRawFeature( void ) { return GetNextAttrRecord(); }
401 };
402 
403 /************************************************************************/
404 /* SDTSRawPoint */
405 /************************************************************************/
406 
410 class SDTSRawPoint : public SDTSFeature
411 {
412  public:
413  SDTSRawPoint();
414  virtual ~SDTSRawPoint();
415 
416  int Read( SDTS_IREF *, DDFRecord * );
417 
419  double dfX;
421  double dfY;
423  double dfZ;
424 
426  SDTSModId oAreaId; /* ARID */
427 
428  virtual void Dump( FILE * );
429 };
430 
431 /************************************************************************/
432 /* SDTSPointReader */
433 /************************************************************************/
434 
441 {
442  SDTS_IREF *poIREF;
443 
444  public:
446  virtual ~SDTSPointReader();
447 
448  int Open( const char * );
449  SDTSRawPoint *GetNextPoint( void );
450  void Close();
451 
452  SDTSFeature *GetNextRawFeature( void ) { return GetNextPoint(); }
453 };
454 
455 /************************************************************************/
456 /* SDTSRawPolygon */
457 /************************************************************************/
458 
477 {
478  void AddEdgeToRing( int, double *, double *, double *, int, int );
479 
480  public:
481  SDTSRawPolygon();
482  virtual ~SDTSRawPolygon();
483 
484  int Read( DDFRecord * );
485 
486  int nEdges;
487  SDTSRawLine **papoEdges;
488 
489  void AddEdge( SDTSRawLine * );
490 
493  int AssembleRings();
494 
496  int nRings;
502 
505  double *padfX;
508  double *padfY;
511  double *padfZ;
512 
513  virtual void Dump( FILE * );
514 };
515 
516 /************************************************************************/
517 /* SDTSPolygonReader */
518 /************************************************************************/
519 
523 {
524  int bRingsAssembled;
525 
526  public:
528  virtual ~SDTSPolygonReader();
529 
530  int Open( const char * );
531  SDTSRawPolygon *GetNextPolygon( void );
532  void Close();
533 
534  SDTSFeature *GetNextRawFeature( void ) { return GetNextPolygon(); }
535 
536  void AssembleRings( SDTSTransfer *, int iPolyLayer );
537 };
538 
539 /************************************************************************/
540 /* SDTSRasterReader */
541 /************************************************************************/
542 
552 {
553  DDFModule oDDFModule;
554 
555  char szModule[20];
556 
557  int nXSize;
558  int nYSize;
559  int nXBlockSize;
560  int nYBlockSize;
561 
562  int nXStart; /* SOCI */
563  int nYStart; /* SORI */
564 
565  double adfTransform[6];
566 
567  public:
568  char szINTR[4]; /* CE is center, TL is top left */
569  char szFMT[32];
570  char szUNITS[64];
571  char szLabel[64];
572 
574  ~SDTSRasterReader();
575 
576  int Open( SDTS_CATD * poCATD, SDTS_IREF *,
577  const char * pszModule );
578  void Close();
579 
580  int GetRasterType(); /* 1 = int16, see GDAL types */
581 #define SDTS_RT_INT16 1
582 #define SDTS_RT_FLOAT32 6
583 
584  int GetTransform( double * );
585 
586  int GetMinMax( double * pdfMin, double * pdfMax,
587  double dfNoData );
588 
594  int GetXSize() { return nXSize; }
600  int GetYSize() { return nYSize; }
601 
603  int GetBlockXSize() { return nXBlockSize; }
605  int GetBlockYSize() { return nYBlockSize; }
606 
607  int GetBlock( int nXOffset, int nYOffset, void * pData );
608 };
609 
610 /************************************************************************/
611 /* SDTSTransfer */
612 /************************************************************************/
613 
623 {
624  public:
625  SDTSTransfer();
626  ~SDTSTransfer();
627 
628  int Open( const char * );
629  void Close();
630 
631  int FindLayer( const char * );
632  int GetLayerCount() { return nLayers; }
633  SDTSLayerType GetLayerType( int );
634  int GetLayerCATDEntry( int );
635 
636  SDTSLineReader *GetLayerLineReader( int );
637  SDTSPointReader *GetLayerPointReader( int );
638  SDTSPolygonReader *GetLayerPolygonReader( int );
639  SDTSAttrReader *GetLayerAttrReader( int );
641  DDFModule *GetLayerModuleReader( int );
642 
644 
650  SDTS_CATD *GetCATD() { return &oCATD ; }
651 
652  SDTS_IREF *GetIREF() { return &oIREF; }
653 
659  SDTS_XREF *GetXREF() { return &oXREF; }
660 
661  SDTSFeature *GetIndexedFeatureRef( SDTSModId *,
662  SDTSLayerType *peType = NULL);
663 
664  DDFField *GetAttr( SDTSModId * );
665 
666  int GetBounds( double *pdfMinX, double *pdfMinY,
667  double *pdfMaxX, double *pdfMaxY );
668 
669  private:
670 
671  SDTS_CATD oCATD;
672  SDTS_IREF oIREF;
673  SDTS_XREF oXREF;
674 
675  int nLayers;
676  int *panLayerCATDEntry;
677  SDTSIndexedReader **papoLayerReader;
678 };
679 
680 #endif /* ifndef SDTS_AL_H_INCLUDED */
SDTSRasterReader * GetLayerRasterReader(int)
Definition: sdtstransfer.cpp:370
Definition: sdts_al.h:53
Definition: sdts_al.h:321
double * padfY
Definition: sdts_al.h:508
Definition: sdts_al.h:440
double * padfX
Definition: sdts_al.h:505
Definition: iso8211.h:490
Definition: sdts_al.h:351
const char * GetEntryTypeDesc(int)
Definition: sdtscatd.cpp:237
int nAttributes
Definition: sdts_al.h:211
int GetTransform(double *)
Definition: sdtsrasterreader.cpp:510
int AssembleRings()
Definition: sdtspolygonreader.cpp:217
SDTSModId oModId
Definition: sdts_al.h:208
int GetBlockXSize()
Definition: sdts_al.h:603
int Open(const char *)
Definition: sdtstransfer.cpp:70
int GetLayerCATDEntry(int)
Definition: sdtstransfer.cpp:218
int GetBlockYSize()
Definition: sdts_al.h:605
int GetMinMax(double *pdfMin, double *pdfMax, double dfNoData)
Definition: sdtsrasterreader.cpp:555
SDTSModId oLeftPoly
Definition: sdts_al.h:290
SDTSFeature * GetIndexedFeatureRef(int)
Definition: sdtsindexedreader.cpp:160
double dfY
Definition: sdts_al.h:421
Definition: sdts_al.h:133
int GetBounds(double *pdfMinX, double *pdfMinY, double *pdfMaxX, double *pdfMaxY)
Definition: sdtstransfer.cpp:604
virtual void Dump(FILE *)
Definition: sdtspointreader.cpp:108
int IsIndexed()
Definition: sdtsindexedreader.cpp:71
char ** ScanModuleReferences(const char *="ATID")
Definition: sdtsindexedreader.cpp:246
Definition: sdts_al.h:233
void AssembleRings(SDTSTransfer *, int iPolyLayer)
Definition: sdtspolygonreader.cpp:590
double * padfZ
Definition: sdts_al.h:511
DDFRecord * poWholeRecord
Definition: sdts_al.h:358
Definition: sdts_al.h:476
Definition: iso8211.h:80
SDTSLayerType GetEntryType(int)
Definition: sdtscatd.cpp:271
DDFField * poATTR
Definition: sdts_al.h:363
virtual void Dump(FILE *)
Definition: sdtsattrreader.cpp:67
Definition: sdts_al.h:163
double * padfY
Definition: sdts_al.h:284
virtual void Dump(FILE *)
Definition: sdtspolygonreader.cpp:462
void ClearIndex()
Definition: sdtsindexedreader.cpp:88
double dfZ
Definition: sdts_al.h:423
char szModule[8]
Definition: sdts_al.h:176
int * panRingStart
Definition: sdts_al.h:501
int nVertices
Definition: sdts_al.h:279
Definition: sdtscatd.cpp:46
void Dump(FILE *)
Definition: sdtslinereader.cpp:133
Definition: sdts_al.h:622
virtual void Rewind()
Definition: sdtsindexedreader.cpp:262
int GetYSize()
Definition: sdts_al.h:600
SDTSFeature * GetNextFeature()
Definition: sdtsindexedreader.cpp:122
SDTSModId oEndNode
Definition: sdts_al.h:302
int GetXSize()
Definition: sdts_al.h:594
char szOBRP[8]
Definition: sdts_al.h:184
Definition: sdts_al.h:522
char * pszSystemName
Definition: sdts_al.h:100
void FillIndex()
Definition: sdtsindexedreader.cpp:183
int nZone
Definition: sdts_al.h:108
void AttachToPolygons(SDTSTransfer *, int iPolyLayer)
Definition: sdtslinereader.cpp:273
int nVertices
Definition: sdts_al.h:498
SDTSModId * paoATID
Definition: sdts_al.h:215
int GetBlock(int nXOffset, int nYOffset, void *pData)
Definition: sdtsrasterreader.cpp:366
DDFField * GetAttr(SDTSModId *)
Definition: sdtstransfer.cpp:570
SDTSModId oStartNode
Definition: sdts_al.h:298
Definition: sdts_al.h:90
SDTS_CATD * GetCATD()
Definition: sdts_al.h:650
int GetRasterType()
Definition: sdtsrasterreader.cpp:529
Definition: sdts_al.h:377
SDTSModId oRightPoly
Definition: sdts_al.h:294
char * pszDatum
Definition: sdts_al.h:105
SDTSLayerType GetLayerType(int)
Definition: sdtstransfer.cpp:194
long nRecord
Definition: sdts_al.h:180
int FindLayer(const char *)
Definition: sdtstransfer.cpp:501
const char * GetEntryFilePath(int)
Definition: sdtscatd.cpp:314
double dfX
Definition: sdts_al.h:419
double * padfZ
Definition: sdts_al.h:286
SDTSIndexedReader * GetLayerIndexedReader(int)
Definition: sdtstransfer.cpp:457
int nRings
Definition: sdts_al.h:496
Definition: sdts_al.h:551
Definition: sdts_al.h:200
SDTSModId oAreaId
Definition: sdts_al.h:426
virtual void Dump(FILE *)=0
Definition: iso8211.h:383
Definition: sdts_al.h:410
SDTS_XREF * GetXREF()
Definition: sdts_al.h:659
int IsSecondary()
Definition: sdts_al.h:398
double * padfX
Definition: sdts_al.h:282
Definition: sdts_al.h:270
char szName[20]
Definition: sdts_al.h:187