Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
47 righe
1.0 KiB
PHP
47 righe
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;
|
|
} |