Canvas Maps: Difference between revisions

Jump to navigation Jump to search
3,088 bytes removed ,  21 October 2017
m
→‎Background: remove outdated stuff
(Deleted the broken Gitorious link to https://gitorious.org/fg/toms-fgdata?p=fg:toms-fgdata.git;a=commit;h=9a40c82bc06c33fb59b95188ea000d69e760b75a, as this specific commit does not exist in the archived repository.)
m (→‎Background: remove outdated stuff)
Line 5: Line 5:
* '''Hooray''': " It would be great to have 2-3 "real" applications, so that the canvas/map API becomes more powerful."
* '''Hooray''': " It would be great to have 2-3 "real" applications, so that the canvas/map API becomes more powerful."
* '''TheTom''': "vertical projection seems not too complicated as its basically just calculating segment lenghts on a sphere, or maybe just direct distance calculations. I think the error in comparison to the real sphere can be neglected while using typical distances (eg. at a distance of 300 miles the error is about 2.8 miles, which is ~0.9%)." {{Pending}} (see [[Canvas Maps]])
* '''TheTom''': "vertical projection seems not too complicated as its basically just calculating segment lenghts on a sphere, or maybe just direct distance calculations. I think the error in comparison to the real sphere can be neglected while using typical distances (eg. at a distance of 300 miles the error is about 2.8 miles, which is ~0.9%)." {{Pending}} (see [[Canvas Maps]])
== Background ==
One of the most common 2D drawing needs in a flight simulator is related to charting and mapping of geographic coordinates (latitude,longitude,altitude) to 2D screen coordinates (x,y). This is a shared requirement for navigational displays, MFDs and also GUI charts/maps. That's the reason why the Canvas system supports a dedicated mapping mode which automatically converts geographic coordinates (lat/lon/alt) to screen coordinates using two different mapping modes (horizontal/vertical (n/a as of 07/2013).
This makes it extremely simple to create new fully interactive navigational displays and mapping dialogs.
There's now a first proof of concept available which replicates part of the built-in, hard-coded, [[Map]] dialog:
[[File:Demonstration of using the Canvas inside a GUI dialog..png|thumb|none|600px|Simple Map of KSFO]]
Using the Canvas system, it has now become trivial to create new map layers of symbols with geographic positions which are transparently mapped to screen coordinates by the canvas system automatically.
To illustrate just how powerful this new feature is, take a look at the following foreach loop which places all the parking positions in the shown map dialog.
<syntaxhighlight lang="nasal">
193  foreach(var park; me._apt.parking())
194  {
195 var icon_park = me.grp_apt.createChild("text");
196 icon_park.setDrawMode(9);
197 icon_park.setText(park.name);
198 icon_park.setFont("LiberationFonts/LiberationMono-Bold.ttf");
199 icon_park.setGeoPosition(park.lat, park.lon);
200 icon_park.setSize(15, 1.3);
201  }
</syntaxhighlight>
As can be seen in line 199, the canvas system directly uses geographic coordinates, so there's no explicit conversion to screen coordinates or other projection handling required. In other words: what you get from the Nasal DB, can be directly used here.
This feature is based on the ARINC661 standard, which handles this very elegantly: the A661 CDS (display) is really just sent geographic positions of objects, associated image information and it will automatically turn this into a horizontal or vertical map using the proper projection mode.
Basically, this means that users of the mfd/canvas module only ever need to know a handful of things (position, symbol, mapping mode) and they can get started right away.
And the really nice thing is that this abstraction wrapper can be reused for all related things: navdisplay, wxradar, tcas, fixes, airports etc.
Thus, the Nasal code to handle these display modes can be really short and elegant, especially compared to all the C++ code that we have currently for the same purpose!
A more recent example can be seen in the new "Airport Selection" dialog:
[[File:Airport-selection-dialog.png|600px|The new Airport Selection dialog with Canvas display of the airport]]
This is implemented in [[$FG_ROOT]]/gui/dialogs/airports.xml:  {{fgdata file|gui/dialogs/airports.xml}}.
The Nasal "driver" can be found in [[$FG_ROOT]]/Nasal/canvas/map.nas: {{fgdata file|Nasal/canvas/map.nas}}.
Also see: [[Talk:ATC-FS]] and particularly [[MapStructure]]


== Shared Requirements (MFDs and GUI maps) ==
== Shared Requirements (MFDs and GUI maps) ==

Navigation menu