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