class Geoblacklight::References
References
is a geoblacklight-schema dct:references parser
Attributes
Public Class Methods
# File lib/geoblacklight/references.rb, line 6 def initialize(document, reference_field = Settings.FIELDS.REFERENCES) @document = document @reference_field = reference_field @refs = parse_references.map { |ref| Reference.new(ref) } end
Public Instance Methods
Generated download types from wxs services @return (see downloads_by_format
)
# File lib/geoblacklight/references.rb, line 67 def download_types downloads_by_format end
Download
hash based off of format type @return [Hash, nil]
# File lib/geoblacklight/references.rb, line 53 def downloads_by_format case format when 'Shapefile' vector_download_formats when 'GeoTIFF' geotiff_download_formats when 'ArcGRID' arcgrid_download_formats end end
Returns all of the Esri webservices for given set of references
# File lib/geoblacklight/references.rb, line 73 def esri_webservices %w[tiled_map_layer dynamic_map_layer feature_layer image_map_layer].map do |layer_type| send(layer_type) end.compact end
Accessor for a document's file format @return [String] file format for the document
# File lib/geoblacklight/references.rb, line 32 def format @document[Settings.FIELDS.FILE_FORMAT] end
Preferred download (should be a file download) @return [Hash, nil]
# File lib/geoblacklight/references.rb, line 46 def preferred_download return file_download if download.present? end
@param [String, Symbol] ref_type @return [Geoblacklight::Reference]
# File lib/geoblacklight/references.rb, line 39 def references(ref_type) @refs.find { |reference| reference.type == ref_type } end
Return only metadata for shown metadata @return [Geoblacklight::Metadata::Base]
# File lib/geoblacklight/references.rb, line 25 def shown_metadata @shown_metadata ||= shown_metadata_refs.map { |ref| Geoblacklight::Metadata.instance(ref) } end
Return only those metadata references which are exposed within the configuration @return [Geoblacklight::Reference]
# File lib/geoblacklight/references.rb, line 15 def shown_metadata_refs metadata = @refs.select { |ref| Settings.METADATA_SHOWN.include?(ref.type.to_s) } metadata.sort do |u, v| Settings.METADATA_SHOWN.index(u.type.to_s) <=> Settings.METADATA_SHOWN.index(v.type.to_s) end end
Private Instance Methods
Download
hash for an ArcGRID file with a WMS reference present @return (see downloads_by_format
)
# File lib/geoblacklight/references.rb, line 122 def arcgrid_download_formats { geotiff: wms.to_hash } if wms.present? end
Download
hash for a static file download @return (see downloads_by_format
)
# File lib/geoblacklight/references.rb, line 95 def file_download { file_download: download.to_hash } end
Download
hash for a GeoTiff file with a WMS reference present @return (see downloads_by_format
)
# File lib/geoblacklight/references.rb, line 115 def geotiff_download_formats { geotiff: wms.to_hash } if wms.present? end
Adds a call to references for defined URI keys
# File lib/geoblacklight/references.rb, line 128 def method_missing(m, *args, &b) if Geoblacklight::Constants::URI.key?(m) references m else super end end
Parses the references field of a document @return [Hash]
# File lib/geoblacklight/references.rb, line 84 def parse_references if @document[reference_field].nil? {} else JSON.parse(@document[reference_field]) end end
Download
hash for a Shapefile file (currently only vector) with a wms and wfs reference present @return (see downloads_by_format
)
# File lib/geoblacklight/references.rb, line 103 def vector_download_formats return unless wms.present? && wfs.present? { shapefile: wfs.to_hash, kmz: wms.to_hash, geojson: wfs.to_hash } end