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