compared to Mappero, which provides lat and lon with 6 decimal digits, I get
only 4 digits for lat and 5 digits for lon from MoNav - which is a bit
inaccurate.
I have no clue whether this is caused by QGeoPositionInfoSource or my
own/MoNav's code:
const RoutingLogic::GPSInfo& gpsInfo = RoutingLogic::instance()->gpsInfo();
qDebug() << gpsInfo.position.x << gpsInfo.position.y;
qDebug() << gpsInfo.position.ToGPSCoordinate().latitude \
<< gpsInfo.position.ToGPSCoordinate().longitude;
results in something like
561900976 368759099
48.9973 8.39198
561900931 368759164
48.9973 8.39197
561900925 368759161
48.9973 8.39197
561900891 368759111
48.9973 8.39195
561900852 368759081
48.9973 8.39194
561900862 368759041
48.9973 8.39194
From coordinates.h:
/** converts to GPS coordinate */
GPSCoordinate ToGPSCoordinate() const
{
return ToProjectedCoordinate().ToGPSCoordinate();
}
/** converts to floating point coordinate */
ProjectedCoordinate ToProjectedCoordinate() const
{
ProjectedCoordinate tile;
if ( !IsValid() )
return tile;
tile.x = x;
tile.y = y;
tile.x /= ( 1u << 30 );
tile.y /= ( 1u << 30 );
return tile;
}
/** converts into a GPS position */
GPSCoordinate ToGPSCoordinate() const
{
GPSCoordinate gps;
if ( !IsValid() )
return gps;
gps.longitude = x * 360.0 - 180;
const double n = M_PI - 2.0 * M_PI * y;
gps.latitude = 180.0 / M_PI * atan( 0.5 * ( exp( n ) - exp( -n ) )
);
return gps;
}
Admittedly I do not exactly understand what the above calculations do. In case
someone savvy could shed a little light on them, it would be much appreciated.
In case it helped to remove one item from my TODO list, even better :) .
--
Beste Grüße,
Best regards,
ce
On Wed, May 11, 2011 at 11:49 PM, Christoph Eckert <c...@christeck.de> wrote:
> Hi,
>
> compared to Mappero, which provides lat and lon with 6 decimal digits, I get
> only 4 digits for lat and 5 digits for lon from MoNav - which is a bit
> inaccurate.
>
> I have no clue whether this is caused by QGeoPositionInfoSource or my
> own/MoNav's code:
>
> const RoutingLogic::GPSInfo& gpsInfo = RoutingLogic::instance()->gpsInfo();
>
> qDebug() << gpsInfo.position.x << gpsInfo.position.y;
> qDebug() << gpsInfo.position.ToGPSCoordinate().latitude \
> << gpsInfo.position.ToGPSCoordinate().longitude;
The reduced accuracy is only caused by the output. qDebug outputs with
a default accuracy of 6 digits ( including the ones before the
decimal point ). So you have to increase the floating point accuracy
of whatever output functions you are using. I do believe that qDebug
cannot be modified to output with increased accuracy. However, you can
use QString().arg(...) (
http://doc.qt.nokia.com/latest/qstring.html#arg-20 ).
UnsignedCoordinate itself should be accurate to at least 4cm ( worst
accuracy on the equator ). The conversion from GPS to
ProjectedCoordinate transforms the coordinate into the Mercator
projection used by OSM, x in [0,1], y in [0,1]. This is beneficial
since most plugins use this projection. UnsignedCoordiante simple
stores x and y as unsigned int, stretching the range [0,1] to
[0,2^30].
Regards,
Christian Vetter
> The reduced accuracy is only caused by the output. qDebug outputs with
> a default accuracy of 6 digits ( including the ones before the
> decimal point ). So you have to increase the floating point accuracy
> of whatever output functions you are using.
I've seen this in the tracklog, using QString::number(). Increasing its
precision to 6 digits only gave me additional 0's. Based on your hint, I'll
try anew. In case the problem persists, I'll come back with some more details.
BTW: I've added a first german translation to the uing branch. Except for some
minor hickups, it looks great on the N900 and the desktop so far.
Gn8,
ce
> The reduced accuracy is only caused by the output. qDebug outputs with
> a default accuracy of 6 digits ( including the ones before the
> decimal point ). So you have to increase the floating point accuracy
> of whatever output functions you are using. I do believe that qDebug
> cannot be modified to output with increased accuracy. However, you can
> use QString().arg(...) (
> http://doc.qt.nokia.com/latest/qstring.html#arg-20 ).
thanks a bunch for the pointer. Of course "it was all my fault" - the
precision obviously went down as I had the device on my desk…
Outdoors, either of the following provide the desired results:
double latitude = m_gpsInfoBuffer.at(i).position.ToGPSCoordinate().latitude;
std::cout.precision( 6 );
cout << latitude;
QString::number( latitude, 'f', 6 )
I apologize for the traffic, but at least we now have more accurate logging for
MoNav :) .
Glad that's fixed. I already fell into that trap several times myself
when coding GPS loggers.
Regards,
Christian Vetter