refactoring
This commit is contained in:
parent
ff8748ef3f
commit
54409ec24d
1 changed files with 11 additions and 13 deletions
|
@ -194,18 +194,16 @@ std::vector<LINE> Collector::segmentize(
|
||||||
if (t->getStopTimes().size() < 2) return ret;
|
if (t->getStopTimes().size() < 2) return ret;
|
||||||
|
|
||||||
POLYLINE pl(shape);
|
POLYLINE pl(shape);
|
||||||
std::vector<std::pair<POINT, double>> cuts;
|
std::vector<double> cuts;
|
||||||
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
for (auto st : t->getStopTimes()) {
|
for (const auto& st : t->getStopTimes()) {
|
||||||
cuts.push_back(std::pair<POINT, double>(
|
cuts.push_back(st.getShapeDistanceTravelled());
|
||||||
{st.getStop()->getLng(), st.getStop()->getLat()},
|
|
||||||
st.getShapeDistanceTravelled()));
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t to = std::upper_bound(dists.begin(), dists.end(), cuts[0].second) -
|
size_t to = std::upper_bound(dists.begin(), dists.end(), cuts[0]) -
|
||||||
dists.begin();
|
dists.begin();
|
||||||
|
|
||||||
POINT lastP;
|
POINT lastP;
|
||||||
|
@ -214,14 +212,14 @@ std::vector<LINE> Collector::segmentize(
|
||||||
} else if (to == 0) {
|
} else if (to == 0) {
|
||||||
lastP = shape.front();
|
lastP = shape.front();
|
||||||
} else {
|
} else {
|
||||||
double progr = (cuts[0].second - dists[to - 1]) / (dists[to] - dists[to - 1]);
|
double progr = (cuts[0] - dists[to - 1]) / (dists[to] - dists[to - 1]);
|
||||||
auto lastP = shape[to - 1];
|
auto lastP = shape[to - 1];
|
||||||
lastP.setX(lastP.getX() + progr * util::geo::dist(shape[to-1], shape[to]));
|
lastP.setX(lastP.getX() + progr * (shape[to].getX() - shape[to-1].getX()));
|
||||||
lastP.setY(lastP.getY() + progr * util::geo::dist(shape[to-1], shape[to]));
|
lastP.setY(lastP.getY() + progr * (shape[to].getY() - shape[to-1].getY()));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 1; i < cuts.size(); i++) {
|
for (size_t i = 1; i < cuts.size(); i++) {
|
||||||
size_t to = std::upper_bound(dists.begin(), dists.end(), cuts[i].second) -
|
size_t to = std::upper_bound(dists.begin(), dists.end(), cuts[i]) -
|
||||||
dists.begin();
|
dists.begin();
|
||||||
|
|
||||||
POINT curP;
|
POINT curP;
|
||||||
|
@ -231,9 +229,9 @@ std::vector<LINE> Collector::segmentize(
|
||||||
curP = shape.front();
|
curP = shape.front();
|
||||||
} else {
|
} else {
|
||||||
curP = shape[to - 1];
|
curP = shape[to - 1];
|
||||||
double progr = (cuts[i].second - dists[to - 1]) / (dists[to] - dists[to - 1]);
|
double progr = (cuts[i] - dists[to - 1]) / (dists[to] - dists[to - 1]);
|
||||||
curP.setX(curP.getX() + progr * util::geo::dist(shape[to-1], shape[to]));
|
curP.setX(curP.getX() + progr * (shape[to].getX() - shape[to-1].getX()));
|
||||||
curP.setY(curP.getY() + progr * util::geo::dist(shape[to-1], shape[to]));
|
curP.setY(curP.getY() + progr * (shape[to].getY() - shape[to-1].getY()));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto curL = pl.getSegment(lastP, curP).getLine();
|
auto curL = pl.getSegment(lastP, curP).getLine();
|
||||||
|
|
Loading…
Reference in a new issue