/[thuban]/branches/WIP-pyshapelib-bramz/libraries/shapelib/shapefil.h
ViewVC logotype

Annotation of /branches/WIP-pyshapelib-bramz/libraries/shapelib/shapefil.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1769 - (hide annotations)
Thu Oct 2 15:15:16 2003 UTC (21 years, 5 months ago) by bh
Original Path: trunk/thuban/libraries/shapelib/shapefil.h
File MIME type: text/plain
File size: 16467 byte(s)
Update to shapelib 1.2.10

1 jan 1612 #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 bh 1769 * Author: Frank Warmerdam, [email protected]
10 jan 1612 *
11     ******************************************************************************
12     * Copyright (c) 1999, Frank Warmerdam
13     *
14     * This software is available under the following "MIT Style" license,
15     * or at the option of the licensee under the LGPL (see LICENSE.LGPL). This
16     * option is discussed in more detail in shapelib.html.
17     *
18     * --
19     *
20     * Permission is hereby granted, free of charge, to any person obtaining a
21     * copy of this software and associated documentation files (the "Software"),
22     * to deal in the Software without restriction, including without limitation
23     * the rights to use, copy, modify, merge, publish, distribute, sublicense,
24     * and/or sell copies of the Software, and to permit persons to whom the
25     * Software is furnished to do so, subject to the following conditions:
26     *
27     * The above copyright notice and this permission notice shall be included
28     * in all copies or substantial portions of the Software.
29     *
30     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
31     * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32     * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
33     * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34     * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
35     * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
36     * DEALINGS IN THE SOFTWARE.
37     ******************************************************************************
38     *
39     * $Log$
40 bh 1769 * Revision 1.2 2003/10/02 15:15:16 bh
41     * Update to shapelib 1.2.10
42 jan 1612 *
43 bh 1769 * Revision 1.26 2002/09/29 00:00:08 warmerda
44     * added FTLogical and logical attribute read/write calls
45 jan 1612 *
46 bh 1769 * Revision 1.25 2002/05/07 13:46:30 warmerda
47     * added DBFWriteAttributeDirectly().
48 jan 1612 *
49 bh 1769 * Revision 1.24 2002/04/10 16:59:54 warmerda
50     * added SHPRewindObject
51     *
52     * Revision 1.23 2002/01/15 14:36:07 warmerda
53     * updated email address
54     *
55     * Revision 1.22 2002/01/15 14:32:00 warmerda
56     * try to improve SHPAPI_CALL docs
57     *
58     * Revision 1.21 2001/11/01 16:29:55 warmerda
59     * move pabyRec into SHPInfo for thread safety
60     *
61 jan 1612 * Revision 1.20 2001/07/20 13:06:02 warmerda
62     * fixed SHPAPI attribute for SHPTreeFindLikelyShapes
63     *
64     * Revision 1.19 2001/05/31 19:20:13 warmerda
65     * added DBFGetFieldIndex()
66     *
67     * Revision 1.18 2001/05/31 18:15:40 warmerda
68     * Added support for NULL fields in DBF files
69     *
70     * Revision 1.17 2001/05/23 13:36:52 warmerda
71     * added use of SHPAPI_CALL
72     *
73     * Revision 1.16 2000/09/25 14:15:59 warmerda
74     * added DBFGetNativeFieldType()
75     *
76     * Revision 1.15 2000/02/16 16:03:51 warmerda
77     * added null shape support
78     *
79     * Revision 1.14 1999/11/05 14:12:05 warmerda
80     * updated license terms
81     *
82     * Revision 1.13 1999/06/02 18:24:21 warmerda
83     * added trimming code
84     *
85     * Revision 1.12 1999/06/02 17:56:12 warmerda
86     * added quad'' subnode support for trees
87     *
88     * Revision 1.11 1999/05/18 19:11:11 warmerda
89     * Added example searching capability
90     *
91     * Revision 1.10 1999/05/18 17:49:38 warmerda
92     * added initial quadtree support
93     *
94     * Revision 1.9 1999/05/11 03:19:28 warmerda
95     * added new Tuple api, and improved extension handling - add from candrsn
96     *
97     * Revision 1.8 1999/03/23 17:22:27 warmerda
98     * Added extern "C" protection for C++ users of shapefil.h.
99     *
100     * Revision 1.7 1998/12/31 15:31:07 warmerda
101     * Added the TRIM_DBF_WHITESPACE and DISABLE_MULTIPATCH_MEASURE options.
102     *
103     * Revision 1.6 1998/12/03 15:48:15 warmerda
104     * Added SHPCalculateExtents().
105     *
106     * Revision 1.5 1998/11/09 20:57:16 warmerda
107     * Altered SHPGetInfo() call.
108     *
109     * Revision 1.4 1998/11/09 20:19:33 warmerda
110     * Added 3D support, and use of SHPObject.
111     *
112     * Revision 1.3 1995/08/23 02:24:05 warmerda
113     * Added support for reading bounds.
114     *
115     * Revision 1.2 1995/08/04 03:17:39 warmerda
116     * Added header.
117     *
118     */
119    
120     #include <stdio.h>
121    
122     #ifdef USE_DBMALLOC
123     #include <dbmalloc.h>
124     #endif
125    
126     #ifdef __cplusplus
127     extern "C" {
128     #endif
129    
130     /************************************************************************/
131     /* Configuration options. */
132     /************************************************************************/
133    
134     /* -------------------------------------------------------------------- */
135     /* Should the DBFReadStringAttribute() strip leading and */
136     /* trailing white space? */
137     /* -------------------------------------------------------------------- */
138     #define TRIM_DBF_WHITESPACE
139    
140     /* -------------------------------------------------------------------- */
141     /* Should we write measure values to the Multipatch object? */
142     /* Reportedly ArcView crashes if we do write it, so for now it */
143     /* is disabled. */
144     /* -------------------------------------------------------------------- */
145     #define DISABLE_MULTIPATCH_MEASURE
146    
147 bh 1769 /* -------------------------------------------------------------------- */
148     /* SHPAPI_CALL */
149     /* */
150     /* The following two macros are present to allow forcing */
151     /* various calling conventions on the Shapelib API. */
152     /* */
153     /* To force __stdcall conventions (needed to call Shapelib */
154     /* from Visual Basic and/or Dephi I believe) the makefile could */
155     /* be modified to define: */
156     /* */
157     /* /DSHPAPI_CALL=__stdcall */
158     /* */
159     /* If it is desired to force export of the Shapelib API without */
160     /* using the shapelib.def file, use the following definition. */
161     /* */
162     /* /DSHAPELIB_DLLEXPORT */
163     /* */
164     /* To get both at once it will be necessary to hack this */
165     /* include file to define: */
166     /* */
167     /* #define SHPAPI_CALL __declspec(dllexport) __stdcall */
168     /* #define SHPAPI_CALL1 __declspec(dllexport) * __stdcall */
169     /* */
170     /* The complexity of the situtation is partly caused by the */
171     /* peculiar requirement of Visual C++ that __stdcall appear */
172     /* after any "*"'s in the return value of a function while the */
173     /* __declspec(dllexport) must appear before them. */
174     /* -------------------------------------------------------------------- */
175    
176     #ifdef SHAPELIB_DLLEXPORT
177     # define SHPAPI_CALL __declspec(dllexport)
178     # define SHPAPI_CALL1(x) __declspec(dllexport) x
179     #endif
180    
181     #ifndef SHPAPI_CALL
182     # define SHPAPI_CALL
183     #endif
184    
185     #ifndef SHPAPI_CALL1
186     # define SHPAPI_CALL1(x) x SHPAPI_CALL
187     #endif
188    
189 jan 1612 /************************************************************************/
190     /* SHP Support. */
191     /************************************************************************/
192     typedef struct
193     {
194     FILE *fpSHP;
195     FILE *fpSHX;
196    
197     int nShapeType; /* SHPT_* */
198    
199     int nFileSize; /* SHP file */
200    
201     int nRecords;
202     int nMaxRecords;
203     int *panRecOffset;
204     int *panRecSize;
205    
206     double adBoundsMin[4];
207     double adBoundsMax[4];
208    
209     int bUpdated;
210 bh 1769
211     unsigned char *pabyRec;
212     int nBufSize;
213 jan 1612 } SHPInfo;
214    
215     typedef SHPInfo * SHPHandle;
216    
217     /* -------------------------------------------------------------------- */
218     /* Shape types (nSHPType) */
219     /* -------------------------------------------------------------------- */
220     #define SHPT_NULL 0
221     #define SHPT_POINT 1
222     #define SHPT_ARC 3
223     #define SHPT_POLYGON 5
224     #define SHPT_MULTIPOINT 8
225     #define SHPT_POINTZ 11
226     #define SHPT_ARCZ 13
227     #define SHPT_POLYGONZ 15
228     #define SHPT_MULTIPOINTZ 18
229     #define SHPT_POINTM 21
230     #define SHPT_ARCM 23
231     #define SHPT_POLYGONM 25
232     #define SHPT_MULTIPOINTM 28
233     #define SHPT_MULTIPATCH 31
234    
235    
236     /* -------------------------------------------------------------------- */
237     /* Part types - everything but SHPT_MULTIPATCH just uses */
238     /* SHPP_RING. */
239     /* -------------------------------------------------------------------- */
240    
241     #define SHPP_TRISTRIP 0
242     #define SHPP_TRIFAN 1
243     #define SHPP_OUTERRING 2
244     #define SHPP_INNERRING 3
245     #define SHPP_FIRSTRING 4
246     #define SHPP_RING 5
247    
248     /* -------------------------------------------------------------------- */
249     /* SHPObject - represents on shape (without attributes) read */
250     /* from the .shp file. */
251     /* -------------------------------------------------------------------- */
252     typedef struct
253     {
254     int nSHPType;
255    
256     int nShapeId; /* -1 is unknown/unassigned */
257    
258     int nParts;
259     int *panPartStart;
260     int *panPartType;
261    
262     int nVertices;
263     double *padfX;
264     double *padfY;
265     double *padfZ;
266     double *padfM;
267    
268     double dfXMin;
269     double dfYMin;
270     double dfZMin;
271     double dfMMin;
272    
273     double dfXMax;
274     double dfYMax;
275     double dfZMax;
276     double dfMMax;
277     } SHPObject;
278    
279     /* -------------------------------------------------------------------- */
280     /* SHP API Prototypes */
281     /* -------------------------------------------------------------------- */
282     SHPHandle SHPAPI_CALL
283     SHPOpen( const char * pszShapeFile, const char * pszAccess );
284     SHPHandle SHPAPI_CALL
285     SHPCreate( const char * pszShapeFile, int nShapeType );
286     void SHPAPI_CALL
287     SHPGetInfo( SHPHandle hSHP, int * pnEntities, int * pnShapeType,
288     double * padfMinBound, double * padfMaxBound );
289    
290     SHPObject SHPAPI_CALL1(*)
291     SHPReadObject( SHPHandle hSHP, int iShape );
292     int SHPAPI_CALL
293     SHPWriteObject( SHPHandle hSHP, int iShape, SHPObject * psObject );
294    
295     void SHPAPI_CALL
296     SHPDestroyObject( SHPObject * psObject );
297     void SHPAPI_CALL
298     SHPComputeExtents( SHPObject * psObject );
299     SHPObject SHPAPI_CALL1(*)
300     SHPCreateObject( int nSHPType, int nShapeId,
301     int nParts, int * panPartStart, int * panPartType,
302     int nVertices, double * padfX, double * padfY,
303     double * padfZ, double * padfM );
304     SHPObject SHPAPI_CALL1(*)
305     SHPCreateSimpleObject( int nSHPType, int nVertices,
306     double * padfX, double * padfY, double * padfZ );
307    
308 bh 1769 int SHPAPI_CALL
309     SHPRewindObject( SHPHandle hSHP, SHPObject * psObject );
310    
311 jan 1612 void SHPAPI_CALL
312     SHPClose( SHPHandle hSHP );
313    
314     const char SHPAPI_CALL1(*)
315     SHPTypeName( int nSHPType );
316     const char SHPAPI_CALL1(*)
317     SHPPartTypeName( int nPartType );
318    
319     /* -------------------------------------------------------------------- */
320     /* Shape quadtree indexing API. */
321     /* -------------------------------------------------------------------- */
322    
323     /* this can be two or four for binary or quad tree */
324     #define MAX_SUBNODE 4
325    
326     typedef struct shape_tree_node
327     {
328     /* region covered by this node */
329     double adfBoundsMin[4];
330     double adfBoundsMax[4];
331    
332     /* list of shapes stored at this node. The papsShapeObj pointers
333     or the whole list can be NULL */
334     int nShapeCount;
335     int *panShapeIds;
336     SHPObject **papsShapeObj;
337    
338     int nSubNodes;
339     struct shape_tree_node *apsSubNode[MAX_SUBNODE];
340    
341     } SHPTreeNode;
342    
343     typedef struct
344     {
345     SHPHandle hSHP;
346    
347     int nMaxDepth;
348     int nDimension;
349    
350     SHPTreeNode *psRoot;
351     } SHPTree;
352    
353     SHPTree SHPAPI_CALL1(*)
354     SHPCreateTree( SHPHandle hSHP, int nDimension, int nMaxDepth,
355     double *padfBoundsMin, double *padfBoundsMax );
356     void SHPAPI_CALL
357     SHPDestroyTree( SHPTree * hTree );
358    
359     int SHPAPI_CALL
360     SHPWriteTree( SHPTree *hTree, const char * pszFilename );
361     SHPTree SHPAPI_CALL
362     SHPReadTree( const char * pszFilename );
363    
364     int SHPAPI_CALL
365     SHPTreeAddObject( SHPTree * hTree, SHPObject * psObject );
366     int SHPAPI_CALL
367     SHPTreeAddShapeId( SHPTree * hTree, SHPObject * psObject );
368     int SHPAPI_CALL
369     SHPTreeRemoveShapeId( SHPTree * hTree, int nShapeId );
370    
371     void SHPAPI_CALL
372     SHPTreeTrimExtraNodes( SHPTree * hTree );
373    
374     int SHPAPI_CALL1(*)
375     SHPTreeFindLikelyShapes( SHPTree * hTree,
376     double * padfBoundsMin,
377     double * padfBoundsMax,
378     int * );
379     int SHPAPI_CALL
380     SHPCheckBoundsOverlap( double *, double *, double *, double *, int );
381    
382     /************************************************************************/
383     /* DBF Support. */
384     /************************************************************************/
385     typedef struct
386     {
387     FILE *fp;
388    
389     int nRecords;
390    
391     int nRecordLength;
392     int nHeaderLength;
393     int nFields;
394     int *panFieldOffset;
395     int *panFieldSize;
396     int *panFieldDecimals;
397     char *pachFieldType;
398    
399     char *pszHeader;
400    
401     int nCurrentRecord;
402     int bCurrentRecordModified;
403     char *pszCurrentRecord;
404    
405     int bNoHeader;
406     int bUpdated;
407     } DBFInfo;
408    
409     typedef DBFInfo * DBFHandle;
410    
411     typedef enum {
412     FTString,
413     FTInteger,
414     FTDouble,
415 bh 1769 FTLogical,
416 jan 1612 FTInvalid
417     } DBFFieldType;
418    
419     #define XBASE_FLDHDR_SZ 32
420    
421     DBFHandle SHPAPI_CALL
422     DBFOpen( const char * pszDBFFile, const char * pszAccess );
423     DBFHandle SHPAPI_CALL
424     DBFCreate( const char * pszDBFFile );
425    
426     int SHPAPI_CALL
427     DBFGetFieldCount( DBFHandle psDBF );
428     int SHPAPI_CALL
429     DBFGetRecordCount( DBFHandle psDBF );
430     int SHPAPI_CALL
431     DBFAddField( DBFHandle hDBF, const char * pszFieldName,
432     DBFFieldType eType, int nWidth, int nDecimals );
433    
434     DBFFieldType SHPAPI_CALL
435     DBFGetFieldInfo( DBFHandle psDBF, int iField,
436     char * pszFieldName, int * pnWidth, int * pnDecimals );
437    
438     int SHPAPI_CALL
439     DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName);
440    
441     int SHPAPI_CALL
442     DBFReadIntegerAttribute( DBFHandle hDBF, int iShape, int iField );
443     double SHPAPI_CALL
444     DBFReadDoubleAttribute( DBFHandle hDBF, int iShape, int iField );
445     const char SHPAPI_CALL1(*)
446     DBFReadStringAttribute( DBFHandle hDBF, int iShape, int iField );
447 bh 1769 const char SHPAPI_CALL1(*)
448     DBFReadLogicalAttribute( DBFHandle hDBF, int iShape, int iField );
449 jan 1612 int SHPAPI_CALL
450     DBFIsAttributeNULL( DBFHandle hDBF, int iShape, int iField );
451    
452     int SHPAPI_CALL
453     DBFWriteIntegerAttribute( DBFHandle hDBF, int iShape, int iField,
454     int nFieldValue );
455     int SHPAPI_CALL
456     DBFWriteDoubleAttribute( DBFHandle hDBF, int iShape, int iField,
457     double dFieldValue );
458     int SHPAPI_CALL
459     DBFWriteStringAttribute( DBFHandle hDBF, int iShape, int iField,
460     const char * pszFieldValue );
461     int SHPAPI_CALL
462     DBFWriteNULLAttribute( DBFHandle hDBF, int iShape, int iField );
463    
464 bh 1769 int SHPAPI_CALL
465     DBFWriteLogicalAttribute( DBFHandle hDBF, int iShape, int iField,
466     const char lFieldValue);
467     int SHPAPI_CALL
468     DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity, int iField,
469     void * pValue );
470 jan 1612 const char SHPAPI_CALL1(*)
471     DBFReadTuple(DBFHandle psDBF, int hEntity );
472     int SHPAPI_CALL
473     DBFWriteTuple(DBFHandle psDBF, int hEntity, void * pRawTuple );
474    
475     DBFHandle SHPAPI_CALL
476     DBFCloneEmpty(DBFHandle psDBF, const char * pszFilename );
477    
478     void SHPAPI_CALL
479     DBFClose( DBFHandle hDBF );
480     char SHPAPI_CALL
481     DBFGetNativeFieldType( DBFHandle hDBF, int iField );
482    
483     int SHPAPI_CALL
484     DBFCommit( DBFHandle hDBF );
485    
486     #ifdef __cplusplus
487     }
488     #endif
489    
490     #endif /* ndef _SHAPEFILE_H_INCLUDED */

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26