shp 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NjNiZWRkYzhhNjE3OGQ5YWExMWRmNzM1ODg3OTIwM2RmZTAzMWEyYg==
5
- data.tar.gz: !binary |-
6
- MmFkMTAxZGFiMDU3MmU1NTJiMDQ2ZjcwMzE5M2Y0NjhjNGE2MmIwZg==
2
+ SHA256:
3
+ metadata.gz: 6f0245123e61d38ed31b3afb1065b60193b20a5bce0161a66b8b6715e999ed26
4
+ data.tar.gz: 941133b419a71cc2ad5efefba01d0fb1a2e795ed4a75bc76db5e0c9745d19774
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NmViNzUwY2FhYjBkZTVmNzMwYzc0NjhhYTY4N2VjMTU4ODY4NTY5N2E0ZGFj
10
- NjIxZjE0MDczNmRiODQ4MzkwNzZmMDY3MjQ1N2IzM2EwODUwOGNjM2I4OWRj
11
- NzM1NmViMTA5YTI2NWMxZGQ5NjJiOGRkMmY4YjVmOWQyNjA3YmU=
12
- data.tar.gz: !binary |-
13
- MmRkNjhjYmM5MjEyZmVkOTYzM2U5NjVmOWY2MTVjYjUxZGE0YjE3OGFkNzY2
14
- OWEwMDIzMjhiNGJmZTEwYzg0ZGRlNjJhZDc4ZjhhZDBlOTJhMmJhY2E2NzE0
15
- NTA3NjgzNGMxOTE2NjA1NDY3MmVlNDAxOWI5YTFjNWJlMjk1M2U=
6
+ metadata.gz: bf2fcf008c5b3514af14eb223f5db69df4887b535186358750540816de9cc0c12abb59290da99a498f2263fde89466b89aadb57cb0f9e511fb0d0e151d77d0af
7
+ data.tar.gz: 37aab89a44dbf8d8aab4dfe673d850d40b98b17c8cff5522e849d7c84ca6a6f6d27e81a065b6d3235f9818723d9897c482c32b81d0260a4f355e00af8627b16b
@@ -2,3 +2,9 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.2
4
4
  - 1.9.3
