Class: GeoMonitor::Layer
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- GeoMonitor::Layer
- Defined in:
- app/models/geo_monitor/layer.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_geoblacklight(schema_json) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/geo_monitor/layer.rb', line 7 def self.from_geoblacklight(schema_json) schema = JSON.parse(schema_json) references = JSON.parse(schema['dct_references_s'] || '{}') find_or_create_by(slug: schema['layer_slug_s']).tap do |layer| layer.checktype = if references['http://www.opengis.net/def/serviceType/ogc/wms'] 'WMS' elsif references['http://iiif.io/api/image'] 'IIIF' end layer.institution = schema['dct_provenance_s'] layer.rights = schema['dc_rights_s'] layer.layername = schema['layer_id_s'] layer.bbox = schema['solr_geom'] layer.url = references['http://www.opengis.net/def/serviceType/ogc/wms'] || references['http://iiif.io/api/image'] layer.active = true end end |
Instance Method Details
#availability_score ⇒ Object
41 42 43 |
# File 'app/models/geo_monitor/layer.rb', line 41 def availability_score statuses.where(res_code: '200', content_type: 'image/png').count.to_f / statuses.count end |
#bounding_box ⇒ Object
26 27 28 29 |
# File 'app/models/geo_monitor/layer.rb', line 26 def bounding_box w, e, n, s = bbox.delete('ENVELOPE(').delete(')').delete(' ').split(',') ::GeoMonitor::BoundingBox.new(north: n, south: s, east: e, west: w) end |
#check ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'app/models/geo_monitor/layer.rb', line 31 def check response = nil time = Benchmark.measure do response = ::GeoMonitor::Requests::WMS.new( bbox: bounding_box, url: url, layers: layername ).tile end ::GeoMonitor::Status.from_response(response, self, time.real.to_f) end |