/[thuban]/trunk/thuban/extensions/shapelib/shapefil.h
ViewVC logotype

Annotation of /trunk/thuban/extensions/shapelib/shapefil.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6 - (hide annotations)
Tue Aug 28 15:41:52 2001 UTC (23 years, 6 months ago) by bh
File MIME type: text/plain
File size: 11471 byte(s)
import all the source files

1 bh 6 #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 2001/08/28 15:41:52 bh
41     * import all the source files
42     *
43     * Revision 1.15 2000/02/16 16:03:51 warmerda
44     * added null shape support
45     *
46     * Revision 1.14 1999/11/05 14:12:05 warmerda
47     * updated license terms
48     *
49     * Revision 1.13 1999/06/02 18:24:21 warmerda
50     * added trimming code
51     *
52     * Revision 1.12 1999/06/02 17:56:12 warmerda
53     * added quad'' subnode support for trees
54     *
55     * Revision 1.11 1999/05/18 19:11:11 warmerda
56     * Added example searching capability
57     *
58     * Revision 1.10 1999/05/18 17:49:38 warmerda
59     * added initial quadtree support
60     *
61     * Revision 1.9 1999/05/11 03:19:28 warmerda
62     * added new Tuple api, and improved extension handling - add from candrsn
63     *
64     * Revision 1.8 1999/03/23 17:22:27 warmerda
65     * Added extern "C" protection for C++ users of shapefil.h.
66     *
67     * Revision 1.7 1998/12/31 15:31:07 warmerda
68     * Added the TRIM_DBF_WHITESPACE and DISABLE_MULTIPATCH_MEASURE options.
69     *
70     * Revision 1.6 1998/12/03 15:48:15 warmerda
71     * Added SHPCalculateExtents().
72     *
73     * Revision 1.5 1998/11/09 20:57:16 warmerda
74     * Altered SHPGetInfo() call.
75     *
76     * Revision 1.4 1998/11/09 20:19:33 warmerda
77     * Added 3D support, and use of SHPObject.
78     *
79     * Revision 1.3 1995/08/23 02:24:05 warmerda
80     * Added support for reading bounds.
81     *
82     * Revision 1.2 1995/08/04 03:17:39 warmerda
83     * Added header.
84     *
85     */
86    
87     #include <stdio.h>
88    
89     #ifdef USE_DBMALLOC
90     #include <dbmalloc.h>
91     #endif
92    
93     #ifdef __cplusplus
94     extern "C" {
95     #endif
96    
97     /************************************************************************/
98     /* Configuration options. */
99     /************************************************************************/
100    
101     /* -------------------------------------------------------------------- */
102     /* Should the DBFReadStringAttribute() strip leading and */
103     /* trailing white space? */
104     /* -------------------------------------------------------------------- */
105     #define TRIM_DBF_WHITESPACE
106    
107     /* -------------------------------------------------------------------- */
108     /* Should we write measure values to the Multipatch object? */
109     /* Reportedly ArcView crashes if we do write it, so for now it */
110     /* is disabled. */
111     /* -------------------------------------------------------------------- */
112     #define DISABLE_MULTIPATCH_MEASURE
113    
114     /************************************************************************/
115     /* SHP Support. */
116     /************************************************************************/
117     typedef struct
118     {
119     FILE *fpSHP;
120     FILE *fpSHX;
121    
122     int nShapeType; /* SHPT_* */
123    
124     int nFileSize; /* SHP file */
125    
126     int nRecords;
127     int nMaxRecords;
128     int *panRecOffset;
129     int *panRecSize;
130    
131     double adBoundsMin[4];
132     double adBoundsMax[4];
133    
134     int bUpdated;
135     } SHPInfo;
136    
137     typedef SHPInfo * SHPHandle;
138    
139     /* -------------------------------------------------------------------- */
140     /* Shape types (nSHPType) */
141     /* -------------------------------------------------------------------- */
142     #define SHPT_NULL 0
143     #define SHPT_POINT 1
144     #define SHPT_ARC 3
145     #define SHPT_POLYGON 5
146     #define SHPT_MULTIPOINT 8
147     #define SHPT_POINTZ 11
148     #define SHPT_ARCZ 13
149     #define SHPT_POLYGONZ 15
150     #define SHPT_MULTIPOINTZ 18
151     #define SHPT_POINTM 21
152     #define SHPT_ARCM 23
153     #define SHPT_POLYGONM 25
154     #define SHPT_MULTIPOINTM 28
155     #define SHPT_MULTIPATCH 31
156    
157    
158     /* -------------------------------------------------------------------- */
159     /* Part types - everything but SHPT_MULTIPATCH just uses */
160     /* SHPP_RING. */
161     /* -------------------------------------------------------------------- */
162    
163     #define SHPP_TRISTRIP 0
164     #define SHPP_TRIFAN 1
165     #define SHPP_OUTERRING 2
166     #define SHPP_INNERRING 3
167     #define SHPP_FIRSTRING 4
168     #define SHPP_RING 5
169    
170     /* -------------------------------------------------------------------- */
171     /* SHPObject - represents on shape (without attributes) read */
172     /* from the .shp file. */
173     /* -------------------------------------------------------------------- */
174     typedef struct
175     {
176     int nSHPType;
177    
178     int nShapeId; /* -1 is unknown/unassigned */
179    
180     int nParts;
181     int *panPartStart;
182     int *panPartType;
183    
184     int nVertices;
185     double *padfX;
186     double *padfY;
187     double *padfZ;
188     double *padfM;
189    
190     double dfXMin;
191     double dfYMin;
192     double dfZMin;
193     double dfMMin;
194    
195     double dfXMax;
196     double dfYMax;
197     double dfZMax;
198     double dfMMax;
199     } SHPObject;
200    
201     /* -------------------------------------------------------------------- */
202     /* SHP API Prototypes */
203     /* -------------------------------------------------------------------- */
204     SHPHandle SHPOpen( const char * pszShapeFile, const char * pszAccess );
205     SHPHandle SHPCreate( const char * pszShapeFile, int nShapeType );
206     void SHPGetInfo( SHPHandle hSHP, int * pnEntities, int * pnShapeType,
207     double * padfMinBound, double * padfMaxBound );
208    
209     SHPObject *SHPReadObject( SHPHandle hSHP, int iShape );
210     int SHPWriteObject( SHPHandle hSHP, int iShape, SHPObject * psObject );
211    
212     void SHPDestroyObject( SHPObject * psObject );
213     void SHPComputeExtents( SHPObject * psObject );
214     SHPObject *SHPCreateObject( int nSHPType, int nShapeId,
215     int nParts, int * panPartStart, int * panPartType,
216     int nVertices, double * padfX, double * padfY,
217     double * padfZ, double * padfM );
218     SHPObject *SHPCreateSimpleObject( int nSHPType, int nVertices,
219     double * padfX, double * padfY, double * padfZ );
220    
221     void SHPClose( SHPHandle hSHP );
222    
223     const char *SHPTypeName( int nSHPType );
224     const char *SHPPartTypeName( int nPartType );
225    
226     /* -------------------------------------------------------------------- */
227     /* Shape quadtree indexing API. */
228     /* -------------------------------------------------------------------- */
229    
230     /* this can be two or four for binary or quad tree */
231     #define MAX_SUBNODE 4
232    
233     typedef struct shape_tree_node
234     {
235     /* region covered by this node */
236     double adfBoundsMin[4];
237     double adfBoundsMax[4];
238    
239     /* list of shapes stored at this node. The papsShapeObj pointers
240     or the whole list can be NULL */
241     int nShapeCount;
242     int *panShapeIds;
243     SHPObject **papsShapeObj;
244    
245     int nSubNodes;
246     struct shape_tree_node *apsSubNode[MAX_SUBNODE];
247    
248     } SHPTreeNode;
249    
250     typedef struct
251     {
252     SHPHandle hSHP;
253    
254     int nMaxDepth;
255     int nDimension;
256    
257     SHPTreeNode *psRoot;
258     } SHPTree;
259    
260     SHPTree *SHPCreateTree( SHPHandle hSHP, int nDimension, int nMaxDepth,
261     double *padfBoundsMin, double *padfBoundsMax );
262     void SHPDestroyTree( SHPTree * hTree );
263    
264     int SHPWriteTree( SHPTree *hTree, const char * pszFilename );
265     SHPTree SHPReadTree( const char * pszFilename );
266    
267     int SHPTreeAddObject( SHPTree * hTree, SHPObject * psObject );
268     int SHPTreeAddShapeId( SHPTree * hTree, SHPObject * psObject );
269     int SHPTreeRemoveShapeId( SHPTree * hTree, int nShapeId );
270    
271     void SHPTreeTrimExtraNodes( SHPTree * hTree );
272    
273     int *SHPTreeFindLikelyShapes( SHPTree * hTree,
274     double * padfBoundsMin,
275     double * padfBoundsMax,
276     int * );
277     int SHPCheckBoundsOverlap( double *, double *, double *, double *, int );
278    
279     /************************************************************************/
280     /* DBF Support. */
281     /************************************************************************/
282     typedef struct
283     {
284     FILE *fp;
285    
286     int nRecords;
287    
288     int nRecordLength;
289     int nHeaderLength;
290     int nFields;
291     int *panFieldOffset;
292     int *panFieldSize;
293     int *panFieldDecimals;
294     char *pachFieldType;
295    
296     char *pszHeader;
297    
298     int nCurrentRecord;
299     int bCurrentRecordModified;
300     char *pszCurrentRecord;
301    
302     int bNoHeader;
303     int bUpdated;
304     } DBFInfo;
305    
306     typedef DBFInfo * DBFHandle;
307    
308     typedef enum {
309     FTString,
310     FTInteger,
311     FTDouble,
312     FTInvalid
313     } DBFFieldType;
314    
315     #define XBASE_FLDHDR_SZ 32
316    
317     DBFHandle DBFOpen( const char * pszDBFFile, const char * pszAccess );
318     DBFHandle DBFCreate( const char * pszDBFFile );
319    
320     int DBFGetFieldCount( DBFHandle psDBF );
321     int DBFGetRecordCount( DBFHandle psDBF );
322     int DBFAddField( DBFHandle hDBF, const char * pszFieldName,
323     DBFFieldType eType, int nWidth, int nDecimals );
324    
325     DBFFieldType DBFGetFieldInfo( DBFHandle psDBF, int iField,
326     char * pszFieldName,
327     int * pnWidth, int * pnDecimals );
328    
329     int DBFReadIntegerAttribute( DBFHandle hDBF, int iShape, int iField );
330     double DBFReadDoubleAttribute( DBFHandle hDBF, int iShape, int iField );
331     const char *DBFReadStringAttribute( DBFHandle hDBF, int iShape, int iField );
332    
333     int DBFWriteIntegerAttribute( DBFHandle hDBF, int iShape, int iField,
334     int nFieldValue );
335     int DBFWriteDoubleAttribute( DBFHandle hDBF, int iShape, int iField,
336     double dFieldValue );
337     int DBFWriteStringAttribute( DBFHandle hDBF, int iShape, int iField,
338     const char * pszFieldValue );
339    
340     const char *DBFReadTuple(DBFHandle psDBF, int hEntity );
341     int DBFWriteTuple(DBFHandle psDBF, int hEntity, void * pRawTuple );
342    
343     DBFHandle DBFCloneEmpty(DBFHandle psDBF, const char * pszFilename );
344    
345     void DBFClose( DBFHandle hDBF );
346    
347     #ifdef __cplusplus
348     }
349     #endif
350    
351     #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