add --osmfilter option

This commit is contained in:
Patrick Brosi 2022-01-11 17:32:50 +01:00
parent 6473dcdb52
commit c25d174e60
14 changed files with 185 additions and 30 deletions

View file

@ -61,6 +61,7 @@ struct RoutingOpts {
bool useStations;
double transitionPen;
std::string transPenMethod;
std::string emPenMethod;
};
// _____________________________________________________________________________
@ -80,6 +81,7 @@ inline bool operator==(const RoutingOpts& a, const RoutingOpts& b) {
fabs(a.transitionPen - b.transitionPen) < 0.01 &&
fabs(a.nonStationPen - b.nonStationPen) < 0.01 &&
a.transPenMethod == b.transPenMethod &&
a.emPenMethod == b.emPenMethod &&
a.useStations == b.useStations && a.popReachEdge == b.popReachEdge &&
a.noSelfHops == b.noSelfHops;
}

View file

@ -206,7 +206,6 @@ EdgeCandGroup ShapeBuilder::getEdgCands(const Stop* s) const {
// stations do not match, punish
nameMatchPunish = _motCfg.routingOpts.stationUnmatchedPen;
}
std::string platform = s->getPlatformCode();
if (!platform.empty() && !nd->pl().getSI()->getTrack().empty() &&
@ -218,8 +217,7 @@ EdgeCandGroup ShapeBuilder::getEdgCands(const Stop* s) const {
// don't snap to one way edges
if (e->pl().oneWay() == 2) continue;
ret.push_back({e,
mDist * _motCfg.routingOpts.stationDistPenFactor +
nameMatchPunish + trackMatchPunish,
emWeight(mDist) + nameMatchPunish + trackMatchPunish,
0,
{},
0,
@ -265,8 +263,7 @@ EdgeCandGroup ShapeBuilder::getEdgCands(const Stop* s) const {
for (auto e : selected) {
ret.push_back({e,
scores[e] * _motCfg.routingOpts.stationDistPenFactor +
_motCfg.routingOpts.nonStationPen,
emWeight(scores[e]) + _motCfg.routingOpts.nonStationPen,
progrs[e],
{},
0,
@ -981,7 +978,7 @@ std::vector<LINE> ShapeBuilder::getGeom(
ret.push_back({hop.pointStart, *hop.end->getFrom()->pl().getGeom()});
}
} else {
ret.push_back({hop.pointEnd, hop.pointStart});
ret.push_back({hop.pointStart, hop.pointEnd});
}
} else {
const auto& l = getLine(hop, rAttrs, colors);
@ -1222,3 +1219,17 @@ uint32_t ShapeBuilder::getTextColor(uint32_t c) const {
if (a < 140) return 0x00FFFFFF;
return 0;
}
// _____________________________________________________________________________
double ShapeBuilder::emWeight(double mDist) const {
if (_motCfg.routingOpts.emPenMethod == "exp") {
return mDist * _motCfg.routingOpts.stationDistPenFactor;
}
if (_motCfg.routingOpts.emPenMethod == "norm") {
double s = mDist * _motCfg.routingOpts.stationDistPenFactor;
return 0.5 * s * s;
}
return mDist;
}

View file

@ -119,6 +119,8 @@ class ShapeBuilder {
std::map<size_t, router::EdgeListHops> route(const TripTrie* trie,
const EdgeCandMap& ecm,
HopCache* hopCache) const;
double emWeight(double mDist) const;
void buildCandCache(const TripForests& clusters);
void buildIndex();

View file

@ -237,8 +237,6 @@ double DistDiffTransWeight::weight(uint32_t c, double d, double t0, double d0,
const RoutingOpts& rOpts) {
UNUSED(t0);
UNUSED(c);
// double mean = 250; // expectation value of 250 meters for buses
// double lambda = 1.0 / mean;
double w = fabs(d - d0);