Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

47 rindas
1.0 KiB
PHP

<?php
/**
* Takes the latitude and longitude and gets nearby places from OSM.
*
* Uses WGS84 in the DD.DD format, because I say so.
*/
require 'required.php';
use AnthonyMartin\GeoLocation\GeoLocation as GeoLocation;
if (is_empty($VARS['osmid'])) {
sendError("Missing OSMID.", true);
}
$radius = 5;
if (!is_empty($VARS['radius']) && is_numeric($VARS['radius'])) {
$radius = floatval($VARS['radius']);
}
$place = $database->select('places', '*', ['osmid' => $VARS['osmid']])[0];
$geo['name'] = "Places";
$geo['type'] = 'FeatureCollection';
$geo['features'] = [];
$geo['features'][] = array("type" => "Feature",
"geometry" => [
"type" => "Point",
"coordinates" => [
floatval($place['longitude']),
floatval($place['latitude'])
]
],
"properties" => [
"osm_id" => intval($place['osmid']),
"name" => ($place['name'] == '' ? null : $place['name'])
]
);
//var_dump($geo);
$out = json_encode($geo);
if ($out == false) {
sendError("Server error.");
} else {
echo $out;
}