1 #ifndef SHAPEFILE_H_INCLUDED 2 #define SHAPEFILE_H_INCLUDED 3 4 /****************************************************************************** 5 * $Id$ 6 * 7 * Project: Shapelib 8 * Purpose: Primary include file for Shapelib. 9 * Author: Frank Warmerdam, warmerdam@pobox.com 10 * 11 ****************************************************************************** 12 * Copyright (c) 1999, Frank Warmerdam 13 * Copyright (c) 2012-2013, Even Rouault <even dot rouault at mines-paris dot org> 14 * 15 * This software is available under the following "MIT Style" license, 16 * or at the option of the licensee under the LGPL (see LICENSE.LGPL). This 17 * option is discussed in more detail in shapelib.html. 18 * 19 * -- 20 * 21 * Permission is hereby granted, free of charge, to any person obtaining a 22 * copy of this software and associated documentation files (the "Software"), 23 * to deal in the Software without restriction, including without limitation 24 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 25 * and/or sell copies of the Software, and to permit persons to whom the 26 * Software is furnished to do so, subject to the following conditions: 27 * 28 * The above copyright notice and this permission notice shall be included 29 * in all copies or substantial portions of the Software. 30 * 31 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 32 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 34 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 35 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 36 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 37 * DEALINGS IN THE SOFTWARE. 38 ****************************************************************************** 39 * 40 * $Log: shapefil.h,v $ 41 * Revision 1.52 2011-12-11 22:26:46 fwarmerdam 42 * upgrade .qix access code to use SAHooks (gdal #3365) 43 * 44 * Revision 1.51 2011-07-24 05:59:25 fwarmerdam 45 * minimize use of CPLError in favor of SAHooks.Error() 46 * 47 * Revision 1.50 2011-05-13 17:35:17 fwarmerdam 48 * added DBFReorderFields() and DBFAlterFields() functions (from Even) 49 * 50 * Revision 1.49 2011-04-16 14:38:21 fwarmerdam 51 * avoid warnings with gcc on SHP_CVSID 52 * 53 * Revision 1.48 2010-08-27 23:42:52 fwarmerdam 54 * add SHPAPI_CALL attribute in code 55 * 56 * Revision 1.47 2010-01-28 11:34:34 fwarmerdam 57 * handle the shape file length limits more gracefully (#3236) 58 * 59 * Revision 1.46 2008-11-12 14:28:15 fwarmerdam 60 * DBFCreateField() now works on files with records 61 * 62 * Revision 1.45 2008/11/11 17:47:10 fwarmerdam 63 * added DBFDeleteField() function 64 * 65 * Revision 1.44 2008/01/16 20:05:19 bram 66 * Add file hooks that accept UTF-8 encoded filenames on some platforms. Use SASetupUtf8Hooks 67 * tosetup the hooks and check SHPAPI_UTF8_HOOKS for its availability. Currently, this 68 * is only available on the Windows platform that decodes the UTF-8 filenames to wide 69 * character strings and feeds them to _wfopen and _wremove. 70 * 71 * Revision 1.43 2008/01/10 16:35:30 fwarmerdam 72 * avoid _ prefix on #defined symbols (bug 1840) 73 * 74 * Revision 1.42 2007/12/18 18:28:14 bram 75 * - create hook for client specific atof (bugzilla ticket 1615) 76 * - check for NULL handle before closing cpCPG file, and close after reading. 77 * 78 * Revision 1.41 2007/12/15 20:25:32 bram 79 * dbfopen.c now reads the Code Page information from the DBF file, and exports 80 * this information as a string through the DBFGetCodePage function. This is 81 * either the number from the LDID header field ("LDID/<number>") or as the 82 * content of an accompanying .CPG file. When creating a DBF file, the code can 83 * be set using DBFCreateEx. 84 * 85 * Revision 1.40 2007/12/06 07:00:25 fwarmerdam 86 * dbfopen now using SAHooks for fileio 87 * 88 * Revision 1.39 2007/12/04 20:37:56 fwarmerdam 89 * preliminary implementation of hooks api for io and errors 90 * 91 * Revision 1.38 2007/11/21 22:39:56 fwarmerdam 92 * close shx file in readonly mode (GDAL #1956) 93 * 94 * Revision 1.37 2007/10/27 03:31:14 fwarmerdam 95 * limit default depth of tree to 12 levels (gdal ticket #1594) 96 * 97 * Revision 1.36 2007/09/10 23:33:15 fwarmerdam 98 * Upstreamed support for visibility flag in SHPAPI_CALL for the needs 99 * of GDAL (gdal ticket #1810). 100 * 101 * Revision 1.35 2007/09/03 19:48:10 fwarmerdam 102 * move DBFReadAttribute() static dDoubleField into dbfinfo 103 * 104 * Revision 1.34 2006/06/17 15:33:32 fwarmerdam 105 * added pszWorkField - bug 1202 (rso) 106 * 107 * Revision 1.33 2006/02/15 01:14:30 fwarmerdam 108 * added DBFAddNativeFieldType 109 * 110 * Revision 1.32 2006/01/26 15:07:32 fwarmerdam 111 * add bMeasureIsUsed flag from Craig Bruce: Bug 1249 112 * 113 * Revision 1.31 2006/01/05 01:27:27 fwarmerdam 114 * added dbf deletion mark/fetch 115 * 116 * Revision 1.30 2005/01/03 22:30:13 fwarmerdam 117 * added support for saved quadtrees 118 * 119 * Revision 1.29 2004/09/26 20:09:35 fwarmerdam 120 * avoid rcsid warnings 121 * 122 * Revision 1.28 2003/12/29 06:02:18 fwarmerdam 123 * added cpl_error.h option 124 * 125 * Revision 1.27 2003/04/21 18:30:37 warmerda 126 * added header write/update public methods 127 * 128 * Revision 1.26 2002/09/29 00:00:08 warmerda 129 * added FTLogical and logical attribute read/write calls 130 * 131 * Revision 1.25 2002/05/07 13:46:30 warmerda 132 * added DBFWriteAttributeDirectly(). 133 * 134 * Revision 1.24 2002/04/10 16:59:54 warmerda 135 * added SHPRewindObject 136 * 137 * Revision 1.23 2002/01/15 14:36:07 warmerda 138 * updated email address 139 * 140 * Revision 1.22 2002/01/15 14:32:00 warmerda 141 * try to improve SHPAPI_CALL docs 142 */ 143 144 #include <stdio.h> 145 146 #ifdef USE_DBMALLOC 147 #include <dbmalloc.h> 148 #endif 149 150 #ifdef USE_CPL 151 #include "cpl_conv.h" 152 #endif 153 154 #ifdef __cplusplus 155 extern "C" { 156 #endif 157 158 /************************************************************************/ 159 /* Configuration options. */ 160 /************************************************************************/ 161 162 /* -------------------------------------------------------------------- */ 163 /* Should the DBFReadStringAttribute() strip leading and */ 164 /* trailing white space? */ 165 /* -------------------------------------------------------------------- */ 166 #define TRIM_DBF_WHITESPACE 167 168 /* -------------------------------------------------------------------- */ 169 /* Should we write measure values to the Multipatch object? */ 170 /* Reportedly ArcView crashes if we do write it, so for now it */ 171 /* is disabled. */ 172 /* -------------------------------------------------------------------- */ 173 #define DISABLE_MULTIPATCH_MEASURE 174 175 /* -------------------------------------------------------------------- */ 176 /* SHPAPI_CALL */ 177 /* */ 178 /* The following two macros are present to allow forcing */ 179 /* various calling conventions on the Shapelib API. */ 180 /* */ 181 /* To force __stdcall conventions (needed to call Shapelib */ 182 /* from Visual Basic and/or Dephi I believe) the makefile could */ 183 /* be modified to define: */ 184 /* */ 185 /* /DSHPAPI_CALL=__stdcall */ 186 /* */ 187 /* If it is desired to force export of the Shapelib API without */ 188 /* using the shapelib.def file, use the following definition. */ 189 /* */ 190 /* /DSHAPELIB_DLLEXPORT */ 191 /* */ 192 /* To get both at once it will be necessary to hack this */ 193 /* include file to define: */ 194 /* */ 195 /* #define SHPAPI_CALL __declspec(dllexport) __stdcall */ 196 /* #define SHPAPI_CALL1 __declspec(dllexport) * __stdcall */ 197 /* */ 198 /* The complexity of the situation is partly caused by the */ 199 /* peculiar requirement of Visual C++ that __stdcall appear */ 200 /* after any "*"'s in the return value of a function while the */ 201 /* __declspec(dllexport) must appear before them. */ 202 /* -------------------------------------------------------------------- */ 203 204 #ifdef SHAPELIB_DLLEXPORT 205 # define SHPAPI_CALL __declspec(dllexport) 206 # define SHPAPI_CALL1(x) __declspec(dllexport) x 207 #endif 208 209 #ifndef SHPAPI_CALL 210 # if defined(USE_GCC_VISIBILITY_FLAG) 211 # define SHPAPI_CALL __attribute__ ((visibility("default"))) 212 # define SHPAPI_CALL1(x) __attribute__ ((visibility("default"))) x 213 # else 214 # define SHPAPI_CALL 215 # endif 216 #endif 217 218 #ifndef SHPAPI_CALL1 219 # define SHPAPI_CALL1(x) x SHPAPI_CALL 220 #endif 221 222 /* -------------------------------------------------------------------- */ 223 /* Macros for controlling CVSID and ensuring they don't appear */ 224 /* as unreferenced variables resulting in lots of warnings. */ 225 /* -------------------------------------------------------------------- */ 226 #ifndef DISABLE_CVSID 227 # if defined(__GNUC__) && __GNUC__ >= 4 228 # define SHP_CVSID(string) static const char cpl_cvsid[] __attribute__((used)) = string; 229 # else 230 # define SHP_CVSID(string) static const char cpl_cvsid[] = string; \ 231 static const char *cvsid_aw() { return( cvsid_aw() ? NULL : cpl_cvsid ); } 232 # endif 233 #else 234 # define SHP_CVSID(string) 235 #endif 236 237 /* -------------------------------------------------------------------- */ 238 /* On some platforms, additional file IO hooks are defined that */ 239 /* UTF-8 encoded filenames Unicode filenames */ 240 /* -------------------------------------------------------------------- */ 241 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) 242 # define SHPAPI_WINDOWS 243 # define SHPAPI_UTF8_HOOKS 244 #endif 245 246 /* -------------------------------------------------------------------- */ 247 /* IO/Error hook functions. */ 248 /* -------------------------------------------------------------------- */ 249 typedef int *SAFile; 250 251 #ifndef SAOffset 252 typedef unsigned long SAOffset; 253 #endif 254 255 typedef struct { 256 SAFile (*FOpen) ( const char *filename, const char *access); 257 SAOffset (*FRead) ( void *p, SAOffset size, SAOffset nmemb, SAFile file); 258 SAOffset (*FWrite)( void *p, SAOffset size, SAOffset nmemb, SAFile file); 259 SAOffset (*FSeek) ( SAFile file, SAOffset offset, int whence ); 260 SAOffset (*FTell) ( SAFile file ); 261 int (*FFlush)( SAFile file ); 262 int (*FClose)( SAFile file ); 263 int (*Remove) ( const char *filename ); 264 265 void (*Error) ( const char *message ); 266 double (*Atof) ( const char *str ); 267 } SAHooks; 268 269 void SHPAPI_CALL SASetupDefaultHooks( SAHooks *psHooks ); 270 #ifdef SHPAPI_UTF8_HOOKS 271 void SHPAPI_CALL SASetupUtf8Hooks( SAHooks *psHooks ); 272 #endif 273 274 /************************************************************************/ 275 /* SHP Support. */ 276 /************************************************************************/ 277 typedef struct tagSHPObject SHPObject; 278 279 typedef struct 280 { 281 SAHooks sHooks; 282 283 SAFile fpSHP; 284 SAFile fpSHX; 285 286 int nShapeType; /* SHPT_* */ 287 288 unsigned int nFileSize; /* SHP file */ 289 290 int nRecords; 291 int nMaxRecords; 292 unsigned int *panRecOffset; 293 unsigned int *panRecSize; 294 295 double adBoundsMin[4]; 296 double adBoundsMax[4]; 297 298 int bUpdated; 299 300 unsigned char *pabyRec; 301 int nBufSize; 302 303 int bFastModeReadObject; 304 unsigned char *pabyObjectBuf; 305 int nObjectBufSize; 306 SHPObject* psCachedObject; 307 } SHPInfo; 308 309 typedef SHPInfo * SHPHandle; 310 311 /* -------------------------------------------------------------------- */ 312 /* Shape types (nSHPType) */ 313 /* -------------------------------------------------------------------- */ 314 #define SHPT_NULL 0 315 #define SHPT_POINT 1 316 #define SHPT_ARC 3 317 #define SHPT_POLYGON 5 318 #define SHPT_MULTIPOINT 8 319 #define SHPT_POINTZ 11 320 #define SHPT_ARCZ 13 321 #define SHPT_POLYGONZ 15 322 #define SHPT_MULTIPOINTZ 18 323 #define SHPT_POINTM 21 324 #define SHPT_ARCM 23 325 #define SHPT_POLYGONM 25 326 #define SHPT_MULTIPOINTM 28 327 #define SHPT_MULTIPATCH 31 328 329 330 /* -------------------------------------------------------------------- */ 331 /* Part types - everything but SHPT_MULTIPATCH just uses */ 332 /* SHPP_RING. */ 333 /* -------------------------------------------------------------------- */ 334 335 #define SHPP_TRISTRIP 0 336 #define SHPP_TRIFAN 1 337 #define SHPP_OUTERRING 2 338 #define SHPP_INNERRING 3 339 #define SHPP_FIRSTRING 4 340 #define SHPP_RING 5 341 342 /* -------------------------------------------------------------------- */ 343 /* SHPObject - represents on shape (without attributes) read */ 344 /* from the .shp file. */ 345 /* -------------------------------------------------------------------- */ 346 struct tagSHPObject 347 { 348 int nSHPType; 349 350 int nShapeId; /* -1 is unknown/unassigned */ 351 352 int nParts; 353 int *panPartStart; 354 int *panPartType; 355 356 int nVertices; 357 double *padfX; 358 double *padfY; 359 double *padfZ; 360 double *padfM; 361 362 double dfXMin; 363 double dfYMin; 364 double dfZMin; 365 double dfMMin; 366 367 double dfXMax; 368 double dfYMax; 369 double dfZMax; 370 double dfMMax; 371 372 int bMeasureIsUsed; 373 int bFastModeReadObject; 374 }; 375 376 /* -------------------------------------------------------------------- */ 377 /* SHP API Prototypes */ 378 /* -------------------------------------------------------------------- */ 379 380 /* If pszAccess is read-only, the fpSHX field of the returned structure */ 381 /* will be NULL as it is not necessary to keep the SHX file open */ 382 SHPHandle SHPAPI_CALL 383 SHPOpen( const char * pszShapeFile, const char * pszAccess ); 384 SHPHandle SHPAPI_CALL 385 SHPOpenLL( const char *pszShapeFile, const char *pszAccess, 386 SAHooks *psHooks ); 387 SHPHandle SHPAPI_CALL 388 SHPOpenLLEx( const char *pszShapeFile, const char *pszAccess, 389 SAHooks *psHooks, int bRestoreSHX ); 390 391 int SHPAPI_CALL 392 SHPRestoreSHX( const char *pszShapeFile, const char *pszAccess, 393 SAHooks *psHooks ); 394 395 /* If setting bFastMode = TRUE, the content of SHPReadObject() is owned by the SHPHandle. */ 396 /* So you cannot have 2 valid instances of SHPReadObject() simultaneously. */ 397 /* The SHPObject padfZ and padfM members may be NULL depending on the geometry */ 398 /* type. It is illegal to free at hand any of the pointer members of the SHPObject structure */ 399 void SHPAPI_CALL SHPSetFastModeReadObject( SHPHandle hSHP, int bFastMode ); 400 401 SHPHandle SHPAPI_CALL 402 SHPCreate( const char * pszShapeFile, int nShapeType ); 403 SHPHandle SHPAPI_CALL 404 SHPCreateLL( const char * pszShapeFile, int nShapeType, 405 SAHooks *psHooks ); 406 void SHPAPI_CALL 407 SHPGetInfo( SHPHandle hSHP, int * pnEntities, int * pnShapeType, 408 double * padfMinBound, double * padfMaxBound ); 409 410 SHPObject SHPAPI_CALL1(*) 411 SHPReadObject( SHPHandle hSHP, int iShape ); 412 int SHPAPI_CALL 413 SHPWriteObject( SHPHandle hSHP, int iShape, SHPObject * psObject ); 414 415 void SHPAPI_CALL 416 SHPDestroyObject( SHPObject * psObject ); 417 void SHPAPI_CALL 418 SHPComputeExtents( SHPObject * psObject ); 419 SHPObject SHPAPI_CALL1(*) 420 SHPCreateObject( int nSHPType, int nShapeId, int nParts, 421 const int * panPartStart, const int * panPartType, 422 int nVertices, 423 const double * padfX, const double * padfY, 424 const double * padfZ, const double * padfM ); 425 SHPObject SHPAPI_CALL1(*) 426 SHPCreateSimpleObject( int nSHPType, int nVertices, 427 const double * padfX, 428 const double * padfY, 429 const double * padfZ ); 430 431 int SHPAPI_CALL 432 SHPRewindObject( SHPHandle hSHP, SHPObject * psObject ); 433 434 void SHPAPI_CALL SHPClose( SHPHandle hSHP ); 435 void SHPAPI_CALL SHPWriteHeader( SHPHandle hSHP ); 436 437 const char SHPAPI_CALL1(*) 438 SHPTypeName( int nSHPType ); 439 const char SHPAPI_CALL1(*) 440 SHPPartTypeName( int nPartType ); 441 442 /* -------------------------------------------------------------------- */ 443 /* Shape quadtree indexing API. */ 444 /* -------------------------------------------------------------------- */ 445 446 /* this can be two or four for binary or quad tree */ 447 #define MAX_SUBNODE 4 448 449 /* upper limit of tree levels for automatic estimation */ 450 #define MAX_DEFAULT_TREE_DEPTH 12 451 452 typedef struct shape_tree_node 453 { 454 /* region covered by this node */ 455 double adfBoundsMin[4]; 456 double adfBoundsMax[4]; 457 458 /* list of shapes stored at this node. The papsShapeObj pointers 459 or the whole list can be NULL */ 460 int nShapeCount; 461 int *panShapeIds; 462 SHPObject **papsShapeObj; 463 464 int nSubNodes; 465 struct shape_tree_node *apsSubNode[MAX_SUBNODE]; 466 467 } SHPTreeNode; 468 469 typedef struct 470 { 471 SHPHandle hSHP; 472 473 int nMaxDepth; 474 int nDimension; 475 int nTotalCount; 476 477 SHPTreeNode *psRoot; 478 } SHPTree; 479 480 SHPTree SHPAPI_CALL1(*) 481 SHPCreateTree( SHPHandle hSHP, int nDimension, int nMaxDepth, 482 double *padfBoundsMin, double *padfBoundsMax ); 483 void SHPAPI_CALL 484 SHPDestroyTree( SHPTree * hTree ); 485 486 int SHPAPI_CALL 487 SHPWriteTree( SHPTree *hTree, const char * pszFilename ); 488 489 int SHPAPI_CALL 490 SHPTreeAddShapeId( SHPTree * hTree, SHPObject * psObject ); 491 int SHPAPI_CALL 492 SHPTreeRemoveShapeId( SHPTree * hTree, int nShapeId ); 493 494 void SHPAPI_CALL 495 SHPTreeTrimExtraNodes( SHPTree * hTree ); 496 497 int SHPAPI_CALL1(*) 498 SHPTreeFindLikelyShapes( SHPTree * hTree, 499 double * padfBoundsMin, 500 double * padfBoundsMax, 501 int * ); 502 int SHPAPI_CALL 503 SHPCheckBoundsOverlap( double *, double *, double *, double *, int ); 504 505 int SHPAPI_CALL1(*) 506 SHPSearchDiskTree( FILE *fp, 507 double *padfBoundsMin, double *padfBoundsMax, 508 int *pnShapeCount ); 509 510 511 typedef struct SHPDiskTreeInfo* SHPTreeDiskHandle; 512 513 SHPTreeDiskHandle SHPAPI_CALL 514 SHPOpenDiskTree( const char* pszQIXFilename, 515 SAHooks *psHooks ); 516 517 void SHPAPI_CALL 518 SHPCloseDiskTree( SHPTreeDiskHandle hDiskTree ); 519 520 int SHPAPI_CALL1(*) 521 SHPSearchDiskTreeEx( SHPTreeDiskHandle hDiskTree, 522 double *padfBoundsMin, double *padfBoundsMax, 523 int *pnShapeCount ); 524 525 int SHPAPI_CALL 526 SHPWriteTreeLL(SHPTree *hTree, const char *pszFilename, SAHooks *psHooks ); 527 528 529 /* -------------------------------------------------------------------- */ 530 /* SBN Search API */ 531 /* -------------------------------------------------------------------- */ 532 533 typedef struct SBNSearchInfo* SBNSearchHandle; 534 535 SBNSearchHandle SHPAPI_CALL 536 SBNOpenDiskTree( const char* pszSBNFilename, 537 SAHooks *psHooks ); 538 539 void SHPAPI_CALL 540 SBNCloseDiskTree( SBNSearchHandle hSBN ); 541 542 int SHPAPI_CALL1(*) 543 SBNSearchDiskTree( SBNSearchHandle hSBN, 544 double *padfBoundsMin, double *padfBoundsMax, 545 int *pnShapeCount ); 546 547 int SHPAPI_CALL1(*) 548 SBNSearchDiskTreeInteger( SBNSearchHandle hSBN, 549 int bMinX, int bMinY, int bMaxX, int bMaxY, 550 int *pnShapeCount ); 551 552 void SHPAPI_CALL SBNSearchFreeIds( int* panShapeId ); 553 554 /************************************************************************/ 555 /* DBF Support. */ 556 /************************************************************************/ 557 typedef struct 558 { 559 SAHooks sHooks; 560 561 SAFile fp; 562 563 int nRecords; 564 565 int nRecordLength; 566 int nHeaderLength; 567 int nFields; 568 int *panFieldOffset; 569 int *panFieldSize; 570 int *panFieldDecimals; 571 char *pachFieldType; 572 573 char *pszHeader; 574 575 int nCurrentRecord; 576 int bCurrentRecordModified; 577 char *pszCurrentRecord; 578 579 int nWorkFieldLength; 580 char *pszWorkField; 581 582 int bNoHeader; 583 int bUpdated; 584 585 union 586 { 587 double dfDoubleField; 588 int nIntField; 589 } fieldValue; 590 591 int iLanguageDriver; 592 char *pszCodePage; 593 594 int nUpdateYearSince1900; /* 0-255 */ 595 int nUpdateMonth; /* 1-12 */ 596 int nUpdateDay; /* 1-31 */ 597 } DBFInfo; 598 599 typedef DBFInfo * DBFHandle; 600 601 typedef enum { 602 FTString, 603 FTInteger, 604 FTDouble, 605 FTLogical, 606 FTInvalid 607 } DBFFieldType; 608 609 #define XBASE_FLDHDR_SZ 32 610 611 612 DBFHandle SHPAPI_CALL 613 DBFOpen( const char * pszDBFFile, const char * pszAccess ); 614 DBFHandle SHPAPI_CALL 615 DBFOpenLL( const char * pszDBFFile, const char * pszAccess, 616 SAHooks *psHooks ); 617 DBFHandle SHPAPI_CALL 618 DBFCreate( const char * pszDBFFile ); 619 DBFHandle SHPAPI_CALL 620 DBFCreateEx( const char * pszDBFFile, const char * pszCodePage ); 621 DBFHandle SHPAPI_CALL 622 DBFCreateLL( const char * pszDBFFile, const char * pszCodePage, SAHooks *psHooks ); 623 624 int SHPAPI_CALL 625 DBFGetFieldCount( DBFHandle psDBF ); 626 int SHPAPI_CALL 627 DBFGetRecordCount( DBFHandle psDBF ); 628 int SHPAPI_CALL 629 DBFAddField( DBFHandle hDBF, const char * pszFieldName, 630 DBFFieldType eType, int nWidth, int nDecimals ); 631 632 int SHPAPI_CALL 633 DBFAddNativeFieldType( DBFHandle hDBF, const char * pszFieldName, 634 char chType, int nWidth, int nDecimals ); 635 636 int SHPAPI_CALL 637 DBFDeleteField( DBFHandle hDBF, int iField ); 638 639 int SHPAPI_CALL 640 DBFReorderFields( DBFHandle psDBF, int* panMap ); 641 642 int SHPAPI_CALL 643 DBFAlterFieldDefn( DBFHandle psDBF, int iField, const char * pszFieldName, 644 char chType, int nWidth, int nDecimals ); 645 646 DBFFieldType SHPAPI_CALL 647 DBFGetFieldInfo( DBFHandle psDBF, int iField, 648 char * pszFieldName, int * pnWidth, int * pnDecimals ); 649 650 int SHPAPI_CALL 651 DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName); 652 653 int SHPAPI_CALL 654 DBFReadIntegerAttribute( DBFHandle hDBF, int iShape, int iField ); 655 double SHPAPI_CALL 656 DBFReadDoubleAttribute( DBFHandle hDBF, int iShape, int iField ); 657 const char SHPAPI_CALL1(*) 658 DBFReadStringAttribute( DBFHandle hDBF, int iShape, int iField ); 659 const char SHPAPI_CALL1(*) 660 DBFReadLogicalAttribute( DBFHandle hDBF, int iShape, int iField ); 661 int SHPAPI_CALL 662 DBFIsAttributeNULL( DBFHandle hDBF, int iShape, int iField ); 663 664 int SHPAPI_CALL 665 DBFWriteIntegerAttribute( DBFHandle hDBF, int iShape, int iField, 666 int nFieldValue ); 667 int SHPAPI_CALL 668 DBFWriteDoubleAttribute( DBFHandle hDBF, int iShape, int iField, 669 double dFieldValue ); 670 int SHPAPI_CALL 671 DBFWriteStringAttribute( DBFHandle hDBF, int iShape, int iField, 672 const char * pszFieldValue ); 673 int SHPAPI_CALL 674 DBFWriteNULLAttribute( DBFHandle hDBF, int iShape, int iField ); 675 676 int SHPAPI_CALL 677 DBFWriteLogicalAttribute( DBFHandle hDBF, int iShape, int iField, 678 const char lFieldValue); 679 int SHPAPI_CALL 680 DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity, int iField, 681 void * pValue ); 682 const char SHPAPI_CALL1(*) 683 DBFReadTuple(DBFHandle psDBF, int hEntity ); 684 int SHPAPI_CALL 685 DBFWriteTuple(DBFHandle psDBF, int hEntity, void * pRawTuple ); 686 687 int SHPAPI_CALL DBFIsRecordDeleted( DBFHandle psDBF, int iShape ); 688 int SHPAPI_CALL DBFMarkRecordDeleted( DBFHandle psDBF, int iShape, 689 int bIsDeleted ); 690 691 DBFHandle SHPAPI_CALL 692 DBFCloneEmpty(DBFHandle psDBF, const char * pszFilename ); 693 694 void SHPAPI_CALL 695 DBFClose( DBFHandle hDBF ); 696 void SHPAPI_CALL 697 DBFUpdateHeader( DBFHandle hDBF ); 698 char SHPAPI_CALL 699 DBFGetNativeFieldType( DBFHandle hDBF, int iField ); 700 701 const char SHPAPI_CALL1(*) 702 DBFGetCodePage(DBFHandle psDBF ); 703 704 void SHPAPI_CALL 705 DBFSetLastModifiedDate( DBFHandle psDBF, int nYYSince1900, int nMM, int nDD ); 706 707 #ifdef __cplusplus 708 } 709 #endif 710 711 #endif /* ndef SHAPEFILE_H_INCLUDED */ 712