/
geo.rb
69 lines (57 loc) · 1.57 KB
/
geo.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# frozen_string_literal: true
module Embed
module Viewer
class Geo < CommonViewer
def component
GeoComponent
end
##
# Options for the map element tag
# @return [Hash]
def map_element_options
options = {
id: 'sul-embed-geo-map',
style: 'flex: 1',
'data-bounding-box' => @purl_object.bounding_box.to_s
}
if @purl_object.public?
options['data-wms-url'] = Settings.geo_wms_url
options['data-layers'] = "druid:#{@purl_object.druid}"
end
options['data-index-map'] = index_map.file_url if index_map?
options
end
def stylesheet
'geo.css'
end
def self.show_download?
true
end
def index_map
purl_object.contents.map(&:files).flatten.find { |file| index_map_files.include? file.title }
end
def index_map?
index_map.present?
end
# Returns true or false whether the viewer should display the Download All
# link. True for all geo objects, unless there is only one file
# (because the file download link will suffice for that)
def display_download_all?
@purl_object.downloadable_files.length > 1
end
def external_url
"#{Settings.geo_external_url}#{@embed_request.object_druid}"
end
def external_url_text
'View this in EarthWorks'
end
private
def index_map_files
%w[index_map.geojson index_map.json]
end
def default_height
493
end
end
end
end