您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

place.php 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Takes the latitude and longitude and gets nearby places from OSM.
  4. *
  5. * Uses WGS84 in the DD.DD format, because I say so.
  6. */
  7. require 'required.php';
  8. use AnthonyMartin\GeoLocation\GeoLocation as GeoLocation;
  9. if (is_empty($VARS['osmid'])) {
  10. sendError("Missing OSMID.", true);
  11. }
  12. $radius = 5;
  13. if (!is_empty($VARS['radius']) && is_numeric($VARS['radius'])) {
  14. $radius = floatval($VARS['radius']);
  15. }
  16. $place = $database->select('places', '*', ['osmid' => $VARS['osmid']])[0];
  17. $geo['name'] = "Places";
  18. $geo['type'] = 'FeatureCollection';
  19. $geo['features'] = [];
  20. $geo['features'][] = array("type" => "Feature",
  21. "geometry" => [
  22. "type" => "Point",
  23. "coordinates" => [
  24. floatval($place['longitude']),
  25. floatval($place['latitude'])
  26. ]
  27. ],
  28. "properties" => [
  29. "osm_id" => intval($place['osmid']),
  30. "name" => ($place['name'] == '' ? null : $place['name'])
  31. ]
  32. );
  33. //var_dump($geo);
  34. $out = json_encode($geo);
  35. if ($out == false) {
  36. sendError("Server error.");
  37. } else {
  38. echo $out;
  39. }