bugfixes
This commit is contained in:
parent
46482788ff
commit
c3bc12eb8c
3 changed files with 45 additions and 18 deletions
|
@ -36,6 +36,7 @@ double Collector::add(const Trip* oldT, const Shape* oldS, const Trip* newT,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (auto st : oldT->getStopTimes()) {
|
for (auto st : oldT->getStopTimes()) {
|
||||||
if (st.getShapeDistanceTravelled() < 0) {
|
if (st.getShapeDistanceTravelled() < 0) {
|
||||||
// we cannot safely compare trips without shape dist travelled
|
// we cannot safely compare trips without shape dist travelled
|
||||||
|
@ -67,6 +68,21 @@ double Collector::add(const Trip* oldT, const Shape* oldS, const Trip* newT,
|
||||||
std::vector<double> newDists;
|
std::vector<double> newDists;
|
||||||
LINE newL = getLine(newS, &newDists);
|
LINE newL = getLine(newS, &newDists);
|
||||||
|
|
||||||
|
// check dist between anchor points
|
||||||
|
|
||||||
|
if ((util::geo::latLngLen(oldL) * 1.0) / (oldL.size() * 1.0) > 1000) {
|
||||||
|
// most likely input with a degenerated shape - dont compare
|
||||||
|
_noOrigShp++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((util::geo::latLngLen(newL) * 1.0) / (newL.size() * 1.0) > 1000) {
|
||||||
|
// most likely input with a degenerated shape - dont compare
|
||||||
|
_noOrigShp++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<std::pair<double, double>> newLenDists;
|
std::vector<std::pair<double, double>> newLenDists;
|
||||||
std::vector<std::pair<double, double>> oldLenDists;
|
std::vector<std::pair<double, double>> oldLenDists;
|
||||||
|
|
||||||
|
@ -90,20 +106,26 @@ double Collector::add(const Trip* oldT, const Shape* oldS, const Trip* newT,
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert (roughly) to degrees
|
// convert (roughly) to degrees
|
||||||
double SEGL = 15.0 / util::geo::M_PER_DEG;
|
double SEGL = 25.0 / util::geo::M_PER_DEG;
|
||||||
|
|
||||||
auto old = _dCache.find(oldLCut);
|
double f = util::geo::webMercDistFactor(oldLCut.front());
|
||||||
|
|
||||||
|
// roughly half a meter
|
||||||
|
auto oldLCutS = util::geo::simplify(oldLCut, f * (0.5 / util::geo::M_PER_DEG));
|
||||||
|
auto newLCutS = util::geo::simplify(newLCut, f * (0.5 / util::geo::M_PER_DEG));
|
||||||
|
|
||||||
|
auto old = _dCache.find(oldLCutS);
|
||||||
if (old != _dCache.end()) {
|
if (old != _dCache.end()) {
|
||||||
auto match = old->second.find(newLCut);
|
auto match = old->second.find(newLCutS);
|
||||||
if (match != old->second.end()) {
|
if (match != old->second.end()) {
|
||||||
fd = match->second;
|
fd = match->second;
|
||||||
} else {
|
} else {
|
||||||
fd = util::geo::accFrechetDistCHav(oldLCut, newLCut, SEGL);
|
fd = util::geo::accFrechetDistCHav(oldLCutS, newLCutS, SEGL);
|
||||||
_dCache[oldLCut][newLCut] = fd;
|
_dCache[oldLCutS][newLCutS] = fd;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fd = util::geo::accFrechetDistCHav(oldLCut, newLCut, SEGL);
|
fd = util::geo::accFrechetDistCHav(oldLCutS, newLCutS, SEGL);
|
||||||
_dCache[oldLCut][newLCut] = fd;
|
_dCache[oldLCutS][newLCutS] = fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto dA = getDa(oldSegs, newSegs);
|
auto dA = getDa(oldSegs, newSegs);
|
||||||
|
@ -218,7 +240,6 @@ LINE Collector::getLine(const Shape* s, std::vector<double>* dists) {
|
||||||
ret.push_back({s->getPoints()[i].lng, s->getPoints()[i].lat});
|
ret.push_back({s->getPoints()[i].lng, s->getPoints()[i].lat});
|
||||||
(*dists).push_back(s->getPoints()[i].travelDist);
|
(*dists).push_back(s->getPoints()[i].travelDist);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,30 +417,36 @@ std::pair<size_t, double> Collector::getDa(const std::vector<LINE>& a,
|
||||||
std::pair<size_t, double> ret{0, 0};
|
std::pair<size_t, double> ret{0, 0};
|
||||||
|
|
||||||
// convert (roughly) to degrees
|
// convert (roughly) to degrees
|
||||||
double SEGL = 15 / util::geo::M_PER_DEG;
|
double SEGL = 25 / util::geo::M_PER_DEG;
|
||||||
|
|
||||||
double MAX = 50;
|
double MAX = 50;
|
||||||
|
|
||||||
for (size_t i = 0; i < a.size(); i++) {
|
for (size_t i = 0; i < a.size(); i++) {
|
||||||
double fdMeter = 0;
|
double fdMeter = 0;
|
||||||
|
|
||||||
auto old = _dACache.find(a[i]);
|
double f = util::geo::webMercDistFactor(a[i].front());
|
||||||
|
|
||||||
|
// roughly half a meter
|
||||||
|
auto aSimpl = util::geo::simplify(a[i], f * (0.5 / util::geo::M_PER_DEG));
|
||||||
|
auto bSimpl = util::geo::simplify(b[i], f * (0.5 / util::geo::M_PER_DEG));
|
||||||
|
|
||||||
|
auto old = _dACache.find(aSimpl);
|
||||||
if (old != _dACache.end()) {
|
if (old != _dACache.end()) {
|
||||||
auto match = old->second.find(b[i]);
|
auto match = old->second.find(bSimpl);
|
||||||
if (match != old->second.end()) {
|
if (match != old->second.end()) {
|
||||||
fdMeter = match->second;
|
fdMeter = match->second;
|
||||||
} else {
|
} else {
|
||||||
fdMeter = util::geo::frechetDistHav(a[i], b[i], SEGL);
|
fdMeter = util::geo::frechetDistHav(aSimpl, bSimpl, SEGL);
|
||||||
_dACache[a[i]][b[i]] = fdMeter;
|
_dACache[aSimpl][bSimpl] = fdMeter;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fdMeter = util::geo::frechetDistHav(a[i], b[i], SEGL);
|
fdMeter = util::geo::frechetDistHav(aSimpl, bSimpl, SEGL);
|
||||||
_dACache[a[i]][b[i]] = fdMeter;
|
_dACache[aSimpl][bSimpl] = fdMeter;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fdMeter >= MAX) {
|
if (fdMeter >= MAX) {
|
||||||
ret.first++;
|
ret.first++;
|
||||||
ret.second += util::geo::latLngLen(a[i]);
|
ret.second += util::geo::latLngLen(aSimpl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ struct lineCmp {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < a.size(); i++) {
|
for (size_t i = 0; i < a.size(); i++) {
|
||||||
if (util::geo::dist(a[i], b[i]) > .000001) {
|
if (util::geo::dist(a[i], b[i]) > .00001) {
|
||||||
return (a[i].getX() < b[i].getX()) ||
|
return (a[i].getX() < b[i].getX()) ||
|
||||||
(a[i].getX() == b[i].getX() && a[i].getY() < b[i].getY());
|
(a[i].getX() == b[i].getX() && a[i].getY() < b[i].getY());
|
||||||
;
|
;
|
||||||
|
|
|
@ -1964,7 +1964,7 @@ inline double accFrechetDistCHav(const Line<T>& a, const Line<T>& b, double d) {
|
||||||
for (size_t i = 1; i < p.size(); i++) {
|
for (size_t i = 1; i < p.size(); i++) {
|
||||||
for (size_t j = 1; j < q.size(); j++) {
|
for (size_t j = 1; j < q.size(); j++) {
|
||||||
float d =
|
float d =
|
||||||
util::geo::haversine(p[i], q[j]) * util::geo::dist(p[i], p[i - 1]);
|
util::geo::haversine(p[i], q[j]) * util::geo::haversine(p[i], p[i - 1]);
|
||||||
ca[i * q.size() + j] =
|
ca[i * q.size() + j] =
|
||||||
d + std::min(ca[(i - 1) * q.size() + j],
|
d + std::min(ca[(i - 1) * q.size() + j],
|
||||||
std::min(ca[i * q.size() + (j - 1)],
|
std::min(ca[i * q.size() + (j - 1)],
|
||||||
|
|
Loading…
Reference in a new issue