fgmapping 1.3.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{LICENSE → LICENSE.txt} +0 -0
- data/README +11 -17
- data/README.internal +4 -0
- data/README.rdoc +19 -0
- data/Rakefile +54 -17
- data/VERSION +1 -0
- data/{lib/init.rb → bin/fgmapping} +1 -1
- data/{bin/flightgear-mapping → lib/fgmapping.rb} +7 -2
- data/lib/{bsearch.rb → fgmapping/bsearch.rb} +0 -0
- data/lib/fgmapping/context_menu.rb +110 -0
- data/lib/{hud-impl.rb → fgmapping/hud-impl.rb} +1 -1
- data/lib/{hud-widget.rb → fgmapping/hud-widget.rb} +0 -0
- data/lib/{main-dlg-impl.rb → fgmapping/main-dlg-impl.rb} +131 -187
- data/lib/{main-dlg.rb → fgmapping/main-dlg.rb} +0 -0
- data/lib/{navaid.rb → fgmapping/navaid.rb} +1 -1
- data/lib/{nodeinfo-impl.rb → fgmapping/nodeinfo-impl.rb} +1 -1
- data/lib/{nodeinfo-widget.rb → fgmapping/nodeinfo-widget.rb} +0 -0
- data/lib/{resources.marshal → fgmapping/resources.marshal} +0 -0
- data/lib/{resources.rb → fgmapping/resources.rb} +0 -0
- data/lib/{tile.rb → fgmapping/tile.rb} +0 -0
- data/lib/{waypoint.rb → fgmapping/waypoint.rb} +1 -1
- data/test/helper.rb +18 -0
- data/test/test_fgmap.rb +7 -0
- metadata +105 -66
- data/CHANGELOG +0 -18
- data/Manifest +0 -22
- data/fgmapping.gemspec +0 -32
- data/lib/LICENSE +0 -340
- data/lib/README +0 -45
data/{LICENSE → LICENSE.txt}
RENAMED
File without changes
|
data/README
CHANGED
@@ -1,39 +1,33 @@
|
|
1
|
-
How to run
|
2
|
-
|
1
|
+
How to run fgmapping
|
2
|
+
====================
|
3
3
|
|
4
4
|
Requirements:
|
5
|
-
- ruby of course. Min version 1.8.6
|
6
|
-
- qtruby4, minimum version 4.4
|
5
|
+
- ruby of course. Min version 1.8.6 up to 1.9.2
|
6
|
+
- either:qtruby4, minimum version 4.4
|
7
7
|
see: http://rubyforge.org/projects/korundum
|
8
8
|
debian/ubuntu: sudo apt-get install libqt4-ruby
|
9
|
-
|
10
|
-
|
11
|
-
debian/ubuntu: sudo apt-get install libxml-ruby
|
9
|
+
or: qtbindings, min version 4.6.3.1
|
10
|
+
sudo gem install qtbindings
|
12
11
|
|
13
12
|
|
14
13
|
Run:
|
15
|
-
You basically have
|
14
|
+
You basically have 2 options:
|
16
15
|
|
17
16
|
1) (you already have ruby and qtruby installed)
|
18
17
|
- unpack the 'fgmap.tar.gz' into any directory
|
19
18
|
- cd into this directory
|
20
|
-
- on shell type: ruby
|
19
|
+
- on shell type: ruby waypoint.rb
|
21
20
|
|
22
21
|
2) (you already have ruby and rubygems installed)
|
23
22
|
- type: sudo gem install fgmapping
|
24
|
-
- make sure /var/lib/gems/1
|
25
|
-
- execute '
|
26
|
-
|
27
|
-
3) (you don't have ruby installed, don't even know what this is)
|
28
|
-
- download "fgmap_linux"
|
29
|
-
- change permission to 'executable': chmod 774 fgmap_linux
|
30
|
-
- to run it, just type ./fgmap_linux
|
23
|
+
- make sure /var/lib/gems/1.*/bin is in your standard path ($PATH)
|
24
|
+
- execute 'fgmapping'
|
31
25
|
|
32
26
|
In any case you need to launch Flightgear like this:
|
33
27
|
- run Flightgear with additional command line option: --telnet=2948
|
34
28
|
|
35
29
|
|
36
|
-
|
30
|
+
Development:
|
37
31
|
Download git repository:
|
38
32
|
- git clone git://rubyforge.org/fgmap.git
|
39
33
|
Remarks for development:
|
data/README.internal
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= fgmap
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to fgmap
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 Michael Meltner. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
CHANGED
@@ -1,23 +1,60 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
2
10
|
require 'rake'
|
3
|
-
require 'echoe'
|
4
11
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
12
|
+
exclude_me = ['*.ui', '*.png', '*.svg', '*.qrc', 'Makefile', 'compress-resource.rb']
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "fgmapping"
|
18
|
+
gem.homepage = "http://rubyforge.org/frs/?group_id=9572"
|
19
|
+
gem.license = "GPL2"
|
20
|
+
gem.summary = %Q{Real-time mapping for Flightgear}
|
21
|
+
gem.description = %Q{Provide a real-time map of flight position in Flightgear. It is based on tiles from Openstreetmap with elevation shading, provides navigation aids and runways, allows setting of waypoints, sends these to Flightgear's route-manager and tracks the flight.}
|
22
|
+
gem.email = "mmeltner@gmail.com"
|
23
|
+
gem.authors = ["Michael Meltner"]
|
24
|
+
gem.rubyforge_project = "fgmap"
|
25
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
26
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
27
|
+
# gem.add_runtime_dependency 'qtbindings', '>= 4.6.3.1'
|
28
|
+
|
29
|
+
exclude_me.each do |excl|
|
30
|
+
gem.files.exclude "lib/**/#{excl}"
|
31
|
+
end
|
10
32
|
end
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
p.email = "mmeltner @nospamplease@ gmail.com"
|
20
|
-
p.ignore_pattern = ["tmp/*", "script/*", "develop/*", "README.build_gem", "*.gz"]
|
21
|
-
p.development_dependencies = []
|
33
|
+
Jeweler::GemcutterTasks.new
|
34
|
+
Jeweler::RubygemsDotOrgTasks.new
|
35
|
+
|
36
|
+
require 'rake/testtask'
|
37
|
+
Rake::TestTask.new(:test) do |test|
|
38
|
+
test.libs << 'lib' << 'test'
|
39
|
+
test.pattern = 'test/**/test_*.rb'
|
40
|
+
test.verbose = true
|
22
41
|
end
|
23
42
|
|
43
|
+
require 'rcov/rcovtask'
|
44
|
+
Rcov::RcovTask.new do |test|
|
45
|
+
test.libs << 'test'
|
46
|
+
test.pattern = 'test/**/test_*.rb'
|
47
|
+
test.verbose = true
|
48
|
+
end
|
49
|
+
|
50
|
+
task :default => :test
|
51
|
+
|
52
|
+
require 'rake/rdoctask'
|
53
|
+
Rake::RDocTask.new do |rdoc|
|
54
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
55
|
+
|
56
|
+
rdoc.rdoc_dir = 'rdoc'
|
57
|
+
rdoc.title = "fgmap #{version}"
|
58
|
+
rdoc.rdoc_files.include('README*')
|
59
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
60
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0
|
@@ -12,7 +12,12 @@
|
|
12
12
|
# Author Michael Meltner (mmeltner@gmail.com)
|
13
13
|
##################################################
|
14
14
|
|
15
|
-
|
15
|
+
# check if we were launched via symlink, then resolve it
|
16
|
+
myself = __FILE__
|
17
|
+
if File.lstat(myself).symlink? then
|
18
|
+
myself = File.readlink(__FILE__)
|
19
|
+
end
|
20
|
+
Dir.chdir(File.dirname(myself))
|
16
21
|
|
17
|
-
load "waypoint.rb"
|
22
|
+
load "./fgmap/waypoint.rb"
|
18
23
|
|
File without changes
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
##################################################
|
3
|
+
# Flightgear Mapping
|
4
|
+
#
|
5
|
+
# Provide a real-time map of flight position in Flightgear. It is based on tiles from Openstreetmap,
|
6
|
+
# downloads them in the background, provides navigation aids and runways, allows setting of waypoints
|
7
|
+
# and tracks the flight.
|
8
|
+
#
|
9
|
+
# License
|
10
|
+
# GPL V2
|
11
|
+
#
|
12
|
+
# Author Michael Meltner (mmeltner@gmail.com)
|
13
|
+
##################################################
|
14
|
+
|
15
|
+
class TileGraphicsItemGroup < Qt::GraphicsItemGroup
|
16
|
+
def contextMenuEvent(contextEvent)
|
17
|
+
dlg=contextEvent.widget.parent.parent
|
18
|
+
# list of menu entries
|
19
|
+
# if it is itself an array then it is a checkbox menu entry and the 2nd item in this array is its boolean
|
20
|
+
entries=["Set Waypoint", "Delete Waypoint", "Waypoints to Route-Mgr", "Set Origin", "-", "Save Waypoints", "Save Track", "Load Waypoints",
|
21
|
+
"Load Track", ["Metric Units", dlg.metricUnit]]
|
22
|
+
menu=Qt::Menu.new
|
23
|
+
entries.each{|e|
|
24
|
+
if e.kind_of? Array then
|
25
|
+
action = Qt::Action.new(e[0], nil)
|
26
|
+
action.setCheckable(true)
|
27
|
+
action.setChecked(e[1])
|
28
|
+
menu.addAction(action)
|
29
|
+
else
|
30
|
+
# if array entry is "-" then just display a separator to make it more nice
|
31
|
+
if e=="-" then
|
32
|
+
menu.addSeparator
|
33
|
+
else
|
34
|
+
action = Qt::Action.new(e, nil)
|
35
|
+
if e =~ /(Delete Waypoint|Waypoints to)/ then
|
36
|
+
action.setEnabled(false) if dlg.waypoints.nodes.empty?
|
37
|
+
end
|
38
|
+
menu.addAction(action)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
}
|
42
|
+
sel=menu.exec(contextEvent.screenPos)
|
43
|
+
sel=sel.text if !sel.nil?
|
44
|
+
lon=dlg.node.tolon(dlg.node.xtile + contextEvent.scenePos.x / 256.0)
|
45
|
+
lat=dlg.node.tolat(dlg.node.ytile + contextEvent.scenePos.y / 256.0)
|
46
|
+
|
47
|
+
# now the selected item is handled, order is the same as defined in the array "entries" previously
|
48
|
+
case sel
|
49
|
+
when entries[0]
|
50
|
+
i=dlg.waypoints << Node.new(nil, Time.now, lon, lat)
|
51
|
+
dlg.putflag(contextEvent.scenePos.x, contextEvent.scenePos.y, i, dlg.waypoints.nodes.last)
|
52
|
+
if i==1 and dlg.waypoints.nodes.length == 1 then
|
53
|
+
dlg.w.lBcurrentwp.text="1"
|
54
|
+
dlg.waypoints.currentwp=1
|
55
|
+
end
|
56
|
+
|
57
|
+
when entries[1]
|
58
|
+
d=dlg.waypoints.del(lon,lat)
|
59
|
+
if dlg.w.lBcurrentwp.text.to_i == d then
|
60
|
+
dlg.w.lBcurrentwp.text="-"
|
61
|
+
end
|
62
|
+
dlg.movemap(dlg.node, true)
|
63
|
+
|
64
|
+
when entries[2]
|
65
|
+
Thread.new {
|
66
|
+
dlg.waypoints.nodes.each do |n|
|
67
|
+
dlg.writeFlightsim("set /autopilot/route-manager/input @INSERT-1:#{n.lon.to_s.gsub(",",".")},#{n.lat.to_s.gsub(",",".")}")
|
68
|
+
end
|
69
|
+
}
|
70
|
+
|
71
|
+
when entries[3]
|
72
|
+
dlg.node = Node.new(1, Time.now, lon, lat)
|
73
|
+
dlg.offset_x = 0
|
74
|
+
dlg.offset_y = 0
|
75
|
+
dlg.movemap(dlg.node, true)
|
76
|
+
|
77
|
+
when entries[5]
|
78
|
+
dlg.saveWaypoints([dlg.waypoints])
|
79
|
+
|
80
|
+
when entries[6]
|
81
|
+
dlg.savetrack(dlg.mytracks)
|
82
|
+
|
83
|
+
when entries[7]
|
84
|
+
savecurrent = dlg.waypoints.currentwp
|
85
|
+
if dlg.loadwaypoint("Load Waypoints") then
|
86
|
+
dlg.waypoints.currentwp = nil
|
87
|
+
else
|
88
|
+
dlg.waypoints.currentwp = savecurrent
|
89
|
+
end
|
90
|
+
|
91
|
+
when entries[8]
|
92
|
+
dlg.mytrack_current += (dlg.w.pBrecordTrack.isChecked ? 0 : 1)
|
93
|
+
savewp=dlg.mytracks[dlg.mytrack_current]
|
94
|
+
if dlg.mytracks[dlg.mytrack_current].nil? then
|
95
|
+
dlg.mytracks[dlg.mytrack_current] = Way.new(1, 'user', Time.now, dlg.nextcolor)
|
96
|
+
@prev_track_node = nil
|
97
|
+
end
|
98
|
+
if dlg.loadtrack("Load Track") then
|
99
|
+
dlg.w.pBrecordTrack.text = "Record Track #{dlg.mytrack_current + 2}"
|
100
|
+
dlg.w.pBrecordTrack.setChecked(false)
|
101
|
+
else
|
102
|
+
dlg.mytracks[dlg.mytrack_current]=savewp
|
103
|
+
end
|
104
|
+
|
105
|
+
when entries[9][0]
|
106
|
+
dlg.metricUnit = !dlg.metricUnit
|
107
|
+
|
108
|
+
end #case
|
109
|
+
end
|
110
|
+
end
|
File without changes
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding: utf-8
|
1
2
|
##################################################
|
2
3
|
# Flightgear Mapping
|
3
4
|
#
|
@@ -11,23 +12,31 @@
|
|
11
12
|
# Author Michael Meltner (mmeltner@gmail.com)
|
12
13
|
##################################################
|
13
14
|
|
15
|
+
|
14
16
|
require 'net/http'
|
15
|
-
require "main-dlg"
|
16
|
-
require "tile"
|
17
|
-
require "resources"
|
18
17
|
require 'socket'
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require '
|
22
|
-
require
|
18
|
+
require 'rexml/document'
|
19
|
+
require './main-dlg'
|
20
|
+
require './tile'
|
21
|
+
require './resources'
|
22
|
+
require './hud-impl'
|
23
|
+
require './nodeinfo-impl'
|
24
|
+
require './navaid.rb'
|
25
|
+
require './context_menu.rb'
|
23
26
|
begin
|
24
|
-
require
|
27
|
+
require 'ap'
|
25
28
|
rescue LoadError
|
26
29
|
def ap(*k)
|
27
30
|
p k
|
28
31
|
end
|
29
32
|
end
|
30
33
|
|
34
|
+
if RUBY_VERSION =~ /^1\.8/ then
|
35
|
+
class Net::HTTP
|
36
|
+
alias request_get get
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
31
40
|
OFFSET_FLAG_X = 3
|
32
41
|
OFFSET_FLAG_Y = 21
|
33
42
|
OFFSET_PIN_X = 1
|
@@ -79,6 +88,14 @@ MAPSDIR = ENV['HOME'] + "/.OpenstreetmapTiles"
|
|
79
88
|
#Thread.abort_on_exception = true
|
80
89
|
#GC.disable
|
81
90
|
|
91
|
+
class REXML::Element
|
92
|
+
def add_text_element(nodename, text)
|
93
|
+
e = REXML::Element.new(nodename)
|
94
|
+
e.add_text(text)
|
95
|
+
self.add_element(e)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
82
99
|
# Class MainDlg ############################################
|
83
100
|
class MainDlg < Qt::Widget
|
84
101
|
attr_reader :node, :scene_tiles, :scene, :toffset_x, :offset_y, :menu, :waypoints, \
|
@@ -99,12 +116,12 @@ class MainDlg < Qt::Widget
|
|
99
116
|
@cfg=Qt::Settings.new("MMeltnerSoft", "fg_map")
|
100
117
|
@metricUnit = @cfg.value("metricUnit",Qt::Variant.new(true)).toBool
|
101
118
|
@zoom = @cfg.value("zoom",Qt::Variant.new(13)).toInt
|
102
|
-
@lat = @cfg.value("lat",Qt::Variant.new(LATSTARTUP)).toDouble
|
103
|
-
@lon = @cfg.value("lon",Qt::Variant.new(LONSTARTUP)).toDouble
|
119
|
+
@lat = @cfg.value("lat",Qt::Variant.new(LATSTARTUP.to_s)).toDouble
|
120
|
+
@lon = @cfg.value("lon",Qt::Variant.new(LONSTARTUP.to_s)).toDouble
|
104
121
|
@w.cBrw.setChecked(@cfg.value("rwChecked",Qt::Variant.new(false)).toBool)
|
105
122
|
@w.cBndb.setChecked(@cfg.value("nbdChecked",Qt::Variant.new(false)).toBool)
|
106
123
|
@w.cBvor.setChecked(@cfg.value("vorChecked",Qt::Variant.new(true)).toBool)
|
107
|
-
@opacity = @cfg.value("opacity",Qt::Variant.new(1.0)).toFloat
|
124
|
+
@opacity = @cfg.value("opacity",Qt::Variant.new((1.0).to_s)).toFloat
|
108
125
|
|
109
126
|
@flag=Qt::Pixmap.new(":/icons/flag-blue.png")
|
110
127
|
@pin=Qt::Pixmap.new(":/icons/wpttemp-red.png")
|
@@ -204,8 +221,8 @@ class MainDlg < Qt::Widget
|
|
204
221
|
r=@fs_ans.reverse.detect do |f|
|
205
222
|
f.include?(path)
|
206
223
|
end
|
207
|
-
r =~
|
208
|
-
return
|
224
|
+
r =~ /'(-?\d+\.\d+)' \(double\)/
|
225
|
+
return $1.to_f
|
209
226
|
end
|
210
227
|
|
211
228
|
def putflag(x,y,i,node)
|
@@ -244,31 +261,36 @@ class MainDlg < Qt::Widget
|
|
244
261
|
end
|
245
262
|
|
246
263
|
ap "generating xml-doc"
|
247
|
-
doc =
|
248
|
-
doc
|
249
|
-
|
250
|
-
doc.
|
251
|
-
|
252
|
-
doc
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
264
|
+
doc = REXML::Document.new
|
265
|
+
doc << REXML::XMLDecl.new(REXML::XMLDecl::DEFAULT_VERSION, REXML::XMLDecl::DEFAULT_ENCODING)
|
266
|
+
|
267
|
+
doc.add_element('gpx')
|
268
|
+
|
269
|
+
node=REXML::XPath.first(doc, "//gpx")
|
270
|
+
node.add_namespace("http://www.topografix.com/GPX/1/1")
|
271
|
+
node.add_attributes({'creator'=>"ruby-tracker", "version"=>"1.1"} )
|
272
|
+
node.add_namespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")
|
273
|
+
|
274
|
+
tracknode = REXML::Element.new("trk")
|
275
|
+
node.add_element(tracknode)
|
257
276
|
items.each{|track|
|
258
|
-
segnode =
|
259
|
-
tracknode
|
277
|
+
segnode = REXML::Element.new("trkseg")
|
278
|
+
tracknode.add_element(segnode)
|
260
279
|
track.nodes.each{|n|
|
261
|
-
trackpoint =
|
262
|
-
trackpoint
|
263
|
-
trackpoint
|
264
|
-
trackpoint
|
265
|
-
trackpoint
|
266
|
-
|
267
|
-
segnode << trackpoint
|
280
|
+
trackpoint = REXML::Element.new("trkpt")
|
281
|
+
trackpoint.add_attributes({"lat" => n.lat.to_s.gsub(",","."), "lon" => n.lon.to_s.gsub(",",".")})
|
282
|
+
trackpoint.add_text_element("ele", n.elevation.to_s.gsub(",","."))
|
283
|
+
trackpoint.add_text_element("time", n.toGPStime)
|
284
|
+
trackpoint.add_text_element("time_us", n.timestamp.usec.to_s)
|
285
|
+
segnode.add_element(trackpoint)
|
268
286
|
}
|
269
287
|
}
|
270
288
|
File.open($MAPSHOME + "/tracks/" + items.first.nodes.first.toGPStime + ".gpx", "w+"){|f|
|
271
|
-
|
289
|
+
begin
|
290
|
+
doc.write(f, 2)
|
291
|
+
rescue Errno::EISDIR
|
292
|
+
Qt::MessageBox::warning(nil, "Warning", "You selected a directory, not a file. Nothing saved.")
|
293
|
+
end
|
272
294
|
}
|
273
295
|
ap "xml-file written"
|
274
296
|
end
|
@@ -278,31 +300,35 @@ class MainDlg < Qt::Widget
|
|
278
300
|
fn=Qt::FileDialog::getOpenFileName(nil, title, $MAPSHOME + "/tracks/", "Track-Data (*.gpx *.log);;All (*)")
|
279
301
|
if !fn.nil? then
|
280
302
|
success = false
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
@mytracks[@mytrack_current]
|
290
|
-
|
303
|
+
file=File.new(fn)
|
304
|
+
begin
|
305
|
+
doc = REXML::Document.new(file)
|
306
|
+
|
307
|
+
doc.elements.each("/gpx/trk") do |trk|
|
308
|
+
@mytrack_current -= 1
|
309
|
+
trk.elements.each("trkseg") do |seg|
|
310
|
+
@mytrack_current += 1
|
311
|
+
if @mytracks[@mytrack_current].nil? then
|
312
|
+
@mytracks[@mytrack_current] = Way.new(1, 'user', Time.now, nextcolor)
|
313
|
+
@prev_track_node = nil
|
314
|
+
end
|
315
|
+
track=@mytracks[@mytrack_current]
|
316
|
+
track.nodes.clear
|
317
|
+
seg.elements.each("trkpt") do |tpt|
|
318
|
+
usec = tpt.elements["time_us"].text.strip
|
319
|
+
usec = (usec.nil? ? "0" : usec)
|
320
|
+
loc = tpt.attributes # lon and lat as a hash
|
321
|
+
track << Node.new(nil, tpt.elements["time"].text.strip + usec, \
|
322
|
+
loc["lon"].to_f, loc["lat"].to_f, \
|
323
|
+
tpt.elements["ele"].text.to_f)
|
324
|
+
success = true
|
325
|
+
end
|
291
326
|
end
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
seg.find("ns:trkpt", "ns:http://www.topografix.com/GPX/1/1").each{|tpt|
|
298
|
-
usec = tpt.find_first(xpat_time_us)
|
299
|
-
usec = (usec.nil? ? "0" : usec.content)
|
300
|
-
track << Node.new(nil, tpt.find_first(xpat_time).content + usec, \
|
301
|
-
tpt["lon"].to_f, tpt["lat"].to_f, tpt.find_first(xpat_elevation).content.to_f)
|
302
|
-
success = true
|
303
|
-
}
|
304
|
-
}
|
305
|
-
}
|
327
|
+
end
|
328
|
+
rescue Errno::EISDIR
|
329
|
+
# swallow error, "success" is false anyway
|
330
|
+
end
|
331
|
+
|
306
332
|
if success then
|
307
333
|
movemap(@node, true)
|
308
334
|
else
|
@@ -316,23 +342,28 @@ class MainDlg < Qt::Widget
|
|
316
342
|
fn=Qt::FileDialog::getOpenFileName(nil, title, $MAPSHOME + "/waypoints/", "Waypoint-Data (*.gpx *.log);;All (*)")
|
317
343
|
if !fn.nil? then
|
318
344
|
success = false
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
345
|
+
file=File.new(fn)
|
346
|
+
begin
|
347
|
+
doc = REXML::Document.new(file)
|
348
|
+
@waypoints = Way.new(nil,'user', Time.now, "Blue")
|
349
|
+
doc.elements.each("/gpx/wpt") do |wpt|
|
350
|
+
loc = wpt.attributes # lon and lat as a hash
|
351
|
+
@waypoints << Node.new(nil, wpt.elements["time"].text.strip,
|
352
|
+
loc["lon"].to_f, loc["lat"].to_f, \
|
353
|
+
wpt.elements["ele"].text.to_f)
|
354
|
+
success = true
|
355
|
+
end
|
356
|
+
file.close
|
357
|
+
if success then
|
358
|
+
movemap(@node, true)
|
359
|
+
else
|
360
|
+
Qt::MessageBox::warning(nil, "Warning", "No data found in file.")
|
361
|
+
end
|
362
|
+
return success
|
363
|
+
rescue Errno::EISDIR
|
364
|
+
Qt::MessageBox::warning(nil, "Warning", "You selected a directory, not a file. Nothing loaded.")
|
365
|
+
return success
|
334
366
|
end
|
335
|
-
return success
|
336
367
|
end
|
337
368
|
end
|
338
369
|
|
@@ -346,32 +377,36 @@ class MainDlg < Qt::Widget
|
|
346
377
|
# just swallow error
|
347
378
|
end
|
348
379
|
|
349
|
-
doc =
|
350
|
-
doc
|
351
|
-
|
352
|
-
doc.
|
353
|
-
|
354
|
-
|
355
|
-
|
380
|
+
doc = REXML::Document.new
|
381
|
+
doc << REXML::XMLDecl.new(REXML::XMLDecl::DEFAULT_VERSION, REXML::XMLDecl::DEFAULT_ENCODING)
|
382
|
+
|
383
|
+
doc.add_element('gpx')
|
384
|
+
root=REXML::XPath.first(doc, "//gpx")
|
385
|
+
root.add_namespace("http://www.topografix.com/GPX/1/1")
|
386
|
+
root.add_attributes({'creator'=>"ruby-tracker", "version"=>"1.1"} )
|
387
|
+
root.add_namespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")
|
356
388
|
|
357
389
|
waypoints[0].nodes.each{|n|
|
358
390
|
if !n.nil? then
|
359
|
-
wpnode =
|
360
|
-
|
361
|
-
wpnode
|
362
|
-
wpnode
|
363
|
-
wpnode
|
364
|
-
wpnode << XML::Node.new("time", n.toGPStime)
|
391
|
+
wpnode = REXML::Element.new("wpt")
|
392
|
+
root.add_element(wpnode)
|
393
|
+
wpnode.add_attributes({"lat" => n.lat.to_s.gsub(",","."), "lon" => n.lon.to_s.gsub(",",".")})
|
394
|
+
wpnode.add_text_element("ele", n.elevation.to_s.gsub(",","."))
|
395
|
+
wpnode.add_text_element("time", n.toGPStime)
|
365
396
|
end
|
366
397
|
}
|
367
|
-
fn=Qt::FileDialog::getSaveFileName(nil, "Save Waypoint File", $MAPSHOME + "/waypoints/", "Waypoint-Data (*.gpx *.log);;All (*)","*.gpx")
|
368
398
|
|
399
|
+
fn=Qt::FileDialog::getSaveFileName(nil, "Save Waypoint File", $MAPSHOME + "/waypoints/", "Waypoint-Data (*.gpx *.log);;All (*)","*.gpx")
|
369
400
|
if !fn.nil? then
|
370
401
|
if fn !~ /\.gpx$/ then
|
371
402
|
fn += ".gpx"
|
372
403
|
end
|
373
404
|
File.open(fn, "w+"){|f|
|
374
|
-
|
405
|
+
begin
|
406
|
+
doc.write(f, 2)
|
407
|
+
rescue Errno::EISDIR
|
408
|
+
Qt::MessageBox::warning(nil, "Warning", "You selected a directory, not a file. Nothing saved.")
|
409
|
+
end
|
375
410
|
}
|
376
411
|
end
|
377
412
|
end
|
@@ -427,10 +462,10 @@ class MainDlg < Qt::Widget
|
|
427
462
|
# we can not add the tiles to the scene within this thread directly. It crosses thread
|
428
463
|
# bounderies which crashes QT badly
|
429
464
|
@tilesToAddMutex.synchronize {
|
430
|
-
@tilesToAdd << [f, (x - origin_x)*256, (y - origin_y)*256, OPENSTREETMAP_TILE]
|
465
|
+
@tilesToAdd << [f+".png", (x - origin_x)*256, (y - origin_y)*256, OPENSTREETMAP_TILE]
|
431
466
|
}
|
432
467
|
else # add immediately, we are not in a different thread
|
433
|
-
pmi=Qt::GraphicsPixmapItem.new(Qt::Pixmap.new(f), @openstreetmapLayer)
|
468
|
+
pmi=Qt::GraphicsPixmapItem.new(Qt::Pixmap.new(f+".png"), @openstreetmapLayer)
|
434
469
|
pmi.setOffset((x - origin_x)*256, (y - origin_y)*256)
|
435
470
|
end
|
436
471
|
|
@@ -458,12 +493,12 @@ class MainDlg < Qt::Widget
|
|
458
493
|
filename =~ /\/\d+\/\d+\/\d+$/
|
459
494
|
fn = $&
|
460
495
|
begin
|
461
|
-
resp, data = h.
|
496
|
+
resp, data = h.request_get("/~cmarqu/hill" + fn + ".png", nil)
|
462
497
|
if resp.kind_of?(Net::HTTPOK) then
|
463
498
|
# check here again as in the meantime another thread might already have added the tile
|
464
499
|
if !FileTest.exist?($MAPSHOME + fn + "-elevation.png") then
|
465
500
|
File.open($MAPSHOME + fn + "-elevation.png", "w") do |file|
|
466
|
-
file.
|
501
|
+
file.syswrite(data)
|
467
502
|
end
|
468
503
|
@tilesToAddMutex.synchronize {
|
469
504
|
@tilesToAdd << [$MAPSHOME + fn + "-elevation.png", (x - origin_x)*256, (y - origin_y)*256, ELEVATION_TILE]
|
@@ -610,7 +645,7 @@ class MainDlg < Qt::Widget
|
|
610
645
|
filename =~ /\/\d+\/\d+\/\d+$/
|
611
646
|
fn = $&
|
612
647
|
begin
|
613
|
-
resp, data = h.
|
648
|
+
resp, data = h.request_get(fn + ".png", nil)
|
614
649
|
if resp.kind_of?(Net::HTTPOK) then
|
615
650
|
maindir = Dir.pwd
|
616
651
|
Dir.chdir($MAPSHOME)
|
@@ -626,7 +661,7 @@ class MainDlg < Qt::Widget
|
|
626
661
|
end
|
627
662
|
Dir.chdir(maindir)
|
628
663
|
File.open($MAPSHOME + fn + ".png", "w") do |file|
|
629
|
-
file.
|
664
|
+
file.syswrite(data)
|
630
665
|
end
|
631
666
|
# we call from within a thread, signal this to the subroutine
|
632
667
|
addTileToScene($MAPSHOME + fn, origin_x, origin_y, true)
|
@@ -759,10 +794,10 @@ class MainDlg < Qt::Widget
|
|
759
794
|
@fs_queries.each do |q|
|
760
795
|
@fs_socket.print("get " + q + "\r\n")
|
761
796
|
s=""
|
762
|
-
while select([@fs_socket], nil, nil, 0.
|
797
|
+
while select([@fs_socket], nil, nil, 0.8) do
|
763
798
|
s += @fs_socket.read(1)
|
764
799
|
# check for end of line characterized by this string: "\r\n/>"
|
765
|
-
|
800
|
+
break if s[-4..-1] == "\r\n/>" and s.include?(q)
|
766
801
|
end
|
767
802
|
if s.include?(q) then
|
768
803
|
@fs_ans << s.split("\n")
|
@@ -1213,97 +1248,6 @@ class TileGraphicsItemGroup < Qt::GraphicsItemGroup
|
|
1213
1248
|
|
1214
1249
|
end # case
|
1215
1250
|
end
|
1216
|
-
|
1217
|
-
def contextMenuEvent(contextEvent)
|
1218
|
-
dlg=contextEvent.widget.parent.parent
|
1219
|
-
entries=["Set Waypoint", "Delete Waypoint", "Waypoints to Route-Mgr", "Set Origin", "-", "Save Waypoints", "Save Track", "Load Waypoints",
|
1220
|
-
"Load Track", ["Metric Units", dlg.metricUnit]]
|
1221
|
-
menu=Qt::Menu.new
|
1222
|
-
entries.each{|e|
|
1223
|
-
if e.kind_of? Array then
|
1224
|
-
action = Qt::Action.new(e[0], nil)
|
1225
|
-
action.setCheckable(true)
|
1226
|
-
action.setChecked(e[1])
|
1227
|
-
menu.addAction(action)
|
1228
|
-
else
|
1229
|
-
if e=="-" then
|
1230
|
-
menu.addSeparator
|
1231
|
-
else
|
1232
|
-
action = Qt::Action.new(e, nil)
|
1233
|
-
if e =~ /(Delete Waypoint|Waypoints to)/ then
|
1234
|
-
action.setEnabled(false) if dlg.waypoints.nodes.empty?
|
1235
|
-
end
|
1236
|
-
menu.addAction(action)
|
1237
|
-
end
|
1238
|
-
end
|
1239
|
-
}
|
1240
|
-
sel=menu.exec(contextEvent.screenPos)
|
1241
|
-
sel=sel.text if !sel.nil?
|
1242
|
-
lon=dlg.node.tolon(dlg.node.xtile + contextEvent.scenePos.x / 256.0)
|
1243
|
-
lat=dlg.node.tolat(dlg.node.ytile + contextEvent.scenePos.y / 256.0)
|
1244
|
-
case sel
|
1245
|
-
when entries[0]
|
1246
|
-
i=dlg.waypoints << Node.new(nil, Time.now, lon, lat)
|
1247
|
-
dlg.putflag(contextEvent.scenePos.x, contextEvent.scenePos.y, i, dlg.waypoints.nodes.last)
|
1248
|
-
if i==1 and dlg.waypoints.nodes.length == 1 then
|
1249
|
-
dlg.w.lBcurrentwp.text="1"
|
1250
|
-
dlg.waypoints.currentwp=1
|
1251
|
-
end
|
1252
|
-
|
1253
|
-
when entries[1]
|
1254
|
-
d=dlg.waypoints.del(lon,lat)
|
1255
|
-
if dlg.w.lBcurrentwp.text.to_i == d then
|
1256
|
-
dlg.w.lBcurrentwp.text="-"
|
1257
|
-
end
|
1258
|
-
dlg.movemap(dlg.node, true)
|
1259
|
-
|
1260
|
-
when entries[2]
|
1261
|
-
Thread.new {
|
1262
|
-
dlg.waypoints.nodes.each do |n|
|
1263
|
-
dlg.writeFlightsim("set /autopilot/route-manager/input @INSERT-1:#{n.lon.to_s.gsub(",",".")},#{n.lat.to_s.gsub(",",".")}")
|
1264
|
-
end
|
1265
|
-
}
|
1266
|
-
|
1267
|
-
|
1268
|
-
when entries[3]
|
1269
|
-
dlg.node = Node.new(1, Time.now, lon, lat)
|
1270
|
-
dlg.offset_x = 0
|
1271
|
-
dlg.offset_y = 0
|
1272
|
-
dlg.movemap(dlg.node, true)
|
1273
|
-
|
1274
|
-
when entries[5]
|
1275
|
-
dlg.saveWaypoints([dlg.waypoints])
|
1276
|
-
|
1277
|
-
when entries[6]
|
1278
|
-
dlg.savetrack(dlg.mytracks)
|
1279
|
-
|
1280
|
-
when entries[7]
|
1281
|
-
savecurrent = dlg.waypoints.currentwp
|
1282
|
-
if dlg.loadwaypoint("Load Waypoints") then
|
1283
|
-
dlg.waypoints.currentwp = nil
|
1284
|
-
else
|
1285
|
-
dlg.waypoints.currentwp = savecurrent
|
1286
|
-
end
|
1287
|
-
|
1288
|
-
when entries[8]
|
1289
|
-
dlg.mytrack_current += (dlg.w.pBrecordTrack.isChecked ? 0 : 1)
|
1290
|
-
savewp=dlg.mytracks[dlg.mytrack_current]
|
1291
|
-
if dlg.mytracks[dlg.mytrack_current].nil? then
|
1292
|
-
dlg.mytracks[dlg.mytrack_current] = Way.new(1, 'user', Time.now, dlg.nextcolor)
|
1293
|
-
@prev_track_node = nil
|
1294
|
-
end
|
1295
|
-
if dlg.loadtrack("Load Track") then
|
1296
|
-
dlg.w.pBrecordTrack.text = "Record Track #{dlg.mytrack_current + 2}"
|
1297
|
-
dlg.w.pBrecordTrack.setChecked(false)
|
1298
|
-
else
|
1299
|
-
dlg.mytracks[dlg.mytrack_current]=savewp
|
1300
|
-
end
|
1301
|
-
|
1302
|
-
when entries[9][0]
|
1303
|
-
dlg.metricUnit = !dlg.metricUnit
|
1304
|
-
|
1305
|
-
end #case
|
1306
|
-
end
|
1307
1251
|
end
|
1308
1252
|
|
1309
1253
|
|