You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
4.3 KiB

7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. # Compass
  2. Compass is a GPS tracking server that stores data in [flat files](https://github.com/aaronpk/QuartzDB).
  3. ![mapview](screenshot-mapview.jpg)
  4. ## Setup
  5. In the `compass` directory, copy `.env.example` to `.env` and fill in the details. Install the dependencies with composer.
  6. ```
  7. $ composer install
  8. ```
  9. If you're using the database queue driver (`QUEUE_DRIVER=database` defined in `.env`), you'll need to create the migration for that table and run it:
  10. * `php artisan queue:table`
  11. * `php artisan migrate`
  12. Otherwise if you're using Redis, make sure you've installed the Redis server and set `QUEUE_DRIVER=redis`.
  13. Make sure the storage folder you've defined in `STORAGE_DIR` is writable by the web server (or by the PHP process if you're using php-fpm).
  14. To process jobs on the queue, run
  15. ```
  16. $ php artisan queue:listen
  17. ```
  18. For more details on how to configure this to run in the background, see https://lumen.laravel.com/docs/5.1/queues#running-the-queue-listener
  19. ## API
  20. After you create a tracking database, you can visit the database's settings page to get a read or write token. These tokens are used with the API to update or retrieve data.
  21. ### Writing
  22. To write to a database, make a POST request in JSON format with the following keys:
  23. `POST /api/input`
  24. * locations - a list of GeoJSON objects
  25. * token - the write token for the database (as a query string parameter or in the post body)
  26. The GeoJSON objects must have at least one property, "timestamp", which is can be any value that can be interpreted as a date. The object can have any additional properties you wish.
  27. The open source iOS [GPS Logger](https://github.com/aaronpk/GPS-Logger-iOS) will send data in this format by default.
  28. ```
  29. POST /api/input?token=XXXXXXX HTTP/1.1
  30. Content-type: application/json
  31. {
  32. "locations": [
  33. {
  34. "type": "Feature",
  35. "geometry": {
  36. "type": "Point",
  37. "coordinates": [-122.621, 45.535]
  38. },
  39. "properties": {
  40. "timestamp": "2017-01-01T10:00:00-0700",
  41. "horizontal_accuracy": 65
  42. }
  43. }
  44. ],
  45. "token": "XXXXXXX"
  46. }
  47. ```
  48. ### Reading
  49. To read a database, make a GET request as follows:
  50. #### Get all data for a calendar day
  51. `GET /api/query`
  52. * token - (required) the read token for the database
  53. * tz - (optional, default UTC) timezone string (e.g. America/Los_Angeles) which will be used to determine the absolute start/end times for the day
  54. * format - (optional, default "full") either "full" or "linestring"
  55. * full - return one JSON record for each result in the database
  56. * linestring - combine all the returned results into a GeoJSON linestring
  57. * date - specify a date to return all data on that day (YYYY-mm-dd format)
  58. #### Get the last location before a given timestamp
  59. `GET /api/last`
  60. * token - (required) the read token for the database
  61. * tz - (optional, default UTC) timezone string (e.g. America/Los_Angeles) which will be used to determine the absolute start/end times for the day
  62. * before - (optional, default to now) specify a full timestamp to return a single record before this date (the point returned will be no more than 24 hours before the given date)
  63. * geocode - (optional) if "true", then the location found will be reverse geocoded using [Atlas](https://atlas.p3k.io) to find the city and timezone at the location
  64. #### Find the last location matching a clock time
  65. `GET /api/find-from-localtime`
  66. This API method can help you answer the question "Where was I when my watch read 9:30am on July 15th?".
  67. Timestamps in Exif data do not include the timezone offset, and there is no standard mechanism for including the timezone offset in Exif. Some Canon cameras put the offset in a field, but not all of them do. You can use this method to find your location given an Exif date.
  68. * token - (required) the read token for the database
  69. * input - specify a clock time in the format `YYYY-mm-dd HH:MM:SS`
  70. This will query the database and find the closest matching location for when your clock read that time.
  71. ## Credits
  72. Compass icon by Ryan Spiering from the Noun Project.
  73. Screenshot of the map view by Sebastiaan Andeweg.
  74. ## License
  75. Copyright 2015 by Aaron Parecki
  76. Compass is licensed under the [Apache 2.0 license](http://opensource.org/licenses/Apache-2.0)
  77. Compass is built using the Lumen framework, which is licensed under the [MIT license](http://opensource.org/licenses/MIT)