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.

86 lines
2.5 KiB

11 years ago
​
3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
9 years ago
​
​
​
​
  1. # Atlas
  2. Atlas is a set of APIs to look up information about locations.
  3. ## Timezone
  4. Retrieving the timezone at a lat/lng
  5. * `/api/timezone?latitude=45.5118&longitude=-122.6433`
  6. * `/api/timezone?airport=PDX`
  7. ## Geocoder
  8. Retrieving the lat/lng for a named location
  9. * `/api/geocode?input=309+SW+6th+Ave,+Portland,+OR`
  10. Retrieving a named location from a lat/lng
  11. * `/api/geocode?latitude=45.5118&longitude=-122.6433`
  12. * `/api/geocode?latitude=45.5118&longitude=-122.6433&date=2016-07-012T09:00:00Z` and return the local time of the given timestamp
  13. ## Weather
  14. Retrieving the current weather for a lat/lng
  15. * `/api/weather?latitude=45.5118&longitude=-122.6433&apikey=XXX`
  16. You'll need to pass an OpenWeatherMap.org API key in the request. Icon names reference the [weather-icons](https://erikflowers.github.io/weather-icons/) icon font.
  17. ## Static Maps
  18. * `/map/img?marker[]=lat:45.5165;lng:-122.6764;icon:small-blue-cutout&basemap=gray&width=600&height=240&zoom=14`
  19. [Full Static Maps Docs](https://atlas.p3k.io/static-maps)
  20. ## Running the web app
  21. Atlas has no framework dependencies. Point a web server at `public/` with
  22. `index.php` as the front controller (an `.htaccess` for Apache is included;
  23. for nginx use `try_files $uri /index.php?$args;`), then run `composer install`.
  24. Requests carrying a `token` listed in `data/apikeys.txt` (one per line) may use
  25. custom tile URLs (`basemap=custom&tileurl=...`) and external marker icons.
  26. For development: `php -S 127.0.0.1:8080 -t public`
  27. ## Using Atlas as a library
  28. ```
  29. composer require p3k/atlas
  30. ```
  31. Static maps are rendered in memory; nothing is echoed and no headers are sent:
  32. ```php
  33. $image = p3k\geo\StaticMap\render([
  34. 'marker' => ['lat:45.5165;lng:-122.6764;icon:small-blue-cutout'],
  35. 'basemap' => 'gray',
  36. 'width' => 600,
  37. 'height' => 240,
  38. 'zoom' => 14,
  39. ]);
  40. // $image['data'] is the PNG (or JPEG, with format=jpg), $image['contentType'] its MIME type
  41. ```
  42. The bundled marker icons are used by default; pass a directory as the second
  43. argument to use your own, and `true` as the third to allow custom tile URLs.
  44. Airports and timezones:
  45. ```php
  46. $airport = p3k\Airports::from_code('PDX'); // ['code','latitude','longitude','name'] or false
  47. $timezone = p3k\Timezone::timezone_for_location($airport['latitude'], $airport['longitude']);
  48. $result = new p3k\timezone\Result($timezone, '2026-10-02'); // ->name, ->offset ("-07:00"), ->seconds, ->localtime
  49. ```
  50. ## License
  51. Available under the Apache 2.0 license. See [[LICENSE]].
  52. Copyright 2015-2022 by Aaron Parecki.