From 64c16118679b99a4044190af454f3ea161af5959 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Tue, 1 Nov 2016 01:58:58 -0600 Subject: [PATCH] Add API to get a single place using OSMID --- place.php | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 place.php diff --git a/place.php b/place.php new file mode 100644 index 0000000..d80f282 --- /dev/null +++ b/place.php @@ -0,0 +1,46 @@ +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']) + ] +); + +$out = json_encode($geo); +if ($out == false) { + sendError("Server error."); +} else { + echo $out; +} \ No newline at end of file