GoogleMap: Add a searchPoint method

This commit is contained in:
Damien
2015-01-13 18:35:46 +01:00
parent 14413fcb94
commit 6ba4bebe57
2 changed files with 37 additions and 0 deletions

View File

@@ -760,6 +760,31 @@ WebBridge::clearHover()
{
}
QList<RideFilePoint*>
WebBridge::searchPoint(double lat, double lng)
{
QList<RideFilePoint*> list;
RideItem *rideItem = gm->property("ride").value<RideItem*>();
RideFilePoint *candidat = NULL;
foreach (RideFilePoint *p1, rideItem->ride()->dataPoints()) {
if (p1->lat == 0 && p1->lon == 0)
continue;
if (((p1->lat-lat> 0 && p1->lat-lat< 0.0001) || (p1->lat-lat< 0 && p1->lat-lat> -0.0001)) &&
((p1->lon-lng> 0 && p1->lon-lng< 0.0001) || (p1->lon-lng< 0 && p1->lon-lng> -0.0001))) {
// Vérifie distance avec dernier candidat
candidat = p1;
} else if (candidat) {
list.append(candidat);
candidat = NULL;
}
}
return list;
}
void
WebBridge::hoverPath(double lat, double lng)
{
@@ -773,6 +798,12 @@ WebBridge::hoverPath(double lat, double lng)
IntervalItem *bottom = (IntervalItem *) allIntervals->child(count-1);
if (bottom->text(0).startsWith(name)) { //delete allIntervals->takeChild(count-1);
/*qDebug() << "searchPoint";
QList<RideFilePoint*> list = searchPoint(lat, lng);
for (int i=0;i<list.count();i++) {
qDebug() << list.at(i)->secs;
}*/
RideItem *rideItem = gm->property("ride").value<RideItem*>();
double position = 0.0;
@@ -785,6 +816,10 @@ WebBridge::hoverPath(double lat, double lng)
}
}
if (position == 0) {
return;
}
if (bottom->start>position) {
bottom->start = position;
} else {