25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.0 KiB
PHTML

<?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'])
]
);
5 년 전
//var_dump($geo);
$out = json_encode($geo);
if ($out == false) {
sendError("Server error.");
} else {
echo $out;
}