• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.12
  • kdeedu
  • marble
  • examples
  • cpp
  • basic-routing
examples/cpp/basic-routing/main.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2012 Dennis Nienhüser <earthwings@gentoo.org>
9 //
10 
11 #include <QApplication>
12 #include <marble/MarbleWidget.h>
13 #include <marble/MarbleModel.h>
14 #include <routing/RouteRequest.h>
15 #include <routing/RoutingManager.h>
16 
17 using namespace Marble;
18 
19 int main(int argc, char** argv)
20 {
21  QApplication app(argc,argv);
22 
23  // Create a Marble QWidget without a parent
24  MarbleWidget *mapWidget = new MarbleWidget();
25 
26  // Load the OpenStreetMap map
27  mapWidget->setMapThemeId( "earth/openstreetmap/openstreetmap.dgml" );
28  mapWidget->setProjection( Mercator );
29 
30  // Access the shared route request (start, destination and parameters)
31  RoutingManager* manager = mapWidget->model()->routingManager();
32  RouteRequest* request = manager->routeRequest();
33 
34  // Use default routing settings for cars
35  request->setRoutingProfile( manager->defaultProfile( RoutingProfile::Motorcar ) );
36 
37  // Set start and destination
38  request->append( GeoDataCoordinates( 8.38942, 48.99738, 0.0, GeoDataCoordinates::Degree ) );
39  request->append( GeoDataCoordinates( 8.42002, 49.0058, 0.0, GeoDataCoordinates::Degree ) );
40 
41  // Calculate the route
42  manager->retrieveRoute();
43 
44  // Center the map on the route start point and show it
45  mapWidget->centerOn( request->at( 0 ) );
46  mapWidget->setDistance( 0.75 );
47  mapWidget->show();
48 
49  return app.exec();
50 }
Marble::GeoDataCoordinates
A 3d point representation.
Definition: GeoDataCoordinates.h:52
MarbleModel.h
This file contains the headers for MarbleModel.
Marble::MarbleWidget::setProjection
void setProjection(int projection)
Set the Projection used for the map.
Definition: MarbleWidget.cpp:702
Marble::RouteRequest::append
void append(const GeoDataCoordinates &coordinates, const QString &name=QString())
Add the given element to the end.
Definition: RouteRequest.cpp:218
Marble::GeoDataCoordinates::Degree
Definition: GeoDataCoordinates.h:66
Marble::MarbleWidget
A widget class that displays a view of the earth.
Definition: MarbleWidget.h:102
Marble::RoutingManager::routeRequest
RouteRequest * routeRequest()
Returns the current route request.
Definition: RoutingManager.cpp:270
Marble::MarbleWidget::setMapThemeId
void setMapThemeId(const QString &maptheme)
Set a new map theme.
Definition: MarbleWidget.cpp:865
Marble::RouteRequest
Points to be included in a route.
Definition: RouteRequest.h:31
RoutingManager.h
Marble::RoutingManager::defaultProfile
RoutingProfile defaultProfile(RoutingProfile::TransportType transportType) const
Generates a routing profile with default settings for the given transport type.
Definition: RoutingManager.cpp:341
Marble::MarbleModel::routingManager
RoutingManager * routingManager()
Definition: MarbleModel.cpp:605
Marble::Mercator
Mercator projection.
Definition: MarbleGlobal.h:47
Marble::RouteRequest::setRoutingProfile
void setRoutingProfile(const RoutingProfile &profile)
Definition: RouteRequest.cpp:315
Marble::MarbleWidget::model
MarbleModel * model() const
Return the model that this view shows.
Definition: MarbleWidget.cpp:283
Marble::RoutingManager
Delegates data retrieval and model updates to the appropriate routing provider.
Definition: RoutingManager.h:37
Marble::RoutingManager::retrieveRoute
void retrieveRoute()
Retrieve a route suiting the routeRequest.
Definition: RoutingManager.cpp:275
Marble::MarbleWidget::centerOn
void centerOn(const qreal lon, const qreal lat, bool animated=false)
Center the view on a geographical point.
Definition: MarbleWidget.cpp:626
main
int main(int argc, char **argv)
Definition: examples/cpp/basic-routing/main.cpp:19
MarbleWidget.h
This file contains the headers for MarbleWidget.
RouteRequest.h
Marble::MarbleWidget::setDistance
void setDistance(qreal distance)
Set the distance of the observer to the globe in km.
Definition: MarbleWidget.cpp:1197
Marble::RoutingProfile::Motorcar
Definition: RoutingProfile.h:30
Marble::RouteRequest::at
GeoDataCoordinates at(int index) const
Accessor for the n-th position.
Definition: RouteRequest.cpp:149
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal