⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mitab.h

📁 mitab,读取MapInfo的地图文件
💻 H
📖 第 1 页 / 共 5 页
字号:
/**********************************************************************
 * $Id: mitab.h,v 1.111.2.1 2008/04/21 19:57:28 dmorissette Exp $
 *
 * Name:     mitab.h
 * Project:  MapInfo TAB Read/Write library
 * Language: C++
 * Purpose:  Header file containing public definitions for the library.
 * Author:   Daniel Morissette, dmorissette@dmsolutions.ca
 *
 **********************************************************************
 * Copyright (c) 1999-2005, Daniel Morissette
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 * DEALINGS IN THE SOFTWARE.
 **********************************************************************
 *
 * $Log: mitab.h,v $
 * Revision 1.111.2.1  2008/04/21 19:57:28  dmorissette
 * Update for 1.7.0 release
 *
 * Revision 1.111  2008/02/29 21:27:41  dmorissette
 * Update to v1.7.0-beta1
 *
 * Revision 1.110  2008/02/20 21:35:30  dmorissette
 * Added support for V800 COLLECTION of large objects (bug 1496)
 *
 * Revision 1.109  2008/02/13 21:10:43  dmorissette
 * Fixed error in TAB_GEOM_GET_VERSION() macro logic
 *
 * Revision 1.108  2008/02/05 22:21:59  dmorissette
 * Added macro TAB_GEOM_GET_VERSION()
 *
 * Revision 1.107  2008/02/01 19:55:55  dmorissette
 * Set version to 1.7.0-dev
 *
 * Revision 1.106  2008/02/01 19:36:31  dmorissette
 * Initial support for V800 REGION and MULTIPLINE (bug 1496)
 *
 * Revision 1.105  2008/01/29 21:56:39  dmorissette
 * Update dataset version properly for Date/Time/DateTime field types (#1754)
 *
 * Revision 1.104  2007/12/11 04:26:29  dmorissette
 * Update for 1.6.4 release
 *
 * Revision 1.103  2007/10/12 15:47:48  dmorissette
 * Updated for 1.6.3 release
 *
 * Revision 1.102  2007/09/18 18:13:42  dmorissette
 * Updated for 1.6.3-beta2
 *
 * Revision 1.101  2007/09/14 20:03:08  dmorissette
 * Removed stray ReadGeometryFromMAPFile() declaration
 *
 * Revision 1.100  2007/09/14 19:42:39  dmorissette
 * Updated for 1.6.3-beta1
 *
 * Revision 1.99  2007/09/14 18:30:18  dmorissette
 * Fixed the splitting of object blocks with the optimized spatial
 * index mode that was producing files with misaligned bytes that
 * confused MapInfo (bug 1732)
 *
 * Revision 1.98  2007/09/12 20:22:31  dmorissette
 * Added TABFeature::CreateFromMapInfoType()
 *
 * Revision 1.97  2007/07/12 12:39:59  dmorissette
 * Set version to 1.6.2
 *
 * Revision 1.96  2007/06/12 14:48:44  dmorissette
 * Set version to 1.6.2-dev
 *
 * Revision 1.95  2007/06/12 14:17:16  dmorissette
 * Added TABFile::TwoPointLineAsPolyline() to allow writing two point lines
 * as polylines (bug 1735)
 *
 * Revision 1.94  2007/06/12 13:52:37  dmorissette
 * Added IMapInfoFile::SetCharset() method (bug 1734)
 *
 * Revision 1.93  2007/06/12 12:50:39  dmorissette
 * Use Quick Spatial Index by default until bug 1732 is fixed (broken files
 * produced by current coord block splitting technique).
 *
 * Revision 1.92  2007/03/30 18:05:49  dmorissette
 * Updated 1.6.1 release date
 *
 * Revision 1.91  2007/03/22 21:01:37  dmorissette
 * Update for v1.6.1
 *
 * Revision 1.90  2007/03/21 21:15:56  dmorissette
 * Added SetQuickSpatialIndexMode() which generates a non-optimal spatial
 * index but results in faster write time (bug 1669)
 *
 * Revision 1.89  2007/02/15 20:19:06  dmorissette
 * Update for v1.6.0
 *
 * Revision 1.88  2006/11/28 19:11:20  dmorissette
 * Set version to 1.6.0-dev
 *
 * Revision 1.87  2006/11/28 18:49:07  dmorissette
 * Completed changes to split TABMAPObjectBlocks properly and produce an
 * optimal spatial index (bug 1585)
 *
 * Revision 1.86  2006/11/20 20:05:58  dmorissette
 * First pass at improving generation of spatial index in .map file (bug 1585)
 * New methods for insertion and splittung in the spatial index are done.
 * Also implemented a method to dump the spatial index to .mif/.mid
 * Still need to implement splitting of TABMapObjectBlock to get optimal
 * results.
 *
 * Revision 1.85  2006/07/25 13:24:47  dmorissette
 * Updated for 1.5.1 release
 *
 * Revision 1.84  2006/07/25 13:22:58  dmorissette
 * Fixed initialization of MBR of TABCollection members (bug 1520)
 *
 * Revision 1.83  2006/02/16 15:13:38  dmorissette
 * Updated for 1.5.0 release
 *
 * Revision 1.82  2005/10/07 18:54:23  dmorissette
 * Ready for 1.5.0-beta1 release
 *
 * Revision 1.81  2005/10/06 23:05:08  dmorissette
 * TABCollection: Added automated sync'ing of OGRFeature's geometry in
 * SetRegion/Pline/MpointDirectly() methods (bug 1126)
 *
 * Revision 1.80  2005/10/06 19:15:30  dmorissette
 * Collections: added support for reading/writing pen/brush/symbol ids and
 * for writing collection objects to .TAB/.MAP (bug 1126)
 *
 * Revision 1.79  2005/10/04 15:44:31  dmorissette
 * First round of support for Collection objects. Currently supports reading
 * from .TAB/.MAP and writing to .MIF. Still lacks symbol support and write
 * support. (Based in part on patch and docs from Jim Hope, bug 1126)
 *
 * Revision 1.78  2005/05/21 03:16:01  fwarmerdam
 * Removed m_poFilterGeom ... should have been done yesterday with spatial
 * filter overhaul.
 *
 * Revision 1.77  2005/05/19 21:10:50  fwarmerdam
 * changed to use OGRLayers spatial filter support
 *
 * Revision 1.76  2005/05/19 15:26:59  jlacroix
 * Implement a method to set the StyleString of a TABFeature.
 * This is done via the ITABFeaturePen, Brush and Symbol classes.
 *
 * Revision 1.75  2005/04/01 16:48:41  dmorissette
 * Updated 1.4.0 release date
 *
 * Revision 1.74  2005/03/23 20:36:09  dmorissette
 * Ready for V1.4.0
 *
 * Revision 1.73  2004/07/07 22:18:02  dmorissette
 * Updated 1.3.0 release date
 *
 * Revision 1.72  2004/06/30 20:22:31  dmorissette
 * Ready for V1.3.0
 *
 * Revision 1.71  2003/08/07 03:20:46  dmorissette
 * Added mitab_c_getlibversion() to C API. (Uffe K. - bug 21)
 *
 * Revision 1.70  2003/07/24 02:47:58  daniel
 * Version 1.2.4
 *
 * ...
 *
 * Revision 1.1  1999/07/12 04:18:23  daniel
 * Initial checkin
 *
 **********************************************************************/

