Open Galbar opened 10 months ago
I have managed to identify the issue. The points in the generated gpx file are not sorted by the time. Once I sort them by time (with a small python script) it displays as it should.
As far as I can tell, it could be solved by adding an orderBy clause in this function:
Probably just before the executeQuery
.
Is there any hope of this being fixed anytime soon? I'd love to make a pull request but I unfortunately know nothing about php...
Sadly, I don't have experience developing Nextcloud apps and I won't have the time to look into it for the foreseeable future :(
I did the investigation to, maybe, make it easier on the maintainers, whenever they can look at it. I don't really know how to set it up to check if that works. I couldn't even figure out what's the DB library they are using, when I was looking at it 🙈
That's no problem at all! Thanks for bringing this up!
I noticed this problem has only been happening for me since the start of this September.. I have no idea why that may be the case though..
I've recently checked auto-exported tracks and they seem to be in the correct order now.. In fact I can only find the scrambled files between 01/09 and 22/09. Before and after that are all normal. @Galbar are you still having this issue?
I'm still having the issue
@Galbar You can try adding this line
$qb->orderBy('timestamp', 'ASC');
in lib/Db/DeviceMapper.php, right before
if ($limit !== null) {
$qb->setMaxResults($limit);
}
Any better?
Hello, sorry for the late reply. I've been busy with life. I've added the ->orderBy('timestamp', 'ASC');
as the last line of the query in the function getDevicePoints()
and that fixed the issue (I tried exporting manually).
Here is a copy-paste of what the function looks like in my file:
public function getDevicePoints(int $deviceId, ?array $filters = null, ?int $limit = null, ?int $offset = null): array {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from('phonetrack_points')
->where(
$qb->expr()->eq('deviceid', $qb->createNamedParameter($deviceId, IQueryBuilder::PARAM_INT))
)
->orderBy('timestamp', 'ASC');
if ($filters !== null) {
$qb = self::applyQueryFilters($qb, $filters);
}
if ($limit !== null) {
$qb->setMaxResults($limit);
}
if ($offset !== null) {
$qb->setFirstResult($offset);
}
$req = $qb->executeQuery();
$points = $req->fetchAll();
$qb->resetQueryParts();
return $points;
}
I've noticed that both on manually exported tracks and auto-exported tracks the order of the points are wrong.
PhoneTrack version 0.7.6 on Nextcloud 26.0.5
See pictures below
On the left: From the PhoneTrack App On the right: In a different app (I've tried GpxMotion and GpxPod on Nextcloud and OSMAnd~ on Android with the same result)
I know this was working in the past, because I used it (like two or three years ago) and now I went to use it again and got this 😢