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; }
void WaySublineCollection::addSubline(const WaySubline& subline) { if (_sublines.size() == 0) { _sublines.push_back(subline); } else { for (size_t i = 0; i < _sublines.size(); i++) { if (subline.overlaps(_sublines[i])) { throw HootException("A subline string may not contain overlapping sublines."); //use this for debugging only /*if (logWarnCount < Log::getWarnMessageLimit()) { LOG_WARN("A subline string may not contain overlapping sublines."); } else if (logWarnCount == Log::getWarnMessageLimit()) { LOG_WARN(className() << ": " << Log::LOG_WARN_LIMIT_REACHED_MESSAGE); } logWarnCount++;*/ } } _sublines.push_back(subline); } }
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]; }
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::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(); }