Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

sdts_al.h

00001 /******************************************************************************
00002  * $Id: sdts_al.h,v 1.25 2001/09/10 19:27:36 warmerda Exp $
00003  *
00004  * Project:  SDTS Translator
00005  * Purpose:  Include file for entire SDTS Abstraction Layer functions.
00006  * Author:   Frank Warmerdam, warmerda@home.com
00007  *
00008  ******************************************************************************
00009  * Copyright (c) 1999, Frank Warmerdam
00010  *
00011  * Permission is hereby granted, free of charge, to any person obtaining a
00012  * copy of this software and associated documentation files (the "Software"),
00013  * to deal in the Software without restriction, including without limitation
00014  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00015  * and/or sell copies of the Software, and to permit persons to whom the
00016  * Software is furnished to do so, subject to the following conditions:
00017  *
00018  * The above copyright notice and this permission notice shall be included
00019  * in all copies or substantial portions of the Software.
00020  *
00021  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00022  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00023  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00024  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00025  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00026  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00027  * DEALINGS IN THE SOFTWARE.
00028  ******************************************************************************
00029  *
00030  * $Log: sdts_al.h,v $
00031  * Revision 1.25  2001/09/10 19:27:36  warmerda
00032  * added GetMinMax() and raster data types
00033  *
00034  * Revision 1.24  2001/01/19 21:20:29  warmerda
00035  * expanded tabs
00036  *
00037  * Revision 1.23  2000/02/03 19:44:51  warmerda
00038  * added method for getting bounds of transfer
00039  *
00040  * Revision 1.22  1999/11/12 13:12:35  warmerda
00041  * make adfTransform public
00042  *
00043  * Revision 1.21  1999/11/04 22:52:53  warmerda
00044  * added dynamic ATID support
00045  *
00046  * Revision 1.20  1999/10/01 14:49:42  warmerda
00047  * added Getmodule()
00048  *
00049  * Revision 1.19  1999/09/22 13:35:31  warmerda
00050  * added SDTSPolygonReader::AssembleRings()
00051  *
00052  * Revision 1.18  1999/09/21 17:25:45  warmerda
00053  * Added DDSH fields to raster reader.
00054  * Moved SADR reading onto SDTS_IREF.
00055  *
00056  * Revision 1.17  1999/09/21 02:23:25  warmerda
00057  * added logic to put outer ring first, and set ring direction
00058  *
00059  * Revision 1.16  1999/09/03 19:03:45  warmerda
00060  * fixed up help
00061  *
00062  * Revision 1.15  1999/09/03 13:34:45  warmerda
00063  * added duplicate flag on GetNextRecord
00064  *
00065  * Revision 1.14  1999/09/03 13:01:39  warmerda
00066  * added docs
00067  *
00068  * Revision 1.13  1999/09/02 03:40:03  warmerda
00069  * added indexed readers
00070  *
00071  * Revision 1.12  1999/08/16 20:59:28  warmerda
00072  * added szOBRP support for SDTSModId
00073  *
00074  * Revision 1.11  1999/08/16 19:24:45  warmerda
00075  * upped ATID limits, added polyreader method
00076  *
00077  * Revision 1.10  1999/08/16 15:45:46  warmerda
00078  * added IsSecondary()
00079  *
00080  * Revision 1.9  1999/08/10 02:52:13  warmerda
00081  * introduce use of SDTSApplyModIdList to capture multi-attributes
00082  *
00083  * Revision 1.8  1999/07/30 19:15:56  warmerda
00084  * added module reference counting
00085  *
00086  * Revision 1.7  1999/06/03 21:13:02  warmerda
00087  * Added transform for rasters.
00088  *
00089  * Revision 1.6  1999/06/03 14:04:10  warmerda
00090  * Added SDTS_XREF and SDTSRasterReader
00091  *
00092  * Revision 1.5  1999/05/11 14:05:59  warmerda
00093  * added SDTSTransfer and SDTSPolygonreader
00094  *
00095  * Revision 1.4  1999/05/07 13:45:01  warmerda
00096  * major upgrade to use iso8211lib
00097  *
00098  * Revision 1.3  1999/04/21 04:38:32  warmerda
00099  * Added new classes including SDTSPoint
00100  *
00101  * Revision 1.2  1999/03/23 15:58:01  warmerda
00102  * some const fixes, and attr record fixes
00103  *
00104  * Revision 1.1  1999/03/23 13:56:14  warmerda
00105  * New
00106  *
00107  */
00108 
00109 #ifndef SDTS_AL_H_INCLUDED
00110 #define STDS_AL_H_INCLUDED
00111 
00112 #include "cpl_conv.h"
00113 #include "iso8211.h"
00114 
00115 class SDTS_IREF;
00116 class SDTSModId;
00117 class SDTSTransfer;
00118 
00119 #define SDTS_SIZEOF_SADR        8
00120 
00121 char **SDTSScanModuleReferences( DDFModule *, const char * );
00122 
00123 /************************************************************************/
00124 /*                              SDTS_IREF                               */
00125 /************************************************************************/
00126 
00132 class SDTS_IREF
00133 {
00134     int         nDefaultSADRFormat;
00135     
00136   public:
00137                 SDTS_IREF();
00138                 ~SDTS_IREF();
00139 
00140     int         Read( const char *pszFilename );
00141 
00142     char        *pszXAxisName;                  /* XLBL */
00143     char        *pszYAxisName;                  /* YLBL */
00144 
00145     double      dfXScale;                       /* SFAX */
00146     double      dfYScale;                       /* SFAY */
00147 
00148     double      dfXOffset;                      /* XORG */
00149     double      dfYOffset;                      /* YORG */
00150 
00151     double      dfXRes;                         /* XHRS */
00152     double      dfYRes;                         /* YHRS */
00153 
00154     char        *pszCoordinateFormat;           /* HFMT */
00155 
00156     int         GetSADRCount( DDFField * );
00157     int         GetSADR( DDFField *, int, double *, double *, double * );
00158 };
00159 
00160 /************************************************************************/
00161 /*                              SDTS_XREF                               */
00162 /************************************************************************/
00163 
00169 class SDTS_XREF
00170 {
00171   public:
00172                 SDTS_XREF();
00173                 ~SDTS_XREF();
00174 
00175     int         Read( const char *pszFilename );
00176 
00179     char        *pszSystemName;         
00180                                   
00181 
00184     char        *pszDatum;              
00185                                   
00187     int         nZone;                        
00188 };
00189 
00190 /************************************************************************/
00191 /*                              SDTS_CATD                               */
00192 /************************************************************************/
00193 class SDTS_CATDEntry;
00194 
00199 typedef enum {
00200   SLTUnknown,
00201   SLTPoint,
00202   SLTLine,
00203   SLTAttr,
00204   SLTPoly,
00205   SLTRaster
00206 } SDTSLayerType;
00207 
00212 class SDTS_CATD
00213 {
00214     char        *pszPrefixPath;
00215 
00216     int         nEntries;
00217     SDTS_CATDEntry **papoEntries;
00218     
00219   public:
00220                 SDTS_CATD();
00221                 ~SDTS_CATD();
00222 
00223     int         Read( const char * pszFilename );
00224 
00225     const char  *GetModuleFilePath( const char * pszModule );
00226 
00227     int         GetEntryCount() { return nEntries; }
00228     const char * GetEntryModule(int);
00229     const char * GetEntryTypeDesc(int);
00230     const char * GetEntryFilePath(int);
00231     SDTSLayerType GetEntryType(int);
00232 };
00233 
00234 /************************************************************************/
00235 /*                              SDTSModId                               */
00236 /************************************************************************/
00237 
00242 class SDTSModId
00243 {
00244   public:
00245                 SDTSModId() { szModule[0] = '\0';
00246                               nRecord = -1;
00247                               szOBRP[0] = '\0'; }
00248 
00249     int         Set( DDFField * );
00250 
00251     const char *GetName();
00252 
00254     char        szModule[8];
00255 
00258     long        nRecord;
00259 
00262     char        szOBRP[8]; 
00263 };
00264 
00265 /************************************************************************/
00266 /*                             SDTSFeature                              */
00267 /************************************************************************/
00268 
00273 class SDTSFeature
00274 {
00275 public:
00276 
00277                         SDTSFeature();
00278     virtual            ~SDTSFeature();
00279 
00281     SDTSModId           oModId;
00282 
00284     int         nAttributes;
00285 
00288     SDTSModId   *paoATID;
00289 
00290     void        ApplyATID( DDFField * );
00291 
00292 
00294     virtual void Dump( FILE * ) = 0;
00295 };
00296 
00297 /************************************************************************/
00298 /*                          SDTSIndexedReader                           */
00299 /************************************************************************/
00300 
00306 class SDTSIndexedReader
00307 {
00308     int                 nIndexSize;
00309     SDTSFeature       **papoFeatures;
00310 
00311     int                 iCurrentFeature;
00312 
00313 protected:    
00314     DDFModule           oDDFModule;
00315 
00316 public:
00317                         SDTSIndexedReader();
00318     virtual            ~SDTSIndexedReader();
00319     
00320     virtual SDTSFeature  *GetNextRawFeature() = 0;
00321     
00322     SDTSFeature        *GetNextFeature();
00323 
00324     virtual void        Rewind();
00325     
00326     void                FillIndex();
00327     void                ClearIndex();
00328     int                 IsIndexed();
00329 
00330     SDTSFeature        *GetIndexedFeatureRef( int );
00331     char **             ScanModuleReferences( const char * = "ATID" );
00332 
00333     DDFModule          *GetModule() { return &oDDFModule; }
00334 };
00335 
00336 
00337 /************************************************************************/
00338 /*                             SDTSRawLine                              */
00339 /************************************************************************/
00340 
00343 class SDTSRawLine : public SDTSFeature
00344 {
00345   public:
00346                 SDTSRawLine();
00347     virtual    ~SDTSRawLine();
00348 
00349     int         Read( SDTS_IREF *, DDFRecord * );
00350 
00352     int         nVertices;
00353 
00355     double      *padfX;
00357     double      *padfY;
00359     double      *padfZ;
00360 
00363     SDTSModId   oLeftPoly;             
00364 
00367     SDTSModId   oRightPoly;
00368 
00371     SDTSModId   oStartNode;             /* SNID */
00372 
00375     SDTSModId   oEndNode;               /* ENID */
00376 
00377     void        Dump( FILE * );
00378 };
00379 
00380 /************************************************************************/
00381 /*                            SDTSLineReader                            */
00382 /*                                                                      */
00383 /*      Class for reading any of the files lines.                       */
00384 /************************************************************************/
00385 
00394 class SDTSLineReader : public SDTSIndexedReader
00395 {
00396     SDTS_IREF   *poIREF;
00397     
00398   public:
00399                 SDTSLineReader( SDTS_IREF * );
00400                 ~SDTSLineReader();
00401 
00402     int         Open( const char * );
00403     SDTSRawLine *GetNextLine( void );
00404     void        Close();
00405     
00406     SDTSFeature *GetNextRawFeature( void ) { return GetNextLine(); }
00407 
00408     void        AttachToPolygons( SDTSTransfer * );
00409 };
00410 
00411 /************************************************************************/
00412 /*                            SDTSAttrRecord                            */
00413 /************************************************************************/
00414 
00424 class SDTSAttrRecord : public SDTSFeature
00425 {
00426   public:
00427                 SDTSAttrRecord();
00428     virtual    ~SDTSAttrRecord();
00429 
00431     DDFRecord   *poWholeRecord;
00432 
00436     DDFField    *poATTR;
00437 
00438     virtual void Dump( FILE * );
00439 };
00440 
00441 /************************************************************************/
00442 /*                            SDTSAttrReader                            */
00443 /************************************************************************/
00444 
00450 class SDTSAttrReader : public SDTSIndexedReader
00451 {
00452     SDTS_IREF   *poIREF;
00453 
00454     int         bIsSecondary;
00455     
00456   public:
00457                 SDTSAttrReader( SDTS_IREF * );
00458    virtual     ~SDTSAttrReader();
00459 
00460     int         Open( const char * );
00461     DDFField    *GetNextRecord( SDTSModId * = NULL,
00462                                 DDFRecord ** = NULL,
00463                                 int bDuplicate = FALSE );
00464     SDTSAttrRecord *GetNextAttrRecord();
00465     void        Close();
00466 
00471     int         IsSecondary() { return bIsSecondary; }
00472     
00473     SDTSFeature *GetNextRawFeature( void ) { return GetNextAttrRecord(); }
00474 };
00475 
00476 /************************************************************************/
00477 /*                             SDTSRawPoint                             */
00478 /************************************************************************/
00479 
00483 class SDTSRawPoint : public SDTSFeature
00484 {
00485   public:
00486                 SDTSRawPoint();
00487     virtual    ~SDTSRawPoint();
00488 
00489     int         Read( SDTS_IREF *, DDFRecord * );
00490 
00492     double      dfX;
00494     double      dfY;
00496     double      dfZ;
00497 
00499     SDTSModId   oAreaId;                /* ARID */
00500 
00501     virtual void Dump( FILE * );
00502 };
00503 
00504 /************************************************************************/
00505 /*                           SDTSPointReader                            */
00506 /************************************************************************/
00507 
00513 class SDTSPointReader : public SDTSIndexedReader
00514 {
00515     SDTS_IREF   *poIREF;
00516     
00517   public:
00518                 SDTSPointReader( SDTS_IREF * );
00519     virtual    ~SDTSPointReader();
00520 
00521     int         Open( const char * );
00522     SDTSRawPoint *GetNextPoint( void );
00523     void        Close();
00524 
00525     SDTSFeature *GetNextRawFeature( void ) { return GetNextPoint(); }
00526 };
00527 
00528 /************************************************************************/
00529 /*                             SDTSRawPolygon                           */
00530 /************************************************************************/
00531 
00549 class SDTSRawPolygon : public SDTSFeature
00550 {
00551     void        AddEdgeToRing( int, double *, double *, double *, int, int );
00552     
00553   public:
00554                 SDTSRawPolygon();
00555     virtual    ~SDTSRawPolygon();
00556 
00557     int         Read( DDFRecord * );
00558 
00559     int         nEdges;
00560     SDTSRawLine **papoEdges;
00561 
00562     void        AddEdge( SDTSRawLine * );
00563 
00566     int         AssembleRings();
00567 
00569     int         nRings;
00571     int         nVertices;
00574     int         *panRingStart;
00575 
00578     double      *padfX;
00581     double      *padfY;
00584     double      *padfZ;
00585 
00586     virtual void Dump( FILE * );
00587 };
00588 
00589 /************************************************************************/
00590 /*                          SDTSPolygonReader                           */
00591 /************************************************************************/
00592 
00595 class SDTSPolygonReader : public SDTSIndexedReader
00596 {
00597     int         bRingsAssembled;
00598     
00599   public:
00600                 SDTSPolygonReader();
00601     virtual    ~SDTSPolygonReader();
00602 
00603     int         Open( const char * );
00604     SDTSRawPolygon *GetNextPolygon( void );
00605     void        Close();
00606 
00607     SDTSFeature *GetNextRawFeature( void ) { return GetNextPolygon(); }
00608 
00609     void        AssembleRings( SDTSTransfer * );
00610 };
00611 
00612 /************************************************************************/
00613 /*                           SDTSRasterReader                           */
00614 /************************************************************************/
00615 
00624 class SDTSRasterReader
00625 {
00626     DDFModule   oDDFModule;
00627 
00628     char        szModule[20];
00629 
00630     int         nXSize;
00631     int         nYSize;
00632     int         nXBlockSize;
00633     int         nYBlockSize;
00634 
00635     int         nXStart;                /* SOCI */
00636     int         nYStart;                /* SORI */
00637 
00638     double      adfTransform[6];
00639     
00640   public:
00641     char        szINTR[4];              /* CE is center, TL is top left */
00642     char        szFMT[32];
00643     char        szUNITS[64];
00644     char        szLabel[64];
00645 
00646                 SDTSRasterReader();
00647                 ~SDTSRasterReader();
00648 
00649     int         Open( SDTS_CATD * poCATD, SDTS_IREF *,
00650                       const char * pszModule  );
00651     void        Close();
00652 
00653     int         GetRasterType();        /* 1 = int16, see GDAL types */
00654 #define SDTS_RT_INT16   1   
00655 #define SDTS_RT_FLOAT32 6
00656 
00657     int         GetTransform( double * );
00658 
00659     int         GetMinMax( double * pdfMin, double * pdfMax,
00660                            double dfNoData );
00661 
00667     int         GetXSize() { return nXSize; }
00673     int         GetYSize() { return nYSize; }
00674 
00676     int         GetBlockXSize() { return nXBlockSize; }
00678     int         GetBlockYSize() { return nYBlockSize; }
00679 
00680     int         GetBlock( int nXOffset, int nYOffset, void * pData );
00681 };
00682 
00683 /************************************************************************/
00684 /*                             SDTSTransfer                             */
00685 /************************************************************************/
00686 
00695 class SDTSTransfer
00696 {
00697   public:
00698                 SDTSTransfer();
00699                 ~SDTSTransfer();
00700 
00701     int         Open( const char * );
00702     void        Close();
00703 
00704     int         FindLayer( const char * );
00705     int         GetLayerCount() { return nLayers; }
00706     SDTSLayerType GetLayerType( int );
00707     int         GetLayerCATDEntry( int );
00708 
00709     SDTSLineReader *GetLayerLineReader( int );
00710     SDTSPointReader *GetLayerPointReader( int );
00711     SDTSPolygonReader *GetLayerPolygonReader( int );
00712     SDTSAttrReader *GetLayerAttrReader( int );
00713     SDTSRasterReader *GetLayerRasterReader( int );
00714     DDFModule   *GetLayerModuleReader( int );
00715 
00716     SDTSIndexedReader *GetLayerIndexedReader( int );
00717 
00723     SDTS_CATD   *GetCATD() { return &oCATD ; }
00724 
00725     SDTS_IREF   *GetIREF() { return &oIREF; }
00726 
00732     SDTS_XREF   *GetXREF() { return &oXREF; }
00733 
00734     SDTSFeature *GetIndexedFeatureRef( SDTSModId *,
00735                                        SDTSLayerType *peType = NULL);
00736                 
00737     DDFField *GetAttr( SDTSModId * );
00738 
00739     int          GetBounds( double *pdfMinX, double *pdfMinY,
00740                             double *pdfMaxX, double *pdfMaxY );
00741     
00742   private:
00743 
00744     SDTS_CATD   oCATD;
00745     SDTS_IREF   oIREF;
00746     SDTS_XREF   oXREF;
00747 
00748     int         nLayers;
00749     int         *panLayerCATDEntry;
00750     SDTSIndexedReader **papoLayerReader;
00751 };
00752 
00753 #endif /* ndef SDTS_AL_H_INCLUDED */

Generated on Mon Oct 6 16:31:38 2003 for SDTS_AL by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002