vatsim_online 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +65 -22
- data/lib/vatsim_online/station.rb +37 -1
- data/lib/vatsim_online/version.rb +1 -1
- data/spec/vatsim_online_spec.rb +34 -0
- data/vatsim_online.gemspec +1 -0
- metadata +18 -2
data/README.md
CHANGED
@@ -6,11 +6,9 @@ online ATC and/or pilots for given airports, areas or globally. Stations are
|
|
6
6
|
returned as objects, exposing a rich set of attributes. Vatsim data is pulled
|
7
7
|
on preset intervals and cached locally to avoid flooding the servers.
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
* Code Analysis (CodeClimate): [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/tarakanbg/vatsim_online)
|
13
|
-
* Dependencies: (Gemnasium) [![Gemnasium](https://gemnasium.com/tarakanbg/vatsim_online.png?travis)](https://gemnasium.com/tarakanbg/vatsim_online)
|
9
|
+
[![Build Status](https://secure.travis-ci.org/tarakanbg/vatsim_online.png?branch=master)](http://travis-ci.org/tarakanbg/vatsim_online)
|
10
|
+
[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/tarakanbg/vatsim_online)
|
11
|
+
[![Gemnasium](https://gemnasium.com/tarakanbg/vatsim_online.png?travis)](https://gemnasium.com/tarakanbg/vatsim_online)
|
14
12
|
|
15
13
|
## Requirements
|
16
14
|
|
@@ -108,23 +106,42 @@ and departures.
|
|
108
106
|
|
109
107
|
Here's a complete list of the station object attributes that can be accessed:
|
110
108
|
|
111
|
-
*
|
112
|
-
*
|
113
|
-
*
|
114
|
-
*
|
115
|
-
*
|
116
|
-
*
|
117
|
-
*
|
118
|
-
*
|
119
|
-
*
|
120
|
-
*
|
121
|
-
*
|
122
|
-
*
|
123
|
-
*
|
124
|
-
*
|
125
|
-
*
|
126
|
-
*
|
127
|
-
*
|
109
|
+
* `cid` (VATSIM ID)
|
110
|
+
* `callsign`
|
111
|
+
* `name`
|
112
|
+
* `role`
|
113
|
+
* `frequency`
|
114
|
+
* `altitude`
|
115
|
+
* `planned_altitude` (or FL)
|
116
|
+
* `heading`
|
117
|
+
* `groundspeed`
|
118
|
+
* `transponder`
|
119
|
+
* `aircraft`
|
120
|
+
* `origin`
|
121
|
+
* `destination`
|
122
|
+
* `route`
|
123
|
+
* `rating`
|
124
|
+
* `facility`
|
125
|
+
* `remarks`
|
126
|
+
* `atis`
|
127
|
+
* `logon` (login time)
|
128
|
+
* `latitude`
|
129
|
+
* `longitude`
|
130
|
+
* `latitude_humanized` (e.g. N44.09780)
|
131
|
+
* `longitude_humanized` (e.g. W58.41483)
|
132
|
+
* `qnh_in` (set QNH in inches Hg)
|
133
|
+
* `qnh_mb` (set QNH in milibars/hectopascals)
|
134
|
+
* `flight_type` (`I` for IFR, `V` for VFR, etc)
|
135
|
+
* `gcmap` (returns a great circle map image url)
|
136
|
+
|
137
|
+
### Great circle map visualization
|
138
|
+
|
139
|
+
The `.gcmap` method, available for all pilot stations, returns a great
|
140
|
+
circle map image url, depicting the GC route of the aircraft, its origin and destination,
|
141
|
+
its current position on the route, together with its current altitude and groundspeed.
|
142
|
+
Example picture below.
|
143
|
+
|
144
|
+
![GC Map](http://www.gcmap.com/map?P=kdfw-N44.09780+W58.41483-egll,+%22AAL026%5cn37112+ft%5cn516+kts%22%2b%40N44.09780+W58.41483&MS=wls&MR=540&MX=720x360&PM=*)
|
128
145
|
|
129
146
|
### Customizing the request
|
130
147
|
|
@@ -195,8 +212,10 @@ end
|
|
195
212
|
= pilot.origin
|
196
213
|
= pilot.destination
|
197
214
|
= pilot.route
|
215
|
+
= pilot.flight_type
|
198
216
|
= pilot.altitude
|
199
217
|
= pilot.groundspeed
|
218
|
+
= pilot.heading
|
200
219
|
= pilot.remarks
|
201
220
|
|
202
221
|
- for arrival in @arrivals
|
@@ -226,6 +245,17 @@ current algorithm does not evaluate enroute flights.
|
|
226
245
|
|
227
246
|
## Changelog
|
228
247
|
|
248
|
+
### v. 0.4 - 27 August 2012
|
249
|
+
|
250
|
+
* GCMapper integration: this library now plays nicely with [gcmapper](https://rubygems.org/gems/gcmapper).
|
251
|
+
A new attribute is provided for the pilot stations: `.gcmap` which returns a great
|
252
|
+
circle map image url, depicting the GC route of the aircraft, its origin and destination,
|
253
|
+
its current position on the route, together with its current altitude and groundspeed.
|
254
|
+
Look at the example in the README section above.
|
255
|
+
* New station attributes: planned_altitude, transponder, heading, qnh_in, qnh_mb,
|
256
|
+
flight_type, cid, latitude_humanized, longitude_humanized
|
257
|
+
|
258
|
+
|
229
259
|
### v. 0.3 - 22 July 2012
|
230
260
|
|
231
261
|
* The hash returned by the `vatsim_online` method now includes 2 new arrays:
|
@@ -251,3 +281,16 @@ original Vatsim data is re-encoded
|
|
251
281
|
4. Make sure all tests are passing!
|
252
282
|
5. Push to the branch (`git push origin my-new-feature`)
|
253
283
|
6. Create new Pull Request
|
284
|
+
|
285
|
+
## Credits
|
286
|
+
|
287
|
+
Copyright © 2012 [Svilen Vassilev](http://about.me/svilen)
|
288
|
+
|
289
|
+
*If you find my work useful or time-saving, you can endorse it or buy me a beer:*
|
290
|
+
|
291
|
+
[![endorse](http://api.coderwall.com/svilenv/endorse.png)](http://coderwall.com/svilenv)
|
292
|
+
[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5FR7AQA4PLD8A)
|
293
|
+
|
294
|
+
Released under the [MIT LICENSE](https://github.com/tarakanbg/airdata/blob/master/LICENSE)
|
295
|
+
|
296
|
+
Maps generated by the [Great Circle Mapper](http://www.gcmap.com/), copyright Karl L. Swartz
|
@@ -1,17 +1,23 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module VatsimTools
|
3
3
|
class Station
|
4
|
+
require "gcmapper"
|
5
|
+
|
4
6
|
attributes = %w{callsign name role frequency altitude groundspeed aircraft
|
5
|
-
origin destination rating facility remarks route atis logon latitude longitude
|
7
|
+
origin destination rating facility remarks route atis logon latitude longitude
|
8
|
+
planned_altitude transponder heading qnh_in qnh_mb flight_type cid gcmap
|
9
|
+
latitude_humanized longitude_humanized}
|
6
10
|
attributes.each {|attribute| attr_accessor attribute.to_sym }
|
7
11
|
|
8
12
|
|
9
13
|
def initialize(station)
|
10
14
|
@callsign = station[0]
|
15
|
+
@cid = station[1]
|
11
16
|
@name = station[2]
|
12
17
|
@role = station[3]
|
13
18
|
@frequency = station[4]
|
14
19
|
@altitude = station[7]
|
20
|
+
@planned_altitude = station[12]
|
15
21
|
@groundspeed = station[8]
|
16
22
|
@aircraft = station[9]
|
17
23
|
@origin = station[11]
|
@@ -23,7 +29,37 @@ module VatsimTools
|
|
23
29
|
@atis = atis_cleaner(station[35]) if station[35]
|
24
30
|
@logon = station[37]
|
25
31
|
@latitude = station[5]
|
32
|
+
@latitude_humanized = latitude_parser(station[5].to_f)
|
26
33
|
@longitude = station[6]
|
34
|
+
@longitude_humanized = longitude_parser(station[6].to_f)
|
35
|
+
@transponder = station[17]
|
36
|
+
@heading = station[38]
|
37
|
+
@qnh_in = station[39]
|
38
|
+
@qnh_mb = station[40]
|
39
|
+
@flight_type = station[21]
|
40
|
+
@gcmap = gcmap_generator
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def gcmap_generator
|
46
|
+
return "No map for ATC stations" if @role != "PILOT"
|
47
|
+
route = @origin
|
48
|
+
route += "-" + @latitude_humanized + "+" + @longitude_humanized
|
49
|
+
route += "-" + @destination
|
50
|
+
route += "%2C+\"" + @callsign + "%5Cn" + @altitude + "+ft%5Cn" + @groundspeed + "+kts"
|
51
|
+
route += "\"%2B%40" + @latitude_humanized + "+" + @longitude_humanized
|
52
|
+
route.gcmap
|
53
|
+
end
|
54
|
+
|
55
|
+
def latitude_parser(lat)
|
56
|
+
lat > 0 ? hemisphere = "N" : hemisphere = "S"
|
57
|
+
hemisphere + lat.abs.to_s
|
58
|
+
end
|
59
|
+
|
60
|
+
def longitude_parser(lon)
|
61
|
+
lon > 0 ? hemisphere = "E" : hemisphere = "W"
|
62
|
+
hemisphere + lon.abs.to_s
|
27
63
|
end
|
28
64
|
|
29
65
|
def atis_cleaner(raw_atis)
|
data/spec/vatsim_online_spec.rb
CHANGED
@@ -49,8 +49,42 @@ describe VatsimTools::Station do
|
|
49
49
|
new_object.facility.should eq("5")
|
50
50
|
new_object.logon.should eq("20120722092836")
|
51
51
|
new_object.latitude.should eq("2.93968")
|
52
|
+
new_object.latitude_humanized.should eq("N2.93968")
|
52
53
|
new_object.longitude.should eq("101.39812")
|
54
|
+
new_object.longitude_humanized.should eq("E101.39812")
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
58
|
+
describe "pilot object" do
|
59
|
+
it "should contain all attributes" do
|
60
|
+
gem_data_file
|
61
|
+
icao = "EGLL"
|
62
|
+
station = VatsimTools::StationParser.new(icao).stations.first
|
63
|
+
new_object = VatsimTools::Station.new(station)
|
64
|
+
new_object.callsign.should eq("AAL026")
|
65
|
+
new_object.name.should eq("Manuel Santillan MMCU")
|
66
|
+
new_object.role.should eq("PILOT")
|
67
|
+
new_object.latitude.should eq("44.09780")
|
68
|
+
new_object.latitude_humanized.should eq("N44.0978")
|
69
|
+
new_object.longitude.should eq("-58.41483")
|
70
|
+
new_object.longitude_humanized.should eq("W58.41483")
|
71
|
+
new_object.planned_altitude.should eq("370")
|
72
|
+
new_object.transponder.should eq("4122")
|
73
|
+
new_object.heading.should eq("73")
|
74
|
+
new_object.qnh_in.should eq("30.12")
|
75
|
+
new_object.qnh_mb.should eq("1019")
|
76
|
+
new_object.flight_type.should eq("I")
|
77
|
+
new_object.cid.should eq("1210329")
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should generate gcmap link" do
|
81
|
+
gem_data_file
|
82
|
+
icao = "EGLL"
|
83
|
+
station = VatsimTools::StationParser.new(icao).stations.first
|
84
|
+
new_object = VatsimTools::Station.new(station)
|
85
|
+
new_object.gcmap.should eq("http://www.gcmap.com/map?P=KDFW-N44.0978+W58.41483-EGLL%2C+\"AAL026%5Cn37210+ft%5Cn543+kts\"%2B%40N44.0978+W58.41483%0d%0a&MS=wls&MR=120&MX=720x360&PM=b:disc7%2b\"%25U%25+%28N\"")
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
56
90
|
end
|
data/vatsim_online.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vatsim_online
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.4'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -123,6 +123,22 @@ dependencies:
|
|
123
123
|
- - ~>
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: 0.2.2
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: gcmapper
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ~>
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0.3'
|
134
|
+
type: :runtime
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ~>
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0.3'
|
126
142
|
description: Selectively pulls and parses Vatsim online stations data. Essentially
|
127
143
|
it's a 'who's online' library, capable of displaying online ATC and/or pilots for
|
128
144
|
given airports, areas or globally. Stations are returned as objects, exposing a
|