Fix one-way restriction when doing reverse search
This commit is contained in:
parent
5bfd56d56e
commit
32ed39c61a
@ -24,7 +24,8 @@ struct Connection {
|
|||||||
uint8_t speedLimit;
|
uint8_t speedLimit;
|
||||||
bool motorway;
|
bool motorway;
|
||||||
bool tunnel;
|
bool tunnel;
|
||||||
bool againstOneWay;
|
bool passableSameDirection;
|
||||||
|
bool passableOppositeDirection;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RoadNode{
|
struct RoadNode{
|
||||||
@ -124,7 +125,7 @@ float getFloatFromBuffer(char* buffer) {
|
|||||||
return *((float*) &correctByteOrder);
|
return *((float*) &correctByteOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addLinkToRoadNode(RoadNode* roadNodes, uint32_t nodeFrom, uint32_t nodeTo, uint8_t speedLimit, bool motorway, bool tunnel, bool againstOneWay) {
|
void addLinkToRoadNode(RoadNode* roadNodes, uint32_t nodeFrom, uint32_t nodeTo, uint8_t speedLimit, bool motorway, bool tunnel, bool passableSameDirection, bool passableOppositeDirection) {
|
||||||
float fromX = roadNodes[nodeFrom].positionX;
|
float fromX = roadNodes[nodeFrom].positionX;
|
||||||
float fromY = roadNodes[nodeFrom].positionY;
|
float fromY = roadNodes[nodeFrom].positionY;
|
||||||
float toX = roadNodes[nodeTo].positionX;
|
float toX = roadNodes[nodeTo].positionX;
|
||||||
@ -140,7 +141,8 @@ void addLinkToRoadNode(RoadNode* roadNodes, uint32_t nodeFrom, uint32_t nodeTo,
|
|||||||
connection.speedLimit = speedLimit;
|
connection.speedLimit = speedLimit;
|
||||||
connection.motorway = motorway;
|
connection.motorway = motorway;
|
||||||
connection.tunnel = tunnel;
|
connection.tunnel = tunnel;
|
||||||
connection.againstOneWay = againstOneWay;
|
connection.passableSameDirection = passableSameDirection;
|
||||||
|
connection.passableOppositeDirection = passableOppositeDirection;
|
||||||
|
|
||||||
if (roadNodes[nodeFrom].connectionOne.connectedPointNumber == -1) {
|
if (roadNodes[nodeFrom].connectionOne.connectedPointNumber == -1) {
|
||||||
roadNodes[nodeFrom].connectionOne = connection;
|
roadNodes[nodeFrom].connectionOne = connection;
|
||||||
@ -209,8 +211,8 @@ void loadData(std::string filePath) {
|
|||||||
bool passableSameDirection = (flagsByte & 0x04) > 0;
|
bool passableSameDirection = (flagsByte & 0x04) > 0;
|
||||||
bool passableOppositeDirection = (flagsByte & 0x08) > 0;
|
bool passableOppositeDirection = (flagsByte & 0x08) > 0;
|
||||||
|
|
||||||
addLinkToRoadNode(set.roadNodes, fromPoint, toPoint, speedLimit, motorway, tunnel, !passableSameDirection);
|
addLinkToRoadNode(set.roadNodes, fromPoint, toPoint, speedLimit, motorway, tunnel, passableSameDirection, passableOppositeDirection);
|
||||||
addLinkToRoadNode(set.roadNodes, toPoint, fromPoint, speedLimit, motorway, tunnel, !passableOppositeDirection);
|
addLinkToRoadNode(set.roadNodes, toPoint, fromPoint, speedLimit, motorway, tunnel, passableOppositeDirection, passableSameDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
@ -399,7 +401,14 @@ SearchResult findAllPathsFromPoint(int startingNode, float minimumSpeed, float m
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (neighbour.againstOneWay && ! allowAgainstOneway) {
|
bool againstOneWay;
|
||||||
|
if (reverse) {
|
||||||
|
againstOneWay = !neighbour.passableOppositeDirection;
|
||||||
|
} else {
|
||||||
|
againstOneWay = !neighbour.passableSameDirection;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!allowAgainstOneway && againstOneWay) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -758,7 +767,7 @@ std::vector<uint32_t> findPossibleStartNodes(float minimumSpeed, float maximumSp
|
|||||||
if (connection.tunnel && !allowTunnels) {
|
if (connection.tunnel && !allowTunnels) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (connection.againstOneWay && !allowAgainstOneway) {
|
if (!connection.passableSameDirection && !allowAgainstOneway) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user