filegdb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +18 -0
  3. data/.travis.yml +4 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE +28 -0
  6. data/Makefile +12 -0
  7. data/README.md +27 -0
  8. data/Rakefile +24 -0
  9. data/ext/filegdb/base.hpp +126 -0
  10. data/ext/filegdb/extconf.rb +13 -0
  11. data/ext/filegdb/filegdb.cpp +27 -0
  12. data/ext/filegdb/filegdb.hpp +44 -0
  13. data/ext/filegdb/filegdb/include/FileGDBAPI.h +30 -0
  14. data/ext/filegdb/filegdb/include/FileGDBCore.h +226 -0
  15. data/ext/filegdb/filegdb/include/Geodatabase.h +291 -0
  16. data/ext/filegdb/filegdb/include/GeodatabaseManagement.h +79 -0
  17. data/ext/filegdb/filegdb/include/Raster.h +101 -0
  18. data/ext/filegdb/filegdb/include/Row.h +336 -0
  19. data/ext/filegdb/filegdb/include/Table.h +296 -0
  20. data/ext/filegdb/filegdb/include/Util.h +936 -0
  21. data/ext/filegdb/filegdb/include/make.include +98 -0
  22. data/ext/filegdb/filegdb/lib/libFileGDBAPI.dylib +0 -0
  23. data/ext/filegdb/filegdb/lib/libFileGDBAPI.so +0 -0
  24. data/ext/filegdb/filegdb/lib/libfgdbunixrtl.dylib +0 -0
  25. data/ext/filegdb/filegdb/lib/libfgdbunixrtl.so +0 -0
  26. data/ext/filegdb/geodatabase.cpp +529 -0
  27. data/ext/filegdb/geodatabase.hpp +53 -0
  28. data/ext/filegdb/multi_point_shape_buffer.cpp +254 -0
  29. data/ext/filegdb/multi_point_shape_buffer.hpp +35 -0
  30. data/ext/filegdb/point.cpp +44 -0
  31. data/ext/filegdb/point.hpp +31 -0
  32. data/ext/filegdb/point_shape_buffer.cpp +162 -0
  33. data/ext/filegdb/point_shape_buffer.hpp +32 -0
  34. data/ext/filegdb/row.cpp +222 -0
  35. data/ext/filegdb/row.hpp +37 -0
  36. data/ext/filegdb/shape_buffer.cpp +19 -0
  37. data/ext/filegdb/shape_buffer.hpp +20 -0
  38. data/ext/filegdb/shape_buffer_base.hpp +33 -0
  39. data/ext/filegdb/table.cpp +65 -0
  40. data/ext/filegdb/table.hpp +29 -0
  41. data/ext/filegdb/util.cpp +16 -0
  42. data/filegdb.gemspec +23 -0
  43. data/lib/filegdb.rb +2 -0
  44. data/lib/filegdb/version.rb +3 -0
  45. data/spec/data/domain_definition.xml +22 -0
  46. data/spec/data/domain_definition_altered.xml +26 -0
  47. data/spec/data/feature_dataset_definition.xml +25 -0
  48. data/spec/data/table_definition.xml +177 -0
  49. data/spec/filegdb_spec.rb +36 -0
  50. data/spec/geodatabase_spec.rb +107 -0
  51. data/spec/multi_point_shape_buffer_spec.rb +58 -0
  52. data/spec/point_shape_buffer_spec.rb +39 -0
  53. data/spec/row_spec.rb +76 -0
  54. data/spec/spec_helper.rb +41 -0
  55. metadata +153 -0
