geo_concerns 0.0.1 → 0.0.2

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 (32) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -0
  3. data/README.md +6 -1
  4. data/app/models/concerns/geo_concerns/file_set/derivatives.rb +5 -5
  5. data/app/models/concerns/geo_concerns/image_file_behavior.rb +1 -1
  6. data/app/models/concerns/geo_concerns/raster_file_behavior.rb +1 -1
  7. data/app/models/concerns/geo_concerns/vector_file_behavior.rb +1 -1
  8. data/app/processors/geo_concerns/processors/base_geo_processor.rb +44 -34
  9. data/app/processors/geo_concerns/processors/gdal.rb +49 -0
  10. data/app/processors/geo_concerns/processors/ogr.rb +19 -0
  11. data/app/processors/geo_concerns/processors/raster/aig.rb +13 -17
  12. data/app/processors/geo_concerns/processors/raster/base.rb +15 -49
  13. data/app/processors/geo_concerns/processors/raster/dem.rb +14 -31
  14. data/app/processors/geo_concerns/processors/raster/info.rb +52 -0
  15. data/app/processors/geo_concerns/processors/raster/processor.rb +0 -1
  16. data/app/processors/geo_concerns/processors/vector/base.rb +16 -42
  17. data/app/processors/geo_concerns/processors/vector/processor.rb +0 -1
  18. data/app/processors/geo_concerns/processors/vector/shapefile.rb +2 -2
  19. data/app/processors/geo_concerns/processors/zip.rb +2 -4
  20. data/geo_concerns.gemspec +7 -8
  21. data/lib/geo_concerns/version.rb +1 -1
  22. data/spec/controllers/image_works_controller_spec.rb +16 -0
  23. data/spec/processors/geo_concerns/processors/base_geo_processor_spec.rb +29 -25
  24. data/spec/processors/geo_concerns/processors/gdal_spec.rb +59 -0
  25. data/spec/processors/geo_concerns/processors/ogr_spec.rb +36 -0
  26. data/spec/processors/geo_concerns/processors/raster/aig_spec.rb +12 -5
  27. data/spec/processors/geo_concerns/processors/raster/base_spec.rb +15 -47
  28. data/spec/processors/geo_concerns/processors/raster/dem_spec.rb +14 -10
  29. data/spec/processors/geo_concerns/processors/raster/info_spec.rb +35 -0
  30. data/spec/processors/geo_concerns/processors/vector/base_spec.rb +15 -28
  31. data/spec/processors/geo_concerns/processors/vector/shapefile_spec.rb +1 -1
  32. metadata +37 -42
@@ -4,7 +4,7 @@ describe GeoConcerns::Processors::Raster::Base do
4
4
  let(:output_file) { 'output/geo.png' }
5
5
  let(:file_name) { 'files/geo.tif' }
6
6
  let(:label) {}
7
- let(:options) { { output_format: 'PNG', output_size: '150 150', label: label } }
7
+ let(:options) { { output_size: '150 150', label: label } }
8
8
 
9
9
  subject { described_class.new(file_name, {}) }
10
10
 
@@ -26,61 +26,29 @@ describe GeoConcerns::Processors::Raster::Base do
26
26
  end
27
27
  end
28
28
 
29
- describe '#encode_raster' do
30
- it 'executes the translate command and cleans up aux file' do
31
- expect(subject.class).to receive(:execute)
32
- expect(File).to receive(:unlink).with("#{output_file}.aux.xml")
33
- subject.class.encode_raster(file_name, options, output_file)
29
+ describe '#encode_queue' do
30
+ it 'returns an array of command name symbols' do
31
+ expect(subject.class.encode_queue).to include :translate
34
32
  end
35
33
  end
36
34
 
37
- describe '#reproject_raster' do
38
- it 'executes the warp and compress commands, then cleans up intermediate file' do
39
- expect(subject.class).to receive(:execute).twice
40
- expect(FileUtils).to receive(:rm_rf)
41
- subject.class.reproject_raster(file_name, options, output_file)
35
+ describe '#reproject_queue' do
36
+ it 'returns an array of command name symbols' do
37
+ expect(subject.class.reproject_queue).to include :warp
42
38
  end
43
39
  end
44
40
 
