Advertisement
Guest User

Untitled

a guest
Aug 24th, 2012
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. diff --git a/simgear/scene/tgdb/ReaderWriterSTG.cxx b/simgear/scene/tgdb/ReaderWriterSTG.cxx
  2. index 386a3f6..1f126f3 100644
  3. --- a/simgear/scene/tgdb/ReaderWriterSTG.cxx
  4. +++ b/simgear/scene/tgdb/ReaderWriterSTG.cxx
  5. @@ -46,6 +46,9 @@
  6.  
  7. #include "SGOceanTile.hxx"
  8.  
  9. +#include <boost/regex.hpp>
  10. +
  11. +
  12. using namespace simgear;
  13.  
  14. static SGBucket bucketIndexFromFileName(const std::string& fileName)
  15. @@ -73,6 +76,16 @@ static bool hasOptionalValue(sg_gzifstream &in)
  16. }
  17. }
  18.  
  19. +static double getGroundElevation(double &lon, double &lat, std::string &offset)
  20. +{
  21. + double GroundElevation(666.45);
  22. + SG_LOG( SG_TERRAIN, SG_ALERT, "Compute ground elevation for STG object with lon="<< lon <<" and lat=" << lat << " with offset="<< offset);
  23. + //SGGeod geod = SGGeod::fromDegM(lon, lat, "10000");
  24. + //here we need to find a SimGear function who return the ground elevation with lon/lat parameters
  25. +
  26. + return GroundElevation;
  27. +}
  28. +
  29. ReaderWriterSTG::ReaderWriterSTG()
  30. {
  31. supportsExtension("stg", "SimGear stg database format");
  32. @@ -240,8 +253,29 @@ ReaderWriterSTG::readStgFile(const std::string& absoluteFileName,
  33. }
  34.  
  35. } else {
  36. + boost::regex re("(GND)([\\+-]{1}[0-9.]+)?");
  37. + boost::cmatch matches;
  38. + std::string gnd;
  39. double lon, lat, elev, hdg;
  40. - in >> lon >> lat >> elev >> hdg;
  41. +
  42. + in >> lon >> lat >> gnd >> hdg;
  43. +
  44. +
  45. + if ( boost::regex_match(gnd.c_str(), matches, re) ) {
  46. +
  47. + //for ( int i = 1; i < matches.size(); i++) {
  48. + string match(matches[2].first, matches[2].second);
  49. + // cout << "\tmatches[" << i << "] = " << match << endl;
  50. +
  51. + SG_LOG( SG_TERRAIN, SG_ALERT, absoluteFileName << ": GND Regex detected '" << name << "' Offset=" << match);
  52. + elev = getGroundElevation(lon, lat, match);
  53. + //}
  54. +
  55. + } else {
  56. +
  57. + elev = atof(gnd.c_str());
  58. +
  59. + }
  60.  
  61. // Always OK to load
  62. if ( token == "OBJECT_STATIC" ) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement