shapes 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ require 'mkmf'
2
+
3
+ create_makefile("shapes/shapeslib")
Binary file
@@ -0,0 +1,40 @@
1
+ have_library: checking for SHPCreate() in -llibshp.a... -------------------- no
2
+
3
+ "/usr/bin/gcc-4.2 -o conftest -I/Users/oq/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/x86_64-darwin12.2.0 -I/Users/oq/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/ruby/backward -I/Users/oq/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/Users/mpapis/.sm/pkg/active/include -pipe conftest.c -L. -L/Users/oq/.rvm/rubies/ruby-1.9.3-p327/lib -L. -Bstatic -L/Users/mpapis/.sm/pkg/active/lib -arch x86_64 -lruby-static -lpthread -ldl -lobjc "
4
+ ld: warning: directory not found for option '-L/Users/mpapis/.sm/pkg/active/lib'
5
+ checked program was:
6
+ /* begin */
7
+ 1: #include "ruby.h"
8
+ 2:
9
+ 3: int main() {return 0;}
10
+ /* end */
11
+
12
+ "/usr/bin/gcc-4.2 -o conftest -I/Users/oq/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/x86_64-darwin12.2.0 -I/Users/oq/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/ruby/backward -I/Users/oq/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/Users/mpapis/.sm/pkg/active/include -pipe conftest.c -L. -L/Users/oq/.rvm/rubies/ruby-1.9.3-p327/lib -L. -Bstatic -L/Users/mpapis/.sm/pkg/active/lib -arch x86_64 -lruby-static -llibshp.a -lpthread -ldl -lobjc "
13
+ conftest.c: In function ‘t’:
14
+ conftest.c:5: error: ‘SHPCreate’ undeclared (first use in this function)
15
+ conftest.c:5: error: (Each undeclared identifier is reported only once
16
+ conftest.c:5: error: for each function it appears in.)
17
+ checked program was:
18
+ /* begin */
19
+ 1: #include "ruby.h"
20
+ 2:
21
+ 3: /*top*/
22
+ 4: int main() {return 0;}
23
+ 5: int t() { void ((*volatile p)()); p = (void ((*)()))SHPCreate; return 0; }
24
+ /* end */
25
+
26
+ "/usr/bin/gcc-4.2 -o conftest -I/Users/oq/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/x86_64-darwin12.2.0 -I/Users/oq/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/ruby/backward -I/Users/oq/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/Users/mpapis/.sm/pkg/active/include -pipe conftest.c -L. -L/Users/oq/.rvm/rubies/ruby-1.9.3-p327/lib -L. -Bstatic -L/Users/mpapis/.sm/pkg/active/lib -arch x86_64 -lruby-static -llibshp.a -lpthread -ldl -lobjc "
27
+ ld: warning: directory not found for option '-L/Users/mpapis/.sm/pkg/active/lib'
28
+ ld: library not found for -llibshp.a
29
+ collect2: ld returned 1 exit status
30
+ checked program was:
31
+ /* begin */
32
+ 1: #include "ruby.h"
33
+ 2:
34
+ 3: /*top*/
35
+ 4: int main() {return 0;}
36
+ 5: int t() { SHPCreate(); return 0; }
37
+ /* end */
38
+
39
+ --------------------
40
+
@@ -0,0 +1,286 @@
1
+ /******************************************************************************
2
+ * $Id: safileio.c,v 1.4 2008-01-16 20:05:14 bram Exp $
3
+ *
4
+ * Project: Shapelib
5
+ * Purpose: Default implementation of file io based on stdio.
6
+ * Author: Frank Warmerdam, warmerdam@pobox.com
7
+ *
8
+ ******************************************************************************
9
+ * Copyright (c) 2007, Frank Warmerdam
10
+ *
11
+ * This software is available under the following "MIT Style" license,
12
+ * or at the option of the licensee under the LGPL (see LICENSE.LGPL). This
13
+ * option is discussed in more detail in shapelib.html.
14
+ *
15
+ * --
16
+ *
17
+ * Permission is hereby granted, free of charge, to any person obtaining a
18
+ * copy of this software and associated documentation files (the "Software"),
19
+ * to deal in the Software without restriction, including without limitation
20
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
21
+ * and/or sell copies of the Software, and to permit persons to whom the
22
+ * Software is furnished to do so, subject to the following conditions:
23
+ *
24
+ * The above copyright notice and this permission notice shall be included
25
+ * in all copies or substantial portions of the Software.
26
+ *
27
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
28
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
30
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
32
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
33
+ * DEALINGS IN THE SOFTWARE.
34
+ ******************************************************************************
35
+ *
36
+ * $Log: safileio.c,v $
37
+ * Revision 1.4 2008-01-16 20:05:14 bram
38
+ * Add file hooks that accept UTF-8 encoded filenames on some platforms. Use SASetupUtf8Hooks
39
+ * tosetup the hooks and check SHPAPI_UTF8_HOOKS for its availability. Currently, this
40
+ * is only available on the Windows platform that decodes the UTF-8 filenames to wide
41
+ * character strings and feeds them to _wfopen and _wremove.
42
+ *
43
+ * Revision 1.3 2007/12/18 18:28:11 bram
44
+ * - create hook for client specific atof (bugzilla ticket 1615)
45
+ * - check for NULL handle before closing cpCPG file, and close after reading.
46
+ *
47
+ * Revision 1.2 2007/12/15 20:25:30 bram
48
+ * dbfopen.c now reads the Code Page information from the DBF file, and exports
49
+ * this information as a string through the DBFGetCodePage function. This is
50
+ * either the number from the LDID header field ("LDID/<number>") or as the
51
+ * content of an accompanying .CPG file. When creating a DBF file, the code can
52
+ * be set using DBFCreateEx.
53
+ *
54
+ * Revision 1.1 2007/12/06 06:56:41 fwarmerdam
55
+ * new
56
+ *
57
+ */
58
+
59
+ #include "shapefil.h"
60
+
61
+ #include <math.h>
62
+ #include <limits.h>
63
+ #include <assert.h>
64
+ #include <stdlib.h>
65
+ #include <string.h>
66
+ #include <stdio.h>
67
+
68
+ SHP_CVSID("$Id: safileio.c,v 1.4 2008-01-16 20:05:14 bram Exp $");
69
+
70
+ #ifdef SHPAPI_UTF8_HOOKS
71
+ # ifdef SHPAPI_WINDOWS
72
+ # define WIN32_LEAN_AND_MEAN
73
+ # define NOMINMAX
74
+ # include <windows.h>
75
+ # pragma comment(lib, "kernel32.lib")
76
+ # endif
77
+ #endif
78
+
79
+ /************************************************************************/
80
+ /* SADFOpen() */
81
+ /************************************************************************/
82
+
83
+ SAFile SADFOpen( const char *pszFilename, const char *pszAccess )
84
+
85
+ {
86
+ return (SAFile) fopen( pszFilename, pszAccess );
87
+ }
88
+
89
+ /************************************************************************/
90
+ /* SADFRead() */
91
+ /************************************************************************/
92
+
93
+ SAOffset SADFRead( void *p, SAOffset size, SAOffset nmemb, SAFile file )
94
+
95
+ {
96
+ return (SAOffset) fread( p, (size_t) size, (size_t) nmemb,
97
+ (FILE *) file );
98
+ }
99
+
100
+ /************************************************************************/
101
+ /* SADFWrite() */
102
+ /************************************************************************/
103
+
104
+ SAOffset SADFWrite( void *p, SAOffset size, SAOffset nmemb, SAFile file )
105
+
106
+ {
107
+ return (SAOffset) fwrite( p, (size_t) size, (size_t) nmemb,
108
+ (FILE *) file );
109
+ }
110
+
111
+ /************************************************************************/
112
+ /* SADFSeek() */
113
+ /************************************************************************/
114
+
115
+ SAOffset SADFSeek( SAFile file, SAOffset offset, int whence )
116
+
117
+ {
118
+ return (SAOffset) fseek( (FILE *) file, (long) offset, whence );
119
+ }
120
+
121
+ /************************************************************************/
122
+ /* SADFTell() */
123
+ /************************************************************************/
124
+
125
+ SAOffset SADFTell( SAFile file )
126
+
127
+ {
128
+ return (SAOffset) ftell( (FILE *) file );
129
+ }
130
+
131
+ /************************************************************************/
132
+ /* SADFFlush() */
133
+ /************************************************************************/
134
+
135
+ int SADFFlush( SAFile file )
136
+
137
+ {
138
+ return fflush( (FILE *) file );
139
+ }
140
+
141
+ /************************************************************************/
142
+ /* SADFClose() */
143
+ /************************************************************************/
144
+
145
+ int SADFClose( SAFile file )
146
+
147
+ {
148
+ return fclose( (FILE *) file );
149
+ }
150
+
151
+ /************************************************************************/
152
+ /* SADFClose() */
153
+ /************************************************************************/
154
+
155
+ int SADRemove( const char *filename )
156
+
157
+ {
158
+ return remove( filename );
159
+ }
160
+
161
+ /************************************************************************/
162
+ /* SADError() */
163
+ /************************************************************************/
164
+
165
+ void SADError( const char *message )
166
+
167
+ {
168
+ fprintf( stderr, "%s\n", message );
169
+ }
170
+
171
+ /************************************************************************/
172
+ /* SASetupDefaultHooks() */
173
+ /************************************************************************/
174
+
175
+ void SASetupDefaultHooks( SAHooks *psHooks )
176
+
177
+ {
178
+ psHooks->FOpen = SADFOpen;
179
+ psHooks->FRead = SADFRead;
180
+ psHooks->FWrite = SADFWrite;
181
+ psHooks->FSeek = SADFSeek;
182
+ psHooks->FTell = SADFTell;
183
+ psHooks->FFlush = SADFFlush;
184
+ psHooks->FClose = SADFClose;
185
+ psHooks->Remove = SADRemove;
186
+
187
+ psHooks->Error = SADError;
188
+ psHooks->Atof = atof;
189
+ }
190
+
191
+
192
+
193
+
194
+ #ifdef SHPAPI_WINDOWS
195
+
196
+ /************************************************************************/
197
+ /* Utf8ToWideChar */
198
+ /************************************************************************/
199
+
200
+ const wchar_t* Utf8ToWideChar( const char *pszFilename )
201
+ {
202
+ int nMulti, nWide;
203
+ wchar_t *pwszFileName;
204
+
205
+ nMulti = strlen(pszFilename) + 1;
206
+ nWide = MultiByteToWideChar( CP_UTF8, 0, pszFilename, nMulti, 0, 0);
207
+ if( nWide == 0 )
208
+ {
209
+ return NULL;
210
+ }
211
+ pwszFileName = (wchar_t*) malloc(nWide * sizeof(wchar_t));
212
+ if ( pwszFileName == NULL )
213
+ {
214
+ return NULL;
215
+ }
216
+ if( MultiByteToWideChar( CP_UTF8, 0, pszFilename, nMulti, pwszFileName, nWide ) == 0 )
217
+ {
218
+ free( pwszFileName );
219
+ return NULL;
220
+ }
221
+ return pwszFileName;
222
+ }
223
+
224
+ /************************************************************************/
225
+ /* SAUtf8WFOpen */
226
+ /************************************************************************/
227
+
228
+ SAFile SAUtf8WFOpen( const char *pszFilename, const char *pszAccess )
229
+ {
230
+ SAFile file = NULL;
231
+ const wchar_t *pwszFileName, *pwszAccess;
232
+ pwszFileName = Utf8ToWideChar( pszFilename );
233
+ pwszAccess = Utf8ToWideChar( pszAccess );
234
+ if( pwszFileName != NULL && pwszFileName != NULL)
235
+ {
236
+ file = (SAFile) _wfopen( pwszFileName, pwszAccess );
237
+ }
238
+ free ((wchar_t*) pwszFileName);
239
+ free ((wchar_t*) pwszAccess);
240
+ return file;
241
+ }
242
+
243
+ /************************************************************************/
244
+ /* SAUtf8WRemove() */
245
+ /************************************************************************/
246
+
247
+ int SAUtf8WRemove( const char *pszFilename )
248
+ {
249
+ const wchar_t *pwszFileName = Utf8ToWideChar( pszFilename );
250
+ int rc = -1;
251
+ if( pwszFileName != NULL )
252
+ {
253
+ rc = _wremove( pwszFileName );
254
+ }
255
+ free ((wchar_t*) pwszFileName);
256
+ return rc;
257
+ }
258
+
259
+ #endif
260
+
261
+ #ifdef SHPAPI_UTF8_HOOKS
262
+
263
+ /************************************************************************/
264
+ /* SASetupUtf8Hooks() */
265
+ /************************************************************************/
266
+
267
+ void SASetupUtf8Hooks( SAHooks *psHooks )
268
+ {
269
+ #ifdef SHPAPI_WINDOWS
270
+ psHooks->FOpen = SAUtf8WFOpen;
271
+ psHooks->Remove = SAUtf8WRemove;
272
+ #else
273
+ # error "no implementations of UTF-8 hooks available for this platform"
274
+ #endif
275
+ psHooks->FRead = SADFRead;
276
+ psHooks->FWrite = SADFWrite;
277
+ psHooks->FSeek = SADFSeek;
278
+ psHooks->FTell = SADFTell;
279
+ psHooks->FFlush = SADFFlush;
280
+ psHooks->FClose = SADFClose;
281
+
282
+ psHooks->Error = SADError;
283
+ psHooks->Atof = atof;
284
+ }
285
+
286
+ #endif
@@ -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 */