Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/******************************************************************************
* $Id: shpopen.c,v 1.76 2017-09-10 10:11:36 erouault Exp $
*
* Project: Shapelib
* Purpose: Implementation of core Shapefile read/write functions.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 1999, 2001, Frank Warmerdam
* Copyright (c) 2011-2013, Even Rouault <even dot rouault at mines-paris dot org>
*
* This software is available under the following "MIT Style" license,
* or at the option of the licensee under the LGPL (see COPYING). This
* option is discussed in more detail in shapelib.html.
*
* --
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************
*
* $Log: shpopen.c,v $
* Revision 1.76 2017-09-10 10:11:36 erouault
* * shpopen.c: resync with GDAL copy. Make sure to zero terminate all
* error messages. And fix regression regarding re-writing the last shape
* of a file (https://trac.osgeo.org/gdal/ticket/7031)
*
* Revision 1.75 2016-12-05 12:44:05 erouault
* * Major overhaul of Makefile build system to use autoconf/automake.
*
* * Warning fixes in contrib/
*
* Revision 1.74 2016-12-04 15:30:15 erouault
* * shpopen.c, dbfopen.c, shptree.c, shapefil.h: resync with
* GDAL Shapefile driver. Mostly cleanups. SHPObject and DBFInfo
* structures extended with new members. New functions:
* DBFSetLastModifiedDate, SHPOpenLLEx, SHPRestoreSHX,
* SHPSetFastModeReadObject
*
* * sbnsearch.c: new file to implement original ESRI .sbn spatial
* index reading. (no write support). New functions:
* SBNOpenDiskTree, SBNCloseDiskTree, SBNSearchDiskTree,
* SBNSearchDiskTreeInteger, SBNSearchFreeIds
*
* * Makefile, makefile.vc, CMakeLists.txt, shapelib.def: updates
* with new file and symbols.
*
* * commit: helper script to cvs commit
*
* Revision 1.73 2012-01-24 22:33:01 fwarmerdam
* fix memory leak on failure to open .shp (gdal #4410)
*
* Revision 1.72 2011-12-11 22:45:28 fwarmerdam
* fix failure return from SHPOpenLL.
*
* Revision 1.71 2011-09-15 03:33:58 fwarmerdam
* fix missing cast (#2344)
*
* Revision 1.70 2011-07-24 05:59:25 fwarmerdam
* minimize use of CPLError in favor of SAHooks.Error()
*
* Revision 1.69 2011-07-24 03:24:22 fwarmerdam
* fix memory leaks in error cases creating shapefiles (#2061)
*
* Revision 1.68 2010-08-27 23:42:52 fwarmerdam
* add SHPAPI_CALL attribute in code
*
* Revision 1.67 2010-07-01 08:15:48 fwarmerdam
* do not error out on an object with zero vertices
*
* Revision 1.66 2010-07-01 07:58:57 fwarmerdam
* minor cleanup of error handling
*
* Revision 1.65 2010-07-01 07:27:13 fwarmerdam
* white space formatting adjustments
*
* Revision 1.64 2010-01-28 11:34:34 fwarmerdam
* handle the shape file length limits more gracefully (#3236)
*
* Revision 1.63 2010-01-28 04:04:40 fwarmerdam
* improve numerical accuracy of SHPRewind() algs (gdal #3363)
*
* Revision 1.62 2010-01-17 05:34:13 fwarmerdam
* Remove asserts on x/y being null (#2148).
*
* Revision 1.61 2010-01-16 05:07:42 fwarmerdam
* allow 0/nulls in shpcreateobject (#2148)
*
* Revision 1.60 2009-09-17 20:50:02 bram
* on Win32, define snprintf as alias to _snprintf
*
* Revision 1.59 2008-03-14 05:25:31 fwarmerdam
* Correct crash on buggy geometries (gdal #2218)
*
* Revision 1.58 2008/01/08 23:28:26 bram
* on line 2095, use a float instead of a double to avoid a compiler warning
*
* Revision 1.57 2007/12/06 07:00:25 fwarmerdam
* dbfopen now using SAHooks for fileio
*
* Revision 1.56 2007/12/04 20:37:56 fwarmerdam
* preliminary implementation of hooks api for io and errors
*
* Revision 1.55 2007/11/21 22:39:56 fwarmerdam
* close shx file in readonly mode (GDAL #1956)
*
* Revision 1.54 2007/11/15 00:12:47 mloskot
* Backported recent changes from GDAL (Ticket #1415) to Shapelib.
*
* Revision 1.53 2007/11/14 22:31:08 fwarmerdam
* checks after mallocs to detect for corrupted/voluntary broken shapefiles.
* http://trac.osgeo.org/gdal/ticket/1991
*
* Revision 1.52 2007/06/21 15:58:33 fwarmerdam
* fix for SHPRewindObject when rings touch at one vertex (gdal #976)
*
* Revision 1.51 2006/09/04 15:24:01 fwarmerdam
* Fixed up log message for 1.49.
*
* Revision 1.50 2006/09/04 15:21:39 fwarmerdam
* fix of last fix
*
* Revision 1.49 2006/09/04 15:21:00 fwarmerdam
* MLoskot: Added stronger test of Shapefile reading failures, e.g. truncated
* files. The problem was discovered by Tim Sutton and reported here
* https://svn.qgis.org/trac/ticket/200
*
* Revision 1.48 2006/01/26 15:07:32 fwarmerdam
* add bMeasureIsUsed flag from Craig Bruce: Bug 1249
*
* Revision 1.47 2006/01/04 20:07:23 fwarmerdam
* In SHPWriteObject() make sure that the record length is updated
* when rewriting an existing record.
*
* Revision 1.46 2005/02/11 17:17:46 fwarmerdam
* added panPartStart[0] validation
*
* Revision 1.45 2004/09/26 20:09:48 fwarmerdam
* const correctness changes
*
* Revision 1.44 2003/12/29 00:18:39 fwarmerdam
* added error checking for failed IO and optional CPL error reporting
*
* Revision 1.43 2003/12/01 16:20:08 warmerda
* be careful of zero vertex shapes
*
* Revision 1.42 2003/12/01 14:58:27 warmerda
* added degenerate object check in SHPRewindObject()
*
* Revision 1.41 2003/07/08 15:22:43 warmerda
* avoid warning
*
* Revision 1.40 2003/04/21 18:30:37 warmerda
* added header write/update public methods
*
* Revision 1.39 2002/08/26 06:46:56 warmerda
* avoid c++ comments
*
* Revision 1.38 2002/05/07 16:43:39 warmerda
* Removed debugging printf()
*
* Revision 1.37 2002/04/10 17:35:22 warmerda
* fixed bug in ring reversal code
*
* Revision 1.36 2002/04/10 16:59:54 warmerda
* added SHPRewindObject
*
* Revision 1.35 2001/12/07 15:10:44 warmerda
* fix if .shx fails to open
*
* Revision 1.34 2001/11/01 16:29:55 warmerda
* move pabyRec into SHPInfo for thread safety
*
* Revision 1.33 2001/07/03 12:18:15 warmerda
* Improved cleanup if SHX not found, provided by Riccardo Cohen.
*
* Revision 1.32 2001/06/22 01:58:07 warmerda
* be more careful about establishing initial bounds in face of NULL shapes
*
* Revision 1.31 2001/05/31 19:35:29 warmerda
* added support for writing null shapes
*
* Revision 1.30 2001/05/28 12:46:29 warmerda
* Add some checking on reasonableness of record count when opening.
*
Loading
Loading full blame...