#ifndef _MITAB_H_INCLUDED_
#define _MITAB_H_INCLUDED_

#include "mitab_priv.h"
#include "ogr_feature.h"
#include "ogr_featurestyle.h"
#include "ogrsf_frmts.h"

/*---------------------------------------------------------------------
 * Current version of the MITAB library... always useful!
 *--------------------------------------------------------------------*/
#define MITAB_VERSION      "1.7.0 (2008-04-21)"
#define MITAB_VERSION_INT  1007000  /* version x.y.z -> xxxyyyzzz */

#ifndef PI
#  define PI 3.14159265358979323846
#endif

#ifndef ROUND_INT
#  define ROUND_INT(dX) ((int)((dX) < 0.0 ? (dX)-0.5 : (dX)+0.5 ))
#endif


#define MITAB_AREA(x1, y1, x2, y2)  ((double)((x2)-(x1))*(double)((y2)-(y1)))

class TABFeature;

/*---------------------------------------------------------------------
 * Codes for the GetFileClass() in the IMapInfoFile-derived  classes
 *--------------------------------------------------------------------*/
typedef enum
{
    TABFC_IMapInfoFile = 0,
    TABFC_TABFile,
    TABFC_TABView,
    TABFC_TABSeamless,
    TABFC_MIFFile
} TABFileClass;


/*---------------------------------------------------------------------
 *                      class IMapInfoFile
 *
 * Virtual base class for the TABFile and MIFFile classes.
 *
 * This is the definition of the public interface methods that should
 * be available for any type of MapInfo dataset.
 *--------------------------------------------------------------------*/

class IMapInfoFile : public OGRLayer
{
  private:

