2013-09-17 12:35:43 -04:00
|
|
|
/*
|
2013-10-21 05:45:16 -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.
|
|
|
|
|
|
|
|
*/
|
2013-09-17 12:35:43 -04:00
|
|
|
|
|
|
|
#ifndef QUERY_DATA_FACADE_H
|
|
|
|
#define QUERY_DATA_FACADE_H
|
|
|
|
|
|
|
|
//Exposes all data access interfaces to the algorithms via base class ptr
|
|
|
|
|
|
|
|
#include "../../DataStructures/Coordinate.h"
|
2013-10-11 10:14:59 -04:00
|
|
|
#include "../../DataStructures/EdgeBasedNode.h"
|
|
|
|
#include "../../DataStructures/ImportNode.h"
|
2013-09-17 12:35:43 -04:00
|
|
|
#include "../../DataStructures/PhantomNodes.h"
|
|
|
|
#include "../../DataStructures/TurnInstructions.h"
|
2013-09-18 11:49:49 -04:00
|
|
|
#include "../../Util/OSRMException.h"
|
2013-09-19 12:55:49 -04:00
|
|
|
#include "../../Util/StringUtil.h"
|
2013-09-17 12:35:43 -04:00
|
|
|
#include "../../typedefs.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2013-09-17 12:45:33 -04:00
|
|
|
template<class EdgeDataT>
|
2013-09-17 12:55:53 -04:00
|
|
|
class BaseDataFacade {
|
2013-09-17 12:35:43 -04:00
|
|
|
public:
|
2013-10-11 10:14:59 -04:00
|
|
|
typedef EdgeBasedNode RTreeLeaf;
|
2013-09-19 12:55:49 -04:00
|
|
|
typedef EdgeDataT EdgeData;
|
2013-09-20 12:30:47 -04:00
|
|
|
BaseDataFacade( ) { }
|
2013-09-17 12:55:53 -04:00
|
|
|
virtual ~BaseDataFacade() { }
|
2013-09-17 12:35:43 -04:00
|
|
|
|
|
|
|
//search graph access
|
2013-09-17 12:45:33 -04:00
|
|
|
virtual unsigned GetNumberOfNodes() const = 0;
|
|
|
|
|
|
|
|
virtual unsigned GetNumberOfEdges() const = 0;
|
|
|
|
|
|
|
|
virtual unsigned GetOutDegree( const NodeID n ) const = 0;
|
|
|
|
|
|
|
|
virtual NodeID GetTarget( const EdgeID e ) const = 0;
|
|
|
|
|
|
|
|
virtual EdgeDataT &GetEdgeData( const EdgeID e ) = 0;
|
|
|
|
|
2013-09-23 13:00:08 -04:00
|
|
|
// virtual const EdgeDataT &GetEdgeData( const EdgeID e ) const = 0;
|
2013-09-17 12:45:33 -04:00
|
|
|
|
|
|
|
virtual EdgeID BeginEdges( const NodeID n ) const = 0;
|
|
|
|
|
|
|
|
virtual EdgeID EndEdges( const NodeID n ) const = 0;
|
|
|
|
|
|
|
|
//searches for a specific edge
|
|
|
|
virtual EdgeID FindEdge( const NodeID from, const NodeID to ) const = 0;
|
|
|
|
|
|
|
|
virtual EdgeID FindEdgeInEitherDirection(
|
|
|
|
const NodeID from,
|
|
|
|
const NodeID to
|
|
|
|
) const = 0;
|
|
|
|
|
|
|
|
virtual EdgeID FindEdgeIndicateIfReverse(
|
|
|
|
const NodeID from,
|
|
|
|
const NodeID to,
|
|
|
|
bool & result
|
|
|
|
) const = 0;
|
|
|
|
|
2013-09-17 12:55:53 -04:00
|
|
|
//node and edge information access
|
|
|
|
virtual FixedPointCoordinate GetCoordinateOfNode(
|
|
|
|
const unsigned id
|
|
|
|
) const = 0;
|
2013-09-17 12:45:33 -04:00
|
|
|
|
2013-10-15 09:44:35 -04:00
|
|
|
virtual TurnInstruction GetTurnInstructionForEdgeID(
|
|
|
|
const unsigned id
|
|
|
|
) const = 0;
|
2013-09-17 12:45:33 -04:00
|
|
|
|
|
|
|
virtual bool LocateClosestEndPointForCoordinate(
|
|
|
|
const FixedPointCoordinate& input_coordinate,
|
|
|
|
FixedPointCoordinate& result,
|
|
|
|
const unsigned zoom_level = 18
|
|
|
|
) const = 0;
|
|
|
|
|
2013-10-15 09:44:35 -04:00
|
|
|
virtual bool FindPhantomNodeForCoordinate(
|
|
|
|
const FixedPointCoordinate & input_coordinate,
|
|
|
|
PhantomNode & resulting_phantom_node,
|
|
|
|
const unsigned zoom_level
|
|
|
|
) const = 0;
|
2013-09-17 12:45:33 -04:00
|
|
|
|
2013-10-15 09:44:35 -04:00
|
|
|
virtual unsigned GetCheckSum() const = 0;
|
2013-09-17 12:45:33 -04:00
|
|
|
|
2013-09-19 12:55:49 -04:00
|
|
|
virtual unsigned GetNameIndexFromEdgeID(const unsigned id) const = 0;
|
|
|
|
|
2013-10-15 09:44:35 -04:00
|
|
|
virtual void GetName(
|
|
|
|
const unsigned name_id,
|
|
|
|
std::string & result
|
|
|
|
) const = 0;
|
|
|
|
|
2013-09-19 12:55:49 -04:00
|
|
|
std::string GetEscapedNameForNameID(const unsigned name_id) const {
|
|
|
|
std::string temporary_string;
|
|
|
|
GetName(name_id, temporary_string);
|
|
|
|
return HTMLEntitize(temporary_string);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual std::string GetTimestamp() const = 0;
|
2013-09-17 12:35:43 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // QUERY_DATA_FACADE_H
|