-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathManualOutputImage.php
More file actions
73 lines (56 loc) · 2.01 KB
/
Copy pathManualOutputImage.php
File metadata and controls
73 lines (56 loc) · 2.01 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* Created by PhpStorm.
* User: starstryder
* Date: 5/25/19
* Time: 2:12 PM
*/
// Connect to Database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully\n";
// --------------------------------
$imageset_id = 4211;
$image_name = "20190321T180657S512_pol_iofL2pan.png";
// --------------------------------
// Output a header
echo "id\t image_name\t x\t y\t diameter\t type\t details\t date\t user_id\n";
// Find all images related to that image set and get their offsets
$sql = "SELECT * FROM images WHERE image_set_id = ".$imageset_id;
$result = mysqli_query($conn, $sql);
while($image = mysqli_fetch_assoc($result)) {
$coord = json_decode($image['details'], true);
echo $coord['x']." ".$coord['y']."\n";
// Get all members of the marks and output data
$sql = "SELECT * FROM marks WHERE image_id = ".$image['id'];
$result2 = mysqli_query($conn, $sql);
while($mark = mysqli_fetch_assoc($result2)) {
$x = $mark['x'] + $coord['x'];
$y = $mark['y'] + $coord['y'];
if(!strncmp($mark['details'],"{\"points",5)) {
$boulder = json_decode($mark['details'],true);
$details = '{"points":[{"x":';
$details .= $boulder['points'][0]['x'];
$details .= ',"y":';
$details .= $boulder['points'][0]['y'];
$details .= '},{"x":';
$details .= $boulder['points'][1]['x'];
$details .= ',"y":';
$details .= $boulder['points'][1]['y'];
$details .= '}]}';
}
else {
$details = '[]';
}
echo $mark['id'] ."\t". $image_name ."\t". $x ."\t". $y ."\t". $mark['diameter'] ."\t". $mark['type'] ."\t". $details ."\t". $mark['created_at'] ."\tuser_id". $mark['user_id'] ."\n";
}
}
?>