  protected: 
    int                 m_nCurFeatureId;
    TABFeature         *m_poCurFeature;
    GBool               m_bBoundsSet;

    char                *m_pszCharset;

  public:
    IMapInfoFile() ;
    virtual ~IMapInfoFile();

    virtual TABFileClass GetFileClass() {return TABFC_IMapInfoFile;}

    virtual int Open(const char *pszFname, const char *pszAccess,
                     GBool bTestOpenNoError = FALSE ) = 0;
    virtual int Close() = 0;

    virtual int SetQuickSpatialIndexMode(GBool bQuickSpatialIndexMode=TRUE) {return -1;}

    virtual const char *GetTableName() = 0;

    ///////////////
    // Static method to detect file type, create an object to read that
    // file and open it.
    static IMapInfoFile *SmartOpen(const char *pszFname,
                                   GBool bTestOpenNoError = FALSE);

    ///////////////
    //  OGR methods for read support
    virtual void        ResetReading() = 0;
    virtual int         GetFeatureCount (int bForce) = 0;
    virtual OGRFeature *GetNextFeature();
    virtual OGRFeature *GetFeature(long nFeatureId);
    virtual OGRErr      CreateFeature(OGRFeature *poFeature);
    virtual int         TestCapability( const char * pszCap ) =0;
    virtual int         GetExtent(OGREnvelope *psExtent, int bForce) =0;

    ///////////////
    // Read access specific stuff
    //
    virtual int GetNextFeatureId(int nPrevId) = 0;
    virtual TABFeature *GetFeatureRef(int nFeatureId) = 0;
    virtual OGRFeatureDefn *GetLayerDefn() = 0;

    virtual TABFieldType GetNativeFieldType(int nFieldId) = 0;

    virtual int GetBounds(double &dXMin, double &dYMin, 
                          double &dXMax, double &dYMax,
                          GBool bForce = TRUE ) = 0;
    
    virtual OGRSpatialReference *GetSpatialRef() = 0;

    virtual int GetFeatureCountByType(int &numPoints, int &numLines,
                                      int &numRegions, int &numTexts,
                                      GBool bForce = TRUE ) = 0;

    virtual GBool IsFieldIndexed(int nFieldId) = 0;
    virtual GBool IsFieldUnique(int nFieldId) = 0;

    ///////////////
    // Write access specific stuff
    //
    GBool       IsBoundsSet()            {return m_bBoundsSet;}
    virtual int SetBounds(double dXMin, double dYMin, 
                          double dXMax, double dYMax) = 0;
    virtual int SetFeatureDefn(OGRFeatureDefn *poFeatureDefn,
                            TABFieldType *paeMapInfoNativeFieldTypes = NULL)=0;
    virtual int AddFieldNative(const char *pszName, TABFieldType eMapInfoType,
                               int nWidth=0, int nPrecision=0,
                               GBool bIndexed=FALSE, GBool bUnique=FALSE) = 0;
    virtual OGRErr CreateField( OGRFieldDefn *poField, int bApproxOK = TRUE );
    
    virtual int SetSpatialRef(OGRSpatialReference *poSpatialRef) = 0;

    virtual int SetFeature(TABFeature *poFeature, int nFeatureId = -1) = 0;

    virtual int SetFieldIndexed(int nFieldId) = 0;

    virtual int SetCharset(const char* charset);

    ///////////////
    // semi-private.
    virtual int  GetProjInfo(TABProjInfo *poPI) = 0;
    virtual int  SetProjInfo(TABProjInfo *poPI) = 0;
    virtual int  SetMIFCoordSys(const char *pszMIFCoordSys) = 0;

#ifdef DEBUG
    virtual void Dump(FILE *fpOut = NULL) = 0;
#endif
};

/*---------------------------------------------------------------------
 *                      class TABFile
 *
 * The main class for TAB datasets.  External programs should use this
 * class to open a TAB dataset and read/write features from/to it.
 *
 *--------------------------------------------------------------------*/
class TABFile: public IMapInfoFile
{
  private:
    char        *m_pszFname;
    TABAccess   m_eAccessMode;
    char        **m_papszTABFile;
    int         m_nVersion;
    int         *m_panIndexNo;
    TABTableType m_eTableType;  // NATIVE (.DAT) or DBF

    TABDATFile  *m_poDATFile;   // Attributes file
    TABMAPFile  *m_poMAPFile;   // Object Geometry file
    TABINDFile  *m_poINDFile;   // Attributes index file

    OGRFeatureDefn *m_poDefn;
    OGRSpatialReference *m_poSpatialRef;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -