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,436 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>Attribute (.DBF) API</title>
|
4
|
+
</head>
|
5
|
+
<body>
|
6
|
+
<h1>Attribute (.DBF) API</h1>
|
7
|
+
|
8
|
+
The Attribute (DBF) API uses DBFHandle to represent a handle for access
|
9
|
+
to one .dbf file. The contents of the DBFHandle are visible (see shapefil.h)
|
10
|
+
but should be ignored by the application. It is intended that all information
|
11
|
+
be accessed by API functions. Note that there should be exactly one record
|
12
|
+
in the .dbf file for each shape in the .shp/.shx files. This constraint
|
13
|
+
must be maintained by the application.<p>
|
14
|
+
|
15
|
+
<!-------------------------------------------------------------------------->
|
16
|
+
|
17
|
+
<h2>DBFOpen()</h2>
|
18
|
+
|
19
|
+
<pre>
|
20
|
+
DBFHandle DBFOpen( const char * pszDBFFile, const char * pszAccess );
|
21
|
+
|
22
|
+
pszDBFFile: The name of the xBase (.dbf) file to access.
|
23
|
+
|
24
|
+
pszAccess: The fopen() style access string. At this time only
|
25
|
+
"rb" (read-only binary) and "rb+" (read/write binary)
|
26
|
+
should be used.
|
27
|
+
</pre>
|
28
|
+
|
29
|
+
The DBFOpen() function should be used to establish access to an existing
|
30
|
+
xBase format table file. The returned DBFHandle is passed to other
|
31
|
+
access functions, and DBFClose() should be invoked to recover resources, and
|
32
|
+
flush changes to disk when complete. The DBFCreate() function should
|
33
|
+
called to create new xBase files. As a convenience, DBFOpen() can be
|
34
|
+
called with the name of a .shp or .shx file, and it will figure out the
|
35
|
+
name of the related .dbf file.<p>
|
36
|
+
|
37
|
+
<!-------------------------------------------------------------------------->
|
38
|
+
|
39
|
+
<h2>DBFCreate()</h2>
|
40
|
+
|
41
|
+
<pre>
|
42
|
+
DBFHandle DBFCreate( const char * pszDBFFile );
|
43
|
+
|
44
|
+
pszDBFFile: The name of the xBase (.dbf) file to create.
|
45
|
+
</pre>
|
46
|
+
|
47
|
+
The DBFCreate() function creates a new xBase format file with the given
|
48
|
+
name, and returns an access handle that can be used with other DBF functions.
|
49
|
+
The newly created file will have no fields, and no records. Fields should
|
50
|
+
be added with DBFAddField() before any records add written.
|
51
|
+
|
52
|
+
<!-------------------------------------------------------------------------->
|
53
|
+
|
54
|
+
<h2>DBFGetFieldCount()</h2>
|
55
|
+
|
56
|
+
<pre>
|
57
|
+
int DBFGetFieldCount( DBFHandle hDBF );
|
58
|
+
|
59
|
+
hDBF: The access handle for the file to be queried, as returned
|
60
|
+
by DBFOpen(), or DBFCreate().
|
61
|
+
</pre>
|
62
|
+
|
63
|
+
The DBFGetFieldCount() function returns the number of fields currently
|
64
|
+
defined for the indicated xBase file.
|
65
|
+
|
66
|
+
<!-------------------------------------------------------------------------->
|
67
|
+
|
68
|
+
<h2>DBFGetRecordCount()</h2>
|
69
|
+
|
70
|
+
<pre>
|
71
|
+
int DBFGetRecordCount( DBFHandle hDBF );
|
72
|
+
|
73
|
+
hDBF: The access handle for the file to be queried, as returned by
|
74
|
+
DBFOpen(), or DBFCreate().
|
75
|
+
</pre>
|
76
|
+
|
77
|
+
The DBFGetRecordCount() function returns the number of records that
|
78
|
+
exist on the xBase file currently. Note that with shape files one xBase
|
79
|
+
record exists for each shape in the .shp/.shx files.<p>
|
80
|
+
|
81
|
+
<!-------------------------------------------------------------------------->
|
82
|
+
|
83
|
+
<h2>DBFGetFieldIndex()</h2>
|
84
|
+
|
85
|
+
<pre>
|
86
|
+
int DBFGetFieldIndex( DBFHandle hDBF, const char *pszFieldName );
|
87
|
+
|
88
|
+
hDBF: The access handle for the file to be queried, as returned by
|
89
|
+
DBFOpen(), or DBFCreate().
|
90
|
+
|
91
|
+
pszFieldName: Name of the field to search for.
|
92
|
+
</pre>
|
93
|
+
|
94
|
+
Returns the index of the field matching this name, or -1 on failure. The
|
95
|
+
comparison is case insensitive. However, lengths must match exactly.<p>
|
96
|
+
|
97
|
+
<!-------------------------------------------------------------------------->
|
98
|
+
|
99
|
+
<h2>DBFGetFieldInfo()</h2>
|
100
|
+
|
101
|
+
<pre>
|
102
|
+
DBFFieldType DBFGetFieldInfo( DBFHandle hDBF, int iField, char * pszFieldName,
|
103
|
+
int * pnWidth, int * pnDecimals );
|
104
|
+
|
105
|
+
hDBF: The access handle for the file to be queried, as returned by
|
106
|
+
DBFOpen(), or DBFCreate().
|
107
|
+
|
108
|
+
iField: The field to be queried. This should be a number between
|
109
|
+
0 and n-1, where n is the number fields on the file, as
|
110
|
+
returned by DBFGetFieldCount().
|
111
|
+
|
112
|
+
pszFieldName: If this pointer is not NULL the name of the requested field
|
113
|
+
will be written to this location. The pszFieldName buffer
|
114
|
+
should be at least 12 character is size in order to hold
|
115
|
+
the longest possible field name of 11 characters plus a
|
116
|
+
terminating zero character.
|
117
|
+
|
118
|
+
pnWidth: If this pointer is not NULL, the width of the requested field
|
119
|
+
will be returned in the int pointed to by pnWidth. This is
|
120
|
+
the width in characters.
|
121
|
+
|
122
|
+
pnDecimals: If this pointer is not NULL, the number of decimal places
|
123
|
+
precision defined for the field will be returned. This is
|
124
|
+
zero for integer fields, or non-numeric fields.
|
125
|
+
</pre>
|
126
|
+
|
127
|
+
The DBFGetFieldInfo() returns the type of the requested field, which is
|
128
|
+
one of the DBFFieldType enumerated values. As well, the field name, and
|
129
|
+
field width information can optionally be returned. The field type returned
|
130
|
+
does not correspond one to one with the xBase field types. For instance
|
131
|
+
the xBase field type for Date will just be returned as being FTInteger. <p>
|
132
|
+
|
133
|
+
<pre>
|
134
|
+
typedef enum {
|
135
|
+
FTString, /* fixed length string field */
|
136
|
+
FTInteger, /* numeric field with no decimals */
|
137
|
+
FTDouble, /* numeric field with decimals */
|
138
|
+
FTLogical, /* logical field. */
|
139
|
+
FTInvalid /* not a recognised field type */
|
140
|
+
} DBFFieldType;
|
141
|
+
</pre>
|
142
|
+
|
143
|
+
<!-------------------------------------------------------------------------->
|
144
|
+
|
145
|
+
<h2>DBFAddField()</h2>
|
146
|
+
|
147
|
+
<pre>
|
148
|
+
int DBFAddField( DBFHandle hDBF, const char * pszFieldName,
|
149
|
+
DBFFieldType eType, int nWidth, int nDecimals );
|
150
|
+
|
151
|
+
hDBF: The access handle for the file to be updated, as returned by
|
152
|
+
DBFOpen(), or DBFCreate().
|
153
|
+
|
154
|
+
pszFieldName: The name of the new field. At most 11 character will be used.
|
155
|
+
In order to use the xBase file in some packages it may be
|
156
|
+
necessary to avoid some special characters in the field names
|
157
|
+
such as spaces, or arithmetic operators.
|
158
|
+
|
159
|
+
eType: One of FTString, FTInteger or FTDouble in order to establish
|
160
|
+
the type of the new field. Note that some valid xBase field
|
161
|
+
types cannot be created such as date fields.
|
162
|
+
|
163
|
+
nWidth: The width of the field to be created. For FTString fields this
|
164
|
+
establishes the maximum length of string that can be stored.
|
165
|
+
For FTInteger this establishes the number of digits of the
|
166
|
+
largest number that can
|
167
|
+
be represented. For FTDouble fields this in combination
|
168
|
+
with the nDecimals value establish the size, and precision
|
169
|
+
of the created field.
|
170
|
+
|
171
|
+
nDecimals: The number of decimal places to reserve for FTDouble fields.
|
172
|
+
For all other field types this should be zero. For instance
|
173
|
+
with nWidth=7, and nDecimals=3 numbers would be formatted
|
174
|
+
similarly to `123.456'.
|
175
|
+
</pre>
|
176
|
+
|
177
|
+
The DBFAddField() function is used to add new fields to an existing xBase
|
178
|
+
file opened with DBFOpen(), or created with DBFCreate(). Note that fields
|
179
|
+
can only be added to xBase files with no records, though this is limitation
|
180
|
+
of this API, not of the file format.<p>
|
181
|
+
|
182
|
+
The DBFAddField() return value is the field number of the new field, or
|
183
|
+
-1 if the addition of the field failed.<p>
|
184
|
+
|
185
|
+
<!-------------------------------------------------------------------------->
|
186
|
+
|
187
|
+
<h2>DBFReadIntegerAttribute()</h2>
|
188
|
+
|
189
|
+
<pre>
|
190
|
+
int DBFReadIntegerAttribute( DBFHandle hDBF, int iShape, int iField );
|
191
|
+
|
192
|
+
hDBF: The access handle for the file to be queried, as returned by
|
193
|
+
DBFOpen(), or DBFCreate().
|
194
|
+
|
195
|
+
iShape: The record number (shape number) from which the field value
|
196
|
+
should be read.
|
197
|
+
|
198
|
+
iField: The field within the selected record that should be read.
|
199
|
+
</pre>
|
200
|
+
|
201
|
+
The DBFReadIntegerAttribute() will read the value of one field and return
|
202
|
+
it as an integer. This can be used even with FTString fields, though the
|
203
|
+
returned value will be zero if not interpretable as a number.<p>
|
204
|
+
|
205
|
+
<!-------------------------------------------------------------------------->
|
206
|
+
|
207
|
+
<h2>DBFReadDoubleAttribute()</h2>
|
208
|
+
|
209
|
+
<pre>
|
210
|
+
double DBFReadDoubleAttribute( DBFHandle hDBF, int iShape, int iField );
|
211
|
+
|
212
|
+
hDBF: The access handle for the file to be queried, as returned by
|
213
|
+
DBFOpen(), or DBFCreate().
|
214
|
+
|
215
|
+
iShape: The record number (shape number) from which the field value
|
216
|
+
should be read.
|
217
|
+
|
218
|
+
iField: The field within the selected record that should be read.
|
219
|
+
</pre>
|
220
|
+
|
221
|
+
The DBFReadDoubleAttribute() will read the value of one field and return
|
222
|
+
it as a double. This can be used even with FTString fields, though the
|
223
|
+
returned value will be zero if not interpretable as a number.<p>
|
224
|
+
|
225
|
+
<!-------------------------------------------------------------------------->
|
226
|
+
|
227
|
+
<h2>DBFReadStringAttribute()</h2>
|
228
|
+
|
229
|
+
<pre>
|
230
|
+
const char *DBFReadStringAttribute( DBFHandle hDBF, int iShape, int iField );
|
231
|
+
|
232
|
+
hDBF: The access handle for the file to be queried, as returned by
|
233
|
+
DBFOpen(), or DBFCreate().
|
234
|
+
|
235
|
+
iShape: The record number (shape number) from which the field value
|
236
|
+
should be read.
|
237
|
+
|
238
|
+
iField: The field within the selected record that should be read.
|
239
|
+
</pre>
|
240
|
+
|
241
|
+
The DBFReadStringAttribute() will read the value of one field and return
|
242
|
+
it as a string. This function may be used on any field type (including
|
243
|
+
FTInteger and FTDouble) and will return the string representation stored
|
244
|
+
in the .dbf file. The returned pointer is to an internal buffer
|
245
|
+
which is only valid untill the next DBF function call. It's contents may
|
246
|
+
be copied with normal string functions such as strcpy(), or strdup(). If
|
247
|
+
the TRIM_DBF_WHITESPACE macro is defined in shapefil.h (it is by default)
|
248
|
+
then all leading and trailing space (ASCII 32) characters will be stripped
|
249
|
+
before the string is returned.<p>
|
250
|
+
|
251
|
+
<!-------------------------------------------------------------------------->
|
252
|
+
|
253
|
+
<h2>DBFIsAttributeNULL()</h2>
|
254
|
+
|
255
|
+
<pre>
|
256
|
+
int DBFIsAttributeNULL( DBFHandle hDBF, int iShape, int iField );
|
257
|
+
|
258
|
+
hDBF: The access handle for the file to be queried, as returned by
|
259
|
+
DBFOpen(), or DBFCreate().
|
260
|
+
|
261
|
+
iShape: The record number (shape number) from which the field value
|
262
|
+
should be read.
|
263
|
+
|
264
|
+
iField: The field within the selected record that should be read.
|
265
|
+
</pre>
|
266
|
+
|
267
|
+
This function will return TRUE if the indicated field is NULL valued
|
268
|
+
otherwise FALSE. Note that NULL fields are represented in the .dbf file
|
269
|
+
as having all spaces in the field. Reading NULL fields will result in
|
270
|
+
a value of 0.0 or an empty string with the other DBFRead*Attribute()
|
271
|
+
functions.<p>
|
272
|
+
|
273
|
+
<!-------------------------------------------------------------------------->
|
274
|
+
|
275
|
+
<h2>DBFWriteIntegerAttribute</h2>
|
276
|
+
|
277
|
+
<pre>
|
278
|
+
int DBFWriteIntegerAttribute( DBFHandle hDBF, int iShape, int iField,
|
279
|
+
int nFieldValue );
|
280
|
+
|
281
|
+
hDBF: The access handle for the file to be written, as returned by
|
282
|
+
DBFOpen(), or DBFCreate().
|
283
|
+
|
284
|
+
iShape: The record number (shape number) to which the field value
|
285
|
+
should be written.
|
286
|
+
|
287
|
+
iField: The field within the selected record that should be written.
|
288
|
+
|
289
|
+
nFieldValue: The integer value that should be written.
|
290
|
+
</pre>
|
291
|
+
|
292
|
+
The DBFWriteIntegerAttribute() function is used to write a value to a numeric
|
293
|
+
field (FTInteger, or FTDouble). If the write succeeds the value TRUE will
|
294
|
+
be returned, otherwise FALSE will be returned. If the value is too large to
|
295
|
+
fit in the field, it will be truncated and FALSE returned.<p>
|
296
|
+
|
297
|
+
<!-------------------------------------------------------------------------->
|
298
|
+
|
299
|
+
<h2>DBFWriteDoubleAttribute()</h2>
|
300
|
+
|
301
|
+
<pre>
|
302
|
+
int DBFWriteDoubleAttribute( DBFHandle hDBF, int iShape, int iField,
|
303
|
+
double dFieldValue );
|
304
|
+
|
305
|
+
hDBF: The access handle for the file to be written, as returned by
|
306
|
+
DBFOpen(), or DBFCreate().
|
307
|
+
|
308
|
+
iShape: The record number (shape number) to which the field value
|
309
|
+
should be written.
|
310
|
+
|
311
|
+
iField: The field within the selected record that should be written.
|
312
|
+
|
313
|
+
dFieldValue: The floating point value that should be written.
|
314
|
+
</pre>
|
315
|
+
|
316
|
+
The DBFWriteDoubleAttribute() function is used to write a value to a numeric
|
317
|
+
field (FTInteger, or FTDouble). If the write succeeds the value TRUE will
|
318
|
+
be returned, otherwise FALSE will be returned. If the value is too large to
|
319
|
+
fit in the field, it will be truncated and FALSE returned.<p>
|
320
|
+
|
321
|
+
<!-------------------------------------------------------------------------->
|
322
|
+
|
323
|
+
<h2>DBFWriteStringAttribute()</h2>
|
324
|
+
|
325
|
+
<pre>
|
326
|
+
int DBFWriteStringAttribute( DBFHandle hDBF, int iShape, int iField,
|
327
|
+
const char * pszFieldValue );
|
328
|
+
|
329
|
+
hDBF: The access handle for the file to be written, as returned by
|
330
|
+
DBFOpen(), or DBFCreate().
|
331
|
+
|
332
|
+
iShape: The record number (shape number) to which the field value
|
333
|
+
should be written.
|
334
|
+
|
335
|
+
iField: The field within the selected record that should be written.
|
336
|
+
|
337
|
+
pszFieldValue: The string to be written to the field.
|
338
|
+
</pre>
|
339
|
+
|
340
|
+
The DBFWriteStringAttribute() function is used to write a value to a string
|
341
|
+
field (FString). If the write succeeds the value TRUE willbe returned,
|
342
|
+
otherwise FALSE will be returned. If the value is too large to
|
343
|
+
fit in the field, it will be truncated and FALSE returned.<p>
|
344
|
+
|
345
|
+
<!-------------------------------------------------------------------------->
|
346
|
+
|
347
|
+
<h2>DBFWriteNULLAttribute()</h2>
|
348
|
+
|
349
|
+
<pre>
|
350
|
+
int DBFWriteNULLAttribute( DBFHandle hDBF, int iShape, int iField );
|
351
|
+
|
352
|
+
hDBF: The access handle for the file to be written, as returned by
|
353
|
+
DBFOpen(), or DBFCreate().
|
354
|
+
|
355
|
+
iShape: The record number (shape number) to which the field value
|
356
|
+
should be written.
|
357
|
+
|
358
|
+
iField: The field within the selected record that should be written.
|
359
|
+
</pre>
|
360
|
+
|
361
|
+
The DBFWriteNULLAttribute() function is used to clear the indicated field
|
362
|
+
to a NULL value. In the .dbf file this is represented by setting the entire
|
363
|
+
field to spaces. If the write succeeds the value TRUE willbe returned,
|
364
|
+
otherwise FALSE will be returned.<p>
|
365
|
+
|
366
|
+
<!-------------------------------------------------------------------------->
|
367
|
+
|
368
|
+
<h2>DBFClose()</h2>
|
369
|
+
|
370
|
+
<pre>
|
371
|
+
void DBFClose( DBFHandle hDBF );
|
372
|
+
|
373
|
+
hDBF: The access handle for the file to be closed.
|
374
|
+
</pre>
|
375
|
+
|
376
|
+
The DBFClose() function will close the indicated xBase file (opened with
|
377
|
+
DBFOpen(), or DBFCreate()), flushing out all information to the file on
|
378
|
+
disk, and recovering any resources associated with having the file open.
|
379
|
+
The file handle (hDBF) should not be used again with the DBF API after
|
380
|
+
calling DBFClose().<p>
|
381
|
+
|
382
|
+
<!-------------------------------------------------------------------------->
|
383
|
+
|
384
|
+
<h2>DBFIsRecordDeleted()</h2>
|
385
|
+
|
386
|
+
<pre>
|
387
|
+
int DBFIsRecordDeleted( DBFHandle hDBF, int iShape );
|
388
|
+
|
389
|
+
hDBF: The access handle for the file to be checked.
|
390
|
+
iShape: The record index to check.
|
391
|
+
</pre>
|
392
|
+
|
393
|
+
Returns TRUE (non-zero) if the record is marked for deletion, otherwise
|
394
|
+
it returns FALSE.<p>
|
395
|
+
|
396
|
+
<!-------------------------------------------------------------------------->
|
397
|
+
|
398
|
+
<h2>DBFMarkRecordDeleted()</h2>
|
399
|
+
|
400
|
+
<pre>
|
401
|
+
int DBFMarkRecordDeleted( DBFHandle hDBF, int iShape, int bIsDeleted );
|
402
|
+
|
403
|
+
hDBF: The access handle for the file.
|
404
|
+
iShape: The record index to update.
|
405
|
+
bIsDeleted: TRUE to mark record deleted, or FALSE to undelete it.
|
406
|
+
</pre>
|
407
|
+
|
408
|
+
Returns TRUE on success, or FALSE on error.<p>
|
409
|
+
|
410
|
+
<!-------------------------------------------------------------------------->
|
411
|
+
|
412
|
+
<h2>DBFGetNativeFieldType()</h2>
|
413
|
+
|
414
|
+
<pre>
|
415
|
+
char DBFGetNativeFieldType( DBFHandle hDBF, int iField );
|
416
|
+
|
417
|
+
hDBF: The access handle for the file.
|
418
|
+
iField: The field index to query.
|
419
|
+
|
420
|
+
</pre>
|
421
|
+
|
422
|
+
This function returns the DBF type code of the indicated field. It will
|
423
|
+
be one of:<p>
|
424
|
+
|
425
|
+
<ul>
|
426
|
+
<li> 'C' (String)
|
427
|
+
<li> 'D' (Date)
|
428
|
+
<li> 'F' (Float)
|
429
|
+
<li> 'N' (Numeric, with or without decimal)
|
430
|
+
<li> 'L' (Logical)
|
431
|
+
<li> 'M' (Memo: 10 digits .DBT block ptr)
|
432
|
+
<li> ' ' (field out of range)
|
433
|
+
</ul>
|
434
|
+
|
435
|
+
</body>
|
436
|
+
</html>
|
@@ -0,0 +1,235 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>Shapefile C Library V1.2</title>
|
4
|
+
<link href="http://www.maptools.org/maptools.css" rel="stylesheet" type="text/css">
|
5
|
+
</head>
|
6
|
+
|
7
|
+
<body>
|
8
|
+
<h1>Shapefile C Library V1.2</h1>
|
9
|
+
|
10
|
+
<h2>Purpose</h2>
|
11
|
+
|
12
|
+
The Shapefile C Library provides the ability to write simple C programs
|
13
|
+
for reading, writing and updating (to a limited extent) ESRI Shapefiles,
|
14
|
+
and the associated attribute file (.dbf).<p>
|
15
|
+
|
16
|
+
<h2>Supporting Information</h2>
|
17
|
+
|
18
|
+
<ul>
|
19
|
+
<li> <a href="shp_api.html">Shapefile API Docs</a>
|
20
|
+
<li> <a href="dbf_api.html">DBF/xBase API Docs</a>
|
21
|
+
<li> <a href="shapelib-tools.html">Shapefile Tools Docs</a>
|
22
|
+
<li> <a href="release.html">Release Notes</a>
|
23
|
+
<li> <a href="manifest.html">Shapelib File Manifest</a>
|
24
|
+
<li> <a href="license.html">Shapelib Licensing Terms</a>
|
25
|
+
</ul>
|
26
|
+
|
27
|
+
<h2>What is a Shapefile?</h2>
|
28
|
+
|
29
|
+
If you don't know, you probably don't need this library. The Shapefile
|
30
|
+
format is a working and interchange format promulagated by
|
31
|
+
<a href="http://www.esri.com/">ESRI</a> for simple vector data with attributes.
|
32
|
+
<p>
|
33
|
+
|
34
|
+
An excellent <a href="dl/shapefile.pdf">white paper</a> on the shapefile format
|
35
|
+
is available from ESRI,
|
36
|
+
but it is .pdf format, so you will need Adobe Acrobat to browse it.<p>
|
37
|
+
|
38
|
+
The file format actually consists of three files.<p>
|
39
|
+
|
40
|
+
<pre>
|
41
|
+
XXX.shp - holds the actual vertices.
|
42
|
+
XXX.shx - hold index data pointing to the structures in the .shp file.
|
43
|
+
XXX.dbf - holds the attributes in xBase (dBase) format.
|
44
|
+
</pre>
|
45
|
+
|
46
|
+
<h2>Download</h2>
|
47
|
+
|
48
|
+
Source code, and some other odds and ends can be downloaded from
|
49
|
+
<a href="http://download.osgeo.org/shapelib">http://download.osgeo.org/shapelib</a> or <a href="http://shapelib.maptools.org/dl">http://shapelib.maptools.org/dl</a>.<p>
|
50
|
+
|
51
|
+
Shapelib is available for anonymous CVS access:
|
52
|
+
|
53
|
+
<pre>
|
54
|
+
cvs -d :pserver:cvsanon@cvs.maptools.org:/cvs/maptools/cvsroot login
|
55
|
+
Password: (hit enter)
|
56
|
+
cvs -d :pserver:cvsanon@cvs.maptools.org:/cvs/maptools/cvsroot co shapelib
|
57
|
+
</pre>
|
58
|
+
|
59
|
+
<h2>Bugs, Maintainance and Support</h2>
|
60
|
+
|
61
|
+
This library is maintained by <a href="http://pobox.com/~warmerdam">Frank
|
62
|
+
Warmerdam</a>. Please send me bug reports, patches and suggestions for the
|
63
|
+
library via the <a href="http://bugzilla.maptools.org/enter_bug.cgi?product=Shapelib">maptools.org Bugzilla</a>. Shapelib bugs can also be
|
64
|
+
<a href="http://bugzilla.maptools.org/query.cgi?product=Shapelib">queried</a>.
|
65
|
+
<p>
|
66
|
+
|
67
|
+
Shapelib is hosted at
|
68
|
+
<a href="http://shapelib.maptools.org">shapelib.maptools.org</a>. A mailing
|
69
|
+
list for discussion of how to use shapelib, and announcing new releases
|
70
|
+
<a href="http://lists.maptools.org/mailman/listinfo/shapelib/">is
|
71
|
+
available</a>. To only find out about new releases of Shapelib select the
|
72
|
+
"<i>Subscribe to new releases</i>" option from the link at
|
73
|
+
<a href="http://freshmeat.net/projects/shapelib/">Freshmeat</a>.<p>
|
74
|
+
|
75
|
+
<h2>Credits</h2>
|
76
|
+
|
77
|
+
I didn't start this section anywhere near soon enough, so alot of earlier
|
78
|
+
contributors to Shapelib are lost in pre-history.
|
79
|
+
|
80
|
+
<ul>
|
81
|
+
<li> Bill Miller (NY-DOT) for shputils.c
|
82
|
+
<li> Carl Anderson for the contents of the contrib directory, and
|
83
|
+
the "tuple" additions to dbfopen.c.
|
84
|
+
<li> Andrea Giacomelli for patches for dbfopen.c.
|
85
|
+
<li> Doug Matthews for portability improvements.
|
86
|
+
<li> Jan-Oliver Wagner for convincing me to make it available under LGPL,
|
87
|
+
shared library support, and various other patches.
|
88
|
+
<li> Dennis Christopher (of Avenza) for testing and bug fixes.
|
89
|
+
<li> Miko Syrj� (of 3D-system Oy) for a record size bug fix.
|
90
|
+
<li> Steven Lime and Curtis Hill for help with NULL shapes.
|
91
|
+
<li> Jim Matthews for support of NULL attributes in dbf files.
|
92
|
+
<li> <a href="http://www.pcigeomatics.com/">PCI Geomatics</a> who let me
|
93
|
+
release a modified version of their shapefile code in the beginning and
|
94
|
+
who hosted shapelib for years.
|
95
|
+
</ul>
|
96
|
+
|
97
|
+
<h2>In Memorium</h2>
|
98
|
+
|
99
|
+
I would like to dedicate Shapelib to the memory of Sol Katz. While I never
|
100
|
+
met him in person, his generous contributions to the GIS community took
|
101
|
+
many forms, including free distribution of a variety of GIS translators
|
102
|
+
with source. The fact that he used this Shapelib in some of his utilities,
|
103
|
+
and thanked me was a great encouragement to me. I hope I can do his memory
|
104
|
+
honour by trying to contribute in a similar fashion.<p>
|
105
|
+
|
106
|
+
<h2>Portability</h2>
|
107
|
+
|
108
|
+
The Shapefile C Library should port easily to 32bit systems with ANSI C
|
109
|
+
compilers. It should work on 64 bit architectures (such as the DEC AXP).<p>
|
110
|
+
|
111
|
+
Care should also be taken to pass the binary access flag into SHPOpen()
|
112
|
+
and DBFOpen() when operating on systems with special text file translation
|
113
|
+
such as MSDOS.<p>
|
114
|
+
|
115
|
+
The shputils.c module is contributed, and may not take the same approach
|
116
|
+
to portability as the rest of the package.<p>
|
117
|
+
|
118
|
+
On Linux, and most unix systems it should be possible to build and
|
119
|
+
install shapefile support as a shared library using the "lib" and "lib_install"
|
120
|
+
targets of the Makefile. Note that this Makefile doesn't use autoconf
|
121
|
+
mechanisms and will generally require some hand tailoring for your environment.
|
122
|
+
|
123
|
+
<h2>Limitations</h2>
|
124
|
+
|
125
|
+
<ul>
|
126
|
+
|
127
|
+
<li> You can't modify the vertices of existing structures (though you
|
128
|
+
can update the attributes of existing structures, and create new
|
129
|
+
structures).<p>
|
130
|
+
|
131
|
+
<li> Not written in such a way as to be particularly fast. This is
|
132
|
+
particularly true of the 1.2 API. For applications more concerned with
|
133
|
+
speed it may be worth using the V1.1 API.<p>
|
134
|
+
|
135
|
+
<li> Doesn't set the last access time properly in the .dbf files.<p>
|
136
|
+
|
137
|
+
<li> There is no way to synchronize information to the file except to close it.
|
138
|
+
<p>
|
139
|
+
|
140
|
+
<li> Poor error checking and reporting.<p>
|
141
|
+
|
142
|
+
<li> Not professionally supported (well it can be, if you want to pay).<p>
|
143
|
+
|
144
|
+
<li> Some aspects of xBase files not supported, though I believe they are
|
145
|
+
not used by ESRI.<p>
|
146
|
+
|
147
|
+
<li> The application must keep the .dbf file in sync with the .shp/.shx
|
148
|
+
files through appropriate use of the DBF and SHP APIs.<p>
|
149
|
+
|
150
|
+
<li> No support for the undocumented .sbn/.sbx spatial index files.<p>
|
151
|
+
|
152
|
+
</ul>
|
153
|
+
|
154
|
+
<h2>Other Shapefile Resources</h2>
|
155
|
+
|
156
|
+
<ul>
|
157
|
+
<li> <a href="dl/shapefile.pdf">Shapefile Format Specifications (pdf)</a><p>
|
158
|
+
|
159
|
+
<li> <a href="http://www.clicketyclick.dk/databases/xbase/format/">Xbase (.dbf) File Format Description</a>. <p>
|
160
|
+
|
161
|
+
<li> <a href="codepage.html">Language ID / Code Page mappings</a><p>
|
162
|
+
|
163
|
+
<li> Shapelib is used within the multiformat
|
164
|
+
<a href="http://ogr.maptools.org/">OGR</a> library. If you are looking for a
|
165
|
+
high level C++ library with support for many geospatial vector formats you
|
166
|
+
might want to check it out.<p>
|
167
|
+
|
168
|
+
<li> Ari Jolma has produced an initial <b>perl</b> binding on top of shapelib,
|
169
|
+
which can be found at CPAN as Geo::ShapeFile under the
|
170
|
+
<a href="http://www.cpan.org/modules/by-module/Geo/">Geo</a> module.
|
171
|
+
<p>
|
172
|
+
|
173
|
+
<li> Bernhard Herzog has produced <b>python</b> bindings for Shapelib with
|
174
|
+
SWIG, available at <a href="http://ftp.intevation.de/users/bh/pyshapelib/">http://ftp.intevation.de/users/bh/pyshapelib</a>. A new version not using swig is
|
175
|
+
available as <a href="http://wald.intevation.org/plugins/scmsvn/viewcvs.php/trunk/thuban/libraries/pyshapelib/?root=thuban">part of Thuban</a>.<p>
|
176
|
+
|
177
|
+
<li> <a href="http://www.triplexware.huckfinn.de/shpapi.html">Delphi</a>
|
178
|
+
bindings for Shapelib courtesy of Alexander Weidauer.<p>
|
179
|
+
|
180
|
+
<li> Miguel Filgueiras has implemented
|
181
|
+
<a href="http://www.ncc.up.pt/gpsmanshp/">Tcl</a> bindings for Shapelib
|
182
|
+
as part of <a href="http://www.ncc.up.pt/gpsman/">GPSMan</a>.<p>
|
183
|
+
|
184
|
+
<li> David Gancarz has implemented a Microsoft
|
185
|
+
<a href="dl/contrib/DotNetArchive.zip">.NET wrapper</a> for
|
186
|
+
Shapelib. An example of using shapelib with VB6 is also icluded in the .NET wrapper project file.<p>
|
187
|
+
|
188
|
+
<li> Andrey Hristov (php at hristov dot com) has developed a PHP extension
|
189
|
+
based on Shapelib. It can be found in CVS at http://cvs.php.net/pecl/shp.<p>
|
190
|
+
|
191
|
+
<li> Toyoda Eizi has developed Ruby bindings found at
|
192
|
+
<a href="http://sourceforge.net/projects/ruby-shapelib">http://sourceforge.net/projects/ruby-shapelib</a>.<p>
|
193
|
+
|
194
|
+
<li> Davide Cesari has developed FORTRAN bindings that can be found at
|
195
|
+
<a href"http://www.webalice.it/o.drofa/davide/shapelib-fortran/">
|
196
|
+
http://www.webalice.it/o.drofa/davide/shapelib-fortran</a>.
|
197
|
+
|
198
|
+
<li> Jan-Oliver Wagner has implemented a commandline program
|
199
|
+
(<b>gen2shp</b>) for producing shapefiles from Arc/Info Generate format ASCII
|
200
|
+
files. He maintains a <a href="http://intevation.de/~jan/gen2shp">web page</a> for his work. <p>
|
201
|
+
|
202
|
+
<li> Tom Russo has implemented a shpcs2cs program, which reprojects shapefiles
|
203
|
+
using arguments similar to the PROJ.4 cs2cs program including datum conversion.
|
204
|
+
Use as an alternate to the contrib/shpproj which doesn't do datums. It is
|
205
|
+
available at the bottom of Tom's <a href="http://www.swcp.com/~russo/shape_web/">Xastir Shapefile Resources</a> page. <p>
|
206
|
+
|
207
|
+
<li>
|
208
|
+
Andrew Williamson's
|
209
|
+
<a href="http://www.geocities.com/SiliconValley/Haven/2295/useful.html">Useful
|
210
|
+
Scripts and Stuff</a> page for ArcView, which includes ShapeChecker.<p>
|
211
|
+
|
212
|
+
<li> The University of Bonn <a href="http://katla.giub.uni-bonn.de/sfjava/">
|
213
|
+
sf4java</a> project apparently includes Java classes for reading Shapefiles.<p>
|
214
|
+
|
215
|
+
<li> The <a href="http://gis.esri.com/arcscripts/details.cfm?CFGRIDKEY=628102085">ShapeIO2</a> Visual Basic libraries may be of interest to those wanting
|
216
|
+
VB access to Shapefiles. Also available <a href="http://shapelib.maptools.org/dl/contrib/ShapeIO2.zip">locally</a>.<p>
|
217
|
+
|
218
|
+
<li> The <a href="http://arcscripts.esri.com/details.asp?dbid=11810">ShapeFile Read/Write OCX</a> is another option for Visual Basic programmers.<p>
|
219
|
+
|
220
|
+
<li> <a href="http://www.casa.ucl.ac.uk/sanjay/software_isovistanalyst.htm">Isovist Analyst</a> is a sort-of-free isovist generating extension for
|
221
|
+
ArcView using shapelib.<p>
|
222
|
+
|
223
|
+
<li> <a href="http://www.obviously.com/gis/shpdiff/">shpdiff</a> utility
|
224
|
+
by Bryce Nesbitt.<p>
|
225
|
+
|
226
|
+
<li> <a href="http://www.aequometer.de/">Aequometer</a>: a program for
|
227
|
+
MS Excel to calculate the area of polygons and export as shapefiles.<p>
|
228
|
+
|
229
|
+
</ul>
|
230
|
+
|
231
|
+
</body>
|
232
|
+
</html>
|
233
|
+
|
234
|
+
|
235
|
+
|