2016-11-14 22:12:43 +01:00
|
|
|
#include "path.h"
|
|
|
|
|
2017-03-18 01:30:31 +01:00
|
|
|
QRectF Path::boundingRect() const
|
|
|
|
{
|
|
|
|
if (size() < 2)
|
|
|
|
return QRectF();
|
|
|
|
|
|
|
|
QPointF topLeft(at(0).coordinates().lon(), at(0).coordinates().lat());
|
|
|
|
QPointF bottomRight(topLeft);
|
|
|
|
|
|
|
|
for (int i = 1; i < size(); i++) {
|
|
|
|
qreal x = at(i).coordinates().lon();
|
|
|
|
qreal y = at(i).coordinates().lat();
|
|
|
|
|
|
|
|
if (x < topLeft.x())
|
|
|
|
topLeft.setX(x);
|
|
|
|
if (y < topLeft.y())
|
|
|
|
topLeft.setY(y);
|
|
|
|
if (x > bottomRight.x())
|
|
|
|
bottomRight.setX(x);
|
|
|
|
if (y > bottomRight.y())
|
|
|
|
bottomRight.setY(y);
|
|
|
|
}
|
|
|
|
return QRectF(topLeft, bottomRight);
|
|
|
|
}
|
|
|
|
|
2016-11-14 22:12:43 +01:00
|
|
|
QDebug operator<<(QDebug dbg, const PathPoint &point)
|
|
|
|
{
|
|
|
|
dbg.nospace() << "PathPoint(" << point.distance() << ", "
|
|
|
|
<< point.coordinates() << ")";
|
|
|
|
|
|
|
|
return dbg.maybeSpace();
|
|
|
|
}
|