Pengujian sistem

4.4.4 Pengujian sistem

Pengujian sistem merupakan salah satu tahapan terpenting dalam penelitian ini untuk menemukan kesalahan-kesalahan atau kekurangan-kekurangan pada setiap bagian sistem yang diuji. Adapun teknik pengujian yang dilakukan yaitu pengujian Black Box. pengujian berfokus pada persyaratan fungsional perangkat lunak

4.4.4.1 Hasil Whitebox Testing

White box testing merupakan pengujian yang memperhitungkan mekanisme internal sistem atau komponen. White box testing menguji jalur perhitungan internal untuk mengidentifikasi bug dengan menyelidiki kebenaran struktur kode (Galin 2004).

1. Pseudocode untuk menyimpan menampilkan rute menuju lokasi tumbuhan. 1. <?php

$db = new database; $db2

= new database; $db3

= new database; $if

= new user_interface; $start = microtime(true);

$locs = explode(";",$curLoc); $lat

= $locs[0]; $long = $locs[1];

2. $kordTarget

= $this->getSpecLocationTerdekat($lat, $long, $spec); $nodeDekat

= $this->getNodeTerdekat($curLoc); $nodeTujuan

= $this->getNodeTerdekat($kordTarget); $garis_awal

= $this->garis($curLoc, $nodeDekat, "255,0,0");

3. $head

= "<table class=\"tabel-rute\" align=\"right\" border=1>"; $header

= "<tr class=\"tr\"> <td class=\"td\">Node Saat Ini</td>

<td class=\"td\">Node Selanjutnya</td> <td class=\"td\">Nilai</td> <td class=\"td\">Heuristik</td> <td class=\"td\">Harga</td> <td class=\"td\">path</td></tr>";

4. $NodeSaatIni = "A*"; $Tujuan

= "T"; $Selanjutnya

= $this->getNode($nodeDekat); $Target = $this->getNode($nodeTujuan); $nilai1

= $this->haversine($this->getLat($curLoc), $this->getLong($curLoc), $this->getLat($nodeDekat), $this->getLong($nodeDekat));

$heur1 = $this->haversine($this->getLat($curLoc), $this->getLong($curLoc), $this->getLat($kordTarget), $this->getLong($kordTarget));

5. $harga1

= $nilai1 + $heur1; $path

= $NodeSaatIni."-".$Selanjutnya; $path_b

= $path; $row1

= "<tr class=\"tr\"> <td class=\"td\">".$NodeSaatIni."</td>

<td class=\"td\">".$Selanjutnya."</td> <td class=\"td\">".$if->round_out($nilai1,2)."</td> <td class=\"td\">".$if->round_out($heur1,2)."</td> <td class=\"td\">".$if->round_out($harga1,2)."</td> <td class=\"td\">".$path."</td></tr>";

6. $harga1

= $nilai1 + $heur1; $path

= $NodeSaatIni."-".$Selanjutnya; $path_b

= $path; $row1

= "<tr class=\"tr\"> <td class=\"td\">".$NodeSaatIni."</td> <td class=\"td\">".$Selanjutnya."</td> <td class=\"td\">".$if->round_out($nilai1,2)."</td> <td class=\"td\">".$if->round_out($heur1,2)."</td> <td class=\"td\">".$if->round_out($harga1,2)."</td> <td class=\"td\">".$path."</td></tr>";

