2011-10-10 11:52:47 -04:00
|
|
|
/*
|
2013-10-14 07:42:28 -04:00
|
|
|
|
|
|
|
Copyright (c) 2013, Project OSRM, Dennis Luxen, others
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
Redistributions of source code must retain the above copyright notice, this list
|
|
|
|
of conditions and the following disclaimer.
|
|
|
|
Redistributions in binary form must reproduce the above copyright notice, this
|
|
|
|
list of conditions and the following disclaimer in the documentation and/or
|
|
|
|
other materials provided with the distribution.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
|
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
*/
|
2011-10-10 11:52:47 -04:00
|
|
|
|
2013-08-14 12:43:01 -04:00
|
|
|
// This class constructs the edge-expanded routing graph
|
2011-10-10 11:52:47 -04:00
|
|
|
|
|
|
|
#ifndef EDGEBASEDGRAPHFACTORY_H_
|
|
|
|
#define EDGEBASEDGRAPHFACTORY_H_
|
|
|
|
|
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"
|
2013-10-11 10:14:59 -04:00
|
|
|
#include "../DataStructures/EdgeBasedNode.h"
|
2012-01-02 07:09:20 -05:00
|
|
|
#include "../DataStructures/HashTable.h"
|
2013-12-09 11:45:45 -05:00
|
|
|
#include "../DataStructures/OriginalEdgeData.h"
|
2011-11-09 10:12:05 -05:00
|
|
|
#include "../DataStructures/Percent.h"
|
2013-11-25 13:05:58 -05:00
|
|
|
#include "../DataStructures/QueryEdge.h"
|
2014-01-09 10:13:35 -05:00
|
|
|
#include "../DataStructures/QueryNode.h"
|
2011-11-17 12:04:49 -05:00
|
|
|
#include "../DataStructures/TurnInstructions.h"
|
2014-01-09 10:13:35 -05:00
|
|
|
#include "../DataStructures/Restriction.h"
|
2014-05-05 19:35:43 -04:00
|
|
|
#include "../DataStructures/NodeBasedGraph.h"
|
|
|
|
#include "../DataStructures/RestrictionMap.h"
|
2013-06-26 09:49:00 -04:00
|
|
|
#include "../Util/LuaUtil.h"
|
2013-08-08 08:17:01 -04:00
|
|
|
#include "../Util/SimpleLogger.h"
|
2012-02-28 10:25:01 -05:00
|
|
|
|
2013-11-25 13:05:58 -05:00
|
|
|
#include "GeometryCompressor.h"
|
|
|
|
|
2013-06-26 09:49:00 -04:00
|
|
|
#include <boost/noncopyable.hpp>
|
|
|
|
#include <boost/unordered_map.hpp>
|
|
|
|
#include <boost/unordered_set.hpp>
|
|
|
|
|
|
|
|
#include <algorithm>
|
2014-01-04 06:10:22 -05:00
|
|
|
#include <iosfwd>
|
2013-06-26 09:49:00 -04:00
|
|
|
#include <queue>
|
|
|
|
#include <vector>
|
2013-02-23 02:33:33 -05:00
|
|
|
|
2014-05-08 17:07:16 -04:00
|
|
|
class EdgeBasedGraphFactory : boost::noncopyable
|
|
|
|
{
|
|
|
|
public:
|
2014-01-04 06:10:22 -05:00
|
|
|
struct SpeedProfileProperties;
|
2013-01-18 15:28:13 -05:00
|
|
|
|
2014-05-08 17:22:49 -04:00
|
|
|
explicit EdgeBasedGraphFactory(const std::shared_ptr<NodeBasedDynamicGraph> &node_based_graph,
|
2014-05-08 17:07:16 -04:00
|
|
|
std::unique_ptr<RestrictionMap> restricion_map,
|
|
|
|
std::vector<NodeID> &barrier_node_list,
|
|
|
|
std::vector<NodeID> &traffic_light_node_list,
|
|
|
|
std::vector<NodeInfo> &m_node_info_list,
|
|
|
|
SpeedProfileProperties &speed_profile);
|
|
|
|
|
|
|
|
void Run(const std::string &original_edge_data_filename,
|
|
|
|
const std::string &geometry_filename,
|
|
|
|
lua_State *myLuaState);
|
|
|
|
|
|
|
|
void GetEdgeBasedEdges(DeallocatingVector<EdgeBasedEdge> &edges);
|
|
|
|
|
|
|
|
void GetEdgeBasedNodes(std::vector<EdgeBasedNode> &nodes);
|
|
|
|
|
|
|
|
TurnInstruction AnalyzeTurn(const NodeID u, const NodeID v, const NodeID w) const;
|
|
|
|
|
|
|
|
int GetTurnPenalty(const NodeID u, const NodeID v, const NodeID w, lua_State *myLuaState) const;
|
2013-08-14 05:59:46 -04:00
|
|
|
|
2014-02-11 05:42:24 -05:00
|
|
|
unsigned GetNumberOfEdgeBasedNodes() const;
|
2013-08-14 05:59:46 -04:00
|
|
|
|
2014-05-08 17:07:16 -04:00
|
|
|
struct SpeedProfileProperties
|
|
|
|
{
|
|
|
|
SpeedProfileProperties()
|
|
|
|
: trafficSignalPenalty(0), uTurnPenalty(0), has_turn_penalty_function(false)
|
|
|
|
{
|
|
|
|
}
|
2014-01-04 06:10:22 -05:00
|
|
|
|
|
|
|
int trafficSignalPenalty;
|
|
|
|
int uTurnPenalty;
|
|
|
|
bool has_turn_penalty_function;
|
|
|
|
} speed_profile;
|
|
|
|
|
2014-05-08 17:07:16 -04:00
|
|
|
private:
|
2013-08-14 12:43:01 -04:00
|
|
|
typedef NodeBasedDynamicGraph::NodeIterator NodeIterator;
|
|
|
|
typedef NodeBasedDynamicGraph::EdgeIterator EdgeIterator;
|
2014-05-08 17:07:16 -04:00
|
|
|
typedef NodeBasedDynamicGraph::EdgeData EdgeData;
|
2014-05-05 19:35:43 -04:00
|
|
|
|
|
|
|
unsigned m_number_of_edge_based_nodes;
|
2012-09-13 08:12:44 -04:00
|
|
|
|
2014-05-08 17:07:16 -04:00
|
|
|
std::vector<NodeInfo> m_node_info_list;
|
|
|
|
std::vector<EdgeBasedNode> m_edge_based_node_list;
|
|
|
|
DeallocatingVector<EdgeBasedEdge> m_edge_based_edge_list;
|
2011-11-09 10:12:05 -05:00
|
|
|
|
2014-05-08 17:22:49 -04:00
|
|
|
std::shared_ptr<NodeBasedDynamicGraph> m_node_based_graph;
|
2014-05-08 17:07:16 -04:00
|
|
|
boost::unordered_set<NodeID> m_barrier_nodes;
|
|
|
|
boost::unordered_set<NodeID> m_traffic_lights;
|
2013-08-14 12:43:01 -04:00
|
|
|
|
2014-05-08 17:07:16 -04:00
|
|
|
std::unique_ptr<RestrictionMap> m_restriction_map;
|
2014-05-05 19:35:43 -04:00
|
|
|
|
2014-05-08 17:07:16 -04:00
|
|
|
GeometryCompressor m_geometry_compressor;
|
2012-02-29 14:02:04 -05:00
|
|
|
|
2014-05-06 19:03:45 -04:00
|
|
|
void CompressGeometry();
|
|
|
|
void RenumberEdges();
|
|
|
|
void GenerateEdgeExpandedNodes();
|
2014-05-08 17:07:16 -04:00
|
|
|
void GenerateEdgeExpandedEdges(const std::string &original_edge_data_filename,
|
|
|
|
lua_State *lua_state);
|
|
|
|
|
|
|
|
void InsertEdgeBasedNode(NodeBasedDynamicGraph::NodeIterator u,
|
|
|
|
NodeBasedDynamicGraph::NodeIterator v,
|
|
|
|
NodeBasedDynamicGraph::EdgeIterator e1,
|
|
|
|
bool belongsToTinyComponent);
|
|
|
|
|
|
|
|
void FlushVectorToStream(std::ofstream &edge_data_file,
|
|
|
|
std::vector<OriginalEdgeData> &original_edge_data_vector) const;
|
2014-01-04 06:10:22 -05:00
|
|
|
|
2014-03-19 11:42:37 -04:00
|
|
|
unsigned max_id;
|
2011-10-10 11:52:47 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* EDGEBASEDGRAPHFACTORY_H_ */
|