-
Notifications
You must be signed in to change notification settings - Fork 3
/
load_annotations.php
32 lines (27 loc) · 973 Bytes
/
load_annotations.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
<?php
$connection = pg_connect("host=localhost port=5432 dbname=bridges user=postgres password=root");
if (!$connection) {
echo "An error occurred.<br>";
exit;
}
// Fetch existing annotations from the database
$query = "SELECT * FROM annotations ORDER BY id";
$result = pg_query($connection, $query);
$annotations = array();
while ($row = pg_fetch_assoc($result)) {
$row['pos_x'] = floatval($row['pos_x']);
$row['pos_y'] = floatval($row['pos_y']);
$row['pos_z'] = floatval($row['pos_z']);
$row['campos_x'] = floatval($row['campos_x']);
$row['campos_y'] = floatval($row['campos_y']);
$row['campos_z'] = floatval($row['campos_z']);
$row['tarpos_x'] = floatval($row['tarpos_x']);
$row['tarpos_y'] = floatval($row['tarpos_y']);
$row['tarpos_z'] = floatval($row['tarpos_z']);
$annotations[] = $row;
}
// Close the database connection
pg_close($connection);
// Return the annotations as JSON
echo json_encode($annotations);
?>