GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71915
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
shapefil.h
Go to the documentation of this file.
1 #ifndef SHAPEFILE_H_INCLUDED
2 #define SHAPEFILE_H_INCLUDED
3 
4 /******************************************************************************
5  * $Id: shapefil.h 69890 2016-11-24 09:57:15Z mmetz $
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 {
282 
283  SAFile fpSHP;
284  SAFile fpSHX;
285 
286  int nShapeType; /* SHPT_* */
287 
288  unsigned int nFileSize; /* SHP file */
289 
290  int nRecords;
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 
304  unsigned char *pabyObjectBuf;
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 /* -------------------------------------------------------------------- */
347 {
348  int nSHPType;
349 
350  int nShapeId; /* -1 is unknown/unassigned */
351 
352  int nParts;
355 
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 
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 
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 );
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 );
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 */
463 
466 
467 } SHPTreeNode;
468 
469 typedef struct
470 {
471  SHPHandle hSHP;
472 
476 
478 } SHPTree;
479 
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(*)
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 {
560 
561  SAFile fp;
562 
563  int nRecords;
564 
567  int nFields;
572 
573  char *pszHeader;
574 
578 
581 
583  int bUpdated;
584 
585  union
586  {
589  } fieldValue;
590 
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 {
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 
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 */
#define SHPAPI_CALL
Definition: shapefil.h:214
int SHPAPI_CALL DBFAddNativeFieldType(DBFHandle psDBF, const char *pszFieldName, char chType, int nWidth, int nDecimals)
Definition: dbfopen.c:854
int SHPAPI_CALL DBFWriteIntegerAttribute(DBFHandle psDBF, int iRecord, int iField, int nValue)
Definition: dbfopen.c:1500
double SHPAPI_CALL DBFReadDoubleAttribute(DBFHandle psDBF, int iRecord, int iField)
Definition: dbfopen.c:1110
int iLanguageDriver
Definition: shapefil.h:591
int nUpdateYearSince1900
Definition: shapefil.h:594
void SHPAPI_CALL SBNCloseDiskTree(SBNSearchHandle hSBN)
int nVertices
Definition: shapefil.h:356
double adfBoundsMin[4]
Definition: shapefil.h:455
const char SHPAPI_CALL1 * DBFReadLogicalAttribute(DBFHandle psDBF, int iRecord, int iField){return((const char *) DBFReadAttribute(psDBF, iRecord, iField, 'L')
void SHPAPI_CALL DBFClose(DBFHandle psDBF)
Definition: dbfopen.c:612
void SHPAPI_CALL DBFSetLastModifiedDate(DBFHandle psDBF, int nYYSince1900, int nMM, int nDD)
Definition: dbfopen.c:381
double dfYMax
Definition: shapefil.h:368
int SHPAPI_CALL DBFMarkRecordDeleted(DBFHandle psDBF, int iShape, int bIsDeleted)
Definition: dbfopen.c:1768
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
int bUpdated
Definition: shapefil.h:298
int * panFieldOffset
Definition: shapefil.h:568
void SHPAPI_CALL SHPComputeExtents(SHPObject *psObject)
Definition: shpopen.c:1348
int nCurrentRecord
Definition: shapefil.h:575
void SHPAPI_CALL DBFUpdateHeader(DBFHandle psDBF)
Definition: dbfopen.c:348
struct shape_tree_node SHPTreeNode
void SHPAPI_CALL SHPTreeTrimExtraNodes(SHPTree *hTree)
double dfZMin
Definition: shapefil.h:364
int bMeasureIsUsed
Definition: shapefil.h:372
#define MAX_SUBNODE
Definition: shapefil.h:447
int SHPAPI_CALL DBFGetFieldCount(DBFHandle psDBF)
Definition: dbfopen.c:1225
int nWorkFieldLength
Definition: shapefil.h:579
int SHPAPI_CALL SHPRewindObject(SHPHandle hSHP, SHPObject *psObject)
DBFHandle SHPAPI_CALL DBFCreateLL(const char *pszFilename, const char *pszCodePage, SAHooks *psHooks)
Definition: dbfopen.c:692
double adfBoundsMax[4]
Definition: shapefil.h:456
DBFHandle SHPAPI_CALL DBFCloneEmpty(DBFHandle psDBF, const char *pszFilename)
char SHPAPI_CALL DBFGetNativeFieldType(DBFHandle psDBF, int iField)
Definition: dbfopen.c:1680
int nShapeId
Definition: shapefil.h:350
unsigned long SAOffset
Definition: shapefil.h:252
const char SHPAPI_CALL1 * DBFReadStringAttribute(DBFHandle psDBF, int iRecord, int iField){return((const char *) DBFReadAttribute(psDBF, iRecord, iField, 'C')
void SHPAPI_CALL SHPGetInfo(SHPHandle hSHP, int *pnEntities, int *pnShapeType, double *padfMinBound, double *padfMaxBound)
Definition: shpopen.c:1141
int SHPAPI_CALL DBFAddField(DBFHandle psDBF, const char *pszFieldName, DBFFieldType eType, int nWidth, int nDecimals)
Definition: dbfopen.c:809
void SHPAPI_CALL SBNSearchFreeIds(int *panShapeId)
int * SAFile
Definition: shapefil.h:249
double dfYMin
Definition: shapefil.h:363
double * padfX
Definition: shapefil.h:357
SHPObject ** papsShapeObj
Definition: shapefil.h:462
int * panPartStart
Definition: shapefil.h:353
int SHPAPI_CALL DBFWriteLogicalAttribute(DBFHandle psDBF, int iRecord, int iField, const char lValue)
Definition: dbfopen.c:1543
int nShapeType
Definition: shapefil.h:286
int nBufSize
Definition: shapefil.h:301
void SHPAPI_CALL SHPClose(SHPHandle hSHP)
Definition: shpopen.c:1073
int SHPAPI_CALL DBFGetRecordCount(DBFHandle psDBF)
Definition: dbfopen.c:1238
int SHPAPI_CALL SHPTreeAddShapeId(SHPTree *hTree, SHPObject *psObject)
int nHeaderLength
Definition: shapefil.h:566
#define SHPAPI_CALL1(x)
Definition: shapefil.h:219
int nFields
Definition: shapefil.h:567
int nUpdateMonth
Definition: shapefil.h:595
DBFInfo * DBFHandle
Definition: shapefil.h:599
DBFHandle SHPAPI_CALL DBFCreateEx(const char *pszFilename, const char *pszCodePage)
Definition: dbfopen.c:675
DBFFieldType SHPAPI_CALL DBFGetFieldInfo(DBFHandle psDBF, int iField, char *pszFieldName, int *pnWidth, int *pnDecimals)
Definition: dbfopen.c:1251
int SHPAPI_CALL DBFWriteDoubleAttribute(DBFHandle psDBF, int iRecord, int iField, double dValue)
Definition: dbfopen.c:1486
DBFFieldType
Definition: shapefil.h:601
int SHPAPI_CALL DBFWriteStringAttribute(DBFHandle psDBF, int iRecord, int iField, const char *pszValue)
Definition: dbfopen.c:1516
int SHPAPI_CALL DBFIsAttributeNULL(DBFHandle psDBF, int iRecord, int iField)
Definition: dbfopen.c:1205
DBFHandle SHPAPI_CALL DBFOpen(const char *pszFilename, const char *pszAccess)
Definition: dbfopen.c:395
int SHPAPI_CALL1 * SHPTreeFindLikelyShapes(SHPTree *hTree, double *padfBoundsMin, double *padfBoundsMax, int *);intSHPAPI_CALLSHPCheckBoundsOverlap(double *, double *, double *, double *, int
const char SHPAPI_CALL1 * DBFGetCodePage(DBFHandle psDBF){return NULL;return psDBF->pszCodePage;}int SHPAPI_CALLDBFDeleteField(DBFHandle psDBF, int iField
Definition: dbfopen.c:1810
int * panPartType
Definition: shapefil.h:354
int SHPAPI_CALL SHPRestoreSHX(const char *pszShapeFile, const char *pszAccess, SAHooks *psHooks)
Definition: shpopen.c:874
psSHP sHooks Error(str)
int SHPAPI_CALL1 * SHPSearchDiskTree(FILE *fp, double *padfBoundsMin, double *padfBoundsMax, int *pnShapeCount);typedef struct SHPDiskTreeInfo *SHPTreeDiskHandle;SHPTreeDiskHandle SHPAPI_CALLSHPOpenDiskTree(const char *pszQIXFilename, SAHooks *psHooks
struct SBNSearchInfo * SBNSearchHandle
Definition: shapefil.h:533
int SHPAPI_CALL DBFReorderFields(DBFHandle psDBF, int *panMap)
Definition: dbfopen.c:1940
int SHPAPI_CALL DBFIsRecordDeleted(DBFHandle psDBF, int iShape)
Definition: dbfopen.c:1743
unsigned int * panRecOffset
Definition: shapefil.h:292
int SHPAPI_CALL DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName)
Definition: dbfopen.c:1714
int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId, SHPObject *psObject)
Definition: shpopen.c:1519
SHPTreeNode * psRoot
Definition: shapefil.h:477
double dfXMin
Definition: shapefil.h:362
void SASetupDefaultHooks(SAHooks *psHooks)
Definition: safileio.c:175
SAHooks sHooks
Definition: shapefil.h:281
double dfMMax
Definition: shapefil.h:370
double * padfY
Definition: shapefil.h:358
SHPHandle hSHP
Definition: shapefil.h:471
psObject nShapeId
Definition: shpopen.c:1397
SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszShapeFile, const char *pszAccess, SAHooks *psHooks)
Definition: shpopen.c:507
SAHooks sHooks
Definition: shapefil.h:559
SBNSearchHandle SHPAPI_CALL SBNOpenDiskTree(const char *pszSBNFilename, SAHooks *psHooks)
SAFile fpSHX
Definition: shapefil.h:284
char * pszCurrentRecord
Definition: shapefil.h:577
SHPTree SHPAPI_CALL1 * SHPCreateTree(SHPHandle hSHP, int nDimension, int nMaxDepth, double *padfBoundsMin, double *padfBoundsMax);voidSHPAPI_CALLSHPDestroyTree(SHPTree *hTree
int SHPAPI_CALL DBFAlterFieldDefn(DBFHandle psDBF, int iField, const char *pszFieldName, char chType, int nWidth, int nDecimals)
Definition: dbfopen.c:2049
SAFile fpSHP
Definition: shapefil.h:283
int nDimension
Definition: shapefil.h:474
SHPHandle SHPAPI_CALL SHPCreate(const char *pszShapeFile, int nShapeType)
Definition: shpopen.c:1173
DBFHandle SHPAPI_CALL DBFCreate(const char *pszFilename)
Definition: dbfopen.c:662
SHPObject * psCachedObject
Definition: shapefil.h:306
DBFHandle SHPAPI_CALL DBFOpenLL(const char *pszFilename, const char *pszAccess, SAHooks *psHooks)
Definition: dbfopen.c:412
int nIntField
Definition: shapefil.h:588
int nSHPType
Definition: shapefil.h:348
int bFastModeReadObject
Definition: shapefil.h:373
int * panFieldDecimals
Definition: shapefil.h:570
int SHPAPI_CALL DBFDeleteField(DBFHandle hDBF, int iField)
int SHPAPI_CALL SHPTreeRemoveShapeId(SHPTree *hTree, int nShapeId)
int bNoHeader
Definition: shapefil.h:582
int SHPAPI_CALL DBFWriteTuple(DBFHandle psDBF, int hEntity, void *pRawTuple)
Definition: dbfopen.c:1557
int nRecordLength
Definition: shapefil.h:565
const char SHPAPI_CALL1 * DBFReadTuple(DBFHandle psDBF, int hEntity){return(NULL
SHPObject SHPAPI_CALL1 * SHPCreateSimpleObject(int nSHPType, int nVertices, const double *padfX, const double *padfY, const double *padfZ){return(SHPCreateObject(nSHPType,-1, 0, NULL, NULL, nVertices, padfX, padfY, padfZ, NULL)
unsigned char * pabyRec
Definition: shapefil.h:300
int * panFieldSize
Definition: shapefil.h:569
psObject nSHPType
Definition: shpopen.c:1396
struct shape_tree_node * apsSubNode[MAX_SUBNODE]
Definition: shapefil.h:465
void SHPAPI_CALL SHPSetFastModeReadObject(SHPHandle hSHP, int bFastMode)
Definition: shpopen.c:1120
psObject nVertices
Definition: shpopen.c:1488
SAFile fp
Definition: shapefil.h:561
unsigned int nFileSize
Definition: shapefil.h:288
char * pachFieldType
Definition: shapefil.h:571
SHPObject SHPAPI_CALL1 * SHPReadObject(SHPHandle hSHP, int iShape);int SHPAPI_CALLSHPWriteObject(SHPHandle hSHP, int iShape, SHPObject *psObject
SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszShapeFile, int nShapeType, SAHooks *psHooks)
Definition: shpopen.c:1191
int nObjectBufSize
Definition: shapefil.h:305
SHPHandle SHPAPI_CALL SHPOpenLLEx(const char *pszShapeFile, const char *pszAccess, SAHooks *psHooks, int bRestoreSHX)
Definition: shpopen.c:850
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 nMaxRecords
Definition: shapefil.h:291
#define file
int nRecords
Definition: shapefil.h:563
const char SHPAPI_CALL1 * SHPPartTypeName(int nPartType){switch(nPartType
Definition: shpopen.c:2733
double dfDoubleField
Definition: shapefil.h:587
double dfXMax
Definition: shapefil.h:367
SHPHandle SHPAPI_CALL SHPOpen(const char *pszShapeFile, const char *pszAccess)
Definition: shpopen.c:489
int SHPAPI_CALL1 * SHPSearchDiskTreeEx(SHPTreeDiskHandle hDiskTree, double *padfBoundsMin, double *padfBoundsMax, int *pnShapeCount);int SHPAPI_CALLSHPWriteTreeLL(SHPTree *hTree, const char *pszFilename, SAHooks *psHooks
void SHPAPI_CALL SHPWriteHeader(SHPHandle hSHP)
Definition: shpopen.c:359
double dfMMin
Definition: shapefil.h:365
int SHPAPI_CALL SHPWriteTree(SHPTree *hTree, const char *pszFilename)
int nUpdateDay
Definition: shapefil.h:596
int nTotalCount
Definition: shapefil.h:475
double dfZMax
Definition: shapefil.h:369
int SHPAPI_CALL DBFReadIntegerAttribute(DBFHandle psDBF, int iRecord, int iField)
Definition: dbfopen.c:1090
int * panShapeIds
Definition: shapefil.h:461
void SHPAPI_CALL SHPCloseDiskTree(SHPTreeDiskHandle hDiskTree)
int
Reads the categories file for map name in mapset and stores the categories in the pcats structure...
unsigned int * panRecSize
Definition: shapefil.h:293
unsigned char * pabyObjectBuf
Definition: shapefil.h:304
int nMaxDepth
Definition: shapefil.h:473
int SHPAPI_CALL DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity, int iField, void *pValue)
Definition: dbfopen.c:1418
char * pszHeader
Definition: shapefil.h:573
int bFastModeReadObject
Definition: shapefil.h:303
char * pszWorkField
Definition: shapefil.h:580
void SHPAPI_CALL SHPDestroyObject(SHPObject *psObject)
Definition: shpopen.c:2766
int nRecords
Definition: shapefil.h:290
double * padfZ
Definition: shapefil.h:359
SHPInfo * SHPHandle
Definition: shapefil.h:309
int bCurrentRecordModified
Definition: shapefil.h:576
int bUpdated
Definition: shapefil.h:583
double * padfM
Definition: shapefil.h:360
char * pszCodePage
Definition: shapefil.h:592
int SHPAPI_CALL DBFWriteNULLAttribute(DBFHandle psDBF, int iRecord, int iField)
Definition: dbfopen.c:1530
const char SHPAPI_CALL1 * SHPTypeName(int nSHPType);const char SHPAPI_CALL1(*) SHPPartTypeName(int nPartType
Definition: shpopen.c:2676