Commit a3cfa74e authored by Feu's avatar Feu

test d'optimisationdu placement

parent 86b2519f
......@@ -418,7 +418,7 @@ class galaxy
$req = new requete($this->db, "SELECT ".
"COUNT(*) ".
"FROM galaxy_star ".
"WHERE id_star != ".intval($except)." AND x_star >= $x1 AND x_star < $x2 AND y_star >= $y1 AND y_star < $y2");
"WHERE id_star NOT IN (".$except.") AND x_star >= $x1 AND x_star < $x2 AND y_star >= $y1 AND y_star < $y2");
list($count) = $req->get_row();
......
......@@ -29,14 +29,32 @@ if ( isset($_GET["optimize"]) )
while ( list($id,$cx,$cy,$l) = $req->get_row() )
{
list($nx,$ny) = $galaxy->find_low_density_point($cx-($l*1.5),$cy-($l*1.5),$l*3,$l*3,$id);
list($nx,$ny) = $galaxy->find_low_density_point($cx-$l,$cy-$l,$l*2,$l*2,$id);
$nx = sprintf("%.f",$nx);
$ny = sprintf("%.f",$ny);
echo "MOVE $id to ($nx, $ny)<br/>\n";
new requete ( $dbrw, "UPDATE galaxy_star set x_star=$nx, y_star=$ny WHERE id_star=$id");
}
list($x1,$y1,$x2,$y2) = $galaxy->limits();
$req = new requete($dbrw,
"SELECT a.id_star, b.id_star, b.x_star, b.y_star
FROM galaxy_star AS a
INNER JOIN galaxy_link AS l ON ( l.id_star_a = a.id_star )
INNER JOIN galaxy_star AS b ON ( l.id_star_b = b.id_star )
WHERE a.nblinks_star=1 AND b.nblinks_star=1");
while ( list($ida,$idb,$x,$y) = $req->get_row() )
{
$d = $galaxy->get_density ( $x-1, $y-1, 2, 2, "$ida,$idb" );
if ( $d > 10 )
{
list($nx,$ny) = $galaxy->find_low_density_point(0,0,$x2,$y2,"$ida,$idb");
echo "MOVE $ida,$idb to ($nx, $ny)<br/>\n";
new requete ( $dbrw, "UPDATE galaxy_star set x_star=$nx, y_star=$ny WHERE id_star=$ida OR id_star=$idb");
}
}
exit();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment