<?php

$site_root = $_SERVER['DOCUMENT_ROOT'];
require_once "{$site_root}/models/identity/model.php";
require_once "{$site_root}/form-validate.php";
if ($pollutant == 'all') {
    $pollutant = 'pm10';
}
$pollutant_value = model_pollutant_point($lat, $lng, $radius, $datetime, $numresults, $pollutant, $modeltype, $maxfit);
echo $pollutant_value["pred"] . ', ' . $pollutant_value["var"];
$longitudes = NULL;
$datetimes = NULL;
get_file_data("test-data/nik-data.csv", $latitudes, $longitudes, $datetimes);
/*
	var_dump($longitudes);
	exit(0);
*/
$ENABLE_SLOW = false;
/* 	echo "\n<br>counts :".count($latitudes)." ".count($longitudes)." ".count($datetimes)."\n<br>"; */
$levels_slow = array();
if ($ENABLE_SLOW) {
    $numresults = 50;
    $t1 = microtime(true);
    for ($i = 0; $i < count($latitudes); $i++) {
        $datetimes[$i] = date('Y-m-d H:i:s', strtotime($datetimes[$i]));
        $r = model_pollutant_point($latitudes[$i], $longitudes[$i], 100, $datetimes[$i], 200, "pm10");
        array_push($levels_slow, $r);
    }
    $t2 = microtime(true);
    $oldtime = $t2 - $t1;
}
$time_window = 15 * 60;
// 15 minutes
$loc_window = 10;
// km
$t1 = microtime(true);
//$levels_fast = model_pollutant_points_for_locations_and_times_custom_window($latitudes, $longitudes, $datetimes, 'co', $time_window, $loc_window);
$levels_fast = model_pollutant_points_for_locations_and_times($latitudes, $longitudes, $datetimes, 'no2');
$t2 = microtime(true);
$newtime = $t2 - $t1;
/*