Reply to topic

Wrong routing

jpati
Registered Member
Posts
8
Karma
0

Wrong routing

Wed Dec 26, 2012 11:38 pm
Hi!
Since I use Marble to build my GUI application, I've decied to make my own class containing MarbleWidget (code below). I've also create function setRoute(qreal,qreal,qreal,qreal) that creates a route between two points (it is executed after pressing the button, hence public slot functions). When I use example Basic Routing from C++ Marble tutorial, everythhing is fine. But when using my function to create a route, it shows wrong coordinates on the map. (not that which I give to function as arguments). I don't know if this some kind of bug if I'm doing sth wrong?

mapWidget.h
Code: Select all
using namespace Marble;
extern std::vector<summit*> Summits; //that's where i store coordinates

class mapWidget : public MarbleWidget
{
    Q_OBJECT
public:
    explicit mapWidget(QWidget *parent = 0);

private:
    MarbleWidget *mapwidget;
    RoutingManager *manager;
    RouteRequest *request;
    typedef std::tuple<qreal, qreal, int > GPS;
    GPS source1; //start of the route
    GPS source2; //finish of the route
    void setRoute(qreal source_AH, qreal source_AV, qreal source_BH, qreal ource_BV); // - H -horizontal, V-vertical

signals:
   
public slots:
    void receivedCoordiantesSource(int index)
    {
        source1 = GPS(Summits[index]->getGPS().first,Summits[index]->getGPS().second,index); // setting coordinates
        if (std::get<2>(source2) != -1)                                                                                                  // check if I just have coordinates from receivedCoordinatesDest function after pushing a button
            setRoute(std::get<0>(source1), std::get<1>(source1), std::get<0>(source2), std::get<1>(source2));
    }
    void receivedCoordiantesDest(int index)
    {
        source2 = GPS(Summits[index]->getGPS().first,Summits[index]->getGPS().second,index);
        if (std::get<2>(source1) != -1)
            setRoute(std::get<0>(source1), std::get<1>(source1), std::get<0>(source2), std::get<1>(source2));
    }

};

cpp file
Code: Select all
using namespace Marble;

mapWidget::mapWidget(QWidget *parent)
{
    source1 = GPS(0.0, 0.0, -1);
    source2 = GPS(0.0, 0.0, -1);

    // Create a Marble QWidget with a parent
    mapwidget = new MarbleWidget(parent);
    mapwidget->setGeometry(QRect(130, 19, 651, 391));

    // Load the OpenStreetMap map
    mapwidget->setMapThemeId( "earth/openstreetmap/openstreetmap.dgml");
    mapwidget->setProjection( Mercator );

    // Access the shared route request (start, destination and parameters)
    manager = mapwidget->model()->routingManager();
    request = manager->routeRequest();

    // Use default routing settings for walking
    request->setRoutingProfile( manager->defaultProfile( RoutingProfile::Pedestrian ) );

    mapwidget->centerOn(  19.94586, 49.25109, true);
    mapwidget->setDistance( 12 );

}


void mapWidget::setRoute(qreal source_AH, qreal source_AV, qreal source_BH, qreal source_BV)
{
    // Set start and destination
    request->append( GeoDataCoordinates( source_AH, source_AV, 0.0, GeoDataCoordinates::Degree) );
    request->append( GeoDataCoordinates( source_BH, source_BV, 0.0, GeoDataCoordinates::Degree) );

    // Calculate the route
    manager->retrieveRoute();

    // Center the map on the route start point and show it
    mapwidget->centerOn( request->at( 0 ) );
    mapwidget->setDistance( 0.75 );
}
User avatar tackat
KDE Developer
Posts
63
Karma
0
OS

Re: Wrong routing

Thu Dec 27, 2012 12:32 am
Dennis Nienhüser (aka Earthwings) is the expert on this topic in our team. Currently he's out of town for a day or two, so it might take a few hours until you get a qualified answer :-)
Personally I don't spot an obvious bug in your code but that says nothing since I'm not very much familiar with the routing topic - longitude and latitude seem to be in the correct order (at least if you initially "feed" them correctly). That being said I'd be surprised if the faulty behavior was due to a bug in Marble since this kind of functionality gets used for all our routing features and is frequently used.

Best Regards,
Torsten
jpati
Registered Member
Posts
8
Karma
0

Re: Wrong routing

Thu Dec 27, 2012 1:46 pm
Ok, so now I wait :) Just to specify: it looks like both points are shifted on the same vector since relative distance and position beetween them looks fine.

Sincerely,
jpati
User avatar tackat
KDE Developer
Posts
63
Karma
0
OS

Re: Wrong routing

Thu Dec 27, 2012 1:48 pm
Maybe you can attach a screenshot to give us a better idea of what is wrong? :)
jpati
Registered Member
Posts
8
Karma
0

Re: Wrong routing

Thu Dec 27, 2012 2:45 pm
Here you are: http://i48.tinypic.com/f0bzau.png Function should calculate route beetween ends of red line but it calculates beetween points A and B.
jpati
Registered Member
Posts
8
Karma
0

Re: Wrong routing

Fri Jan 18, 2013 11:59 pm
Ok, I've just found where the problem exists! I copied coordinates from Marble application that are given in UTM (or DMS, I'm not sure) format but GeoDataCoordinates function accepts Decimal format so my points were wrong indeed. Is it possible to use UTM (DMS?) coordinates in my routing or I have to convert them to Decimal format?
User avatar Earthwings
KDE Developer
Posts
89
Karma
1
OS

Re: Wrong routing  Topic is solved

Tue Jan 22, 2013 7:34 am
Possibly DMS, which is Marble's default coordinate representation to the user. Note that you can change it in Marble's settings to Decimal, which many people prefer. The "copy coordinates" action follows that setting.

There's GeoDataCoordinates fromString() method which can be used to parse DMS coordinates, but it's primarily meant to parse user input that does not originate from a map directly (e.g. copied as a string from some website). If you have a chance to get the input in Decimal notation, I'd go for that.

 
Reply to topic

Bookmarks



Who is online

Registered users: Abdelrahman Magdy, Baidu [Spider], Bing [Bot], colomar, cylverbak, edmael, Exabot [Bot], Google [Bot], google01103, jeanliu, ken300, koriun, Majestic-12 [Bot], MSNbot Media, navalgupte, paulus3005, psbot [Picsearch], robinh, scummos, Sentynel, TheraHedwig, tshearer, Uri_Herrera, vascobasque, wolfi323, Yahoo [Bot]