Skip to content

Commit

Permalink
adds in direct download for geotiff option
Browse files Browse the repository at this point in the history
  • Loading branch information
mejackreed committed Nov 25, 2014
1 parent 077b6de commit 251f164
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 0 additions & 2 deletions lib/geoblacklight/references.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ def downloads_by_format
case format
when 'Shapefile'
{ shapefile: wfs.to_hash, kmz: wms.to_hash }
when 'GeoTIFF'
{ geotiff: wms.to_hash }
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/geoblacklight/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def restricted?
end

def downloadable?
get(:solr_wfs_url) && get(:solr_wms_url) && available?
download_types.present? && available?
end

def download_types
Expand Down
12 changes: 12 additions & 0 deletions spec/lib/geoblacklight/references_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,18 @@
)
)
}
let(:direct_download_only) {
Geoblacklight::References.new(
dc_format_s: 'GeoTIFF',
dct_references_s: {
'http://schema.org/downloadUrl' => 'http://example.com/layer-id-geotiff.tiff'
}.to_json
)
}
describe 'format' do
it 'should return format' do
expect(complex_shapefile.format).to eq 'Shapefile'
expect(direct_download_only.format).to eq 'GeoTIFF'
end
end
describe 'refs' do
Expand All @@ -55,6 +64,7 @@
download = complex_shapefile.download
expect(download).to be_an Geoblacklight::Reference
expect(download.endpoint).to eq('http://example.com/urn:hul.harvard.edu:HARVARD.SDE2.TG10USAIANNH/data.zip')
expect(direct_download_only.download.endpoint).to eq 'http://example.com/layer-id-geotiff.tiff'
end
it 'should not return if download not available' do
expect(typical_ogp_shapefile.download).to be_nil
Expand All @@ -63,6 +73,7 @@
describe 'preferred_download' do
it 'should return the direct download if available' do
expect(complex_shapefile.preferred_download[:file_download][:download]).to eq 'http://example.com/urn:hul.harvard.edu:HARVARD.SDE2.TG10USAIANNH/data.zip'
expect(direct_download_only.preferred_download[:file_download][:download]).to eq 'http://example.com/layer-id-geotiff.tiff'
end
it 'should return nil if there is no direct download' do
expect(typical_ogp_shapefile.preferred_download).to be_nil
Expand All @@ -76,6 +87,7 @@
types = complex_shapefile.download_types
expect(types.first[1]).to eq wfs: 'http://hgl.harvard.edu:8080/geoserver/wfs'
expect(types.count).to eq 2
expect(direct_download_only.download_types).to be_nil
end
it 'should only return available downloads if no direct is present' do
types = typical_ogp_shapefile.download_types
Expand Down

0 comments on commit 251f164

Please sign in to comment.