$tmp = $export_more;
    unset($tmp['viewer_id']);
    $fingerprint = md5(serialize($tmp));
    $filename = "{$sheet['id']}_{$is_own}_{$fingerprint}.{$format}";
    $cache_more = array('filename' => $filename);
    $cache_path = export_cache_path_for_sheet($sheet, $cache_more);
    #
    $cache_ok = 1;
    if (!file_exists($cache_path)) {
        $cache_ok = 0;
    }
    #
    if ($cache_ok) {
        $export = $cache_path;
    } else {
        $export = export_dots($sheet['dots'], $format, $export_more);
        if ($export) {
            $cache_rsp = export_cache_store_file($export, $cache_path);
            if ($cache_rsp['ok']) {
                unlink($export);
                $export = $cache_rsp['path'];
            }
        }
    }
}
# sad face
if (!$export) {
    error_500();
}
# now send the file to the browser
$send_more = array('path' => $export, 'mimetype' => $map[$format], 'filename' => "dotspotting-sheet-{$sheet['id']}.{$format}", 'inline' => get_str('inline'), 'x-headers' => array('Sheet-ID' => $sheet['id'], 'Sheet-Label' => $sheet['label'], 'Sheet-Extent' => $bbox));
} else {
    $owner_ids = array_keys($owner_ids);
    $sheet_ids = array_keys($sheet_ids);
    $sheet = sheets_get_sheet($sheet_ids[0]);
    $is_own = $owner_ids[0] == $GLOBALS['cfg']['user']['id'] ? 1 : 0;
    $tmp = $export_more;
    $tmp['dot_ids'] = $dot_ids;
    unset($tmp['viewer_id']);
    $fingerprint = md5(serialize($tmp));
    $filename = "{$sheet['id']}_{$is_own}_{$fingerprint}.{$format}";
    $cache_more = array('filename' => $filename);
    $cache_path = export_cache_path_for_sheet($sheet, $cache_more);
    if (file_exists($cache_path)) {
        $export = $cache_path;
    } else {
        $export = export_dots($dots, $format, $export_more);
        if ($export) {
            $cache_rsp = export_cache_store_file($export, $cache_path);
            if (!$cache_rsp['ok']) {
                # log an error...
            }
        }
    }
}
if (!$export) {
    error_500();
}
# go!
$send_more = array('path' => $export, 'mimetype' => $map[$format], 'filename' => "dotspotting-search.{$format}", 'inline' => get_str('inline'));
if ($ok_cache) {
    $send_more['unlink_file'] = 0;