45
- describe '#warp' do
46
- it 'returns a gdalwarp command ' do
47
- expect(subject.class.warp(file_name, options, output_file))
48
- .to include('gdalwarp')
49
- end
50
- end
51
-
52
- describe '#compress' do
53
- it 'returns a gdal_translate command with a compress option' do
54
- expect(subject.class.compress(file_name, options, output_file))
55
- .to include('gdal_translate', 'COMPRESS=LZW')
56
- end
57
- end
58
-
59
- describe '#get_raster_min_max' do
60
- let(:min_max) { subject.class.get_raster_min_max(info_string) }
61
-
62
- context 'when a string has computed min and max' do
63
- let(:info_string) { 'Band 1 Block=256x16 Type=Float32 Computed Min/Max=2.054,11.717 ' }
64
-
65
- it 'returns with formatted text' do
66
- expect(min_max).to eq('2.054 11.717')
67
- end
68
- end
69
-
70
- context 'when a string does not have a computed min and max' do
71
- let(:info_string) { 'Band 1 Block=256x16 Type=Float32' }
72
-
73
- it 'returns with formatted text' do
74
- expect(min_max).to eq('')
75
- end
41
+ describe '#encode_raster' do
42
+ it 'runs commands to encode the raster thumbnail' do
43
+ expect(subject.class).to receive(:run_commands)
44
+ subject.class.encode_raster(file_name, options, output_file)
76
45
  end
77
46
  end
78
47
 
79
- describe '#gdalinfo' do
80
- it 'shells out to gdalinfo and returns the output as a string' do
81
- expect(Open3).to receive(:capture3).with("gdalinfo -mm #{file_name}")
82
- .and_return(['info', '', ''])
83
- expect(subject.class.gdalinfo(file_name)).to eq('info')
48
+ describe '#reproject_raster' do
49
+ it 'runs commands to reproject the raster' do
50
+ expect(subject.class).to receive(:run_commands)
51
+ subject.class.reproject_raster(file_name, options, output_file)
84
52
  end
85
53
  end
86
54
  end
@@ -3,24 +3,28 @@ require 'spec_helper'
3
3
  describe GeoConcerns::Processors::Raster::Dem do
4
4
  let(:output_file) { 'output/geo.png' }
5
5
  let(:file_name) { 'files/geo.dem' }
