Fetch livetracking locations from Nextcloud PhoneTrack

Svitozar shared this idea 5 years ago
Gathering feedback

Hi,

I have recently started to run Nextcloud server with Phonetrack plugin to have a self-hosted google timeline alternative

There is a nice and easy way to fetch one's location from many loggers including Locus via link like https://example.com/index.php/apps/phonetrack/log/locusmap/5csessiontokenbb/devicename:/f7e417070cf434d8c3bb555376d68195


In addition to acquire, this plugin also allows to share the location:/4fc47315756ed8e410815efbff600833


via link that looks like

https://example.com/index.php/apps/phonetrack/api/getlastpositions/29watchsessiontoken83

and, if placed in a browser, yields the following JSON text:

{"29watchsessiontoken83":{"device1":{"useragent":"LocusMap","lat":55.423354,"lon":8.32445,"timestamp":1554119133,"batterylevel":0,"satellites":null,"accuracy":16,"altitude":68,"speed":0,"bearing":0},"device2":{"useragent":"Owntracks","lat":55.423321,"lon":8.32478,"timestamp":1554132024,"batterylevel":77,"satellites":null,"accuracy":17,"altitude":91,"speed":null,"bearing":null}}}
Currently custom live tracking in Locus works publish-only, as I understand. My question/idea is: would it be possible to fetch the arbitrary or, in particular, Nextcloud Phonetracker JSON data in Locus to show where other devices are? Marker with timestamp of the last location and a tail with last 5 fetched locations (to have an idea about movement directions) would provide a nice added value.Thanks again for creating a great app!BestSvitozar

Replies (3)

photo
1

Hello,

I am not familiar with the Phonetrack solution and their reply format. It is not currently possible to parse arbitrary JSON from a reply in custom live tracking. Theoretically GeoJSON could be parsed correctly with appropriate MIME type, but it has never been tested in this way as far as I know.

According to the Phonetrack plugin description the solution should also be capable of generating GPX data from the tracked data. If you could get GPX to be sent as a reply instead of the JSON then Locus Map should be able to handle such response correctly.

This similar issue with GPX as a response has already been solved successfully before, so please take a look into that if it would help you.

Best regards

Milan

photo
1

Hi Milan,

I just read this discussion and the solution seems easier to me and should process JSON according to user guide. As I understand, Locus would periodically check the file for changes once every few seconds, right?

I tried to fetch a gpx file for Map Items via remote url https://example.com/index.php/s/Sxtokenr7/download but I receive the invalid value error

the same problem with a public OSM gpx file https://www.openstreetmap.org/trace/2951158/data

no problem with the following explicit link https://sites.google.com/site/tracksgpxdownload/home/BlueRidge.gpx

I found no way to generate direct links in nextcloud. Is it possible to implement downloading files from such non-explicit links in Locus?


Thanks,

Svitozar

photo
1

Hello Svitozar,

Locus Map should indeed process JSON in the specific format of GeoJSON (should probably be made more clear in the manual). It is not possible to parse any arbitrary JSON format as Locus Map cannot possibly understand the semantics of all the possible formats in advance.


The URL links which does not directly containt gpx filename but only return the GPX as a response are a bit problematic and do not work at the moment.


But that should not be needed for the solution described in the mentioned discussion. Your server should return the GPX directly as a response body and correct MIME type as a response to the "track request" with your position data.

Periodic link download can be done with Locus Map through KML format and its network link feature. But if I understand your use case correctly, that should not be needed, no URL generation needed either. GPX body should be returned directly by your live tracking server solution as the response.


Best regards

Milan

Leave a Comment
 
Attach a file