5
+ - 2.0.0-p648
6
+ - 2.1.10
7
+ - 2.2.9
8
+ - 2.3.6
9
+ - 2.4.3
10
+ - 2.5.0
@@ -121,9 +121,6 @@ VALUE shapefile::create_object(VALUE klass, VALUE shapeType, VALUE shapeIndex, V
121
121
  double *zVertices = NULL;
122
122
  double *mVertices = NULL;
123
123
 
124
- int *nativeArrayOfPartStarts = NULL;
125
- int *nativeArrayOfPartTypes = NULL;
126
-
127
124
  if (!NIL_P(arrayOfZ)) {
128
125
  CHECK_ARGUMENT_ARRAY(arrayOfZ);
129
126
  zVertices = new double[FIX2INT(numberOfVertices)];
@@ -134,6 +131,22 @@ VALUE shapefile::create_object(VALUE klass, VALUE shapeType, VALUE shapeIndex, V
134
131
  mVertices = new double[FIX2INT(numberOfVertices)];
135
132
  }
136
133
 
134
+ for (int i = 0; i < FIX2INT(numberOfVertices); ++i) {
135
+ xVertices[i] = NUM2DBL(rb_ary_entry(arrayOfX, i));
136
+ yVertices[i] = NUM2DBL(rb_ary_entry(arrayOfY, i));
137
+
138
+ if (zVertices) {
139
+ zVertices[i] = NUM2DBL(rb_ary_entry(arrayOfZ, i));
140
+ }
141
+
142
+ if (mVertices) {
143
+ mVertices[i] = NUM2DBL(rb_ary_entry(arrayOfM, i));
144
+ }
145
+ }
146
+
147
+ int *nativeArrayOfPartStarts = NULL;
148
+ int *nativeArrayOfPartTypes = NULL;
149
+
137
150
  if (!NIL_P(arrayOfPartStarts)) {
138
151
  CHECK_ARGUMENT_ARRAY(arrayOfPartStarts);
139
152
  nativeArrayOfPartStarts = new int[FIX2INT(numberOfParts)];
@@ -305,7 +318,7 @@ void shapefile::define(VALUE module)
305
318
  rb_define_singleton_method(shapefile::_klass, "open", SHP_METHOD(shapefile::open), 2);
306
319
  rb_define_singleton_method(shapefile::_klass, "create", SHP_METHOD(shapefile::create), 2);
307
320
  rb_define_singleton_method(shapefile::_klass, "create_simple_object", SHP_METHOD(shapefile::create_simple_object), 5);
308
- rb_define_singleton_method(shapefile::_klass, "create_object", SHP_METHOD(shapefile::create_simple_object), 10);
321
+ rb_define_singleton_method(shapefile::_klass, "create_object", SHP_METHOD(shapefile::create_object), 10);
309
322
  rb_define_method(shapefile::_klass, "write_object", SHP_METHOD(shapefile::write_object), 2);
310
323
  rb_define_method(shapefile::_klass, "close", SHP_METHOD(shapefile::close), 0);
311
324
  rb_define_method(shapefile::_klass, "get_info", SHP_METHOD(shapefile::get_info), 0);
@@ -1,3 +1,3 @@
1
1
  module SHP
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -128,7 +128,7 @@ describe "SHP" do
128
128
  lambda { file.get_info }.should raise_error
129
129
  end
130
130
 
131
- context 'shp' do
131
+ context 'single part polygon' do
132
132
  before(:each) do
133
133
  sni_office = [ [ -82.72932529449463, 27.93789618055838 ],
134
134
  [ -82.72932529449463, 27.93768765436987 ],
@@ -221,4 +221,107 @@ describe "SHP" do
221
221
  @obj.get_m_max.should eq(0)
222
222
  end
223
223
  end
224
+
225
+ context 'multipart polygon' do
226
+ before(:each) do
227
+ multipolygon = [
228
+ [0, 0], [5, 0], [5, 4], [0, 4], [0, 0], # outer ring 1
229
+ [1, 1], [2, 1], [2, 2], [1, 2], [1, 1], # inner ring
230
+ [-1, -1], [-1, -3], [-2, -3], [-2, -1], [-1, -1], # outer ring 2
231
+ ]
232
+ x_values = multipolygon.map { |v| v[0] }
233
+ y_values = multipolygon.map { |v| v[1] }
234
+ nparts = 3
235
+ pan_part_start = [0, 5, 10]
236
+ n_vertices = x_values.length
237
+
238
+ @shp = SHP::Shapefile.create('testfile_multipolygons', 5)
239
+ @shape = SHP::Shapefile.create_object(
240
+ 5, # ShpType ID(5=POLYGON)
241
+ -1, # iShape
242
+ nparts,
243
+ pan_part_start,
244
+ nil, # panPartType
245
+ n_vertices,
246
+ x_values,
247
+ y_values,
248
+ nil, # z_values
249
+ nil # M values
250
+ )
251
+ @shp.write_object(-1, @shape)
252
+ @obj = @shp.read_object(0)
253
+ end
254
+
255
+ it 'should return the shape type' do
256
+ @obj.get_shape_type.should eq(5)
257
+ end
258
+
259
+ it 'should return the shape id' do
260
+ @obj.get_shape_id.should eq(0)
261
+ end
262
+
263
+ it 'should return the shape part count' do
264
+ @obj.get_shape_parts.should eq(3)
265
+ end
266
+
267
+ it 'should return the shape part start offsets' do
268
+ @obj.get_shape_part_starts.should eq([0, 5, 10])
269
+ end
270
+
271
+ it 'should return the shape part types' do
272
+ @obj.get_shape_part_types.should eq([5, 5, 5]) # [SHPP_RING]
273
+ end
274
+
275
+ it 'should return the vertex count' do
276
+ @obj.get_vertex_count.should eq(15)
277
+ end
278
+
279
+ it 'should return the x values' do
280
+ @obj.get_x.should eq([0, 5, 5, 0, 0, 1, 2, 2, 1, 1, -1, -1, -2, -2, -1].map(&:to_f))
281
+ end
282
+
283
+ it 'should return the y values' do
284
+ @obj.get_y.should eq([0, 0, 4, 4, 0, 1, 1, 2, 2, 1, -1, -3, -3, -1, -1].map(&:to_f))
285
+ end
286
+
287
+ it 'should return the z values' do
288
+ @obj.get_z.should eq(Array.new(15, 0))
289
+ end
290
+
291
+ it 'should return the m values' do
292
+ @obj.get_m.should eq(Array.new(15, 0))
293
+ end
294
+
295
+ it 'should return the x min' do
296
+ @obj.get_x_min.should eq(-2.0)
297
+ end
298
+
299
+ it 'should return the y min' do
300
+ @obj.get_y_min.should eq(-3.0)
301
+ end
302
+
303
+ it 'should return the z min' do
304
+ @obj.get_z_min.should eq(0)
305
+ end
306
+
307
+ it 'should return the m min' do
308
+ @obj.get_m_min.should eq(0)
309
+ end
310
+
311
+ it 'should return the x max' do
312
+ @obj.get_x_max.should eq(5.0)
313
+ end
314
+
315
+ it 'should return the y max' do
316
+ @obj.get_y_max.should eq(4.0)
317
+ end
318
+
319
+ it 'should return the z max' do
320
+ @obj.get_z_max.should eq(0)
321
+ end
322
+
323
+ it 'should return the m max' do
324
+ @obj.get_m_max.should eq(0)
325
+ end
326
+ end
224
327
  end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
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-12-16 00:00:00.000000000 Z
11
+ date: 2018-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake-compiler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: ESRI Shapefile bindings for ruby using shapelib
@@ -60,8 +60,8 @@ extensions:
60
60
  - ext/shp/extconf.rb
61
61
  extra_rdoc_files: []
62
62
  files:
63
- - .gitignore
64
- - .travis.yml
63
+ - ".gitignore"
64
+ - ".travis.yml"
65
65
  - Gemfile
66
66
  - LICENSE
67
67
  - README.md
@@ -156,21 +156,20 @@ require_paths:
156
156
  - ext
157
157
  required_ruby_version: !ruby/object:Gem::Requirement
158
158
  requirements:
159
- - - ! '>='
159
+ - - ">="
160
160
  - !ruby/object:Gem::Version
161
161
  version: '0'
162
162
  required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ! '>='
164
+ - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  requirements: []
168
168
  rubyforge_project:
169
- rubygems_version: 2.1.5
169
+ rubygems_version: 2.7.4
170
170
  signing_key:
171
171
  specification_version: 4
172
172
  summary: ESRI Shapefile bindings for ruby using shapelib. Currently contains native
173
173
  extensions for ShapeLib 1.3
174
174
  test_files:
175
175
  - spec/shp_spec.rb
176
- has_rdoc: