Changeset 129


Ignore:
Timestamp:
01/05/2006 06:36:43 AM (6 years ago)
Author:
Winner
Message:

Change: Plotting methods added into classes.
Add: SRTM path in config file.
Add: FSL calculation by frequency.
Fix: Fresnel zone correction by elevation variation.
Fix: Distance calculation via GeoCalc? class only.
Fix: Distance correction by elevation variation.

Location:
trunk
Files:
3 added
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/config-sample/config.php

    r106 r129  
    6060                ), 
    6161         
     62        'srtm' => array( 
     63                'path' => $root_path.'files/srtm/' 
     64                ), 
     65                 
    6266        'gmap' => array( 
    6367                'server' => 'maps.google.com', 
  • trunk/includes/pages/nodes/nodes_plot_link.php

    r5 r129  
    2020 */ 
    2121  
    22 $plot_path = $root_path."plot/"; 
    23 include_once $root_path."plot/elevation.php"; 
    2422include_once($root_path.'globals/classes/geocalc.php'); 
     23$geocalc = new geocalc(); 
     24 
     25include_once($root_path.'globals/classes/srtm.php'); 
     26$srtm = new srtm($vars['srtm']['path']); 
    2527 
    2628class nodes_plot_link { 
     
    3335 
    3436        function output() { 
    35                 global $main, $db; 
     37                global $main, $db, $geocalc, $srtm; 
    3638                $main->header->hide = TRUE; 
    3739                $main->menu->hide = TRUE; 
     
    5153                 
    5254                if ($this->tpl['a_node'] != '' && $this->tpl['b_node'] != '') { 
    53                         $gc = new GeoCalc(); 
    54                         $this->tpl['a_node_azimuth'] = $gc->GCAzimuth($a_node_data['latitude'], $a_node_data['longitude'], $b_node_data['latitude'], $b_node_data['longitude']); 
    55                         $this->tpl['b_node_azimuth'] = $gc->GCAzimuth($b_node_data['latitude'], $b_node_data['longitude'], $a_node_data['latitude'], $a_node_data['longitude']); 
    56                         $this->tpl['a_node_elevation'] = get_elevation($a_node_data['latitude'], $a_node_data['longitude']) + $a_node_data['elevation'];  
    57                         $this->tpl['b_node_elevation'] = get_elevation($b_node_data['latitude'], $b_node_data['longitude']) + $b_node_data['elevation'];  
    58                         $frequency = 2400000000; 
     55                        $this->tpl['a_node_azimuth'] = $geocalc->GCAzimuth($a_node_data['latitude'], $a_node_data['longitude'], $b_node_data['latitude'], $b_node_data['longitude']); 
     56                        $this->tpl['b_node_azimuth'] = $geocalc->GCAzimuth($b_node_data['latitude'], $b_node_data['longitude'], $a_node_data['latitude'], $a_node_data['longitude']); 
     57                        $this->tpl['a_node_geo_elevation'] = $srtm->get_elevation($a_node_data['latitude'], $a_node_data['longitude']);  
     58                        $this->tpl['b_node_geo_elevation'] = $srtm->get_elevation($b_node_data['latitude'], $b_node_data['longitude']); 
     59                        $this->tpl['a_node_elevation'] = $a_node_data['elevation'];  
     60                        $this->tpl['b_node_elevation'] = $b_node_data['elevation'];  
     61                         
     62                        $a_node_total_elevation = $this->tpl['a_node_geo_elevation'] + $this->tpl['a_node_elevation'];  
     63                        $b_node_total_elevation = $this->tpl['b_node_geo_elevation'] + $this->tpl['b_node_elevation'];  
     64                         
     65                        $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))); 
     68                        $this->tpl['distance'] = sqrt( pow($this->tpl['distance'] * 1000, 2) + pow( abs($a_node_total_elevation - $b_node_total_elevation), 2 ) ) / 1000; 
     69 
     70                        $this->tpl['frequency'] = (integer)$_POST['frequency']; 
     71                        if ($this->tpl['frequency'] <= 0) $this->tpl['frequency'] = 2450; 
     72                        $frequency = $this->tpl['frequency'] * 1000000; 
    5973                        $c = 299792.458; // light speed in km 
    60                         $this->tpl['distance'] = $gc->GCDistance($a_node_data['latitude'], $a_node_data['longitude'], $b_node_data['latitude'], $b_node_data['longitude']); 
    6174                        $this->tpl['fsl'] = 20 * log10(4 * pi() * $this->tpl['distance'] * ($frequency / $c)); 
    62                         $this->tpl['a_node_tilt'] = rad2deg(atan(($this->tpl['b_node_elevation'] - $this->tpl['a_node_elevation']) / ($this->tpl['distance'] * 1000))); 
    63                         $this->tpl['b_node_tilt'] = rad2deg(atan(($this->tpl['a_node_elevation'] - $this->tpl['b_node_elevation']) / ($this->tpl['distance'] * 1000))); 
     75                         
     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'])); 
    6477                } 
    6578                 
  • trunk/includes/pages/nodes/nodes_view.php

    r103 r129  
    2020 */ 
    2121 
    22 $plot_path = $root_path."plot/"; 
    23 include_once $root_path."plot/elevation.php"; 
     22include_once($root_path.'globals/classes/geocalc.php'); 
     23$geocalc = new geocalc(); 
     24 
     25include_once($root_path.'globals/classes/srtm.php'); 
     26$srtm = new srtm($vars['srtm']['path']); 
    2427 
    2528class nodes_view { 
     
    3235 
    3336        function calculate_distance($a_node, $b_node) { 
    34                 global $db; 
     37                global $db, $geocalc, $srtm; 
    3538                $a_node_i = $db->get('latitude, longitude, elevation', 'nodes', "id = '".$a_node."'"); 
    3639                $b_node_i = $db->get('latitude, longitude, elevation', 'nodes', "id = '".$b_node."'"); 
     
    4144                $lon2 = $b_node_i[0]['longitude']; 
    4245 
    43                 $a_node_el = str_replace(",", ".", get_elevation($lat1, $lon1, FALSE)); 
    44                 $b_node_el = str_replace(",", ".", get_elevation($lat2, $lon2, FALSE)); 
    45                  
    46                 $dist   = acos(sin(deg2rad($lat1)) 
    47                                   * sin(deg2rad($lat2)) 
    48                                   + cos(deg2rad($lat1)) 
    49                                   * cos(deg2rad($lat2)) 
    50                                   * cos(deg2rad($lon1 - $lon2))); 
    51                  
    52                 $dist   = rad2deg($dist); 
    53                  
    54                 $miles  = (float) $dist * 69; 
    55                  
    56                 $meters = (float) $miles * 1610; 
     46                $a_node_el = str_replace(",", ".", $srtm->get_elevation($lat1, $lon1, FALSE)); 
     47                $b_node_el = str_replace(",", ".", $srtm->get_elevation($lat2, $lon2, FALSE)); 
     48                 
     49                $dist   = $geocalc->GCDistance($lat1, $lon1, $lat2, $lon2); 
    5750                 
    5851                if ($a_node_el != FALSE && $b_node_el != FALSE) { 
    5952                        $a_node_el += (integer)$a_node_i[0]['elevation']; 
    6053                        $b_node_el += (integer)$b_node_i[0]['elevation']; 
    61                         $meters = sqrt( pow($meters, 2) + pow( abs($a_node_el - $b_node_el), 2 ) ); 
    62                 } 
    63                  
    64                 $km     = (float) $meters / 1000; 
    65  
    66                 return $km; 
     54                        $dist = sqrt( pow($dist * 1000, 2) + pow( abs($a_node_el - $b_node_el), 2 ) ) / 1000; 
     55                } 
     56 
     57                return $dist; 
    6758        } 
    6859         
  • trunk/templates/basic/generic/plot.tpl

    r48 r129  
    2222<tr><td colspan="3" class="plot-title">{$lang.plot}</td></tr> 
    2323<tr><td width="33%" align="left">{$data[rowl].node_name|escape} (#{$data[rowl].node_id})</td><td width="33%" align="center">-- {$data[rowl].distance|round:3}km --</td><td align="right">{$data[rowl].peer_node_name|escape} (#{$data[rowl].links__peer_node_id})</td></tr> 
    24 <tr><td colspan="3" align="center"><a href="" onclick="javascript: t = window.open('?page=nodes&subpage=plot_link&a_node={$data[rowl].node_id}&b_node={$data[rowl].links__peer_node_id}', 'popup_plot_link', 'width=600,height=420,toolbar=0,resizable=1,scrollbars=1'); t.focus(); return false;"><img src="?page=nodes&subpage=plot&a_node={$data[rowl].node_id}&b_node={$data[rowl].links__peer_node_id}&width=300&height=150" width="300" height="150" alt="{$lang.plot}" /></a></td></tr> 
     24<tr><td colspan="3" align="center"><a href="" onclick="javascript: t = window.open('?page=nodes&subpage=plot_link&a_node={$data[rowl].node_id}&b_node={$data[rowl].links__peer_node_id}', 'popup_plot_link', 'width=600,height=450,toolbar=0,resizable=1,scrollbars=1'); t.focus(); return false;"><img src="?page=nodes&subpage=plot&a_node={$data[rowl].node_id}&b_node={$data[rowl].links__peer_node_id}&width=300&height=150" width="300" height="150" alt="{$lang.plot}" /></a></td></tr> 
    2525</table> 
  • trunk/templates/basic/includes/pages/nodes/nodes_plot_link.tpl

    r120 r129  
    3535        <input class="fld-form-input-pickup" type="text" disabled="disabled" name="a_node_output" value="{$a_node_output|escape}" /> 
    3636</td> 
    37 <td width="50%" align="center"><input class="fld-form-submit" type="submit" name="submit" value="{$lang.submit}" /></td> 
     37<td width="50%" align="center"><input class="fld-form-submit" type="submit" name="submitbutton" value="{$lang.submit}" /></td> 
    3838<td width="25%" align="right"> 
    3939        {include file=generic/link.tpl content="`$lang.change`" onclick="javascript: t = window.open('?page=pickup&subpage=nodes&object=form_nodes_plot_link.b_node', 'popup_pickup', 'width=700,height=600,toolbar=0,resizable=1,scrollbars=1'); t.focus(); return false;"} 
     
    4747<td align="left"> 
    4848{$lang.azimuth}: {$a_node_azimuth|round:2}&#176;<br /> 
    49 {$lang.elevation}: {$a_node_elevation|round:0} m<br /> 
     49{$lang.elevation}: {$a_node_geo_elevation|round:0} (+{$a_node_elevation|round:0}) m<br /> 
    5050{$lang.tilt}: {$a_node_tilt|round:2}&#176; 
    5151</td> 
    5252<td align="center"> 
    53 {$lang.distance}: {$distance|round:3} km<br /> 
    54 {$lang.fsl}: {$fsl|round:2} dBm 
     53<--- {$lang.distance}: {$distance|round:3} km ---><br /> 
     54<span style="color: brown;"> 
     55{$lang.fsl}:<br /> 
     56{$fsl|round:2} dBm @  
     57<select name="frequency" onchange="this.form.submit();" style="font-size: 10px;"> 
     58        <option value="2450"{if $frequency == 2450} selected="selected"{/if}>2450</option> 
     59        <option value="5500"{if $frequency == 5500} selected="selected"{/if}>5500</option> 
     60</select> 
     61 MHz 
     62</span> 
    5563</td> 
    5664<td align="right"> 
    5765{$lang.azimuth}: {$b_node_azimuth|round:2}&#176;<br /> 
    58 {$lang.elevation}: {$b_node_elevation|round:0} m<br /> 
     66{$lang.elevation}: {$b_node_geo_elevation|round:0} (+{$b_node_elevation|round:0}) m<br /> 
    5967{$lang.tilt}: {$b_node_tilt|round:2}&#176; 
    6068</td> 
    6169</tr> 
    6270<tr> 
    63 <td height="100%" colspan="3" align="center"><img src="?page=nodes&subpage=plot&a_node={$a_node}&b_node={$b_node}&width=570&height=250" width="570" height="250" /></td> 
     71<td height="100%" colspan="3" align="center"><img src="{$plot_image}&amp;width=570&amp;height=250" width="570" height="250" /></td> 
    6472</tr> 
    6573{else} 
Note: See TracChangeset for help on using the changeset viewer.