1
0
Fork 0
Commit graph

398 commits

Author SHA1 Message Date
James Turner
c628ac7649 Use SGMisc::isNaN instead of isnan()
Fixes a compiler error with C++11/GGC 6.2
2016-10-24 18:40:36 +02:00
Florent Rougon
101bdce343 APTLoader: improve progress status info
It is not needed anymore to hardcode the number of lines of
$FG_ROOT/Airports/apt.dat.gz. The new method, which relies on
SGPath::sizeInBytes() and sg_gzifstream::approxOffset(), works as well
for the other dat files.

Add a new NavCache rebuild phase, REBUILD_READING_APT_DAT_FILES, since
the process is now made of two parts.

Rename NavDataCachePrivate::getDatFilesPaths() to
NavDataCachePrivate::findDatFiles(), because it now returns a
DatFilesGroupInfo (new struct) instead of a PathList. For the same
reason, rename NavDataCachePrivate::aptDatPaths to
NavDataCachePrivate::aptDatFilesInfo. Adapt signatures, etc.

This requires up-to-date SimGear and FGData.
2016-10-19 13:01:35 +02:00
Florent Rougon
57402dec1b Fix a compilation bug that can appear before C++11
Initialization of std::vector can't be done simply in braces-style
(var = { ... }) before C++11.
2016-10-18 08:48:46 +02:00
Florent Rougon
516a5cf016 Support merging of arbitrary apt.dat[.gz] files
It is now allowed to have the same airport appear in several apt.dat
files ($scenery_path/NavData/apt/*.dat[.gz] for each scenery path, plus
the default $FG_ROOT/Airports/apt.dat.gz, coming last). Airports found
in earlier files(*) take precedence over those found later, in case
several apt.dat files define the same airports. Airports that are
skipped due to this mechanism are logged with
SG_LOG(SG_GENERAL, SG_INFO, ...).

(*) using 1) FG_SCENERY order (followed by $FG_ROOT/Airports/apt.dat.gz)
    and   2) lexicographic order inside each $scenery_path/NavData/apt
             folder

With this commit, APTLoader::parseAPT() is replaced by two methods:
readAptDatFile() and loadAirports():
  - APTLoader::readAptDatFile() reads airport definitions from an
    apt.dat file into APTLoader's 'airportInfoMap' member variable,
    discarding duplicate definitions due to overlapping apt.dat files
    ('airportInfoMap' is an std::unordered_map instance in C++11 and
    later, an std::map otherwise);
  - APTLoader::loadAirports() reads each airport definition from
    'airportInfoMap' and loads it into the NavCache, the same way as
    APTLoader::parseAPT() used to do.

The airportDBLoad() function is not useful anymore, and is thus removed
(in NavDataCache::doRebuild(), APTLoader::readAptDatFile() is now called
once per apt.dat file, but APTLoader::loadAirports() is only called
once at the end, after duplicate airports have been discarded; the class
interface is much better suited to this scheme, because it can cleanly
retain the state between these calls).

By the way, this commit fixes an old bug: APTLoader's member variable
'last_apt_id' was used in several places but never assigned to, except
in APTLoader::APTLoader() as the empty string.

Thanks to Alan Teeder for his feedback and testing.
2016-10-17 12:10:03 +01:00
Florent Rougon
670cf9a894 Initial support for NavData/<type>/*.dat[.gz] files in scenery paths
Load every file matching the pattern NavData/apt/*.dat[.gz] inside each
scenery path. These files are loaded in the same order as the components
of globals->get_unmangled_fg_scenery() they reside in. Inside a given
component, the order is determined by pathSortPredicate() in
simgear/misc/sg_dir.cxx (lexicographic order at the time of this
writing). For compatibility with existing scenery,
$FG_ROOT/Airports/apt.dat.gz is also loaded last.

The idea is that such files will have the same precedence order as the
globals->get_unmangled_fg_scenery() scenery components they come from.
This commit doesn't handle this fully yet, though: it blindly loads all
these files. A future commit will ensure that no airport is loaded twice
due to overlapping apt.dat files. This commit however handles all the
logic of navdata cache rebuilding when the list, the order of apt.dat
files, or any of their timestamps changes.

Although only apt.dat files receive a new treatment in this commit, the
changes to NavDataCache.[ch]xx are already generic so that extension of
this method to fix.dat, nav.dat, etc. will require almost no change to
NavDataCache.[ch]xx (however, changes will probably be needed in the
various loaders: in fixlist.[ch]xx, navdb.[ch]xx, etc.).

src/Navaids/CacheSchema.h:

  - increment the SCHEMA_VERSION by 1. This ensures among others that if
    someone uses a FlightGear version posterior to this change with
    new-style scenery (having NavData/apt/*.dat[.gz] files inside
    scenery paths), then goes back to a FlightGear version anterior to
    this change, his NavCache is rebuilt ignoring the in-scenery-paths
    NavData/apt/*.dat[.gz] files, as expected with the old FlightGear
    version.

src/Navaids/NavDataCache.cxx:

  - NavDataCachePrivate: replace aptDatPath (SGPath) with aptDatPaths
    (PathList).

  - NavDataCachePrivate::getDatFilesPaths(): new method that returns the
    list of $scenery_path/NavData/<type>/*.dat[.gz] files found inside
    scenery paths (where <type> is one of 'apt', 'fix', etc.), plus the
    historical file (e.g., $FG_ROOT/Airports/apt.dat.gz for the 'apt'
    type).

  - NavDataCachePrivate::areDatFilesModified(): new method that tells
    whether any of these files (for a given type) has changed since the
    last NavCache rebuild, or if their ordered list has changed.

  - NavDataCachePrivate::isCachedFileModified(): minor changes.

  - NavDataCache::updateListsOfDatFiles(): new method that updates the
    lists of dat files used for NavCache freshness checking and
    rebuilding, i.e. currently sets/updates d->aptDatPaths using the new
    method d->getDatFilesPaths(), and d->metarDatPath, d->navDatPath,
    d->fixDatPath, d->poiDatPath, etc. as usual. This method will be
    useful for instance in the built-in launcher after updating scenery
    paths and before calling NavDataCache::isRebuildRequired().

  - NavDataCache::NavDataCache(): use
    NavDataCache::updateListsOfDatFiles() to initialize d->aptDatPaths,
    d->metarDatPath, d->navDatPath, d->fixDatPath, d->poiDatPath, etc.

  - NavDataCache::isRebuildRequired(): use
    NavDataCachePrivate::areDatFilesModified() instead of just checking
    $FG_ROOT/Airports/apt.dat.gz.

  - NavDataCache::doRebuild(): load all apt.dat files listed in
    d->aptDatPaths, instead of only $FG_ROOT/Airports/apt.dat.gz. Write
    their ordered list and timestamps in the NavCache.

src/Navaids/NavDataCache.hxx:

  - declare the new method NavDataCache::updateListsOfDatFiles().

  - NavDataCache::DatFileType: new enum with values DATFILETYPE_APT,
    DATFILETYPE_METAR, DATFILETYPE_AWY, DATFILETYPE_NAV,
    DATFILETYPE_FIX, DATFILETYPE_POI, DATFILETYPE_CARRIER and
    DATFILETYPE_TACAN_FREQ. Maybe some of the corresponding files won't
    have to be moved to scenery paths, but simply listing them in the
    enum doesn't change how they are dealt with. Those for which
    per-scenery-path locations doesn't make sense can just be removed
    from the enum.

  - NavDataCache::datTypeStr: new static string_list giving an
    std::string such as 'apt' for each value of the
    NavDataCache::DatFileType enum.

  - NavDataCache::defaultDatFile: new static string_list giving a path
    (relative to $FG_ROOT) to the historical/default file for each value
    of the NavDataCache::DatFileType enum.

src/Airports/apt_loader.cxx and src/Airports/apt_loader.hxx:

  - always include a path to the apt.dat file being processed in log
    messages, since they can now apply to many files;

  - be clearer about code 99: it should normally be at the end of
    apt.dat files, but technically, it is not an EOF;

  - use the expression "row code" consistently with the apt.dat format
    spec (for now: only in places where there is another change to do).

src/GUI/QtLauncher.cxx and src/GUI/QtLauncher_private.hxx:

  - turn QtLauncher::setSceneryPaths() into a static method and call it
    in runLauncherDialog() before instantiating NavDataCache, so that
    NavDataCache::updateListsOfDatFiles() (called from NavDataCache's
    constructor) can see all configured scenery paths.
2016-10-17 12:10:03 +01:00
Florent Rougon
dfdd52a81b Use SGPath::realpath() for paths stored in the stat_cache table of the NavCache
This will avoid problems in case stampCacheFile() or
isCachedFileModified() is passed a relative path, or a path containing
.. components, etc. Among others, it ensures the stat_cache table only
contains absolute paths.

NavDataCache: read and write methods preserving order for string list props

New methods: NavDataCache::readOrderedStringListProperty() and
NavDataCache::writeOrderedStringListProperty().
2016-10-17 12:10:03 +01:00
Florent Rougon
eb1c6adbc7 fix.dat parser: correct use of sg_io_exception
- For sg_io_exception's constructor, 'location' is not the same as
  'origin'.
- Use simgear::strutils::error_string() to provide details on the error.
2016-09-28 12:22:54 +02:00
Florent Rougon
29c7fa54b1 fix.dat parser: indentation fix 2016-09-28 12:22:54 +02:00
Florent Rougon
30c8328399 fix.dat parser: check the stream's badbit flag after each I/O operation
- new private method FixesLoader::throwExceptionIfStreamError();
- call it whenever appropriate.
2016-09-28 12:22:44 +02:00
Florent Rougon
d9c879ff30 fix.dat parser: new class FixesLoader; change loadFixes() into a method
- loadFixes() becomes FixesLoader::loadFixes();
- the previous 'cache' variable (NavDataCache *) is now a private member
  of FixesLoader, named '_cache'.
2016-09-28 09:24:33 +02:00
Florent Rougon
cf9759f78f fix.dat parser: fix line numbering and better handle malformed data
- Line numbering was incorrect, because "in >> lat >> lon >> ident;"
  happily skipped over blank lines without increasing the line number.

- Safe stream input handling: first, std::getline() tries to read data,
  then we check whether that was successful (via the input stream's
  bool() method, implicitly called in the 'for' loop's exit check), and
  only if this is the case, we process the data that was read. The main
  problem with the previous code is that checking the stream's eofbit
  can't possibly predict whether a _future_ read will be successful---it
  may fail due to an I/O error, at least.

- Currently, the code uses atof() to parse the latitude and longitude
  fields. This should be fast, though not good at detecting errors in
  the input; however, this is not worse than the previous code which
  didn't handle such cases at all.

- Correctly deal with input lines containing a number of fields
  different from 3 (except for the header and the special '99' line):
  log a warning, ignore the line and continue. This adresses the problem
  described in
  <https://sourceforge.net/p/flightgear/mailman/flightgear-devel/thread/87shydeen1.fsf%40frougon.crabdance.com/#msg35034274>.
  In short, the previous code entered an endless loop trying to process

   31.815914 -106.281897 EL PA

  from recent earth_fix.dat
  (obtained from <http://gateway.x-plane.com/navaids/LatestNavFix.zip>).
2016-09-28 09:24:33 +02:00
James Turner
a60d07ea9c Incremental insert of NE data to the index. 2016-08-09 09:38:54 +01:00
James Turner
7f3fe584e3 Update for path-aware easyXML API 2016-07-03 23:43:39 +01:00
James Turner
9cffcf63ae Further SGPath encoding fixes. 2016-07-01 04:54:29 -05:00
James Turner
6d0c2070fd Use future-proof SGPath APIs.
Remove uses of .str(), .c_str() and some other methods of SGPath.
Pass SGPath directly where possible, or explicitly convert to the
appropriate 8-bit encoding.
2016-06-28 10:08:38 +01:00
James Turner
16814800ce Use Paths instead of strings. 2016-06-22 17:36:05 +01:00
James Turner
03ecac9dbc Work with new SGPath API. 2016-06-22 17:36:05 +01:00
Florent Rougon
959ac91a8b Add missing include in src/Navaids/NavDataCache.cxx
#include <sstream> is needed for NavDataCachePrivate::init()
which uses std::ostringstream.
2016-05-19 09:19:06 +02:00
James Turner
b431696e9b Fixes for first/last legs on a route
- fixes total route distance calculation
2015-12-17 19:22:14 -08:00
James Turner
9c467af6bf Interim windows build fix
(real fix to follow shortly)
2015-12-14 10:56:42 -06:00
James Turner
7afedb1702 Work on visualisation of Vias 2015-12-11 13:43:25 -06:00
James Turner
eaa147e3c2 Work on FlightPlan VIA / discontinuity support.
Needed for realistic FMS route support.
2015-12-11 13:43:25 -06:00
James Turner
545b347a16 Relocate implementation of geocRadialIntersection 2015-12-10 15:53:05 -06:00
James Turner
fc887b106b Checkpoint - ground-net skips the cache 2015-12-01 14:01:32 +00:00
James Turner
cec1de6219 Use a transaction when indexing polylines. 2015-11-29 14:18:30 +00:00
James Turner
e52e20b54f SHPParser 2015-11-27 23:02:42 +00:00
James Turner
b9acb26c07 Work on launcher diagrams. 2015-11-23 00:47:01 +00:00
James Turner
56d7d049bc Launcher GUI for in-air / navaid starts 2015-11-23 00:46:25 +00:00
James Turner
1e213201cf Work on the launcher 2015-11-23 00:45:21 +00:00
James Turner
bbff8dcbb6 Remove / reduce level on some debug output 2015-06-08 10:37:26 +01:00
Rebecca N. Palmer
659c5b9676 Fix spelling 2015-04-06 10:28:10 +01:00
James Turner
e0274af493 Percentage feedback during nav-cache build.
- also used by the GUI launcher for the same.
2015-03-19 12:01:38 -05:00
James Turner
c3543f8fdd GUI ‘restore defaults’ support.
- Hold ‘alt’ on launch to restore defaults, including launcher prefs.
2015-03-08 00:42:39 +00:00
James Turner
2d8cf78328 Fix Linux compilation.
- <memory> needed for auto_ptr
2015-02-25 23:53:49 +00:00
James Turner
e1def22193 Fix cleanup of RouteDataPrivate 2015-02-25 22:58:56 +00:00
James Turner
564177933b FlightPlan activation, delegate hook. 2015-02-23 13:41:50 +00:00
Stuart Buchanan
6725b460bf Clean up some trivial warnings 2015-01-18 19:49:14 +00:00
James Turner
dcf8ac1778 route-path: separate turn entry and exit parts.
Fixes appearance of runway legs with off-centerline previous
and next points, since we can generate different curves for each
end of the runway.
2015-01-14 23:28:52 +00:00
James Turner
e4f5f71aae Route path turn helpers.
Make the code more readable with some named helper functions.
2015-01-11 13:15:24 +00:00
James Turner
e94371ebfc Route-path bug fixes.
- explicit aircraft performance categories for turn radius
- allow overflight leg course behaviour to be selected
2015-01-08 19:46:04 +00:00
James Turner
78e8f53312 In-app launcher for Mac, based on Qt5.
The old Mac launcher doesn’t work on Yosemite, add a tiny
Qt-based launcher inside the main process (no need to fork /
exec) which runs before the OSG window is created.

Will be merged for 3.4, hopefully with no impact on other
platforms.
2015-01-06 19:13:30 +00:00
James Turner
5ccc835667 Fix turn entry path position computation. 2015-01-03 00:29:07 +00:00
James Turner
6db45dac9d Fix two route path issues found by Hyde
- course computation from a runway was wrong (used threshold pos)
- negative distance along path was using wrong distance to offset
2015-01-02 09:47:54 +00:00
James Turner
dbc47efa18 Partial fix for runway leg courses.
Don’t assume runway leg course matches the runway heading.
Full fix means generating separate entry/exit turns for runways.
2014-12-25 21:52:54 +03:00
James Turner
5c659b3970 Fix distance-along-path computation
(Thanks to Hyde Yamakawa for pointing this one)
2014-12-25 21:52:13 +03:00
James Turner
dd1b829618 When the turn angle is large, don’t fly-by.
This avoids the tan() term in the fly-by computation
causing huge turn cuts which will fail to sequence.
Convert such turns to fly-over.
2014-12-22 21:47:21 +03:00
James Turner
f80528f8d6 RoutePath mag-var and point-on-path fixes 2014-12-22 17:00:43 +03:00
James Turner
aa3333cd31 Fix runway path appearance. 2014-12-21 09:21:31 +03:00
James Turner
91992f6cf1 Route path
- better point along path computation
 - fix path distance for turns
 - detect and skip duplicated waypoints

(and provision to skip based upon impossible turn
geometry soon)
2014-12-20 15:19:00 +01:00
James Turner
088572e87d Route-path:
* better overflight pathing based on next wpt type
* tolerate procedures with bad intersections (eg KSFO OFFSH8)
2014-12-19 17:01:27 +00:00