-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetWay.php
60 lines (47 loc) · 1.54 KB
/
getWay.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
56
57
58
59
60
<?php
$arrayStops = array();
$arrayStopsId = array();
function cordDecoder($c) {
$str = "";
for ($i = 0; $i < strlen($c); $i++) {
$str .= $c[$i];
if ($i == 1) {
$str .= ".";
}
}
return $str;
}
$mysqli = @new mysqli('mysql.daminik00.myjino.ru', 'daminik00', 'luabeo', 'daminik00_routes');
if (mysqli_connect_errno()) {
echo "Подключение невозможно: ".mysqli_connect_error();
}
$mysqli->query ("SET NAMES 'utf8'");
$result_set = $mysqli->query ("SELECT * FROM `routes`");
$ab = "";
while (($row = $result_set->fetch_assoc()) != false) {
$ab = $row["ab"];
break;
return;
}
$result_set = $mysqli->query ("SELECT * FROM `ab` WHERE id = '{$ab}'");
while (($row = $result_set->fetch_assoc()) != false) {
$arrayStopsId = split(',', $row["RouteStops"]);
}
// print_r($arrayStopsId);
$result_set = $mysqli->query ("SELECT * FROM `stops`");
while (($row = $result_set->fetch_assoc()) != false) {
if (in_array($row['id'], $arrayStopsId)) {
$lat = cordDecoder($row['Lat']);
$lng = cordDecoder($row['Lng']);
$arrayStops[] = array("lat" => $lat, "lng" => $lng, "googleMaps" => "".$lat." ".$lng);
}
}
$path = $arrayStops[0]['googleMaps'];
for ($i = 1; $i < count($arrayStops); $i++) {
$path .= "|".$arrayStops[$i]['googleMaps'];
}
$url = "https://roads.googleapis.com/v1/snapToRoads?path=".$path."&interpolate=true&key=AIzaSyAW3kP-9G3kMq2_3vxMVTJKaNPuEfTDgcQ";
echo "<pre>";
print_r($url);
echo "</pre>";
?>