Atlas Map MSVC6 Build

FG Index -|- ATLAS Index -|- End

What to do next? Assuming you have 'flown' around in FlightGear, tried a few aircraft, downloaded some additional scenery, you have some choices ... continuing the build using Microsoft Visual C/C++, Version 6, (MSVC6) ...

Atlas [ ] - A moving map ... see where you are flying ... FlightGear's position can be dispatched in 'packets', and Atlas will display the aircraft position on the current terrain...

Atlas Build using MSVC6 below, but be warned as of about early 2008, SimGear no longer builds with this MSVC version. Atlas Build using MSVC7, or with MSVC8

Atlas Build using MSVC6 

Atlas - A 'moving' map, while you are flying FlightGear ... the Map.exe component 'generates' a map images, default map.png, in your FG-ROOT\Atlas folder, of the information from your FlightGear data folder (FG_ROOT) ...

Below is a 2 step batch file to download Atlas ... on examining the source, you should note  the atlas.sln, and the 3 project files, atlas\atlas.vcproj, map\Map.vcproj, and mapps\MapPS.vcproj files. These are the MSVC7's 'build' files ... if you have ever tried to 'understand' your MSVC6 DSW/DSP files, then you will 'recognise' lots of things ... like 'Name="Source Files"' entries, etc ... 

Just start a new Project tab, selecting 'Win32 Console Application' ... Some care needs to be taken with the 'Project Name:' ... those familiar with MSVC6 'know' the IDE will create a Path out of the name you use, and this is not ideal in all cases ... so when you 'create' the first project, ensure it is in Altas\atlas path ... OK ... check 'An Empty Project:' ... Finish, and Ok ...

In the FileView tab, expand the Atlas Files ... and right click on 'Source Files', and choose 'Add Files to Folder' ... back out of the 'Atlas' folder, and into the 'src' folder, and select the list per atlas.vcproj file ... The current list is -
"Atlas.cxx" "FlightTrack.cxx" "LoadPng.cxx" "MapBrowser.cxx" "MapMaker.cxx" "Output.cxx" "OutputGL.cxx" "Overlays.cxx" "Projection.cxx"
- just copy the above 'formatted' list to the clipboard, and paste it into the Open Dialog ...

Select menu, Project Setting ..., select the 'Atlas' project, on the C/C++ tab, do at least the following category checks :-
(a) Code Generation - I have chosen 'Debug Multithreaded' for Debug configuration, and 'Multithreaded' for 'Release' configuration ... Just be completely CONSISTENT will all static libraries ...
(b) Precompiled Headers - Select 'All Configuration', and select 'Not using Precompiled Headers' ... This was a 'good' idea when compilers, and disk io was dreadfully SLOW ... today, I like to push the disk io memory caching of XP, and watch the compiler 'fly' through the sources ...
(c) Pre-processor Definitions and 'Additional include directories:' -
A quick scan through the atlas.vcproj files shows some 'interesting' proprocessor definitions, like -
PreprocessorDefinitions="WIN32,NDEBUG,_CONSOLE, ... these are standards, but -
could be added, changing it to suit your structure -
In my particular case, groot is 'C:\\FG098' ... Also note the escaping of the '\' character ...

Jumping ahead to the Link stage, I also note the additional library line of -
AdditionalDependencies="wsock32.lib pui-nd.lib ul-nd.lib fnt-nd.lib net-nd.lib SimGear-nd.lib libpng.lib"
My PLIB libraries use '_d'. my SimGear is just that ... so the above line becomes ...
"wsock32.lib pui_d.lib ul_d.lib fnt_d.lib net_d.lib SimGear.lib libpng.lib"
added under the Project, Settings, Link tab ... will deal with Addition Paths later ...

I also 'know', because I have done this before, may times, ;=)) to have downloaded, and compiled fltk-1.1.6, which has a 'libpng.lib' ... actually the set of fltk Debug static libraries are - fltkd.lib, fltkgld.lib, fltkjpegd.lib, fltkpngd.lib ... so the above 'list' will need adjustment, but for the moment, continue with the compile ...

Try my first compile ... F7 (Build) ... and quickly stops on the line, in projection.hxx, of -
#include <plib/sg.h>
This indicates the include path to PLIB is missing ... Since this file is in Atlas\src, the relative path to my PLIB is '..\..', so I add that 'Additional Path' ...

I quickly come to what can be for me, a show stopper ... that is I have not yet 'found' a 'good' work around ... and have to choose a very 'sloppy' 'MSVC6 fix' ... and this is use 'enum', under a MSVC6 label, which I place in the Preprocessor defines ... the next is a 'missing' ...
#include <simgear/io/sg_socket.hxx>
and I add '..\..\Simgear\source' to Additional Include paths ... F7, onwards ...

Line -
static const int OVERLAY_AIRPORTS = 1 << 0;
causes MSVC6 to 'cough' error C2258: illegal pure syntax, must be '= 0', so I decide to convert them all to 'functions', like :-
#ifdef MSVC6
int OVERLAY_AIRPORTS() { return( 1 << 0 ); }
int OVERLAY_NAVAIDS() { return( 1 << 1 ); }
... etc ...
This will probably 'cost' some more effort later ... F7, onwards ... the next -
error C2653: 'list<struct FlightData *,class std::allocator... is simple to 'modify' ... the line -
list<FlightData*>::iterator track_pos;
typedef list<FlightData*> lFDp;
lFDp::iterator track_pos;
for (list<FlightData*>::iterator i = track.begin(); i != track.end(); i++) {
becomes ...
typedef list<FlightData*> lFDp;
FlightTrack::~FlightTrack() {
for (lFDp::iterator i = track.begin(); i != track.end(); i++) {

The 'missing' png.h shows up ... As mentioned I have already downloaded and compiled fltk-1.1.6, so I can just add the relative path '..\..\fltk-1.1.6\png' to the Additional Include paths ...

Next 'missing' item is -
#include "zlib.h"
which is, luckily, included in simgear, so add '..\..\Simgear\source\src-libs\zlib-1.1.4' path ...

Again, a little 'modification' to accommodate the compile ... this time it is -
#ifdef MSVC6
inline int getShade() { return features & DO_SHADE(); }
inline int getAirports() { return features & DO_AIRPORTS(); }
... etc, until
#else // #ifdef MSVC6
inline bool getShade() { return features & DO_SHADE; }
inline bool getAirports() { return features & DO_AIRPORTS; }

I can see this is going to 'cost' some effort ... is it worth it? Yes ... so I build a macro to add my MSVC6 switch, easily, and efficiently ... just cut, and paste the following to your mymacros file -

Function GetCompSwitch2( sBlk )
Dim sNBlk
Dim iLen
sNBlk = ""
iLen = Len(sBlk)
If (iLen > 0) Then
sNBlk = "#ifdef MSVC6" + vbCrLf
sNBlk = sNBlk + sBlk
sNBlk = sNBlk + "#else // !#ifdef MSVC6" + vbCrLf
sNBlk = sNBlk + sBlk
sNBlk = sNBlk + "#endif // #ifdef MSVC6 y/n" + vbCrLf
End If
GetCompSwitch2 = sNBlk
End Function

Sub AddCompSwitch()
'DESCRIPTION: Convert selected to two lines
Dim sBlk, sNBlk
sBlk = ActiveDocument.Selection
' sNBlk = GetCompSwitch(sBlk)
sNBlk = GetCompSwitch2(sBlk)
If (Len(sNBlk) > 0) Then
ActiveDocument.Selection = sNBlk
End If
End Sub

This allows you to select the 'troublesome' line, or lines, and 'encase' it all in a compiler 'switch' code ... then you modify the first version, until MSVC6 trundles on ...

This is the final Debug configuration, 'Preprocessor definitions:' -

This is the final 'Additional include directories:' -

The 'Object/library modules: -
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib pui_d.lib sg_d.lib ul_d.lib fnt_d.lib net_d.lib SimGear.lib fltkpngd.lib zlib.lib 

and the important 'Additional library path:' -

This 'combination' get my MSVC6 Atlas to compile, and link ... quite a few 'warnings' have been ignored ...

The next step is the Map project. Again, in this source, you can find a Map\Map.vcproj file, and this will give you  the list of 'source' files, but if you are going to get into cross platform, open source, projects, then you really will do yourself a favour by reading, and understanding, to some degree, the ever present files ... If you load src/, and scan around a bit, you will find, the like of -

Map.cxx \
FlightTrack.hxx FlightTrack.cxx \
MapMaker.cxx MapMaker.hxx \
Output.cxx Output.hxx \
OutputGL.cxx OutputGL.hxx \
Overlays.cxx Overlays.hxx \
Projection.cxx Projection.hxx

Map_LDADD = \
-lsgmagvar -lsgtiming -lsgmisc -lsgio -lsgdebug \
-lplibsg -lplibpu -lplibul -lplibfnt -lsgbucket \
$(opengl_LIBS) \
-lpng -lz

From this  you get the 'source' list, in MSVC6 cut & paste format, of -
"Map.cxx" "FlightTrack.cxx" "MapMaker.cxx" "Output.cxx" "OutputGL.cxx" "Overlays.cxx" "Projection.cxx"

Your can initially 'ignore' the header file, the .hxx. As you get to know MSVC6, you will see 'it' prefers header files to be put under their own pseudo folder 'Header files...' ... Actually, it does not make any difference. When you complete a project ... that is get through to the completed link, without error, then the IDE does a full 'dependancy' update, and put just about 'every' header, included anywhere in the source, in the pseudo-folder, 'External Dependancies' ...

And, depending on our mood, it might be the time to also create the third project, in this atals workspace ... again, the provides the 'source' list ...
"MapPS.cxx" "FlightTrack.cxx" "MapMaker.cxx" "Output.cxx" "OutputPS.cxx" "Overlays.cxx" "Projection.cxx"

When you elect menu, Project Setting ..., you can now 'configure' the 3 projects, similarly, on the C/C++ tab, do at least the following category checks :-
(a) Code Generation - Debug = 'Debug Multithreaded' Release =  'Multithreaded' ... be CONSISTENT ...
(b) Precompiled Headers - Select 'All Configuration', and select 'Not using Precompiled Headers' ...
(c) Pre-processor Definitions and 'Additional include directories:' - should be a 'simple' matter of cut, and paste ...

Now that the Debug compile, and link, have completed, it may be time to do the Release version ... again it is easy to cut and paste from project to project ... then select menu, Batch Build, check all projects, and click Re-Build All ... In this case, I was unable to get the Release version linked, but in 'tools' like this, the Debug version will do ....

Sometimes, at this stage I go back and 'quieten' some the compiler warnings. The default is warning level 3 (-W3), so one way is to lower the 'warning' level ... One pesky one is warning: C4786 : '...big block..' : debug truncated label to 256 - Oftem I will just drop the following code into, in this case Overlays.hxx ...

#ifdef MSVC6
#pragma warning( disable:4786 ) // debug truncation to 256
#endif // #ifdef MSVC6

Running Map/MapPS and Atlas:

Of course you can just set a project active, select the configuration desired, in this case the Debug version, and press F5 ... but it is usually worth reading a little of the available documentation first ... or, 'cheat', like me, and 'read' the source ...

From Map.cxx, we have a great HELP script -
void print_help() {
printf("MAP - FlightGear mapping utility\n\n");
printf(" --lat=xx.xx Start at latitude xx.xx (deg., south is neg.)\n");
printf(" --lon=xx.xx Start at longitude xx.xx (deg., west is neg.)\n");
printf(" --size=pixels Create map of size pixels*pixels (default 256)\n");
printf(" --scale=x Kilometers from top to bottom of map (default 100)\n"); 
printf(" --autoscale Automatically set scale to 1x1 degree tile\n");
printf(" --light=x, y, z Set light vector for shading\n");
printf(" --airport-filter=string Display only airports with id beginning 'string'\n");
printf(" --output=name Write output to given file name (default 'map.png')\n");
printf(" --fg-root=path Overrides FG_ROOT environment variable\n");
printf(" --fg-scenery=path Overrides FG_SCENERY environment variable\n");
printf(" --enable-airports Show airports\n");
printf(" --enable-navaids Show navaids\n");
printf(" --flat-shading Don't do nice shading of the terrain\n");
printf(" --atlas=path Create maps of all scenery, and store them in path\n");
printf(" --verbose Display information during processing\n");
printf(" --singlebuffer Use single buffered display\n");
printf(" --glutfonts Use GLUT built-in fonts\n");
printf(" --palette=path Set the palette file to use\n");
printf(" --smooth-color Make smooth color heights\n");

Really, what more HELP do you need ... Of course, if you have ONLY downloaded, the 'core' FlightGear data, then your choices here are quite limited. I have downloaded several of the many Australia 'slabs', so I want to choose around Sydney, which I 'know' is in 'chunk' (10x10 deg) e150s40, so what lat, lon should I give this 'mapper'? It says, start at, and assume it will progress up, and to the right ... that is, the reference is the lower left 'corner' ... let's try ... I later 'see' Map uses the top-right!

So I construct my command line -
--lon=150.0 --lat=-34.0 --fg-root=C:\FG098\FlightGear\data --fg-scenery=C:\FG098\FlightGear\data --enable-airports
and copy it to Project, Settings, Debug tab, Program arguments ... Ok, and F5 ... it trundles for about a minute, and exits ... what happened ... as you know, unfortunately the command window, containing the cout, disappears when the application exits, but I had seen 'nothing' appear for the time I watched it ... I later 'see' the verbose option ...

Ok, look into 'what happened' ... In Map.cxx, in 'main', is the line -
glutDisplayFunc( redrawMap );
Because glut is an event, message, driven system, then you need to 'trap' in the 'redrawMap' function .. to see what gives ... or you could probably read the good documentation provided by the author ... each to their own, 'fastest' method ... ;=))

In trapping, and tracing for a while, I realise the default 'verbosity' is 'nothing', and that is why I am not seeing anything in the console window ... so I add --verbose to the command, to be able to 'see' a little more of what is happening, or not, as the case may be ... I hadd been tracing through so directory/file processing, so I drop a break there, so I can come back immediately to here ... but hopefully with more output in the console window ...

But, in this case, this not help a lot ... I got 100's of output of the form -
Warning: unknown material "DryCropPastureCover" encountered.
Need more information on what is happening ...

The text console output is done mainly using printf("..."), but watch for the occasional 'putc('\n', stdout);', and fprintf( stderr, "..."); as 'alternate' output 'styles' ... So I add a few messages in the file processing loop ... and to 'quieten' the current mutiple output, put in a string map_missed, and only put out missed material names once ... from this additional output, and reduction of common output, I can 'see' the processing ...

Processing: e140s40/e149s35: directory ...
File: C:\FG098\FlightGear\data/Scenery/Terrain/e140s40/e149s35/5393856.btg.gz ...
Warning: unknown material "DryCropPastureCover" encountered.
Warning: unknown material "EvergreenBroadCover" encountered.
File: C:\FG098\FlightGear\data/Scenery/Terrain/e140s40/e149s35/5393856.stg ...
Tile "C:\FG098\FlightGear\data/Scenery/Terrain/e140s40/e149s35/5393856.stg" is of unknown format.
File: C:\FG098\FlightGear\data/Scenery/Terrain/e140s40/e149s35/5393857.btg.gz ...
Warning: unknown material "SomeSort" encountered.
Warning: unknown material "GrassCover" encountered.
File: C:\FG098\FlightGear\data/Scenery/Terrain/e140s40/e149s35/5393857.stg ...
Tile "C:\FG098\FlightGear\data/Scenery/Terrain/e140s40/e149s35/5393857.stg" is of unknown format.
File: C:\FG098\FlightGear\data/Scenery/Terrain/e140s40/e149s35/5393858.btg.gz ...
Warning: unknown material "MixedForestCover" encountered.
File: C:\FG098\FlightGear\data/Scenery/Terrain/e140s40/e149s35/5393858.stg ...
Tile "C:\FG098\FlightGear\data/Scenery/Terrain/e140s40/e149s35/5393858.stg" is of unknown format.
File: C:\FG098\FlightGear\data/Scenery/Terrain/e140s40/e149s35/5393859.btg.gz ...

Ok, that is interesting. It is not decoding the FlightGear STG file ... says it is unknown format, tried it twice, as binary, and ascii before it FAILED with the above message ... why not 'skip' these files, if they are not being 'read' ... so drop in some code -
if( is_stg_ext(path) )
in the loop ... and add some load statistical variables ... just to help 'understand' what is happening, rather than 'converting vector information to a png file' ...
Map area: lat s35 / s34, lon e149 / e150.
Directory: e140s40/e149s35: ...
File: C:\FG098\FlightGear\data/Scenery/Terrain/e140s40/e149s35/5393856.btg.gz ...
Warning: unknown material "DryCropPastureCover" encountered.
Warning: unknown material "EvergreenBroadCover" encountered.
File: C:\FG098\FlightGear\data/Scenery/Terrain/e140s40/e149s35/5393857.btg.gz ...
Warning: unknown material "SomeSort" encountered.
Warning: unknown material "GrassCover" encountered.
File: C:\FG098\FlightGear\data/Scenery/Terrain/e140s40/e149s35/5393858.btg.gz ...
Warning: unknown material "MixedForestCover" encountered.
File: C:\FG098\FlightGear\data/Scenery/Terrain/e140s40/e149s35/5393859.btg.gz ...
File: C:\FG098\FlightGear\data/Scenery/Terrain/e140s40/e149s35/5393864.btg.gz ...
File: C:\FG098\FlightGear\data/Scenery/Terrain/e140s40/e149s35/5393865.btg.gz ...
File: C:\FG098\FlightGear\data/Scenery/Terrain/e140s40/e149s35/5393866.btg.gz ...
Warning: unknown material "Airport" encountered.
File: C:\FG098\FlightGear\data/Scenery/Terrain/e140s40/e149s35/5393867.btg.gz ... 
and onwards ... until the final entries ...
File: C:\FG098\FlightGear\data/Scenery/Terrain/e140s40/e149s35/5393915.btg.gz ...
File: C:\FG098\FlightGear\data/Scenery/Terrain/e140s40/e149s35/YGLB.btg.gz ...
Done dir:C:\FG098\FlightGear\data/Scenery/Terrain/e140s40/e149s35
Files=33 af=0 tot verts=38964 norms=38539 fans=21428

This is only one iteration into the range shown at the top ... Map area: lat s35 / s34, lon e149 / e150 ... so one can see why the author of the code left out all this output ... remember in unix, stdout, and stderr can be directed to different files, thus the 'errors' do not get mixed up with the 'standard' ... and the only output are dots ... but, it really shows more of 'what is happening' ... the FlightGear files being loaded ... now the total verts, norms, and fans ...

At the end of the 1x1 degree scan, the stats are -
Files=138 af=0 tot verts=164957 norms=156614 fans=87365
Interesting, huh ... the program ends with a smart, sharp, curt ... (no pun intended)
Written 'map.png'

Of course, only in this IDE Debug 'stepping' mode can we 'see' the console window output, especially when the program ends with a simple -
and poof, the console window is gone ... it is also well to note that in this 'application' all the real action occurs in output.closeOutput(); ;=)) This is where the 'image', that was prepared for the glut screen, is snapped, converted to png, and zapped to the disk file, all in the blink of an eye ... Thank you to all those people who write such wonderful code ...

