forked from kaitockt/simdChecker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getsimd.php
55 lines (49 loc) · 1.58 KB
/
getsimd.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
// $input = "EH16 5PS";
$input = $_GET['pc'];
include_once 'includes/autoload.inc.php';
$dbh = new Dbh();
$pcv = new PostCodeView();
$fp = new FindPlace();
$dm = new DistanceMatrix();
// $res["Post Code"] = $_GET['pc'];
$res["Post Code"] = $input;
$res["ranks"] = $pcv->showSimdByPostCode($input);
if(!isset($_GET['lat']) || !isset($_GET['lng'])){
//if geometry is not found yet, find it now
$geocode = new Geocode();
//get api key
$key = file_get_contents("apikey.txt", true);
$geocode->curl($input, $key);
$lat = $geocode->getLat();
$lng = $geocode->getLng();
} else {
$lat = $_GET['lat'];
$lng = $_GET['lng'];
}
//list cloest point of interests
// $pois = ["Bus Stop", "Lidl", "Sainsbury", "Aldi", "Costco", "Iceland", "Bar", "School", "Hotel"];
// $pois =[
// "Bus Stop",
// "Lidl",
// "Tesco",
// "Sainsbury",
// "Bar",
// "School",
// "Hotel"
// ];
$origin = $lat.",".$lng;
// $toBus = distanceToClosest($origin, 'bus stop');
// $res["poi"]["Bus Stop"] = $toBus;
// foreach($pois as $poi){
// $res["poi"][$poi] = distanceToClosest($origin, $poi);
// }
$res['origin'] = $origin;
echo json_encode($res);
// function distanceToClosest($origin, $type){
// global $fp, $dm;
// $fp->curl($origin, $type);
// $destination = $fp->getLat().",".$fp->getLng();
// $dm->curl($origin, $destination);
// return $dm->getDuration();
// }