only fail if not sort-in succeeded at all
This commit is contained in:
parent
7835242cb8
commit
8fb21919f3
1 changed files with 35 additions and 30 deletions
|
@ -168,10 +168,11 @@ void OsmBuilder::read(const std::string& path, const OsmReadOpts& opts,
|
||||||
|
|
||||||
std::vector<const Stop*> notSnapped;
|
std::vector<const Stop*> notSnapped;
|
||||||
|
|
||||||
|
for (auto& s : *fs) {
|
||||||
|
bool snapped = false;
|
||||||
|
auto pl = plFromGtfs(s.first, opts);
|
||||||
for (size_t i = 0; i < opts.maxSnapDistances.size(); i++) {
|
for (size_t i = 0; i < opts.maxSnapDistances.size(); i++) {
|
||||||
double d = opts.maxSnapDistances[i];
|
double d = opts.maxSnapDistances[i];
|
||||||
for (auto& s : *fs) {
|
|
||||||
auto pl = plFromGtfs(s.first, opts);
|
|
||||||
|
|
||||||
StatGroup* group = groupStats(
|
StatGroup* group = groupStats(
|
||||||
snapStation(g, &pl, &eg, &sng, opts, res,
|
snapStation(g, &pl, &eg, &sng, opts, res,
|
||||||
|
@ -180,7 +181,10 @@ void OsmBuilder::read(const std::string& path, const OsmReadOpts& opts,
|
||||||
if (group) {
|
if (group) {
|
||||||
group->addStop(s.first);
|
group->addStop(s.first);
|
||||||
(*fs)[s.first] = *group->getNodes().begin();
|
(*fs)[s.first] = *group->getNodes().begin();
|
||||||
} else if (i == opts.maxSnapDistances.size() - 1) {
|
snapped = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!snapped) {
|
||||||
LOG(VDEBUG) << "Could not snap station "
|
LOG(VDEBUG) << "Could not snap station "
|
||||||
<< "(" << pl.getSI()->getName() << ")"
|
<< "(" << pl.getSI()->getName() << ")"
|
||||||
<< " (" << s.first->getLat() << "," << s.first->getLng()
|
<< " (" << s.first->getLat() << "," << s.first->getLng()
|
||||||
|
@ -188,7 +192,6 @@ void OsmBuilder::read(const std::string& path, const OsmReadOpts& opts,
|
||||||
notSnapped.push_back(s.first);
|
notSnapped.push_back(s.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (notSnapped.size())
|
if (notSnapped.size())
|
||||||
LOG(VDEBUG) << notSnapped.size() << " stations could not be snapped in "
|
LOG(VDEBUG) << notSnapped.size() << " stations could not be snapped in "
|
||||||
|
@ -197,10 +200,11 @@ void OsmBuilder::read(const std::string& path, const OsmReadOpts& opts,
|
||||||
|
|
||||||
// try again, but aggressively snap to orphan OSM stations which have
|
// try again, but aggressively snap to orphan OSM stations which have
|
||||||
// not been assigned to any GTFS stop yet
|
// not been assigned to any GTFS stop yet
|
||||||
|
for (auto& s : notSnapped) {
|
||||||
|
bool snapped = false;
|
||||||
|
auto pl = plFromGtfs(s, opts);
|
||||||
for (size_t i = 0; i < opts.maxSnapDistances.size(); i++) {
|
for (size_t i = 0; i < opts.maxSnapDistances.size(); i++) {
|
||||||
double d = opts.maxSnapDistances[i];
|
double d = opts.maxSnapDistances[i];
|
||||||
for (auto& s : notSnapped) {
|
|
||||||
auto pl = plFromGtfs(s, opts);
|
|
||||||
|
|
||||||
StatGroup* group = groupStats(
|
StatGroup* group = groupStats(
|
||||||
snapStation(g, &pl, &eg, &sng, opts, res,
|
snapStation(g, &pl, &eg, &sng, opts, res,
|
||||||
|
@ -215,8 +219,10 @@ void OsmBuilder::read(const std::string& path, const OsmReadOpts& opts,
|
||||||
n->pl().getSI()->addAltName(pl.getSI()->getName());
|
n->pl().getSI()->addAltName(pl.getSI()->getName());
|
||||||
}
|
}
|
||||||
(*fs)[s] = *group->getNodes().begin();
|
(*fs)[s] = *group->getNodes().begin();
|
||||||
} else if (i ==
|
snapped = true;
|
||||||
opts.maxSnapDistances.size() - 1) { // only fail on last
|
}
|
||||||
|
}
|
||||||
|
if (!snapped) {
|
||||||
// finally give up
|
// finally give up
|
||||||
|
|
||||||
// add a group with only this stop in it
|
// add a group with only this stop in it
|
||||||
|
@ -233,7 +239,6 @@ void OsmBuilder::read(const std::string& path, const OsmReadOpts& opts,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
LOG(VDEBUG) << "Deleting orphan nodes...";
|
LOG(VDEBUG) << "Deleting orphan nodes...";
|
||||||
deleteOrphNds(g);
|
deleteOrphNds(g);
|
||||||
|
@ -299,7 +304,7 @@ void OsmBuilder::overpassQryWrite(std::ostream* out,
|
||||||
wr.writeText(" - written by pfaedle -");
|
wr.writeText(" - written by pfaedle -");
|
||||||
wr.closeTag();
|
wr.closeTag();
|
||||||
wr.openTag("osm-script",
|
wr.openTag("osm-script",
|
||||||
{{"timeout", "99999"}, {"element-limit", "1073741824"}});
|
{{"timeout", "99999"}, {"element-limit", "2073741824"}});
|
||||||
|
|
||||||
OsmFilter filter;
|
OsmFilter filter;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue