orb_def 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +79 -0
- data/.gitignore +14 -0
- data/.rakeTasks +7 -0
- data/.rspec +1 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +207 -0
- data/MIT-LICENSE +20 -0
- data/README.md +30 -0
- data/Rakefile +23 -0
- data/app/assets/config/orb_def_manifest.js +2 -0
- data/app/assets/javascripts/orb_def/application.js +15 -0
- data/app/assets/stylesheets/orb_def/application.css +15 -0
- data/app/controllers/orb_def/api/v1/fires_controller.rb +64 -0
- data/app/controllers/orb_def/api/v1/weather_readings_controller.rb +16 -0
- data/app/controllers/orb_def/application_controller.rb +5 -0
- data/app/helpers/orb_def/application_helper.rb +4 -0
- data/app/jobs/orb_def/application_job.rb +4 -0
- data/app/mailers/orb_def/application_mailer.rb +6 -0
- data/app/models/orb_def/application_record.rb +5 -0
- data/app/models/orb_def/detection_type.rb +7 -0
- data/app/models/orb_def/fire.rb +60 -0
- data/app/models/orb_def/weather_reading.rb +41 -0
- data/app/models/orb_def/weather_station.rb +33 -0
- data/app/serializers/orb_def/api/v1/fire_serializer.rb +17 -0
- data/app/services/orb_def/fire_weather_data.rb +36 -0
- data/app/services/orb_def/nasa/firms_client.rb +38 -0
- data/app/services/orb_def/nasa/firms_import.rb +44 -0
- data/app/services/orb_def/open_weather_api/weather_by_coordinates.rb +31 -0
- data/app/views/layouts/orb_def/application.html.erb +16 -0
- data/bin/rails +25 -0
- data/config/routes.rb +13 -0
- data/db/migrate/20200422073925_create_orb_def_weather_stations.rb +12 -0
- data/db/migrate/20200422073938_create_orb_def_weather_readings.rb +20 -0
- data/db/migrate/20200423064313_create_orb_def_detection_types.rb +9 -0
- data/db/migrate/20200428063630_create_orb_def_fires.rb +28 -0
- data/db/seeds.rb +8 -0
- data/lib/orb_def/engine.rb +16 -0
- data/lib/orb_def/version.rb +3 -0
- data/lib/orb_def.rb +16 -0
- data/lib/tasks/orb_def_tasks.rake +4 -0
- data/orb_def.gemspec +38 -0
- data/spec/controllers/orb_def/api/v1/fires_controller_spec.rb +16 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +4 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +36 -0
- data/spec/dummy/bin/update +31 -0
- data/spec/dummy/bin/yarn +11 -0
- data/spec/dummy/config/application.rb +30 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/database.yml +21 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +61 -0
- data/spec/dummy/config/environments/production.rb +94 -0
- data/spec/dummy/config/environments/test.rb +46 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/assets.rb +14 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/orb_def.rb +4 -0
- data/spec/dummy/config/initializers/pagy.rb +170 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/orb_def/spring.rb +1 -0
- data/spec/dummy/config/puma.rb +37 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/db/schema.rb +87 -0
- data/spec/dummy/package.json +5 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/detection_type.rb +5 -0
- data/spec/fixtures/files/modis_c6.txt +3 -0
- data/spec/fixtures/nasa/firms/viirs.txt +3 -0
- data/spec/rails_helper.rb +72 -0
- data/spec/services/orbital_defence_engine/nasa/firms_import_spec.rb +27 -0
- data/spec/services/orbital_defence_engine/open_weather_api/weather_by_coordinates_spec.rb +16 -0
- data/spec/spec/vcr/cassettes/OrbitalDefenceEngine_Nasa_FirmsImport/_all/when_request_successful/creates_fires.yml +77 -0
- data/spec/spec/vcr/cassettes/OrbitalDefenceEngine_OpenWeatherApi_WeatherByCoordinates/_fetch_weather_by_coordinates/returns_json_data_as_a_hash.yml +41 -0
- data/spec/spec_helper.rb +96 -0
- data/spec/support/factory_bot.rb +3 -0
- data/spec/support/vcr.rb +9 -0
- data/spec/vcr/cassettes/OpenWeatherApi_WeatherByCoordinates/_fetch_weather_by_coordinates/returns_json_data_as_a_hash.yml +41 -0
- data/spec/vcr/cassettes/OrbDef_Nasa_FirmsImport/_all/when_request_successful/creates_fires.yml +4766 -0
- data/spec/vcr/cassettes/OrbDef_OpenWeatherApi_WeatherByCoordinates/_fetch_weather_by_coordinates/returns_json_data_as_a_hash.yml +41 -0
- metadata +438 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 45cd1b41303717de3db93b68f5f070153f9f2df9f7afb949ff8fef692afb796b
|
4
|
+
data.tar.gz: ce1191ce16e8f3462aea7fa4e2c3132164c900a26b8ac9f1fc80c0b48b51f64f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 37c7a7c7457d6f7bcbcb496c6c4375038a1fb86b8d717cb42271294418320c568837cae351d6ff0c1ea7d44b071c7bb93b0c965e15b76ad272f7e307703fc6dc
|
7
|
+
data.tar.gz: 9a7a3e9774701b98885202078e721a524d53f3f38ca8324aec1f9c57fbf9f805c6a4ae4ed7069ee32138ebde373d3b080951965d2c0e3aad3fc962d5d58c6bfa
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# Ruby CircleCI 2.0 configuration file
|
2
|
+
#
|
3
|
+
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
4
|
+
#
|
5
|
+
version: 2
|
6
|
+
jobs:
|
7
|
+
build:
|
8
|
+
docker:
|
9
|
+
# specify the version you desire here
|
10
|
+
- image: circleci/ruby:2.6.5-node-browsers
|
11
|
+
environment:
|
12
|
+
RAILS_ENV: test
|
13
|
+
PGHOST: 127.0.0.1
|
14
|
+
PGUSER: root
|
15
|
+
# DB_USER: ${DB_USER}
|
16
|
+
# DB_PASSWORD: ${DB_PASSWORD}
|
17
|
+
# DB_HOST: ${DB_HOST}
|
18
|
+
|
19
|
+
# Specify service dependencies here if necessary
|
20
|
+
# CircleCI maintains a library of pre-built images
|
21
|
+
# documented at https://circleci.com/docs/2.0/circleci-images/
|
22
|
+
- image: circleci/postgres:9.4
|
23
|
+
environment:
|
24
|
+
POSTGRES_USER: root
|
25
|
+
POSTGRES_PASSWORD: circleci_test
|
26
|
+
POSTGRES_DB: orb_def_test
|
27
|
+
|
28
|
+
working_directory: ~/repo
|
29
|
+
|
30
|
+
steps:
|
31
|
+
- checkout
|
32
|
+
|
33
|
+
# Download and cache dependencies
|
34
|
+
- restore_cache:
|
35
|
+
keys:
|
36
|
+
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
37
|
+
# fallback to using the latest cache if no exact match is found
|
38
|
+
- v1-dependencies-
|
39
|
+
|
40
|
+
- run:
|
41
|
+
name: install dependencies
|
42
|
+
command: |
|
43
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
44
|
+
|
45
|
+
- run: sudo apt install -y postgresql-client || true
|
46
|
+
|
47
|
+
- save_cache:
|
48
|
+
paths:
|
49
|
+
- ./vendor/bundle
|
50
|
+
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
51
|
+
|
52
|
+
# Database setup
|
53
|
+
- run:
|
54
|
+
name: Set up DB
|
55
|
+
command: |
|
56
|
+
bundle exec rake db:create db:schema:load --trace
|
57
|
+
bundle exec rake db:migrate
|
58
|
+
environment:
|
59
|
+
DATABASE_URL: "postgres://root@localhost:5432/orb_def_test"
|
60
|
+
|
61
|
+
# run tests!
|
62
|
+
- run:
|
63
|
+
name: run tests
|
64
|
+
command: |
|
65
|
+
mkdir /tmp/test-results
|
66
|
+
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
|
67
|
+
|
68
|
+
bundle exec rspec --format progress \
|
69
|
+
--format RspecJunitFormatter \
|
70
|
+
--out /tmp/test-results/rspec.xml \
|
71
|
+
--format progress \
|
72
|
+
$TEST_FILES
|
73
|
+
|
74
|
+
# collect reports
|
75
|
+
- store_test_results:
|
76
|
+
path: /tmp/test-results
|
77
|
+
- store_artifacts:
|
78
|
+
path: /tmp/test-results
|
79
|
+
destination: test-results
|
data/.gitignore
ADDED
data/.rakeTasks
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
3
|
+
You are allowed to:
|
4
|
+
1. Remove rake task
|
5
|
+
2. Add existing rake tasks
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
3
|
+
|
4
|
+
# Declare your gem's dependencies in orb_def.gemspec.
|
5
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
6
|
+
# development dependencies will be added by default to the :development group.
|
7
|
+
gemspec
|
8
|
+
|
9
|
+
# Declare any dependencies that are still in development here instead of in
|
10
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
11
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
12
|
+
# your gem to rubygems.org.
|
13
|
+
|
14
|
+
# To use a debugger
|
15
|
+
# gem 'byebug', group: [:development, :test]
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,207 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
orb_def (0.0.1)
|
5
|
+
active_model_serializers
|
6
|
+
faraday (~> 0.15.3)
|
7
|
+
geokit-rails (~> 2.3, >= 2.3.1)
|
8
|
+
pagy (~> 3.7, >= 3.7.5)
|
9
|
+
rails (~> 5.2.4, >= 5.2.4.2)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
actioncable (5.2.4.2)
|
15
|
+
actionpack (= 5.2.4.2)
|
16
|
+
nio4r (~> 2.0)
|
17
|
+
websocket-driver (>= 0.6.1)
|
18
|
+
actionmailer (5.2.4.2)
|
19
|
+
actionpack (= 5.2.4.2)
|
20
|
+
actionview (= 5.2.4.2)
|
21
|
+
activejob (= 5.2.4.2)
|
22
|
+
mail (~> 2.5, >= 2.5.4)
|
23
|
+
rails-dom-testing (~> 2.0)
|
24
|
+
actionpack (5.2.4.2)
|
25
|
+
actionview (= 5.2.4.2)
|
26
|
+
activesupport (= 5.2.4.2)
|
27
|
+
rack (~> 2.0, >= 2.0.8)
|
28
|
+
rack-test (>= 0.6.3)
|
29
|
+
rails-dom-testing (~> 2.0)
|
30
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
31
|
+
actionview (5.2.4.2)
|
32
|
+
activesupport (= 5.2.4.2)
|
33
|
+
builder (~> 3.1)
|
34
|
+
erubi (~> 1.4)
|
35
|
+
rails-dom-testing (~> 2.0)
|
36
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
37
|
+
active_model_serializers (0.10.10)
|
38
|
+
actionpack (>= 4.1, < 6.1)
|
39
|
+
activemodel (>= 4.1, < 6.1)
|
40
|
+
case_transform (>= 0.2)
|
41
|
+
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
|
42
|
+
activejob (5.2.4.2)
|
43
|
+
activesupport (= 5.2.4.2)
|
44
|
+
globalid (>= 0.3.6)
|
45
|
+
activemodel (5.2.4.2)
|
46
|
+
activesupport (= 5.2.4.2)
|
47
|
+
activerecord (5.2.4.2)
|
48
|
+
activemodel (= 5.2.4.2)
|
49
|
+
activesupport (= 5.2.4.2)
|
50
|
+
arel (>= 9.0)
|
51
|
+
activestorage (5.2.4.2)
|
52
|
+
actionpack (= 5.2.4.2)
|
53
|
+
activerecord (= 5.2.4.2)
|
54
|
+
marcel (~> 0.3.1)
|
55
|
+
activesupport (5.2.4.2)
|
56
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
57
|
+
i18n (>= 0.7, < 2)
|
58
|
+
minitest (~> 5.1)
|
59
|
+
tzinfo (~> 1.1)
|
60
|
+
addressable (2.7.0)
|
61
|
+
public_suffix (>= 2.0.2, < 5.0)
|
62
|
+
arel (9.0.0)
|
63
|
+
builder (3.2.4)
|
64
|
+
case_transform (0.2)
|
65
|
+
activesupport
|
66
|
+
concurrent-ruby (1.1.6)
|
67
|
+
connection_pool (2.2.2)
|
68
|
+
crack (0.4.3)
|
69
|
+
safe_yaml (~> 1.0.0)
|
70
|
+
crass (1.0.6)
|
71
|
+
diff-lcs (1.3)
|
72
|
+
erubi (1.9.0)
|
73
|
+
factory_bot (5.1.2)
|
74
|
+
activesupport (>= 4.2.0)
|
75
|
+
factory_bot_rails (5.1.1)
|
76
|
+
factory_bot (~> 5.1.0)
|
77
|
+
railties (>= 4.2.0)
|
78
|
+
faraday (0.15.4)
|
79
|
+
multipart-post (>= 1.2, < 3)
|
80
|
+
geokit (1.13.1)
|
81
|
+
geokit-rails (2.3.1)
|
82
|
+
geokit (~> 1.5)
|
83
|
+
rails (>= 3.0)
|
84
|
+
globalid (0.4.2)
|
85
|
+
activesupport (>= 4.2.0)
|
86
|
+
hashdiff (1.0.1)
|
87
|
+
i18n (1.8.2)
|
88
|
+
concurrent-ruby (~> 1.0)
|
89
|
+
jsonapi-renderer (0.2.2)
|
90
|
+
loofah (2.5.0)
|
91
|
+
crass (~> 1.0.2)
|
92
|
+
nokogiri (>= 1.5.9)
|
93
|
+
mail (2.7.1)
|
94
|
+
mini_mime (>= 0.1.1)
|
95
|
+
marcel (0.3.3)
|
96
|
+
mimemagic (~> 0.3.2)
|
97
|
+
method_source (1.0.0)
|
98
|
+
mimemagic (0.3.4)
|
99
|
+
mini_mime (1.0.2)
|
100
|
+
mini_portile2 (2.4.0)
|
101
|
+
minitest (5.14.0)
|
102
|
+
multipart-post (2.1.1)
|
103
|
+
nio4r (2.5.2)
|
104
|
+
nokogiri (1.10.9)
|
105
|
+
mini_portile2 (~> 2.4.0)
|
106
|
+
pagy (3.7.5)
|
107
|
+
pg (1.2.3)
|
108
|
+
public_suffix (4.0.4)
|
109
|
+
rack (2.2.2)
|
110
|
+
rack-protection (2.0.8.1)
|
111
|
+
rack
|
112
|
+
rack-test (1.1.0)
|
113
|
+
rack (>= 1.0, < 3)
|
114
|
+
rails (5.2.4.2)
|
115
|
+
actioncable (= 5.2.4.2)
|
116
|
+
actionmailer (= 5.2.4.2)
|
117
|
+
actionpack (= 5.2.4.2)
|
118
|
+
actionview (= 5.2.4.2)
|
119
|
+
activejob (= 5.2.4.2)
|
120
|
+
activemodel (= 5.2.4.2)
|
121
|
+
activerecord (= 5.2.4.2)
|
122
|
+
activestorage (= 5.2.4.2)
|
123
|
+
activesupport (= 5.2.4.2)
|
124
|
+
bundler (>= 1.3.0)
|
125
|
+
railties (= 5.2.4.2)
|
126
|
+
sprockets-rails (>= 2.0.0)
|
127
|
+
rails-dom-testing (2.0.3)
|
128
|
+
activesupport (>= 4.2.0)
|
129
|
+
nokogiri (>= 1.6)
|
130
|
+
rails-html-sanitizer (1.3.0)
|
131
|
+
loofah (~> 2.3)
|
132
|
+
railties (5.2.4.2)
|
133
|
+
actionpack (= 5.2.4.2)
|
134
|
+
activesupport (= 5.2.4.2)
|
135
|
+
method_source
|
136
|
+
rake (>= 0.8.7)
|
137
|
+
thor (>= 0.19.0, < 2.0)
|
138
|
+
rake (13.0.1)
|
139
|
+
redis (4.1.3)
|
140
|
+
rspec-core (3.9.1)
|
141
|
+
rspec-support (~> 3.9.1)
|
142
|
+
rspec-expectations (3.9.1)
|
143
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
144
|
+
rspec-support (~> 3.9.0)
|
145
|
+
rspec-mocks (3.9.1)
|
146
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
147
|
+
rspec-support (~> 3.9.0)
|
148
|
+
rspec-rails (3.9.1)
|
149
|
+
actionpack (>= 3.0)
|
150
|
+
activesupport (>= 3.0)
|
151
|
+
railties (>= 3.0)
|
152
|
+
rspec-core (~> 3.9.0)
|
153
|
+
rspec-expectations (~> 3.9.0)
|
154
|
+
rspec-mocks (~> 3.9.0)
|
155
|
+
rspec-support (~> 3.9.0)
|
156
|
+
rspec-sidekiq (3.0.3)
|
157
|
+
rspec-core (~> 3.0, >= 3.0.0)
|
158
|
+
sidekiq (>= 2.4.0)
|
159
|
+
rspec-support (3.9.2)
|
160
|
+
rspec_junit_formatter (0.4.1)
|
161
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
162
|
+
safe_yaml (1.0.5)
|
163
|
+
shoulda-matchers (3.1.3)
|
164
|
+
activesupport (>= 4.0.0)
|
165
|
+
sidekiq (6.0.7)
|
166
|
+
connection_pool (>= 2.2.2)
|
167
|
+
rack (~> 2.0)
|
168
|
+
rack-protection (>= 2.0.0)
|
169
|
+
redis (>= 4.1.0)
|
170
|
+
sprockets (4.0.0)
|
171
|
+
concurrent-ruby (~> 1.0)
|
172
|
+
rack (> 1, < 3)
|
173
|
+
sprockets-rails (3.2.1)
|
174
|
+
actionpack (>= 4.0)
|
175
|
+
activesupport (>= 4.0)
|
176
|
+
sprockets (>= 3.0.0)
|
177
|
+
thor (1.0.1)
|
178
|
+
thread_safe (0.3.6)
|
179
|
+
timecop (0.9.1)
|
180
|
+
tzinfo (1.2.7)
|
181
|
+
thread_safe (~> 0.1)
|
182
|
+
vcr (5.1.0)
|
183
|
+
webmock (3.8.3)
|
184
|
+
addressable (>= 2.3.6)
|
185
|
+
crack (>= 0.3.2)
|
186
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
187
|
+
websocket-driver (0.7.1)
|
188
|
+
websocket-extensions (>= 0.1.0)
|
189
|
+
websocket-extensions (0.1.4)
|
190
|
+
|
191
|
+
PLATFORMS
|
192
|
+
ruby
|
193
|
+
|
194
|
+
DEPENDENCIES
|
195
|
+
factory_bot_rails (>= 5.1.1)
|
196
|
+
orb_def!
|
197
|
+
pg
|
198
|
+
rspec-rails (~> 3.9.0)
|
199
|
+
rspec-sidekiq
|
200
|
+
rspec_junit_formatter
|
201
|
+
shoulda-matchers (~> 3.1)
|
202
|
+
timecop (~> 0.9.1)
|
203
|
+
vcr
|
204
|
+
webmock
|
205
|
+
|
206
|
+
BUNDLED WITH
|
207
|
+
1.17.3
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2020 James Gascoigne-Taylor
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
[![CircleCI](https://circleci.com/gh/flippakitten/orbital_defence_engine/tree/master.svg?style=svg)](https://circleci.com/gh/flippakitten/orbital_defence_engine/tree/master)
|
2
|
+
# OrbitalDefenceEngine
|
3
|
+
Busy extracting out the logic from [Orbital Defence Demo](https://github.com/flippakitten/orbital_defence_demo)
|
4
|
+
Will probably rename this to something shorter and does not contain the word Engine (unless I name it FireEngine)
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
Coming soon!
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'orb_def'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
```bash
|
18
|
+
$ bundle
|
19
|
+
```
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
```bash
|
23
|
+
$ gem install orb_def
|
24
|
+
```
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
Contribution directions go here.
|
28
|
+
|
29
|
+
## License
|
30
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'OrbitalDefenceEngine'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
load 'rails/tasks/statistics.rake'
|
21
|
+
|
22
|
+
require 'bundler/gem_tasks'
|
23
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require rails-ujs
|
14
|
+
//= require activestorage
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module OrbDef
|
2
|
+
class Api::V1::FiresController < ApplicationController
|
3
|
+
include Pagy::Backend
|
4
|
+
after_action { pagy_headers_merge(@pagy) if @pagy }
|
5
|
+
|
6
|
+
def index
|
7
|
+
@pagy, @records = pagy(Fire.in_last_24_hours, items: 100)
|
8
|
+
|
9
|
+
render json: { data: @records }, status: :ok, each_serializer: Api::V1::FireSerializer
|
10
|
+
end
|
11
|
+
|
12
|
+
def search
|
13
|
+
render json: fires_in_bounds, status: :ok, each_serializer: Api::V1::FireSerializer
|
14
|
+
end
|
15
|
+
|
16
|
+
def fires_current_wind_direction_indicator
|
17
|
+
|
18
|
+
wind_indicators = fires_in_bounds.map do |fire|
|
19
|
+
current_weather = fire.weather_station.weather_readings.last
|
20
|
+
endpoint = fire.endpoint(current_weather.wind_direction, 2)
|
21
|
+
{
|
22
|
+
fire: { lat: fire.latitude, lng: fire.longitude },
|
23
|
+
wind: { lat: endpoint.lat, lng: endpoint.lng }
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
render json: wind_indicators, status: :ok
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def fire_params
|
33
|
+
params.permit(:sw_bound_point, :ne_bound_point)
|
34
|
+
end
|
35
|
+
|
36
|
+
def fires_in_bounds
|
37
|
+
@fires_in_bounds ||= Fire.in_last_24_hours.in_bounds([sw_bound_point, ne_bound_point])
|
38
|
+
end
|
39
|
+
def sw_bound_point
|
40
|
+
@sw_bound_point ||= Geokit::LatLng.new(get_lat(sw_lat_lng), get_lng(sw_lat_lng))
|
41
|
+
end
|
42
|
+
|
43
|
+
def ne_bound_point
|
44
|
+
@ne_bound_point ||= Geokit::LatLng.new(get_lat(ne_lat_lng), get_lng(ne_lat_lng))
|
45
|
+
end
|
46
|
+
|
47
|
+
def ne_lat_lng
|
48
|
+
params['ne_bound_point']
|
49
|
+
end
|
50
|
+
|
51
|
+
def sw_lat_lng
|
52
|
+
params['sw_bound_point']
|
53
|
+
end
|
54
|
+
|
55
|
+
def get_lat(string)
|
56
|
+
string.split(',').first.to_f
|
57
|
+
end
|
58
|
+
|
59
|
+
def get_lng(string)
|
60
|
+
string.split(',').last.to_f
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module OrbDef
|
2
|
+
class Api::V1::WeatherReadingsController < ApplicationController
|
3
|
+
|
4
|
+
def show
|
5
|
+
reading = WeatherStation.find(params['id'].to_i).weather_readings.last
|
6
|
+
render json: reading.to_json, status: :ok
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def fire_params
|
12
|
+
params.permit(:id)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module OrbDef
|
2
|
+
class Fire < ApplicationRecord
|
3
|
+
acts_as_mappable :default_units => :kms,
|
4
|
+
:default_formula => :sphere,
|
5
|
+
:distance_field_name => :distance,
|
6
|
+
:lat_column_name => :latitude,
|
7
|
+
:lng_column_name => :longitude
|
8
|
+
|
9
|
+
belongs_to :weather_station
|
10
|
+
belongs_to :detection_type
|
11
|
+
has_many :weather_readings, through: :weather_station
|
12
|
+
|
13
|
+
validates :identifier, uniqueness: true
|
14
|
+
validates :latitude, presence: true
|
15
|
+
validates :longitude, presence: true
|
16
|
+
|
17
|
+
scope :in_last_24_hours, -> { where(detected_at: (Time.now - 24.hours)..Time.now) }
|
18
|
+
|
19
|
+
class << self
|
20
|
+
def create_from_csv_row(row, scan_type)
|
21
|
+
acq_time = row['acq_time'].include?(':') ? row['acq_time'] : "#{row['acq_time'][0..1]}:#{row['acq_time'][2..3]}"
|
22
|
+
detected_at = "#{row['acq_date']} #{acq_time}"
|
23
|
+
lat_long = "#{row['latitude']},#{row['longitude']}"
|
24
|
+
fire_identifier = Digest::SHA2.hexdigest "#{lat_long}#{detected_at}"
|
25
|
+
|
26
|
+
return if Fire.find_by(identifier: fire_identifier).present?
|
27
|
+
|
28
|
+
fire = Fire.create(
|
29
|
+
identifier: fire_identifier,
|
30
|
+
lat_long: lat_long,
|
31
|
+
scan_type: scan_type.downcase,
|
32
|
+
latitude: row['latitude'].to_f,
|
33
|
+
longitude: row['longitude'].to_f,
|
34
|
+
brightness: row['brightness'],
|
35
|
+
bright_t31: row['bright_t31'],
|
36
|
+
bright_ti5: row['bright_ti5'],
|
37
|
+
bright_ti4: row['bright_ti4'],
|
38
|
+
scan: row['scan'],
|
39
|
+
track: row['track'],
|
40
|
+
frp: row['frp'],
|
41
|
+
satellite: row['satellite'],
|
42
|
+
confidence: row['confidence'],
|
43
|
+
version: row['version'],
|
44
|
+
day_night: row['day_night'],
|
45
|
+
detected_at: detected_at.to_datetime,
|
46
|
+
detection_type_id: OrbDef::DetectionType.find_by_name('Satellite').id
|
47
|
+
)
|
48
|
+
|
49
|
+
station, reading = OrbDef::FireWeatherData.new(fire).find_or_create_weather
|
50
|
+
|
51
|
+
fire.update_attributes(detected_at_weather_reading_id: reading.id, weather_station_id: station.id)
|
52
|
+
fire.save!
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def detected_at_weather
|
57
|
+
OrbDef::WeatherReading.find_by(id: weather_reading_id)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module OrbDef
|
2
|
+
class WeatherReading < ApplicationRecord
|
3
|
+
belongs_to :weather_station
|
4
|
+
has_many :fires, through: :weather_station
|
5
|
+
|
6
|
+
validates :identifier, uniqueness: true
|
7
|
+
validates :temperature, presence: true
|
8
|
+
|
9
|
+
after_find :convert_temperature
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def find_or_create_by_reading(reading_json, weather_station_id)
|
13
|
+
identifier = "#{reading_json['name']}:#{reading_json['dt']}"
|
14
|
+
weather_reading = WeatherReading.find_by(identifier: identifier)
|
15
|
+
|
16
|
+
return weather_reading if weather_reading.present?
|
17
|
+
|
18
|
+
WeatherReading.create(
|
19
|
+
weather_station_id: weather_station_id,
|
20
|
+
identifier: identifier,
|
21
|
+
temperature: reading_json['main']['temp'],
|
22
|
+
pressure: reading_json['main']['pressure'],
|
23
|
+
ground_level: reading_json['main']['grnd_level'],
|
24
|
+
humidity: reading_json['main']['humidity'],
|
25
|
+
wind_speed: ( reading_json['wind']['speed'] * 3.6),
|
26
|
+
wind_direction: reading_json['wind']['deg'],
|
27
|
+
rain: reading_json.dig('rain', '3h'),
|
28
|
+
cloud: reading_json.dig('clouds', 'today'),
|
29
|
+
description: reading_json['weather'].first['description'],
|
30
|
+
reading_at: Time.at(reading_json['dt']).to_datetime
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def convert_temperature
|
38
|
+
self.temperature = self.temperature - 273.15
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|