7. while ($KordSaatIni <> $kordTarget){

= false; $closed = 0;

$sqlNode = "SELECT * FROM relasi WHERE node

='".$now."'";

$jmlNode = $db->getJumlahDariQuery($sqlNode); $db->query($sqlNode); $nowKord

= $this->node2Kordinat($now);

$db3->query($sqlNode);

8. while ($OpenList2

= $db3->tampilkan()){

9. if(in_array($OpenList2['next'],$closed_list)>0){ 10. $closed = $closed+1;

11. while ($OpenList

= $db->tampilkan()){ $temp_path

>node2Kordinat($OpenList['next']); $garis_kuning = $garis_kuning. $this->garis($nowKord,$nextKord,"255, 206, 67"); $sqlNode_cek = "SELECT * FROM relasi WHERE

node ='".$OpenList['next']."'";

$jml = $db2->getJumlahDariQuery($sqlNode_cek);

12. if ($jml==1){ 13. $buntu = true;

$closed= $closed+1;

}else{

14. $buntu = false;

15. if(in_array($OpenList['next'],$closed_list)==0 && $buntu==false){

16. $nilai = $this->haversine($this->getLat($nowKord),

$this->getLong($nowKord), $this->getLat($nextKord), $this->getLong($nextKord));

$heur = $this->haversine($this->getLat($nextKord), $this->getLong($nextKord), $this->getLat($kordTarget), $this->getLong($kordTarget));

$harga = $nilai + $heur; $temp_path = $temp_path."-".$OpenList['next'];

$temp_rows = "<tr class=\"tr\"> <td class=\"td\">".$now."</td> <td class=\"td\">".$OpenList['next']."</td> <td class=\"td\">".$if->round_out($nilai,2)."</td> <td class=\"td\">".$if->round_out($heur,2)."</td> <td class=\"td\">".$if->round_out($harga,2)."</td> <td class=\"td\">".$temp_path."</td></tr>";

$rows = $rows.$temp_rows; array_push($temp_node, $OpenList['next']); array_push($temp_harga, $if->round_out($harga,2)); array_push($open_list, $temp_path); } 17. if($closed==$jmlNode ){

18 $counts = array_count_values($closed_list); $jmlNodeClosed = $counts[$OpenList['next']]; $porbid1 = substr($path, -5, -3);

19. if($jmlNodeClosed>1){ 20. $simpul2

= true;}

21. if($OpenList['next']<>$porbid1 && $jmlNodeClosed<=1){ 22. $nilai = $this->haversine($this->getLat($nowKord),

$this->getLong($nowKord), $this->getLat($nextKord), $this->getLong($nextKord));

$heur = $this->haversine($this->getLat($nextKord), $this->getLong($nextKord), $this->getLat($kordTarget), $this->getLong($kordTarget));

$harga = $heur; $temp_path

= $temp_path."-".$OpenList['next']; $temp_rows

= "<tr class=\"tr\">

<td class=\"td\">".$now."</td> <td class=\"td\">".$OpenList['next']."</td> <td class=\"td\">".$if->round_out($nilai,2)."</td> <td class=\"td\">".$if->round_out($heur,2)."</td> <td class=\"td\">".$if->round_out($harga,2)."</td> <td class=\"td\">".$temp_path."</td></tr>";

$rows = $rows.$temp_rows; array_push($temp_node, $OpenList['next']); array_push($temp_harga, $if->round_out($harga,2)); array_push($open_list, $temp_path);

} } 23. if($OpenList['next']==strtoupper($Target)){

24. $found = true;

} } 25. if(!empty($temp_harga)){

26. $terkecil = min($temp_harga);

$key = array_search($terkecil, $temp_harga); array_push($closed_list, $temp_node[$key]);

} 27. if($found==true){ 28. array_push($temp_node, $Tujuan);

= $this->haversine($this-> getLat($this->node2Kordinat($temp_node[$key])), $this->getLong($this- >node2Kordinat($temp_node[$key])), $this->getLat($kordTarget), $this->getLong($kordTarget));

$heurTujuan

$rowLast = "<tr class=\"tr\">

<td class=\"td\">".$temp_node[$key]."</td> <td class=\"td\">T</td> <td class=\"td\">-</td>

<td class=\"td\">-</td> <td class=\"td\">".$if->round_out($heurTujuan,2)."</td> <td class=\"td\">".$temp_path."-T</td></tr>";

$garis_akhir = $this->garis($this->node2Kordinat ($temp_node[$key]), $kordTarget, "255,0,0"); array_push($temp_harga, $if->round_out($heurTujuan,2)); array_push($open_list, $temp_path."-T"); $KordSaatIni

= $kordTarget; $nodes

= explode("-",$temp_path); $countNodes

= count($nodes);

29. for($x=1; $x<($countNodes-1); $x++){

= $garis_biru.$this->garis( $this->node2Kordinat($nodes[$x]), $this->node2Kordinat($nodes[$x+1]),"0, 0, 255"); }

$garis_biru

}else{ 30. $NodeSaatIni= $this->node2Kordinat($temp_node[$key]); 31. if($simpul2==false){

32. $path = $open_list[$key];

$next = $temp_node[$key]; }else{

33. $path = $path_b; $next = $Selanjutnya;

34. $garis_hijau

= $garis_hijau.$this->garis($nowKord,

$this->node2Kordinat($temp_node[$key]),"0, 255, 0"); $temp_harga

= array();

$temp_node

= array();

$open_list

= array();

35. $closer

= "</table>";

$this->GarisRute= $garis_awal.$garis_kuning.$garis_hijau.

$garis_biru.$garis_akhir;

$this->TableRute= $head.$header.$row1.$rows.$rowLast.$closer; $this->wktProses= microtime(true) - $start; ?>