Skip to content
Snippets Groups Projects
Commit c237d6b9 authored by Hakkel Tamás's avatar Hakkel Tamás
Browse files

photos time-precision bugfix, reintroduction of location-based burst detection

parent 9255a112
No related branches found
No related tags found
No related merge requests found
......@@ -9,10 +9,10 @@ else
// Once the page is loaded, we do not want to send already loaded images
if (isset($_POST['last_timestamp'])) {
$last_timestamp = (float)$_POST['last_timestamp'];
$last_timestamp = $_POST['last_timestamp'];
$limit = 100;
} else{
$last_timestamp = time()*1000;
$last_timestamp = bcmul(time(),1000);
$limit = 500;
}
......@@ -49,11 +49,10 @@ if (isset($_POST['accepted']) OR isset($_POST['rejected'])) {
// Query for images
$query = '
SELECT photo_ID,timestamp
SELECT photo_ID,timestamp, xmin, ymin, xmax, ymax
FROM photo JOIN user USING(card_ID)
WHERE shibboleth=:shibboleth
AND is_it_sure = '.
(isset($_POST['page']) && $_POST['page'] === 'unverified' ? 0 : 1).'
AND is_it_sure = '.($_POST['page'] === 'unverified' ? '0' : '1').'
AND timestamp < :last_timestamp
ORDER BY timestamp DESC
LIMIT '.$limit;
......@@ -68,19 +67,35 @@ class Burst {
var $first_timestamp;
var $last_timestamp;
var $items = array();
var $grouping_time = 3000;
var $grouping_time = 1500;
var $xmin, $ymin, $xmax, $ymax;
function __construct($new_item) {
$this->first_timestamp = $new_item['timestamp'];
$this->xmin = $new_item['xmin'];
$this->ymin = $new_item['ymin'];
$this->xmax = $new_item['xmax'];
$this->ymax = $new_item['ymax'];
$this->add($new_item);
}
function check($new_item) {
return $new_item['timestamp'] - $this->last_timestamp < $this->grouping_time;
$new_x_middle = ($new_item['xmin'] + $new_item['xmax']) / 2;
$new_y_middle = ($new_item['ymin'] + $new_item['ymax']) / 2;
$width = $new_item['xmax'] - $new_item['xmin'];
$height = $new_item['ymax'] - $new_item['ymin'];
return
$this->last_timestamp - $new_item['timestamp'] < $this->grouping_time AND
$this->xmin - $width*.5 < $new_x_middle AND $new_x_middle < $this->xmax + $width*.5 AND
$this->ymin < $new_y_middle AND $new_y_middle < $this->ymax;
}
function add($new_item) {
$this->last_timestamp = $new_item['timestamp'];
$this->xmin = $new_item['xmin'];
$this->ymin = $new_item['ymin'];
$this->xmax = $new_item['xmax'];
$this->ymax = $new_item['ymax'];
array_push($this->items, $new_item['photo_ID']);
}
......
......@@ -31,7 +31,7 @@ function receivePhotos(data) {
var photos = parsed['photos'];
last_timestamp = parsed['last_timestamp'];
var div = $(document.createElement('div'));
for (var date of Object.keys(photos).reverse()) {
for (var date of Object.keys(photos)) {
var group_template = $("#img-group-template > div").clone(true);
group_template.find("p").text(parseTimestamp(date));
group_template.find("a").attr("data-group",date);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment