function find_clusters($text, $format = 'json') { $obj = new stdclass(); $obj->text = $text; $strings = explode("\n", trim($text)); $obj->result = cluster($strings); switch ($format) { case 'json': echo json_format(json_encode($obj)); break; case 'html': default: echo '<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <style type="text/css" title="text/css"> body { font-family: sans-serif; margin:20px; } </style> <a href="clusterstrings.php">Home</a> <title>Cluster strings</title> </head> <body> <h1>Cluster strings results</h1>'; echo '<pre>'; echo $obj->result->graph; echo '</pre>'; //echo str_replace("\n", '', $obj->result->graph); $s = urlencode(str_replace("\n", '', $obj->result->graph)); echo '<img src="http://chart.googleapis.com/chart?cht=gv&chl=' . $s . '" />'; echo '<pre>'; print_r($obj->result->clusters); echo '</pre>'; echo '</body> </html>'; break; } }
} else { list($swlat, $swlon, $nelat, $nelon) = explode(',', $coords); $data = get_map_markers(0, 0, $page, $swlat, $nelat, $swlon, $nelon, $categoria_padre, $categoria_actual, $prefijo_categoria); $data_top = get_map_markers(0, 1, $page, $swlat, $nelat, $swlon, $nelon, $categoria_padre, $categoria_actual, $prefijo_categoria); if (isset($_GET['ref'])) { $ref = filter_input(INPUT_GET, 'ref', FILTER_SANITIZE_NUMBER_INT); $content = get_info_marker($ref, $categoria_padre, $categoria_actual, $prefijo_categoria); } } // if (sizeof($data)) { /* if($categoria_padre == 'motor' && $zoom > 13){ rand_markers($data); }*/ $length = count($data); if ($zoom < ZOOM_MAX_CLUSTERING) { $data = cluster($data, DISTANCE, $zoom); } $clustered["EMsg"] = ""; $clustered["Msec"] = 185; $clustered["Ok"] = 1; $clustered["Rid"] = $sid; $clustered["Count"] = sizeof($data); $clustered["CountTotal"] = $length; $clustered["Mia"] = 0; $clustered["Top"] = $data_top; $clustered["Content"] = $content; $clustered["Markers"] = array(); foreach ($data as $key => $marker) { if (isset($marker[0]) && is_array($marker[0])) { $clustered["Markers"][$key] = array("I" => sizeof($marker) == 1 ? $marker[0]['id'] : 0, "X" => $marker[0]['longitud'], "Y" => $marker[0]['latitud'], "C" => sizeof($marker)); } else {
$finalResultStr .= $combinedArray[$i][5]; $finalResultStr .= " <u>Number of Engines:</u> "; $finalResultStr .= $combinedArray[$i][6]; $finalResultStr .= "</em></p><br />"; } $finalResultStr .= "</div>"; $contents = str_replace('<div class="span4" id="divCheckboxBing" style="display: none;"></div> <div class="span4" id="divCheckboxBlekko" style="display: none;"></div> <div class="span4" id="divCheckboxGoogle" style="display: none;"></div>', $finalResultStr, $contents); } //display our clustered results if ($outputType == 3) { $combinedArray = aggregateCombMNZ($googleResultArray, $bingResultArray, $blekkoResultArray); $clusteredArray = $combinedArray; //we will need to look into the object array in order to do the cluster mappings cluster($clusteredArray, 4); //copy the original snippets back into the clustered array $arrSize = sizeof($clusteredArray); for ($i = 0; $i < $arrSize; $i++) { $clusteredArray[$i][1] = $combinedArray[$i][1]; } //sort array by cluster index arraySortByColumn($clusteredArray, 7, SORT_ASC); $finalResultStr .= '<div class="span12">'; $check == 0; for ($i = 0; $i < $arrSize; $i++) { //1. url 2. snippet 3. rank 4. combMNZ 5. aggregated 6. search engine 7. number of engines //this splits off the clusters into differently coloured columns if ($clusteredArray[$i][7] == 1 && $check == 0) { $finalResultStr .= '<div class="span3" style="padding:3px 3px">'; $check = 1;