WaySubline::WaySubline(const WaySubline& from, const ConstOsmMapPtr& newMap) { if (from.isValid()) { ConstWayPtr oldWay = from.getStart().getWay(); ConstWayPtr newWay = newMap->getWay(oldWay->getId()); _start = WayLocation(newMap, newWay, from.getStart().getSegmentIndex(), from.getStart().getSegmentFraction()); _end = WayLocation(newMap, newWay, from.getEnd().getSegmentIndex(), from.getEnd().getSegmentFraction()); } }
bool WaySubline::touches(const WaySubline& other) const { bool touches = true; if (other.getWay() != getWay() || getStart() > other.getEnd() || other.getStart() > getEnd()) { touches = false; } return touches; }
bool WaySubline::overlaps(const WaySubline& other) const { bool overlaps = true; if (other.getWay() != getWay() || getStart() >= other.getEnd() || other.getStart() >= getEnd()) { overlaps = false; } return overlaps; }
WayPtr WaySplitter::createSubline(const WaySubline& subline, vector<WayPtr>& scraps) { vector<WayLocation> wls; wls.push_back(subline.getStart()); wls.push_back(subline.getEnd()); assert(subline.isValid() && subline.getStart() != subline.getEnd()); vector<WayPtr> splits = createSplits(wls); assert(splits[1].get() != 0); if (splits[0].get()) { scraps.push_back(splits[0]); } if (splits[2].get()) { scraps.push_back(splits[2]); } return splits[1]; }
bool WaySubline::contains(const WaySubline& other) const { return getStart().getWay() == other.getStart().getWay() && other.getStart() >= getStart() && other.getEnd() <= getEnd(); }
WaySubline::WaySubline(const WaySubline& from) : _start(from.getStart()), _end(from.getEnd()) { }
bool operator==(const WaySubline& a, const WaySubline& b) { return a.getStart() == b.getStart() && a.getEnd() == b.getEnd(); }
bool compareSublines(const WaySubline& ws1, const WaySubline& ws2) { return ws1.getStart() < ws2.getStart(); }