filegdb 0.0.6 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/README.md +2 -2
  4. data/ext/filegdb/base.hpp +3 -4
  5. data/ext/filegdb/double_primitive.cpp +0 -1
  6. data/ext/filegdb/extconf.rb +0 -44
  7. data/ext/filegdb/field_info.cpp +1 -2
  8. data/ext/filegdb/filegdb.hpp +4 -4
  9. data/ext/filegdb/filegdb/include/FileGDBAPI.h +4 -1
  10. data/ext/filegdb/filegdb/include/FileGDBCore.h +4 -1
  11. data/ext/filegdb/filegdb/include/Geodatabase.h +319 -291
  12. data/ext/filegdb/filegdb/include/GeodatabaseManagement.h +1 -1
  13. data/ext/filegdb/filegdb/include/Raster.h +1 -1
  14. data/ext/filegdb/filegdb/include/Row.h +175 -5
  15. data/ext/filegdb/filegdb/include/Table.h +300 -296
  16. data/ext/filegdb/filegdb/include/Util.h +24 -15
  17. data/ext/filegdb/filegdb/include/make.include +39 -29
  18. data/ext/filegdb/filegdb/lib/libFileGDBAPI.dylib +0 -0
  19. data/ext/filegdb/filegdb/lib/libFileGDBAPI.so +0 -0
  20. data/ext/filegdb/filegdb/lib/libfgdbunixrtl.dylib +0 -0
  21. data/ext/filegdb/filegdb/lib/libfgdbunixrtl.so +0 -0
  22. data/ext/filegdb/geodatabase.cpp +11 -12
  23. data/ext/filegdb/integer_primitive.cpp +0 -1
  24. data/ext/filegdb/multi_part_shape_buffer.cpp +0 -1
  25. data/ext/filegdb/multi_point_shape_buffer.cpp +0 -1
  26. data/ext/filegdb/point.cpp +0 -1
  27. data/ext/filegdb/point_shape_buffer.cpp +0 -1
  28. data/ext/filegdb/row.cpp +1 -2
  29. data/ext/filegdb/shape_buffer.cpp +0 -1
  30. data/ext/filegdb/spatial_reference.cpp +1 -2
  31. data/ext/filegdb/table.cpp +0 -1
  32. data/ext/filegdb/util.cpp +10 -5
  33. data/filegdb.gemspec +1 -1
  34. data/lib/filegdb/version.rb +1 -1
  35. data/spec/geodatabase_spec.rb +2 -2
  36. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 677d968b5a1e27a980b55a14ad7827334cee08ef
4
- data.tar.gz: bc66c992a35d804e72384e0ca533d793b5578a3c
3
+ metadata.gz: 02900384944dc52c6eac6c964279fdc292ce47da
4
+ data.tar.gz: bfae68079510cbc348d2087cb9d8b174185aaa19
5
5
  SHA512:
6
- metadata.gz: e192453e9cba907e2da2f0857986b3f0201c84b724be4f8c5b4aa6588679c5b2037272ce7350640dcc0f05a57a16bbcc09714db8c1d937f94f700753b4272b70
7
- data.tar.gz: 75c686c905926545994302d0a24fca6523e13624743aff2c60766b39deb6fa36ab38e5ab5a7551fb6206f1eab3f9e3d53e4fdf90929db4e95331a956e4af29d0
6
+ metadata.gz: 7249fd30bedc183107b41907dd10c2f29f6e356824a9b59f6121a425bc074437ac6a5bc126b63126475a715a61f0e04563c31ccc2f898eff372d76ad5c0e66f6
7
+ data.tar.gz: be9bd3cfd11365d8dfceaef94332fddfb9e451b7a9a122ab5be48a2cf3c126786edf01d70da1fcc30ad323f3dfb0faffc82030f969884bbcfd81c16845f8e094
@@ -2,3 +2,4 @@ language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
4
  - 2.1.1
5
+ - 2.2.3
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # filegdb-ruby [![Build Status](https://secure.travis-ci.org/spatialnetworks/filegdb-ruby.png)](http://travis-ci.org/spatialnetworks/filegdb-ruby)
1
+ # filegdb-ruby [![Build Status](https://secure.travis-ci.org/fulcrumapp/filegdb-ruby.png)](http://travis-ci.org/fulcrumapp/filegdb-ruby)
2
2
 
3
- Native bindings for the ESRI libFileGDBAPI library.
3
+ Native bindings for the ESRI libFileGDBAPI library 1.4.
4
4
 
5
5
  ## Installation
6
6
 
@@ -1,5 +1,5 @@
1
- #ifndef __SHP_BASE_HPP__
2
- #define __SHP_BASE_HPP__
1
+ #ifndef __FILEGDB_BASE_HPP__
2
+ #define __FILEGDB_BASE_HPP__
3
3
 
4
4
  #include <vector>
5
5
  #include <algorithm>
@@ -114,8 +114,7 @@ namespace filegdb {
114
114
  }
115
115
  }
116
116
 
