OLD | NEW |
(Empty) | |
| 1 |
| 2 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 3 /* |
| 4 * Copyright (c) 2014 CISTER - Research Center in Real-Time & Embedded Computing
Systems |
| 5 * |
| 6 * This program is free software; you can redistribute it and/or modify |
| 7 * it under the terms of the GNU General Public License version 2 as |
| 8 * published by the Free Software Foundation; |
| 9 * |
| 10 * This program is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 * GNU General Public License for more details. |
| 14 * |
| 15 * You should have received a copy of the GNU General Public License |
| 16 * along with this program; if not, write to the Free Software |
| 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 * |
| 19 * Author: Tiago Cerqueira <1090678@isep.ipp.pt> <tiago.miguel43@gmail.com> |
| 20 * Author: Michele Albano <mialb@isep.ipp.pt> <michele.albano@gmail.com@gmail.co
m> |
| 21 */ |
| 22 #ifndef GOOGLEMAPSDECODER_H |
| 23 #define GOOGLEMAPSDECODER_H |
| 24 #include <string> |
| 25 #include <iostream> |
| 26 #include <list> |
| 27 #include <GeographicLib/Geocentric.hpp> |
| 28 #include <GeographicLib/LocalCartesian.hpp> |
| 29 |
| 30 #include <ns3/pointer.h> |
| 31 |
| 32 #include "leg.h" |
| 33 namespace ns3 { |
| 34 |
| 35 /** |
| 36 * \ingroup mobility |
| 37 * \brief This class is responsible for decoding the information received from t
he Google Maps Directions API |
| 38 * |
| 39 * The information received from the Google Maps Directions API cannot be used b
y ns3 as it is. The coordinates of the points are encoded in a format called a p
olyline. |
| 40 * A polyline is a string representation of a set of points. This class is respo
nsible for decoding the polylines, convert from Geodetic coordinates (WSG84) to
Cartesian coordinates and fill up the time information for the points of the pol
ylines |
| 41 */ |
| 42 class GoogleMapsDecoder |
| 43 { |
| 44 public: |
| 45 /** |
| 46 * \brief Creates a GoogleMapsDecoder object |
| 47 * |
| 48 * Creates a GoogleMapsDecoder object, setting its attributes to the default v
alues |
| 49 */ |
| 50 GoogleMapsDecoder (); |
| 51 /** |
| 52 * \brief Creates a GoogleMapsDecoder object |
| 53 * |
| 54 * Creates a GoogleMapsDecoder object setting the center of the Cartesian plan
e to the parameters passed. |
| 55 * |
| 56 * \param lat The latitude of the point which will serve as the center of the
Cartesian plane |
| 57 * \param lng The longitude of the point which will serve as the center of the
Cartesian plane |
| 58 * \param altitude The altitude of the point which will serve as the center of
the Cartesian plane |
| 59 */ |
| 60 GoogleMapsDecoder (double lat, double lng, double altitude); |
| 61 /** |
| 62 * \brief Creates a GoogleMapsDecoder object |
| 63 * |
| 64 * Standard copy constructor |
| 65 * \param orig The object to copy from |
| 66 */ |
| 67 GoogleMapsDecoder (const GoogleMapsDecoder& orig); |
| 68 virtual ~GoogleMapsDecoder (); |
| 69 /** |
| 70 * \brief Converts the latitude and longitude of all points into Cartesian coo
rdinates |
| 71 * |
| 72 * This function takes a LegList and converts the latitude and longitude of al
l the points to Cartesian coordinates |
| 73 * \param legList |
| 74 */ |
| 75 int ConvertToCartesian (LegList& legList); |
| 76 private: |
| 77 GeographicLib::Geocentric m_earth; |
| 78 GeographicLib::LocalCartesian m_proj; |
| 79 /** |
| 80 * \brief Converts the polyline passed as the argument into Points |
| 81 * |
| 82 * This function fills the std::list<Ptr<Point> > passed to the function with
all the points in the given polyline |
| 83 * \param polyline The polyline to decode |
| 84 * \param pointList The std::list to fill with Points |
| 85 */ |
| 86 int ConvertToGeoCoordinates (std::string polyline, std::list< Ptr<Point> > &po
intList); |
| 87 /** |
| 88 * \brief Calculates the distance between two points |
| 89 * |
| 90 * \param x1 The X coordinate of Point 1 |
| 91 * \param x2 The X coordinate of Point 2 |
| 92 * \param y1 The Y coordinate of Point 1 |
| 93 * \param y2 The Y coordinate of Point 2 |
| 94 * \return a double which represents the distance between the two points |
| 95 */ |
| 96 double CalculatePartialDistance (double x1, double x2, double y1, double y2); |
| 97 //returns the last waypoint time. Maybe create a offset variable to separate s
teps in time, if needed |
| 98 /** |
| 99 * \brief Calculates the time at which this Point should be reached |
| 100 * |
| 101 * In order to add realism to the mobility trace, the time attribute of the po
ints needs to be set realistically. |
| 102 * This function computes the time it would take for a node to reach the given
point, in practice, creating motion that resembles its real-world counterpart. |
| 103 * \param startAt This attribute contains the time information from the previo
us point in the Step |
| 104 * \param totalDistanceInStep The total distance spanned by the Step. This val
ue is calculated |
| 105 * \param p1 The previous Point of the std::list of Points |
| 106 * \param p2 This Point will receive the calculated time |
| 107 * \param travelTime The total time it takes to go through the Step. This attr
ibute is originally received from the Google Maps API. |
| 108 * \return Returns 0 if the function exists without errors |
| 109 */ |
| 110 int SetWaypointTime (double startAt, double totalDistanceInStep, Ptr<Point> p1
, Ptr<Point> p2, double travelTime); |
| 111 /** |
| 112 * \brief Fills the time of all the Points in the std::list<Ptr<Point> > |
| 113 * |
| 114 * This function iterates through the std::list<Ptr<Point> > to set the time o
f all Points |
| 115 * \param pointList The list of Points |
| 116 * \param totalDistanceInStep The total distance of that Step |
| 117 * \param stepListBegin An iterator to the beginning of the StepList |
| 118 * \param currentStepPosition An iterator to the current Step position in the
StepList |
| 119 * \param legListBegin An iterator to the beginning of the LegList |
| 120 * \param currentLegPosition An iterator to the current Leg position in the Le
gList |
| 121 * \param travelTime The total time it takes to go through this Step. This val
ue is obtained directly from the Google Maps API. |
| 122 */ |
| 123 void FillInWaypointTime (std::list<Ptr<Point> > &pointList, double totalDistan
ceInStep, |
| 124 std::list<Ptr<Step> >::iterator stepListBegin, std::list<Ptr<Step> >::iterat
or currentStepPosition, |
| 125 std::list<Ptr<Leg> >::iterator legListBegin, std::list<Ptr<Leg> >::iterator
currentLegPosition, double travelTime); |
| 126 }; |
| 127 } //namespace ns3 |
| 128 #endif /* GOOGLEMAPSDECODER_H */ |
| 129 |
OLD | NEW |