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

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • lib
  • marble
  • routing
  • instructions
InstructionTransformation.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 2010 Dennis Nienhüser <earthwings@gentoo.org>
9 //
10 
11 #include "InstructionTransformation.h"
12 
13 #include <cmath>
14 
15 namespace Marble
16 {
17 
18 RoutingInstructions InstructionTransformation::process( const RoutingWaypoints &model )
19 {
20  RoutingInstructions result;
21 
22  int lastAngle = 0;
23  for( int i = 0; i < model.size(); ++i ) {
24  const RoutingWaypoint &item = model[i];
25  int newAngle = 180 + lastAngle;
26  if ( i < model.size() - 1 ) {
27  newAngle = qRound( 180.0 / M_PI * item.point().bearing( model[i+1].point() ) );
28  }
29  int angle = ( newAngle - lastAngle + 540 ) % 360;
30  Q_ASSERT( angle >= 0 && angle <= 360 );
31  if ( result.isEmpty() || !result.last().append( item, angle ) ) {
32  result.push_back( RoutingInstruction( item ) );
33  }
34  lastAngle = newAngle;
35  }
36 
37  for ( int i = 0; i < result.size(); ++i ) {
38  result[i].setSuccessor( i < result.size() - 1 ? &result[i+1] : 0 );
39  result[i].setPredecessor( i ? &result[i-1] : 0 );
40  }
41 
42  return result;
43 }
44 
45 } // namespace Marble
Marble::RoutingInstruction
Stores data related to one instruction: Road name, angle to predecessor, associated waypoints etc...
Definition: RoutingInstruction.h:29
angle
double angle(double vec1[3], double vec2[3])
Definition: sgp4ext.cpp:164
QVector::last
T & last()
Marble::RoutingWaypoint::point
RoutingPoint point() const
Associated geo point.
Definition: RoutingWaypoint.cpp:33
InstructionTransformation.h
Marble::InstructionTransformation::process
static RoutingInstructions process(const RoutingWaypoints &waypoints)
Transforms waypoints and metadata into driving directions.
Definition: InstructionTransformation.cpp:18
QVector
QVector::isEmpty
bool isEmpty() const
Marble::RoutingPoint::bearing
qreal bearing(const RoutingPoint &other) const
Calculates the bearing of the line defined by this point and the given other point.
Definition: RoutingPoint.cpp:36
M_PI
#define M_PI
Definition: GeoDataCoordinates.h:26
QVector::push_back
void push_back(const T &value)
QVector::size
int size() const
Marble::RoutingWaypoint
Stores one line of gosmore/routino output.
Definition: RoutingWaypoint.h:25
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:39 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
  • 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