I load my 'trusty' XnView to view the png, and export it as a jpeg, to include here ... why the conversion ... well the png is only 58KB, the jpeg, for demo purposes, is just 9KB ...


If you know your Blue Mountains, you will see this has 'YKAT', which is Katoomba - from apt.dat.gz, it says -1 3280 0 0 YKAT Katoomba, then 10 -33.666672 150.316666 06x 72.00 2952 0.0000 0.0000 98 111111 05 0 0 0.25 0 ... so input --lon=150.0 --lat=-34.0 got me the area lat s34 to s35, lon e150 to e149 ...

I want YSSY, Sydney, which from apt.dat is 1 21 1 0 YSSY Sydney Intl, then first line10 -33.940645 151.176808 07x 74.14 8285 0.0332 0.0000 148 231221 01 2 1 0.25 1 - I decide I want to see all the 1x1 'map' blocks to the coast, so I next try --lon=151.0 --lat=-34.0 ... it should also get 'after' YKAT ... that is give the top-right coordinates ... and add some more 'artefacts' to the image ...

The new run ends with -
File: C:\FG098\FlightGear\data/Scenery/Terrain/e150s40/e151s34/5426746.btg.gz ...
File: C:\FG098\FlightGear\data/Scenery/Terrain/e150s40/e151s34/YCOB.btg.gz ...
File: C:\FG098\FlightGear\data/Scenery/Terrain/e150s40/e151s34/YPEC.btg.gz ...
File: C:\FG098\FlightGear\data/Scenery/Terrain/e150s40/e151s34/YSSY.btg.gz ...
File: C:\FG098\FlightGear\data/Scenery/Terrain/e150s40/e151s34/YWVA.btg.gz ...
Done dir:C:\FG098\FlightGear\data/Scenery/Terrain/e150s40/e151s34
Files=97 af=0 tot verts=123400 norms=104278 fans=58765
Written 'map.png'

Rewarded with the image, now converted for here, to a little JPEG -

This is the 1x1 map block I was looking for ... beautiful Sydney harbour ... what great software ...

Ok, that is map creating ... now for the Atlas part ... still working on this ... more to come ...

Geoff R. McLane
January, 2005


Contents of my loadatlas.bat
@echo Load Atlas ...
@echo CVS passwd: enter
@echo cvs login
#echo cvs -z3 co Atlas
@if "%CVSROOT%." == "." goto SETROOT
@if "%1." == "1." goto LOGIN
@if "%1." == "2." goto LOAD
@echo Use command 1 or 2, meaning -
@echo 1 = login
@echo 2 = download ...
@goto End

@echo (use password "enter")
cvs login
@goto End

cvs -z3 co Atlas
@echo Load done ...
@echo To update, run setroot bat, then cd Atlas, use: cvs up -dP, will do it ...
@goto End

@if NOT EXIST setroot.bat goto NOSET
call setroot
@if "%CVSROOT%." == "." goto NOROOT
@echo Run again ...
@goto End

@echo CVSROOT must be set in the environment ...
@goto End


Previous -|- FG Index -|- ATLAS Index -|- Top -|- Next

under construction

checked by tidy  Valid HTML 4.01 Transitional