29#define JUNCTION_TAZ_MISSING_HELP "\nSet option '--junction-taz' or load a TAZ-file"
43template<
class E,
class L,
class N>
57 std::vector<const E*>& into,
const std::string& rid,
bool isFrom,
bool& ok) {
59 WRITE_ERROR(
TL(
"Cannot convert geo-positions because the network has no geo-reference"));
73 if (best ==
nullptr) {
77 const E* bestEdge = &best->getEdge();
78 while (bestEdge->isInternal()) {
79 bestEdge = bestEdge->getSuccessors().front();
83 if (bestEdge !=
nullptr) {
84 into.push_back(bestEdge);
88 if (positions.size() == 1 || into.empty() || into.back() != bestEdge) {
89 into.push_back(bestEdge);
103 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
104 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
105 std::set<const Named*> lanes;
107 t->
Search(cmin, cmax, sv);
109 double minDist = std::numeric_limits<double>::max();
110 const L* best =
nullptr;
111 for (
const Named* o : lanes) {
112 const L* cand =
static_cast<const L*
>(o);
113 if (!cand->allowsVehicleClass(vClass)) {
116 double dist = cand->getShape().distance2D(pos);
117 if (dist < minDist) {
127 if (closestEdge ==
nullptr) {
130 const N* fromJunction = closestEdge->getFromJunction();
131 const N* toJunction = closestEdge->getToJunction();
132 const bool fromCloser = (fromJunction->getPosition().distanceSquaredTo2D(pos) <
133 toJunction->getPosition().distanceSquaredTo2D(pos));
134 const E* fromSource =
retrieveEdge(fromJunction->getID() +
"-source");
135 const E* fromSink =
retrieveEdge(fromJunction->getID() +
"-sink");
136 const E* toSource =
retrieveEdge(toJunction->getID() +
"-source");
137 const E* toSink =
retrieveEdge(toJunction->getID() +
"-sink");
138 if (fromSource ==
nullptr || fromSink ==
nullptr) {
142 if (toSource ==
nullptr || toSink ==
nullptr) {
146 const bool fromPossible = isFrom ? fromSource->getSuccessors(vClass).size() > 0 : fromSink->getPredecessors().size() > 0;
147 const bool toPossible = isFrom ? toSource->getSuccessors(vClass).size() > 0 : toSink->getPredecessors().size() > 0;
149 if (fromCloser && fromPossible) {
151 return isFrom ? fromSource : fromSink;
152 }
else if (!fromCloser && toPossible) {
154 return isFrom ? toSource : toSink;
158 return isFrom ? fromSource : fromSink;
160 return isFrom ? toSource : toSink;
#define JUNCTION_TAZ_MISSING_HELP
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
int gPrecision
the precision for floating point outputs
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A class that stores a 2D geometrical boundary.
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
double ymin() const
Returns minimum y-coordinate.
double xmin() const
Returns minimum x-coordinate.
Boundary & grow(double by)
extends the boundary by the given amount
double ymax() const
Returns maximum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation.
Provides utility functions for matching locations to edges (during route parsing)
double myMapMatchingDistance
virtual E * retrieveEdge(const std::string &id)=0
MapMatcher(bool matchJunctions, double matchDistance, MsgHandler *errorOutput)
void parseGeoEdges(const PositionVector &positions, bool geo, SUMOVehicleClass vClass, std::vector< const E * > &into, const std::string &rid, bool isFrom, bool &ok)
MapMatcher & operator=(const MapMatcher &s)=delete
Invalidated assignment operator.
const L * getClosestLane(const Position &pos, SUMOVehicleClass vClass, double distance=-1.)
find closest lane within distance for the given position or nullptr
MapMatcher(const MapMatcher &s)=delete
Invalidated copy constructor.
virtual void initLaneTree(NamedRTree *tree)=0
const E * getJunctionTaz(const Position &pos, const E *closestEdge, SUMOVehicleClass vClass, bool isFrom)
find closest junction taz given the closest edge
MsgHandler * myErrorOutput
NamedRTree * myLaneTree
RTree for finding lanes.
NamedRTree * getLaneTree()
initialize lane-RTree
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
Allows to store the object; used as context while traveling the rtree in TraCI.
Base class for objects which have an id.
A RT-tree for efficient storing of SUMO's Named objects.
int Search(const float a_min[2], const float a_max[2], const Named::StoringVisitor &c) const
Find all within search rectangle.
A point in 2D or 3D with translation and scaling methods.