shp 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +34 -0
- data/.travis.yml +4 -0
- data/Gemfile +3 -0
- data/LICENSE +28 -0
- data/README.md +30 -0
- data/Rakefile +23 -0
- data/ext/shp/base.hpp +113 -0
- data/ext/shp/dbf.cpp +381 -0
- data/ext/shp/dbf.hpp +44 -0
- data/ext/shp/extconf.rb +13 -0
- data/ext/shp/shape_object.cpp +58 -0
- data/ext/shp/shape_object.hpp +27 -0
- data/ext/shp/shapefile.cpp +299 -0
- data/ext/shp/shapefile.hpp +35 -0
- data/ext/shp/shapelib/.cvsignore +15 -0
- data/ext/shp/shapelib/ChangeLog +450 -0
- data/ext/shp/shapelib/HOWTO-RELEASE +16 -0
- data/ext/shp/shapelib/LICENSE.LGPL +483 -0
- data/ext/shp/shapelib/Makefile +113 -0
- data/ext/shp/shapelib/README +41 -0
- data/ext/shp/shapelib/README.tree +172 -0
- data/ext/shp/shapelib/contrib/.cvsignore +12 -0
- data/ext/shp/shapelib/contrib/Makefile +66 -0
- data/ext/shp/shapelib/contrib/ShapeFileII.pas +234 -0
- data/ext/shp/shapelib/contrib/Shape_PointInPoly.cpp +238 -0
- data/ext/shp/shapelib/contrib/Shape_PointInPoly_README.txt +59 -0
- data/ext/shp/shapelib/contrib/csv2shp.c +558 -0
- data/ext/shp/shapelib/contrib/dbfcat.c +166 -0
- data/ext/shp/shapelib/contrib/dbfinfo.c +106 -0
- data/ext/shp/shapelib/contrib/makefile.vc +34 -0
- data/ext/shp/shapelib/contrib/my_nan.h +46 -0
- data/ext/shp/shapelib/contrib/shpcat.c +100 -0
- data/ext/shp/shapelib/contrib/shpcentrd.c +159 -0
- data/ext/shp/shapelib/contrib/shpdata.c +129 -0
- data/ext/shp/shapelib/contrib/shpdxf.c +340 -0
- data/ext/shp/shapelib/contrib/shpfix.c +110 -0
- data/ext/shp/shapelib/contrib/shpgeo.c +1595 -0
- data/ext/shp/shapelib/contrib/shpgeo.h +154 -0
- data/ext/shp/shapelib/contrib/shpinfo.c +113 -0
- data/ext/shp/shapelib/contrib/shpproj.c +260 -0
- data/ext/shp/shapelib/contrib/shpsort.c +605 -0
- data/ext/shp/shapelib/contrib/shpsort.txt +44 -0
- data/ext/shp/shapelib/contrib/shpwkb.c +123 -0
- data/ext/shp/shapelib/contrib/tests/shpproj.sh +38 -0
- data/ext/shp/shapelib/dbfopen.c +2221 -0
- data/ext/shp/shapelib/makefile.vc +86 -0
- data/ext/shp/shapelib/makeshape.sh +21 -0
- data/ext/shp/shapelib/mkdist.sh +37 -0
- data/ext/shp/shapelib/mkinstalldirs +38 -0
- data/ext/shp/shapelib/mkrelease.sh +55 -0
- data/ext/shp/shapelib/safileio.c +286 -0
- data/ext/shp/shapelib/shapefil.h +647 -0
- data/ext/shp/shapelib/shapelib.def +46 -0
- data/ext/shp/shapelib/shpopen.c +2388 -0
- data/ext/shp/shapelib/shptree.c +1187 -0
- data/ext/shp/shapelib/shputils.c +1072 -0
- data/ext/shp/shapelib/stream1.out +1465 -0
- data/ext/shp/shapelib/stream1.sh +28 -0
- data/ext/shp/shapelib/stream2.out +530 -0
- data/ext/shp/shapelib/stream2.sh +11 -0
- data/ext/shp/shapelib/stream3.out +37 -0
- data/ext/shp/shapelib/web/.cvsignore +2 -0
- data/ext/shp/shapelib/web/codepage.html +403 -0
- data/ext/shp/shapelib/web/dbf_api.html +436 -0
- data/ext/shp/shapelib/web/index.html +235 -0
- data/ext/shp/shapelib/web/license.html +78 -0
- data/ext/shp/shapelib/web/manifest.html +87 -0
- data/ext/shp/shapelib/web/release.html +80 -0
- data/ext/shp/shapelib/web/shapelib-tools.html +352 -0
- data/ext/shp/shapelib/web/shp_api.html +376 -0
- data/ext/shp/shp.cpp +19 -0
- data/ext/shp/shp.hpp +47 -0
- data/lib/shp.rb +35 -0
- data/lib/shp/version.rb +3 -0
- data/shp.gemspec +23 -0
- data/spec/shp_spec.rb +127 -0
- metadata +176 -0
@@ -0,0 +1,647 @@
|
|
1
|
+
#ifndef SHAPEFILE_H_INCLUDED
|
2
|
+
#define SHAPEFILE_H_INCLUDED
|
3
|
+
|
4
|
+
/******************************************************************************
|
5
|
+
* $Id: shapefil.h,v 1.52 2011-12-11 22:26:46 fwarmerdam Exp $
|
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
|
+
*
|
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: shapefil.h,v $
|
40
|
+
* Revision 1.52 2011-12-11 22:26:46 fwarmerdam
|
41
|
+
* upgrade .qix access code to use SAHooks (gdal #3365)
|
42
|
+
*
|
43
|
+
* Revision 1.51 2011-07-24 05:59:25 fwarmerdam
|
44
|
+
* minimize use of CPLError in favor of SAHooks.Error()
|
45
|
+
*
|
46
|
+
* Revision 1.50 2011-05-13 17:35:17 fwarmerdam
|
47
|
+
* added DBFReorderFields() and DBFAlterFields() functions (from Even)
|
48
|
+
*
|
49
|
+
* Revision 1.49 2011-04-16 14:38:21 fwarmerdam
|
50
|
+
* avoid warnings with gcc on SHP_CVSID
|
51
|
+
*
|
52
|
+
* Revision 1.48 2010-08-27 23:42:52 fwarmerdam
|
53
|
+
* add SHPAPI_CALL attribute in code
|
54
|
+
*
|
55
|
+
* Revision 1.47 2010-01-28 11:34:34 fwarmerdam
|
56
|
+
* handle the shape file length limits more gracefully (#3236)
|
57
|
+
*
|
58
|
+
* Revision 1.46 2008-11-12 14:28:15 fwarmerdam
|
59
|
+
* DBFCreateField() now works on files with records
|
60
|
+
*
|
61
|
+
* Revision 1.45 2008/11/11 17:47:10 fwarmerdam
|
62
|
+
* added DBFDeleteField() function
|
63
|
+
*
|
64
|
+
* Revision 1.44 2008/01/16 20:05:19 bram
|
65
|
+
* Add file hooks that accept UTF-8 encoded filenames on some platforms. Use SASetupUtf8Hooks
|
66
|
+
* tosetup the hooks and check SHPAPI_UTF8_HOOKS for its availability. Currently, this
|
67
|
+
* is only available on the Windows platform that decodes the UTF-8 filenames to wide
|
68
|
+
* character strings and feeds them to _wfopen and _wremove.
|
69
|
+
*
|
70
|
+
* Revision 1.43 2008/01/10 16:35:30 fwarmerdam
|
71
|
+
* avoid _ prefix on #defined symbols (bug 1840)
|
72
|
+
*
|
73
|
+
* Revision 1.42 2007/12/18 18:28:14 bram
|
74
|
+
* - create hook for client specific atof (bugzilla ticket 1615)
|
75
|
+
* - check for NULL handle before closing cpCPG file, and close after reading.
|
76
|
+
*
|
77
|
+
* Revision 1.41 2007/12/15 20:25:32 bram
|
78
|
+
* dbfopen.c now reads the Code Page information from the DBF file, and exports
|
79
|
+
* this information as a string through the DBFGetCodePage function. This is
|
80
|
+
* either the number from the LDID header field ("LDID/<number>") or as the
|
81
|
+
* content of an accompanying .CPG file. When creating a DBF file, the code can
|
82
|
+
* be set using DBFCreateEx.
|
83
|
+
*
|
84
|
+
* Revision 1.40 2007/12/06 07:00:25 fwarmerdam
|
85
|
+
* dbfopen now using SAHooks for fileio
|
86
|
+
*
|
87
|
+
* Revision 1.39 2007/12/04 20:37:56 fwarmerdam
|
88
|
+
* preliminary implementation of hooks api for io and errors
|
89
|
+
*
|
90
|
+
* Revision 1.38 2007/11/21 22:39:56 fwarmerdam
|
91
|
+
* close shx file in readonly mode (GDAL #1956)
|
92
|
+
*
|
93
|
+
* Revision 1.37 2007/10/27 03:31:14 fwarmerdam
|
94
|
+
* limit default depth of tree to 12 levels (gdal ticket #1594)
|
95
|
+
*
|
96
|
+
* Revision 1.36 2007/09/10 23:33:15 fwarmerdam
|
97
|
+
* Upstreamed support for visibility flag in SHPAPI_CALL for the needs
|
98
|
+
* of GDAL (gdal ticket #1810).
|
99
|
+
*
|
100
|
+
* Revision 1.35 2007/09/03 19:48:10 fwarmerdam
|
101
|
+
* move DBFReadAttribute() static dDoubleField into dbfinfo
|
102
|
+
*
|
103
|
+
* Revision 1.34 2006/06/17 15:33:32 fwarmerdam
|
104
|
+
* added pszWorkField - bug 1202 (rso)
|
105
|
+
*
|
106
|
+
* Revision 1.33 2006/02/15 01:14:30 fwarmerdam
|
107
|
+
* added DBFAddNativeFieldType
|
108
|
+
*
|
109
|
+
* Revision 1.32 2006/01/26 15:07:32 fwarmerdam
|
110
|
+
* add bMeasureIsUsed flag from Craig Bruce: Bug 1249
|
111
|
+
*
|
112
|
+
* Revision 1.31 2006/01/05 01:27:27 fwarmerdam
|
113
|
+
* added dbf deletion mark/fetch
|
114
|
+
*
|
115
|
+
* Revision 1.30 2005/01/03 22:30:13 fwarmerdam
|
116
|
+
* added support for saved quadtrees
|
117
|
+
*
|
118
|
+
* Revision 1.29 2004/09/26 20:09:35 fwarmerdam
|
119
|
+
* avoid rcsid warnings
|
120
|
+
*
|
121
|
+
* Revision 1.28 2003/12/29 06:02:18 fwarmerdam
|
122
|
+
* added cpl_error.h option
|
123
|
+
*
|
124
|
+
* Revision 1.27 2003/04/21 18:30:37 warmerda
|
125
|
+
* added header write/update public methods
|
126
|
+
*
|
127
|
+
* Revision 1.26 2002/09/29 00:00:08 warmerda
|
128
|
+
* added FTLogical and logical attribute read/write calls
|
129
|
+
*
|
130
|
+
* Revision 1.25 2002/05/07 13:46:30 warmerda
|
131
|
+
* added DBFWriteAttributeDirectly().
|
132
|
+
*
|
133
|
+
* Revision 1.24 2002/04/10 16:59:54 warmerda
|
134
|
+
* added SHPRewindObject
|
135
|
+
*
|
136
|
+
* Revision 1.23 2002/01/15 14:36:07 warmerda
|
137
|
+
* updated email address
|
138
|
+
*
|
139
|
+
* Revision 1.22 2002/01/15 14:32:00 warmerda
|
140
|
+
* try to improve SHPAPI_CALL docs
|
141
|
+
*/
|
142
|
+
|
143
|
+
#include <stdio.h>
|
144
|
+
|
145
|
+
#ifdef USE_DBMALLOC
|
146
|
+
#include <dbmalloc.h>
|
147
|
+
#endif
|
148
|
+
|
149
|
+
#ifdef __cplusplus
|
150
|
+
extern "C" {
|
151
|
+
#endif
|
152
|
+
|
153
|
+
/************************************************************************/
|
154
|
+
/* Configuration options. */
|
155
|
+
/************************************************************************/
|
156
|
+
|
157
|
+
/* -------------------------------------------------------------------- */
|
158
|
+
/* Should the DBFReadStringAttribute() strip leading and */
|
159
|
+
/* trailing white space? */
|
160
|
+
/* -------------------------------------------------------------------- */
|
161
|
+
#define TRIM_DBF_WHITESPACE
|
162
|
+
|
163
|
+
/* -------------------------------------------------------------------- */
|
164
|
+
/* Should we write measure values to the Multipatch object? */
|
165
|
+
/* Reportedly ArcView crashes if we do write it, so for now it */
|
166
|
+
/* is disabled. */
|
167
|
+
/* -------------------------------------------------------------------- */
|
168
|
+
#define DISABLE_MULTIPATCH_MEASURE
|
169
|
+
|
170
|
+
/* -------------------------------------------------------------------- */
|
171
|
+
/* SHPAPI_CALL */
|
172
|
+
/* */
|
173
|
+
/* The following two macros are present to allow forcing */
|
174
|
+
/* various calling conventions on the Shapelib API. */
|
175
|
+
/* */
|
176
|
+
/* To force __stdcall conventions (needed to call Shapelib */
|
177
|
+
/* from Visual Basic and/or Dephi I believe) the makefile could */
|
178
|
+
/* be modified to define: */
|
179
|
+
/* */
|
180
|
+
/* /DSHPAPI_CALL=__stdcall */
|
181
|
+
/* */
|
182
|
+
/* If it is desired to force export of the Shapelib API without */
|
183
|
+
/* using the shapelib.def file, use the following definition. */
|
184
|
+
/* */
|
185
|
+
/* /DSHAPELIB_DLLEXPORT */
|
186
|
+
/* */
|
187
|
+
/* To get both at once it will be necessary to hack this */
|
188
|
+
/* include file to define: */
|
189
|
+
/* */
|
190
|
+
/* #define SHPAPI_CALL __declspec(dllexport) __stdcall */
|
191
|
+
/* #define SHPAPI_CALL1 __declspec(dllexport) * __stdcall */
|
192
|
+
/* */
|
193
|
+
/* The complexity of the situtation is partly caused by the */
|
194
|
+
/* peculiar requirement of Visual C++ that __stdcall appear */
|
195
|
+
/* after any "*"'s in the return value of a function while the */
|
196
|
+
/* __declspec(dllexport) must appear before them. */
|
197
|
+
/* -------------------------------------------------------------------- */
|
198
|
+
|
199
|
+
#ifdef SHAPELIB_DLLEXPORT
|
200
|
+
# define SHPAPI_CALL __declspec(dllexport)
|
201
|
+
# define SHPAPI_CALL1(x) __declspec(dllexport) x
|
202
|
+
#endif
|
203
|
+
|
204
|
+
#ifndef SHPAPI_CALL
|
205
|
+
# if defined(USE_GCC_VISIBILITY_FLAG)
|
206
|
+
# define SHPAPI_CALL __attribute__ ((visibility("default")))
|
207
|
+
# define SHPAPI_CALL1(x) __attribute__ ((visibility("default"))) x
|
208
|
+
# else
|
209
|
+
# define SHPAPI_CALL
|
210
|
+
# endif
|
211
|
+
#endif
|
212
|
+
|
213
|
+
#ifndef SHPAPI_CALL1
|
214
|
+
# define SHPAPI_CALL1(x) x SHPAPI_CALL
|
215
|
+
#endif
|
216
|
+
|
217
|
+
/* -------------------------------------------------------------------- */
|
218
|
+
/* Macros for controlling CVSID and ensuring they don't appear */
|
219
|
+
/* as unreferenced variables resulting in lots of warnings. */
|
220
|
+
/* -------------------------------------------------------------------- */
|
221
|
+
#ifndef DISABLE_CVSID
|
222
|
+
# if defined(__GNUC__) && __GNUC__ >= 4
|
223
|
+
# define SHP_CVSID(string) static char cpl_cvsid[] __attribute__((used)) = string;
|
224
|
+
# else
|
225
|
+
# define SHP_CVSID(string) static char cpl_cvsid[] = string; \
|
226
|
+
static char *cvsid_aw() { return( cvsid_aw() ? ((char *) NULL) : cpl_cvsid ); }
|
227
|
+
# endif
|
228
|
+
#else
|
229
|
+
# define SHP_CVSID(string)
|
230
|
+
#endif
|
231
|
+
|
232
|
+
/* -------------------------------------------------------------------- */
|
233
|
+
/* On some platforms, additional file IO hooks are defined that */
|
234
|
+
/* UTF-8 encoded filenames Unicode filenames */
|
235
|
+
/* -------------------------------------------------------------------- */
|
236
|
+
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
|
237
|
+
# define SHPAPI_WINDOWS
|
238
|
+
# define SHPAPI_UTF8_HOOKS
|
239
|
+
#endif
|
240
|
+
|
241
|
+
/* -------------------------------------------------------------------- */
|
242
|
+
/* IO/Error hook functions. */
|
243
|
+
/* -------------------------------------------------------------------- */
|
244
|
+
typedef int *SAFile;
|
245
|
+
|
246
|
+
#ifndef SAOffset
|
247
|
+
typedef unsigned long SAOffset;
|
248
|
+
#endif
|
249
|
+
|
250
|
+
typedef struct {
|
251
|
+
SAFile (*FOpen) ( const char *filename, const char *access);
|
252
|
+
SAOffset (*FRead) ( void *p, SAOffset size, SAOffset nmemb, SAFile file);
|
253
|
+
SAOffset (*FWrite)( void *p, SAOffset size, SAOffset nmemb, SAFile file);
|
254
|
+
SAOffset (*FSeek) ( SAFile file, SAOffset offset, int whence );
|
255
|
+
SAOffset (*FTell) ( SAFile file );
|
256
|
+
int (*FFlush)( SAFile file );
|
257
|
+
int (*FClose)( SAFile file );
|
258
|
+
int (*Remove) ( const char *filename );
|
259
|
+
|
260
|
+
void (*Error) ( const char *message );
|
261
|
+
double (*Atof) ( const char *str );
|
262
|
+
} SAHooks;
|
263
|
+
|
264
|
+
void SHPAPI_CALL SASetupDefaultHooks( SAHooks *psHooks );
|
265
|
+
#ifdef SHPAPI_UTF8_HOOKS
|
266
|
+
void SHPAPI_CALL SASetupUtf8Hooks( SAHooks *psHooks );
|
267
|
+
#endif
|
268
|
+
|
269
|
+
/************************************************************************/
|
270
|
+
/* SHP Support. */
|
271
|
+
/************************************************************************/
|
272
|
+
typedef struct
|
273
|
+
{
|
274
|
+
SAHooks sHooks;
|
275
|
+
|
276
|
+
SAFile fpSHP;
|
277
|
+
SAFile fpSHX;
|
278
|
+
|
279
|
+
int nShapeType; /* SHPT_* */
|
280
|
+
|
281
|
+
unsigned int nFileSize; /* SHP file */
|
282
|
+
|
283
|
+
int nRecords;
|
284
|
+
int nMaxRecords;
|
285
|
+
unsigned int *panRecOffset;
|
286
|
+
unsigned int *panRecSize;
|
287
|
+
|
288
|
+
double adBoundsMin[4];
|
289
|
+
double adBoundsMax[4];
|
290
|
+
|
291
|
+
int bUpdated;
|
292
|
+
|
293
|
+
unsigned char *pabyRec;
|
294
|
+
int nBufSize;
|
295
|
+
} SHPInfo;
|
296
|
+
|
297
|
+
typedef SHPInfo * SHPHandle;
|
298
|
+
|
299
|
+
/* -------------------------------------------------------------------- */
|
300
|
+
/* Shape types (nSHPType) */
|
301
|
+
/* -------------------------------------------------------------------- */
|
302
|
+
#define SHPT_NULL 0
|
303
|
+
#define SHPT_POINT 1
|
304
|
+
#define SHPT_ARC 3
|
305
|
+
#define SHPT_POLYGON 5
|
306
|
+
#define SHPT_MULTIPOINT 8
|
307
|
+
#define SHPT_POINTZ 11
|
308
|
+
#define SHPT_ARCZ 13
|
309
|
+
#define SHPT_POLYGONZ 15
|
310
|
+
#define SHPT_MULTIPOINTZ 18
|
311
|
+
#define SHPT_POINTM 21
|
312
|
+
#define SHPT_ARCM 23
|
313
|
+
#define SHPT_POLYGONM 25
|
314
|
+
#define SHPT_MULTIPOINTM 28
|
315
|
+
#define SHPT_MULTIPATCH 31
|
316
|
+
|
317
|
+
|
318
|
+
/* -------------------------------------------------------------------- */
|
319
|
+
/* Part types - everything but SHPT_MULTIPATCH just uses */
|
320
|
+
/* SHPP_RING. */
|
321
|
+
/* -------------------------------------------------------------------- */
|
322
|
+
|
323
|
+
#define SHPP_TRISTRIP 0
|
324
|
+
#define SHPP_TRIFAN 1
|
325
|
+
#define SHPP_OUTERRING 2
|
326
|
+
#define SHPP_INNERRING 3
|
327
|
+
#define SHPP_FIRSTRING 4
|
328
|
+
#define SHPP_RING 5
|
329
|
+
|
330
|
+
/* -------------------------------------------------------------------- */
|
331
|
+
/* SHPObject - represents on shape (without attributes) read */
|
332
|
+
/* from the .shp file. */
|
333
|
+
/* -------------------------------------------------------------------- */
|
334
|
+
typedef struct
|
335
|
+
{
|
336
|
+
int nSHPType;
|
337
|
+
|
338
|
+
int nShapeId; /* -1 is unknown/unassigned */
|
339
|
+
|
340
|
+
int nParts;
|
341
|
+
int *panPartStart;
|
342
|
+
int *panPartType;
|
343
|
+
|
344
|
+
int nVertices;
|
345
|
+
double *padfX;
|
346
|
+
double *padfY;
|
347
|
+
double *padfZ;
|
348
|
+
double *padfM;
|
349
|
+
|
350
|
+
double dfXMin;
|
351
|
+
double dfYMin;
|
352
|
+
double dfZMin;
|
353
|
+
double dfMMin;
|
354
|
+
|
355
|
+
double dfXMax;
|
356
|
+
double dfYMax;
|
357
|
+
double dfZMax;
|
358
|
+
double dfMMax;
|
359
|
+
|
360
|
+
int bMeasureIsUsed;
|
361
|
+
} SHPObject;
|
362
|
+
|
363
|
+
/* -------------------------------------------------------------------- */
|
364
|
+
/* SHP API Prototypes */
|
365
|
+
/* -------------------------------------------------------------------- */
|
366
|
+
|
367
|
+
/* If pszAccess is read-only, the fpSHX field of the returned structure */
|
368
|
+
/* will be NULL as it is not necessary to keep the SHX file open */
|
369
|
+
SHPHandle SHPAPI_CALL
|
370
|
+
SHPOpen( const char * pszShapeFile, const char * pszAccess );
|
371
|
+
SHPHandle SHPAPI_CALL
|
372
|
+
SHPOpenLL( const char *pszShapeFile, const char *pszAccess,
|
373
|
+
SAHooks *psHooks );
|
374
|
+
SHPHandle SHPAPI_CALL
|
375
|
+
SHPCreate( const char * pszShapeFile, int nShapeType );
|
376
|
+
SHPHandle SHPAPI_CALL
|
377
|
+
SHPCreateLL( const char * pszShapeFile, int nShapeType,
|
378
|
+
SAHooks *psHooks );
|
379
|
+
void SHPAPI_CALL
|
380
|
+
SHPGetInfo( SHPHandle hSHP, int * pnEntities, int * pnShapeType,
|
381
|
+
double * padfMinBound, double * padfMaxBound );
|
382
|
+
|
383
|
+
SHPObject SHPAPI_CALL1(*)
|
384
|
+
SHPReadObject( SHPHandle hSHP, int iShape );
|
385
|
+
int SHPAPI_CALL
|
386
|
+
SHPWriteObject( SHPHandle hSHP, int iShape, SHPObject * psObject );
|
387
|
+
|
388
|
+
void SHPAPI_CALL
|
389
|
+
SHPDestroyObject( SHPObject * psObject );
|
390
|
+
void SHPAPI_CALL
|
391
|
+
SHPComputeExtents( SHPObject * psObject );
|
392
|
+
SHPObject SHPAPI_CALL1(*)
|
393
|
+
SHPCreateObject( int nSHPType, int nShapeId, int nParts,
|
394
|
+
const int * panPartStart, const int * panPartType,
|
395
|
+
int nVertices,
|
396
|
+
const double * padfX, const double * padfY,
|
397
|
+
const double * padfZ, const double * padfM );
|
398
|
+
SHPObject SHPAPI_CALL1(*)
|
399
|
+
SHPCreateSimpleObject( int nSHPType, int nVertices,
|
400
|
+
const double * padfX,
|
401
|
+
const double * padfY,
|
402
|
+
const double * padfZ );
|
403
|
+
|
404
|
+
int SHPAPI_CALL
|
405
|
+
SHPRewindObject( SHPHandle hSHP, SHPObject * psObject );
|
406
|
+
|
407
|
+
void SHPAPI_CALL SHPClose( SHPHandle hSHP );
|
408
|
+
void SHPAPI_CALL SHPWriteHeader( SHPHandle hSHP );
|
409
|
+
|
410
|
+
const char SHPAPI_CALL1(*)
|
411
|
+
SHPTypeName( int nSHPType );
|
412
|
+
const char SHPAPI_CALL1(*)
|
413
|
+
SHPPartTypeName( int nPartType );
|
414
|
+
|
415
|
+
/* -------------------------------------------------------------------- */
|
416
|
+
/* Shape quadtree indexing API. */
|
417
|
+
/* -------------------------------------------------------------------- */
|
418
|
+
|
419
|
+
/* this can be two or four for binary or quad tree */
|
420
|
+
#define MAX_SUBNODE 4
|
421
|
+
|
422
|
+
/* upper limit of tree levels for automatic estimation */
|
423
|
+
#define MAX_DEFAULT_TREE_DEPTH 12
|
424
|
+
|
425
|
+
typedef struct shape_tree_node
|
426
|
+
{
|
427
|
+
/* region covered by this node */
|
428
|
+
double adfBoundsMin[4];
|
429
|
+
double adfBoundsMax[4];
|
430
|
+
|
431
|
+
/* list of shapes stored at this node. The papsShapeObj pointers
|
432
|
+
or the whole list can be NULL */
|
433
|
+
int nShapeCount;
|
434
|
+
int *panShapeIds;
|
435
|
+
SHPObject **papsShapeObj;
|
436
|
+
|
437
|
+
int nSubNodes;
|
438
|
+
struct shape_tree_node *apsSubNode[MAX_SUBNODE];
|
439
|
+
|
440
|
+
} SHPTreeNode;
|
441
|
+
|
442
|
+
typedef struct
|
443
|
+
{
|
444
|
+
SHPHandle hSHP;
|
445
|
+
|
446
|
+
int nMaxDepth;
|
447
|
+
int nDimension;
|
448
|
+
int nTotalCount;
|
449
|
+
|
450
|
+
SHPTreeNode *psRoot;
|
451
|
+
} SHPTree;
|
452
|
+
|
453
|
+
SHPTree SHPAPI_CALL1(*)
|
454
|
+
SHPCreateTree( SHPHandle hSHP, int nDimension, int nMaxDepth,
|
455
|
+
double *padfBoundsMin, double *padfBoundsMax );
|
456
|
+
void SHPAPI_CALL
|
457
|
+
SHPDestroyTree( SHPTree * hTree );
|
458
|
+
|
459
|
+
int SHPAPI_CALL
|
460
|
+
SHPWriteTree( SHPTree *hTree, const char * pszFilename );
|
461
|
+
|
462
|
+
int SHPAPI_CALL
|
463
|
+
SHPTreeAddShapeId( SHPTree * hTree, SHPObject * psObject );
|
464
|
+
int SHPAPI_CALL
|
465
|
+
SHPTreeRemoveShapeId( SHPTree * hTree, int nShapeId );
|
466
|
+
|
467
|
+
void SHPAPI_CALL
|
468
|
+
SHPTreeTrimExtraNodes( SHPTree * hTree );
|
469
|
+
|
470
|
+
int SHPAPI_CALL1(*)
|
471
|
+
SHPTreeFindLikelyShapes( SHPTree * hTree,
|
472
|
+
double * padfBoundsMin,
|
473
|
+
double * padfBoundsMax,
|
474
|
+
int * );
|
475
|
+
int SHPAPI_CALL
|
476
|
+
SHPCheckBoundsOverlap( double *, double *, double *, double *, int );
|
477
|
+
|
478
|
+
int SHPAPI_CALL1(*)
|
479
|
+
SHPSearchDiskTree( FILE *fp,
|
480
|
+
double *padfBoundsMin, double *padfBoundsMax,
|
481
|
+
int *pnShapeCount );
|
482
|
+
|
483
|
+
|
484
|
+
typedef struct SHPDiskTreeInfo* SHPTreeDiskHandle;
|
485
|
+
|
486
|
+
SHPTreeDiskHandle SHPAPI_CALL
|
487
|
+
SHPOpenDiskTree( const char* pszQIXFilename,
|
488
|
+
SAHooks *psHooks );
|
489
|
+
|
490
|
+
void SHPAPI_CALL
|
491
|
+
SHPCloseDiskTree( SHPTreeDiskHandle hDiskTree );
|
492
|
+
|
493
|
+
int SHPAPI_CALL1(*)
|
494
|
+
SHPSearchDiskTreeEx( SHPTreeDiskHandle hDiskTree,
|
495
|
+
double *padfBoundsMin, double *padfBoundsMax,
|
496
|
+
int *pnShapeCount );
|
497
|
+
|
498
|
+
int SHPAPI_CALL
|
499
|
+
SHPWriteTreeLL(SHPTree *hTree, const char *pszFilename, SAHooks *psHooks );
|
500
|
+
|
501
|
+
/************************************************************************/
|
502
|
+
/* DBF Support. */
|
503
|
+
/************************************************************************/
|
504
|
+
typedef struct
|
505
|
+
{
|
506
|
+
SAHooks sHooks;
|
507
|
+
|
508
|
+
SAFile fp;
|
509
|
+
|
510
|
+
int nRecords;
|
511
|
+
|
512
|
+
int nRecordLength;
|
513
|
+
int nHeaderLength;
|
514
|
+
int nFields;
|
515
|
+
int *panFieldOffset;
|
516
|
+
int *panFieldSize;
|
517
|
+
int *panFieldDecimals;
|
518
|
+
char *pachFieldType;
|
519
|
+
|
520
|
+
char *pszHeader;
|
521
|
+
|
522
|
+
int nCurrentRecord;
|
523
|
+
int bCurrentRecordModified;
|
524
|
+
char *pszCurrentRecord;
|
525
|
+
|
526
|
+
int nWorkFieldLength;
|
527
|
+
char *pszWorkField;
|
528
|
+
|
529
|
+
int bNoHeader;
|
530
|
+
int bUpdated;
|
531
|
+
|
532
|
+
double dfDoubleField;
|
533
|
+
|
534
|
+
int iLanguageDriver;
|
535
|
+
char *pszCodePage;
|
536
|
+
} DBFInfo;
|
537
|
+
|
538
|
+
typedef DBFInfo * DBFHandle;
|
539
|
+
|
540
|
+
typedef enum {
|
541
|
+
FTString,
|
542
|
+
FTInteger,
|
543
|
+
FTDouble,
|
544
|
+
FTLogical,
|
545
|
+
FTInvalid
|
546
|
+
} DBFFieldType;
|
547
|
+
|
548
|
+
#define XBASE_FLDHDR_SZ 32
|
549
|
+
|
550
|
+
|
551
|
+
DBFHandle SHPAPI_CALL
|
552
|
+
DBFOpen( const char * pszDBFFile, const char * pszAccess );
|
553
|
+
DBFHandle SHPAPI_CALL
|
554
|
+
DBFOpenLL( const char * pszDBFFile, const char * pszAccess,
|
555
|
+
SAHooks *psHooks );
|
556
|
+
DBFHandle SHPAPI_CALL
|
557
|
+
DBFCreate( const char * pszDBFFile );
|
558
|
+
DBFHandle SHPAPI_CALL
|
559
|
+
DBFCreateEx( const char * pszDBFFile, const char * pszCodePage );
|
560
|
+
DBFHandle SHPAPI_CALL
|
561
|
+
DBFCreateLL( const char * pszDBFFile, const char * pszCodePage, SAHooks *psHooks );
|
562
|
+
|
563
|
+
int SHPAPI_CALL
|
564
|
+
DBFGetFieldCount( DBFHandle psDBF );
|
565
|
+
int SHPAPI_CALL
|
566
|
+
DBFGetRecordCount( DBFHandle psDBF );
|
567
|
+
int SHPAPI_CALL
|
568
|
+
DBFAddField( DBFHandle hDBF, const char * pszFieldName,
|
569
|
+
DBFFieldType eType, int nWidth, int nDecimals );
|
570
|
+
|
571
|
+
int SHPAPI_CALL
|
572
|
+
DBFAddNativeFieldType( DBFHandle hDBF, const char * pszFieldName,
|
573
|
+
char chType, int nWidth, int nDecimals );
|
574
|
+
|
575
|
+
int SHPAPI_CALL
|
576
|
+
DBFDeleteField( DBFHandle hDBF, int iField );
|
577
|
+
|
578
|
+
int SHPAPI_CALL
|
579
|
+
DBFReorderFields( DBFHandle psDBF, int* panMap );
|
580
|
+
|
581
|
+
int SHPAPI_CALL
|
582
|
+
DBFAlterFieldDefn( DBFHandle psDBF, int iField, const char * pszFieldName,
|
583
|
+
char chType, int nWidth, int nDecimals );
|
584
|
+
|
585
|
+
DBFFieldType SHPAPI_CALL
|
586
|
+
DBFGetFieldInfo( DBFHandle psDBF, int iField,
|
587
|
+
char * pszFieldName, int * pnWidth, int * pnDecimals );
|
588
|
+
|
589
|
+
int SHPAPI_CALL
|
590
|
+
DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName);
|
591
|
+
|
592
|
+
int SHPAPI_CALL
|
593
|
+
DBFReadIntegerAttribute( DBFHandle hDBF, int iShape, int iField );
|
594
|
+
double SHPAPI_CALL
|
595
|
+
DBFReadDoubleAttribute( DBFHandle hDBF, int iShape, int iField );
|
596
|
+
const char SHPAPI_CALL1(*)
|
597
|
+
DBFReadStringAttribute( DBFHandle hDBF, int iShape, int iField );
|
598
|
+
const char SHPAPI_CALL1(*)
|
599
|
+
DBFReadLogicalAttribute( DBFHandle hDBF, int iShape, int iField );
|
600
|
+
int SHPAPI_CALL
|
601
|
+
DBFIsAttributeNULL( DBFHandle hDBF, int iShape, int iField );
|
602
|
+
|
603
|
+
int SHPAPI_CALL
|
604
|
+
DBFWriteIntegerAttribute( DBFHandle hDBF, int iShape, int iField,
|
605
|
+
int nFieldValue );
|
606
|
+
int SHPAPI_CALL
|
607
|
+
DBFWriteDoubleAttribute( DBFHandle hDBF, int iShape, int iField,
|
608
|
+
double dFieldValue );
|
609
|
+
int SHPAPI_CALL
|
610
|
+
DBFWriteStringAttribute( DBFHandle hDBF, int iShape, int iField,
|
611
|
+
const char * pszFieldValue );
|
612
|
+
int SHPAPI_CALL
|
613
|
+
DBFWriteNULLAttribute( DBFHandle hDBF, int iShape, int iField );
|
614
|
+
|
615
|
+
int SHPAPI_CALL
|
616
|
+
DBFWriteLogicalAttribute( DBFHandle hDBF, int iShape, int iField,
|
617
|
+
const char lFieldValue);
|
618
|
+
int SHPAPI_CALL
|
619
|
+
DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity, int iField,
|
620
|
+
void * pValue );
|
621
|
+
const char SHPAPI_CALL1(*)
|
622
|
+
DBFReadTuple(DBFHandle psDBF, int hEntity );
|
623
|
+
int SHPAPI_CALL
|
624
|
+
DBFWriteTuple(DBFHandle psDBF, int hEntity, void * pRawTuple );
|
625
|
+
|
626
|
+
int SHPAPI_CALL DBFIsRecordDeleted( DBFHandle psDBF, int iShape );
|
627
|
+
int SHPAPI_CALL DBFMarkRecordDeleted( DBFHandle psDBF, int iShape,
|
628
|
+
int bIsDeleted );
|
629
|
+
|
630
|
+
DBFHandle SHPAPI_CALL
|
631
|
+
DBFCloneEmpty(DBFHandle psDBF, const char * pszFilename );
|
632
|
+
|
633
|
+
void SHPAPI_CALL
|
634
|
+
DBFClose( DBFHandle hDBF );
|
635
|
+
void SHPAPI_CALL
|
636
|
+
DBFUpdateHeader( DBFHandle hDBF );
|
637
|
+
char SHPAPI_CALL
|
638
|
+
DBFGetNativeFieldType( DBFHandle hDBF, int iField );
|
639
|
+
|
640
|
+
const char SHPAPI_CALL1(*)
|
641
|
+
DBFGetCodePage(DBFHandle psDBF );
|
642
|
+
|
643
|
+
#ifdef __cplusplus
|
644
|
+
}
|
645
|
+
#endif
|
646
|
+
|
647
|
+
#endif /* ndef SHAPEFILE_H_INCLUDED */
|