Changeset 12358

Show
Ignore:
Timestamp:
10/09/07 13:49:17 (1 year ago)
Author:
warmerdam
Message:

refresh from upstream - corresponds roughly with 1.6.3 beta2 (#1883)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gdal/ogr/ogrsf_frmts/mitab/HISTORY.TXT

    r11971 r12358  
    1313CHANGES - Current Version: 
    1414-------------------------- 
     15 
     16Version 1.6.3-beta2 (2007-09-18) 
     17-------------------------------- 
     18 
     19- Fixed another issue related to splitting of object blocks with the  
     20  optimized spatial index. The compressed coordinate origin values were 
     21  not initialized properly before being written (bug 1732) 
     22 
     23- Remove static variables that interfere with reentrancy.  
     24  http://trac.osgeo.org/gdal/ticket/1883 
     25 
     26 
     27Version 1.6.3-beta1 (2007-09-14) 
     28-------------------------------- 
     29 
     30- Fixed the splitting of object blocks with the optimized spatial 
     31  index mode that was producing files with misaligned bytes that 
     32  confused MapInfo (bug 1732) 
     33  Note that even if this bug is (hopefully) fixed, the optimized spatial 
     34  index is still disabled by default in this release and we still use 
     35  the quick (i.e. traditional) spatial index mode by default. 
     36 
     37- Fixed problem with MIF parser being confused by special attribute  
     38  names (bug 1795) 
    1539 
    1640 
     
    813837 
    814838------------ 
    815 $Id: HISTORY.TXT,v 1.190 2007/07/31 21:06:51 dmorissette Exp $ 
     839$Id: HISTORY.TXT,v 1.195 2007/10/09 17:43:16 fwarmerdam Exp $ 
    816840------------ 
  • trunk/gdal/ogr/ogrsf_frmts/mitab/mitab.h

    r11971 r12358  
    11/********************************************************************** 
    2  * $Id: mitab.h,v 1.97 2007/07/12 12:39:59 dmorissette Exp $ 
     2 * $Id: mitab.h,v 1.102 2007/09/18 18:13:42 dmorissette Exp $ 
    33 * 
    44 * Name:     mitab.h 
     
    3131 * 
    3232 * $Log: mitab.h,v $ 
     33 * Revision 1.102  2007/09/18 18:13:42  dmorissette 
     34 * Updated for 1.6.3-beta2 
     35 * 
     36 * Revision 1.101  2007/09/14 20:03:08  dmorissette 
     37 * Removed stray ReadGeometryFromMAPFile() declaration 
     38 * 
     39 * Revision 1.100  2007/09/14 19:42:39  dmorissette 
     40 * Updated for 1.6.3-beta1 
     41 * 
     42 * Revision 1.99  2007/09/14 18:30:18  dmorissette 
     43 * Fixed the splitting of object blocks with the optimized spatial 
     44 * index mode that was producing files with misaligned bytes that 
     45 * confused MapInfo (bug 1732) 
     46 * 
     47 * Revision 1.98  2007/09/12 20:22:31  dmorissette 
     48 * Added TABFeature::CreateFromMapInfoType() 
     49 * 
    3350 * Revision 1.97  2007/07/12 12:39:59  dmorissette 
    3451 * Set version to 1.6.2 
     
    147164 * Current version of the MITAB library... always useful! 
    148165 *--------------------------------------------------------------------*/ 
    149 #define MITAB_VERSION      "1.6.2 (2007-07-12)" 
    150 #define MITAB_VERSION_INT  1006002  /* version x.y.z -> xxxyyyzzz */ 
     166#define MITAB_VERSION      "1.6.3-beta2 (2007-09-18)" 
     167#define MITAB_VERSION_INT  1006003  /* version x.y.z -> xxxyyyzzz */ 
    151168 
    152169#ifndef PI 
     
    10601077    virtual ~TABFeature(); 
    10611078 
     1079    static  TABFeature     *CreateFromMapInfoType(int nMapInfoType, 
     1080                                                  OGRFeatureDefn *poDefn); 
     1081 
    10621082    virtual TABFeature     *CloneTABFeature(OGRFeatureDefn *pNewDefn = NULL); 
    10631083    virtual TABFeatureClass GetFeatureClass() { return TABFCNoGeomFeature; }; 
     
    10741094 
    10751095    virtual int ReadRecordFromDATFile(TABDATFile *poDATFile); 
    1076     virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
     1096    virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1097                                        GBool bCoordDataOnly=FALSE, 
     1098                                        TABMAPCoordBlock **ppoCoordBlock=NULL); 
    10771099 
    10781100    virtual int WriteRecordToDATFile(TABDATFile *poDATFile, 
    10791101                                     TABINDFile *poINDFile, int *panIndexNo); 
    1080     virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
     1102    virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1103                                       GBool bCoordDataOnly=FALSE, 
     1104                                       TABMAPCoordBlock **ppoCoordBlock=NULL); 
    10811105    GBool       ValidateCoordType(TABMAPFile * poMapFile); 
    10821106    void        ForceCoordTypeAndOrigin(int nMapInfoType, GBool bCompr, 
     
    11051129    void        GetMBR(double &dXMin, double &dYMin,  
    11061130                       double &dXMax, double &dYMax); 
     1131    void        SetIntMBR(GInt32 nXMin, GInt32 nYMin,  
     1132                          GInt32 nXMax, GInt32 nYMax); 
    11071133    void        GetIntMBR(GInt32 &nXMin, GInt32 &nYMin,  
    11081134                          GInt32 &nXMax, GInt32 &nYMax); 
     
    11451171    double      GetY(); 
    11461172 
    1147     virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
    1148     virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
     1173    virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1174                                        GBool bCoordDataOnly=FALSE, 
     1175                                        TABMAPCoordBlock **ppoCoordBlock=NULL); 
     1176    virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1177                                       GBool bCoordDataOnly=FALSE, 
     1178                                       TABMAPCoordBlock **ppoCoordBlock=NULL); 
    11491179 
    11501180    virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp); 
     
    11851215    virtual TABFeature *CloneTABFeature(OGRFeatureDefn *poNewDefn = NULL ); 
    11861216 
    1187     virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
    1188     virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
     1217    virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1218                                        GBool bCoordDataOnly=FALSE, 
     1219                                        TABMAPCoordBlock **ppoCoordBlock=NULL); 
     1220    virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1221                                       GBool bCoordDataOnly=FALSE, 
     1222                                       TABMAPCoordBlock **ppoCoordBlock=NULL); 
    11891223 
    11901224    virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp); 
     
    12381272    virtual TABFeature *CloneTABFeature(OGRFeatureDefn *poNewDefn = NULL ); 
    12391273 
    1240     virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
    1241     virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
     1274    virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1275                                        GBool bCoordDataOnly=FALSE, 
     1276                                        TABMAPCoordBlock **ppoCoordBlock=NULL); 
     1277    virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1278                                       GBool bCoordDataOnly=FALSE, 
     1279                                       TABMAPCoordBlock **ppoCoordBlock=NULL); 
    12421280 
    12431281    virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp); 
     
    12921330    OGRLineString      *GetPartRef(int nPartIndex); 
    12931331 
    1294     int         ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
    1295                                         TABMAPCoordBlock **ppoCoordBlock); 
    1296  
    12971332    GBool       TwoPointLineAsPolyline(); 
    12981333    void        TwoPointLineAsPolyline(GBool bTwoPointLineAsPolyline); 
    12991334 
    1300     virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
    1301     virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
     1335    virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1336                                        GBool bCoordDataOnly=FALSE, 
     1337                                        TABMAPCoordBlock **ppoCoordBlock=NULL); 
     1338    virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1339                                       GBool bCoordDataOnly=FALSE, 
     1340                                       TABMAPCoordBlock **ppoCoordBlock=NULL); 
    13021341 
    13031342    virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp); 
     
    13681407    GBool               IsInteriorRing(int nRequestedRingIndex); 
    13691408 
    1370     int         ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
    1371                                         TABMAPCoordBlock **ppoCoordBlock); 
    1372     virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
    1373     virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
     1409    virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1410                                        GBool bCoordDataOnly=FALSE, 
     1411                                        TABMAPCoordBlock **ppoCoordBlock=NULL); 
     1412    virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1413                                       GBool bCoordDataOnly=FALSE, 
     1414                                       TABMAPCoordBlock **ppoCoordBlock=NULL); 
    13741415 
    13751416    virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp); 
     
    14171458    virtual TABFeature *CloneTABFeature(OGRFeatureDefn *poNewDefn = NULL ); 
    14181459 
    1419     virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
    1420     virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
     1460    virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1461                                        GBool bCoordDataOnly=FALSE, 
     1462                                        TABMAPCoordBlock **ppoCoordBlock=NULL); 
     1463    virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1464                                       GBool bCoordDataOnly=FALSE, 
     1465                                       TABMAPCoordBlock **ppoCoordBlock=NULL); 
    14211466 
    14221467    virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp); 
     
    14741519    virtual TABFeature *CloneTABFeature(OGRFeatureDefn *poNewDefn = NULL ); 
    14751520 
    1476     virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
    1477     virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
     1521    virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1522                                        GBool bCoordDataOnly=FALSE, 
     1523                                        TABMAPCoordBlock **ppoCoordBlock=NULL); 
     1524    virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1525                                       GBool bCoordDataOnly=FALSE, 
     1526                                       TABMAPCoordBlock **ppoCoordBlock=NULL); 
    14781527 
    14791528    virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp); 
     
    15321581    virtual TABFeature *CloneTABFeature(OGRFeatureDefn *poNewDefn = NULL ); 
    15331582 
    1534     virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
    1535     virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
     1583    virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1584                                        GBool bCoordDataOnly=FALSE, 
     1585                                        TABMAPCoordBlock **ppoCoordBlock=NULL); 
     1586    virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1587                                       GBool bCoordDataOnly=FALSE, 
     1588                                       TABMAPCoordBlock **ppoCoordBlock=NULL); 
    15361589 
    15371590    virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp); 
     
    16051658    virtual TABFeature *CloneTABFeature(OGRFeatureDefn *poNewDefn = NULL ); 
    16061659 
    1607     virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
    1608     virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
     1660    virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1661                                        GBool bCoordDataOnly=FALSE, 
     1662                                        TABMAPCoordBlock **ppoCoordBlock=NULL); 
     1663    virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1664                                       GBool bCoordDataOnly=FALSE, 
     1665                                       TABMAPCoordBlock **ppoCoordBlock=NULL); 
    16091666 
    16101667    virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp); 
     
    16871744    void        SetCenter(double dX, double dY); 
    16881745 
    1689     int         ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
    1690                                         TABMAPCoordBlock **ppoCoordBlock); 
    1691     virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
    1692     virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
     1746    virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1747                                        GBool bCoordDataOnly=FALSE, 
     1748                                        TABMAPCoordBlock **ppoCoordBlock=NULL); 
     1749    virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1750                                       GBool bCoordDataOnly=FALSE, 
     1751                                       TABMAPCoordBlock **ppoCoordBlock=NULL); 
    16931752 
    16941753    virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp); 
     
    17571816    virtual TABFeature *CloneTABFeature(OGRFeatureDefn *poNewDefn = NULL ); 
    17581817 
    1759     virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
    1760     virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
     1818    virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1819                                        GBool bCoordDataOnly=FALSE, 
     1820                                        TABMAPCoordBlock **ppoCoordBlock=NULL); 
     1821    virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1822                                       GBool bCoordDataOnly=FALSE, 
     1823                                       TABMAPCoordBlock **ppoCoordBlock=NULL); 
    17611824     
    17621825    virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp); 
     
    17981861    virtual TABFeatureClass GetFeatureClass() { return TABFCDebugFeature; }; 
    17991862 
    1800     virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
    1801     virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *); 
     1863    virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1864                                        GBool bCoordDataOnly=FALSE, 
     1865                                        TABMAPCoordBlock **ppoCoordBlock=NULL); 
     1866    virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *, 
     1867                                       GBool bCoordDataOnly=FALSE, 
     1868                                       TABMAPCoordBlock **ppoCoordBlock=NULL); 
    18021869 
    18031870    virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp); 
  • trunk/gdal/ogr/ogrsf_frmts/mitab/mitab_datfile.cpp

    r6276 r12358  
    11/********************************************************************** 
    2  * $Id: mitab_datfile.cpp,v 1.17 2004/06/30 20:29:03 dmorissette Exp $ 
     2 * $Id: mitab_datfile.cpp,v 1.18 2007/10/09 17:43:16 fwarmerdam Exp $ 
    33 * 
    44 * Name:     mitab_datfile.cpp 
     
    3232 * 
    3333 * $Log: mitab_datfile.cpp,v $ 
     34 * Revision 1.18  2007/10/09 17:43:16  fwarmerdam 
     35 * Remove static variables that interfere with reentrancy. (GDAL #1883) 
     36 * 
    3437 * Revision 1.17  2004/06/30 20:29:03  dmorissette 
    3538 * Fixed refs to old address danmo@videotron.ca 
     
    820823const char *TABDATFile::ReadCharField(int nWidth) 
    821824{ 
    822     // We know that character strings are limited to 254 chars in MapInfo 
    823     static char szBuf[256]; 
    824  
    825825    // If current record has been deleted, then return an acceptable  
    826826    // default value. 
     
    842842    } 
    843843 
    844     if (m_poRecordBlock->ReadBytes(nWidth, (GByte*)szBuf) != 0) 
     844    if (m_poRecordBlock->ReadBytes(nWidth, (GByte*)m_szBuffer) != 0) 
    845845        return ""; 
    846846 
    847     szBuf[nWidth] = '\0'; 
     847    m_szBuffer[nWidth] = '\0'; 
    848848 
    849849    // NATIVE tables are padded with '\0' chars, but DBF tables are padded 
     
    851851    if (m_eTableType == TABTableDBF) 
    852852    { 
    853         int nLen = strlen(szBuf)-1; 
    854         while(nLen>=0 && szBuf[nLen] == ' ') 
    855             szBuf[nLen--] = '\0'; 
    856     } 
    857  
    858     return szBuf
     853        int nLen = strlen(m_szBuffer)-1; 
     854        while(nLen>=0 && m_szBuffer[nLen] == ' ') 
     855            m_szBuffer[nLen--] = '\0'; 
     856    } 
     857 
     858    return m_szBuffer
    859859} 
    860860 
     
    10121012{ 
    10131013    int nDay, nMonth, nYear; 
    1014     static char szBuf[20]; 
    10151014 
    10161015    // If current record has been deleted, then return an acceptable  
     
    10391038        return ""; 
    10401039 
    1041     sprintf(szBuf, "%4.4d%2.2d%2.2d", nYear, nMonth, nDay); 
    1042  
    1043     return szBuf
     1040    sprintf(m_szBuffer, "%4.4d%2.2d%2.2d", nYear, nMonth, nDay); 
     1041 
     1042    return m_szBuffer
    10441043} 
    10451044 
  • trunk/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp

    r11728 r12358  
    11/********************************************************************** 
    2  * $Id: mitab_feature.cpp,v 1.72 2007/06/12 14:17:16 dmorissette Exp $ 
     2 * $Id: mitab_feature.cpp,v 1.76 2007/09/18 17:43:56 dmorissette Exp $ 
    33 * 
    44 * Name:     mitab_feature.cpp 
     
    3131 * 
    3232 * $Log: mitab_feature.cpp,v $ 
     33 * Revision 1.76  2007/09/18 17:43:56  dmorissette 
     34 * Fixed another index splitting issue: compr coordinates origin was not 
     35 * stored in the TABFeature in ReadGeometry... (bug 1732) 
     36 * 
     37 * Revision 1.75  2007/09/14 19:29:24  dmorissette 
     38 * Completed handling of bCoordBlockDataOnly arg to Read/WriteGeometry() 
     39 * functions to avoid screwing up pen/brush ref counters (bug 1732) 
     40 * 
     41 * Revision 1.74  2007/09/14 18:30:19  dmorissette 
     42 * Fixed the splitting of object blocks with the optimized spatial 
     43 * index mode that was producing files with misaligned bytes that 
     44 * confused MapInfo (bug 1732) 
     45 * 
     46 * Revision 1.73  2007/09/12 20:22:31  dmorissette 
     47 * Added TABFeature::CreateFromMapInfoType() 
     48 * 
    3349 * Revision 1.72  2007/06/12 14:17:16  dmorissette 
    3450 * Added TABFile::TwoPointLineAsPolyline() to allow writing two point lines 
     
    6884 * geometry (GDAL bug 1059) 
    6985 * 
    70  * Revision 1.62  2005/11/08 22:02:36  fwarmerdam 
    71  * cast strstr() results as per email from Charles Savage for VC8. 
    72  * 
    73  * Revision 1.61  2005/10/12 19:13:30  jlacroix 
    74  * bug1012 Make sure Style Units are set when seting a feature from StyleString 
    75  * 
    76  * Revision 1.60  2005/10/07 21:22:33  dmorissette 
    77  * Clone region/pline/mpoint components in TABCollection::CloneTABFeature() 
    78  * 
    79  * Revision 1.59  2005/10/06 23:05:08  dmorissette 
    80  * TABCollection: Added automated sync'ing of OGRFeature's geometry in 
    81  * SetRegion/Pline/MpointDirectly() methods (bug 1126) 
    82  * 
    83  * Revision 1.58  2005/10/06 19:15:30  dmorissette 
    84  * Collections: added support for reading/writing pen/brush/symbol ids and 
    85  * for writing collection objects to .TAB/.MAP (bug 1126) 
    86  * 
    87  * Revision 1.57  2005/10/04 15:44:31  dmorissette 
    88  * First round of support for Collection objects. Currently supports reading 
    89  * from .TAB/.MAP and writing to .MIF. Still lacks symbol support and write 
    90  * support. (Based in part on patch and docs from Jim Hope, bug 1126) 
    91  * 
    92  * Revision 1.56  2005/07/14 16:15:05  jlacroix 
    93  * \n and \ are now unescaped internally. 
    94  * 
    95  * Revision 1.55  2005/05/19 15:26:59  jlacroix 
    96  * Implement a method to set the StyleString of a TABFeature. 
    97  * This is done via the ITABFeaturePen, Brush and Symbol classes. 
    98  * 
    99  * Revision 1.54  2004/12/01 18:25:03  dmorissette 
    100  * Fixed potential memory leaks in error conditions (bug 881) 
    101  * 
    102  * Revision 1.53  2004/10/19 14:21:11  jlacroix 
    103  * Support pen width bigger than 7 with GetStyleString. (Bug 683) 
    104  * 
    105  * Revision 1.52  2004/10/11 20:18:27  dmorissette 
    106  * Do not output a BG color in style string for transparent brushes (bug 693) 
    107  * 
    108  * Revision 1.51  2004/06/30 20:29:03  dmorissette 
    109  * Fixed refs to old address danmo@videotron.ca 
    110  * 
    111  * Revision 1.50  2003/12/19 08:30:10  fwarmerdam 
    112  * write 3d geometries to tab in 2D 
    113  * 
    114  * Revision 1.49  2003/03/28 14:01:14  warmerda 
    115  * use TRUE/FALSE in place of true/false 
    116  * 
    117  * Revision 1.48  2002/08/27 17:17:33  warmerda 
    118  * handle errors better, auto-add FID column if there aren't any columns 
    119  * 
    120  * Revision 1.47  2002/06/17 15:00:30  julien 
    121  * Add IsInteriorRing() function in TABRegion to validate if a ring is internal 
    122  * 
    123  * Revision 1.46  2002/03/26 03:17:13  daniel 
    124  * Added Get/SetCenter() to MultiPoint 
    125  * 
    126  * Revision 1.45  2002/03/26 01:48:40  daniel 
    127  * Added Multipoint object type (V650) 
    128  * 
    129  * Revision 1.44  2002/01/23 20:29:56  daniel 
    130  * Fixed warning produced by CPLAssert() in non-DEBUG mode. 
    131  * 
    132  * Revision 1.43  2001/12/05 22:38:59  daniel 
    133  * Fixed problems writing TAB_GEOM_LINE (bug 610, 633). 
    134  * 
    135  * Revision 1.42  2001/11/23 22:50:17  daniel 
    136  * Fixed geometry type assertion in TABPolyline::WriteGeomToMAPFile (bug605) 
    137  * 
    138  * Revision 1.41  2001/11/17 21:54:06  daniel 
    139  * Made several changes in order to support writing objects in 16 bits  
    140  * coordinate format.  New TABMAPObjHdr-derived classes are used to hold  
    141  * object info in mem until block is full. 
    142  * 
    143  * Revision 1.40  2001/09/17 21:33:44  daniel 
    144  * TABText: do not produce an error when reading 0-length text strings. 
    145  * 
    146  * Revision 1.39  2001/09/05 13:33:33  daniel 
    147  * TABPolyline::ValidateMapInfoType(): return TAB_GEOM_NONE if numpoints < 2 
    148  * 
    149  * Revision 1.38  2001/07/03 03:14:52  daniel 
    150  * GetLabelStyleString(): take line spacing and num. of lines into account 
    151  * when calculating text height. 
    152  * 
    153  * Revision 1.37  2001/06/25 01:04:21  daniel 
    154  * StyleString fixes: include font name in text style string, and placed 
    155  * brush before pen in region style strings. 
    156  * 
    157  * Revision 1.36  2001/05/01 18:34:12  daniel 
    158  * TABRegion: use outside/inside ring relationship to build geometry if 
    159  * the information is available in the source file. 
    160  * 
    161  * Revision 1.35  2001/02/28 07:15:08  daniel 
    162  * Added support for text label line end point 
    163  * 
    164  * Revision 1.34  2001/01/22 16:03:58  warmerda 
    165  * expanded tabs 
    166  * 
    167  * Revision 1.33  2000/11/23 21:11:07  daniel 
    168  * OOpps... VC++ didn't like the way TABPenDef, etc. were initialized 
    169  * 
    170  * Revision 1.32  2000/11/23 20:47:45  daniel 
    171  * Use MI defaults for Pen, Brush, Font, Symbol instead of all zeros 
    172  * 
    173  * Revision 1.31  2000/10/18 03:23:37  warmerda 
    174  * ensure TABText::m_dWidth is initialized in constructor 
    175  * 
    176  * Revision 1.30  2000/10/03 19:29:51  daniel 
    177  * Include OGR StyleString stuff (implemented by Stephane) 
    178  * 
    179  * Revision 1.29  2000/09/19 17:23:52  daniel 
    180  * Maintain and/or compute valid region and polyline center/label point 
    181  * 
    182  * Revision 1.28  2000/09/07 23:32:13  daniel 
    183  * Added RecordDeletedFlag to TABFeature with get/set methods 
    184  * 
    185  * Revision 1.27  2000/07/10 14:56:25  daniel 
    186  * Handle m_nOriginQuadrant==0 as quadrant 3 (reverse x and y axis) 
    187  * 
    188  * Revision 1.26  2000/04/21 12:39:05  daniel 
    189  * Added TABPolyline::GetNumParts()/GetPartRef() 
    190  * 
    191  * Revision 1.25  2000/02/28 16:44:10  daniel 
    192  * Added support for indexed, unique, and for new V450 object types 
    193  * 
    19486 * ... 
    19587 * 
     
    233125 
    234126/********************************************************************** 
     127 *                     TABFeature::CreateFromMapInfoType() 
     128 * 
     129 * Factory that creates a TABFeature of the right class for the specified 
     130 * MapInfo Type 
     131 * 
     132 **********************************************************************/ 
     133TABFeature *TABFeature::CreateFromMapInfoType(int nMapInfoType, 
     134                                              OGRFeatureDefn *poDefn) 
     135{ 
     136    TABFeature *poFeature = NULL; 
     137 
     138    /*----------------------------------------------------------------- 
     139     * Create new feature object of the right type 
     140     *----------------------------------------------------------------*/ 
     141    switch(nMapInfoType) 
     142    { 
     143      case TAB_GEOM_NONE: 
     144        poFeature = new TABFeature(poDefn); 
     145        break; 
     146      case TAB_GEOM_SYMBOL_C: 
     147      case TAB_GEOM_SYMBOL: 
     148        poFeature = new TABPoint(poDefn); 
     149        break; 
     150      case TAB_GEOM_FONTSYMBOL_C: 
     151      case TAB_GEOM_FONTSYMBOL: 
     152        poFeature = new TABFontPoint(poDefn); 
     153        break; 
     154      case TAB_GEOM_CUSTOMSYMBOL_C: 
     155      case TAB_GEOM_CUSTOMSYMBOL: 
     156        poFeature = new TABCustomPoint(poDefn); 
     157        break; 
     158      case TAB_GEOM_LINE_C: 
     159      case TAB_GEOM_LINE: 
     160      case TAB_GEOM_PLINE_C: 
     161      case TAB_GEOM_PLINE: 
     162      case TAB_GEOM_MULTIPLINE_C: 
     163      case TAB_GEOM_MULTIPLINE: 
     164      case TAB_GEOM_V450_MULTIPLINE_C: 
     165      case TAB_GEOM_V450_MULTIPLINE: 
     166       poFeature = new TABPolyline(poDefn); 
     167        break; 
     168      case TAB_GEOM_ARC_C: 
     169      case TAB_GEOM_ARC: 
     170        poFeature = new TABArc(poDefn); 
     171        break; 
     172 
     173      case TAB_GEOM_REGION_C: 
     174      case TAB_GEOM_REGION: 
     175      case TAB_GEOM_V450_REGION_C: 
     176      case TAB_GEOM_V450_REGION: 
     177        poFeature = new TABRegion(poDefn); 
     178        break; 
     179      case TAB_GEOM_RECT_C: 
     180      case TAB_GEOM_RECT: 
     181      case TAB_GEOM_ROUNDRECT_C: 
     182      case TAB_GEOM_ROUNDRECT: 
     183        poFeature = new TABRectangle(poDefn); 
     184        break; 
     185      case TAB_GEOM_ELLIPSE_C: 
     186      case TAB_GEOM_ELLIPSE: 
     187        poFeature = new TABEllipse(poDefn); 
     188        break; 
     189      case TAB_GEOM_TEXT_C: 
     190      case TAB_GEOM_TEXT: 
     191        poFeature = new TABText(poDefn); 
     192        break; 
     193      case TAB_GEOM_MULTIPOINT_C: 
     194      case TAB_GEOM_MULTIPOINT: 
     195        poFeature = new TABMultiPoint(poDefn); 
     196        break; 
     197      case TAB_GEOM_COLLECTION_C: 
     198      case TAB_GEOM_COLLECTION: 
     199        poFeature = new TABCollection(poDefn);   
     200        break; 
     201      default: 
     202        /*------------------------------------------------------------- 
     203         * Unsupported feature type... we still return a valid feature 
     204         * with NONE geometry after producing a Warning. 
     205         * Callers can trap that case by checking CPLGetLastErrorNo()  
     206         * against TAB_WarningFeatureTypeNotSupported 
     207         *------------------------------------------------------------*/ 
     208//        poFeature = new TABDebugFeature(poDefn); 
     209        poFeature = new TABFeature(poDefn); 
     210 
     211        CPLError(CE_Warning, TAB_WarningFeatureTypeNotSupported, 
     212                 "Unsupported object type %d (0x%2.2x).  Feature will be " 
     213                 "returned with NONE geometry.", 
     214                 nMapInfoType, nMapInfoType); 
     215    } 
     216 
     217    return poFeature; 
     218} 
     219 
     220 
     221/********************************************************************** 
    235222 *                     TABFeature::CopyTABFeatureBase() 
    236223 * 
     
    268255    GetMBR(dXMin, dYMin, dXMax, dYMax); 
    269256    poDestFeature->SetMBR(dXMin, dYMin, dXMax, dYMax); 
     257 
     258    GInt32 nXMin, nYMin, nXMax, nYMax; 
     259    GetIntMBR(nXMin, nYMin, nXMax, nYMax); 
     260    poDestFeature->SetIntMBR(nXMin, nYMin, nXMax, nYMax); 
    270261 
    271262    // m_nMapInfoType is not carried but it is not required anyways. 
     
    331322    dXMax = m_dXMax; 
    332323    dYMax = m_dYMax; 
     324} 
     325 
     326/********************************************************************** 
     327 *                   TABFeature::SetIntMBR() 
     328 * 
     329 * Set the integer coordinates values of the MBR of this feature. 
     330 **********************************************************************/ 
     331void TABFeature::SetIntMBR(GInt32 nXMin, GInt32 nYMin,  
     332                           GInt32 nXMax, GInt32 nYMax) 
     333{ 
     334    m_nXMin = nXMin; 
     335    m_nYMin = nYMin; 
     336    m_nXMax = nXMax; 
     337    m_nYMax = nYMax; 
    333338} 
    334339 
     
    506511 * currently points to the beginning of a map object. 
    507512 * 
     513 * bCoordBlockDataOnly=TRUE is used when this method is called to copy only 
     514 * the CoordBlock data during splitting of object blocks. In this case we 
     515 * need to process only the information related to the CoordBlock. One  
     516 * important thing to avoid is reading/writing pen/brush/symbol definitions 
     517 * as that would screw up their ref counters. 
     518 * 
     519 * ppoCoordBlock is used by TABCollection and by index splitting code 
     520 * to provide a CoordBlock to use instead of the one from the poMAPFile and 
     521 * return the current pointer at the end of the call. 
     522 * 
    508523 * The current implementation does nothing since instances of TABFeature 
    509524 * objects contain no geometry (i.e. TAB_GEOM_NONE). 
     
    513528 **********************************************************************/ 
    514529int TABFeature::ReadGeometryFromMAPFile(TABMAPFile * /*poMapFile*/, 
    515                                         TABMAPObjHdr * /*poObjHdr*/) 
     530                                        TABMAPObjHdr * /*poObjHdr*/, 
     531                                        GBool /*bCoordBlockDataOnly=FALSE*/,  
     532                                        TABMAPCoordBlock ** /*ppoCoordBlock=NULL*/) 
    516533{ 
    517534    /*----------------------------------------------------------------- 
     
    643660 * currently points to a valid map object. 
    644661 * 
     662 * bCoordBlockDataOnly=TRUE is used when this method is called to copy only 
     663 * the CoordBlock data during splitting of object blocks. In this case we 
     664 * need to process only the information related to the CoordBlock. One  
     665 * important thing to avoid is reading/writing pen/brush/symbol definitions 
     666 * as that would screw up their ref counters. 
     667 * 
     668 * ppoCoordBlock is used by TABCollection and by index splitting code 
     669 * to provide a CoordBlock to use instead of the one from the poMAPFile and 
     670 * return the current pointer at the end of the call. 
     671 * 
    645672 * The current implementation does nothing since instances of TABFeature 
    646673 * objects contain no geometry (i.e. TAB_GEOM_NONE). 
     
    650677 **********************************************************************/ 
    651678int TABFeature::WriteGeometryToMAPFile(TABMAPFile * /* poMapFile*/, 
    652                                        TABMAPObjHdr * /*poObjHdr*/) 
     679                                       TABMAPObjHdr * /*poObjHdr*/, 
     680                                       GBool /*bCoordBlockDataOnly=FALSE*/,  
     681                                       TABMAPCoordBlock ** /*ppoCoordBlock=NULL*/) 
    653682{ 
    654683    /*----------------------------------------------------------------- 
     
    818847 **********************************************************************/ 
    819848int TABPoint::ReadGeometryFromMAPFile(TABMAPFile *poMapFile, 
    820                                       TABMAPObjHdr *poObjHdr) 
     849                                      TABMAPObjHdr *poObjHdr, 
     850                                      GBool bCoordBlockDataOnly /*=FALSE*/,  
     851                                      TABMAPCoordBlock ** /*ppoCoordBlock=NULL*/) 
    821852{ 
    822853    double              dX, dY; 
    823854    OGRGeometry         *poGeometry; 
    824855 
     856    /* Nothing to do for bCoordBlockDataOnly (used by index splitting) */ 
     857    if (bCoordBlockDataOnly) 
     858        return 0; 
     859 
    825860    /*----------------------------------------------------------------- 
    826861     * Fetch and validate geometry type 
    827862     *----------------------------------------------------------------*/ 
    828     m_nMapInfoType = poMapFile->GetCurObjType()
     863    m_nMapInfoType = poObjHdr->m_nType
    829864 
    830865    if (m_nMapInfoType != TAB_GEOM_SYMBOL && 
     
    855890 
    856891    SetMBR(dX, dY, dX, dY); 
     892    SetIntMBR(poObjHdr->m_nMinX, poObjHdr->m_nMinY,  
     893              poObjHdr->m_nMaxX, poObjHdr->m_nMaxY); 
    857894 
    858895    return 0; 
     
    871908 **********************************************************************/ 
    872909int TABPoint::WriteGeometryToMAPFile(TABMAPFile *poMapFile, 
    873                                        TABMAPObjHdr *poObjHdr) 
     910                                     TABMAPObjHdr *poObjHdr, 
     911                                     GBool bCoordBlockDataOnly /*=FALSE*/,  
     912                                     TABMAPCoordBlock ** /*ppoCoordBlock=NULL*/) 
    874913{ 
    875914    GInt32              nX, nY; 
    876915    OGRGeometry         *poGeom; 
    877916    OGRPoint            *poPoint; 
     917 
     918    /* Nothing to do for bCoordBlockDataOnly (used by index splitting) */ 
     919    if (bCoordBlockDataOnly) 
     920        return 0; 
    878921 
    879922    /*----------------------------------------------------------------- 
     
    11211164 **********************************************************************/ 
    11221165int TABFontPoint::ReadGeometryFromMAPFile(TABMAPFile *poMapFile, 
    1123                                           TABMAPObjHdr *poObjHdr) 
     1166                                          TABMAPObjHdr *poObjHdr, 
     1167                                          GBool bCoordBlockDataOnly /*=FALSE*/, 
     1168                                          TABMAPCoordBlock ** /*ppoCoordBlock=NULL*/) 
    11241169{ 
    11251170    double              dX, dY; 
    11261171    OGRGeometry         *poGeometry; 
    11271172 
     1173    /* Nothing to do for bCoordBlockDataOnly (used by index splitting) */ 
     1174    if (bCoordBlockDataOnly) 
     1175        return 0; 
     1176 
    11281177    /*----------------------------------------------------------------- 
    11291178     * Fetch and validate geometry type 
    11301179     *----------------------------------------------------------------*/ 
    1131     m_nMapInfoType = poMapFile->GetCurObjType()
     1180    m_nMapInfoType = poObjHdr->m_nType
    11321181 
    11331182    if (m_nMapInfoType != TAB_GEOM_FONTSYMBOL && 
     
    11811230 
    11821231    SetMBR(dX, dY, dX, dY); 
     1232    SetIntMBR(poObjHdr->m_nMinX, poObjHdr->m_nMinY,  
     1233              poObjHdr->m_nMaxX, poObjHdr->m_nMaxY); 
    11831234 
    11841235    return 0; 
     
    11971248 **********************************************************************/ 
    11981249int TABFontPoint::WriteGeometryToMAPFile(TABMAPFile *poMapFile, 
    1199                                        TABMAPObjHdr *poObjHdr) 
     1250                                         TABMAPObjHdr *poObjHdr, 
     1251                                         GBool bCoordBlockDataOnly /*=FALSE*/,  
     1252                                         TABMAPCoordBlock ** /*ppoCoordBlock=NULL*/) 
    12001253{ 
    12011254    GInt32              nX, nY; 
    12021255    OGRGeometry         *poGeom; 
    12031256    OGRPoint            *poPoint; 
     1257 
     1258    /* Nothing to do for bCoordBlockDataOnly (used by index splitting) */ 
     1259    if (bCoordBlockDataOnly) 
     1260        return 0; 
    12041261 
    12051262    /*----------------------------------------------------------------- 
     
    14141471 **********************************************************************/ 
    14151472int TABCustomPoint::ReadGeometryFromMAPFile(TABMAPFile *poMapFile, 
    1416                                             TABMAPObjHdr *poObjHdr) 
     1473                                            TABMAPObjHdr *poObjHdr, 
     1474                                            GBool bCoordBlockDataOnly /*=FALSE*/, 
     1475                                            TABMAPCoordBlock ** /*ppoCoordBlock=NULL*/) 
    14171476{ 
    14181477    double              dX, dY; 
    14191478    OGRGeometry         *poGeometry; 
    14201479 
     1480    /* Nothing to do for bCoordBlockDataOnly (used by index splitting) */ 
     1481    if (bCoordBlockDataOnly) 
     1482        return 0; 
     1483 
    14211484    /*----------------------------------------------------------------- 
    14221485     * Fetch and validate geometry type 
    14231486     *----------------------------------------------------------------*/ 
    1424     m_nMapInfoType = poMapFile->GetCurObjType()
     1487    m_nMapInfoType = poObjHdr->m_nType
    14251488 
    14261489    if (m_nMapInfoType != TAB_GEOM_CUSTOMSYMBOL && 
     
    14571520 
    14581521    SetMBR(dX, dY, dX, dY); 
     1522    SetIntMBR(poObjHdr->m_nMinX, poObjHdr->m_nMinY,  
     1523              poObjHdr->m_nMaxX, poObjHdr->m_nMaxY); 
    14591524 
    14601525    return 0; 
     
    14731538 **********************************************************************/ 
    14741539int TABCustomPoint::WriteGeometryToMAPFile(TABMAPFile *poMapFile, 
    1475                                        TABMAPObjHdr *poObjHdr) 
     1540                                           TABMAPObjHdr *poObjHdr, 
     1541                                           GBool bCoordBlockDataOnly /*=FALSE*/, 
     1542                                           TABMAPCoordBlock ** /*ppoCoordBlock=NULL*/) 
    14761543{ 
    14771544    GInt32              nX, nY; 
    14781545    OGRGeometry         *poGeom; 
    14791546    OGRPoint            *poPoint; 
     1547 
     1548    /* Nothing to do for bCoordBlockDataOnly (used by index splitting) */ 
     1549    if (bCoordBlockDataOnly) 
     1550        return 0; 
    14801551 
    14811552    /*----------------------------------------------------------------- 
     
    17951866 **********************************************************************/ 
    17961867int TABPolyline::ReadGeometryFromMAPFile(TABMAPFile *poMapFile, 
    1797                                          TABMAPObjHdr *poObjHdr) 
    1798 { 
    1799     return ReadGeometryFromMAPFile(poMapFile, poObjHdr, NULL); 
    1800 } 
    1801  
    1802 int TABPolyline::ReadGeometryFromMAPFile(TABMAPFile *poMapFile, 
    18031868                                         TABMAPObjHdr *poObjHdr, 
    1804                                          TABMAPCoordBlock **ppoCoordBlock) 
     1869                                         GBool bCoordBlockDataOnly /*=FALSE*/, 
     1870                                         TABMAPCoordBlock **ppoCoordBlock/*=NULL*/) 
    18051871{ 
    18061872    GInt32              nX, nY; 
     
    18371903        poLine->setPoint(1, dXMax, dYMax); 
    18381904 
    1839         m_nPenDefIndex = poLineHdr->m_nPenId;      // Pen index 
    1840         poMapFile->ReadPenDef(m_nPenDefIndex, &m_sPenDef); 
     1905        if (!bCoordBlockDataOnly) 
     1906        { 
     1907            m_nPenDefIndex = poLineHdr->m_nPenId;      // Pen index 
     1908            poMapFile->ReadPenDef(m_nPenDefIndex, &m_sPenDef); 
     1909        } 
    18411910    } 
    18421911    else if (m_nMapInfoType == TAB_GEOM_PLINE || 
     
    18481917        int     i, numPoints, nStatus; 
    18491918        GUInt32 nCoordDataSize; 
    1850         GInt32  nCoordBlockPtr, nCenterX, nCenterY
     1919        GInt32  nCoordBlockPtr
    18511920 
    18521921        /*------------------------------------------------------------- 
     
    18661935 
    18671936        // Compressed coordinate origin (useful only in compressed case!) 
    1868         nCenterX = poPLineHdr->m_nComprOrgX; 
    1869         nCenterY = poPLineHdr->m_nComprOrgY; 
     1937        m_nComprOrgX = poPLineHdr->m_nComprOrgX; 
     1938        m_nComprOrgY = poPLineHdr->m_nComprOrgY; 
    18701939 
    18711940        // MBR 
     
    18751944                                dXMax, dYMax); 
    18761945 
    1877         m_nPenDefIndex = poPLineHdr->m_nPenId;        // Pen index 
    1878         poMapFile->ReadPenDef(m_nPenDefIndex, &m_sPenDef); 
     1946        if (!bCoordBlockDataOnly) 
     1947        { 
     1948            m_nPenDefIndex = poPLineHdr->m_nPenId;        // Pen index 
     1949            poMapFile->ReadPenDef(m_nPenDefIndex, &m_sPenDef); 
     1950        } 
    18791951 
    18801952        /*------------------------------------------------------------- 
     
    18831955        numPoints = nCoordDataSize/(bComprCoord?4:8); 
    18841956 
    1885         poCoordBlock = poMapFile->GetCoordBlock(nCoordBlockPtr); 
     1957        if (ppoCoordBlock != NULL && *ppoCoordBlock != NULL) 
     1958            poCoordBlock = *ppoCoordBlock; 
     1959        else