/[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 1612 - (hide annotations)
Tue Aug 19 21:29:25 2003 UTC (21 years, 6 months ago) by jan
Original Path: trunk/thuban/libraries/shapelib/shapefil.h
File MIME type: text/plain
File size: 13709 byte(s)
These files have been moved here from thuban/extensions/shapelib/
See there in the Attic for the older history.

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     * Author: Frank Warmerdam, [email protected]
10     *
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     * Revision 1.1 2003/08/19 21:29:25 jan
41     * These files have been moved here from thuban/extensions/shapelib/
42     * See there in the Attic for the older history.
43     *
44     * Revision 1.4 2002/08/22 16:00:01 bh
45     * * extensions/shapelib/shapefil.h (DBFCommit),
46     * extensions/shapelib/dbfopen.c (DBFCommit): New API function to
47     * commit any changes made to the DBF file.
48     *
49     * Revision 1.3 2002/05/07 14:09:45 bh
50     * * extensions/shapelib/shpopen.c, extensions/shapelib/shapefil.h,
51     * extensions/shapelib/dbfopen.c: Really update to the versions of
52     * shapelib 1.2.9. For some reason it wasn't really done on
53     * 2002-04-11.
54     *
55     * Revision 1.20 2001/07/20 13:06:02 warmerda
56     * fixed SHPAPI attribute for SHPTreeFindLikelyShapes
57     *
58     * Revision 1.19 2001/05/31 19:20:13 warmerda
59     * added DBFGetFieldIndex()
60     *
61     * Revision 1.18 2001/05/31 18:15:40 warmerda
62     * Added support for NULL fields in DBF files
63     *
64     * Revision 1.17 2001/05/23 13:36:52 warmerda
65     * added use of SHPAPI_CALL
66     *
67     * Revision 1.16 2000/09/25 14:15:59 warmerda
68     * added DBFGetNativeFieldType()
69     *
70     * Revision 1.15 2000/02/16 16:03:51 warmerda
71     * added null shape support
72     *
73     * Revision 1.14 1999/11/05 14:12:05 warmerda
74     * updated license terms
75     *
76     * Revision 1.13 1999/06/02 18:24:21 warmerda
77     * added trimming code
78     *
79     * Revision 1.12 1999/06/02 17:56:12 warmerda
80     * added quad'' subnode support for trees
81     *
82     * Revision 1.11 1999/05/18 19:11:11 warmerda
83     * Added example searching capability
84     *
85     * Revision 1.10 1999/05/18 17:49:38 warmerda
86     * added initial quadtree support
87     *
88     * Revision 1.9 1999/05/11 03:19:28 warmerda
89     * added new Tuple api, and improved extension handling - add from candrsn
90     *
91     * Revision 1.8 1999/03/23 17:22:27 warmerda
92     * Added extern "C" protection for C++ users of shapefil.h.
93     *
94     * Revision 1.7 1998/12/31 15:31:07 warmerda
95     * Added the TRIM_DBF_WHITESPACE and DISABLE_MULTIPATCH_MEASURE options.
96     *
97     * Revision 1.6 1998/12/03 15:48:15 warmerda
98     * Added SHPCalculateExtents().
99     *
100     * Revision 1.5 1998/11/09 20:57:16 warmerda
101     * Altered SHPGetInfo() call.
102     *
103     * Revision 1.4 1998/11/09 20:19:33 warmerda
104     * Added 3D support, and use of SHPObject.
105     *
106     * Revision 1.3 1995/08/23 02:24:05 warmerda
107     * Added support for reading bounds.
108     *
109     * Revision 1.2 1995/08/04 03:17:39 warmerda
110     * Added header.
111     *
112     */
113    
114     #include <stdio.h>
115    
116     #ifdef USE_DBMALLOC
117     #include <dbmalloc.h>
118     #endif
119    
120     #ifdef __cplusplus
121     extern "C" {
122     #endif
123    
124     #ifndef SHPAPI_CALL
125     #define SHPAPI_CALL
126     #endif
127    
128     #define SHPAPI_CALL1(x) * SHPAPI_CALL
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     /************************************************************************/
148     /* SHP Support. */
149     /************************************************************************/
150     typedef struct
151     {
152     FILE *fpSHP;
153     FILE *fpSHX;
154    
155     int nShapeType; /* SHPT_* */
156    
157     int nFileSize; /* SHP file */
158    
159     int nRecords;
160     int nMaxRecords;
161     int *panRecOffset;
162     int *panRecSize;
163    
164     double adBoundsMin[4];
165     double adBoundsMax[4];
166    
167     int bUpdated;
168     } SHPInfo;
169    
170     typedef SHPInfo * SHPHandle;
171    
172     /* -------------------------------------------------------------------- */
173     /* Shape types (nSHPType) */
174     /* -------------------------------------------------------------------- */
175     #define SHPT_NULL 0
176     #define SHPT_POINT 1
177     #define SHPT_ARC 3
178     #define SHPT_POLYGON 5
179     #define SHPT_MULTIPOINT 8
180     #define SHPT_POINTZ 11
181     #define SHPT_ARCZ 13
182     #define SHPT_POLYGONZ 15
183     #define SHPT_MULTIPOINTZ 18
184     #define SHPT_POINTM 21
185     #define SHPT_ARCM 23
186     #define SHPT_POLYGONM 25
187     #define SHPT_MULTIPOINTM 28
188     #define SHPT_MULTIPATCH 31
189    
190    
191     /* -------------------------------------------------------------------- */
192     /* Part types - everything but SHPT_MULTIPATCH just uses */
193     /* SHPP_RING. */
194     /* -------------------------------------------------------------------- */
195    
196     #define SHPP_TRISTRIP 0
197     #define SHPP_TRIFAN 1
198     #define SHPP_OUTERRING 2
199     #define SHPP_INNERRING 3
200     #define SHPP_FIRSTRING 4
201     #define SHPP_RING 5
202    
203     /* -------------------------------------------------------------------- */
204     /* SHPObject - represents on shape (without attributes) read */
205     /* from the .shp file. */
206     /* -------------------------------------------------------------------- */
207     typedef struct
208     {
209     int nSHPType;
210    
211     int nShapeId; /* -1 is unknown/unassigned */
212    
213     int nParts;
214     int *panPartStart;
215     int *panPartType;
216    
217     int nVertices;
218     double *padfX;
219     double *padfY;
220     double *padfZ;
221     double *padfM;
222    
223     double dfXMin;
224     double dfYMin;
225     double dfZMin;
226     double dfMMin;
227    
228     double dfXMax;
229     double dfYMax;
230     double dfZMax;
231     double dfMMax;
232     } SHPObject;
233    
234     /* -------------------------------------------------------------------- */
235     /* SHP API Prototypes */
236     /* -------------------------------------------------------------------- */
237     SHPHandle SHPAPI_CALL
238     SHPOpen( const char * pszShapeFile, const char * pszAccess );
239     SHPHandle SHPAPI_CALL
240     SHPCreate( const char * pszShapeFile, int nShapeType );
241     void SHPAPI_CALL
242     SHPGetInfo( SHPHandle hSHP, int * pnEntities, int * pnShapeType,
243     double * padfMinBound, double * padfMaxBound );
244    
245     SHPObject SHPAPI_CALL1(*)
246     SHPReadObject( SHPHandle hSHP, int iShape );
247     int SHPAPI_CALL
248     SHPWriteObject( SHPHandle hSHP, int iShape, SHPObject * psObject );
249    
250     void SHPAPI_CALL
251     SHPDestroyObject( SHPObject * psObject );
252     void SHPAPI_CALL
253     SHPComputeExtents( SHPObject * psObject );
254     SHPObject SHPAPI_CALL1(*)
255     SHPCreateObject( int nSHPType, int nShapeId,
256     int nParts, int * panPartStart, int * panPartType,
257     int nVertices, double * padfX, double * padfY,
258     double * padfZ, double * padfM );
259     SHPObject SHPAPI_CALL1(*)
260     SHPCreateSimpleObject( int nSHPType, int nVertices,
261     double * padfX, double * padfY, double * padfZ );
262    
263     void SHPAPI_CALL
264     SHPClose( SHPHandle hSHP );
265    
266     const char SHPAPI_CALL1(*)
267     SHPTypeName( int nSHPType );
268     const char SHPAPI_CALL1(*)
269     SHPPartTypeName( int nPartType );
270    
271     /* -------------------------------------------------------------------- */
272     /* Shape quadtree indexing API. */
273     /* -------------------------------------------------------------------- */
274    
275     /* this can be two or four for binary or quad tree */
276     #define MAX_SUBNODE 4
277    
278     typedef struct shape_tree_node
279     {
280     /* region covered by this node */
281     double adfBoundsMin[4];
282     double adfBoundsMax[4];
283    
284     /* list of shapes stored at this node. The papsShapeObj pointers
285     or the whole list can be NULL */
286     int nShapeCount;
287     int *panShapeIds;
288     SHPObject **papsShapeObj;
289    
290     int nSubNodes;
291     struct shape_tree_node *apsSubNode[MAX_SUBNODE];
292    
293     } SHPTreeNode;
294    
295     typedef struct
296     {
297     SHPHandle hSHP;
298    
299     int nMaxDepth;
300     int nDimension;
301    
302     SHPTreeNode *psRoot;
303     } SHPTree;
304    
305     SHPTree SHPAPI_CALL1(*)
306     SHPCreateTree( SHPHandle hSHP, int nDimension, int nMaxDepth,
307     double *padfBoundsMin, double *padfBoundsMax );
308     void SHPAPI_CALL
309     SHPDestroyTree( SHPTree * hTree );
310    
311     int SHPAPI_CALL
312     SHPWriteTree( SHPTree *hTree, const char * pszFilename );
313     SHPTree SHPAPI_CALL
314     SHPReadTree( const char * pszFilename );
315    
316     int SHPAPI_CALL
317     SHPTreeAddObject( SHPTree * hTree, SHPObject * psObject );
318     int SHPAPI_CALL
319     SHPTreeAddShapeId( SHPTree * hTree, SHPObject * psObject );
320     int SHPAPI_CALL
321     SHPTreeRemoveShapeId( SHPTree * hTree, int nShapeId );
322    
323     void SHPAPI_CALL
324     SHPTreeTrimExtraNodes( SHPTree * hTree );
325    
326     int SHPAPI_CALL1(*)
327     SHPTreeFindLikelyShapes( SHPTree * hTree,
328     double * padfBoundsMin,
329     double * padfBoundsMax,
330     int * );
331     int SHPAPI_CALL
332     SHPCheckBoundsOverlap( double *, double *, double *, double *, int );
333    
334     /************************************************************************/
335     /* DBF Support. */
336     /************************************************************************/
337     typedef struct
338     {
339     FILE *fp;
340    
341     int nRecords;
342    
343     int nRecordLength;
344     int nHeaderLength;
345     int nFields;
346     int *panFieldOffset;
347     int *panFieldSize;
348     int *panFieldDecimals;
349     char *pachFieldType;
350    
351     char *pszHeader;
352    
353     int nCurrentRecord;
354     int bCurrentRecordModified;
355     char *pszCurrentRecord;
356    
357     int bNoHeader;
358     int bUpdated;
359     } DBFInfo;
360    
361     typedef DBFInfo * DBFHandle;
362    
363     typedef enum {
364     FTString,
365     FTInteger,
366     FTDouble,
367     FTInvalid
368     } DBFFieldType;
369    
370     #define XBASE_FLDHDR_SZ 32
371    
372     DBFHandle SHPAPI_CALL
373     DBFOpen( const char * pszDBFFile, const char * pszAccess );
374     DBFHandle SHPAPI_CALL
375     DBFCreate( const char * pszDBFFile );
376    
377     int SHPAPI_CALL
378     DBFGetFieldCount( DBFHandle psDBF );
379     int SHPAPI_CALL
380     DBFGetRecordCount( DBFHandle psDBF );
381     int SHPAPI_CALL
382     DBFAddField( DBFHandle hDBF, const char * pszFieldName,
383     DBFFieldType eType, int nWidth, int nDecimals );
384    
385     DBFFieldType SHPAPI_CALL
386     DBFGetFieldInfo( DBFHandle psDBF, int iField,
387     char * pszFieldName, int * pnWidth, int * pnDecimals );
388    
389     int SHPAPI_CALL
390     DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName);
391    
392     int SHPAPI_CALL
393     DBFReadIntegerAttribute( DBFHandle hDBF, int iShape, int iField );
394     double SHPAPI_CALL
395     DBFReadDoubleAttribute( DBFHandle hDBF, int iShape, int iField );
396     const char SHPAPI_CALL1(*)
397     DBFReadStringAttribute( DBFHandle hDBF, int iShape, int iField );
398     int SHPAPI_CALL
399     DBFIsAttributeNULL( DBFHandle hDBF, int iShape, int iField );
400    
401     int SHPAPI_CALL
402     DBFWriteIntegerAttribute( DBFHandle hDBF, int iShape, int iField,
403     int nFieldValue );
404     int SHPAPI_CALL
405     DBFWriteDoubleAttribute( DBFHandle hDBF, int iShape, int iField,
406     double dFieldValue );
407     int SHPAPI_CALL
408     DBFWriteStringAttribute( DBFHandle hDBF, int iShape, int iField,
409     const char * pszFieldValue );
410     int SHPAPI_CALL
411     DBFWriteNULLAttribute( DBFHandle hDBF, int iShape, int iField );
412    
413     const char SHPAPI_CALL1(*)
414     DBFReadTuple(DBFHandle psDBF, int hEntity );
415     int SHPAPI_CALL
416     DBFWriteTuple(DBFHandle psDBF, int hEntity, void * pRawTuple );
417    
418     DBFHandle SHPAPI_CALL
419     DBFCloneEmpty(DBFHandle psDBF, const char * pszFilename );
420    
421     void SHPAPI_CALL
422     DBFClose( DBFHandle hDBF );
423     char SHPAPI_CALL
424     DBFGetNativeFieldType( DBFHandle hDBF, int iField );
425    
426     int SHPAPI_CALL
427     DBFCommit( DBFHandle hDBF );
428    
429     #ifdef __cplusplus
430     }
431     #endif
432    
433     #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