//$data='[{"constraint1":"does","constraint2":"originate","constraint3":"city","constraint4":"Halifax","constraint5":"AND"},{"constraint1":"does","constraint2":"goesVia","constraint3":"city","constraint4":"Toronto","constraint5":"AND"},{"constraint1":"does","constraint2":"terminate","constraint3":"city","constraint4":"Chicago","constraint5":""}]';
    // two
    //$data='[{"constraint1":"does","constraint2":"originate","constraint3":"city","constraint4":"Toronto","constraint5":"AND"},{"constraint1":"does","constraint2":"goesVia","constraint3":"city","constraint4":"Miami","constraint5":"AND"}]';
    $data = json_encode($dataArray);
    // one
    //$data='[{"constraint1":"does","constraint2":"originate","constraint3":"city","constraint4":"Toronto","constraint5":"AND"}]';
    Traceroute::saveSearch($data);
    //Traceroute::testArrays();
    $b = Traceroute::getTraceRoute($data);
    /*	if(count($b)>1000) {
    		echo '<p>The number of traceroutes found is greather than 1000. <br/>Please add new constraints to your query.</p>';
    
    	} else {
    		Traceroute::renderTrSets($b);
    	}*/
    Traceroute::renderTrSets($b);
    //Traceroute::buildWhere($data);
    //$trId = 1813;
    //echo 'TR id: '.$trId.' : Last Hop: '.Traceroute::getLastHop($trId);
    //Traceroute::getHop($trId, 'last');
}
// testing
/*
$c = array_diff($a, $b);
echo '<hr/>Difference: <b>'.count($c).'</b>';
//print_r($c);
Traceroute::renderTrSets($c);

$d = array_intersect($a, $b);
echo '<hr/>Intersects: : <b>'.count($d).'</b>';
//print_r($d);
     $b = Traceroute::processQuickLink($dataArray);
 } else {
     $b = Traceroute::getTraceRoute($dataArray);
 }
 $data = json_encode($dataArray);
 $saveLog = Traceroute::saveSearch($data);
 //Traceroute::saveSearch($data);
 // get IXmaps geographic data and prepare the response into a json format
 //print_r($data);
 if (count($b) != 0) {
     $ixMapsData = Traceroute::getIxMapsData($b);
     //print_r($ixMapsData);
     $ixMapsDataT = Traceroute::dataTransform($ixMapsData);
     //print_r($ixMapsDataT);
     $ixMapsDataStats = Traceroute::generateDataForGoogleMaps($ixMapsDataT);
     $trHtmlTable = Traceroute::renderTrSets($ixMapsDataT);
 }
 // end calculation of execution time
 $mtime = microtime();
 $mtime = explode(" ", $mtime);
 $mtime = $mtime[1] + $mtime[0];
 $endtime = $mtime;
 $totaltime = $endtime - $starttime;
 $totaltime = number_format($totaltime, 2);
 //echo "<hr/>This page was created in <b>".$totaltime."</b> seconds";
 // add db query results/errors
 $ixMapsDataStats['querySummary'] = $dbQuerySummary;
 $ixMapsDataStats['queryLogs'] = $dbQueryHtml;
 //$ixMapsDataStats['queryLogs']=.$dbQueryHtml.'<hr/>'.$saveLog;
 // add excec time
 $ixMapsDataStats['execTime'] = $totaltime;