117
- VALUE initialize_not_allowed()
118
- {
117
+ VALUE initialize_not_allowed() {
119
118
  rb_raise(rb_eRuntimeError, "You cannot use #new on this class.");
120
119
  return Qnil;
121
120
  }
@@ -1,4 +1,3 @@
1
-
2
1
  #include "double_primitive.hpp"
3
2
 
4
3
  namespace filegdb {
@@ -10,48 +10,4 @@ $libs = append_library $libs, 'FileGDBAPI'
10
10
 
11
11
  $LDFLAGS << " -Wl,-rpath,#{File.join(filegdb_path, 'lib')}"
12
12
 
13
- if RUBY_PLATFORM =~ /darwin/
14
- # libFileGDBAPI requires GCC compilation because its C++ symbols are incompatible with LLVM/clang
15
- #
16
- # To install GCC on OSX:
17
- #
18
- # $ brew install gcc
19
- #
20
-
21
- msg = <<-GCC
22
-
23
-
24
- \e[31m
25
- ===========================================================================================================================
26
- ===========================================================================================================================
27
-
28
- The filegdb gem requires GCC on OSX because the C++ symbols in libFileGDBAPI.dylib are incompatible with LLVM/clang
29
-
30
- To install GCC on OSX:
31
-
32
- $ brew install gcc
33
-
34
- Note: Installing GCC through homebrew is safe and will not interfere with your Xcode installation.
35
-
36
- Report installation bugs here: https://github.com/spatialnetworks/filegdb-ruby
37
-
38
- ===========================================================================================================================
39
- ===========================================================================================================================
40
- \e[0m
41
-
42
- GCC
43
-
44
- if `which gcc-4.9`.strip.length == 0
45
- puts msg
46
- exit
47
- end
48
-
49
- require 'rbconfig'
50
- RbConfig::MAKEFILE_CONFIG['CC'] = 'gcc-4.9'
51
- RbConfig::MAKEFILE_CONFIG['CXX'] = 'gcc-4.9'
52
-
53
- # remove -Wshorten-64-to-32 since it's incompatible with GCC
54
- $warnflags = $warnflags.gsub(/-Wshorten-64-to-32/, '')
55
- end
56
-
57
13
  create_makefile 'filegdb/filegdb'
@@ -1,4 +1,3 @@
1
-
2
1
  #include "field_info.hpp"
3
2
 
4
3
  namespace filegdb {
@@ -45,7 +44,7 @@ VALUE field_info::get_field_name(VALUE self, VALUE fieldIndex) {
45
44
  return Qnil;
46
45
  }
47
46
 
48
- return rb_str_new2(to_char_array(fieldName));
47
+ return rb_str_new2(to_string(fieldName).c_str());
49
48
  }
50
49
 
51
50
  VALUE field_info::get_field_type(VALUE self, VALUE fieldIndex) {
@@ -12,7 +12,7 @@ using namespace FileGDBAPI;
12
12
  typedef VALUE (*RB_INSTANCE_METHOD)(...);
13
13
 
14
14
  #define FGDB_IS_FAILURE(hr) ((hr) != S_OK)
15
- #define FGDB_RAISE_ERROR(hr) rb_raise(rb_eRuntimeError, "%s", fgdb_error_string(hr))
15
+ #define FGDB_RAISE_ERROR(hr) rb_raise(rb_eRuntimeError, "%s", fgdb_error_string(hr).c_str())
16
16
  #define FGDB_FATAL(msg) rb_raise(rb_eRuntimeError, "%s", msg)
17
17
  #define FGDB_FATAL_ARGUMENT(msg) rb_raise(rb_eArgError, "%s", msg)
18
18
  #define FGDB_METHOD(method) ((RB_INSTANCE_METHOD)&method)
@@ -35,9 +35,9 @@ typedef VALUE (*RB_INSTANCE_METHOD)(...);
35
35
  return Qnil; \
36
36
  }
37
37
 
38
- std::wstring to_wstring(const char *input);
39
- const char *to_char_array(std::wstring str);
40
- const char *fgdb_error_string(fgdbError hr);
38
+ const std::wstring to_wstring(const char *input);
39
+ const std::string to_string(std::wstring str);
40
+ const std::string fgdb_error_string(fgdbError hr);
41
41
 
42
42
  extern VALUE fgdb_klass;
43
43
 
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  /*
6
- COPYRIGHT � 2012 ESRI
6
+ COPYRIGHT � 2015 ESRI
7
7
  TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
8
8
  Unpublished material - all rights reserved under the
9
9
  Copyright Laws of the United States and applicable international
@@ -19,6 +19,9 @@
19
19
  email: contracts@esri.com
20
20
  */
21
21
 
22
+ /// Convenience lynchpin include containing all of the file geodatabase API includes.
23
+ /// @file FileGDBAPI.h
24
+
22
25
  #pragma once
23
26
 
24
27
  #include "FileGDBCore.h"
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  /*
6
- COPYRIGHT � 2012 ESRI
6
+ COPYRIGHT � 2015 ESRI
7
7
  TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
8
8
  Unpublished material - all rights reserved under the
9
9
  Copyright Laws of the United States and applicable international
@@ -19,6 +19,9 @@
19
19
  email: contracts@esri.com
20
20
  */
21
21
 
22
+ // Core defines and enumerations.
23
+ /// @file FileGDBCore.h
24
+
22
25
  #pragma once
23
26
 
24
27
  typedef unsigned char byte;
@@ -1,291 +1,319 @@
1
- //
2
- // Geodatabase.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
- #include <map>
27
-
28
- #ifndef EXPORT_FILEGDB_API
29
- # if defined linux || defined __APPLE__
30
- # define EXT_FILEGDB_API
31
- # else
32
- # define EXT_FILEGDB_API _declspec(dllimport)
33
- # endif
34
- #else
35
- # if defined linux || defined __APPLE__
36
- # define EXT_FILEGDB_API __attribute__((visibility("default")))
37
- # else
38
- # define EXT_FILEGDB_API _declspec(dllexport)
39
- # endif
40
- #endif
41
-
42
- #include "FileGDBCore.h"
43
-
44
- class Catalog;
45
- class CatalogRef;
46
-
47
- namespace FileGDBAPI
48
- {
49
-
50
- class EnumRows;
51
- class Row;
52
- class Table;
53
-
54
- /// A class representing a File Geodatabase.
55
- class EXT_FILEGDB_API Geodatabase
56
- {
57
- public:
58
-
59
- /// @name Schema browsing
60
- //@{
61
- /// Gets a list of the dataset types in the geodatabase.
62
- /// @param[out] datasetTypes The dataset types in the geodatabase.
63
- /// @return Error code indicating whether the method finished successfully.
64
- fgdbError GetDatasetTypes(std::vector<std::wstring>& datasetTypes) const;
65
-
66
- /// Gets a list of relationship types in the geodatabase.
67
- /// @param[out] relationshipTypes The relationship types in the geodatabase.
68
- /// @return Error code indicating whether the method finished successfully.
69
- fgdbError GetDatasetRelationshipTypes(std::vector<std::wstring>& relationshipTypes) const;
70
-
71
- /// Gets the child datasets for a particular dataset, if any.
72
- /// If a non-existent path is provided, a -2147211775 (The item was not found) error will be returned.
73
- /// @param[in] parentPath The dataset to find the children of, e.g. "\usa".
74
- /// @param[in] datasetType The child dataset type as a wstring, e.g. "Feature Class". Passing in
75
- /// an empty string will return all child datasets. <a href="ItemTypes.txt">DatasetType</a>
76
- /// @param[out] childDatasets The children of the parent dataset, if any.
77
- /// @return Error code indicating whether the method finished successfully.
78
- fgdbError GetChildDatasets(const std::wstring& parentPath, const std::wstring& datasetType, std::vector<std::wstring>& childDatasets) const;
79
-
80
- /// Gets the related datasets for a particular dataset, if any.
81
- /// If a non-existent path is provided, a -2147211775 (The item was not found) error will be returned.
82
- /// @param[in] path The path of the dataset to find related datasets for, e.g. "\usa\streets_topology".
83
- /// @param[in] relType The relationship type to filter return values with, e.g. "DatasetInFeatureDataset". Passing in
84
- /// an empty string will return all related datasets. <a href="RelationshipTypes.txt">RelationshipType</a>
85
- /// @param[in] datasetType The type of the dataset to find related datasets for. <a href="ItemTypes.txt">DatasetType</a>
86
- /// @param[out] relatedDatasets The origin dataset's related datasets, if any.
87
- /// @result Error code indicating whether the method finished successfully.
88
- fgdbError GetRelatedDatasets(const std::wstring& path, const std::wstring& relType, const std::wstring& datasetType, std::vector<std::wstring>& relatedDatasets) const;
89
- //@}
90
-
91
- /// @name Schema definition
92
- //@{
93
- /// Gets the definition of a dataset as an XML document.
94
- /// If the dataset does not exist, this will fail with an error code of -2147220655 (The table was not found).
95
- /// If a non-existent path is provided, a -2147211775 (The item was not found) error will be returned.
96
- /// @param[in] path The requested dataset's path. e.g. "\usa\city_anno"
97
- /// @param[in] datasetType The requested dataset's type as a string, e.g. "Table". <a href="ItemTypes.txt">DatasetType</a>
98
- /// @param[out] datasetDef The dataset's definition as an XML document.
99
- /// @return Error code indicating whether the method finished successfully.
100
- fgdbError GetDatasetDefinition(const std::wstring& path, const std::wstring& datasetType, std::string& datasetDef) const;
101
-
102
- /// Gets the definitions of child datasets as a collection of XML documents.
103
- /// If a non-existent path is provided, a -2147211775 (The item was not found) error will be returned.
104
- /// @param[in] parentPath The parent dataset's path, e.g. "\usa".
105
- /// @param[in] datasetType The parent dataset's type as a string, e.g. "Feature Dataset". Passing in
106
- /// an empty string will return all child datasets. <a href="ItemTypes.txt">DatasetType</a>
107
- /// @param[out] childDatasetDefs A collection of child dataset definitions, if any.
108
- /// @return Error code indicating whether the method finished successfully.
109
- fgdbError GetChildDatasetDefinitions(const std::wstring& parentPath, const std::wstring& datasetType, std::vector<std::string>& childDatasetDefs) const;
110
-
111
- /// Gets the definitions of related datasets as a collection of XML documents.
112
- /// If a non-existent path is provided, a -2147211775 (The item was not found) error will be returned.
113
- /// @param[in] path The origin dataset's path, e.g. "\usa\streets_topology"
114
- /// @param[in] relType The relationship type to filter return values with, e.g. "DatasetInFeatureDataset". <a href="RelationshipTypes.txt">RelationshipType</a>
115
- /// @param[in] datasetType The origin dataset's type as a string, e.g. "Relationship Class". Passing in
116
- /// an empty string will return all related datasets. <a href="ItemTypes.txt">DatasetType</a>
117
- /// @param[out] relatedDatasetDefs A collection of related dataset definitions, if any.
118
- /// @return Error code indicating whether the method finished successfully.
119
- fgdbError GetRelatedDatasetDefinitions(const std::wstring& path, const std::wstring& relType, const std::wstring& datasetType, std::vector<std::string>& relatedDatasetDefs) const;
120
-
121
- /// Gets the metadata of a dataset as XML.
122
- /// If a non-existent path is provided, a -2147211775 (The item was not found) error will be returned.
123
- /// @param[in] path The requested dataset's path. e.g. "\address_list"
124
- /// @param[in] datasetType The requested dataset's type as a string, e.g. "Table". <a href="ItemTypes.txt">DatasetType</a>
125
- /// @param[out] documentation The dataset's metadata as XML.
126
- /// @return Error code indicating whether the method finished successfully.
127
- fgdbError GetDatasetDocumentation(const std::wstring& path, const std::wstring& datasetType, std::string& documentation) const;
128
- //@}
129
-
130
- /// @name Datasets
131
- //@{
132
- /// Creates a new feature dataset.
133
- /// If the feature dataset already exists, a -2147220733 (The dataset already exists) error will be returned.<br/>
134
- /// If the feature dataset name is missing from the XML, a -2147220645 (INVALID_NAME) error will be returned.<br/>
135
- /// If the XML is not UTF-8 encoded, create will fail with an error code of -2147024809 (Invalid function arguments).<br/>
136
- /// <a href="FeatureDataset.xml">XML</a>
137
- /// <br><br>
138
- /// @param[in] featureDatasetDef The XML definition of the feature dataset to be created.
139
- /// @return Error code indicating whether the method finished successfully.
140
- fgdbError CreateFeatureDataset(const std::string& featureDatasetDef);
141
-
142
- /// Creates a new table. This can either be a table or a feature class. If a geometry is to support Zs or Ms (measures), HasZ
143
- /// and or HasM must be set to true in the GeometryDef in the XML. The ZOrigin, MOrigin, ZScale and MScale
144
- /// must also be set in the SpatialReferences in the XML. These do not default.
145
- /// See the samlples\XMLsamples\FC_GCS_LineMin.xml for an example. Domain definitions in the table XML definition
146
- /// will be ignored. Use Table.AlterField to assign a domain. <br/>
147
- /// If the table already exists, a -2147220653 (The table already exists) error will be returned.<br/>
148
- /// If the table name is missing from the XML, a -2147220654 (The table name is invalid) error will be returned.<br/>
149
- /// If the XML is not UTF-8 encoded, create will fail with an error code of -2147024809 (Invalid function arguments).<br/>
150
- /// <br><a href="Table.xml">XML-Table</a><br><a href="FC_GCS_Line.xml">XML-Feature Class</a>
151
- /// <br><a href="FC_GCS_LineMin.xml">XML-Feature Class with the minimum spatial reference definition</a>
152
- /// <br><a href="FeatureClassInAFeatureDataset.xml">XML-Feature Class to be created in a feature dataset</a>
153
- /// @param[in] tableDef The XML definition of the table to be created.
154
- /// @param[in] parent The location where the table will be created. Pass an empty string if you want to
155
- /// create a table or feature class at the root. If you want to create a feature class in an existing feature
156
- /// dataset use the path "\USA".
157
- /// @param[out] table An Table instance for the newly created table.
158
- /// @return Error code indicating whether the method finished successfully.
159
- fgdbError CreateTable(const std::string& tableDef, const std::wstring& parent, Table& table);
160
-
161
- /// Opens a table. This can also be used to open attributed and M:N relationship class tables.
162
- /// If the table does not exist, a -2147220655 (The table was not found) error will be returned.
163
- /// Attempting to open a compressed file is not supported and a -2147220109 (FileGDB compression is
164
- /// not installed.) error will be returned.
165
- /// @param[in] path The path of the table to open. Opening a table or feature class at
166
- /// the root make sure to include "\". If opening a feature class in a feature dataset include
167
- /// the feature dataset name in the path "\USA\counties".
168
- /// @param[out] table An Table instance for the opened table.
169
- /// @return Error code indicating whether the method finished successfully.
170
- fgdbError OpenTable(const std::wstring& path, Table& table);
171
-
172
- /// Closes a table that has been previously created or opened.
173
- /// @param[in] table The table to close.
174
- /// @return Error code indicating whether the method finished successfully.
175
- fgdbError CloseTable(Table& table);
176
-
177
- /// Renames a dataset.
178
- /// @param[in] path The path of the dataset, e.g. "\Landbase\Parcels".
179
- /// @param[in] datasetType The requested dataset's type as a string, e.g. "Table". <a href="ItemTypes.txt">DatasetType</a>
180
- /// @param[in] newName The name to apply to the dataset, e.g. "Parcels2".
181
- /// @return Error code indicating whether the method finished successfully.
182
- fgdbError Rename(const std::wstring& path, const std::wstring& datasetType, const std::wstring& newName);
183
-
184
- /// Moves a dataset from one container to another.
185
- /// @param[in] path The path of the dataset to move, e.g. "\Landbase\Parcels".
186
- /// @param[in] newParentPath The path of the container the dataset will be moved to, e.g. "\LandUse".
187
- /// @return Error code indicating whether the method finished successfully.
188
- fgdbError Move(const std::wstring& path, const std::wstring& newParentPath);
189
-
190
- /// Deletes a dataset.
191
- /// If a the dataset does not exist, this will fail with an error code of -2147219118 (A requested row object could not be located).<br/>
192
- /// If you do not have delete access to the dataset, this will fail with an error code of E_FAIL.<br/>
193
- /// @param[in] path The path of the dataset to delete, e.g. "\Owners".
194
- /// @param[in] datasetType The requested dataset's type as a string, e.g. "Table". <a href="ItemTypes.txt">DatasetType</a>
195
- /// @return Error code indicating whether the method finished successfully.
196
- fgdbError Delete(const std::wstring& path, const std::wstring& datasetType);
197
- //@}
198
-
199
- /// @name Domains
200
- //@{
201
-
202
- /// Gets the names of all domains, if any.
203
- /// @param[out] domainNames The domains.
204
- /// @return Error code indicating whether the method finished successfully.
205
- fgdbError GetDomains(std::vector<std::wstring>& domainNames) const;
206
-
207
- /// Creates a domain.
208
- /// If the XML is not UTF-8, create will fail with an error code of -2147024809 (Invalid function arguments).<br/>
209
- /// If the domain name already exists, a -2147209212 (Domain name already in use) error will be returned.<br/>
210
- /// <a href="CodedValueDomain.xml">XML - Coded Value Domain</a> <a href="RangeDomain.xml">XML - Range Domain</a>
211
- /// @param[in] domainDef The XML definition of the domain to be created.
212
- /// @return Error code indicating whether the method finished successfully.
213
- fgdbError CreateDomain(const std::string& domainDef);
214
-
215
- /// Modifies the properties of an existing domain.
216
- /// If the XML is not UTF-8, create will fail with an error code of -2147024809 (Invalid function arguments).<br/>
217
- /// @param[in] domainDef The modified XML definition of the domain.
218
- /// @return Error code indicating whether the method finished successfully.
219
- fgdbError AlterDomain(const std::string& domainDef);
220
-
221
- /// Deletes the specified domain.
222
- ///If the domain does not exist, this will fail with an error code of -2147209215 (The domain was not found).<br/>
223
- /// @param[in] domainName The name of the domain to delete.
224
- /// @return Error code indicating whether the method finished successfully.
225
- fgdbError DeleteDomain(const std::wstring& domainName);
226
-
227
- /// Gets the definition of the specified domain.
228
- /// @param[in] domainName The name of the domain.
229
- /// @param[out] domainDef The XML definition of the domain.
230
- /// @return Error code indicating whether the method finished successfully.
231
- fgdbError GetDomainDefinition(const std::wstring& domainName, std::string& domainDef) const;
232
- //@}
233
-
234
- /// @name SQL
235
- //@{
236
- /// Gets the query name (the name to use in SQL statements) of a table based on its path.
237
- /// @param[in] path The path of the dataset that will be queried.
238
- /// @param[out] queryName The name that should be used for the table in SQL statements.
239
- /// @return Error code indicating whether the method finished successfully.
240
- fgdbError GetQueryName(const std::wstring& path, std::wstring& queryName) const;
241
-
242
- /// Executes a SQL statement on the geodatabase. This may or may not return a result set.
243
- /// If the SQL statement is invalid, an -2147220985 (An invalid SQL statement was used) error will be returned.<br/>
244
- /// @param[in] sqlStmt The SQL statement to be executed.
245
- /// @param[in] recycling Indicates whether the row enumerator should recycle memory.
246
- /// @param[out] rows An enumerator of rows or a null value.
247
- /// @return Error code indicating whether the method finished successfully.
248
- fgdbError ExecuteSQL(const std::wstring& sqlStmt, bool recycling, EnumRows& rows) const;
249
- //@}
250
-
251
- /// @name Constructors and Destructors
252
- //@{
253
- /// The class constructor.
254
- Geodatabase();
255
-
256
- /// The class destructor.
257
- ~Geodatabase();
258
- //@}
259
-
260
- private:
261
-
262
- /// @cond PRIVATE
263
- fgdbError CreateGeodatabase(const std::wstring& path);
264
- fgdbError OpenGeodatabase(const std::wstring& path);
265
- fgdbError CloseGeodatabase();
266
- fgdbError DeleteGeodatabase();
267
-
268
- bool IsSetup() const;
269
-
270
- Catalog* m_pCatalog;
271
-
272
- #pragma warning(push)
273
- #pragma warning(disable : 4251)
274
-
275
- std::map<Table*, Table*> m_tableROT;
276
-
277
- #pragma warning(pop)
278
-
279
- friend EXT_FILEGDB_API fgdbError CreateGeodatabase(const std::wstring& path, Geodatabase& geodatabase);
280
- friend EXT_FILEGDB_API fgdbError OpenGeodatabase(const std::wstring& path, Geodatabase& geodatabase);
281
- friend EXT_FILEGDB_API fgdbError CloseGeodatabase(Geodatabase& geodatabase);
282
- friend EXT_FILEGDB_API fgdbError DeleteGeodatabase(const std::wstring& path);
283
-
284
- friend class Table;
285
-
286
- Geodatabase(const Geodatabase&) { }
287
- Geodatabase& operator=(const Geodatabase&) { return *this; }
288
- /// @endcond
289
- };
290
-
291
- }; // namespace FileGDBAPI
1
+ //
2
+ // Geodatabase.h
3
+ //
4
+
5
+ /*
6
+ COPYRIGHT � 2015 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
+ /// A set of functions for opening, querying, creating, listing and deleting file geodatabase data.
23
+ /// @file Geodatabase.h
24
+
25
+ #pragma once
26
+
27
+ #include <string>
28
+ #include <vector>
29
+ #include <map>
30
+
31
+ #ifndef EXPORT_FILEGDB_API
32
+ # if defined linux || defined __APPLE__
33
+ # define EXT_FILEGDB_API
34
+ # else
35
+ # define EXT_FILEGDB_API _declspec(dllimport)
36
+ # endif
37
+ #else
38
+ # if defined linux || defined __APPLE__
39
+ # define EXT_FILEGDB_API __attribute__((visibility("default")))
40
+ # else
41
+ # define EXT_FILEGDB_API _declspec(dllexport)
42
+ # endif
43
+ #endif
44
+
45
+ #include "FileGDBCore.h"
46
+
47
+ class Catalog;
48
+ class CatalogRef;
49
+
50
+ namespace FileGDBAPI
51
+ {
52
+
53
+ class EnumRows;
54
+ class Row;
55
+ class Table;
56
+ class FieldDef;
57
+ class SpatialReference;
58
+
59
+ /// A class representing a File Geodatabase.
60
+ class EXT_FILEGDB_API Geodatabase
61
+ {
62
+ public:
63
+
64
+ /// @name Schema browsing
65
+ //@{
66
+ /// Gets a list of the dataset types in the geodatabase.
67
+ /// @param[out] datasetTypes The dataset types in the geodatabase.
68
+ /// @return Error code indicating whether the method finished successfully.
69
+ fgdbError GetDatasetTypes(std::vector<std::wstring>& datasetTypes) const;
70
+
71
+ /// Gets a list of relationship types in the geodatabase.
72
+ /// @param[out] relationshipTypes The relationship types in the geodatabase.
73
+ /// @return Error code indicating whether the method finished successfully.
74
+ fgdbError GetDatasetRelationshipTypes(std::vector<std::wstring>& relationshipTypes) const;
75
+
76
+ /// Gets the child datasets for a particular dataset, if any.
77
+ /// If a non-existent path is provided, a -2147211775 (The item was not found) error will be returned.
78
+ /// @param[in] parentPath The dataset to find the children of, e.g. "\usa".
79
+ /// @param[in] datasetType The child dataset type as a wstring, e.g. "Feature Class". Passing in
80
+ /// an empty string will return all child datasets. <a href="ItemTypes.txt">DatasetType</a>
81
+ /// @param[out] childDatasets The children of the parent dataset, if any.
82
+ /// @return Error code indicating whether the method finished successfully.
83
+ fgdbError GetChildDatasets(const std::wstring& parentPath, const std::wstring& datasetType, std::vector<std::wstring>& childDatasets) const;
84
+
85
+ /// Gets the related datasets for a particular dataset, if any.
86
+ /// If a non-existent path is provided, a -2147211775 (The item was not found) error will be returned.
87
+ /// @param[in] path The path of the dataset to find related datasets for, e.g. "\usa\streets_topology".
88
+ /// @param[in] relType The relationship type to filter return values with, e.g. "DatasetInFeatureDataset". Passing in
89
+ /// an empty string will return all related datasets. <a href="RelationshipTypes.txt">RelationshipType</a>
90
+ /// @param[in] datasetType The type of the dataset to find related datasets for. <a href="ItemTypes.txt">DatasetType</a>
91
+ /// @param[out] relatedDatasets The origin dataset's related datasets, if any.
92
+ /// @result Error code indicating whether the method finished successfully.
93
+ fgdbError GetRelatedDatasets(const std::wstring& path, const std::wstring& relType, const std::wstring& datasetType, std::vector<std::wstring>& relatedDatasets) const;
94
+ //@}
95
+
96
+ /// @name Schema definition
97
+ //@{
98
+ /// Gets the definition of a dataset as an XML document.
99
+ /// If the dataset does not exist, this will fail with an error code of -2147220655 (The table was not found).
100
+ /// If a non-existent path is provided, a -2147211775 (The item was not found) error will be returned.
101
+ /// @param[in] path The requested dataset's path. e.g. "\usa\city_anno"
102
+ /// @param[in] datasetType The requested dataset's type as a string, e.g. "Table". <a href="ItemTypes.txt">DatasetType</a>
103
+ /// @param[out] datasetDef The dataset's definition as an XML document.
104
+ /// @return Error code indicating whether the method finished successfully.
105
+ fgdbError GetDatasetDefinition(const std::wstring& path, const std::wstring& datasetType, std::string& datasetDef) const;
106
+
107
+ /// Gets the definitions of child datasets as a collection of XML documents.
108
+ /// If a non-existent path is provided, a -2147211775 (The item was not found) error will be returned.
109
+ /// @param[in] parentPath The parent dataset's path, e.g. "\usa".
110
+ /// @param[in] datasetType The parent dataset's type as a string, e.g. "Feature Dataset". Passing in
111
+ /// an empty string will return all child datasets. <a href="ItemTypes.txt">DatasetType</a>
112
+ /// @param[out] childDatasetDefs A collection of child dataset definitions, if any.
113
+ /// @return Error code indicating whether the method finished successfully.
114
+ fgdbError GetChildDatasetDefinitions(const std::wstring& parentPath, const std::wstring& datasetType, std::vector<std::string>& childDatasetDefs) const;
115
+
116
+ /// Gets the definitions of related datasets as a collection of XML documents.
117
+ /// If a non-existent path is provided, a -2147211775 (The item was not found) error will be returned.
118
+ /// @param[in] path The origin dataset's path, e.g. "\usa\streets_topology"
119
+ /// @param[in] relType The relationship type to filter return values with, e.g. "DatasetInFeatureDataset". <a href="RelationshipTypes.txt">RelationshipType</a>
120
+ /// @param[in] datasetType The origin dataset's type as a string, e.g. "Relationship Class". Passing in
121
+ /// an empty string will return all related datasets. <a href="ItemTypes.txt">DatasetType</a>
122
+ /// @param[out] relatedDatasetDefs A collection of related dataset definitions, if any.
123
+ /// @return Error code indicating whether the method finished successfully.
124
+ fgdbError GetRelatedDatasetDefinitions(const std::wstring& path, const std::wstring& relType, const std::wstring& datasetType, std::vector<std::string>& relatedDatasetDefs) const;
125
+
126
+ /// Gets the metadata of a dataset as XML.
127
+ /// If a non-existent path is provided, a -2147211775 (The item was not found) error will be returned.
128
+ /// @param[in] path The requested dataset's path. e.g. "\address_list"
129
+ /// @param[in] datasetType The requested dataset's type as a string, e.g. "Table". <a href="ItemTypes.txt">DatasetType</a>
130
+ /// @param[out] documentation The dataset's metadata as XML.
131
+ /// @return Error code indicating whether the method finished successfully.
132
+ fgdbError GetDatasetDocumentation(const std::wstring& path, const std::wstring& datasetType, std::string& documentation) const;
133
+ //@}
134
+
135
+ /// @name Datasets
136
+ //@{
137
+ /// Creates a new feature dataset.
138
+ /// If the feature dataset already exists, a -2147220733 (The dataset already exists) error will be returned.<br/>
139
+ /// If the feature dataset name is missing from the XML, a -2147220645 (INVALID_NAME) error will be returned.<br/>
140
+ /// If the XML is not UTF-8 encoded, create will fail with an error code of -2147024809 (Invalid function arguments).<br/>
141
+ /// <a href="FeatureDataset.xml">XML</a>
142
+ ///
143
+ /// @param[in] featureDatasetDef The XML definition of the feature dataset to be created.
144
+ /// @return Error code indicating whether the method finished successfully.
145
+ fgdbError CreateFeatureDataset(const std::string& featureDatasetDef);
146
+
147
+ /// Creates a new feature dataset.
148
+ /// If the feature dataset already exists, a -2147220733 (The dataset already exists) error will be returned.<br/>
149
+ /// @param[in] path The name of the feature dataset to be created.
150
+ /// @param[in] spatialReference The spatial reference of the feature dataset to be created.
151
+ /// @return Error code indicating whether the method finished successfully.
152
+ fgdbError CreateFeatureDataset(const std::wstring& path, const SpatialReference& spatialReference);
153
+
154
+ /// Creates a new table. This can either be a table or a feature class. If a geometry is to support Zs or Ms (measures), HasZ
155
+ /// and or HasM must be set to true in the GeometryDef in the XML. The ZOrigin, MOrigin, ZScale and MScale
156
+ /// must also be set in the SpatialReferences in the XML. These do not default.
157
+ /// See the samples\XMLsamples\FC_GCS_LineMin.xml for an example. Domain definitions in the table XML definition
158
+ /// will be ignored. Use Table.AlterField to assign a domain.
159
+ /// If the table already exists, a -2147220653 (The table already exists) error will be returned.<br/>
160
+ /// If the table name is missing from the XML, a -2147220654 (The table name is invalid) error will be returned.<br/>
161
+ /// If the XML is not UTF-8 encoded, create will fail with an error code of -2147024809 (Invalid function arguments).<br/>
162
+ /// <a href="Table.xml">XML-Table</a><a href="FC_GCS_Line.xml">XML-Feature Class</a>
163
+ /// <a href="FC_GCS_LineMin.xml">XML-Feature Class with the minimum spatial reference definition</a>
164
+ /// <a href="FeatureClassInAFeatureDataset.xml">XML-Feature Class to be created in a feature dataset</a>
165
+ /// @param[in] tableDef The XML definition of the table to be created.
166
+ /// @param[in] parent The location where the table will be created. Pass an empty string if you want to
167
+ /// create a table or feature class at the root. If you want to create a feature class in an existing feature
168
+ /// dataset use the path "\USA".
169
+ /// @param[out] table A Table instance for the newly created table.
170
+ /// @return Error code indicating whether the method finished successfully.
171
+ fgdbError CreateTable(const std::string& tableDef, const std::wstring& parent, Table& table);
172
+
173
+ /// @param[in] path The path of the table to create. If creating a table or feature class at
174
+ /// the root make sure to include "\". If creating a feature class in a feature dataset include
175
+ /// the feature dataset name in the path "\USA\counties".
176
+ /// @param[in] fieldDefs The field definitions of the table to be created.
177
+ /// @param[in] configurationKeyword The configuration keyword of the table to be created.
178
+ /// If a empty string or unknown keyword is entered, the DEFAULTS keyword is used.
179
+ /// <a href="Keywords.html">Configuration Keywords</a>
180
+ /// @param[out] table A Table instance for the newly created table.
181
+ /// @return Error code indicating whether the method finished successfully.
182
+ fgdbError CreateTable(const std::wstring& path, const std::vector<FieldDef>& fieldDefs, const std::wstring& configurationKeyword, Table& table);
183
+
184
+ /// Opens a table. This can also be used to open attributed and M:N relationship class tables.
185
+ /// If the table does not exist, a -2147220655 (The table was not found) error will be returned.
186
+ /// Attempting to open a compressed file is not supported and a -2147220109 (FileGDB compression is
187
+ /// not installed.) error will be returned.
188
+ /// @param[in] path The path of the table to open. Opening a table or feature class at
189
+ /// the root make sure to include "\". If opening a feature class in a feature dataset include
190
+ /// the feature dataset name in the path "\USA\counties".
191
+ /// @param[out] table An Table instance for the opened table.
192
+ /// @return Error code indicating whether the method finished successfully.
193
+ fgdbError OpenTable(const std::wstring& path, Table& table);
194
+
195
+ /// Closes a table that has been previously created or opened.
196
+ /// @param[in] table The table to close.
197
+ /// @return Error code indicating whether the method finished successfully.
198
+ fgdbError CloseTable(Table& table);
199
+
200
+ /// Renames a dataset.
201
+ /// @param[in] path The path of the dataset, e.g. "\Landbase\Parcels".
202
+ /// @param[in] datasetType The requested dataset's type as a string, e.g. "Table". <a href="ItemTypes.txt">DatasetType</a>
203
+ /// @param[in] newName The name to apply to the dataset, e.g. "Parcels2".
204
+ /// @return Error code indicating whether the method finished successfully.
205
+ fgdbError Rename(const std::wstring& path, const std::wstring& datasetType, const std::wstring& newName);
206
+
207
+ /// Moves a dataset from one container to another.
208
+ /// @param[in] path The path of the dataset to move, e.g. "\Landbase\Parcels".
209
+ /// @param[in] newParentPath The path of the container the dataset will be moved to, e.g. "\LandUse".
210
+ /// @return Error code indicating whether the method finished successfully.
211
+ fgdbError Move(const std::wstring& path, const std::wstring& newParentPath);
212
+
213
+ /// Deletes a dataset.
214
+ /// If a the dataset does not exist, this will fail with an error code of -2147219118 (A requested row object could not be located).<br/>
215
+ /// If you do not have delete access to the dataset, this will fail with an error code of E_FAIL.<br/>
216
+ /// @param[in] path The path of the dataset to delete, e.g. "\Owners".
217
+ /// @param[in] datasetType The requested dataset's type as a string, e.g. "Table". <a href="ItemTypes.txt">DatasetType</a>
218
+ /// @return Error code indicating whether the method finished successfully.
219
+ fgdbError Delete(const std::wstring& path, const std::wstring& datasetType);
220
+
221
+ /// Compacts the geodatabase.
222
+ /// @return Error code indicating whether the method finished successfully.
223
+ fgdbError CompactDatabase();
224
+ //@}
225
+
226
+ /// @name Domains
227
+ //@{
228
+
229
+ /// Gets the names of all domains, if any.
230
+ /// @param[out] domainNames The domains.
231
+ /// @return Error code indicating whether the method finished successfully.
232
+ fgdbError GetDomains(std::vector<std::wstring>& domainNames) const;
233
+
234
+ /// Creates a domain.
235
+ /// If the XML is not UTF-8, create will fail with an error code of -2147024809 (Invalid function arguments).<br/>
236
+ /// If the domain name already exists, a -2147209212 (Domain name already in use) error will be returned.<br/>
237
+ /// <a href="CodedValueDomain.xml">XML - Coded Value Domain</a> <a href="RangeDomain.xml">XML - Range Domain</a>
238
+ /// @param[in] domainDef The XML definition of the domain to be created.
239
+ /// @return Error code indicating whether the method finished successfully.
240
+ fgdbError CreateDomain(const std::string& domainDef);
241
+
242
+ /// Modifies the properties of an existing domain.
243
+ /// If the XML is not UTF-8, create will fail with an error code of -2147024809 (Invalid function arguments).<br/>
244
+ /// @param[in] domainDef The modified XML definition of the domain.
245
+ /// @return Error code indicating whether the method finished successfully.
246
+ fgdbError AlterDomain(const std::string& domainDef);
247
+
248
+ /// Deletes the specified domain.
249
+ ///If the domain does not exist, this will fail with an error code of -2147209215 (The domain was not found).<br/>
250
+ /// @param[in] domainName The name of the domain to delete.
251
+ /// @return Error code indicating whether the method finished successfully.
252
+ fgdbError DeleteDomain(const std::wstring& domainName);
253
+
254
+ /// Gets the definition of the specified domain.
255
+ /// @param[in] domainName The name of the domain.
256
+ /// @param[out] domainDef The XML definition of the domain.
257
+ /// @return Error code indicating whether the method finished successfully.
258
+ fgdbError GetDomainDefinition(const std::wstring& domainName, std::string& domainDef) const;
259
+ //@}
260
+
261
+ /// @name SQL
262
+ //@{
263
+ /// Gets the query name (the name to use in SQL statements) of a table based on its path.
264
+ /// @param[in] path The path of the dataset that will be queried.
265
+ /// @param[out] queryName The name that should be used for the table in SQL statements.
266
+ /// @return Error code indicating whether the method finished successfully.
267
+ fgdbError GetQueryName(const std::wstring& path, std::wstring& queryName) const;
268
+
269
+ /// Executes a SQL statement on the geodatabase. This may or may not return a result set.
270
+ /// A DELETE without a WHERE clause will result in a truncate.
271
+ /// If the SQL statement is invalid, an -2147220985 (An invalid SQL statement was used) error will be returned.<br/>
272
+ /// @param[in] sqlStmt The SQL statement to be executed.
273
+ /// @param[in] recycling Indicates whether the row enumerator should recycle memory.
274
+ /// @param[out] rows An enumerator of rows or a null value.
275
+ /// @return Error code indicating whether the method finished successfully.
276
+ fgdbError ExecuteSQL(const std::wstring& sqlStmt, bool recycling, EnumRows& rows) const;
277
+ //@}
278
+
279
+ /// @name Constructors and Destructors
280
+ //@{
281
+ /// The class constructor.
282
+ Geodatabase();
283
+
284
+ /// The class destructor.
285
+ ~Geodatabase();
286
+ //@}
287
+
288
+ private:
289
+
290
+ /// @cond PRIVATE
291
+ fgdbError CreateGeodatabase(const std::wstring& path);
292
+ fgdbError OpenGeodatabase(const std::wstring& path);
293
+ fgdbError CloseGeodatabase();
294
+ fgdbError DeleteGeodatabase();
295
+
296
+ bool IsSetup() const;
297
+
298
+ Catalog* m_pCatalog;
299
+
300
+ #pragma warning(push)
301
+ #pragma warning(disable : 4251)
302
+
303
+ std::map<Table*, Table*> m_tableROT;
304
+
305
+ #pragma warning(pop)
306
+
307
+ friend EXT_FILEGDB_API fgdbError CreateGeodatabase(const std::wstring& path, Geodatabase& geodatabase);
308
+ friend EXT_FILEGDB_API fgdbError OpenGeodatabase(const std::wstring& path, Geodatabase& geodatabase);
309
+ friend EXT_FILEGDB_API fgdbError CloseGeodatabase(Geodatabase& geodatabase);
310
+ friend EXT_FILEGDB_API fgdbError DeleteGeodatabase(const std::wstring& path);
311
+
312
+ friend class Table;
313
+
314
+ Geodatabase(const Geodatabase&) { }
315
+ Geodatabase& operator=(const Geodatabase&) { return *this; }
316
+ /// @endcond
317
+ };
318
+
319
+ }; // namespace FileGDBAPI