Menu

Welcome to Open Discussion

2009-10-17
2012-09-22
  • Charles Karney

    Charles Karney - 2009-10-17

    Welcome to Open Discussion

     
  • Roland Bengtsson

    A simple newbie question. How can I use this library to calculate the distance
    between 2 coordinates if the cordinates are in format 60,12345 22,54321 ?

     
  • Charles Karney

    Charles Karney - 2010-01-21

    The degree and DMS decoding in the DMS class uses a period for the
    decimal separator. On a Unix platform you can convert commas to periods
    with:

    echo 60,12345 22,54321 61,12345 23,54321 | tr , . | Geod -i | tr . ,

    =>

    25,73198351 26,60343672 124142,645 124134,834

    I can look into using the current locale to regulate this. However, I
    regard this as a side issue for the library -- so don't hold your
    breath. The "recommended" way to do distance calculations is with C++
    code:

    double lat1, lon1, lat2, lon2;
    double s12, azi1, azi2, m12;
    std::cin >> lat1 >> lon1 >> lat2 >> lon2;
    GeographicLib::Geodesic::WGS84.Inverse(lat1, lon1, lat2, lon2,
    s12, azi1, azi2, m12);
    std::cout << "Distance = " << s12 << "\n";

    In this case, you, the programmer, deal with the reading and writing of
    the numbers.

     
  • Roland Bengtsson

    Thanks for the answer. Now I know more how to deal with it.

    Regards

     

Anonymous
Anonymous

Add attachments
Cancel