filegdb 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzFlYzdmNzU1Y2Y2NTg0MTZhMGFmNGFkMTJjZmVmZGViYmRkMjZhOQ==
4
+ NDQ3ODRmZTVmYmQ1NjI1Mjc5OGJlZWQwNDkzNjg2ZWIwYmU0NzNlYw==
5
5
  data.tar.gz: !binary |-
6
- MzM3ZmU2M2NkNTA3MjZhZjRhNWI0ZTc5OWU0ODE3ZDFiYTQyOTJjZA==
6
+ YTA1Y2FiMjIzMTBhYWNiYTI5NTllOWZhNTQ2OWNhYzkzYzc1NjdmNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OWZmMzc0NDIyZWE3NWE2ZjBkM2M0Y2FjZTQ2YWYwYTc2YTA1ZjU5M2JlNjRk
10
- MzY3NWE3OWFlMGQ2OTc5Mjk1NzYwYmI4ZTUxZjdkZDM3ODY2Y2EyNjNjNzk4
11
- MDM2NWQ1ZWI5OTllODUwYTQxNDZkODUxMDMzMzIyMjU3NjRhMDQ=
9
+ OTUxMjlkMjM0MjNiYTkxZjkyNTVlZGZhNThhZjhhN2IwZTFjMTc5MzdlN2Zj
10
+ Yjc4N2EwN2IxMmQ3NDJhMWFiOWQxMzIwNzY2Nzk0YTc4ZWE2NDMyNjA4ZmFi
11
+ YWU5Y2VlYmVkNTc1N2ZmNDAxZjM2MTkwYTRjZDZkN2RjNzQ0MGM=
12
12
  data.tar.gz: !binary |-
13
- NDgxMTcyNzI1MTQyZjg2ZWNhZDJmZWMxZTlkODZiMWQ2Y2EyOTgzNWEwNjJl
14
- OTc4YmY0NjAyNTg2ZWJmNjdmYTU3NjgxNTkxNjM4MWNlYTk1MTljNDJiZDQx
15
- OTg1NzRhZWVmOWEyOGI2ODU2MGYxMzViMzY1NTgyYTI2ZDIzOTY=
13
+ N2EyOWM2ZTE2MTdlYTY5ODljMDY0NTRlYzU5ZTFlZGQ2ZmUwOTgxMDg4Njkx
14
+ OWRjYzk5NmY2ZTg1M2RiODg1OTA0MjZkNWQ2NDRlNTQ3MWQ0ODRiYzQ0NGY1
15
+ Y2QwNGMxNWFkMWQwOWJlMzlmNjVlOTRmYjY0NTFmZDkzMjY4ZTc=
@@ -10,4 +10,50 @@ $libs = append_library $libs, 'FileGDBAPI'
10
10
 
11
11
  $LDFLAGS << " -Wl,-rpath,#{File.join(filegdb_path, 'lib')}"
12
12
 
13
+ if RUBY_PLATFORM =~ /darwin12/
14
+ # libFileGDBAPI requires GCC compilation because its C++ symbols are incompatible with LLVM 5.0
15
+ #
16
+ # To install GCC on OSX:
17
+ #
18
+ # $ brew tap homebrew/versions
19
+ # $ brew install --enable-cxx gcc49
20
+ #
21
+
22
+ msg = <<-GCC
23
+
24
+
25
+ \e[31m
26
+ ===========================================================================================================================
27
+ ===========================================================================================================================
28
+
29
+ The filegdb gem requires GCC on OSX Mavericks because the C++ symbols in libFileGDBAPI.dylib are incompatible with LLVM 5.0
30
+
31
+ To install GCC on OSX:
32
+
33
+ $ brew tap homebrew/versions
34
+ $ brew install --enable-cxx gcc49
35
+
36
+ Note: Installing GCC through homebrew is safe and will not interfere with your Xcode installation.
37
+
38
+ Report installation bugs here: https://github.com/spatialnetworks/filegdb-ruby
39
+
40
+ ===========================================================================================================================
41
+ ===========================================================================================================================
42
+ \e[0m
43
+
44
+ GCC
45
+
46
+ if `which gcc-4.9`.strip.length == 0
47
+ puts msg
48
+ exit
49
+ end
50
+
51
+ require 'rbconfig'
52
+ RbConfig::MAKEFILE_CONFIG['CC'] = 'gcc-4.9'
53
+ RbConfig::MAKEFILE_CONFIG['CXX'] = 'gcc-4.9'
54
+
55
+ # remove -Wshorten-64-to-32 since it's incompatible with GCC
56
+ $warnflags = $warnflags.gsub(/-Wshorten-64-to-32/, '')
57
+ end
58
+
13
59
  create_makefile 'filegdb/filegdb'
@@ -0,0 +1,116 @@
1
+
2
+ #include "field_info.hpp"
3
+
4
+ namespace filegdb {
5
+
6
+ VALUE field_info::_klass = Qnil;
7
+
8
+ VALUE field_info::klass() {
9
+ return field_info::_klass;
10
+ }
11
+
12
+ field_info::~field_info() {
13
+ if (_fieldInfo) {
14
+ delete _fieldInfo;
15
+ _fieldInfo = NULL;
16
+ }
17
+ }
18
+
19
+ VALUE field_info::get_field_count(VALUE self) {
20
+ filegdb::field_info *info = unwrap(self);
21
+
22
+ int fieldCount = -1;
23
+
24
+ fgdbError hr = info->value().GetFieldCount(fieldCount);
25
+
26
+ if (FGDB_IS_FAILURE(hr)) {
27
+ FGDB_RAISE_ERROR(hr);
28
+ return Qnil;
29
+ }
30
+
31
+ return INT2FIX(fieldCount);
32
+ }
33
+
34
+ VALUE field_info::get_field_name(VALUE self, VALUE fieldIndex) {
35
+ CHECK_ARGUMENT_FIXNUM(fieldIndex);
36
+
37
+ filegdb::field_info *info = unwrap(self);
38
+
39
+ std::wstring fieldName;
40
+
41
+ fgdbError hr = info->value().GetFieldName(FIX2INT(fieldIndex), fieldName);
42
+
43
+ if (FGDB_IS_FAILURE(hr)) {
44
+ FGDB_RAISE_ERROR(hr);
45
+ return Qnil;
46
+ }
47
+
48
+ return rb_str_new2(to_char_array(fieldName));
49
+ }
50
+
51
+ VALUE field_info::get_field_type(VALUE self, VALUE fieldIndex) {
52
+ CHECK_ARGUMENT_FIXNUM(fieldIndex);
53
+
54
+ filegdb::field_info *info = unwrap(self);
55
+
56
+ FieldType type;
57
+
58
+ fgdbError hr = info->value().GetFieldType(FIX2INT(fieldIndex), type);
59
+
60
+ if (FGDB_IS_FAILURE(hr)) {
61
+ FGDB_RAISE_ERROR(hr);
62
+ return Qnil;
63
+ }
64
+
65
+ return INT2FIX((int)type);
66
+ }
67
+
68
+ VALUE field_info::get_field_length(VALUE self, VALUE fieldIndex) {
69
+ CHECK_ARGUMENT_FIXNUM(fieldIndex);
70
+
71
+ filegdb::field_info *info = unwrap(self);
72
+
73
+ int length;
74
+
75
+ fgdbError hr = info->value().GetFieldLength(FIX2INT(fieldIndex), length);
76
+
77
+ if (FGDB_IS_FAILURE(hr)) {
78
+ FGDB_RAISE_ERROR(hr);
79
+ return Qnil;
80
+ }
81
+
82
+ return INT2FIX(length);
83
+ }
84
+
85
+ VALUE field_info::get_field_is_nullable(VALUE self, VALUE fieldIndex) {
86
+ CHECK_ARGUMENT_FIXNUM(fieldIndex);
87
+
88
+ filegdb::field_info *info = unwrap(self);
89
+
90
+ bool isNullable = false;
91
+
92
+ fgdbError hr = info->value().GetFieldIsNullable(FIX2INT(fieldIndex), isNullable);
93
+
94
+ if (FGDB_IS_FAILURE(hr)) {
95
+ FGDB_RAISE_ERROR(hr);
96
+ return Qnil;
97
+ }
98
+
99
+ return isNullable ? Qtrue : Qfalse;
100
+ }
101
+
102
+ void field_info::define(VALUE module)
103
+ {
104
+ field_info::_klass = rb_define_class_under(module, "FieldInfo", rb_cObject);
105
+ base::define(field_info::_klass, false);
106
+ rb_define_method(field_info::_klass, "get_field_count", FGDB_METHOD(field_info::get_field_count), 0);
107
+ rb_define_method(field_info::_klass, "get_field_name", FGDB_METHOD(field_info::get_field_name), 1);
108
+ rb_define_method(field_info::_klass, "get_field_type", FGDB_METHOD(field_info::get_field_type), 1);
109
+ rb_define_method(field_info::_klass, "get_field_length", FGDB_METHOD(field_info::get_field_length), 1);
110
+ rb_define_method(field_info::_klass, "get_field_is_nullable", FGDB_METHOD(field_info::get_field_is_nullable), 1);
111
+ }
112
+
113
+ }
114
+
115
+
116
+
@@ -0,0 +1,32 @@
1
+ #ifndef __FGDB_FIELD_INFO_HPP__
2
+ #define __FGDB_FIELD_INFO_HPP__
3
+
4
+ #include "filegdb.hpp"
5
+ #include "base.hpp"
6
+
7
+ namespace filegdb {
8
+ class field_info : public base<field_info> {
9
+ public:
10
+ field_info() : base<field_info>(), _fieldInfo(new FieldInfo) {};
11
+ static void define(VALUE module);
12
+
13
+ static VALUE get_field_count(VALUE self);
14
+ static VALUE get_field_name(VALUE self, VALUE fieldIndex);
15
+ static VALUE get_field_type(VALUE self, VALUE fieldIndex);
16
+ static VALUE get_field_length(VALUE self, VALUE fieldIndex);
17
+ static VALUE get_field_is_nullable(VALUE self, VALUE fieldIndex);
18
+
19
+ virtual VALUE klass();
20
+ static VALUE _klass;
21
+
22
+ FieldInfo &value() { return *_fieldInfo; }
23
+
24
+ virtual ~field_info();
25
+
26
+ private:
27
+ FieldInfo *_fieldInfo;
28
+ };
29
+ }
30
+
31
+ #endif
32
+
@@ -10,6 +10,8 @@
10
10
  #include "point_shape_buffer.hpp"
11
11
  #include "multi_point_shape_buffer.hpp"
12
12
  #include "point.hpp"
13
+ #include "field_info.hpp"
14
+ #include "spatial_reference.hpp"
13
15
 
14
16
  VALUE cFileGDB;
15
17
 
@@ -23,5 +25,7 @@ extern "C" {
23
25
  filegdb::shape_buffer::define(cFileGDB);
24
26
  filegdb::point_shape_buffer::define(cFileGDB);
25
27
  filegdb::multi_point_shape_buffer::define(cFileGDB);
28
+ filegdb::field_info::define(cFileGDB);
29
+ filegdb::spatial_reference::define(cFileGDB);
26
30
  }
27
31
  }
@@ -0,0 +1,61 @@
1
+
2
+ #include "spatial_reference.hpp"
3
+
4
+ namespace filegdb {
5
+
6
+ VALUE spatial_reference::_klass = Qnil;
7
+
8
+ VALUE spatial_reference::klass() {
9
+ return spatial_reference::_klass;
10
+ }
11
+
12
+ spatial_reference::~spatial_reference() {
13
+ if (_spatialReference) {
14
+ delete _spatialReference;
15
+ _spatialReference = NULL;
16
+ }
17
+ }
18
+
19
+ VALUE spatial_reference::get_spatial_reference_text(VALUE self) {
20
+ filegdb::spatial_reference *srs = unwrap(self);
21
+
22
+ std::wstring text;
23
+
24
+ fgdbError hr = srs->value().GetSpatialReferenceText(text);
25
+
26
+ if (FGDB_IS_FAILURE(hr)) {
27
+ FGDB_RAISE_ERROR(hr);
28
+ return Qnil;
29
+ }
30
+
31
+ return rb_str_new2(to_char_array(text));
32
+ }
33
+
34
+ VALUE spatial_reference::set_spatial_reference_text(VALUE self, VALUE srs) {
35
+ CHECK_ARGUMENT_STRING(srs);
36
+
37
+ filegdb::spatial_reference *reference = unwrap(self);
38
+
39
+ fgdbError hr = reference->value().SetSpatialReferenceText(to_wstring(RSTRING_PTR(srs)));
40
+
41
+ if (FGDB_IS_FAILURE(hr)) {
42
+ FGDB_RAISE_ERROR(hr);
43
+ return Qnil;
44
+ }
45
+
46
+ return Qnil;
47
+ }
48
+
49
+ void spatial_reference::define(VALUE module)
50
+ {
51
+ spatial_reference::_klass = rb_define_class_under(module, "SpatialReference", rb_cObject);
52
+ base::define(spatial_reference::_klass, true);
53
+ rb_define_method(spatial_reference::_klass, "get_spatial_reference_text", FGDB_METHOD(spatial_reference::get_spatial_reference_text), 0);
54
+ rb_define_method(spatial_reference::_klass, "set_spatial_reference_text", FGDB_METHOD(spatial_reference::set_spatial_reference_text), 1);
55
+ }
56
+
57
+ }
58
+
59
+
60
+
61
+
@@ -0,0 +1,30 @@
1
+ #ifndef __FGDB_SPATIAL_REFERENCE_HPP__
2
+ #define __FGDB_SPATIAL_REFERENCE_HPP__
3
+
4
+ #include "filegdb.hpp"
5
+ #include "base.hpp"
6
+
7
+ namespace filegdb {
8
+ class spatial_reference : public base<spatial_reference> {
9
+ public:
10
+ spatial_reference() : base<spatial_reference>(), _spatialReference(new SpatialReference) {};
11
+ static void define(VALUE module);
12
+
13
+ static VALUE get_spatial_reference_text(VALUE self);
14
+ static VALUE set_spatial_reference_text(VALUE self, VALUE srs);
15
+
16
+ virtual VALUE klass();
17
+ static VALUE _klass;
18
+
19
+ SpatialReference &value() { return *_spatialReference; }
20
+
21
+ virtual ~spatial_reference();
22
+
23
+ private:
24
+ SpatialReference *_spatialReference;
25
+ };
26
+ }
27
+
28
+ #endif
29
+
30
+
@@ -1,6 +1,7 @@
1
1
 
2
2
  #include "table.hpp"
3
3
  #include "row.hpp"
4
+ #include "field_info.hpp"
4
5
 
5
6
  namespace filegdb {
6
7
 
@@ -52,12 +53,76 @@ VALUE table::insert(VALUE self, VALUE row) {
52
53
  return self;
53
54
  }
54
55
 
56
+ VALUE table::get_definition(VALUE self) {
57
+ filegdb::table *table = unwrap(self);
58
+
59
+ std::string definition;
60
+
61
+ fgdbError hr = table->value().GetDefinition(definition);
62
+
63
+ if (FGDB_IS_FAILURE(hr)) {
64
+ FGDB_RAISE_ERROR(hr);
65
+ return Qnil;
66
+ }
67
+
68
+ return rb_str_new2(definition.c_str());
69
+ }
70
+
71
+ VALUE table::get_documentation(VALUE self) {
72
+ filegdb::table *table = unwrap(self);
73
+
74
+ std::string documentation;
75
+
76
+ fgdbError hr = table->value().GetDocumentation(documentation);
77
+
78
+ if (FGDB_IS_FAILURE(hr)) {
79
+ FGDB_RAISE_ERROR(hr);
80
+ return Qnil;
81
+ }
82
+
83
+ return rb_str_new2(documentation.c_str());
84
+ }
85
+
86
+ VALUE table::set_documentation(VALUE self, VALUE documentation) {
87
+ CHECK_ARGUMENT_STRING(documentation);
88
+
89
+ filegdb::table *table = unwrap(self);
90
+
91
+ fgdbError hr = table->value().SetDocumentation(std::string(RSTRING_PTR(documentation)));
92
+
93
+ if (FGDB_IS_FAILURE(hr)) {
94
+ FGDB_RAISE_ERROR(hr);
95
+ return Qnil;
96
+ }
97
+
98
+ return Qnil;
99
+ }
100
+
101
+ VALUE table::get_field_information(VALUE self) {
102
+ filegdb::table *table = unwrap(self);
103
+
104
+ filegdb::field_info *info = new filegdb::field_info();
105
+
106
+ fgdbError hr = table->value().GetFieldInformation(info->value());
107
+
108
+ if (FGDB_IS_FAILURE(hr)) {
109
+ FGDB_RAISE_ERROR(hr);
110
+ return Qnil;
111
+ }
112
+
113
+ return info->wrapped();
114
+ }
115
+
55
116
  void table::define(VALUE module)
56
117
  {
57
118
  table::_klass = rb_define_class_under(module, "Table", rb_cObject);
58
119
  base::define(table::_klass, false);
59
120
  rb_define_method(table::_klass, "create_row_object", FGDB_METHOD(table::create_row_object), 0);
60
121
  rb_define_method(table::_klass, "insert", FGDB_METHOD(table::insert), 1);
122
+ rb_define_method(table::_klass, "get_definition", FGDB_METHOD(table::get_definition), 0);
123
+ rb_define_method(table::_klass, "get_documentation", FGDB_METHOD(table::get_documentation), 0);
124
+ rb_define_method(table::_klass, "set_documentation", FGDB_METHOD(table::set_documentation), 1);
125
+ rb_define_method(table::_klass, "get_field_information", FGDB_METHOD(table::get_field_information), 0);
61
126
  }
62
127
 
63
128
  }
@@ -13,6 +13,11 @@ namespace filegdb {
13
13
  static VALUE insert(VALUE self, VALUE row);
14
14
  static void define(VALUE module);
15
15
 
16
+ static VALUE get_definition(VALUE self);
17
+ static VALUE get_documentation(VALUE self);
18
+ static VALUE set_documentation(VALUE self, VALUE documentation);
19
+ static VALUE get_field_information(VALUE self);
20
+
16
21
  virtual VALUE klass();
17
22
  static VALUE _klass;
18
23
 
@@ -1,3 +1,3 @@
1
1
  module FileGDB
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'FieldInfo' do
4
+ before(:each) do
5
+ delete_database rescue nil
6
+ @db = create_database
7
+ @table = @db.create_table('', table_definition)
8
+ @info = @table.get_field_information
9
+ end
10
+
11
+ after(:each) do
12
+ @db.close if @db
13
+ delete_database
14
+ end
15
+
16
+ it 'gets the field count' do
17
+ @info.get_field_count.should eq(3)
18
+ end
19
+
20
+ it 'gets the field name' do
21
+ @info.get_field_name(2).should eq('string_field')
22
+ end
23
+
24
+ it 'gets the field type' do
25
+ @info.get_field_type(2).should eq(4)
26
+ end
27
+
28
+ it 'gets the field length' do
29
+ @info.get_field_length(2).should eq(4000)
30
+ end
31
+
32
+ it 'gets the field nullability' do
33
+ @info.get_field_is_nullable(2).should eq(true)
34
+ end
35
+ end
36
+
37
+
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'SpatialReference' do
4
+ before(:each) do
5
+ delete_database rescue nil
6
+ @db = create_database
7
+ @table = @db.create_table('', table_definition)
8
+ @info = @table.get_field_information
9
+ @srs = FileGDB::SpatialReference.new
10
+ @valid_srs = 'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]'
11
+ end
12
+
13
+ after(:each) do
14
+ @db.close if @db
15
+ delete_database
16
+ end
17
+
18
+ it 'gets the spatial reference text' do
19
+ @srs.get_spatial_reference_text.should eq('')
20
+ end
21
+
22
+ it 'sets the spatial reference text' do
23
+ lambda { @srs.set_spatial_reference_text(@valid_srs) }.should_not raise_error
24
+ @srs.get_spatial_reference_text.should eq(@valid_srs)
25
+ end
26
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Table' do
4
+ before(:each) do
5
+ delete_database rescue nil
6
+ @db = create_database
7
+ @table = @db.create_table('', table_definition)
8
+ end
9
+
10
+ after(:each) do
11
+ @db.close if @db
12
+ delete_database
13
+ end
14
+
15
+ it 'gets the definition' do
16
+ @table.get_definition.should_not be_nil
17
+ end
18
+
19
+ it 'gets the documentation' do
20
+ @table.get_documentation.should eq('')
21
+ end
22
+
23
+ it 'sets the documentation' do
24
+ @table.set_documentation('Table Documentation')
25
+ @table.get_documentation.should eq('Table Documentation')
26
+ end
27
+
28
+ it 'gets the field information' do
29
+ @table.get_field_information.should_not be_nil
30
+ end
31
+ end
32
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filegdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zac McCormick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-16 00:00:00.000000000 Z
11
+ date: 2013-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -69,6 +69,8 @@ files:
69
69
  - Rakefile
70
70
  - ext/filegdb/base.hpp
71
71
  - ext/filegdb/extconf.rb
72
+ - ext/filegdb/field_info.cpp
73
+ - ext/filegdb/field_info.hpp
72
74
  - ext/filegdb/filegdb.cpp
73
75
  - ext/filegdb/filegdb.hpp
74
76
  - ext/filegdb/filegdb/include/FileGDBAPI.h
@@ -97,6 +99,8 @@ files:
97
99
  - ext/filegdb/shape_buffer.cpp
98
100
  - ext/filegdb/shape_buffer.hpp
99
101
  - ext/filegdb/shape_buffer_base.hpp
102
+ - ext/filegdb/spatial_reference.cpp
103
+ - ext/filegdb/spatial_reference.hpp
100
104
  - ext/filegdb/table.cpp
101
105
  - ext/filegdb/table.hpp
102
106
  - ext/filegdb/util.cpp
@@ -107,12 +111,15 @@ files:
107
111
  - spec/data/domain_definition_altered.xml
108
112
  - spec/data/feature_dataset_definition.xml
109
113
  - spec/data/table_definition.xml
114
+ - spec/field_info_spec.rb
110
115
  - spec/filegdb_spec.rb
111
116
  - spec/geodatabase_spec.rb
112
117
  - spec/multi_point_shape_buffer_spec.rb
113
118
  - spec/point_shape_buffer_spec.rb
114
119
  - spec/row_spec.rb
120
+ - spec/spatial_reference_spec.rb
115
121
  - spec/spec_helper.rb
122
+ - spec/table_spec.rb
116
123
  homepage: https://github.com/spatialnetworks/filegdb-ruby
117
124
  licenses:
118
125
  - BSD
@@ -144,10 +151,13 @@ test_files:
144
151
  - spec/data/domain_definition_altered.xml
145
152
  - spec/data/feature_dataset_definition.xml
146
153
  - spec/data/table_definition.xml
154
+ - spec/field_info_spec.rb
147
155
  - spec/filegdb_spec.rb
148
156
  - spec/geodatabase_spec.rb
149
157
  - spec/multi_point_shape_buffer_spec.rb
150
158
  - spec/point_shape_buffer_spec.rb
151
159
  - spec/row_spec.rb
160
+ - spec/spatial_reference_spec.rb
152
161
  - spec/spec_helper.rb
162
+ - spec/table_spec.rb
153
163
  has_rdoc: