fallo_motor 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/Rakefile +6 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/exe/fallo_motor +112 -0
- data/fallo_motor.gemspec +28 -0
- data/lib/fallo_motor/version.rb +3 -0
- data/lib/fallo_motor.rb +1 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 797404d75ecebc407002a679a517091ed360aa03
|
4
|
+
data.tar.gz: 70cdaddcd16a63ffa9e04157b1fbed7da2715dba
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 539f954d7215635b3f4565833070cb16418ec2c1ac9e57e274eb68145324a02f5c04e2ebb68f2bb24d74b306449317ea6445b5532824411f3f29e0c81c85f49a
|
7
|
+
data.tar.gz: 42d9b2742e557e9599e135e617c8f5b36e3fd4179b4f78224549f54aaee787ac4c1b271eb786249e9af4d7a76d2afd0658239bbec42e7c0eee2dcab84f07e5c3
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 David Marchante
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "fallo_motor"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
require "pry"
|
11
|
+
Pry.start
|
data/bin/setup
ADDED
data/exe/fallo_motor
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'csv'
|
4
|
+
require 'nokogiri'
|
5
|
+
|
6
|
+
# Pillamos los ficheros
|
7
|
+
unless ARGV.size == 2
|
8
|
+
puts 'Dame los 2 ficheros'
|
9
|
+
exit
|
10
|
+
end
|
11
|
+
|
12
|
+
# Comprobar e inicializar el KML
|
13
|
+
kml_file = ARGV.index { |file| file =~ /\.kml$/i }
|
14
|
+
unless kml_file
|
15
|
+
puts 'Falta el kml'
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
|
19
|
+
kml_file = ARGV[kml_file]
|
20
|
+
|
21
|
+
# Comprobar e inicializar el CSV
|
22
|
+
csv_file = ARGV.index { |file| file =~ /\.csv$/i }
|
23
|
+
unless csv_file
|
24
|
+
puts 'Falta el csv'
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
|
28
|
+
csv_file = ARGV[csv_file]
|
29
|
+
|
30
|
+
# Constantes
|
31
|
+
meters = 0.3048
|
32
|
+
lost_engine_coeff = 0.8 / 100
|
33
|
+
|
34
|
+
# Datos de actuaciones del avion
|
35
|
+
csv_data = CSV.read(csv_file, converters: :numeric)
|
36
|
+
|
37
|
+
# Datos de Google Earth
|
38
|
+
kml_data = Nokogiri::XML(File.open(kml_file))
|
39
|
+
|
40
|
+
# Coordenadas pasadas a floats
|
41
|
+
flight_path_node = kml_data.at('Folder Placemark LineString coordinates')
|
42
|
+
splay_node = kml_data.at('Folder Placemark Polygon outerBoundaryIs LinearRing coordinates')
|
43
|
+
flight_path_coor = flight_path_node.text.split.map! { |coor| coor.split(',').map!(&:to_f) }
|
44
|
+
splay_coor = splay_node.text.split.map! { |coor| coor.split(',').map!(&:to_f) }
|
45
|
+
|
46
|
+
# Datos iniciales del bucle
|
47
|
+
h_inicial = flight_path_coor.first[2] - csv_data[4][4] * meters
|
48
|
+
thrust0 = csv_data[4][21]
|
49
|
+
gr0 = h0 = h0_corregida = 0.0
|
50
|
+
splay_idx = 0
|
51
|
+
engine_failed = false
|
52
|
+
ft35 = false
|
53
|
+
|
54
|
+
# Recorremos ambos sistemas de coordenadas
|
55
|
+
flight_path_coor.each_with_index do |coor, i|
|
56
|
+
# Hay que saltarse las 4 filas de cabecera del csv
|
57
|
+
csv_row = csv_data[i + 4]
|
58
|
+
|
59
|
+
h1 = (h_inicial + csv_row[4] * meters).round(4)
|
60
|
+
gr1 = csv_row[7]
|
61
|
+
thrust1 = csv_row[21]
|
62
|
+
|
63
|
+
# Pido perdon a los informaticos del mundo
|
64
|
+
# Calcular la nueva altura
|
65
|
+
if engine_failed
|
66
|
+
tan_alpha = (h1 - h0) / (gr1 - gr0)
|
67
|
+
h1_corregida = (h0_corregida + (tan_alpha - lost_engine_coeff) * (gr1 - gr0)).round(4)
|
68
|
+
|
69
|
+
# Valores iniciales para la siguiente iteracion
|
70
|
+
h0 = h1
|
71
|
+
h0_corregida = h1_corregida
|
72
|
+
gr0 = gr1
|
73
|
+
elsif thrust1 <= thrust0 * 0.6
|
74
|
+
engine_failed = true
|
75
|
+
h1_corregida = h1
|
76
|
+
gr0 = gr1
|
77
|
+
h0 = h1
|
78
|
+
h0_corregida = h1
|
79
|
+
else
|
80
|
+
h1_corregida = h1
|
81
|
+
thrust0 = thrust1
|
82
|
+
end
|
83
|
+
|
84
|
+
# Corregir el splay
|
85
|
+
if ft35
|
86
|
+
splay_coor[i - splay_idx][2] = h1_corregida
|
87
|
+
elsif csv_row[0].include? '35FT'
|
88
|
+
ft35 = true
|
89
|
+
splay_idx = i
|
90
|
+
splay_coor[0][2] = h1_corregida
|
91
|
+
end
|
92
|
+
|
93
|
+
# Escribir la coordenada z
|
94
|
+
coor[2] = h1_corregida
|
95
|
+
end
|
96
|
+
|
97
|
+
# Punto medio del splay
|
98
|
+
splay_coor[splay_coor.size / 2][2] = splay_coor[splay_coor.size / 2 - 1][2]
|
99
|
+
|
100
|
+
# Revertimos las alturas simetricamente
|
101
|
+
splay_coor[0..splay_coor.size / 2].each_with_index do |coor, i|
|
102
|
+
splay_coor[-i - 1][2] = coor[2]
|
103
|
+
end
|
104
|
+
|
105
|
+
# Marcamos alturas absolutas para el splay
|
106
|
+
kml_data.at('Folder Placemark Polygon').add_child '<altitudeMode>absolute</altitudeMode>'
|
107
|
+
|
108
|
+
# Write to file
|
109
|
+
filename = 'output.kml'
|
110
|
+
flight_path_node.content = flight_path_coor.map { |el| el.join(',') }.join("\n")
|
111
|
+
splay_node.content = splay_coor.map { |el| el.join(',') }.join("\n")
|
112
|
+
File.write(filename, kml_data.to_xml)
|
data/fallo_motor.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fallo_motor/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fallo_motor"
|
8
|
+
spec.version = FalloMotor::VERSION
|
9
|
+
spec.authors = ["David Marchante"]
|
10
|
+
spec.email = ["davidmarchan@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Un favor para Carlos}
|
13
|
+
spec.homepage = "https://github.com/iovis9/fallo_motor"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "nokogiri", "~> 1.6"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
spec.add_development_dependency 'pry', '~> 0.10'
|
27
|
+
spec.add_development_dependency 'pry-byebug', '~> 3.3'
|
28
|
+
end
|
data/lib/fallo_motor.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "fallo_motor/version"
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fallo_motor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Marchante
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.10'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.10'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry-byebug
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.3'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.3'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- davidmarchan@gmail.com
|
100
|
+
executables:
|
101
|
+
- fallo_motor
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- ".travis.yml"
|
108
|
+
- Gemfile
|
109
|
+
- LICENSE.txt
|
110
|
+
- Rakefile
|
111
|
+
- bin/console
|
112
|
+
- bin/setup
|
113
|
+
- exe/fallo_motor
|
114
|
+
- fallo_motor.gemspec
|
115
|
+
- lib/fallo_motor.rb
|
116
|
+
- lib/fallo_motor/version.rb
|
117
|
+
homepage: https://github.com/iovis9/fallo_motor
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata: {}
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 2.6.4
|
138
|
+
signing_key:
|
139
|
+
specification_version: 4
|
140
|
+
summary: Un favor para Carlos
|
141
|
+
test_files: []
|