This forum has been archived. All content is frozen. Please use KDE Discuss instead.

UTM projection in marble

Tags: None
(comma "," separated)
phamanhtuan
Registered Member
Posts
1
Karma
0

UTM projection in marble

Thu Apr 09, 2015 3:14 am
Hi,
I am developing an apps using marble.

It supports some projections such as Spherical, Equirectangular, Mercator, ...
I know that the Mercator projection Marble using is Normal Mercator Projection, not Universal Transverse Mercator (UTM).
Does anyone know how to use UTM projection?

Thanks,
User avatar
tackat
KDE Developer
Posts
131
Karma
0
OS

Re: UTM projection in marble

Mon Apr 13, 2015 1:49 pm
Hi,

If you are referring to the UTM coordinate system - currently there is just support for the UTM grid:

Settings->Configure Marble

Then in the "Unit" section switch "Angle" to UTM.

This will make the Graticule render the major UTM zones.
For further UTM support (i.e. displaying UTM coordinates on hover, search for UTM positions in the query) we'd gladly accept patches (That would probably mostly require a patch to the GeoDataCoordinates class).
User avatar
tackat
KDE Developer
Posts
131
Karma
0
OS

Re: UTM projection in marble

Mon Apr 13, 2015 2:40 pm
If you want to add further support it would be very much welcome.
Check out the the Marble source code (https://marble.kde.org/sources.php).

In order to enable UTM mode, see my prior post.

A) Displaying UTM coordinates (e.g. if you enable the status bar or click an item on the map)
Initially I guess it would be best if we had a more accurate implementation of

QString GeoDataCoordinates::lonToString( )
and
QString GeoDataCoordinates::latToString( )
See lines 938 and 1085 inside src/lib/marble/geodata/data/GeoDataCoordinates.cpp where UTM is mentioned and where a stub implementation is provided already.

I just checked whether the current implementation seems to work but at least for me it just displays always "30,N" (maybe a regression?)


B) Interpreting search queries e.g. when you enter a UTM coordinate in the Marble Search Query:
This would require to add UTM support inside src/lib/marble/geodata/data/GeoDataCoordinates.cpp to


bool LonLatParser::parse( const QString& string )

C) Improving the Graticule: That would require to improve the implementation inside
src/plugins/render/graticule/GraticulePlugin.cpp. , line 311
User avatar
agarciamontoro
Registered Member
Posts
1
Karma
0
OS

Re: UTM projection in marble

Thu Apr 30, 2015 1:38 am
Hi!

I have done some work concerning these issues.

It's just the first approach but, by now, the code is able to calculate the zone and latitude bands (only the regular ones).
I copy here the relevant code so far:

Code: Select all
latToString( ... )
{
    if ( notation == UTM ) {
        //Converts lat from [-90,90] (degree) or [-M_PI/2,M_PI/2] (radian) to [0,180]
        qreal lat180 = (unit == Degree) ? lat+90 : lat*RAD2DEG+90;

        //Regular latitude bands between 80 S and 80 N (that is, between 10 and 170 in the [0,180] interval)
        int bandLetterIndex;

        if(lat180 >= 10 && lat180 <= 170){
            bandLetterIndex = static_cast<int>( lat180 / 8.0) - 1;
        }
        else{
            bandLetterIndex = 20;
        }

        return QString( "CDEFGHJKLMNPQRSTUVWX?" ).at( bandLetterIndex );
    }
    ...
}

lonToString( ... )
{
    if ( notation == UTM ) {
        //Converts lon from [-180,180] (degree) or [-M_PI,M_PI] (radian) to [0,360]
        qreal lon360 = (unit == Degree) ? lon+180 : lon*RAD2DEG+180;

        //Divides into 60 zones of 6 degrees.
        int zoneNumber = static_cast<int>( lon360 / 6.0 ) + 1;
        return QString::number( zoneNumber );
    }
    ...
}


Furthermore, the equator, meridian and antimeridian lines are now drawn in UTM mode.

The lines and the proper calculation of zone/latitude band are seen in the following screenshot:

Image

The code does not calculate the exceptions in the latitude bands nor the precise coordinate position yet. There are also some grid labels that does not appear.

Once I got those things working, I'll submit a Review Request.
User avatar
Earthwings
KDE Developer
Posts
172
Karma
1
OS

Re: UTM projection in marble

Mon May 25, 2015 2:03 pm
You can find the review request at https://git.reviewboard.kde.org/r/123579/


Bookmarks



Who is online

Registered users: bancha, Bing [Bot], Evergrowing, Google [Bot], lockheed, mesutakcan, Sogou [Bot]