Auto Interval Discovery : Add a ROUTE detection

This commit is contained in:
grauser
2015-05-09 22:50:13 +02:00
parent edf9b826ff
commit 644a8f069e
2 changed files with 21 additions and 14 deletions

View File

@@ -145,6 +145,9 @@ Athlete::Athlete(Context *context, const QDir &homeDir)
// seconds step of the upgrade - now everything of configuration needed should be in place in Context
v3.upgradeLate(context);
// Routes
routes = new Routes(context, home->config());
// get withings in if there is a cache
QFile withingsJSON(QString("%1/withings.json").arg(context->athlete->home->cache().canonicalPath()));
if (withingsJSON.exists() && withingsJSON.open(QFile::ReadOnly)) {

View File

@@ -696,37 +696,41 @@ RideItem::updateIntervals()
}
}
// TODO Search ROUTE, PEAK, HILL, ...
//Search routes
/*context->athlete->routes->searchRoutesInRide(this->ride());
//context->athlete->routes->searchRoutesInRide(f);
// Search
//qDebug() << "find ROUTES "<< fileName;
Routes* routes = context->athlete->routes;
if (routes->routes.count()>0) {
for (int n=0;n<routes->routes.count();n++) {
RouteSegment* route = &routes->routes[n];
//qDebug() << "find route "<< route->getName() << n;
for (int j=0;j<route->getRides().count();j++) {
RouteRide _ride = route->getRides()[j];
QDateTime rideStartDate = route->getRides()[j].startTime;
QString rideSegmentName = route->getRides()[j].filename;
if (this->ride()->startTime() == rideStartDate) {
qDebug() << "find ride "<< fileName <<" for " <<rideSegmentName;
if (f->startTime() == rideStartDate) {
//qDebug() << "find ride "<< fileName <<" for " <<rideSegmentName;
// Verify interval in db
// type, name, filename, start,
//IntervalItem* interval = new IntervalItem(ride(), route->getName(), _ride.start, _ride.stop, 0, 0, j, IntervalItem::Route);
//interval->name = route->getName();
//interval->color = color;
ride()->addInterval(RideFileInterval::ROUTE, _ride.start, _ride.stop, route->getName());
// create a new interval item
IntervalItem *intervalItem = new IntervalItem(f, route->getName(),
_ride.start, _ride.stop,
f->timeToDistance(_ride.start),
f->timeToDistance(_ride.stop),
count++, // sequence defaults to count
RideFileInterval::ROUTE);
intervalItem->rideItem_ = this; // XXX will go when we refactor and be passed instead of ridefile
intervalItem->refresh(); // XXX will get called in constructore when refactor
intervals_ << intervalItem;
}
}
}
}*/
}
}
QList<IntervalItem*> RideItem::intervalsSelected()