refactoring
This commit is contained in:
parent
10b72785ba
commit
dfce1a44fc
3 changed files with 13 additions and 34 deletions
|
@ -24,7 +24,6 @@
|
||||||
#include "util/json/Writer.h"
|
#include "util/json/Writer.h"
|
||||||
#include "util/log/Log.h"
|
#include "util/log/Log.h"
|
||||||
|
|
||||||
using std::string;
|
|
||||||
using pfaedle::router::MOTs;
|
using pfaedle::router::MOTs;
|
||||||
using pfaedle::osm::BBoxIdx;
|
using pfaedle::osm::BBoxIdx;
|
||||||
using pfaedle::osm::OsmBuilder;
|
using pfaedle::osm::OsmBuilder;
|
||||||
|
|
|
@ -1244,15 +1244,6 @@ std::set<Node*> OsmBuilder::snapStation(Graph* g, NodePL* s, EdgeGrid* eg,
|
||||||
if (best) getEdgCands(*best->pl().getGeom(), &pq, eg, d);
|
if (best) getEdgCands(*best->pl().getGeom(), &pq, eg, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(patrick): problem here: the rules below may be circumvented if a node
|
|
||||||
// is
|
|
||||||
// placed
|
|
||||||
// near the end of an edge. Then, a full turn punish prevents a detection of
|
|
||||||
// nearby nodes!!!
|
|
||||||
// This is a mere performance problem and will not affect routing very much,
|
|
||||||
// as
|
|
||||||
// long as station passing is not heavily punished.
|
|
||||||
|
|
||||||
while (!pq.empty()) {
|
while (!pq.empty()) {
|
||||||
auto* e = pq.top().second;
|
auto* e = pq.top().second;
|
||||||
pq.pop();
|
pq.pop();
|
||||||
|
@ -1270,8 +1261,7 @@ std::set<Node*> OsmBuilder::snapStation(Graph* g, NodePL* s, EdgeGrid* eg,
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the projected position is near (< 2 meters) the end point of this
|
// if the projected position is near (< 2 meters) the end point of this
|
||||||
// way,
|
// way and the endpoint is not already a station, place the station there.
|
||||||
// and the endpoint is not already a station, place the station there.
|
|
||||||
if (!e->getFrom()->pl().getSI() &&
|
if (!e->getFrom()->pl().getSI() &&
|
||||||
webMercMeterDist(geom, *e->getFrom()->pl().getGeom()) < 2) {
|
webMercMeterDist(geom, *e->getFrom()->pl().getGeom()) < 2) {
|
||||||
e->getFrom()->pl().setSI(*s->getSI());
|
e->getFrom()->pl().setSI(*s->getSI());
|
||||||
|
|
|
@ -40,6 +40,7 @@ using pfaedle::router::HopBand;
|
||||||
using pfaedle::router::NodeCandRoute;
|
using pfaedle::router::NodeCandRoute;
|
||||||
using util::graph::EDijkstra;
|
using util::graph::EDijkstra;
|
||||||
using util::graph::Dijkstra;
|
using util::graph::Dijkstra;
|
||||||
|
using util::geo::webMercMeterDist;
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
EdgeCost NCostFunc::operator()(const trgraph::Node* from,
|
EdgeCost NCostFunc::operator()(const trgraph::Node* from,
|
||||||
|
@ -51,8 +52,6 @@ EdgeCost NCostFunc::operator()(const trgraph::Node* from,
|
||||||
int oneway = e->pl().oneWay() == 2;
|
int oneway = e->pl().oneWay() == 2;
|
||||||
int32_t stationSkip = 0;
|
int32_t stationSkip = 0;
|
||||||
|
|
||||||
double transitLinePen = 0; // transitLineCmp(e->pl());
|
|
||||||
|
|
||||||
return EdgeCost(e->pl().lvl() == 0 ? e->pl().getLength() : 0,
|
return EdgeCost(e->pl().lvl() == 0 ? e->pl().getLength() : 0,
|
||||||
e->pl().lvl() == 1 ? e->pl().getLength() : 0,
|
e->pl().lvl() == 1 ? e->pl().getLength() : 0,
|
||||||
e->pl().lvl() == 2 ? e->pl().getLength() : 0,
|
e->pl().lvl() == 2 ? e->pl().getLength() : 0,
|
||||||
|
@ -61,8 +60,7 @@ EdgeCost NCostFunc::operator()(const trgraph::Node* from,
|
||||||
e->pl().lvl() == 5 ? e->pl().getLength() : 0,
|
e->pl().lvl() == 5 ? e->pl().getLength() : 0,
|
||||||
e->pl().lvl() == 6 ? e->pl().getLength() : 0,
|
e->pl().lvl() == 6 ? e->pl().getLength() : 0,
|
||||||
e->pl().lvl() == 7 ? e->pl().getLength() : 0, 0, stationSkip,
|
e->pl().lvl() == 7 ? e->pl().getLength() : 0, 0, stationSkip,
|
||||||
e->pl().getLength() * oneway, oneway,
|
e->pl().getLength() * oneway, oneway, 0, 0, &_rOpts);
|
||||||
e->pl().getLength() * transitLinePen, 0, &_rOpts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
|
@ -137,8 +135,7 @@ NDistHeur::NDistHeur(const RoutingOpts& rOpts,
|
||||||
_center = FPoint(x, y);
|
_center = FPoint(x, y);
|
||||||
|
|
||||||
for (auto to : tos) {
|
for (auto to : tos) {
|
||||||
double cur = static_cast<double>(static_cast<double>(
|
double cur = webMercMeterDist(*to->pl().getGeom(), _center);
|
||||||
util::geo::webMercMeterDist(*to->pl().getGeom(), _center)));
|
|
||||||
if (cur > _maxCentD) _maxCentD = cur;
|
if (cur > _maxCentD) _maxCentD = cur;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,9 +157,8 @@ DistHeur::DistHeur(uint8_t minLvl, const RoutingOpts& rOpts,
|
||||||
_center = FPoint(x, y);
|
_center = FPoint(x, y);
|
||||||
|
|
||||||
for (auto to : tos) {
|
for (auto to : tos) {
|
||||||
double cur = static_cast<double>(static_cast<double>(
|
double cur = webMercMeterDist(*to->getFrom()->pl().getGeom(), _center) *
|
||||||
util::geo::webMercMeterDist(*to->getFrom()->pl().getGeom(), _center) *
|
_rOpts.levelPunish[_lvl];
|
||||||
_rOpts.levelPunish[_lvl]));
|
|
||||||
if (cur > _maxCentD) _maxCentD = cur;
|
if (cur > _maxCentD) _maxCentD = cur;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,11 +166,9 @@ DistHeur::DistHeur(uint8_t minLvl, const RoutingOpts& rOpts,
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
EdgeCost DistHeur::operator()(const trgraph::Edge* a,
|
EdgeCost DistHeur::operator()(const trgraph::Edge* a,
|
||||||
const std::set<trgraph::Edge*>& b) const {
|
const std::set<trgraph::Edge*>& b) const {
|
||||||
double cur = static_cast<double>(static_cast<double>(
|
|
||||||
util::geo::webMercMeterDist(*a->getTo()->pl().getGeom(), _center) *
|
|
||||||
_rOpts.levelPunish[_lvl]));
|
|
||||||
|
|
||||||
UNUSED(b);
|
UNUSED(b);
|
||||||
|
double cur = webMercMeterDist(*a->getTo()->pl().getGeom(), _center) *
|
||||||
|
_rOpts.levelPunish[_lvl];
|
||||||
|
|
||||||
return EdgeCost(cur - _maxCentD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
return EdgeCost(cur - _maxCentD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
@ -182,10 +176,8 @@ EdgeCost DistHeur::operator()(const trgraph::Edge* a,
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
EdgeCost NDistHeur::operator()(const trgraph::Node* a,
|
EdgeCost NDistHeur::operator()(const trgraph::Node* a,
|
||||||
const std::set<trgraph::Node*>& b) const {
|
const std::set<trgraph::Node*>& b) const {
|
||||||
double cur = static_cast<double>(static_cast<double>(
|
|
||||||
util::geo::webMercMeterDist(*a->pl().getGeom(), _center)));
|
|
||||||
|
|
||||||
UNUSED(b);
|
UNUSED(b);
|
||||||
|
double cur = webMercMeterDist(*a->pl().getGeom(), _center);
|
||||||
|
|
||||||
return EdgeCost(cur - _maxCentD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
return EdgeCost(cur - _maxCentD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
@ -230,8 +222,8 @@ HopBand Router::getHopBand(const NodeCandGroup& a, const NodeCandGroup& b,
|
||||||
double pend = 0;
|
double pend = 0;
|
||||||
for (size_t i = 0; i < a.size(); i++) {
|
for (size_t i = 0; i < a.size(); i++) {
|
||||||
for (size_t j = 0; j < b.size(); j++) {
|
for (size_t j = 0; j < b.size(); j++) {
|
||||||
double d = util::geo::webMercMeterDist(*a[i].nd->pl().getGeom(),
|
double d =
|
||||||
*b[j].nd->pl().getGeom());
|
webMercMeterDist(*a[i].nd->pl().getGeom(), *b[j].nd->pl().getGeom());
|
||||||
if (d > pend) pend = d;
|
if (d > pend) pend = d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,9 +271,8 @@ HopBand Router::getHopBand(const NodeCandGroup& a, const NodeCandGroup& b,
|
||||||
double maxStrD = 0;
|
double maxStrD = 0;
|
||||||
|
|
||||||
for (auto e : to) {
|
for (auto e : to) {
|
||||||
double d = static_cast<double>(static_cast<double>(
|
double d = webMercMeterDist(*el.front()->getFrom()->pl().getGeom(),
|
||||||
util::geo::webMercMeterDist(*el.front()->getFrom()->pl().getGeom(),
|
*e->getTo()->pl().getGeom());
|
||||||
*e->getTo()->pl().getGeom())));
|
|
||||||
if (d > maxStrD) maxStrD = d;
|
if (d > maxStrD) maxStrD = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,7 +442,6 @@ EdgeListHops Router::route(const NodeCandRoute& route,
|
||||||
ce->pl().setStartNode(eFr->getFrom());
|
ce->pl().setStartNode(eFr->getFrom());
|
||||||
// for debugging
|
// for debugging
|
||||||
ce->pl().setStartEdge(eFr);
|
ce->pl().setStartEdge(eFr);
|
||||||
|
|
||||||
ce->pl().setEndNode(to.nd);
|
ce->pl().setEndNode(to.nd);
|
||||||
// for debugging
|
// for debugging
|
||||||
ce->pl().setEndEdge(eTo);
|
ce->pl().setEndEdge(eTo);
|
||||||
|
|
Loading…
Reference in a new issue