2011-10-10 11:52:47 -04:00
|
|
|
/*
|
|
|
|
open source routing machine
|
|
|
|
Copyright (C) Dennis Luxen, others 2010
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU AFFERO General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
or see http://www.gnu.org/licenses/agpl.txt.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This class constructs the edge base representation of a graph from a given node based edge list
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef EDGEBASEDGRAPHFACTORY_H_
|
|
|
|
#define EDGEBASEDGRAPHFACTORY_H_
|
|
|
|
|
2011-11-09 10:12:05 -05:00
|
|
|
#include <boost/shared_ptr.hpp>
|
2012-02-28 10:25:01 -05:00
|
|
|
#include <boost/property_tree/ptree.hpp>
|
|
|
|
#include <boost/property_tree/ini_parser.hpp>
|
|
|
|
|
2011-10-10 11:52:47 -04:00
|
|
|
#include <vector>
|
2012-04-26 05:19:45 -04:00
|
|
|
#include <stxxl.h>
|
2012-02-28 10:25:01 -05:00
|
|
|
#include <cstdlib>
|
|
|
|
|
2011-11-09 10:12:05 -05:00
|
|
|
#include "../typedefs.h"
|
2012-05-23 15:18:38 -04:00
|
|
|
#include "../DataStructures/DeallocatingVector.h"
|
2011-11-09 10:12:05 -05:00
|
|
|
#include "../DataStructures/DynamicGraph.h"
|
|
|
|
#include "../DataStructures/ExtractorStructs.h"
|
2012-01-02 07:09:20 -05:00
|
|
|
#include "../DataStructures/HashTable.h"
|
2011-11-09 10:12:05 -05:00
|
|
|
#include "../DataStructures/ImportEdge.h"
|
2012-04-25 04:51:16 -04:00
|
|
|
#include "../DataStructures/QueryEdge.h"
|
2011-11-09 10:12:05 -05:00
|
|
|
#include "../DataStructures/Percent.h"
|
2011-11-17 12:04:49 -05:00
|
|
|
#include "../DataStructures/TurnInstructions.h"
|
2012-02-28 10:25:01 -05:00
|
|
|
#include "../Util/BaseConfiguration.h"
|
|
|
|
|
2011-12-14 13:01:57 -05:00
|
|
|
//#include "../Util/SRTMLookup.h"
|
2011-11-09 10:12:05 -05:00
|
|
|
|
2011-10-10 11:52:47 -04:00
|
|
|
class EdgeBasedGraphFactory {
|
|
|
|
private:
|
|
|
|
struct _NodeBasedEdgeData {
|
2011-11-16 11:29:00 -05:00
|
|
|
int distance;
|
2011-11-14 07:12:56 -05:00
|
|
|
unsigned edgeBasedNodeID;
|
2011-12-16 08:05:30 -05:00
|
|
|
unsigned nameID:31;
|
2011-11-25 06:02:52 -05:00
|
|
|
bool shortcut:1;
|
|
|
|
bool forward:1;
|
|
|
|
bool backward:1;
|
|
|
|
bool roundabout:1;
|
2011-12-16 08:05:30 -05:00
|
|
|
bool ignoreInGrid:1;
|
2011-11-14 07:12:56 -05:00
|
|
|
short type;
|
2012-03-22 05:25:04 -04:00
|
|
|
bool isAccessRestricted;
|
2012-03-01 08:36:10 -05:00
|
|
|
};
|
2011-10-10 11:52:47 -04:00
|
|
|
|
2011-11-09 10:12:05 -05:00
|
|
|
struct _EdgeBasedEdgeData {
|
2011-11-16 11:29:00 -05:00
|
|
|
int distance;
|
2011-11-14 07:12:56 -05:00
|
|
|
unsigned via;
|
2011-11-16 12:10:51 -05:00
|
|
|
unsigned nameID;
|
2011-11-09 10:12:05 -05:00
|
|
|
bool forward;
|
|
|
|
bool backward;
|
2011-11-14 07:12:56 -05:00
|
|
|
short turnInstruction;
|
2011-11-09 10:12:05 -05:00
|
|
|
};
|
|
|
|
|
2011-10-10 11:52:47 -04:00
|
|
|
typedef DynamicGraph< _NodeBasedEdgeData > _NodeBasedDynamicGraph;
|
2011-11-09 10:12:05 -05:00
|
|
|
typedef _NodeBasedDynamicGraph::InputEdge _NodeBasedEdge;
|
|
|
|
|
|
|
|
public:
|
2011-11-14 07:12:56 -05:00
|
|
|
struct EdgeBasedNode {
|
|
|
|
bool operator<(const EdgeBasedNode & other) const {
|
|
|
|
return other.id < id;
|
|
|
|
}
|
|
|
|
bool operator==(const EdgeBasedNode & other) const {
|
|
|
|
return id == other.id;
|
|
|
|
}
|
2012-05-11 09:11:13 -04:00
|
|
|
NodeID id;
|
2011-11-14 07:12:56 -05:00
|
|
|
int lat1;
|
|
|
|
int lat2;
|
|
|
|
int lon1;
|
|
|
|
int lon2;
|
2011-11-15 10:24:13 -05:00
|
|
|
NodeID nameID;
|
2012-03-01 08:36:10 -05:00
|
|
|
unsigned weight:31;
|
|
|
|
bool ignoreInGrid:1;
|
2011-11-14 07:12:56 -05:00
|
|
|
};
|
|
|
|
|
2011-11-09 10:12:05 -05:00
|
|
|
private:
|
2012-02-28 10:25:01 -05:00
|
|
|
boost::shared_ptr<_NodeBasedDynamicGraph> _nodeBasedGraph;
|
|
|
|
boost::unordered_map<NodeID, bool> _barrierNodes;
|
|
|
|
boost::unordered_map<NodeID, bool> _trafficLights;
|
2011-11-09 10:12:05 -05:00
|
|
|
|
2012-02-29 14:02:04 -05:00
|
|
|
typedef std::pair<NodeID, NodeID> RestrictionSource;
|
|
|
|
typedef std::pair<NodeID, bool> RestrictionTarget;
|
|
|
|
typedef std::vector<RestrictionTarget> EmanatingRestrictionsVector;
|
|
|
|
typedef boost::unordered_map<RestrictionSource, unsigned > RestrictionMap;
|
|
|
|
std::vector<EmanatingRestrictionsVector> _restrictionBucketVector;
|
|
|
|
RestrictionMap _restrictionMap;
|
|
|
|
|
2011-10-10 11:52:47 -04:00
|
|
|
|
2012-05-23 15:18:38 -04:00
|
|
|
DeallocatingVector<EdgeBasedEdge> edgeBasedEdges;
|
2012-04-25 12:36:18 -04:00
|
|
|
std::vector<EdgeBasedNode> edgeBasedNodes;
|
|
|
|
std::vector<OriginalEdgeData> originalEdgeData;
|
|
|
|
std::vector<NodeInfo> inputNodeInfoList;
|
2011-10-10 11:52:47 -04:00
|
|
|
|
2012-02-29 14:02:04 -05:00
|
|
|
NodeID CheckForEmanatingIsOnlyTurn(const NodeID u, const NodeID v) const;
|
|
|
|
bool CheckIfTurnIsRestricted(const NodeID u, const NodeID v, const NodeID w) const;
|
2012-03-01 13:41:06 -05:00
|
|
|
void InsertEdgeBasedNode(
|
|
|
|
_NodeBasedDynamicGraph::EdgeIterator e1,
|
|
|
|
_NodeBasedDynamicGraph::NodeIterator u,
|
|
|
|
_NodeBasedDynamicGraph::NodeIterator v);
|
2011-11-22 10:47:15 -05:00
|
|
|
template<class CoordinateT>
|
|
|
|
double GetAngleBetweenTwoEdges(const CoordinateT& A, const CoordinateT& C, const CoordinateT& B) const;
|
2011-12-14 13:01:57 -05:00
|
|
|
// SRTMLookup srtmLookup;
|
2012-02-29 14:02:04 -05:00
|
|
|
unsigned numberOfTurnRestrictions;
|
2012-03-05 03:36:20 -05:00
|
|
|
unsigned trafficSignalPenalty;
|
2012-03-20 07:35:52 -04:00
|
|
|
unsigned uturnPenalty;
|
|
|
|
bool takeMinimumOfSpeeds;
|
2011-12-14 13:01:57 -05:00
|
|
|
|
2011-10-10 11:52:47 -04:00
|
|
|
public:
|
|
|
|
template< class InputEdgeT >
|
2012-02-28 10:25:01 -05:00
|
|
|
explicit EdgeBasedGraphFactory(int nodes, std::vector<InputEdgeT> & inputEdges, std::vector<NodeID> & _bollardNodes, std::vector<NodeID> & trafficLights, std::vector<_Restriction> & inputRestrictions, std::vector<NodeInfo> & nI, boost::property_tree::ptree speedProfile, std::string & srtm);
|
2011-10-10 11:52:47 -04:00
|
|
|
|
2012-04-27 10:50:34 -04:00
|
|
|
void Run(const char * originalEdgeDataFilename);
|
2012-05-23 15:18:38 -04:00
|
|
|
void GetEdgeBasedEdges( DeallocatingVector< EdgeBasedEdge >& edges );
|
2011-11-14 07:12:56 -05:00
|
|
|
void GetEdgeBasedNodes( std::vector< EdgeBasedNode> & nodes);
|
2012-04-25 04:51:16 -04:00
|
|
|
void GetOriginalEdgeData( std::vector< OriginalEdgeData> & originalEdgeData);
|
2011-11-17 12:04:49 -05:00
|
|
|
short AnalyzeTurn(const NodeID u, const NodeID v, const NodeID w) const;
|
2011-11-09 10:12:05 -05:00
|
|
|
unsigned GetNumberOfNodes() const;
|
2011-10-10 11:52:47 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* EDGEBASEDGRAPHFACTORY_H_ */
|