$queryTime = 0;
$gridTime = 0;
$contourTime = 0;
// query based on timestamp
$readOnly = false;
// disable gzip -- TMH 2012/07/13
$useGzip = false;
// pad with JSONP -- TMH 2012/07/20
$useJSONP = true;
// keep history -- TMH 2012/08/31
$keepHistory = false;
// grid Updated time
$updatedTime = -1;
$phpStart = microtime(true);
$queryManager = new QueryManager($readOnly);
$contourDataStore = new ContourCacheHelper($useGzip, $bandHelper->getSchemeId());
$phpTime = microtime(true) - $phpStart;
// Check if $txnAt for $timestamp is older than specified right now,
// then only proceed. Otherwise just exit from here
// Honour force flag if is set
$lastTxnAt = $txnAt;
if ($txnAt >= 0) {
    $lastTxnAt = $queryManager->getGridUpdatedTime($timestamp);
}
if ($txnAt >= 0 && $lastTxnAt >= $txnAt) {
    echo "Grid last updated with txn stamp [{$lastTxnAt}]," . " more recent than / equal to [{$txnAt}]\n";
    echo "Use force write if it was intended to forcefully update data";
    exit(0);
}
$midTime = microtime(true);
$queryStart = microtime(true);
}
$bandSchema = 0;
if (!empty($_REQUEST['bandschema'])) {
    $bandSchema = intval($_REQUEST['bandschema']);
}
// forece using JSONP by default
$use_jsonp = true;
// option to return JSON, instead of jsonp
if (isset($_REQUEST['forcejson']) && $_REQUEST['forcejson'] == 1) {
    $use_jsonp = false;
}
//$useGzip = true;
$useGzip = false;
$queryManager = new QueryManager();
$bandHelper = new DiscreteBandHelper(DiscreteBandHelper::LABEL_TYPE_BAND, $bandSchema);
$contourDataStore = new ContourCacheHelper($useGzip, $bandHelper->getSchemeId());
$ozoneBand = $bandHelper->getBand();
//$bandHashMap = new Java("java.util.HashMap");
//foreach($ozoneBand as $key => $val) {
//    $bandHashMap->put($key, doubleval($val));
//}
$timestamp = '';
if (isset($_REQUEST['timestamp']) && is_numeric($_REQUEST['timestamp'])) {
    $timestamp = $_REQUEST['timestamp'];
    $month = date('m', $timestamp);
    $day = date('d', $timestamp);
    $year = date('Y', $timestamp);
    $hour = date('H', $timestamp);
    $min = date('i', $timestamp);
    $min = intval($min) - intval($min) % 5;
    $timestamp = mktime($hour, $min, 0, $month, $day, $year);