point_count = count($points_array["id_array"]);
for ($i=0; $i<($this->point_count) ; $i++) {
for ($j=$i+1; $j<($this->point_count);$j++) {
$delta_y = $points_array["longitude_array"][$i] - $points_array["longitude_array"][$j];
$delta_x = $points_array["latitude_array"][$i] - $points_array["latitude_array"][$j];
$distance = 110*(sqrt( ($delta_y*$delta_y) + ($delta_x*$delta_x)));
$distance_array[$distance_count] = array($i,$j,round($distance));
$distance_count++;
} //for $j=$i+1
} //for $i=0
return $distance_array;
} // function construct_full_distance_matrix
// limited matrix leaves out the distances that surpass the distance limit
public function construct_limited_distance_matrix($points_array,$distance_limit) {
$distance_count = 0;
$this->point_count = count($points_array["unique_id_array"]);
for ($i=0; $i<($this->point_count) ; $i++) {
for ($j=$i+1; $j<($this->point_count);$j++) {
$delta_y = $points_array["longitude_array"][$i] - $points_array["longitude_array"][$j];
$delta_x = $points_array["latitude_array"][$i] - $points_array["latitude_array"][$j];
$distance = 110*(sqrt( ($delta_y*$delta_y) + ($delta_x*$delta_x)));
if (round($distance)<$distance_limit) {
$distance_array[$distance_count] = array($i,$j,round($distance));
//echo ("i:" . $points_array['unique_id_array'][$i] ."
");
//echo ("j:" . $points_array['unique_id_array'][$j] ."
");
$distance_count++;
} // if
} //for $j=$i+1
} //for $i=0
return $distance_array;
} //function construct_limited_distance_matrix
//private function checkMemory
// check if enough memory is available for n! distances
} // class Distance_matrix
?>