@@ -0,0 +1,936 @@
1
+ //
2
+ // Util.h
3
+ //
4
+
5
+ /*
6
+ COPYRIGHT � 2012 ESRI
7
+ TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
8
+ Unpublished material - all rights reserved under the
9
+ Copyright Laws of the United States and applicable international
10
+ laws, treaties, and conventions.
11
+
12
+ For additional information, contact:
13
+ Environmental Systems Research Institute, Inc.
14
+ Attn: Contracts and Legal Services Department
15
+ 380 New York Street
16
+ Redlands, California, 92373
17
+ USA
18
+
19
+ email: contracts@esri.com
20
+ */
21
+
22
+ #pragma once
23
+
24
+ #include <string>
25
+ #include <vector>
26
+
27
+ #ifndef EXPORT_FILEGDB_API
28
+ # if defined linux || defined __APPLE__
29
+ # define EXT_FILEGDB_API
30
+ # else
31
+ # define EXT_FILEGDB_API _declspec(dllimport)
32
+ # endif
33
+ #else
34
+ # if defined linux || defined __APPLE__
35
+ # define EXT_FILEGDB_API __attribute__((visibility("default")))
36
+ # else
37
+ # define EXT_FILEGDB_API _declspec(dllexport)
38
+ # endif
39
+ #endif
40
+
41
+ #include "FileGDBCore.h"
42
+
43
+ struct IFields;
44
+ class SqlSelectCommand;
45
+
46
+ namespace FileGDBAPI
47
+ {
48
+
49
+ class Row;
50
+ class FieldInfo;
51
+ class FieldDef;
52
+ class Point;
53
+ class Curve;
54
+
55
+ /// An enumerator of rows. Used as a return type for table queries.
56
+
57
+ class EXT_FILEGDB_API EnumRows
58
+ {
59
+ public:
60
+
61
+ /// Returns the next available row in the enumerator, or null if no rows remain.
62
+ /// @param[out] row The next row in the enumerator.
63
+ /// @return Error code indicating whether the method finished successfully.
64
+ fgdbError Next(Row& row);
65
+
66
+ /// Closes the enumerator and releases any resources it is holding.
67
+ void Close();
68
+
69
+ /// Return information about the fields in the row.
70
+ /// @param[out] fieldInfo The field information.
71
+ /// @return Error code indicating whether the method finished successfully.
72
+ fgdbError GetFieldInformation(FieldInfo& fieldInfo) const;
73
+
74
+ /// Returns an array of FieldDef objects of the table's field collection.
75
+ /// @param[out] fieldDefs An array of FieldDef objects containing a collection of field definitions.
76
+ /// @return Error code indicating whether the method finished successfully.
77
+ fgdbError GetFields(std::vector<FieldDef>& fieldDefs) const;
78
+
79
+ /// @name Constructors and destructors
80
+ //@{
81
+ /// The class constructor.
82
+ EnumRows();
83
+
84
+ /// The class destructor.
85
+ ~EnumRows();
86
+ //@}
87
+
88
+ private:
89
+
90
+ /// @cond PRIVATE
91
+ fgdbError SetupRows(SqlSelectCommand* pSqlSelectCommand);
92
+ bool IsSetup() const;
93
+
94
+ SqlSelectCommand* m_pSqlSelectCommand;
95
+
96
+ friend class Geodatabase;
97
+ friend class Table;
98
+
99
+ EnumRows(const EnumRows&) { }
100
+ EnumRows& operator=(const EnumRows&) { return *this; }
101
+ /// @endcond
102
+ };
103
+
104
+ /// A utility class for spatial reference definitions
105
+ class EXT_FILEGDB_API SpatialReference
106
+ {
107
+ public:
108
+
109
+ SpatialReference();
110
+ ~SpatialReference();
111
+
112
+ fgdbError GetSpatialReferenceText(std::wstring& spatialReference) const;
113
+ fgdbError SetSpatialReferenceText(const std::wstring& spatialReference);
114
+
115
+ fgdbError GetSpatialReferenceID(int& wkid);
116
+ fgdbError SetSpatialReferenceID(int wkid);
117
+
118
+ fgdbError GetFalseOriginAndUnits(double& falseX, double& falseY, double& xyUnits);
119
+ fgdbError SetFalseOriginAndUnits(double falseX, double falseY, double xyUnits);
120
+
121
+ fgdbError GetZFalseOriginAndUnits(double& falseZ, double& zUnits);
122
+ fgdbError SetZFalseOriginAndUnits(double falseZ, double zUnits);
123
+
124
+ fgdbError GetMFalseOriginAndUnits(double& falseM, double& mUnits);
125
+ fgdbError SetMFalseOriginAndUnits(double falseM, double mUnits);
126
+
127
+ fgdbError GetXYTolerance(double& xyTolerance);
128
+ fgdbError SetXYTolerance(double xyTolerance);
129
+
130
+ fgdbError GetZTolerance(double& zTolerance);
131
+ fgdbError SetZTolerance(double zTolerance);
132
+
133
+ fgdbError GetMTolerance(double& mTolerance);
134
+ fgdbError SetMTolerance(double mTolerance);
135
+
136
+ private:
137
+
138
+ #pragma warning(push)
139
+ #pragma warning(disable : 4251)
140
+ std::wstring m_spatialReference;
141
+ #pragma warning(pop)
142
+ int m_wkid;
143
+ double m_falseX;
144
+ double m_falseY;
145
+ double m_XYUnits;
146
+ double m_falseZ;
147
+ double m_ZUnits;
148
+ double m_falseM;
149
+ double m_MUnits;
150
+ double m_XYTolerance;
151
+ double m_ZTolerance;
152
+ double m_MTolerance;
153
+ };
154
+
155
+ /// A utility class for providing geometry definitions.
156
+ class EXT_FILEGDB_API GeometryDef
157
+ {
158
+ public:
159
+
160
+ GeometryDef();
161
+ ~GeometryDef();
162
+
163
+ fgdbError GetGeometryType(GeometryType& geometryType) const;
164
+ fgdbError SetGeometryType(GeometryType geometryType);
165
+
166
+ fgdbError GetHasZ(bool& hasZ) const;
167
+ fgdbError SetHasZ(bool hasZ);
168
+
169
+ fgdbError GetHasM(bool& hasM) const;
170
+ fgdbError SetHasM(bool hasM);
171
+
172
+ fgdbError GetSpatialReference(SpatialReference& spatialReference) const;
173
+ fgdbError SetSpatialReference(const SpatialReference& spatialReference);
174
+
175
+ private:
176
+
177
+ GeometryType m_geometryType;
178
+ bool m_hasZ;
179
+ bool m_hasM;
180
+ SpatialReference m_spatialReference;
181
+ };
182
+
183
+ /// A utility class for providing field definitions.
184
+ class EXT_FILEGDB_API FieldDef
185
+ {
186
+ public:
187
+
188
+ FieldDef();
189
+ ~FieldDef();
190
+
191
+ fgdbError GetName(std::wstring& name) const;
192
+ fgdbError SetName(const std::wstring& name);
193
+
194
+ fgdbError GetAlias(std::wstring& alias) const;
195
+ fgdbError SetAlias(const std::wstring& alias);
196
+
197
+ fgdbError GetType(FieldType& type) const;
198
+ fgdbError SetType(FieldType type);
199
+
200
+ fgdbError GetLength(int& length) const;
201
+ fgdbError SetLength(int length);
202
+
203
+ fgdbError GetIsNullable(bool& isNullable) const;
204
+ fgdbError SetIsNullable(bool isNullable);
205
+
206
+ fgdbError GetGeometryDef(GeometryDef& geometryDef) const;
207
+ fgdbError SetGeometryDef(const GeometryDef& geometryDef);
208
+
209
+ private:
210
+
211
+ #pragma warning(push)
212
+ #pragma warning(disable : 4251)
213
+ std::wstring m_name;
214
+ std::wstring m_alias;
215
+ #pragma warning(pop)
216
+ FieldType m_type;
217
+ int m_length;
218
+ bool m_isNullable;
219
+ GeometryDef m_geometryDef;
220
+ };
221
+
222
+ /// A utility class for providing index definitions.
223
+ class EXT_FILEGDB_API IndexDef
224
+ {
225
+ public:
226
+
227
+ IndexDef();
228
+ IndexDef(const std::wstring& name, const std::wstring& fields, bool isUnique = false);
229
+ ~IndexDef();
230
+
231
+ fgdbError GetName(std::wstring& name) const;
232
+ fgdbError SetName(const std::wstring& name);
233
+
234
+ // Note: FileGDB currently supports only single column indexes, but that could
235
+ // change in the future.
236
+ fgdbError GetFields(std::wstring& fields) const;
237
+ fgdbError SetFields(const std::wstring& fields);
238
+
239
+ fgdbError GetIsUnique(bool& isUnique) const; // TODO: not used for FileGDB - remove?
240
+ fgdbError SetIsUnique(bool isUnique);
241
+
242
+ private:
243
+
244
+ #pragma warning(push)
245
+ #pragma warning(disable : 4251)
246
+ std::wstring m_name;
247
+ std::wstring m_fields;
248
+ #pragma warning(pop)
249
+ bool m_isUnique;
250
+ };
251
+
252
+ /// A utility class for providing field information.
253
+ class EXT_FILEGDB_API FieldInfo
254
+ {
255
+ public:
256
+
257
+ /// The number of fields.
258
+ /// @param[out] fieldCount The number of fields.
259
+ /// @return Error code indicating whether the method finished successfully.
260
+ fgdbError GetFieldCount(int& fieldCount) const;
261
+
262
+ /// The name of the field.
263
+ /// @param[in] fieldNumber The number of field.
264
+ /// @param[out] fieldName The name of the field.
265
+ /// @return Error code indicating whether the method finished successfully.
266
+ fgdbError GetFieldName(int fieldNumber, std::wstring& fieldName) const;
267
+
268
+ /// The data type of the field.
269
+ /// @param[in] fieldNumber The number of field.
270
+ /// @param[out] fieldType The data type of the field.
271
+ /// @return Error code indicating whether the method finished successfully.
272
+ fgdbError GetFieldType(int fieldNumber, FieldType& fieldType) const;
273
+
274
+ /// The length of the field.
275
+ /// @param[in] fieldNumber The number of field.
276
+ /// @param[out] fieldLength The length of the field.
277
+ /// @return Error code indicating whether the method finished successfully.
278
+ fgdbError GetFieldLength(int fieldNumber, int& fieldLength) const;
279
+
280
+ /// The nullability of the field.
281
+ /// @param[in] fieldNumber The number of field.
282
+ /// @param[out] isNullable The nullability of the field.
283
+ /// @return Error code indicating whether the method finished successfully.
284
+ fgdbError GetFieldIsNullable(int fieldNumber, bool& isNullable) const;
285
+
286
+ /// @name Constructors and destructors
287
+ //@{
288
+ /// The class constructor.
289
+ FieldInfo();
290
+
291
+ /// The class destructor.
292
+ ~FieldInfo();
293
+ //@}
294
+
295
+ private:
296
+
297
+ fgdbError SetupFieldInfo(IFields* pFields);
298
+ bool IsSetup() const;
299
+
300
+ IFields* m_pFields;
301
+
302
+ friend class EnumRows;
303
+ friend class Table;
304
+ friend class Row;
305
+
306
+ FieldInfo(const FieldInfo&) { }
307
+ FieldInfo& operator=(const FieldInfo&) { return *this; }
308
+ };
309
+
310
+ /// A utility class for working with serialized shapes.
311
+ class EXT_FILEGDB_API ShapeBuffer
312
+ {
313
+ public:
314
+
315
+ /// Allocates a byte array of the specified size.
316
+ /// @param[in] length The number of bytes to allocate.
317
+ /// @return bool Indicates success.
318
+ bool Allocate(size_t length);
319
+
320
+ /// @name Constructors and destructors
321
+ //@{
322
+ /// The class constructor.
323
+ ShapeBuffer(size_t length = 0);
324
+
325
+ /// The class destructor.
326
+ virtual ~ShapeBuffer();
327
+ //@}
328
+
329
+ /// The underlying byte array.
330
+ byte* shapeBuffer;
331
+
332
+ /// The capacity of the byte array.
333
+ size_t allocatedLength;
334
+
335
+ /// The number of bytes being used in the array.
336
+ size_t inUseLength;
337
+
338
+ /// Is the ShapeBuffer empty.
339
+ /// @return bool Indicates if the shape buffer is empty.
340
+ bool IsEmpty(void) const;
341
+
342
+ /// Set the ShapeBuffer empty.
343
+ void SetEmpty(void);
344
+
345
+ /// Gets the shape type from the shape buffer.
346
+ /// @param[out] shapeType The shape type of the buffer. <a href="ShapeTypes.txt">Shape Type</a>
347
+ /// @return Error code indicating whether the method finished successfully.
348
+ fgdbError GetShapeType(ShapeType& shapeType) const;
349
+
350
+ /// Gets the geometry type which corresponds to the shape type in the shape buffer.
351
+ /// @param[out] geometryType The geometry type of the shape. <a href="GeometryType.txt">Geometry Type</a>
352
+ /// @return Error code indicating whether the method finished successfully.
353
+ fgdbError GetGeometryType(GeometryType& geometryType) const;
354
+
355
+ /// Does the shape buffer contain Z values.
356
+ /// @param[in] shapeType The shape type of the buffer. <a href="ShapeTypes.txt">Shape Type</a>
357
+ /// @return bool Indicates if the shape buffer includes Zs.
358
+ static bool HasZs(ShapeType shapeType);
359
+
360
+ /// Does the shape buffer contain Ms.
361
+ /// @param[in] shapeType The shape type of the buffer. <a href="ShapeTypes.txt">Shape Type</a>
362
+ /// @return bool Indicates if the shape buffer includes Ms.
363
+ static bool HasMs(ShapeType shapeType);
364
+
365
+ /// Does the shape buffer contain IDs.
366
+ /// @param[in] shapeType The shape type of the buffer. <a href="ShapeTypes.txt">Shape Type</a>
367
+ /// @return bool Indicates if the shape buffer includes IDs.
368
+ static bool HasIDs(ShapeType shapeType);
369
+
370
+ /// Does the shape buffer contain Curves.
371
+ /// @param[in] shapeType The shape type of the buffer. <a href="ShapeTypes.txt">Shape Type</a>
372
+ /// @return bool Indicates if the shape buffer includes Curves.
373
+ static bool HasCurves(ShapeType shapeType);
374
+
375
+ /// Does the shape buffer includes Normals.
376
+ /// @param[in] shapeType The shape type of the buffer. <a href="ShapeTypes.txt">Shape Type</a>
377
+ /// @return bool Indicates if the shape buffer includes Normals.
378
+ static bool HasNormals(ShapeType shapeType);
379
+
380
+ /// Does the shape buffer include Textures.
381
+ /// @param[in] shapeType The shape type of the buffer. <a href="ShapeTypes.txt">Shape Type</a>
382
+ /// @return bool Indicates if the shape buffer includes Textures
383
+ static bool HasTextures(ShapeType shapeType);
384
+
385
+ /// Does the shape buffer include Materials.
386
+ /// @param[in] shapeType The shape type of the buffer. <a href="ShapeTypes.txt">Shape Type</a>
387
+ /// @return bool Indicates if the shape buffer includes Materials.
388
+ static bool HasMaterials(ShapeType shapeType);
389
+
390
+ /// Gets the geometry type from a shape type.
391
+ /// @param[in] shapeType The shape type of the buffer. <a href="ShapeTypes.txt">Shape Type</a>
392
+ /// @return GeometryType The geometry type of the shape. <a href="GeometryType.txt">Geometry Type</a>
393
+ static GeometryType GetGeometryType(ShapeType shapeType);
394
+
395
+ private:
396
+
397
+ ShapeBuffer(const ShapeBuffer&) { }
398
+ ShapeBuffer& operator=(const ShapeBuffer&) { return *this; }
399
+ };
400
+
401
+ /// Point Shape Buffer accessor functions.
402
+ /// These functions provide access to the shape buffer. Consult the extended
403
+ /// shapefile format document for the buffer layout. When reading a point shape
404
+ /// buffer you should first create the appropriate shape buffer, get the geometry,
405
+ /// get the point, and any z or m values. To write a point create a row buffer,
406
+ /// create a shape buffer, set up the shape buffer, get the point,
407
+ /// assign the coordinates to the point, assign z and m values if present, set the
408
+ /// geometry and insert the row.
409
+ class EXT_FILEGDB_API PointShapeBuffer : public ShapeBuffer
410
+ {
411
+ public:
412
+
413
+ /// Get a pointer to the points coordinates.
414
+ /// @param[out] point A pointer to the coordinate.
415
+ /// @return Error code indicating whether the method finished successfully.
416
+ fgdbError GetPoint(Point*& point) const;
417
+
418
+ /// Get a pointer to the points z coordinate.
419
+ /// @param[out] z A pointer to the z value.
420
+ /// @return Error code indicating whether the method finished successfully..
421
+ fgdbError GetZ(double*& z) const;
422
+
423
+ /// Get a pointer to the points measure.
424
+ /// @param[out] m A pointer to the m value.
425
+ /// @return Error code indicating whether the method finished successfully.
426
+ fgdbError GetM(double*& m) const;
427
+
428
+ /// Get a pointer to the points ID value.
429
+ /// @param[out] id A pointer to the id.
430
+ /// @return Error code indicating whether the method finished successfully..
431
+ fgdbError GetID(int*& id) const;
432
+
433
+ /// Setup a shape buffer for insert. Allocates the correct length buffer for the selected shape type.
434
+ /// @param[in] shapeType The shape type of the buffer. <a href="ShapeTypes.txt">Shape Type</a>
435
+ /// @return Error code indicating whether the method finished successfully.
436
+ fgdbError Setup(ShapeType shapeType);
437
+ };
438
+
439
+ /// MultiPoint Shape Buffer accessor functions.
440
+ /// These functions provide access to the shape buffer. Consult the extended shapefile format document
441
+ /// for the buffer layout. When reading a multipoint shape buffer you should first create the appropriate
442
+ /// shape buffer, get the geometry, get the number of points, get a pointer to the part array, get a pointer
443
+ /// to the point array, and, if present, pointers to the z, m, and id arrays. To write a multipoint shape
444
+ /// buffer create a row buffer, create a shape buffer, set up the shape buffer, get the
445
+ /// points, assign the coordinates to the point array, and if needed get the z, m, id and curve arrays and
446
+ /// populate, calculate the extent of the geometry, set the geometry and insert the row. To improve load
447
+ /// use Table::LoadOnlyMode. Set it to true before you insert any rows and set it too false when
448
+ /// finished. If all grid size values in the spatial index are zero, the values will be calculated based on
449
+ /// the existing geometries.
450
+ class EXT_FILEGDB_API MultiPointShapeBuffer : public ShapeBuffer
451
+ {
452
+ public:
453
+
454
+ /// Get a pointer to the geomtries extent.
455
+ /// @param[out] extent A pointer to the geometries extent.
456
+ /// @return Error code indicating whether the method finished successfully.
457
+ fgdbError GetExtent(double*& extent) const;
458
+
459
+ /// Get the number of coordinates in the geometry.
460
+ /// @param[out] numPoints The number of points.
461
+ /// @return Error code indicating whether the method finished successfully.
462
+ fgdbError GetNumPoints(int& numPoints) const;
463
+
464
+ /// Get a pointer to the point array.
465
+ /// @param[out] points A pointer to the coordinate array.
466
+ /// @return Error code indicating whether the method finished successfully.
467
+ fgdbError GetPoints(Point*& points) const;
468
+
469
+ /// Get a pointer to the z extent.
470
+ /// @param[out] zExtent A pointer to the z extent.
471
+ /// @return Error code indicating whether the method finished successfully.
472
+ fgdbError GetZExtent(double*& zExtent) const;
473
+
474
+ /// Get a pointer to the z array.
475
+ /// @param[out] zArray A pointer to the z array.
476
+ /// @return Error code indicating whether the method finished successfully.
477
+ fgdbError GetZs(double*& zArray) const;
478
+
479
+ /// Get a pointer to the m extent.
480
+ /// @param[out] mExtent A pointer to the m extent.
481
+ /// @return Error code indicating whether the method finished successfully.
482
+ fgdbError GetMExtent(double*& mExtent) const;
483
+
484
+ /// Get a pointer to the m array.
485
+ /// @param[out] mArray A pointer to the m array.
486
+ /// @return Error code indicating whether the method finished successfully.
487
+ fgdbError GetMs(double*& mArray) const;
488
+
489
+ /// Get a pointer to the id array.
490
+ /// @param[out] ids A pointer to the id array.
491
+ /// @return Error code indicating whether the method finished successfully.
492
+ fgdbError GetIDs(int*& ids) const;
493
+
494
+ /// Setup a shape buffer for insert. Allocates the correct length buffer for the selected shape type.
495
+ /// @param[in] shapeType The shape type of the buffer. <a href="ShapeTypes.txt">Shape Type</a>
496
+ /// @param[in] numPoints The number of points to be loaded.
497
+ /// @return Error code indicating whether the method finished successfully.
498
+ fgdbError Setup(ShapeType shapeType, int numPoints);
499
+
500
+ /// Calculates the extent for the shape after all of the coordinate arrays have been filled.
501
+ /// @return Error code indicating whether the method finished successfully.
502
+ fgdbError CalculateExtent(void);
503
+ };
504
+
505
+ /// MultiPart Shape Buffer accessor functions.
506
+ /// These functions provide access to the shape buffer. Consult the extended shapefile
507
+ /// format document for the buffer layout. When reading a multipart shape buffer you
508
+ /// should first create the appropriate shape buffer, get the geometry, get the number
509
+ /// of points, get the number of parts, get the number of curves, get a pointer to the
510
+ /// part array, get a pointer to the point array, and, if present pointers to the z, m,
511
+ /// and id arrays. To write a multipart shape buffer create a row buffer, create a shape
512
+ /// buffer, set up the shape buffer, get the points, assign the coordinates
513
+ /// to the point array, get the part array and populate the array as needed, and if needed
514
+ /// get the z, m, id and curve arrays and populate, calculate the extent of the geometry,
515
+ /// set the geometry and insert the row. If curves were added Pact the curves before setting
516
+ /// the geometry. To improve load use Table::LoadOnlyMode. Set it to true before you insert
517
+ /// any rows and set it too false when finished. If all grid size values in the spatial index
518
+ /// are zero, the values will be calculated based on the existing geometries.
519
+ class EXT_FILEGDB_API MultiPartShapeBuffer : public ShapeBuffer
520
+ {
521
+ public:
522
+
523
+ /// Get a pointer to the geomtries extent.
524
+ /// @param[out] extent A pointer to the geometries extent.
525
+ /// @return Error code indicating whether the method finished successfully.
526
+ fgdbError GetExtent(double*& extent) const;
527
+
528
+ /// Get the number of parts.
529
+ /// @param[out] numParts The number of parts in the geometry.
530
+ /// @return Error code indicating whether the method finished successfully.
531
+ fgdbError GetNumParts(int& numParts) const;
532
+
533
+ /// Get the number of coordinates in the geometry.
534
+ /// @param[out] numPoints The number of points.
535
+ /// @return Error code indicating whether the method finished successfully.
536
+ fgdbError GetNumPoints(int& numPoints) const;
537
+
538
+ /// Get a pointer to the parts array.
539
+ /// @param[out] parts A pointer to the parts array.
540
+ /// @return Error code indicating whether the method finished successfully.
541
+ fgdbError GetParts(int*& parts) const;
542
+
543
+ /// Get a pointer to the point array.
544
+ /// @param[out] points A pointer to the point array.
545
+ /// @return Error code indicating whether the method finished successfully.
546
+ fgdbError GetPoints(Point*& points) const;
547
+
548
+ /// Get a pointer to the z extent.
549
+ /// @param[out] zExtent A pointer to the z extent.
550
+ /// @return Error code indicating whether the method finished successfully.
551
+ fgdbError GetZExtent(double*& zExtent) const;
552
+
553
+ /// Get a pointer to the z array.
554
+ /// @param[out] zArray A pointer to the z array.
555
+ /// @return Error code indicating whether the method finished successfully.
556
+ fgdbError GetZs(double*& zArray) const;
557
+
558
+ /// Get a pointer to the m extent.
559
+ /// @param[out] mExtent A pointer to the m extent.
560
+ /// @return Error code indicating whether the method finished successfully.
561
+ fgdbError GetMExtent(double*& mExtent) const;
562
+
563
+ /// Get a pointer to the m array.
564
+ /// @param[out] mArray A pointer to the m array.
565
+ /// @return Error code indicating whether the method finished successfully.
566
+ fgdbError GetMs(double*& mArray) const;
567
+
568
+ /// Get the number of curves in the geometry.
569
+ /// @param[out] numCurves The number of curves.
570
+ /// @return Error code indicating whether the method finished successfully.
571
+ fgdbError GetNumCurves(int& numCurves) const;
572
+
573
+ /// Get a pointer to the curve array.
574
+ /// @param[out] curves A pointer to the curve array.
575
+ /// @return Error code indicating whether the method finished successfully.
576
+ fgdbError GetCurves(byte*& curves) const;
577
+
578
+ /// Get a pointer to the id array.
579
+ /// @param[out] ids A pointer to the id array.
580
+ /// @return Error code indicating whether the method finished successfully.
581
+ fgdbError GetIDs(int*& ids) const;
582
+
583
+ /// Setup a shape buffer for insert. Allocates the correct length buffer for the selected shape type.
584
+ /// @param[in] shapeType The shape type of the buffer. <a href="ShapeTypes.txt">Shape Type</a>
585
+ /// @param[in] numParts The number of parts that the geometry will contain.
586
+ /// @param[in] numPoints The number of points that the geometry will contain.
587
+ /// @param[in] numCurves The number of curves that the geometry will contain, defaults to zero.
588
+ /// @return Error code indicating whether the method finished successfully.
589
+ fgdbError Setup(ShapeType shapeType, int numParts, int numPoints, int numCurves = 0);
590
+
591
+ /// Calculates the extent for the shape after all of the coordinate arrays have been filled.
592
+ /// @return Error code indicating whether the method finished successfully.
593
+ fgdbError CalculateExtent(void);
594
+
595
+ /// Remove excess space allocated for curves. Setup allocates space for curves based of the
596
+ /// max size that could be required. Depending on the curves loaded, all of the allocated
597
+ /// space may not be required.
598
+ /// @return Error code indicating whether the method finished successfully.
599
+ fgdbError PackCurves(void);
600
+ };
601
+
602
+ /// MultiPatch Shape Buffer accessor functions.
603
+ /// These functions provide access to the shape buffer. Consult the extended shapefile format
604
+ /// document for the buffer layout.
605
+ class EXT_FILEGDB_API MultiPatchShapeBuffer : public ShapeBuffer
606
+ {
607
+ public:
608
+
609
+ /// Get a pointer to the geomtries extent.
610
+ /// @param[out] extent A pointer to the geometries extent.
611
+ /// @return Error code indicating whether the method finished successfully.
612
+ fgdbError GetExtent(double*& extent) const;
613
+
614
+ /// Get the number of parts.
615
+ /// @param[out] numParts The number of parts in the geometry.
616
+ /// @return Error code indicating whether the method finished successfully.
617
+ fgdbError GetNumParts(int& numParts) const;
618
+
619
+ /// Get the number of coordinates in the geometry.
620
+ /// @param[out] numPoints The number of points.
621
+ /// @return Error code indicating whether the method finished successfully.
622
+ fgdbError GetNumPoints(int& numPoints) const;
623
+
624
+ /// Get a pointer to the parts array.
625
+ /// @param[out] parts A pointer to the parts array.
626
+ /// @return Error code indicating whether the method finished successfully.
627
+ fgdbError GetParts(int*& parts) const;
628
+
629
+ /// Get a pointer to the part descriptor array.
630
+ /// @param[out] partDescriptorArray A pointer to the part descriptor array.
631
+ /// @return Error code indicating whether the method finished successfully
632
+ fgdbError GetPartDescriptors(int*& partDescriptorArray) const;
633
+
634
+ /// Get a pointer to the point array.
635
+ /// @param[out] points A pointer to the point array.
636
+ /// @return Error code indicating whether the method finished successfully.
637
+ fgdbError GetPoints(Point*& points) const;
638
+
639
+ /// Get a pointer to the z extent.
640
+ /// @param[out] zExtent A pointer to the z extent.
641
+ /// @return Error code indicating whether the method finished successfully.
642
+ fgdbError GetZExtent(double*& zExtent) const;
643
+
644
+ /// Get a pointer to the z array.
645
+ /// @param[out] zArray A pointer to the z array.
646
+ /// @return Error code indicating whether the method finished successfully.
647
+ fgdbError GetZs(double*& zArray) const;
648
+
649
+ /// Get a pointer to the m extent.
650
+ /// @param[out] mExtent A pointer to the m extent.
651
+ /// @return Error code indicating whether the method finished successfully.
652
+ fgdbError GetMExtent(double*& mExtent) const;
653
+
654
+ /// Get a pointer to the m array.
655
+ /// @param[out] mArray A pointer to the m array.
656
+ /// @return Error code indicating whether the method finished successfully.
657
+ fgdbError GetMs(double*& mArray) const;
658
+
659
+ /// Get a pointer to the id array.
660
+ /// @param[out] ids A pointer to the id array.
661
+ /// @return Error code indicating whether the method finished successfully.
662
+ fgdbError GetIDs(int*& ids) const;
663
+
664
+ /// Get a pointer to the normals array.
665
+ /// @param[out] normals A pointer to the normals array.
666
+ /// @return Error code indicating whether the method finished successfully.
667
+ fgdbError GetNormals(float*& normals) const;
668
+
669
+ /// Returns textures.
670
+ /// @param[out] numTextures The number of textures
671
+ /// @param[out] textureDimension The texture dimension.
672
+ /// @param[out] textureParts A pointer to the texture parts.
673
+ /// @param[out] textureCoords A pointer to the texture coordinates.
674
+ /// @return Error code indicating whether the method finished successfully.
675
+ fgdbError GetTextures(int& numTextures, int& textureDimension, int*& textureParts, float*& textureCoords) const;
676
+
677
+ /// Returns materials.
678
+ /// @param[out] numMaterials The number of materials
679
+ /// @param[out] compressionType The compression type.
680
+ /// @param[out] materialParts A pointer to the number of material parts.
681
+ /// @param[out] materials A pointer to the materials array.
682
+ /// @return Error code indicating whether the method finished successfully.
683
+ fgdbError GetMaterials(int& numMaterials, int& compressionType, int*& materialParts, byte*& materials) const;
684
+
685
+ /// Setup a shape buffer for insert. Allocates the correct length buffer for the selected shape type.
686
+ /// @param[in] shapeType The shape type of the buffer. <a href="ShapeTypes.txt">Shape Type</a>
687
+ /// @param[in] numParts The number of parts that the geometry will contain.
688
+ /// @param[in] numPoints The number of points that the geometry will contain.
689
+ /// @param[in] numTextures The number of textures that the geometry will contain, defaults to zero.
690
+ /// @param[in] textureDimension The textureDimension that the geometry will contain, defaults to zero.
691
+ /// @param[in] numMaterials The number of materials that the geometry will contain, defaults to zero.
692
+ /// @param[in] materialsLength The size in bytes of the materials block, defaults to zero.
693
+ /// @return Error code indicating whether the method finished successfully.
694
+ fgdbError Setup(ShapeType shapeType, int numParts, int numPoints, int numTextures = 0,
695
+ int textureDimension = 0, int numMaterials = 0, size_t materialsLength = 0);
696
+
697
+ /// Calculates the extent for the shape after all of the coordinate arrays have been filled.
698
+ /// @return Error code indicating whether the method finished successfully.
699
+ fgdbError CalculateExtent(void);
700
+ };
701
+
702
+ /// A utility class for working with database BLOBs.
703
+ class EXT_FILEGDB_API ByteArray
704
+ {
705
+ public:
706
+
707
+ /// Allocates a byte array of the specified size.
708
+ /// @param[in] length The number of bytes to allocate.
709
+ /// @return bool Indicates success.
710
+ bool Allocate(size_t length);
711
+
712
+ /// @name Constructors and destructors
713
+ //@{
714
+ /// The class constructor.
715
+ ByteArray(size_t length = 0);
716
+
717
+ /// The class destructor.
718
+ ~ByteArray();
719
+ //@}
720
+
721
+ /// The underlying byte array.
722
+ byte* byteArray;
723
+
724
+ /// The capacity of the byte array.
725
+ size_t allocatedLength;
726
+
727
+ /// The number of bytes being used in the array.
728
+ size_t inUseLength;
729
+
730
+ private:
731
+
732
+ ByteArray(const ByteArray&) { }
733
+ ByteArray& operator=(const ByteArray&) { return *this; }
734
+ };
735
+
736
+ /// Defines an XY spatial extent.
737
+ class EXT_FILEGDB_API Envelope
738
+ {
739
+ public:
740
+
741
+ /// Indicates whether the envelope's attributes have been set.
742
+ /// @return True if one or more attributes are NaN, false otherwise.
743
+ bool IsEmpty() const;
744
+
745
+ /// Sets the envelope's attributes to NaN.
746
+ /// @return Void.
747
+ void SetEmpty();
748
+
749
+ /// @name Constructors and destructors
750
+ //@{
751
+ /// The class constructors.
752
+ Envelope();
753
+ Envelope(double xmin, double xmax, double ymin, double ymax);
754
+
755
+ /// The class destructor.
756
+ ~Envelope();
757
+ //@}
758
+
759
+ /// The lower X boundary of the envelope.
760
+ double xMin;
761
+
762
+ /// The lower Y boundary of the envelope.
763
+ double yMin;
764
+
765
+ /// The upper X boundary of the envelope.
766
+ double xMax;
767
+
768
+ /// The upper Y boundary of the envelope.
769
+ double yMax;
770
+
771
+ /// The lower Z boundary of the envelope.
772
+ double zMin;
773
+
774
+ /// The upper Z boundary of the envelope.
775
+ double zMax;
776
+ };
777
+
778
+ class EXT_FILEGDB_API Point
779
+ {
780
+ public:
781
+
782
+ double x;
783
+ double y;
784
+ };
785
+
786
+ class EXT_FILEGDB_API Curve
787
+ {
788
+ public:
789
+
790
+ virtual ~Curve();
791
+
792
+ int startPointIndex;
793
+ int curveType;
794
+
795
+ fgdbError GetCurveType(CurveType& curvetype) const;
796
+
797
+ private:
798
+
799
+ Curve();
800
+ };
801
+
802
+ class EXT_FILEGDB_API CircularArcCurve : public Curve
803
+ {
804
+ public:
805
+
806
+ union
807
+ {
808
+ Point centerPoint;
809
+ double angles[2];
810
+ };
811
+ int bits;
812
+ };
813
+
814
+ class EXT_FILEGDB_API BezierCurve : public Curve
815
+ {
816
+ public:
817
+
818
+ Point controlPoints[2];
819
+ };
820
+
821
+ class EXT_FILEGDB_API EllipticArcCurve : public Curve
822
+ {
823
+ public:
824
+
825
+ union
826
+ {
827
+ Point centerPoint;
828
+ double vs[2];
829
+ };
830
+ union
831
+ {
832
+ double rotation;
833
+ double fromV;
834
+ };
835
+ double semiMajor;
836
+ union
837
+ {
838
+ double minorMajorRatio;
839
+ double deltaV;
840
+ };
841
+ int bits;
842
+ };
843
+
844
+ class EXT_FILEGDB_API Guid
845
+ {
846
+ public:
847
+
848
+ Guid();
849
+ ~Guid();
850
+
851
+ void SetNull(void);
852
+ void Create(void);
853
+
854
+ fgdbError FromString(const std::wstring& guidString);
855
+ fgdbError ToString(std::wstring& guidString);
856
+
857
+ bool operator==(const Guid& other);
858
+ bool operator!=(const Guid& other);
859
+
860
+ uint32 data1;
861
+ uint16 data2;
862
+ uint16 data3;
863
+ byte data4[8];
864
+ };
865
+
866
+ /// Provides access to error text and extended error information.
867
+ namespace ErrorInfo
868
+ {
869
+ /// Returns the text error message which corresponds to an error code.
870
+ /// If there is no description corresponding to the error code, the error
871
+ /// description string will be empty and a 1 (S_FALSE) error will be returned.
872
+ /// @param[in] fgdbError The error code to look up.
873
+ /// @param[out] errorDescription The description of the error.
874
+ /// @return Error code indicating whether the method finished successfully.
875
+ EXT_FILEGDB_API fgdbError GetErrorDescription(fgdbError fgdbError, std::wstring& errorDescription);
876
+
877
+ /// Returns the number of error records in the error stack.
878
+ /// @param[out] recordCount The number of error records.
879
+ /// @return Void.
880
+ EXT_FILEGDB_API void GetErrorRecordCount(int& recordCount);
881
+
882
+ /// Returns an error record.
883
+ /// @param[in] recordNum The error record to return.
884
+ /// @param[out] fgdbError The error code.
885
+ /// @param[out] errorDescription The description of the error.
886
+ /// @return Error code indicating whether the method finished successfully.
887
+ EXT_FILEGDB_API fgdbError GetErrorRecord(int recordNum, fgdbError& fgdbError, std::wstring& errorDescription);
888
+
889
+ /// Clears the error stack.
890
+ /// @return Void.
891
+ EXT_FILEGDB_API void ClearErrors(void);
892
+ };
893
+
894
+ struct SpatialReferenceInfo
895
+ {
896
+ std::wstring auth_name; // The name of the standard or standards body that is being cited for this reference system.
897
+ int auth_srid; // The ID of the Spatial Reference System as defined by the Authority cited in AUTH_NAME.
898
+ std::wstring srtext; // The Well-known Text Representation of the Spatial Reference System.
899
+ std::wstring srname; // The name of the Spatial Reference System.
900
+ };
901
+
902
+ class EXT_FILEGDB_API EnumSpatialReferenceInfo
903
+ {
904
+ public:
905
+
906
+ EnumSpatialReferenceInfo();
907
+ ~EnumSpatialReferenceInfo();
908
+
909
+ bool NextGeographicSpatialReference(SpatialReferenceInfo& spatialReferenceInfo);
910
+ bool NextProjectedSpatialReference(SpatialReferenceInfo& spatialReferenceInfo);
911
+ void Reset();
912
+
913
+ private:
914
+
915
+ int m_currentGCS;
916
+ int m_currentPCS;
917
+ };
918
+
919
+ ///@ SpatialReferences
920
+ namespace SpatialReferences
921
+ {
922
+ /// Returns information about a spatial reference given its AUTH_SRID.
923
+ /// @param[in] auth_srid The AUTH_SRID of the spatial reference to find.
924
+ /// @param[out] spatialRef The properties of the requested spatial reference.
925
+ /// @return Error code indicating whether the method finished successfully.
926
+ EXT_FILEGDB_API bool FindSpatialReferenceBySRID(int auth_srid, SpatialReferenceInfo& spatialRef);
927
+
928
+ /// Returns information about a spatial reference given its name.
929
+ /// @param[in] srname The name of the spatial reference to find.
930
+ /// @param[out] spatialRef The properties of the requested spatial reference.
931
+ /// @return Error code indicating whether the method finished successfully.
932
+ EXT_FILEGDB_API bool FindSpatialReferenceByName(const std::wstring& srname, SpatialReferenceInfo& spatialRef);
933
+ };
934
+ //@
935
+
936
+ }; // namespace FileGDBAPI