2010-08-31 10:00:40 -04:00
|
|
|
/*
|
|
|
|
open source routing machine
|
|
|
|
Copyright (C) Dennis Luxen, 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PHANTOMNODES_H_
|
|
|
|
#define PHANTOMNODES_H_
|
|
|
|
|
2012-08-27 11:40:59 -04:00
|
|
|
#include "Coordinate.h"
|
2010-08-31 10:00:40 -04:00
|
|
|
|
2011-07-11 11:16:14 -04:00
|
|
|
struct PhantomNode {
|
2012-02-10 11:14:30 -05:00
|
|
|
PhantomNode() : edgeBasedNode(UINT_MAX), nodeBasedEdgeNameID(UINT_MAX), weight1(INT_MAX), weight2(INT_MAX), ratio(0.) {}
|
2011-11-14 13:36:31 -05:00
|
|
|
NodeID edgeBasedNode;
|
2011-11-15 10:47:53 -05:00
|
|
|
unsigned nodeBasedEdgeNameID;
|
2011-11-16 11:29:00 -05:00
|
|
|
int weight1;
|
|
|
|
int weight2;
|
2012-02-10 11:14:30 -05:00
|
|
|
double ratio;
|
2011-07-11 11:16:14 -04:00
|
|
|
_Coordinate location;
|
|
|
|
void Reset() {
|
2011-11-14 13:36:31 -05:00
|
|
|
edgeBasedNode = UINT_MAX;
|
2011-11-16 11:29:00 -05:00
|
|
|
nodeBasedEdgeNameID = UINT_MAX;
|
|
|
|
weight1 = INT_MAX;
|
|
|
|
weight2 = INT_MAX;
|
2012-02-10 11:14:30 -05:00
|
|
|
ratio = 0.;
|
2011-07-11 11:16:14 -04:00
|
|
|
location.Reset();
|
|
|
|
}
|
2011-11-24 11:33:23 -05:00
|
|
|
bool isBidirected() const {
|
|
|
|
return weight2 != INT_MAX;
|
|
|
|
}
|
2012-03-05 13:08:10 -05:00
|
|
|
bool isValid(const unsigned numberOfNodes) const {
|
|
|
|
return location.isValid() && (edgeBasedNode < numberOfNodes) && (weight1 != INT_MAX) && (ratio >= 0.) && (ratio <= 1.) && (nodeBasedEdgeNameID != UINT_MAX);
|
|
|
|
}
|
2012-09-27 08:55:48 -04:00
|
|
|
|
|
|
|
bool operator==(const PhantomNode & other) const {
|
|
|
|
return location == other.location;
|
|
|
|
}
|
2011-07-11 11:16:14 -04:00
|
|
|
};
|
|
|
|
|
2010-08-31 10:00:40 -04:00
|
|
|
struct PhantomNodes {
|
2011-07-11 11:16:14 -04:00
|
|
|
PhantomNode startPhantom;
|
|
|
|
PhantomNode targetPhantom;
|
2011-06-10 04:25:26 -04:00
|
|
|
void Reset() {
|
2011-07-11 11:16:14 -04:00
|
|
|
startPhantom.Reset();
|
|
|
|
targetPhantom.Reset();
|
2011-06-10 04:25:26 -04:00
|
|
|
}
|
2011-07-18 11:48:30 -04:00
|
|
|
|
2011-11-14 13:36:31 -05:00
|
|
|
bool PhantomsAreOnSameNodeBasedEdge() const {
|
|
|
|
return (startPhantom.edgeBasedNode == targetPhantom.edgeBasedNode);
|
2011-07-18 11:48:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AtLeastOnePhantomNodeIsUINTMAX() const {
|
2011-11-14 13:36:31 -05:00
|
|
|
return !(startPhantom.edgeBasedNode == UINT_MAX || targetPhantom.edgeBasedNode == UINT_MAX);
|
2011-07-18 11:48:30 -04:00
|
|
|
}
|
2012-09-27 08:55:48 -04:00
|
|
|
|
|
|
|
bool PhantomNodesHaveEqualLocation() const {
|
|
|
|
return startPhantom == targetPhantom;
|
|
|
|
}
|
2011-06-10 04:25:26 -04:00
|
|
|
};
|
|
|
|
|
2011-10-10 12:55:25 -04:00
|
|
|
inline std::ostream& operator<<(std::ostream &out, const PhantomNodes & pn){
|
2011-11-14 13:36:31 -05:00
|
|
|
out << "Node1: " << pn.startPhantom.edgeBasedNode << std::endl;
|
|
|
|
out << "Node2: " << pn.targetPhantom.edgeBasedNode << std::endl;
|
2011-07-11 11:16:14 -04:00
|
|
|
out << "startCoord: " << pn.startPhantom.location << std::endl;
|
|
|
|
out << "targetCoord: " << pn.targetPhantom.location << std::endl;
|
2011-06-10 04:25:26 -04:00
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2012-02-29 08:30:19 -05:00
|
|
|
inline std::ostream& operator<<(std::ostream &out, const PhantomNode & pn){
|
2012-03-16 08:22:51 -04:00
|
|
|
out << "node: " << pn.edgeBasedNode << ", name: " << pn.nodeBasedEdgeNameID << ", w1: " << pn.weight1 << ", w2: " << pn.weight2 << ", ratio: " << pn.ratio << ", loc: " << pn.location;
|
2012-02-29 08:30:19 -05:00
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2011-06-10 04:25:26 -04:00
|
|
|
struct NodesOfEdge {
|
2011-11-14 13:36:31 -05:00
|
|
|
NodeID edgeBasedNode;
|
2011-06-10 04:25:26 -04:00
|
|
|
double ratio;
|
|
|
|
_Coordinate projectedPoint;
|
2010-08-31 10:00:40 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* PHANTOMNODES_H_ */
|