Ignore:
Timestamp:
12/10/2008 04:45:22 PM (3 years ago)
Author:
Ernest0x
Message:

PHP 5.x fixes (mostly fixes for warnings and notices)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/pages/nodes/nodes_plot_link.php

    r146 r187  
    5959                        $this->tpl['a_node_elevation'] = $a_node_data['elevation'];  
    6060                        $this->tpl['b_node_elevation'] = $b_node_data['elevation'];  
    61                          
     61 
    6262                        $a_node_total_elevation = $this->tpl['a_node_geo_elevation'] + $this->tpl['a_node_elevation'];  
    6363                        $b_node_total_elevation = $this->tpl['b_node_geo_elevation'] + $this->tpl['b_node_elevation'];  
    6464                         
    6565                        $this->tpl['distance'] = $geocalc->GCDistance($a_node_data['latitude'], $a_node_data['longitude'], $b_node_data['latitude'], $b_node_data['longitude']); 
    66                         $this->tpl['a_node_tilt'] = rad2deg(atan(($b_node_total_elevation - $a_node_total_elevation) / ($this->tpl['distance'] * 1000))); 
    67                         $this->tpl['b_node_tilt'] = rad2deg(atan(($a_node_total_elevation - $b_node_total_elevation) / ($this->tpl['distance'] * 1000))); 
     66                        if ($this->tpl['distance'] != 0) { 
     67                                $this->tpl['a_node_tilt'] = rad2deg(atan(($b_node_total_elevation - $a_node_total_elevation) / ($this->tpl['distance'] * 1000))); 
     68                                $this->tpl['b_node_tilt'] = rad2deg(atan(($a_node_total_elevation - $b_node_total_elevation) / ($this->tpl['distance'] * 1000))); 
     69                        } 
     70                        else {  // For links between nodes in the same place but with different elevations (e.g. link between rooftop and floor) 
     71                                // FIXME: plotlink function of geoimage class does not plot anything in that (admitedly rare) case, but perhaps it should(?) 
     72                                $sign = 0; 
     73                                $elev = $b_node_total_elevation - $a_node_total_elevation; 
     74                                if ($elev != 0) $sign = ($elev>0)?1:-1; 
     75                                $this->tpl['a_node_tilt'] = ($elev!=0?$sign:0) * 90; 
     76                                $this->tpl['b_node_tilt'] = -($this->tpl['a_node_tilt']); 
     77                        } 
    6878                        $this->tpl['distance'] = sqrt( pow($this->tpl['distance'] * 1000, 2) + pow( abs($a_node_total_elevation - $b_node_total_elevation), 2 ) ) / 1000; 
    6979                        $this->tpl['gearth'] = makelink(array("page" => "gearth", "subpage" => "download", "node" => get('a_node'), "node2" => get('b_node'), "show_p2p" => "1", "show_aps" => "1", "show_clients" => "1", "show_unlinked" => "1", "show_links_p2p" => "1", "show_links_client" => "1")); 
    70                         $this->tpl['frequency'] = (integer)$_POST['frequency']; 
     80                        $this->tpl['frequency'] = (integer)(isset($_POST['frequency'])?$_POST['frequency']:2450); 
    7181                        if ($this->tpl['frequency'] <= 0) $this->tpl['frequency'] = 2450; 
    7282                        $frequency = $this->tpl['frequency'] * 1000000; 
     
    7484                        $this->tpl['fsl'] = 20 * log10(4 * pi() * $this->tpl['distance'] * ($frequency / $c)); 
    7585                         
    76                         $this->tpl['plot_image'] = makelink(array("page" => "nodes", "subpage" => "plot", "a_node" => $this->tpl['a_node'], "b_node" => $this->tpl['b_node'], "frequency" => $_POST['frequency'])); 
     86                        $this->tpl['plot_image'] = makelink(array("page" => "nodes", "subpage" => "plot", "a_node" => $this->tpl['a_node'], "b_node" => $this->tpl['b_node'], "frequency" => $this->tpl['frequency'])); 
    7787                } 
    7888                 
Note: See TracChangeset for help on using the changeset viewer.