6
- let(:options) { { output_format: 'PNG',
7
- output_size: '150 150',
8
- label: :thumbnail }
6
+ let(:options) { { output_size: '150 150', label: :thumbnail }
9
7
  }
10
8
 
11
9
  subject { described_class.new(file_name, {}) }
12
10
 
13
- describe '#translate' do
14
- it 'returns a translate command for the USGS Digital Elevation Model format' do
15
- expect(subject.class.translate(file_name, options, output_file))
16
- .to include('USGSDEM')
11
+ describe '#encode_queue' do
12
+ it 'returns an array of command name symbols' do
13
+ expect(subject.class.encode_queue).to include :hillshade
14
+ end
15
+ end
16
+
17
+ describe '#reproject_queue' do
18
+ it 'returns an array of command name symbols' do
19
+ expect(subject.class.reproject_queue).to include :hillshade
17
20
  end
18
21
  end
19
22
 
20
23
  describe '#hillshade' do
21
- it 'returns a gdal hillshade command' do
22
- expect(subject.class.hillshade(file_name, options, output_file))
23
- .to include('gdaldem hillshade')
24
+ it 'executes a gdal hillshade command' do
25
+ command = "gdaldem hillshade -q -of GTiff \"files/geo.dem\" output/geo.png"
26
+ expect(subject.class).to receive(:execute).with command
27
+ subject.class.hillshade(file_name, output_file, options)
24
28
  end
25
29
  end
26
30
  end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+ require 'open3'
3
+
4
+ describe GeoConcerns::Processors::Raster::Info do
5
+ let(:path) { 'test.tif' }
6
+ let(:info_doc) { read_test_data_fixture('gdalinfo.txt') }
7
+
8
+ subject { described_class.new(path) }
9
+
10
+ context 'when initializing a new info class' do
11
+ it 'shells out to gdalinfo and sets the doc variable to the output string' do
12
+ expect(Open3).to receive(:capture3).with("gdalinfo -mm #{path}")
13
+ .and_return([info_doc, '', ''])
14
+ expect(subject.doc).to eq(info_doc)
15
+ end
16
+ end
17
+
18
+ context 'after intialization' do
19
+ before do
20
+ allow(subject).to receive(:doc).and_return(info_doc)
21
+ end
22
+
23
+ describe '#min_max' do
24
+ it 'returns with min and max values' do
25
+ expect(subject.min_max).to eq('354.000 900.000')
26
+ end
27
+ end
28
+
29
+ describe '#size' do
30
+ it 'returns raster size' do
31
+ expect(subject.size).to eq('310 266')
32
+ end
33
+ end
34
+ end
35
+ end
@@ -4,7 +4,7 @@ describe GeoConcerns::Processors::Vector::Base do
4
4
  let(:output_file) { 'output/geo.png' }
5
5
  let(:file_name) { 'files/geo.zip' }
6
6
  let(:label) {}
7
- let(:options) { { output_format: 'PNG', output_size: '150 150', label: label } }
7
+ let(:options) { { output_size: '150 150', label: label } }
8
8
 
9
9
  subject { described_class.new(file_name, {}) }
10
10
 
@@ -26,42 +26,29 @@ describe GeoConcerns::Processors::Vector::Base do
26
26
  end
27
27
  end
28
28
 
29
- describe '#encode_vector' do
30
- it 'executes rasterize and translate commands, and cleans up files' do
31
- expect(subject.class).to receive(:execute).twice
32
- expect(File).to receive(:unlink)
33
- expect(File).to receive(:unlink).with("#{output_file}.aux.xml")
34
- subject.class.encode_vector(file_name, options, output_file)
29
+ describe '#encode_queue' do
30
+ it 'returns an array of command name symbols' do
31
+ expect(subject.class.encode_queue).to include :rasterize
35
32
  end
36
33
  end
37
34
 
38
- describe '#reproject_vector' do
39
- it 'executes the reproject command, zips the output, then cleans up' do
40
- expect(subject.class).to receive(:execute)
41
- expect(subject.class).to receive(:zip)
42
- expect(FileUtils).to receive(:rm_rf)
43
- subject.class.reproject_vector(file_name, options, output_file)
35
+ describe '#reproject_queue' do
36
+ it 'returns an array of command name symbols' do
37
+ expect(subject.class.reproject_queue).to include :zip
44
38
  end
45
39
  end
46
40
 
47
- describe '#rasterize' do
48
- it 'returns a gdal_rasterize command ' do
49
- expect(subject.class.rasterize(file_name, options, output_file))
50
- .to include('gdal_rasterize')
51
- end
52
- end
53
-
54
- describe '#reproject' do
55
- it 'returns a ogr2ogr command' do
56
- expect(subject.class.reproject(file_name, options, output_file))
57
- .to include('ogr2ogr', 'ESRI Shapefile')
41
+ describe '#encode_vector' do
42
+ it 'runs commands to encode the raster thumbnail' do
43
+ expect(subject.class).to receive(:run_commands)
44
+ subject.class.encode_vector(file_name, options, output_file)
58
45
  end
59
46
  end
60
47
 
61
- describe '#intermediate_shapefile_path' do
62
- it 'returns a path to a shapefile' do
63
- expect(subject.class.intermediate_shapefile_path('/test/path/file.zip'))
64
- .to eq('/test/path/file/')
48
+ describe '#reproject_vector' do
49
+ it 'runs commands to reproject the raster' do
50
+ expect(subject.class).to receive(:run_commands)
51
+ subject.class.reproject_vector(file_name, options, output_file)
65
52
  end
66
53
  end
67
54
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe GeoConcerns::Processors::Vector::Shapefile do
4
4
  let(:output_file) { 'output/geo.png' }
5
5
  let(:file_name) { 'files/Shapefile.zip' }
6
- let(:options) { { output_format: 'PNG', output_size: '150 150', label: :thumbnail } }
6
+ let(:options) { { output_size: '150 150', label: :thumbnail } }
7
7
 
8
8
  subject { described_class.new(file_name, {}) }
9
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geo_concerns
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
  - James Griffin
@@ -12,50 +12,36 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2016-04-28 00:00:00.000000000 Z
15
+ date: 2016-05-05 00:00:00.000000000 Z
16
16
  dependencies:
17
- - !ruby/object:Gem::Dependency
18
- name: rails
19
- requirement: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - "~>"
22
- - !ruby/object:Gem::Version
23
- version: 4.2.6
24
- type: :runtime
25
- prerelease: false
26
- version_requirements: !ruby/object:Gem::Requirement
27
- requirements:
28
- - - "~>"
29
- - !ruby/object:Gem::Version
30
- version: 4.2.6
31
17
  - !ruby/object:Gem::Dependency
32
18
  name: curation_concerns
33
19
  requirement: !ruby/object:Gem::Requirement
34
20
  requirements:
35
21
  - - "~>"
36
22
  - !ruby/object:Gem::Version
37
- version: 0.14.0.pre1
23
+ version: 0.14.0.pre4
38
24
  type: :runtime
39
25
  prerelease: false
40
26
  version_requirements: !ruby/object:Gem::Requirement
41
27
  requirements:
42
28
  - - "~>"
43
29
  - !ruby/object:Gem::Version
44
- version: 0.14.0.pre1
30
+ version: 0.14.0.pre4
45
31
  - !ruby/object:Gem::Dependency
46
32
  name: leaflet-rails
47
33
  requirement: !ruby/object:Gem::Requirement
48
34
  requirements:
49
- - - ">="
35
+ - - "~>"
50
36
  - !ruby/object:Gem::Version
51
- version: '0'
37
+ version: '0.7'
52
38
  type: :runtime
53
39
  prerelease: false
54
40
  version_requirements: !ruby/object:Gem::Requirement
55
41
  requirements:
56
- - - ">="
42
+ - - "~>"
57
43
  - !ruby/object:Gem::Version
58
- version: '0'
44
+ version: '0.7'
59
45
  - !ruby/object:Gem::Dependency
60
46
  name: sqlite3
61
47
  requirement: !ruby/object:Gem::Requirement
@@ -88,30 +74,30 @@ dependencies:
88
74
  name: engine_cart
89
75
  requirement: !ruby/object:Gem::Requirement
90
76
  requirements:
91
- - - ">="
77
+ - - "~>"
92
78
  - !ruby/object:Gem::Version
93
- version: '0'
79
+ version: '0.8'
94
80
  type: :development
95
81
  prerelease: false
96
82
  version_requirements: !ruby/object:Gem::Requirement
97
83
  requirements:
98
- - - ">="
84
+ - - "~>"
99
85
  - !ruby/object:Gem::Version
100
- version: '0'
86
+ version: '0.8'
101
87
  - !ruby/object:Gem::Dependency
102
88
  name: solr_wrapper
103
89
  requirement: !ruby/object:Gem::Requirement
104
90
  requirements:
105
- - - ">="
91
+ - - "~>"
106
92
  - !ruby/object:Gem::Version
107
- version: '0'
93
+ version: '0.10'
108
94
  type: :development
109
95
  prerelease: false
110
96
  version_requirements: !ruby/object:Gem::Requirement
111
97
  requirements:
112
- - - ">="
98
+ - - "~>"
113
99
  - !ruby/object:Gem::Version
114
- version: '0'
100
+ version: '0.10'
115
101
  - !ruby/object:Gem::Dependency
116
102
  name: fcrepo_wrapper
117
103
  requirement: !ruby/object:Gem::Requirement
@@ -158,30 +144,30 @@ dependencies:
158
144
  name: rubocop
159
145
  requirement: !ruby/object:Gem::Requirement
160
146
  requirements:
161
- - - ">="
147
+ - - "~>"
162
148
  - !ruby/object:Gem::Version
163
- version: '0'
149
+ version: '0.39'
164
150
  type: :development
165
151
  prerelease: false
166
152
  version_requirements: !ruby/object:Gem::Requirement
167
153
  requirements:
168
- - - ">="
154
+ - - "~>"
169
155
  - !ruby/object:Gem::Version
170
- version: '0'
156
+ version: '0.39'
171
157
  - !ruby/object:Gem::Dependency
172
158
  name: rubocop-rspec
173
159
  requirement: !ruby/object:Gem::Requirement
174
160
  requirements:
175
- - - ">="
161
+ - - "~>"
176
162
  - !ruby/object:Gem::Version
177
- version: '0'
163
+ version: 1.4.1
178
164
  type: :development
179
165
  prerelease: false
180
166
  version_requirements: !ruby/object:Gem::Requirement
181
167
  requirements:
182
- - - ">="
168
+ - - "~>"
183
169
  - !ruby/object:Gem::Version
184
- version: '0'
170
+ version: 1.4.1
185
171
  - !ruby/object:Gem::Dependency
186
172
  name: factory_girl
187
173
  requirement: !ruby/object:Gem::Requirement
@@ -200,16 +186,16 @@ dependencies:
200
186
  name: capybara
201
187
  requirement: !ruby/object:Gem::Requirement
202
188
  requirements:
203
- - - ">="
189
+ - - "~>"
204
190
  - !ruby/object:Gem::Version
205
- version: '0'
191
+ version: '2.7'
206
192
  type: :development
207
193
  prerelease: false
208
194
  version_requirements: !ruby/object:Gem::Requirement
209
195
  requirements:
210
- - - ">="
196
+ - - "~>"
211
197
  - !ruby/object:Gem::Version
212
- version: '0'
198
+ version: '2.7'
213
199
  description: 'Rails engine for Hydra Geo models. Built around Curation Concerns engine. '
214
200
  email:
215
201
  - jrgriffiniii@gmail.com
@@ -281,10 +267,13 @@ files:
281
267
  - app/presenters/geo_concerns/raster_work_show_presenter.rb
282
268
  - app/presenters/geo_concerns/vector_work_show_presenter.rb
283
269
  - app/processors/geo_concerns/processors/base_geo_processor.rb
270
+ - app/processors/geo_concerns/processors/gdal.rb
271
+ - app/processors/geo_concerns/processors/ogr.rb
284
272
  - app/processors/geo_concerns/processors/raster.rb
285
273
  - app/processors/geo_concerns/processors/raster/aig.rb
286
274
  - app/processors/geo_concerns/processors/raster/base.rb
287
275
  - app/processors/geo_concerns/processors/raster/dem.rb
276
+ - app/processors/geo_concerns/processors/raster/info.rb
288
277
  - app/processors/geo_concerns/processors/raster/processor.rb
289
278
  - app/processors/geo_concerns/processors/vector.rb
290
279
  - app/processors/geo_concerns/processors/vector/base.rb
@@ -417,9 +406,12 @@ files:
417
406
  - spec/presenters/raster_work_show_presenter_spec.rb
418
407
  - spec/presenters/vector_work_show_presenter_spec.rb
419
408
  - spec/processors/geo_concerns/processors/base_geo_processor_spec.rb
409
+ - spec/processors/geo_concerns/processors/gdal_spec.rb
410
+ - spec/processors/geo_concerns/processors/ogr_spec.rb
420
411
  - spec/processors/geo_concerns/processors/raster/aig_spec.rb
421
412
  - spec/processors/geo_concerns/processors/raster/base_spec.rb
422
413
  - spec/processors/geo_concerns/processors/raster/dem_spec.rb
414
+ - spec/processors/geo_concerns/processors/raster/info_spec.rb
423
415
  - spec/processors/geo_concerns/processors/raster/processor_spec.rb
424
416
  - spec/processors/geo_concerns/processors/vector/base_spec.rb
425
417
  - spec/processors/geo_concerns/processors/vector/processor_spec.rb
@@ -503,9 +495,12 @@ test_files:
503
495
  - spec/presenters/raster_work_show_presenter_spec.rb
504
496
  - spec/presenters/vector_work_show_presenter_spec.rb
505
497
  - spec/processors/geo_concerns/processors/base_geo_processor_spec.rb
498
+ - spec/processors/geo_concerns/processors/gdal_spec.rb
499
+ - spec/processors/geo_concerns/processors/ogr_spec.rb
506
500
  - spec/processors/geo_concerns/processors/raster/aig_spec.rb
507
501
  - spec/processors/geo_concerns/processors/raster/base_spec.rb
508
502
  - spec/processors/geo_concerns/processors/raster/dem_spec.rb
503
+ - spec/processors/geo_concerns/processors/raster/info_spec.rb
509
504
  - spec/processors/geo_concerns/processors/raster/processor_spec.rb
510
505
  - spec/processors/geo_concerns/processors/vector/base_spec.rb
511
506
  - spec/processors/geo_concerns/processors/vector/processor_spec.rb