Add GeoJSON output format option to getnearby
This commit is contained in:
parent
11b61a7125
commit
dc42241515
@ -46,6 +46,35 @@ ob_end_clean();
|
||||
|
||||
$nearby = [];
|
||||
|
||||
if (!empty($VARS["format"]) && $VARS["format"] == "geojson") {
|
||||
$geojson = [
|
||||
"name" => "Nearby People",
|
||||
"type" => "FeatureCollection",
|
||||
"features" => []
|
||||
];
|
||||
|
||||
foreach ($people as $person) {
|
||||
$geojson["features"][] = [
|
||||
"type" => "Feature",
|
||||
"geometry" => [
|
||||
"type" => "Point",
|
||||
"coordinates" => [
|
||||
$person["longitude"] * 1.0,
|
||||
$person["latitude"] * 1.0
|
||||
]
|
||||
],
|
||||
"properties" => [
|
||||
"id" => $person["publicid"],
|
||||
"name" => utf8_encode(empty($person["name"]) ? $person["username"] : $person["name"]),
|
||||
"username" => $person["username"],
|
||||
"verified" => $person["verified"] == 1
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
exitWithJson($geojson);
|
||||
}
|
||||
|
||||
foreach ($people as $person) {
|
||||
$nearby[] = [
|
||||
"name" => (empty($person["name"]) ? $person["username"] : $person["name"]),
|
||||
|
@ -72,7 +72,8 @@ $APIS = [
|
||||
"key" => $keyregex,
|
||||
"latitude" => "/-?[0-9]{2}\.[0-9]+/",
|
||||
"longitude" => "/-?[0-9]{2,3}\.[0-9]+/",
|
||||
"radius (optional)" => "/[0-9]*\.?[0-9]+/"
|
||||
"radius (optional)" => "/[0-9]*\.?[0-9]+/",
|
||||
"format (optional)" => "/(geojson)/"
|
||||
]
|
||||
],
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user