filegdb 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,32 @@
1
+ #ifndef __FGDB_POINT_SHAPE_BUFFER_HPP__
2
+ #define __FGDB_POINT_SHAPE_BUFFER_HPP__
3
+
4
+ #include "filegdb.hpp"
5
+ #include "shape_buffer_base.hpp"
6
+
7
+ namespace filegdb {
8
+ class point_shape_buffer : public shape_buffer_base<point_shape_buffer, PointShapeBuffer> {
9
+ public:
10
+ static void define(VALUE module);
11
+
12
+ static VALUE setup(VALUE self, VALUE shapeType);
13
+ static VALUE get_point(VALUE self);
14
+ static VALUE get_z(VALUE self);
15
+ static VALUE get_m(VALUE self);
16
+ static VALUE get_id(VALUE self);
17
+ static VALUE set_z(VALUE self, VALUE zValue);
18
+ static VALUE set_m(VALUE self, VALUE mValue);
19
+ static VALUE set_id(VALUE self, VALUE idValue);
20
+
21
+ virtual VALUE klass();
22
+
23
+ static VALUE _klass;
24
+
25
+ virtual ~point_shape_buffer() {};
26
+ };
27
+ }
28
+
29
+ #endif
30
+
31
+
32
+
@@ -0,0 +1,222 @@
1
+
2
+ #include "row.hpp"
3
+ #include "shape_buffer.hpp"
4
+
5
+ #define DATETIME_FORMAT "%Y-%m-%d %H:%M:%S"
6
+
7
+ namespace filegdb {
8
+
9
+ VALUE row::_klass = Qnil;
10
+
11
+ VALUE row::klass() {
12
+ return row::_klass;
13
+ }
14
+
15
+ row::row(table *table)
16
+ : _table(table), _row(new Row)
17
+ {
18
+ }
19
+
20
+ row::~row() {
21
+ if (_row) {
22
+ delete _row;
23
+ _row = NULL;
24
+ }
25
+ }
26
+
27
+ VALUE row::set_string(VALUE self, VALUE column, VALUE value) {
28
+ row *row = unwrap(self);
29
+
30
+ std::wstring wcolumn = to_wstring(RSTRING_PTR(column));
31
+ std::wstring wvalue = to_wstring(RSTRING_PTR(value));
32
+
33
+ fgdbError hr = row->value().SetString(wcolumn, wvalue);
34
+
35
+ if (FGDB_IS_FAILURE(hr)) {
36
+ FGDB_RAISE_ERROR(hr);
37
+ return Qnil;
38
+ }
39
+
40
+ return row->_value;
41
+ }
42
+
43
+ VALUE row::get_string(VALUE self, VALUE column) {
44
+ row *row = unwrap(self);
45
+
46
+ std::wstring wcolumn = to_wstring(RSTRING_PTR(column));
47
+ std::wstring wvalue;
48
+
49
+ fgdbError hr = row->value().GetString(wcolumn, wvalue);
50
+
51
+ if (FGDB_IS_FAILURE(hr)) {
52
+ FGDB_RAISE_ERROR(hr);
53
+ return Qnil;
54
+ }
55
+
56
+ return rb_str_new2(to_char_array(wvalue));
57
+ }
58
+
59
+ VALUE row::set_geometry(VALUE self, VALUE geometry) {
60
+ row *row = unwrap(self);
61
+
62
+ shape_buffer *shape = shape_buffer::unwrap(geometry);
63
+
64
+ fgdbError hr = row->value().SetGeometry(shape->value());
65
+
66
+ if (FGDB_IS_FAILURE(hr)) {
67
+ FGDB_RAISE_ERROR(hr);
68
+ return Qnil;
69
+ }
70
+
71
+ return shape->wrapped();
72
+ }
73
+
74
+ VALUE row::set_date(VALUE self, VALUE column, VALUE date) {
75
+ CHECK_ARGUMENT_STRING(column)
76
+ CHECK_ARGUMENT_STRING(date)
77
+
78
+ row *row = unwrap(self);
79
+
80
+ struct tm datetime;
81
+
82
+ std::wstring wcolumn = to_wstring(RSTRING_PTR(column));
83
+
84
+ if (strptime(RSTRING_PTR(date), DATETIME_FORMAT, &datetime) != NULL) {
85
+ fgdbError hr = row->value().SetDate(wcolumn, datetime);
86
+
87
+ if (FGDB_IS_FAILURE(hr)) {
88
+ FGDB_RAISE_ERROR(hr);
89
+ return Qnil;
90
+ }
91
+ } else {
92
+ FGDB_FATAL("Date could not be parsed.");
93
+ return Qnil;
94
+ }
95
+
96
+ return row->wrapped();
97
+ }
98
+
99
+ VALUE row::get_date(VALUE self, VALUE column) {
100
+ CHECK_ARGUMENT_STRING(column)
101
+
102
+ row *row = unwrap(self);
103
+
104
+ std::wstring wcolumn = to_wstring(RSTRING_PTR(column));
105
+
106
+ struct tm datetime;
107
+
108
+ fgdbError hr = row->value().GetDate(wcolumn, datetime);
109
+
110
+ if (FGDB_IS_FAILURE(hr)) {
111
+ FGDB_RAISE_ERROR(hr);
112
+ return Qnil;
113
+ }
114
+
115
+ char buffer[80];
116
+
117
+ size_t length = strftime(buffer, 80, DATETIME_FORMAT, &datetime);
118
+
119
+ if (length == 0) {
120
+ FGDB_FATAL("Date could not be parsed.");
121
+ return Qnil;
122
+ }
123
+
124
+ return rb_str_new2(buffer);
125
+ }
126
+
127
+ VALUE row::set_double(VALUE self, VALUE column, VALUE number) {
128
+ CHECK_ARGUMENT_STRING(column)
129
+ CHECK_ARGUMENT_FLOAT(number)
130
+
131
+ row *row = unwrap(self);
132
+
133
+ std::wstring wcolumn = to_wstring(RSTRING_PTR(column));
134
+
135
+ fgdbError hr = row->value().SetDouble(wcolumn, NUM2DBL(number));
136
+
137
+ if (FGDB_IS_FAILURE(hr)) {
138
+ FGDB_RAISE_ERROR(hr);
139
+ return Qnil;
140
+ }
141
+
142
+ return row->wrapped();
143
+ }
144
+
145
+ VALUE row::get_double(VALUE self, VALUE column) {
146
+ CHECK_ARGUMENT_STRING(column)
147
+
148
+ row *row = unwrap(self);
149
+
150
+ std::wstring wcolumn = to_wstring(RSTRING_PTR(column));
151
+
152
+ double result = 0;
153
+
154
+ fgdbError hr = row->value().GetDouble(wcolumn, result);
155
+
156
+ if (FGDB_IS_FAILURE(hr)) {
157
+ FGDB_RAISE_ERROR(hr);
158
+ return Qnil;
159
+ }
160
+
161
+ return rb_float_new(result);
162
+ }
163
+
164
+ VALUE row::set_integer(VALUE self, VALUE column, VALUE integer) {
165
+ CHECK_ARGUMENT_STRING(column)
166
+ CHECK_ARGUMENT_FIXNUM(integer)
167
+
168
+ row *row = unwrap(self);
169
+
170
+ std::wstring wcolumn = to_wstring(RSTRING_PTR(column));
171
+
172
+ fgdbError hr = row->value().SetInteger(wcolumn, FIX2INT(integer));
173
+
174
+ if (FGDB_IS_FAILURE(hr)) {
175
+ FGDB_RAISE_ERROR(hr);
176
+ return Qnil;
177
+ }
178
+
179
+ return row->wrapped();
180
+ }
181
+
182
+ VALUE row::get_integer(VALUE self, VALUE column) {
183
+ CHECK_ARGUMENT_STRING(column)
184
+
185
+ row *row = unwrap(self);
186
+
187
+ std::wstring wcolumn = to_wstring(RSTRING_PTR(column));
188
+
189
+ int32 result = 0;
190
+
191
+ fgdbError hr = row->value().GetInteger(wcolumn, result);
192
+
193
+ if (FGDB_IS_FAILURE(hr)) {
194
+ FGDB_RAISE_ERROR(hr);
195
+ return Qnil;
196
+ }
197
+
198
+ return INT2NUM(result);
199
+ }
200
+
201
+ VALUE row::get_geometry(VALUE self) {
202
+ FGDB_FATAL("Not implemented");
203
+ return Qnil;
204
+ }
205
+
206
+ void row::define(VALUE module)
207
+ {
208
+ row::_klass = rb_define_class_under(module, "Row", rb_cObject);
209
+ base::define(row::_klass, false);
210
+ rb_define_method(row::_klass, "set_string", FGDB_METHOD(row::set_string), 2);
211
+ rb_define_method(row::_klass, "get_string", FGDB_METHOD(row::get_string), 1);
212
+ rb_define_method(row::_klass, "set_geometry", FGDB_METHOD(row::set_geometry), 1);
213
+ rb_define_method(row::_klass, "get_geometry", FGDB_METHOD(row::get_geometry), 0);
214
+ rb_define_method(row::_klass, "set_date", FGDB_METHOD(row::set_date), 2);
215
+ rb_define_method(row::_klass, "get_date", FGDB_METHOD(row::get_date), 1);
216
+ rb_define_method(row::_klass, "set_double", FGDB_METHOD(row::set_double), 2);
217
+ rb_define_method(row::_klass, "get_double", FGDB_METHOD(row::get_double), 1);
218
+ rb_define_method(row::_klass, "set_integer", FGDB_METHOD(row::set_integer), 2);
219
+ rb_define_method(row::_klass, "get_integer", FGDB_METHOD(row::get_integer), 1);
220
+ }
221
+
222
+ }
@@ -0,0 +1,37 @@
1
+ #ifndef __FGDB_ROW_HPP__
2
+ #define __FGDB_ROW_HPP__
3
+
4
+ #include "filegdb.hpp"
5
+ #include "table.hpp"
6
+
7
+ namespace filegdb {
8
+ class row : public base<row> {
9
+ public:
10
+ row() : base<row>() {};
11
+ row(table *table);
12
+ static void define(VALUE module);
13
+ static VALUE set_string(VALUE self, VALUE column, VALUE value);
14
+ static VALUE get_string(VALUE self, VALUE column);
15
+ static VALUE set_geometry(VALUE self, VALUE geometry);
16
+ static VALUE get_geometry(VALUE self);
17
+ static VALUE set_date(VALUE self, VALUE column, VALUE date);
18
+ static VALUE get_date(VALUE self, VALUE column);
19
+ static VALUE set_double(VALUE self, VALUE column, VALUE number);
20
+ static VALUE get_double(VALUE self, VALUE column);
21
+ static VALUE set_integer(VALUE self, VALUE column, VALUE integer);
22
+ static VALUE get_integer(VALUE self, VALUE column);
23
+
24
+ virtual VALUE klass();
25
+ static VALUE _klass;
26
+
27
+ Row &value() { return *_row; }
28
+
29
+ virtual ~row();
30
+ private:
31
+ Row *_row;
32
+ table *_table;
33
+ };
34
+ }
35
+
36
+ #endif
37
+
@@ -0,0 +1,19 @@
1
+
2
+ #include "shape_buffer.hpp"
3
+
4
+ namespace filegdb {
5
+
6
+ VALUE shape_buffer::_klass = Qnil;
7
+
8
+ VALUE shape_buffer::klass() {
9
+ return shape_buffer::_klass;
10
+ }
11
+
12
+ void shape_buffer::define(VALUE module)
13
+ {
14
+ shape_buffer::_klass = rb_define_class_under(module, "ShapeBuffer", rb_cObject);
15
+ base::define(shape_buffer::_klass, true);
16
+ }
17
+
18
+ }
19
+
@@ -0,0 +1,20 @@
1
+ #ifndef __FGDB_SHAPE_BUFFER_HPP__
2
+ #define __FGDB_SHAPE_BUFFER_HPP__
3
+
4
+ #include "filegdb.hpp"
5
+ #include "shape_buffer_base.hpp"
6
+
7
+ namespace filegdb {
8
+ class shape_buffer : public shape_buffer_base<shape_buffer, ShapeBuffer> {
9
+ public:
10
+ static void define(VALUE module);
11
+
12
+ virtual VALUE klass();
13
+
14
+ static VALUE _klass;
15
+
16
+ virtual ~shape_buffer() {};
17
+ };
18
+ }
19
+
20
+ #endif
@@ -0,0 +1,33 @@
1
+ #ifndef __FGDB_SHAPE_BUFFER_BASE_HPP__
2
+ #define __FGDB_SHAPE_BUFFER_BASE_HPP__
3
+
4
+ #include "filegdb.hpp"
5
+ #include "base.hpp"
6
+
7
+ namespace filegdb {
8
+ template <typename T, typename S>
9
+ class shape_buffer_base : public base<T> {
10
+ public:
11
+ shape_buffer_base() : _shape_buffer(0) {};
12
+
13
+ virtual ~shape_buffer_base() {
14
+ if (_shape_buffer) {
15
+ delete _shape_buffer;
16
+ _shape_buffer = NULL;
17
+ }
18
+ }
19
+
20
+ virtual VALUE initialize(int argc, VALUE *argv) {
21
+ _shape_buffer = new S;
22
+ return base<T>::wrapped();
23
+ }
24
+
25
+ S &value() { return *_shape_buffer; }
26
+ protected:
27
+ S *_shape_buffer;
28
+ };
29
+ }
30
+
31
+ #endif
32
+
33
+
@@ -0,0 +1,65 @@
1
+
2
+ #include "table.hpp"
3
+ #include "row.hpp"
4
+
5
+ namespace filegdb {
6
+
7
+ VALUE table::_klass = Qnil;
8
+
9
+ VALUE table::klass() {
10
+ return table::_klass;
11
+ }
12
+
13
+ table::table(geodatabase *db)
14
+ : _db(db), _table(new Table)
15
+ {
16
+ }
17
+
18
+ table::~table() {
19
+ if (_table) {
20
+ delete _table;
21
+ _table = NULL;
22
+ }
23
+ }
24
+
25
+ VALUE table::create_row_object(VALUE self) {
26
+ table *table = unwrap(self);
27
+
28
+ filegdb::row *row = new filegdb::row(table);
29
+
30
+ fgdbError hr = table->value().CreateRowObject(row->value());
31
+
32
+ if (FGDB_IS_FAILURE(hr)) {
33
+ delete row;
34
+ FGDB_RAISE_ERROR(hr);
35
+ return Qnil;
36
+ }
37
+
38
+ return row->wrapped();
39
+ }
40
+
41
+ VALUE table::insert(VALUE self, VALUE row) {
42
+ filegdb::table *table = unwrap(self);
43
+ filegdb::row *newRow = filegdb::row::unwrap(row);
44
+
45
+ fgdbError hr = table->value().Insert(newRow->value());
46
+
47
+ if (FGDB_IS_FAILURE(hr)) {
48
+ FGDB_RAISE_ERROR(hr);
49
+ return Qnil;
50
+ }
51
+
52
+ return self;
53
+ }
54
+
55
+ void table::define(VALUE module)
56
+ {
57
+ table::_klass = rb_define_class_under(module, "Table", rb_cObject);
58
+ base::define(table::_klass, false);
59
+ rb_define_method(table::_klass, "create_row_object", FGDB_METHOD(table::create_row_object), 0);
60
+ rb_define_method(table::_klass, "insert", FGDB_METHOD(table::insert), 1);
61
+ }
62
+
63
+ }
64
+
65
+
@@ -0,0 +1,29 @@
1
+ #ifndef __FGDB_TABLE_HPP__
2
+ #define __FGDB_TABLE_HPP__
3
+
4
+ #include "filegdb.hpp"
5
+ #include "geodatabase.hpp"
6
+
7
+ namespace filegdb {
8
+ class table : public base<table> {
9
+ public:
10
+ table() : base<table>(), _table(0) {};
11
+ table(geodatabase *db);
12
+ static VALUE create_row_object(VALUE self);
13
+ static VALUE insert(VALUE self, VALUE row);
14
+ static void define(VALUE module);
15
+
16
+ virtual VALUE klass();
17
+ static VALUE _klass;
18
+
19
+ Table &value() { return *_table; }
20
+
21
+ virtual ~table();
22
+
23
+ private:
24
+ Table *_table;
25
+ geodatabase *_db;
26
+ };
27
+ }
28
+
29
+ #endif