geo_monitor 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/geo_monitor/layer.rb +11 -4
- data/app/models/geo_monitor/status.rb +4 -3
- data/db/migrate/20180112220603_add_content_type_to_status.rb +5 -0
- data/db/migrate/20180116150504_add_more_layer_fields.rb +6 -0
- data/lib/geo_monitor.rb +3 -0
- data/lib/geo_monitor/bounding_box.rb +3 -3
- data/lib/geo_monitor/constants.rb +6 -0
- data/lib/geo_monitor/engine.rb +5 -6
- data/lib/geo_monitor/lat_lng_point.rb +2 -2
- data/lib/geo_monitor/requests/wms.rb +2 -2
- data/lib/geo_monitor/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5835f3c34e5de884e5df6a85e0f133d1f758fad2
|
4
|
+
data.tar.gz: 31f3016139b942dce0ef4470b6cb31965f9c2c18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72457008a4a5ad667a99a5025ad2a7a47ab24193477713978287fa1f693dabbb164987bd2934f01d4ec5d6cba214134ac90342a5c64e452d5ef671e20f351030
|
7
|
+
data.tar.gz: 89bf2d4eafd89ab821a166e704969afe9e8ca10dde776e2dd0ee7de4aad6bd281dbde35857a8f5cb9c0fef37d5a0f7d60d68fbb7904624e581d3efd87b94524b
|
@@ -8,10 +8,17 @@ module GeoMonitor
|
|
8
8
|
schema = JSON.parse(schema_json)
|
9
9
|
references = JSON.parse(schema['dct_references_s'])
|
10
10
|
find_or_create_by(slug: schema['layer_slug_s']) do |layer|
|
11
|
-
layer.checktype =
|
11
|
+
layer.checktype =
|
12
|
+
if references['http://www.opengis.net/def/serviceType/ogc/wms']
|
13
|
+
'WMS'
|
14
|
+
elsif references['http://iiif.io/api/image']
|
15
|
+
'IIIF'
|
16
|
+
end
|
17
|
+
layer.institution = schema['dct_provenance_s']
|
18
|
+
layer.rights = schema['dc_rights_s']
|
12
19
|
layer.layername = schema['layer_id_s']
|
13
20
|
layer.bbox = schema['solr_geom']
|
14
|
-
layer.url = references['http://www.opengis.net/def/serviceType/ogc/wms']
|
21
|
+
layer.url = references['http://www.opengis.net/def/serviceType/ogc/wms'] || references['http://iiif.io/api/image']
|
15
22
|
layer.active = true
|
16
23
|
end
|
17
24
|
end
|
@@ -28,11 +35,11 @@ module GeoMonitor
|
|
28
35
|
bbox: bounding_box, url: url, layers: layername
|
29
36
|
).tile
|
30
37
|
end
|
31
|
-
GeoMonitor::Status.from_response(response, self, time.real.to_f)
|
38
|
+
::GeoMonitor::Status.from_response(response, self, time.real.to_f)
|
32
39
|
end
|
33
40
|
|
34
41
|
def availability_score
|
35
|
-
statuses.where(res_code: '200').count.to_f / statuses.count
|
42
|
+
statuses.where(res_code: '200', content_type: 'image/png').count.to_f / statuses.count
|
36
43
|
end
|
37
44
|
end
|
38
45
|
end
|
@@ -7,7 +7,7 @@ module GeoMonitor
|
|
7
7
|
# Limits the number of statuses per layer to prevent a ballooing database
|
8
8
|
def limit_by_layer
|
9
9
|
statuses_by_layer = self.class.where(layer: layer).count
|
10
|
-
max = GeoMonitor::Engine.config.max_status_per_layer
|
10
|
+
max = ::GeoMonitor::Engine.config.max_status_per_layer
|
11
11
|
self.class
|
12
12
|
.where(layer: layer)
|
13
13
|
.last(statuses_by_layer - max + 1)
|
@@ -15,7 +15,7 @@ module GeoMonitor
|
|
15
15
|
end
|
16
16
|
|
17
17
|
##
|
18
|
-
# @param [Faraday::
|
18
|
+
# @param [Faraday::Response] response
|
19
19
|
# @param [GeoMonitor::Layer] layer
|
20
20
|
# @param [Float] time
|
21
21
|
def self.from_response(response, layer, time)
|
@@ -24,7 +24,8 @@ module GeoMonitor
|
|
24
24
|
res_code: response.status,
|
25
25
|
submitted_query: response.env[:url].to_s,
|
26
26
|
layer: layer,
|
27
|
-
res_headers: response.headers
|
27
|
+
res_headers: response.headers,
|
28
|
+
content_type: response.headers.try(:[], :content_type)
|
28
29
|
)
|
29
30
|
end
|
30
31
|
end
|
data/lib/geo_monitor.rb
CHANGED
@@ -38,10 +38,10 @@ module GeoMonitor
|
|
38
38
|
lng_diff = east - west
|
39
39
|
max_diff = [lat_diff, lng_diff].max
|
40
40
|
|
41
|
-
if max_diff < ::GeoMonitor::DEGREES_IN_CIRCLE / 2**20
|
41
|
+
if max_diff < ::GeoMonitor::Constants::DEGREES_IN_CIRCLE / 2**20
|
42
42
|
zoom = 21
|
43
43
|
else
|
44
|
-
zoom = -1 * ((Math.log(max_diff) / Math.log(2)) - (Math.log(::GeoMonitor::DEGREES_IN_CIRCLE) / Math.log(2)))
|
44
|
+
zoom = -1 * ((Math.log(max_diff) / Math.log(2)) - (Math.log(::GeoMonitor::Constants::DEGREES_IN_CIRCLE) / Math.log(2)))
|
45
45
|
zoom = 1 if zoom < 1
|
46
46
|
end
|
47
47
|
zoom.ceil
|
@@ -52,7 +52,7 @@ module GeoMonitor
|
|
52
52
|
def tile_number
|
53
53
|
lat_rad = south / 180 * Math::PI
|
54
54
|
n = 2.0**zoom_level
|
55
|
-
x = ((west + 180.0) / ::GeoMonitor::DEGREES_IN_CIRCLE * n).to_i
|
55
|
+
x = ((west + 180.0) / ::GeoMonitor::Constants::DEGREES_IN_CIRCLE * n).to_i
|
56
56
|
y = ((1.0 - Math.log(Math.tan(lat_rad) + (1 / Math.cos(lat_rad))) / Math::PI) / 2.0 * n)
|
57
57
|
y = if y.infinite?.nil?
|
58
58
|
y.to_i
|
data/lib/geo_monitor/engine.rb
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
require 'rails/all'
|
2
2
|
require 'faraday'
|
3
|
-
require 'geo_monitor/bounding_box'
|
4
|
-
require 'geo_monitor/lat_lng_point'
|
5
|
-
require 'geo_monitor/requests/wms'
|
6
3
|
|
7
4
|
module GeoMonitor
|
8
|
-
R = 6_378_137 # Radius of Earth in meters
|
9
|
-
DEGREES_IN_CIRCLE = 360.0
|
10
|
-
|
11
5
|
##
|
12
6
|
# Top level Rails Engine class
|
13
7
|
class Engine < ::Rails::Engine
|
8
|
+
require 'geo_monitor/constants'
|
9
|
+
require 'geo_monitor/bounding_box'
|
10
|
+
require 'geo_monitor/lat_lng_point'
|
11
|
+
require 'geo_monitor/requests/wms'
|
12
|
+
|
14
13
|
isolate_namespace GeoMonitor
|
15
14
|
|
16
15
|
GeoMonitor::Engine.config.max_status_per_layer = 5
|
@@ -14,8 +14,8 @@ module GeoMonitor
|
|
14
14
|
max = 1 - 1E-15
|
15
15
|
sin = [[Math.sin(lng * d), max].min, -max].max
|
16
16
|
self.class.new(
|
17
|
-
lat: GeoMonitor::R * lat * d,
|
18
|
-
lng: GeoMonitor::R * Math.log((1 + sin) / (1 - sin)) / 2
|
17
|
+
lat: ::GeoMonitor::Constants::R * lat * d,
|
18
|
+
lng: ::GeoMonitor::Constants::R * Math.log((1 + sin) / (1 - sin)) / 2
|
19
19
|
)
|
20
20
|
end
|
21
21
|
|
@@ -34,7 +34,7 @@ module GeoMonitor
|
|
34
34
|
# Request the tile.
|
35
35
|
def tile
|
36
36
|
unless url.present?
|
37
|
-
return GeoMonitor::FailedResponse.new(
|
37
|
+
return ::GeoMonitor::FailedResponse.new(
|
38
38
|
{ url: url }, 'No URL provided', {}
|
39
39
|
)
|
40
40
|
end
|
@@ -46,7 +46,7 @@ module GeoMonitor
|
|
46
46
|
request.options.open_timeout = 10
|
47
47
|
end
|
48
48
|
rescue Faraday::ConnectionFailed, Faraday::TimeoutError => e
|
49
|
-
GeoMonitor::FailedResponse.new(
|
49
|
+
::GeoMonitor::FailedResponse.new(
|
50
50
|
{ url: conn.url_prefix.to_s },
|
51
51
|
e.class,
|
52
52
|
nil
|
data/lib/geo_monitor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geo_monitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Reed
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -119,9 +119,12 @@ files:
|
|
119
119
|
- config/routes.rb
|
120
120
|
- db/migrate/20171212180244_create_geo_monitor_layers.rb
|
121
121
|
- db/migrate/20171212181423_create_geo_monitor_statuses.rb
|
122
|
+
- db/migrate/20180112220603_add_content_type_to_status.rb
|
123
|
+
- db/migrate/20180116150504_add_more_layer_fields.rb
|
122
124
|
- lib/generators/geo_monitor/install_generator.rb
|
123
125
|
- lib/geo_monitor.rb
|
124
126
|
- lib/geo_monitor/bounding_box.rb
|
127
|
+
- lib/geo_monitor/constants.rb
|
125
128
|
- lib/geo_monitor/engine.rb
|
126
129
|
- lib/geo_monitor/lat_lng_point.rb
|
127
130
|
- lib/geo_monitor/requests/wms.rb
|