1 : /**********************************************************************
2 : * $Id: mitab.h,v 1.117 2008/10/29 12:55:10 dmorissette Exp $
3 : *
4 : * Name: mitab.h
5 : * Project: MapInfo TAB Read/Write library
6 : * Language: C++
7 : * Purpose: Header file containing public definitions for the library.
8 : * Author: Daniel Morissette, dmorissette@dmsolutions.ca
9 : *
10 : **********************************************************************
11 : * Copyright (c) 1999-2005, Daniel Morissette
12 : *
13 : * Permission is hereby granted, free of charge, to any person obtaining a
14 : * copy of this software and associated documentation files (the "Software"),
15 : * to deal in the Software without restriction, including without limitation
16 : * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 : * and/or sell copies of the Software, and to permit persons to whom the
18 : * Software is furnished to do so, subject to the following conditions:
19 : *
20 : * The above copyright notice and this permission notice shall be included
21 : * in all copies or substantial portions of the Software.
22 : *
23 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 : * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 : * DEALINGS IN THE SOFTWARE.
30 : **********************************************************************
31 : *
32 : * $Log: mitab.h,v $
33 : * Revision 1.117 2008/10/29 12:55:10 dmorissette
34 : * Update version to 2.0.0-dev (2008-10) for GDAL 1.6.0 release
35 : *
36 : * Revision 1.116 2008/08/22 16:14:19 fwarmerdam
37 : * export spatialref/coordsys transformers
38 : *
39 : * Revision 1.115 2008/07/21 14:09:41 aboudreault
40 : * Add font text styles support (bold, italic, etc.) (bug 1922)
41 : *
42 : * Revision 1.114 2008/07/17 14:09:30 aboudreault
43 : * Add text outline color support (halo background in MapInfo)
44 : *
45 : * Revision 1.113 2008/07/01 14:33:17 aboudreault
46 : * * Fixed deprecated warnings generated by mitab.h by moving SetFontName to
47 : * mitab_feature.cpp.
48 : *
49 : * Revision 1.112 2008/03/05 20:35:39 dmorissette
50 : * Replace MITAB 1.x SetFeature() with a CreateFeature() for V2.x (bug 1859)
51 : *
52 : * Revision 1.111 2008/02/29 21:27:41 dmorissette
53 : * Update to v1.7.0-beta1
54 : *
55 : * Revision 1.110 2008/02/20 21:35:30 dmorissette
56 : * Added support for V800 COLLECTION of large objects (bug 1496)
57 : *
58 : * Revision 1.109 2008/02/13 21:10:43 dmorissette
59 : * Fixed error in TAB_GEOM_GET_VERSION() macro logic
60 : *
61 : * Revision 1.108 2008/02/05 22:21:59 dmorissette
62 : * Added macro TAB_GEOM_GET_VERSION()
63 : *
64 : * Revision 1.107 2008/02/01 19:55:55 dmorissette
65 : * Set version to 1.7.0-dev
66 : *
67 : * Revision 1.106 2008/02/01 19:36:31 dmorissette
68 : * Initial support for V800 REGION and MULTIPLINE (bug 1496)
69 : *
70 : * Revision 1.105 2008/01/29 21:56:39 dmorissette
71 : * Update dataset version properly for Date/Time/DateTime field types (#1754)
72 : *
73 : * Revision 1.104 2007/12/11 04:26:29 dmorissette
74 : * Update for 1.6.4 release
75 : *
76 : * Revision 1.103 2007/10/12 15:47:48 dmorissette
77 : * Updated for 1.6.3 release
78 : *
79 : * Revision 1.102 2007/09/18 18:13:42 dmorissette
80 : * Updated for 1.6.3-beta2
81 : *
82 : * Revision 1.101 2007/09/14 20:03:08 dmorissette
83 : * Removed stray ReadGeometryFromMAPFile() declaration
84 : *
85 : * Revision 1.100 2007/09/14 19:42:39 dmorissette
86 : * Updated for 1.6.3-beta1
87 : *
88 : * Revision 1.99 2007/09/14 18:30:18 dmorissette
89 : * Fixed the splitting of object blocks with the optimized spatial
90 : * index mode that was producing files with misaligned bytes that
91 : * confused MapInfo (bug 1732)
92 : *
93 : * Revision 1.98 2007/09/12 20:22:31 dmorissette
94 : * Added TABFeature::CreateFromMapInfoType()
95 : *
96 : * ...
97 : *
98 : * Revision 1.1 1999/07/12 04:18:23 daniel
99 : * Initial checkin
100 : *
101 : **********************************************************************/
102 :
103 : #ifndef _MITAB_H_INCLUDED_
104 : #define _MITAB_H_INCLUDED_
105 :
106 : #include "mitab_priv.h"
107 : #include "ogr_feature.h"
108 : #include "ogr_featurestyle.h"
109 : #include "ogrsf_frmts.h"
110 :
111 : /*---------------------------------------------------------------------
112 : * Current version of the MITAB library... always useful!
113 : *--------------------------------------------------------------------*/
114 : #define MITAB_VERSION "2.0.0-dev (2008-10)"
115 : #define MITAB_VERSION_INT 2000000 /* version x.y.z -> xxxyyyzzz */
116 :
117 : #ifndef PI
118 : # define PI 3.14159265358979323846
119 : #endif
120 :
121 : #ifndef ROUND_INT
122 : # define ROUND_INT(dX) ((int)((dX) < 0.0 ? (dX)-0.5 : (dX)+0.5 ))
123 : #endif
124 :
125 :
126 : #define MITAB_AREA(x1, y1, x2, y2) ((double)((x2)-(x1))*(double)((y2)-(y1)))
127 :
128 : class TABFeature;
129 :
130 : /*---------------------------------------------------------------------
131 : * Codes for the GetFileClass() in the IMapInfoFile-derived classes
132 : *--------------------------------------------------------------------*/
133 : typedef enum
134 : {
135 : TABFC_IMapInfoFile = 0,
136 : TABFC_TABFile,
137 : TABFC_TABView,
138 : TABFC_TABSeamless,
139 : TABFC_MIFFile
140 : } TABFileClass;
141 :
142 :
143 : /*---------------------------------------------------------------------
144 : * class IMapInfoFile
145 : *
146 : * Virtual base class for the TABFile and MIFFile classes.
147 : *
148 : * This is the definition of the public interface methods that should
149 : * be available for any type of MapInfo dataset.
150 : *--------------------------------------------------------------------*/
151 :
152 : class IMapInfoFile : public OGRLayer
153 : {
154 : private:
155 :
156 : protected:
157 : int m_nCurFeatureId;
158 : TABFeature *m_poCurFeature;
159 : GBool m_bBoundsSet;
160 :
161 : char *m_pszCharset;
162 :
163 : public:
164 : IMapInfoFile() ;
165 : virtual ~IMapInfoFile();
166 :
167 0 : virtual TABFileClass GetFileClass() {return TABFC_IMapInfoFile;}
168 :
169 : virtual int Open(const char *pszFname, const char *pszAccess,
170 : GBool bTestOpenNoError = FALSE ) = 0;
171 : virtual int Close() = 0;
172 :
173 0 : virtual int SetQuickSpatialIndexMode(GBool bQuickSpatialIndexMode=TRUE) {return -1;}
174 :
175 : virtual const char *GetTableName() = 0;
176 :
177 : ///////////////
178 : // Static method to detect file type, create an object to read that
179 : // file and open it.
180 : static IMapInfoFile *SmartOpen(const char *pszFname,
181 : GBool bTestOpenNoError = FALSE);
182 :
183 : ///////////////
184 : // OGR methods for read support
185 : virtual void ResetReading() = 0;
186 : virtual int GetFeatureCount (int bForce) = 0;
187 : virtual OGRFeature *GetNextFeature();
188 : virtual OGRFeature *GetFeature(long nFeatureId);
189 : virtual OGRErr CreateFeature(OGRFeature *poFeature);
190 : virtual int TestCapability( const char * pszCap ) =0;
191 : virtual int GetExtent(OGREnvelope *psExtent, int bForce) =0;
192 :
193 : ///////////////
194 : // Read access specific stuff
195 : //
196 : virtual int GetNextFeatureId(int nPrevId) = 0;
197 : virtual TABFeature *GetFeatureRef(int nFeatureId) = 0;
198 : virtual OGRFeatureDefn *GetLayerDefn() = 0;
199 :
200 : virtual TABFieldType GetNativeFieldType(int nFieldId) = 0;
201 :
202 : virtual int GetBounds(double &dXMin, double &dYMin,
203 : double &dXMax, double &dYMax,
204 : GBool bForce = TRUE ) = 0;
205 :
206 : virtual OGRSpatialReference *GetSpatialRef() = 0;
207 :
208 : virtual int GetFeatureCountByType(int &numPoints, int &numLines,
209 : int &numRegions, int &numTexts,
210 : GBool bForce = TRUE ) = 0;
211 :
212 : virtual GBool IsFieldIndexed(int nFieldId) = 0;
213 : virtual GBool IsFieldUnique(int nFieldId) = 0;
214 :
215 : ///////////////
216 : // Write access specific stuff
217 : //
218 9 : GBool IsBoundsSet() {return m_bBoundsSet;}
219 : virtual int SetBounds(double dXMin, double dYMin,
220 : double dXMax, double dYMax) = 0;
221 : virtual int SetFeatureDefn(OGRFeatureDefn *poFeatureDefn,
222 : TABFieldType *paeMapInfoNativeFieldTypes = NULL)=0;
223 : virtual int AddFieldNative(const char *pszName, TABFieldType eMapInfoType,
224 : int nWidth=0, int nPrecision=0,
225 : GBool bIndexed=FALSE, GBool bUnique=FALSE) = 0;
226 : virtual OGRErr CreateField( OGRFieldDefn *poField, int bApproxOK = TRUE );
227 :
228 : virtual int SetSpatialRef(OGRSpatialReference *poSpatialRef) = 0;
229 :
230 : virtual OGRErr CreateFeature(TABFeature *poFeature) = 0;
231 :
232 : virtual int SetFieldIndexed(int nFieldId) = 0;
233 :
234 : virtual int SetCharset(const char* charset);
235 :
236 : ///////////////
237 : // semi-private.
238 : virtual int GetProjInfo(TABProjInfo *poPI) = 0;
239 : virtual int SetProjInfo(TABProjInfo *poPI) = 0;
240 : virtual int SetMIFCoordSys(const char *pszMIFCoordSys) = 0;
241 :
242 : #ifdef DEBUG
243 : virtual void Dump(FILE *fpOut = NULL) = 0;
244 : #endif
245 : };
246 :
247 : /*---------------------------------------------------------------------
248 : * class TABFile
249 : *
250 : * The main class for TAB datasets. External programs should use this
251 : * class to open a TAB dataset and read/write features from/to it.
252 : *
253 : *--------------------------------------------------------------------*/
254 : class TABFile: public IMapInfoFile
255 : {
256 : private:
257 : char *m_pszFname;
258 : TABAccess m_eAccessMode;
259 : char **m_papszTABFile;
260 : int m_nVersion;
261 : int *m_panIndexNo;
262 : TABTableType m_eTableType; // NATIVE (.DAT) or DBF
263 :
264 : TABDATFile *m_poDATFile; // Attributes file
265 : TABMAPFile *m_poMAPFile; // Object Geometry file
266 : TABINDFile *m_poINDFile; // Attributes index file
267 :
268 : OGRFeatureDefn *m_poDefn;
269 : OGRSpatialReference *m_poSpatialRef;
270 : int bUseSpatialTraversal;
271 :
272 : int m_nLastFeatureId;
273 :
274 :
275 : ///////////////
276 : // Private Read access specific stuff
277 : //
278 : int ParseTABFileFirstPass(GBool bTestOpenNoError);
279 : int ParseTABFileFields();
280 :
281 : ///////////////
282 : // Private Write access specific stuff
283 : //
284 : int WriteTABFile();
285 :
286 : public:
287 : TABFile();
288 : virtual ~TABFile();
289 :
290 0 : virtual TABFileClass GetFileClass() {return TABFC_TABFile;}
291 :
292 : virtual int Open(const char *pszFname, const char *pszAccess,
293 : GBool bTestOpenNoError = FALSE );
294 : virtual int Close();
295 :
296 : virtual int SetQuickSpatialIndexMode(GBool bQuickSpatialIndexMode=TRUE);
297 :
298 0 : virtual const char *GetTableName()
299 0 : {return m_poDefn?m_poDefn->GetName():"";};
300 :
301 : virtual void ResetReading();
302 : virtual int TestCapability( const char * pszCap );
303 : virtual int GetFeatureCount (int bForce);
304 : virtual int GetExtent(OGREnvelope *psExtent, int bForce);
305 :
306 : /* Implement OGRLayer's SetFeature() for random write, only with TABFile */
307 : virtual OGRErr SetFeature( OGRFeature * );
308 :
309 : ///////////////
310 : // Read access specific stuff
311 : //
312 :
313 : int GetNextFeatureId_Spatial( int nPrevId );
314 :
315 : virtual int GetNextFeatureId(int nPrevId);
316 : virtual TABFeature *GetFeatureRef(int nFeatureId);
317 : virtual OGRFeatureDefn *GetLayerDefn();
318 :
319 : virtual TABFieldType GetNativeFieldType(int nFieldId);
320 :
321 : virtual int GetBounds(double &dXMin, double &dYMin,
322 : double &dXMax, double &dYMax,
323 : GBool bForce = TRUE );
324 :
325 : virtual OGRSpatialReference *GetSpatialRef();
326 :
327 : virtual int GetFeatureCountByType(int &numPoints, int &numLines,
328 : int &numRegions, int &numTexts,
329 : GBool bForce = TRUE);
330 :
331 : virtual GBool IsFieldIndexed(int nFieldId);
332 0 : virtual GBool IsFieldUnique(int /*nFieldId*/) {return FALSE;};
333 :
334 : ///////////////
335 : // Write access specific stuff
336 : //
337 : virtual int SetBounds(double dXMin, double dYMin,
338 : double dXMax, double dYMax);
339 : virtual int SetFeatureDefn(OGRFeatureDefn *poFeatureDefn,
340 : TABFieldType *paeMapInfoNativeFieldTypes = NULL);
341 : virtual int AddFieldNative(const char *pszName, TABFieldType eMapInfoType,
342 : int nWidth=0, int nPrecision=0,
343 : GBool bIndexed=FALSE, GBool bUnique=FALSE);
344 : virtual int SetSpatialRef(OGRSpatialReference *poSpatialRef);
345 :
346 : virtual OGRErr CreateFeature(TABFeature *poFeature);
347 :
348 : virtual int SetFieldIndexed(int nFieldId);
349 :
350 : ///////////////
351 : // semi-private.
352 0 : virtual int GetProjInfo(TABProjInfo *poPI)
353 0 : { return m_poMAPFile->GetHeaderBlock()->GetProjInfo( poPI ); }
354 : virtual int SetProjInfo(TABProjInfo *poPI);
355 : virtual int SetMIFCoordSys(const char *pszMIFCoordSys);
356 :
357 : int GetFieldIndexNumber(int nFieldId);
358 : TABINDFile *GetINDFileRef();
359 :
360 : TABMAPFile *GetMAPFileRef() { return m_poMAPFile; }
361 :
362 : int WriteFeature(TABFeature *poFeature, int nFeatureId /*=-1*/);
363 :
364 : #ifdef DEBUG
365 : virtual void Dump(FILE *fpOut = NULL);
366 : #endif
367 : };
368 :
369 :
370 : /*---------------------------------------------------------------------
371 : * class TABView
372 : *
373 : * TABView is used to handle special type of .TAB files that are
374 : * composed of a number of .TAB datasets linked through some indexed
375 : * fields.
376 : *
377 : * NOTE: The current implementation supports only TABViews composed
378 : * of 2 TABFiles linked through an indexed field of integer type.
379 : * It is unclear if any other type of views could exist anyways.
380 : *--------------------------------------------------------------------*/
381 : class TABView: public IMapInfoFile
382 : {
383 : private:
384 : char *m_pszFname;
385 : TABAccess m_eAccessMode;
386 : char **m_papszTABFile;
387 : char *m_pszVersion;
388 :
389 : char **m_papszTABFnames;
390 : TABFile **m_papoTABFiles;
391 : int m_numTABFiles;
392 : int m_nMainTableIndex; // The main table is the one that also
393 : // contains the geometries
394 : char **m_papszFieldNames;
395 : char **m_papszWhereClause;
396 :
397 : TABRelation *m_poRelation;
398 : GBool m_bRelFieldsCreated;
399 :
400 : ///////////////
401 : // Private Read access specific stuff
402 : //
403 : int ParseTABFile(const char *pszDatasetPath,
404 : GBool bTestOpenNoError = FALSE);
405 :
406 : int OpenForRead(const char *pszFname,
407 : GBool bTestOpenNoError = FALSE );
408 :
409 : ///////////////
410 : // Private Write access specific stuff
411 : //
412 : int OpenForWrite(const char *pszFname );
413 : int WriteTABFile();
414 :
415 :
416 : public:
417 : TABView();
418 : virtual ~TABView();
419 :
420 0 : virtual TABFileClass GetFileClass() {return TABFC_TABView;}
421 :
422 : virtual int Open(const char *pszFname, const char *pszAccess,
423 : GBool bTestOpenNoError = FALSE );
424 : virtual int Close();
425 :
426 : virtual int SetQuickSpatialIndexMode(GBool bQuickSpatialIndexMode=TRUE);
427 :
428 0 : virtual const char *GetTableName()
429 0 : {return m_poRelation?m_poRelation->GetFeatureDefn()->GetName():"";};
430 :
431 : virtual void ResetReading();
432 : virtual int TestCapability( const char * pszCap );
433 : virtual int GetFeatureCount (int bForce);
434 : virtual int GetExtent(OGREnvelope *psExtent, int bForce);
435 :
436 : ///////////////
437 : // Read access specific stuff
438 : //
439 :
440 : virtual int GetNextFeatureId(int nPrevId);
441 : virtual TABFeature *GetFeatureRef(int nFeatureId);
442 : virtual OGRFeatureDefn *GetLayerDefn();
443 :
444 : virtual TABFieldType GetNativeFieldType(int nFieldId);
445 :
446 : virtual int GetBounds(double &dXMin, double &dYMin,
447 : double &dXMax, double &dYMax,
448 : GBool bForce = TRUE );
449 :
450 : virtual OGRSpatialReference *GetSpatialRef();
451 :
452 : virtual int GetFeatureCountByType(int &numPoints, int &numLines,
453 : int &numRegions, int &numTexts,
454 : GBool bForce = TRUE);
455 :
456 : virtual GBool IsFieldIndexed(int nFieldId);
457 : virtual GBool IsFieldUnique(int nFieldId);
458 :
459 : ///////////////
460 : // Write access specific stuff
461 : //
462 : virtual int SetBounds(double dXMin, double dYMin,
463 : double dXMax, double dYMax);
464 : virtual int SetFeatureDefn(OGRFeatureDefn *poFeatureDefn,
465 : TABFieldType *paeMapInfoNativeFieldTypes=NULL);
466 : virtual int AddFieldNative(const char *pszName,
467 : TABFieldType eMapInfoType,
468 : int nWidth=0, int nPrecision=0,
469 : GBool bIndexed=FALSE, GBool bUnique=FALSE);
470 : virtual int SetSpatialRef(OGRSpatialReference *poSpatialRef);
471 :
472 : virtual OGRErr CreateFeature(TABFeature *poFeature);
473 :
474 : virtual int SetFieldIndexed(int nFieldId);
475 :
476 : ///////////////
477 : // semi-private.
478 0 : virtual int GetProjInfo(TABProjInfo *poPI)
479 : { return m_nMainTableIndex!=-1?
480 0 : m_papoTABFiles[m_nMainTableIndex]->GetProjInfo(poPI):-1; }
481 0 : virtual int SetProjInfo(TABProjInfo *poPI)
482 : { return m_nMainTableIndex!=-1?
483 0 : m_papoTABFiles[m_nMainTableIndex]->SetProjInfo(poPI):-1; }
484 0 : virtual int SetMIFCoordSys(const char * /*pszMIFCoordSys*/) {return -1;};
485 :
486 : #ifdef DEBUG
487 : virtual void Dump(FILE *fpOut = NULL);
488 : #endif
489 : };
490 :
491 :
492 : /*---------------------------------------------------------------------
493 : * class TABSeamless
494 : *
495 : * TABSeamless is used to handle seamless .TAB files that are
496 : * composed of a main .TAB file in which each feature is the MBR of
497 : * a base table.
498 : *
499 : * TABSeamless are supported for read access only.
500 : *--------------------------------------------------------------------*/
501 : class TABSeamless: public IMapInfoFile
502 : {
503 : private:
504 : char *m_pszFname;
505 : char *m_pszPath;
506 : TABAccess m_eAccessMode;
507 : OGRFeatureDefn *m_poFeatureDefnRef;
508 :
509 : TABFile *m_poIndexTable;
510 : int m_nTableNameField;
511 : int m_nCurBaseTableId;
512 : TABFile *m_poCurBaseTable;
513 : GBool m_bEOF;
514 :
515 : ///////////////
516 : // Private Read access specific stuff
517 : //
518 : int OpenForRead(const char *pszFname,
519 : GBool bTestOpenNoError = FALSE );
520 : int OpenBaseTable(TABFeature *poIndexFeature,
521 : GBool bTestOpenNoError = FALSE);
522 : int OpenBaseTable(int nTableId, GBool bTestOpenNoError = FALSE);
523 : int OpenNextBaseTable(GBool bTestOpenNoError =FALSE);
524 : int EncodeFeatureId(int nTableId, int nBaseFeatureId);
525 : int ExtractBaseTableId(int nEncodedFeatureId);
526 : int ExtractBaseFeatureId(int nEncodedFeatureId);
527 :
528 : public:
529 : TABSeamless();
530 : virtual ~TABSeamless();
531 :
532 0 : virtual TABFileClass GetFileClass() {return TABFC_TABSeamless;}
533 :
534 : virtual int Open(const char *pszFname, const char *pszAccess,
535 : GBool bTestOpenNoError = FALSE );
536 : virtual int Close();
537 :
538 0 : virtual const char *GetTableName()
539 0 : {return m_poFeatureDefnRef?m_poFeatureDefnRef->GetName():"";};
540 :
541 : virtual void SetSpatialFilter( OGRGeometry * );
542 :
543 : virtual void ResetReading();
544 : virtual int TestCapability( const char * pszCap );
545 : virtual int GetFeatureCount (int bForce);
546 : virtual int GetExtent(OGREnvelope *psExtent, int bForce);
547 :
548 : ///////////////
549 : // Read access specific stuff
550 : //
551 :
552 : virtual int GetNextFeatureId(int nPrevId);
553 : virtual TABFeature *GetFeatureRef(int nFeatureId);
554 : virtual OGRFeatureDefn *GetLayerDefn();
555 :
556 : virtual TABFieldType GetNativeFieldType(int nFieldId);
557 :
558 : virtual int GetBounds(double &dXMin, double &dYMin,
559 : double &dXMax, double &dYMax,
560 : GBool bForce = TRUE );
561 :
562 : virtual OGRSpatialReference *GetSpatialRef();
563 :
564 : virtual int GetFeatureCountByType(int &numPoints, int &numLines,
565 : int &numRegions, int &numTexts,
566 : GBool bForce = TRUE);
567 :
568 : virtual GBool IsFieldIndexed(int nFieldId);
569 : virtual GBool IsFieldUnique(int nFieldId);
570 :
571 : ///////////////
572 : // Write access specific stuff
573 : //
574 : virtual int SetBounds(double dXMin, double dYMin,
575 0 : double dXMax, double dYMax) {return -1;}
576 : virtual int SetFeatureDefn(OGRFeatureDefn *poFeatureDefn,
577 0 : TABFieldType *paeMapInfoNativeFieldTypes=NULL)
578 0 : {return -1;}
579 : virtual int AddFieldNative(const char *pszName,
580 : TABFieldType eMapInfoType,
581 : int nWidth=0, int nPrecision=0,
582 : GBool bIndexed=FALSE,
583 0 : GBool bUnique=FALSE) {return -1;}
584 :
585 0 : virtual int SetSpatialRef(OGRSpatialReference *poSpatialRef) {return -1;}
586 :
587 0 : virtual OGRErr CreateFeature(TABFeature *poFeature)
588 0 : {return OGRERR_UNSUPPORTED_OPERATION;}
589 :
590 0 : virtual int SetFieldIndexed(int nFieldId) {return -1;}
591 :
592 : ///////////////
593 : // semi-private.
594 0 : virtual int GetProjInfo(TABProjInfo *poPI)
595 0 : { return m_poIndexTable?m_poIndexTable->GetProjInfo(poPI):-1; }
596 0 : virtual int SetProjInfo(TABProjInfo *poPI) { return -1; }
597 0 : virtual int SetMIFCoordSys(const char * /*pszMIFCoordSys*/) {return -1;};
598 :
599 : #ifdef DEBUG
600 : virtual void Dump(FILE *fpOut = NULL);
601 : #endif
602 : };
603 :
604 :
605 : /*---------------------------------------------------------------------
606 : * class MIFFile
607 : *
608 : * The main class for (MID/MIF) datasets. External programs should use this
609 : * class to open a (MID/MIF) dataset and read/write features from/to it.
610 : *
611 : *--------------------------------------------------------------------*/
612 : class MIFFile: public IMapInfoFile
613 : {
614 : private:
615 : char *m_pszFname;
616 : TABAccess m_eAccessMode;
617 : int m_nVersion; /* Dataset version: 300, 450, 600, 900, etc. */
618 : char *m_pszDelimiter;
619 : char *m_pszUnique;
620 : char *m_pszIndex;
621 : char *m_pszCoordSys;
622 :
623 : TABFieldType *m_paeFieldType;
624 : GBool *m_pabFieldIndexed;
625 : GBool *m_pabFieldUnique;
626 :
627 : double m_dfXMultiplier;
628 : double m_dfYMultiplier;
629 : double m_dfXDisplacement;
630 : double m_dfYDisplacement;
631 :
632 : /* these are the projection bounds, possibly much broader than extents */
633 : double m_dXMin;
634 : double m_dYMin;
635 : double m_dXMax;
636 : double m_dYMax;
637 :
638 : /* extents, as cached by MIFFile::PreParseFile() */
639 : int m_bExtentsSet;
640 : OGREnvelope m_sExtents;
641 :
642 : int m_nPoints;
643 : int m_nLines;
644 : int m_nRegions;
645 : int m_nTexts;
646 :
647 : int m_nPreloadedId; // preloaded mif line is for this feature id
648 : MIDDATAFile *m_poMIDFile; // Mid file
649 : MIDDATAFile *m_poMIFFile; // Mif File
650 :
651 : OGRFeatureDefn *m_poDefn;
652 : OGRSpatialReference *m_poSpatialRef;
653 :
654 : int m_nFeatureCount;
655 : int m_nWriteFeatureId;
656 : int m_nAttribut;
657 :
658 : ///////////////
659 : // Private Read access specific stuff
660 : //
661 : int ReadFeatureDefn();
662 : int ParseMIFHeader();
663 : void PreParseFile();
664 : int AddFields(const char *pszLine);
665 : int GotoFeature(int nFeatureId);
666 : int NextFeature();
667 :
668 : ///////////////
669 : // Private Write access specific stuff
670 : //
671 : GBool m_bPreParsed;
672 : GBool m_bHeaderWrote;
673 :
674 : int WriteMIFHeader();
675 : void UpdateExtents(double dfX,double dfY);
676 :
677 : public:
678 : MIFFile();
679 : virtual ~MIFFile();
680 :
681 0 : virtual TABFileClass GetFileClass() {return TABFC_MIFFile;}
682 :
683 : virtual int Open(const char *pszFname, const char *pszAccess,
684 : GBool bTestOpenNoError = FALSE );
685 : virtual int Close();
686 :
687 0 : virtual const char *GetTableName()
688 0 : {return m_poDefn?m_poDefn->GetName():"";};
689 :
690 : virtual int TestCapability( const char * pszCap ) ;
691 : virtual int GetFeatureCount (int bForce);
692 : virtual void ResetReading();
693 : virtual int GetExtent(OGREnvelope *psExtent, int bForce);
694 :
695 : ///////////////
696 : // Read access specific stuff
697 : //
698 :
699 : virtual int GetNextFeatureId(int nPrevId);
700 : virtual TABFeature *GetFeatureRef(int nFeatureId);
701 : virtual OGRFeatureDefn *GetLayerDefn();
702 :
703 : virtual TABFieldType GetNativeFieldType(int nFieldId);
704 :
705 : virtual int GetBounds(double &dXMin, double &dYMin,
706 : double &dXMax, double &dYMax,
707 : GBool bForce = TRUE );
708 :
709 : virtual OGRSpatialReference *GetSpatialRef();
710 :
711 : virtual int GetFeatureCountByType(int &numPoints, int &numLines,
712 : int &numRegions, int &numTexts,
713 : GBool bForce = TRUE);
714 :
715 : virtual GBool IsFieldIndexed(int nFieldId);
716 : virtual GBool IsFieldUnique(int nFieldId);
717 :
718 : ///////////////
719 : // Write access specific stuff
720 : //
721 : virtual int SetBounds(double dXMin, double dYMin,
722 : double dXMax, double dYMax);
723 : virtual int SetFeatureDefn(OGRFeatureDefn *poFeatureDefn,
724 : TABFieldType *paeMapInfoNativeFieldTypes = NULL);
725 : virtual int AddFieldNative(const char *pszName, TABFieldType eMapInfoType,
726 : int nWidth=0, int nPrecision=0,
727 : GBool bIndexed=FALSE, GBool bUnique=FALSE);
728 : /* TODO */
729 : virtual int SetSpatialRef(OGRSpatialReference *poSpatialRef);
730 :
731 : virtual OGRErr CreateFeature(TABFeature *poFeature);
732 :
733 : virtual int SetFieldIndexed(int nFieldId);
734 :
735 : ///////////////
736 : // semi-private.
737 0 : virtual int GetProjInfo(TABProjInfo * /*poPI*/){return -1;}
738 : /* { return m_poMAPFile->GetHeaderBlock()->GetProjInfo( poPI ); }*/
739 0 : virtual int SetProjInfo(TABProjInfo * /*poPI*/){return -1;}
740 : /* { return m_poMAPFile->GetHeaderBlock()->SetProjInfo( poPI ); }*/
741 : virtual int SetMIFCoordSys(const char * pszMIFCoordSys);
742 :
743 : #ifdef DEBUG
744 0 : virtual void Dump(FILE * /*fpOut*/ = NULL) {};
745 : #endif
746 : };
747 :
748 : /*---------------------------------------------------------------------
749 : * Define some error codes specific to this lib.
750 : *--------------------------------------------------------------------*/
751 : #define TAB_WarningFeatureTypeNotSupported 501
752 : #define TAB_WarningInvalidFieldName 502
753 : #define TAB_WarningBoundsOverflow 503
754 :
755 : /*---------------------------------------------------------------------
756 : * Codes for the known MapInfo Geometry types
757 : *--------------------------------------------------------------------*/
758 : #define TAB_GEOM_NONE 0
759 : #define TAB_GEOM_SYMBOL_C 0x01
760 : #define TAB_GEOM_SYMBOL 0x02
761 : #define TAB_GEOM_LINE_C 0x04
762 : #define TAB_GEOM_LINE 0x05
763 : #define TAB_GEOM_PLINE_C 0x07
764 : #define TAB_GEOM_PLINE 0x08
765 : #define TAB_GEOM_ARC_C 0x0a
766 : #define TAB_GEOM_ARC 0x0b
767 : #define TAB_GEOM_REGION_C 0x0d
768 : #define TAB_GEOM_REGION 0x0e
769 : #define TAB_GEOM_TEXT_C 0x10
770 : #define TAB_GEOM_TEXT 0x11
771 : #define TAB_GEOM_RECT_C 0x13
772 : #define TAB_GEOM_RECT 0x14
773 : #define TAB_GEOM_ROUNDRECT_C 0x16
774 : #define TAB_GEOM_ROUNDRECT 0x17
775 : #define TAB_GEOM_ELLIPSE_C 0x19
776 : #define TAB_GEOM_ELLIPSE 0x1a
777 : #define TAB_GEOM_MULTIPLINE_C 0x25
778 : #define TAB_GEOM_MULTIPLINE 0x26
779 : #define TAB_GEOM_FONTSYMBOL_C 0x28
780 : #define TAB_GEOM_FONTSYMBOL 0x29
781 : #define TAB_GEOM_CUSTOMSYMBOL_C 0x2b
782 : #define TAB_GEOM_CUSTOMSYMBOL 0x2c
783 : /* Version 450 object types: */
784 : #define TAB_GEOM_V450_REGION_C 0x2e
785 : #define TAB_GEOM_V450_REGION 0x2f
786 : #define TAB_GEOM_V450_MULTIPLINE_C 0x31
787 : #define TAB_GEOM_V450_MULTIPLINE 0x32
788 : /* Version 650 object types: */
789 : #define TAB_GEOM_MULTIPOINT_C 0x34
790 : #define TAB_GEOM_MULTIPOINT 0x35
791 : #define TAB_GEOM_COLLECTION_C 0x37
792 : #define TAB_GEOM_COLLECTION 0x38
793 : /* Version 800 object types: */
794 : #define TAB_GEOM_UNKNOWN1_C 0x3a // ???
795 : #define TAB_GEOM_UNKNOWN1 0x3b // ???
796 : #define TAB_GEOM_V800_REGION_C 0x3d
797 : #define TAB_GEOM_V800_REGION 0x3e
798 : #define TAB_GEOM_V800_MULTIPLINE_C 0x40
799 : #define TAB_GEOM_V800_MULTIPLINE 0x41
800 : #define TAB_GEOM_V800_MULTIPOINT_C 0x43
801 : #define TAB_GEOM_V800_MULTIPOINT 0x44
802 : #define TAB_GEOM_V800_COLLECTION_C 0x46
803 : #define TAB_GEOM_V800_COLLECTION 0x47
804 :
805 : #define TAB_GEOM_GET_VERSION(nGeomType) \
806 : (((nGeomType) < TAB_GEOM_V450_REGION_C) ? 300: \
807 : ((nGeomType) < TAB_GEOM_MULTIPOINT_C) ? 450: \
808 : ((nGeomType) < TAB_GEOM_UNKNOWN1_C) ? 650: 800 )
809 :
810 :
811 : /*---------------------------------------------------------------------
812 : * Codes for the feature classes
813 : *--------------------------------------------------------------------*/
814 : typedef enum
815 : {
816 : TABFCNoGeomFeature = 0,
817 : TABFCPoint = 1,
818 : TABFCFontPoint = 2,
819 : TABFCCustomPoint = 3,
820 : TABFCText = 4,
821 : TABFCPolyline = 5,
822 : TABFCArc = 6,
823 : TABFCRegion = 7,
824 : TABFCRectangle = 8,
825 : TABFCEllipse = 9,
826 : TABFCMultiPoint = 10,
827 : TABFCCollection = 11,
828 : TABFCDebugFeature
829 : } TABFeatureClass;
830 :
831 : /*---------------------------------------------------------------------
832 : * Definitions for text attributes
833 : *--------------------------------------------------------------------*/
834 : typedef enum TABTextJust_t
835 : {
836 : TABTJLeft = 0, // Default: Left Justification
837 : TABTJCenter,
838 : TABTJRight
839 : } TABTextJust;
840 :
841 : typedef enum TABTextSpacing_t
842 : {
843 : TABTSSingle = 0, // Default: Single spacing
844 : TABTS1_5, // 1.5
845 : TABTSDouble
846 : } TABTextSpacing;
847 :
848 : typedef enum TABTextLineType_t
849 : {
850 : TABTLNoLine = 0, // Default: No line
851 : TABTLSimple,
852 : TABTLArrow
853 : } TABTextLineType;
854 :
855 : typedef enum TABFontStyle_t // Can be OR'ed
856 : { // except box and halo are mutually exclusive
857 : TABFSNone = 0,
858 : TABFSBold = 0x0001,
859 : TABFSItalic = 0x0002,
860 : TABFSUnderline = 0x0004,
861 : TABFSStrikeout = 0x0008,
862 : TABFSOutline = 0x0010,
863 : TABFSShadow = 0x0020,
864 : TABFSInverse = 0x0040,
865 : TABFSBlink = 0x0080,
866 : TABFSBox = 0x0100, // See note about box vs halo below.
867 : TABFSHalo = 0x0200, // MIF uses 256, see MIF docs, App.A
868 : TABFSAllCaps = 0x0400, // MIF uses 512
869 : TABFSExpanded = 0x0800 // MIF uses 1024
870 : } TABFontStyle;
871 :
872 : /* TABFontStyle enum notes:
873 : *
874 : * The enumeration values above correspond to the values found in a .MAP
875 : * file. However, they differ a little from what is found in a MIF file:
876 : * Values 0x01 to 0x80 are the same in .MIF and .MAP files.
877 : * Values 0x200 to 0x800 in .MAP are 0x100 to 0x400 in .MIF
878 : *
879 : * What about TABFSBox (0x100) ?
880 : * TABFSBox is stored just like the other styles in .MAP files but it is not
881 : * explicitly stored in a MIF file.
882 : * If a .MIF FONT() clause contains the optional BG color, then this implies
883 : * that either Halo or Box was set. Thus if TABFSHalo (value 256 in MIF)
884 : * is not set in the style, then this implies that TABFSBox should be set.
885 : */
886 :
887 : typedef enum TABCustSymbStyle_t // Can be OR'ed
888 : {
889 : TABCSNone = 0, // Transparent BG, use default colors
890 : TABCSBGOpaque = 0x01, // White pixels are opaque
891 : TABCSApplyColor = 0x02 // non-white pixels drawn using symbol color
892 : } TABCustSymbStyle;
893 :
894 : /*=====================================================================
895 : Base classes to be used to add supported drawing tools to each feature type
896 : =====================================================================*/
897 :
898 : class ITABFeaturePen
899 : {
900 : protected:
901 : int m_nPenDefIndex;
902 : TABPenDef m_sPenDef;
903 : public:
904 : ITABFeaturePen();
905 102 : ~ITABFeaturePen() {};
906 : int GetPenDefIndex() {return m_nPenDefIndex;};
907 0 : TABPenDef *GetPenDefRef() {return &m_sPenDef;};
908 :
909 : GByte GetPenWidthPixel();
910 : double GetPenWidthPoint();
911 : int GetPenWidthMIF();
912 34 : GByte GetPenPattern() {return m_sPenDef.nLinePattern;};
913 10 : GInt32 GetPenColor() {return m_sPenDef.rgbColor;};
914 :
915 : void SetPenWidthPixel(GByte val);
916 : void SetPenWidthPoint(double val);
917 : void SetPenWidthMIF(int val);
918 :
919 28 : void SetPenPattern(GByte val) {m_sPenDef.nLinePattern=val;};
920 28 : void SetPenColor(GInt32 clr) {m_sPenDef.rgbColor = clr;};
921 :
922 : const char *GetPenStyleString();
923 : void SetPenFromStyleString(const char *pszStyleString);
924 :
925 : void DumpPenDef(FILE *fpOut = NULL);
926 : };
927 :
928 : class ITABFeatureBrush
929 : {
930 : protected:
931 : int m_nBrushDefIndex;
932 : TABBrushDef m_sBrushDef;
933 : public:
934 : ITABFeatureBrush();
935 100 : ~ITABFeatureBrush() {};
936 : int GetBrushDefIndex() {return m_nBrushDefIndex;};
937 0 : TABBrushDef *GetBrushDefRef() {return &m_sBrushDef;};
938 :
939 10 : GInt32 GetBrushFGColor() {return m_sBrushDef.rgbFGColor;};
940 10 : GInt32 GetBrushBGColor() {return m_sBrushDef.rgbBGColor;};
941 20 : GByte GetBrushPattern() {return m_sBrushDef.nFillPattern;};
942 17 : GByte GetBrushTransparent() {return m_sBrushDef.bTransparentFill;};
943 :
944 28 : void SetBrushFGColor(GInt32 clr) { m_sBrushDef.rgbFGColor = clr;};
945 28 : void SetBrushBGColor(GInt32 clr) { m_sBrushDef.rgbBGColor = clr;};
946 28 : void SetBrushPattern(GByte val) { m_sBrushDef.nFillPattern=val;};
947 0 : void SetBrushTransparent(GByte val)
948 0 : {m_sBrushDef.bTransparentFill=val;};
949 :
950 : const char *GetBrushStyleString();
951 : void SetBrushFromStyleString(const char *pszStyleString);
952 :
953 : void DumpBrushDef(FILE *fpOut = NULL);
954 : };
955 :
956 : class ITABFeatureFont
957 : {
958 : protected:
959 : int m_nFontDefIndex;
960 : TABFontDef m_sFontDef;
961 : public:
962 : ITABFeatureFont();
963 0 : ~ITABFeatureFont() {};
964 : int GetFontDefIndex() {return m_nFontDefIndex;};
965 0 : TABFontDef *GetFontDefRef() {return &m_sFontDef;};
966 :
967 0 : const char *GetFontNameRef() {return m_sFontDef.szFontName;};
968 :
969 : void SetFontName(const char *pszName);
970 :
971 : void DumpFontDef(FILE *fpOut = NULL);
972 : };
973 :
974 : class ITABFeatureSymbol
975 : {
976 : protected:
977 : int m_nSymbolDefIndex;
978 : TABSymbolDef m_sSymbolDef;
979 : public:
980 : ITABFeatureSymbol();
981 8 : ~ITABFeatureSymbol() {};
982 : int GetSymbolDefIndex() {return m_nSymbolDefIndex;};
983 0 : TABSymbolDef *GetSymbolDefRef() {return &m_sSymbolDef;};
984 :
985 4 : GInt16 GetSymbolNo() {return m_sSymbolDef.nSymbolNo;};
986 4 : GInt16 GetSymbolSize() {return m_sSymbolDef.nPointSize;};
987 4 : GInt32 GetSymbolColor() {return m_sSymbolDef.rgbColor;};
988 :
989 4 : void SetSymbolNo(GInt16 val) { m_sSymbolDef.nSymbolNo = val;};
990 4 : void SetSymbolSize(GInt16 val) { m_sSymbolDef.nPointSize = val;};
991 4 : void SetSymbolColor(GInt32 clr) { m_sSymbolDef.rgbColor = clr;};
992 :
993 : const char *GetSymbolStyleString(double dfAngle = 0.0);
994 : void SetSymbolFromStyleString(const char *pszStyleString);
995 :
996 : void DumpSymbolDef(FILE *fpOut = NULL);
997 : };
998 :
999 :
1000 : /*=====================================================================
1001 : Feature Classes
1002 : =====================================================================*/
1003 :
1004 : /*---------------------------------------------------------------------
1005 : * class TABFeature
1006 : *
1007 : * Extend the OGRFeature to support MapInfo specific extensions related
1008 : * to geometry types, representation strings, etc.
1009 : *
1010 : * TABFeature will be used as a base class for all the feature classes.
1011 : *
1012 : * This class will also be used to instanciate objects with no Geometry
1013 : * (i.e. type TAB_GEOM_NONE) which is a valid case in MapInfo.
1014 : *
1015 : * The logic to read/write the object from/to the .DAT and .MAP files is also
1016 : * implemented as part of this class and derived classes.
1017 : *--------------------------------------------------------------------*/
1018 : class TABFeature: public OGRFeature
1019 : {
1020 : protected:
1021 : int m_nMapInfoType;
1022 :
1023 : double m_dXMin;
1024 : double m_dYMin;
1025 : double m_dXMax;
1026 : double m_dYMax;
1027 :
1028 : GBool m_bDeletedFlag;
1029 :
1030 : void CopyTABFeatureBase(TABFeature *poDestFeature);
1031 :
1032 : // Compr. Origin is set for TAB files by ValidateCoordType()
1033 : GInt32 m_nXMin;
1034 : GInt32 m_nYMin;
1035 : GInt32 m_nXMax;
1036 : GInt32 m_nYMax;
1037 : GInt32 m_nComprOrgX;
1038 : GInt32 m_nComprOrgY;
1039 :
1040 : virtual int UpdateMBR(TABMAPFile *poMapFile = NULL);
1041 :
1042 : public:
1043 : TABFeature(OGRFeatureDefn *poDefnIn );
1044 : virtual ~TABFeature();
1045 :
1046 : static TABFeature *CreateFromMapInfoType(int nMapInfoType,
1047 : OGRFeatureDefn *poDefn);
1048 :
1049 : virtual TABFeature *CloneTABFeature(OGRFeatureDefn *pNewDefn = NULL);
1050 1 : virtual TABFeatureClass GetFeatureClass() { return TABFCNoGeomFeature; };
1051 0 : virtual int GetMapInfoType() { return m_nMapInfoType; };
1052 1 : virtual int ValidateMapInfoType(TABMAPFile *poMapFile = NULL)
1053 1 : {m_nMapInfoType=TAB_GEOM_NONE;
1054 1 : return m_nMapInfoType;};
1055 : GBool IsRecordDeleted() { return m_bDeletedFlag; };
1056 53 : void SetRecordDeleted(GBool bDeleted) { m_bDeletedFlag=bDeleted; };
1057 :
1058 : /*-----------------------------------------------------------------
1059 : * TAB Support
1060 : *----------------------------------------------------------------*/
1061 :
1062 : virtual int ReadRecordFromDATFile(TABDATFile *poDATFile);
1063 : virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1064 : GBool bCoordDataOnly=FALSE,
1065 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1066 :
1067 : virtual int WriteRecordToDATFile(TABDATFile *poDATFile,
1068 : TABINDFile *poINDFile, int *panIndexNo);
1069 : virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1070 : GBool bCoordDataOnly=FALSE,
1071 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1072 : GBool ValidateCoordType(TABMAPFile * poMapFile);
1073 : void ForceCoordTypeAndOrigin(int nMapInfoType, GBool bCompr,
1074 : GInt32 nComprOrgX, GInt32 nComprOrgY,
1075 : GInt32 nXMin, GInt32 nYMin,
1076 : GInt32 nXMax, GInt32 nYMax);
1077 :
1078 : /*-----------------------------------------------------------------
1079 : * Mid/Mif Support
1080 : *----------------------------------------------------------------*/
1081 :
1082 : virtual int ReadRecordFromMIDFile(MIDDATAFile *fp);
1083 : virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp);
1084 :
1085 : virtual int WriteRecordToMIDFile(MIDDATAFile *fp);
1086 : virtual int WriteGeometryToMIFFile(MIDDATAFile *fp);
1087 :
1088 : void ReadMIFParameters(MIDDATAFile *fp);
1089 : void WriteMIFParameters(MIDDATAFile *fp);
1090 :
1091 : /*-----------------------------------------------------------------
1092 : *----------------------------------------------------------------*/
1093 :
1094 : void SetMBR(double dXMin, double dYMin,
1095 : double dXMax, double dYMax);
1096 : void GetMBR(double &dXMin, double &dYMin,
1097 : double &dXMax, double &dYMax);
1098 : void SetIntMBR(GInt32 nXMin, GInt32 nYMin,
1099 : GInt32 nXMax, GInt32 nYMax);
1100 : void GetIntMBR(GInt32 &nXMin, GInt32 &nYMin,
1101 : GInt32 &nXMax, GInt32 &nYMax);
1102 :
1103 : virtual void DumpMID(FILE *fpOut = NULL);
1104 : virtual void DumpMIF(FILE *fpOut = NULL);
1105 :
1106 : };
1107 :
1108 :
1109 : /*---------------------------------------------------------------------
1110 : * class TABPoint
1111 : *
1112 : * Feature class to handle old style MapInfo point symbols:
1113 : *
1114 : * TAB_GEOM_SYMBOL_C 0x01
1115 : * TAB_GEOM_SYMBOL 0x02
1116 : *
1117 : * Feature geometry will be a OGRPoint
1118 : *
1119 : * The symbol number is in the range [31..67], with 31=None and corresponds
1120 : * to one of the 35 predefined "Old MapInfo Symbols"
1121 : *
1122 : * NOTE: This class is also used as a base class for the other point
1123 : * symbol types TABFontPoint and TABCustomPoint.
1124 : *--------------------------------------------------------------------*/
1125 : class TABPoint: public TABFeature,
1126 : public ITABFeatureSymbol
1127 : {
1128 : public:
1129 : TABPoint(OGRFeatureDefn *poDefnIn);
1130 : virtual ~TABPoint();
1131 :
1132 0 : virtual TABFeatureClass GetFeatureClass() { return TABFCPoint; };
1133 : virtual int ValidateMapInfoType(TABMAPFile *poMapFile = NULL);
1134 :
1135 : virtual TABFeature *CloneTABFeature(OGRFeatureDefn *poNewDefn = NULL );
1136 :
1137 : double GetX();
1138 : double GetY();
1139 :
1140 : virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1141 : GBool bCoordDataOnly=FALSE,
1142 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1143 : virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1144 : GBool bCoordDataOnly=FALSE,
1145 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1146 :
1147 : virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp);
1148 : virtual int WriteGeometryToMIFFile(MIDDATAFile *fp);
1149 :
1150 : virtual const char *GetStyleString();
1151 :
1152 : virtual void DumpMIF(FILE *fpOut = NULL);
1153 : };
1154 :
1155 :
1156 : /*---------------------------------------------------------------------
1157 : * class TABFontPoint
1158 : *
1159 : * Feature class to handle MapInfo Font Point Symbol types:
1160 : *
1161 : * TAB_GEOM_FONTSYMBOL_C 0x28
1162 : * TAB_GEOM_FONTSYMBOL 0x29
1163 : *
1164 : * Feature geometry will be a OGRPoint
1165 : *
1166 : * The symbol number refers to a character code in the specified Windows
1167 : * Font (e.g. "Windings").
1168 : *--------------------------------------------------------------------*/
1169 : class TABFontPoint: public TABPoint,
1170 : public ITABFeatureFont
1171 : {
1172 : protected:
1173 : double m_dAngle;
1174 : GInt16 m_nFontStyle; // Bold/shadow/halo/etc.
1175 :
1176 : public:
1177 : TABFontPoint(OGRFeatureDefn *poDefnIn);
1178 : virtual ~TABFontPoint();
1179 :
1180 0 : virtual TABFeatureClass GetFeatureClass() { return TABFCFontPoint; };
1181 :
1182 : virtual TABFeature *CloneTABFeature(OGRFeatureDefn *poNewDefn = NULL );
1183 :
1184 : virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1185 : GBool bCoordDataOnly=FALSE,
1186 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1187 : virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1188 : GBool bCoordDataOnly=FALSE,
1189 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1190 :
1191 : virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp);
1192 : virtual int WriteGeometryToMIFFile(MIDDATAFile *fp);
1193 :
1194 : virtual const char *GetStyleString();
1195 :
1196 : GBool QueryFontStyle(TABFontStyle eStyleToQuery);
1197 : void ToggleFontStyle(TABFontStyle eStyleToToggle, GBool bStatus);
1198 :
1199 : int GetFontStyleMIFValue();
1200 : void SetFontStyleMIFValue(int nStyle);
1201 0 : int GetFontStyleTABValue() {return m_nFontStyle;};
1202 0 : void SetFontStyleTABValue(int nStyle){m_nFontStyle=(GInt16)nStyle;};
1203 :
1204 : // GetSymbolAngle(): Return angle in degrees counterclockwise
1205 0 : double GetSymbolAngle() {return m_dAngle;};
1206 : void SetSymbolAngle(double dAngle);
1207 : };
1208 :
1209 :
1210 : /*---------------------------------------------------------------------
1211 : * class TABCustomPoint
1212 : *
1213 : * Feature class to handle MapInfo Custom Point Symbol (Bitmap) types:
1214 : *
1215 : * TAB_GEOM_CUSTOMSYMBOL_C 0x2b
1216 : * TAB_GEOM_CUSTOMSYMBOL 0x2c
1217 : *
1218 : * Feature geometry will be a OGRPoint
1219 : *
1220 : * The symbol name is the name of a BMP file stored in the "CustSymb"
1221 : * directory (e.g. "arrow.BMP"). The symbol number has no meaning for
1222 : * this symbol type.
1223 : *--------------------------------------------------------------------*/
1224 : class TABCustomPoint: public TABPoint,
1225 : public ITABFeatureFont
1226 : {
1227 : protected:
1228 : GByte m_nCustomStyle; // Show BG/Apply Color
1229 :
1230 : public:
1231 : GByte m_nUnknown_;
1232 :
1233 : public:
1234 : TABCustomPoint(OGRFeatureDefn *poDefnIn);
1235 : virtual ~TABCustomPoint();
1236 :
1237 0 : virtual TABFeatureClass GetFeatureClass() { return TABFCCustomPoint; };
1238 :
1239 : virtual TABFeature *CloneTABFeature(OGRFeatureDefn *poNewDefn = NULL );
1240 :
1241 : virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1242 : GBool bCoordDataOnly=FALSE,
1243 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1244 : virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1245 : GBool bCoordDataOnly=FALSE,
1246 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1247 :
1248 : virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp);
1249 : virtual int WriteGeometryToMIFFile(MIDDATAFile *fp);
1250 :
1251 : virtual const char *GetStyleString();
1252 :
1253 : const char *GetSymbolNameRef() { return GetFontNameRef(); };
1254 : void SetSymbolName(const char *pszName) {SetFontName(pszName);};
1255 :
1256 0 : GByte GetCustomSymbolStyle() {return m_nCustomStyle;}
1257 0 : void SetCustomSymbolStyle(GByte nStyle) {m_nCustomStyle = nStyle;}
1258 : };
1259 :
1260 :
1261 : /*---------------------------------------------------------------------
1262 : * class TABPolyline
1263 : *
1264 : * Feature class to handle the various MapInfo line types:
1265 : *
1266 : * TAB_GEOM_LINE_C 0x04
1267 : * TAB_GEOM_LINE 0x05
1268 : * TAB_GEOM_PLINE_C 0x07
1269 : * TAB_GEOM_PLINE 0x08
1270 : * TAB_GEOM_MULTIPLINE_C 0x25
1271 : * TAB_GEOM_MULTIPLINE 0x26
1272 : * TAB_GEOM_V450_MULTIPLINE_C 0x31
1273 : * TAB_GEOM_V450_MULTIPLINE 0x32
1274 : *
1275 : * Feature geometry can be either a OGRLineString or a OGRMultiLineString
1276 : *--------------------------------------------------------------------*/
1277 : class TABPolyline: public TABFeature,
1278 : public ITABFeaturePen
1279 : {
1280 : private:
1281 : GBool m_bCenterIsSet;
1282 : double m_dCenterX, m_dCenterY;
1283 : GBool m_bWriteTwoPointLineAsPolyline;
1284 :
1285 : public:
1286 : TABPolyline(OGRFeatureDefn *poDefnIn);
1287 : virtual ~TABPolyline();
1288 :
1289 0 : virtual TABFeatureClass GetFeatureClass() { return TABFCPolyline; };
1290 : virtual int ValidateMapInfoType(TABMAPFile *poMapFile = NULL);
1291 :
1292 : virtual TABFeature *CloneTABFeature(OGRFeatureDefn *poNewDefn = NULL );
1293 :
1294 : /* 2 methods to simplify access to rings in a multiple polyline
1295 : */
1296 : int GetNumParts();
1297 : OGRLineString *GetPartRef(int nPartIndex);
1298 :
1299 : GBool TwoPointLineAsPolyline();
1300 : void TwoPointLineAsPolyline(GBool bTwoPointLineAsPolyline);
1301 :
1302 : virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1303 : GBool bCoordDataOnly=FALSE,
1304 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1305 : virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1306 : GBool bCoordDataOnly=FALSE,
1307 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1308 :
1309 : virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp);
1310 : virtual int WriteGeometryToMIFFile(MIDDATAFile *fp);
1311 :
1312 : virtual const char *GetStyleString();
1313 :
1314 : virtual void DumpMIF(FILE *fpOut = NULL);
1315 :
1316 : int GetCenter(double &dX, double &dY);
1317 : void SetCenter(double dX, double dY);
1318 :
1319 : // MapInfo-specific attributes... made available through public vars
1320 : // for now.
1321 : GBool m_bSmooth;
1322 :
1323 : };
1324 :
1325 : /*---------------------------------------------------------------------
1326 : * class TABRegion
1327 : *
1328 : * Feature class to handle the MapInfo region types:
1329 : *
1330 : * TAB_GEOM_REGION_C 0x0d
1331 : * TAB_GEOM_REGION 0x0e
1332 : * TAB_GEOM_V450_REGION_C 0x2e
1333 : * TAB_GEOM_V450_REGION 0x2f
1334 : *
1335 : * Feature geometry will be returned as OGRPolygon (with a single ring)
1336 : * or OGRMultiPolygon (for multiple rings).
1337 : *
1338 : * REGIONs with multiple rings are returned as OGRMultiPolygon instead of
1339 : * as OGRPolygons since OGRPolygons require that the first ring be the
1340 : * outer ring, and the other all be inner rings, but this is not guaranteed
1341 : * inside MapInfo files. However, when writing features, OGRPolygons with
1342 : * multiple rings will be accepted without problem.
1343 : *--------------------------------------------------------------------*/
1344 : class TABRegion: public TABFeature,
1345 : public ITABFeaturePen,
1346 : public ITABFeatureBrush
1347 : {
1348 : GBool m_bSmooth;
1349 : private:
1350 : GBool m_bCenterIsSet;
1351 : double m_dCenterX, m_dCenterY;
1352 :
1353 : int ComputeNumRings(TABMAPCoordSecHdr **ppasSecHdrs,
1354 : TABMAPFile *poMAPFile);
1355 : int AppendSecHdrs(OGRPolygon *poPolygon,
1356 : TABMAPCoordSecHdr * &pasSecHdrs,
1357 : TABMAPFile *poMAPFile,
1358 : int &iLastRing);
1359 :
1360 : public:
1361 : TABRegion(OGRFeatureDefn *poDefnIn);
1362 : virtual ~TABRegion();
1363 :
1364 0 : virtual TABFeatureClass GetFeatureClass() { return TABFCRegion; };
1365 : virtual int ValidateMapInfoType(TABMAPFile *poMapFile = NULL);
1366 :
1367 : virtual TABFeature *CloneTABFeature(OGRFeatureDefn *poNewDefn = NULL );
1368 :
1369 : /* 2 methods to make the REGION's geometry look like a single collection
1370 : * of OGRLinearRings
1371 : */
1372 : int GetNumRings();
1373 : OGRLinearRing *GetRingRef(int nRequestedRingIndex);
1374 : GBool IsInteriorRing(int nRequestedRingIndex);
1375 :
1376 : virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1377 : GBool bCoordDataOnly=FALSE,
1378 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1379 : virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1380 : GBool bCoordDataOnly=FALSE,
1381 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1382 :
1383 : virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp);
1384 : virtual int WriteGeometryToMIFFile(MIDDATAFile *fp);
1385 :
1386 : virtual const char *GetStyleString();
1387 :
1388 : virtual void DumpMIF(FILE *fpOut = NULL);
1389 :
1390 : int GetCenter(double &dX, double &dY);
1391 : void SetCenter(double dX, double dY);
1392 : };
1393 :
1394 :
1395 : /*---------------------------------------------------------------------
1396 : * class TABRectangle
1397 : *
1398 : * Feature class to handle the MapInfo rectangle types:
1399 : *
1400 : * TAB_GEOM_RECT_C 0x13
1401 : * TAB_GEOM_RECT 0x14
1402 : * TAB_GEOM_ROUNDRECT_C 0x16
1403 : * TAB_GEOM_ROUNDRECT 0x17
1404 : *
1405 : * A rectangle is defined by the coords of its 2 opposite corners (the MBR)
1406 : * Its corners can optionaly be rounded, in which case a X and Y rounding
1407 : * radius will be defined.
1408 : *
1409 : * Feature geometry will be OGRPolygon
1410 : *--------------------------------------------------------------------*/
1411 : class TABRectangle: public TABFeature,
1412 : public ITABFeaturePen,
1413 : public ITABFeatureBrush
1414 : {
1415 : private:
1416 : virtual int UpdateMBR(TABMAPFile *poMapFile = NULL);
1417 :
1418 : public:
1419 : TABRectangle(OGRFeatureDefn *poDefnIn);
1420 : virtual ~TABRectangle();
1421 :
1422 0 : virtual TABFeatureClass GetFeatureClass() { return TABFCRectangle; };
1423 : virtual int ValidateMapInfoType(TABMAPFile *poMapFile = NULL);
1424 :
1425 : virtual TABFeature *CloneTABFeature(OGRFeatureDefn *poNewDefn = NULL );
1426 :
1427 : virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1428 : GBool bCoordDataOnly=FALSE,
1429 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1430 : virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1431 : GBool bCoordDataOnly=FALSE,
1432 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1433 :
1434 : virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp);
1435 : virtual int WriteGeometryToMIFFile(MIDDATAFile *fp);
1436 :
1437 : virtual const char *GetStyleString();
1438 :
1439 : virtual void DumpMIF(FILE *fpOut = NULL);
1440 :
1441 : // MapInfo-specific attributes... made available through public vars
1442 : // for now.
1443 : GBool m_bRoundCorners;
1444 : double m_dRoundXRadius;
1445 : double m_dRoundYRadius;
1446 :
1447 : };
1448 :
1449 :
1450 : /*---------------------------------------------------------------------
1451 : * class TABEllipse
1452 : *
1453 : * Feature class to handle the MapInfo ellipse types:
1454 : *
1455 : * TAB_GEOM_ELLIPSE_C 0x19
1456 : * TAB_GEOM_ELLIPSE 0x1a
1457 : *
1458 : * An ellipse is defined by the coords of its 2 opposite corners (the MBR)
1459 : *
1460 : * Feature geometry can be either an OGRPoint defining the center of the
1461 : * ellipse, or an OGRPolygon defining the ellipse itself.
1462 : *
1463 : * When an ellipse is read, the returned geometry is a OGRPolygon representing
1464 : * the ellipse with 2 degrees line segments.
1465 : *
1466 : * In the case of the OGRPoint, then the X/Y Radius MUST be set, but.
1467 : * However with an OGRPolygon, if the X/Y radius are not set (== 0) then
1468 : * the MBR of the polygon will be used to define the ellipse parameters
1469 : * and the center of the MBR is used as the center of the ellipse...
1470 : * (i.e. the polygon vertices themselves will be ignored).
1471 : *--------------------------------------------------------------------*/
1472 : class TABEllipse: public TABFeature,
1473 : public ITABFeaturePen,
1474 : public ITABFeatureBrush
1475 : {
1476 : private:
1477 : virtual int UpdateMBR(TABMAPFile *poMapFile = NULL);
1478 :
1479 : public:
1480 : TABEllipse(OGRFeatureDefn *poDefnIn);
1481 : virtual ~TABEllipse();
1482 :
1483 0 : virtual TABFeatureClass GetFeatureClass() { return TABFCEllipse; };
1484 : virtual int ValidateMapInfoType(TABMAPFile *poMapFile = NULL);
1485 :
1486 : virtual TABFeature *CloneTABFeature(OGRFeatureDefn *poNewDefn = NULL );
1487 :
1488 : virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1489 : GBool bCoordDataOnly=FALSE,
1490 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1491 : virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1492 : GBool bCoordDataOnly=FALSE,
1493 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1494 :
1495 : virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp);
1496 : virtual int WriteGeometryToMIFFile(MIDDATAFile *fp);
1497 :
1498 : virtual const char *GetStyleString();
1499 :
1500 : virtual void DumpMIF(FILE *fpOut = NULL);
1501 :
1502 : // MapInfo-specific attributes... made available through public vars
1503 : // for now.
1504 : double m_dCenterX;
1505 : double m_dCenterY;
1506 : double m_dXRadius;
1507 : double m_dYRadius;
1508 :
1509 : };
1510 :
1511 :
1512 : /*---------------------------------------------------------------------
1513 : * class TABArc
1514 : *
1515 : * Feature class to handle the MapInfo arc types:
1516 : *
1517 : * TAB_GEOM_ARC_C 0x0a
1518 : * TAB_GEOM_ARC 0x0b
1519 : *
1520 : * In MapInfo, an arc is defined by the coords of the MBR corners of its
1521 : * defining ellipse, which in this case is different from the arc's MBR,
1522 : * and a start and end angle in degrees.
1523 : *
1524 : * Feature geometry can be either an OGRLineString or an OGRPoint.
1525 : *
1526 : * In any case, X/Y radius X/Y center, and start/end angle (in degrees
1527 : * counterclockwise) MUST be set.
1528 : *
1529 : * When an arc is read, the returned geometry is an OGRLineString
1530 : * representing the arc with 2 degrees line segments.
1531 : *--------------------------------------------------------------------*/
1532 : class TABArc: public TABFeature,
1533 : public ITABFeaturePen
1534 : {
1535 : private:
1536 : double m_dStartAngle; // In degrees, counterclockwise,
1537 : double m_dEndAngle; // starting at 3 o'clock
1538 :
1539 : virtual int UpdateMBR(TABMAPFile *poMapFile = NULL);
1540 :
1541 : public:
1542 : TABArc(OGRFeatureDefn *poDefnIn);
1543 : virtual ~TABArc();
1544 :
1545 0 : virtual TABFeatureClass GetFeatureClass() { return TABFCArc; };
1546 : virtual int ValidateMapInfoType(TABMAPFile *poMapFile = NULL);
1547 :
1548 : virtual TABFeature *CloneTABFeature(OGRFeatureDefn *poNewDefn = NULL );
1549 :
1550 : virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1551 : GBool bCoordDataOnly=FALSE,
1552 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1553 : virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1554 : GBool bCoordDataOnly=FALSE,
1555 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1556 :
1557 : virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp);
1558 : virtual int WriteGeometryToMIFFile(MIDDATAFile *fp);
1559 :
1560 : virtual const char *GetStyleString();
1561 :
1562 : virtual void DumpMIF(FILE *fpOut = NULL);
1563 :
1564 0 : double GetStartAngle() { return m_dStartAngle; };
1565 0 : double GetEndAngle() { return m_dEndAngle; };
1566 : void SetStartAngle(double dAngle);
1567 : void SetEndAngle(double dAngle);
1568 :
1569 : // MapInfo-specific attributes... made available through public vars
1570 : // for now.
1571 : double m_dCenterX;
1572 : double m_dCenterY;
1573 : double m_dXRadius;
1574 : double m_dYRadius;
1575 : };
1576 :
1577 :
1578 : /*---------------------------------------------------------------------
1579 : * class TABText
1580 : *
1581 : * Feature class to handle the MapInfo text types:
1582 : *
1583 : * TAB_GEOM_TEXT_C 0x10
1584 : * TAB_GEOM_TEXT 0x11
1585 : *
1586 : * Feature geometry is an OGRPoint corresponding to the lower-left
1587 : * corner of the text MBR BEFORE ROTATION.
1588 : *
1589 : * Text string, and box height/width (box before rotation is applied)
1590 : * are required in a valid text feature and MUST be set.
1591 : * Text angle and other styles are optional.
1592 : *--------------------------------------------------------------------*/
1593 : class TABText: public TABFeature,
1594 : public ITABFeatureFont,
1595 : public ITABFeaturePen
1596 : {
1597 : protected:
1598 : char *m_pszString;
1599 :
1600 : double m_dAngle;
1601 : double m_dHeight;
1602 : double m_dWidth;
1603 : double m_dfLineEndX;
1604 : double m_dfLineEndY;
1605 : GBool m_bLineEndSet;
1606 : void UpdateTextMBR();
1607 :
1608 : GInt32 m_rgbForeground;
1609 : GInt32 m_rgbBackground;
1610 : GInt32 m_rgbOutline;
1611 : GInt32 m_rgbShadow;
1612 :
1613 : GInt16 m_nTextAlignment; // Justification/Vert.Spacing/arrow
1614 : GInt16 m_nFontStyle; // Bold/italic/underlined/shadow/...
1615 :
1616 : const char *GetLabelStyleString();
1617 :
1618 : virtual int UpdateMBR(TABMAPFile *poMapFile = NULL);
1619 :
1620 : public:
1621 : TABText(OGRFeatureDefn *poDefnIn);
1622 : virtual ~TABText();
1623 :
1624 0 : virtual TABFeatureClass GetFeatureClass() { return TABFCText; };
1625 : virtual int ValidateMapInfoType(TABMAPFile *poMapFile = NULL);
1626 :
1627 : virtual TABFeature *CloneTABFeature(OGRFeatureDefn *poNewDefn = NULL );
1628 :
1629 : virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1630 : GBool bCoordDataOnly=FALSE,
1631 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1632 : virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1633 : GBool bCoordDataOnly=FALSE,
1634 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1635 :
1636 : virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp);
1637 : virtual int WriteGeometryToMIFFile(MIDDATAFile *fp);
1638 :
1639 : virtual const char *GetStyleString();
1640 :
1641 : virtual void DumpMIF(FILE *fpOut = NULL);
1642 :
1643 : const char *GetTextString();
1644 : double GetTextAngle();
1645 : double GetTextBoxHeight();
1646 : double GetTextBoxWidth();
1647 : GInt32 GetFontFGColor();
1648 : GInt32 GetFontBGColor();
1649 : GInt32 GetFontOColor();
1650 : GInt32 GetFontSColor();
1651 : void GetTextLineEndPoint(double &dX, double &dY);
1652 :
1653 : TABTextJust GetTextJustification();
1654 : TABTextSpacing GetTextSpacing();
1655 : TABTextLineType GetTextLineType();
1656 : GBool QueryFontStyle(TABFontStyle eStyleToQuery);
1657 :
1658 : void SetTextString(const char *pszStr);
1659 : void SetTextAngle(double dAngle);
1660 : void SetTextBoxHeight(double dHeight);
1661 : void SetTextBoxWidth(double dWidth);
1662 : void SetFontFGColor(GInt32 rgbColor);
1663 : void SetFontBGColor(GInt32 rgbColor);
1664 : void SetFontOColor(GInt32 rgbColor);
1665 : void SetFontSColor(GInt32 rgbColor);
1666 : void SetTextLineEndPoint(double dX, double dY);
1667 :
1668 : void SetTextJustification(TABTextJust eJust);
1669 : void SetTextSpacing(TABTextSpacing eSpacing);
1670 : void SetTextLineType(TABTextLineType eLineType);
1671 : void ToggleFontStyle(TABFontStyle eStyleToToggle, GBool bStatus);
1672 :
1673 : int GetFontStyleMIFValue();
1674 : void SetFontStyleMIFValue(int nStyle, GBool bBGColorSet=FALSE);
1675 : GBool IsFontBGColorUsed();
1676 : GBool IsFontOColorUsed();
1677 : GBool IsFontSColorUsed();
1678 : GBool IsFontBold();
1679 : GBool IsFontItalic();
1680 : GBool IsFontUnderline();
1681 0 : int GetFontStyleTABValue() {return m_nFontStyle;};
1682 0 : void SetFontStyleTABValue(int nStyle){m_nFontStyle=(GInt16)nStyle;};
1683 :
1684 : };
1685 :
1686 :
1687 : /*---------------------------------------------------------------------
1688 : * class TABMultiPoint
1689 : *
1690 : * Feature class to handle MapInfo Multipoint features:
1691 : *
1692 : * TAB_GEOM_MULTIPOINT_C 0x34
1693 : * TAB_GEOM_MULTIPOINT 0x35
1694 : *
1695 : * Feature geometry will be a OGRMultiPoint
1696 : *
1697 : * The symbol number is in the range [31..67], with 31=None and corresponds
1698 : * to one of the 35 predefined "Old MapInfo Symbols"
1699 : *--------------------------------------------------------------------*/
1700 : class TABMultiPoint: public TABFeature,
1701 : public ITABFeatureSymbol
1702 : {
1703 : private:
1704 : // We call it center, but it's more like a label point
1705 : // Its value default to be the location of the first point
1706 : GBool m_bCenterIsSet;
1707 : double m_dCenterX, m_dCenterY;
1708 :
1709 : public:
1710 : TABMultiPoint(OGRFeatureDefn *poDefnIn);
1711 : virtual ~TABMultiPoint();
1712 :
1713 0 : virtual TABFeatureClass GetFeatureClass() { return TABFCMultiPoint; };
1714 : virtual int ValidateMapInfoType(TABMAPFile *poMapFile = NULL);
1715 :
1716 : virtual TABFeature *CloneTABFeature(OGRFeatureDefn *poNewDefn = NULL );
1717 :
1718 : int GetXY(int i, double &dX, double &dY);
1719 : int GetNumPoints();
1720 :
1721 : int GetCenter(double &dX, double &dY);
1722 : void SetCenter(double dX, double dY);
1723 :
1724 : virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1725 : GBool bCoordDataOnly=FALSE,
1726 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1727 : virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1728 : GBool bCoordDataOnly=FALSE,
1729 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1730 :
1731 : virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp);
1732 : virtual int WriteGeometryToMIFFile(MIDDATAFile *fp);
1733 :
1734 : virtual const char *GetStyleString();
1735 :
1736 : virtual void DumpMIF(FILE *fpOut = NULL);
1737 : };
1738 :
1739 : /*---------------------------------------------------------------------
1740 : *
1741 : * class TABCollection
1742 : *
1743 : * Feature class to handle MapInfo Collection features:
1744 : *
1745 : * TAB_GEOM_COLLECTION_C 0x37
1746 : * TAB_GEOM_COLLECTION 0x38
1747 : *
1748 : * Feature geometry will be a OGRCollection
1749 : *
1750 : * **** IMPORTANT NOTE: ****
1751 : *
1752 : * The current implementation does not allow setting the Geometry via
1753 : * OGRFeature::SetGeometry*(). The geometries must be set via the
1754 : * TABCollection::SetRegion/Pline/MpointDirectly() methods which will take
1755 : * care of keeping the OGRFeature's geometry in sync.
1756 : *
1757 : * If we ever want to support creating collections via the OGR interface then
1758 : * something should be added in TABCollection::WriteGeometryToMapFile(), or
1759 : * perhaps in ValidateMapInfoType(), or even better in a custom
1760 : * TABCollection::SetGeometry*()... but then this last option may not work
1761 : * unless OGRFeature::SetGeometry*() are made virtual in OGR.
1762 : *
1763 : *--------------------------------------------------------------------*/
1764 : class TABCollection: public TABFeature,
1765 : public ITABFeatureSymbol
1766 : {
1767 : private:
1768 : TABRegion *m_poRegion;
1769 : TABPolyline *m_poPline;
1770 : TABMultiPoint *m_poMpoint;
1771 :
1772 : void EmptyCollection();
1773 : int ReadLabelAndMBR(TABMAPCoordBlock *poCoordBlock,
1774 : GBool bComprCoord,
1775 : GInt32 nComprOrgX, GInt32 nComprOrgY,
1776 : GInt32 &pnMinX, GInt32 &pnMinY,
1777 : GInt32 &pnMaxX, GInt32 &pnMaxY,
1778 : GInt32 &pnLabelX, GInt32 &pnLabelY );
1779 : int WriteLabelAndMBR(TABMAPCoordBlock *poCoordBlock,
1780 : GBool bComprCoord,
1781 : GInt32 nMinX, GInt32 nMinY,
1782 : GInt32 nMaxX, GInt32 nMaxY,
1783 : GInt32 nLabelX, GInt32 nLabelY );
1784 : int SyncOGRGeometryCollection(GBool bSyncRegion,
1785 : GBool bSyncPline,
1786 : GBool bSyncMpoint);
1787 :
1788 : public:
1789 : TABCollection(OGRFeatureDefn *poDefnIn);
1790 : virtual ~TABCollection();
1791 :
1792 0 : virtual TABFeatureClass GetFeatureClass() { return TABFCCollection; };
1793 : virtual int ValidateMapInfoType(TABMAPFile *poMapFile = NULL);
1794 :
1795 : virtual TABFeature *CloneTABFeature(OGRFeatureDefn *poNewDefn = NULL );
1796 :
1797 : virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1798 : GBool bCoordDataOnly=FALSE,
1799 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1800 : virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1801 : GBool bCoordDataOnly=FALSE,
1802 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1803 :
1804 : virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp);
1805 : virtual int WriteGeometryToMIFFile(MIDDATAFile *fp);
1806 :
1807 : virtual const char *GetStyleString();
1808 :
1809 : virtual void DumpMIF(FILE *fpOut = NULL);
1810 :
1811 : TABRegion *GetRegionRef() {return m_poRegion; };
1812 : TABPolyline *GetPolylineRef() {return m_poPline; };
1813 : TABMultiPoint *GetMultiPointRef() {return m_poMpoint; };
1814 :
1815 : int SetRegionDirectly(TABRegion *poRegion);
1816 : int SetPolylineDirectly(TABPolyline *poPline);
1817 : int SetMultiPointDirectly(TABMultiPoint *poMpoint);
1818 : };
1819 :
1820 :
1821 : /*---------------------------------------------------------------------
1822 : * class TABDebugFeature
1823 : *
1824 : * Feature class to use for testing purposes... this one does not
1825 : * correspond to any MapInfo type... it's just used to dump info about
1826 : * feature types that are not implemented yet.
1827 : *--------------------------------------------------------------------*/
1828 : class TABDebugFeature: public TABFeature
1829 : {
1830 : private:
1831 : GByte m_abyBuf[512];
1832 : int m_nSize;
1833 : int m_nCoordDataPtr; // -1 if none
1834 : int m_nCoordDataSize;
1835 :
1836 : public:
1837 : TABDebugFeature(OGRFeatureDefn *poDefnIn);
1838 : virtual ~TABDebugFeature();
1839 :
1840 0 : virtual TABFeatureClass GetFeatureClass() { return TABFCDebugFeature; };
1841 :
1842 : virtual int ReadGeometryFromMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1843 : GBool bCoordDataOnly=FALSE,
1844 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1845 : virtual int WriteGeometryToMAPFile(TABMAPFile *poMapFile, TABMAPObjHdr *,
1846 : GBool bCoordDataOnly=FALSE,
1847 : TABMAPCoordBlock **ppoCoordBlock=NULL);
1848 :
1849 : virtual int ReadGeometryFromMIFFile(MIDDATAFile *fp);
1850 : virtual int WriteGeometryToMIFFile(MIDDATAFile *fp);
1851 :
1852 : virtual void DumpMIF(FILE *fpOut = NULL);
1853 : };
1854 :
1855 : /* -------------------------------------------------------------------- */
1856 : /* Some stuff related to spatial reference system handling. */
1857 : /* */
1858 : /* In GDAL we make use of the coordsys transformation from */
1859 : /* other places (sometimes even from plugins), so we */
1860 : /* deliberately export these two functions from the DLL. */
1861 : /* -------------------------------------------------------------------- */
1862 :
1863 : char CPL_DLL *MITABSpatialRef2CoordSys( OGRSpatialReference * );
1864 : OGRSpatialReference CPL_DLL * MITABCoordSys2SpatialRef( const char * );
1865 :
1866 : GBool MITABExtractCoordSysBounds( const char * pszCoordSys,
1867 : double &dXMin, double &dYMin,
1868 : double &dXMax, double &dYMax );
1869 : int MITABCoordSys2TABProjInfo(const char * pszCoordSys, TABProjInfo *psProj);
1870 :
1871 : typedef struct {
1872 : int nMapInfoDatumID;
1873 : const char *pszOGCDatumName;
1874 : int nEllipsoid;
1875 : double dfShiftX;
1876 : double dfShiftY;
1877 : double dfShiftZ;
1878 : double dfDatumParm0; /* RotX */
1879 : double dfDatumParm1; /* RotY */
1880 : double dfDatumParm2; /* RotZ */
1881 : double dfDatumParm3; /* Scale Factor */
1882 : double dfDatumParm4; /* Prime Meridian */
1883 : } MapInfoDatumInfo;
1884 :
1885 : typedef struct
1886 : {
1887 : int nMapInfoId;
1888 : const char *pszMapinfoName;
1889 : double dfA; /* semi major axis in meters */
1890 : double dfInvFlattening; /* Inverse flattening */
1891 : } MapInfoSpheroidInfo;
1892 :
1893 :
1894 : /*---------------------------------------------------------------------
1895 : * The following are used for coordsys bounds lookup
1896 : *--------------------------------------------------------------------*/
1897 : typedef struct
1898 : {
1899 : TABProjInfo sProj; /* Projection/datum definition */
1900 : double dXMin; /* Default bounds for that coordsys */
1901 : double dYMin;
1902 : double dXMax;
1903 : double dYMax;
1904 : } MapInfoBoundsInfo;
1905 :
1906 : GBool MITABLookupCoordSysBounds(TABProjInfo *psCS,
1907 : double &dXMin, double &dYMin,
1908 : double &dXMax, double &dYMax);
1909 : int MITABLoadCoordSysTable(const char *pszFname);
1910 : void MITABFreeCoordSysTable();
1911 : GBool MITABCoordSysTableLoaded();
1912 :
1913 : #endif /* _MITAB_H_INCLUDED_ */
1914 :
1915 :
|