osrm-backend/Contractor/EdgeBasedGraphFactory.h

111 lines
3.3 KiB
C
Raw Normal View History

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_
#include <boost/shared_ptr.hpp>
2011-10-10 11:52:47 -04:00
#include <vector>
#include "../typedefs.h"
#include "../DataStructures/DynamicGraph.h"
#include "../DataStructures/ExtractorStructs.h"
#include "../DataStructures/ImportEdge.h"
#include "../DataStructures/Percent.h"
2011-11-17 12:04:49 -05:00
#include "../DataStructures/TurnInstructions.h"
2011-10-10 11:52:47 -04:00
class EdgeBasedGraphFactory {
private:
union _MiddleName {
unsigned middle;
unsigned nameID;
};
struct _NodeBasedEdgeData {
2011-11-16 11:29:00 -05:00
int distance;
2011-11-14 07:12:56 -05:00
unsigned edgeBasedNodeID;
unsigned originalEdges;
bool shortcut;
bool forward;
bool backward;
short type;
2011-10-10 11:52:47 -04:00
_MiddleName middleName;
} data;
struct _EdgeBasedEdgeData {
2011-11-16 11:29:00 -05:00
int distance;
2011-11-14 07:12:56 -05:00
unsigned via;
unsigned nameID;
bool forward;
bool backward;
2011-11-14 07:12:56 -05:00
short turnInstruction;
};
2011-10-10 11:52:47 -04:00
typedef DynamicGraph< _NodeBasedEdgeData > _NodeBasedDynamicGraph;
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;
}
int lat1;
int lat2;
int lon1;
int lon2;
NodeID id;
2011-11-15 10:24:13 -05:00
NodeID nameID;
2011-11-16 11:29:00 -05:00
unsigned weight;
2011-11-14 07:12:56 -05:00
};
typedef DynamicGraph< _EdgeBasedEdgeData> _EdgeBasedDynamicGraph;
typedef _EdgeBasedDynamicGraph::InputEdge _EdgeBasedEdge;
private:
boost::shared_ptr<_NodeBasedDynamicGraph> _nodeBasedGraph;
boost::shared_ptr<_EdgeBasedDynamicGraph> _edgeBasedGraph;
std::vector<_Restriction> & inputRestrictions;
2011-11-14 07:12:56 -05:00
std::vector<NodeInfo> & inputNodeInfoList;
2011-10-10 11:52:47 -04:00
std::vector<_EdgeBasedEdge> edgeBasedEdges;
2011-11-14 07:12:56 -05:00
std::vector<EdgeBasedNode> edgeBasedNodes;
2011-10-10 11:52:47 -04:00
public:
template< class InputEdgeT >
2011-11-14 07:12:56 -05:00
explicit EdgeBasedGraphFactory(int nodes, std::vector<InputEdgeT> & inputEdges, std::vector<_Restriction> & inputRestrictions, std::vector<NodeInfo> & nI);
2011-10-10 11:52:47 -04:00
virtual ~EdgeBasedGraphFactory();
void Run();
template< class ImportEdgeT >
2011-11-14 07:12:56 -05:00
void GetEdgeBasedEdges( std::vector< ImportEdgeT >& edges );
void GetEdgeBasedNodes( std::vector< EdgeBasedNode> & nodes);
2011-11-17 12:04:49 -05:00
short AnalyzeTurn(const NodeID u, const NodeID v, const NodeID w) const;
unsigned GetNumberOfNodes() const;
2011-10-10 11:52:47 -04:00
};
#endif /* EDGEBASEDGRAPHFACTORY_H_ */