diff --git a/src/lib/marble/geodata/data/GeoDataCoordinates.h b/lib/marble/geodata/data/GeoDataCoordinates.h --- a/src/lib/marble/geodata/data/GeoDataCoordinates.h +++ b/lib/marble/geodata/data/GeoDataCoordinates.h @@ -373,6 +373,14 @@ */ QString toString() const; + /** + * @brief enum used to specify the order of latitude and longitude when converted to string + */ + enum LatLonOrder { + OrderLonLat, + OrderLatLon + }; + /** * @brief return a string with the notation given by notation * @@ -384,9 +392,14 @@ * In DMS a precision of 1 or 2 shows the arc minutes; a precision * of 3 or 4 will show arc seconds. A precision beyond that will * increase the number of digits after the arc second decimal point. + * @param order if OrderLatLon, coordinate order is latitude before + * longitude, as specified in ISO 6709. Default is OrderLonLat to be + * consistent with the previous behaviour. This parameter is ignored + * for UTM notation */ - QString toString( GeoDataCoordinates::Notation notation, int precision = -1 ) const; - + QString toString( GeoDataCoordinates::Notation notation, int precision = -1, + GeoDataCoordinates::LatLonOrder order = OrderLonLat ) const; + static QString lonToString( qreal lon, GeoDataCoordinates::Notation notation, GeoDataCoordinates::Unit unit = Radian, int precision = -1, diff --git a/src/lib/marble/geodata/data/GeoDataCoordinates.cpp b/lib/marble/geodata/data/GeoDataCoordinates.cpp --- a/src/lib/marble/geodata/data/GeoDataCoordinates.cpp +++ b/lib/marble/geodata/data/GeoDataCoordinates.cpp @@ -398,10 +398,9 @@ return GeoDataCoordinates::toString( s_notation ); } -QString GeoDataCoordinates::toString( GeoDataCoordinates::Notation notation, int precision ) const +QString GeoDataCoordinates::toString( GeoDataCoordinates::Notation notation, int precision, + GeoDataCoordinates::LatLonOrder order ) const { - QString coordString; - if( notation == GeoDataCoordinates::UTM ){ int zoneNumber = GeoDataCoordinatesPrivate::lonLatToZone(d->m_lon, d->m_lat); @@ -413,15 +412,14 @@ QString eastingString = QString::number(GeoDataCoordinatesPrivate::lonLatToEasting(d->m_lon, d->m_lat), 'f', 2); QString northingString = QString::number(GeoDataCoordinatesPrivate::lonLatToNorthing(d->m_lon, d->m_lat), 'f', 2); + // UTM coordinates (Cartesian coordinates inside a grid zone) always have easting before northing (X before Y) return QString("%1%2 %3 m E, %4 m N").arg(zoneString, bandString, eastingString, northingString); } else{ - coordString = lonToString( d->m_lon, notation, Radian, precision ) - + QLatin1String(", ") - + latToString( d->m_lat, notation, Radian, precision ); + QString lonString = lonToString(d->m_lon, notation, Radian, precision); + QString latString = latToString(d->m_lat, notation, Radian, precision); + return order == OrderLatLon ? QString("%1, %2").arg(latString, lonString) : QString("%1, %2").arg(lonString, latString); } - - return coordString; } QString GeoDataCoordinates::lonToString( qreal lon, GeoDataCoordinates::Notation notation,