/
info.php
116 lines (99 loc) · 3.53 KB
/
info.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
require_once('config.php');
if(isset($_GET['survey'])){
$survey_key = $_GET['survey'];
if(strlen($survey_key) > 40) exit;
}else{
echo 'No survey id specified!';
exit;
}
$response = $mysqli->query("SELECT * FROM submissions WHERE survey_key = '$survey_key'");
if($response->num_rows == 1){
$row = $response->fetch_assoc();
$survey = json_decode($row['survey_json']);
$photo = $row['photo'];
$submission_id = $row['id'];
// fixme: we could get the surveyor and modified info here
}else{
echo "Survey $survey_key not found";
exit;
}
?>
<div class="tenbreaths-survey-info">
<div class="tenbreaths-survey-info-float">
<?php
if($photo){
echo '<img src="/data/'. $photo .'" />';
}
// the OSM tag cloud
$response = $mysqli->query("SELECT * FROM au_osm_nodes WHERE submission_id = $submission_id");
if($response->num_rows == 1){
include_once('lib/osm_nodes_tag_cloud.php');
$row = $response->fetch_assoc();
osm_nodes_tag_cloud($row['raw']);
}
?>
</div>
<h3>Survey Information</h3>
<p style="color: orange;">This is work in progress!</p>
<p>
<?php
echo $survey->geolocation->display_string;
// var_dump($survey);
?>
</p>
<h3>OpenStreetMap</h3>
<p><strong>Address: </strong>
<?php
$response = $mysqli->query("SELECT * FROM au_osm_reverse_geocode WHERE submission_id = $submission_id");
if($response->num_rows == 1){
$row = $response->fetch_assoc();
$address = json_decode($row['raw']);
echo '<a target="_new" href="';
echo "http://www.openstreetmap.org/#map=16/" . $address->lat . "/". $address->lon ."&layers=C";
echo '" title="' . $address->licence . '">';
echo $address->display_name;
echo '</a>';
}else{
echo "No address found";
}
?>
</p>
<h3>National Biodiversity Network</h3>
<p>All occurrence records from within 500m of this point.</p>
<?php
$response = $mysqli->query("SELECT * FROM au_nbn_point_buffer WHERE submission_id = $submission_id");
if($response->num_rows == 1){
$row = $response->fetch_assoc();
$nbn_data = json_decode($row['raw']);
// first output the totals.
echo '<p><strong>Total species: </strong>'. $row['taxon_count'].'</p>';
echo '<p><strong>Total records: </strong>'. $row['observation_count'].'</p>';
// create a rendering friendly array
$render = array();
foreach($nbn_data as $ob){
if(!isset($render[$ob->taxon->taxonOutputGroupName])){
$sum = new stdClass();
$sum->taxonCount = 1;
$sum->observationCount = $ob->querySpecificObservationCount;
$sum->observations[] = $ob;
$render[$ob->taxon->taxonOutputGroupName] = $sum;
}else{
$sum = $render[$ob->taxon->taxonOutputGroupName];
$sum->taxonCount++;
$sum->observationCount += $ob->querySpecificObservationCount;
$sum->observations[] = $ob;
}
}
ksort($render);
foreach($render as $n => $data){
echo '<p class="nbn-outgroup-taxon">';
echo '<strong>'. $n . ': </strong>';
echo $data->taxonCount . ' taxa ' . $data->observationCount . ' records.';
echo '</p>';
}
}else{
echo "No nbn found";
}
?>
</div>