Changeset 1806

Show
Ignore:
Timestamp:
09/08/10 18:59:14 (17 months ago)
Author:
spf
Message:

added arrows for waypoint crossing [See #34]

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/site/map.class.php

    r1785 r1806  
    138138    $this->colorWaypointsArea = ImageColorAllocate($this->mapImage, 230, 120, 40); 
    139139    $this->colorWaypointsIceGate = ImageColorAllocate($this->mapImage, 0, 51, 204); 
     140    $this->colorWaypointsIndication = imagecolorallocatealpha($this->mapImage, 102, 255, 51, 64); 
    140141    $this->colorBuoy = ImageColorAllocate($this->mapImage, 250, 150, 150); 
    141142    $this->colorWind = ImageColorAllocate($this->mapImage, 110, 130, 150); 
     
    200201  } 
    201202 
    202  
    203  
     203  // (-7 0) -> (-2 -5) -> (-2 -1) -> (7 -1) => (7 1) -> (-2 1) -> (-2 5) (-7 0) 
     204 
     205  function drawArrow($image, $x1, $y1, $angle, $color) { 
     206    $deg = round(fmod($angle, 360.0));  
     207    switch (intval($angle)) { 
     208    case 0: 
     209      $poly = array( $x1-7, $y1, $x1-2, $y1-5, $x1-2, $y1-1, $x1+7, $y1-1, $x1+7, $y1+1, $x1-2, $y1+1, $x1-2, $y1+5); 
     210      break; 
     211    case 90: 
     212      $poly = array( $x1, $y1-7, $x1-5, $y1-2, $x1-1, $y1-2, $x1-1, $y1+7, $x1+1, $y1+7, $x1+1, $y1-2, $x1+5, $y1-2); 
     213      break; 
     214    case 180: 
     215      $poly = array( $x1+7, $y1, $x1+2, $y1-5, $x1+2, $y1-1, $x1-7, $y1-1, $x1-7, $y1+1, $x1+2, $y1+1, $x1+2, $y1+5); 
     216      break; 
     217    case 270: 
     218      $poly = array( $x1, $y1+7, $x1-5, $y1+2, $x1-1, $y1+2, $x1-1, $y1-7, $x1+1, $y1-7, $x1+1, $y1+2, $x1+5, $y1+2); 
     219      break; 
     220    default: 
     221      $poly = array(); 
     222      // (-7 0) -> (-2 -5) -> (-2 -1) -> (7 -1) => (7 1) -> (-2 1) -> (-2 5) (-7 0) 
     223      array_push($poly, $x1+7*cos((180-$deg)*M_PI/180.0), $y1-7*sin((180-$deg)*M_PI/180.0)); 
     224      array_push($poly, $x1+5.385164807134504*cos((111.8014094863518-$deg)*M_PI/180.0), $y1-5.385164807134504*sin((111.8014094863518-$deg)*M_PI/180.0)); 
     225      array_push($poly, $x1+2.23606797749979*cos((153.434948822922-$deg)*M_PI/180.0), $y1-2.23606797749979*sin((153.434948822922-$deg)*M_PI/180.0)); 
     226      array_push($poly, $x1+7.071067811865476*cos((8.130102354156051-$deg)*M_PI/180.0), $y1-7.071067811865476*sin((8.130102354156051-$deg)*M_PI/180.0)); 
     227      array_push($poly, $x1+7.071067811865476*cos((-8.130102354156051-$deg)*M_PI/180.0), $y1-7.071067811865476*sin((-8.130102354156051-$deg)*M_PI/180.0)); 
     228      array_push($poly, $x1+2.23606797749979*cos((-153.434948822922-$deg)*M_PI/180.0), $y1-2.23606797749979*sin((-153.434948822922-$deg)*M_PI/180.0)); 
     229      array_push($poly, $x1+5.385164807134504*cos((-111.8014094863518-$deg)*M_PI/180.0), $y1-5.385164807134504*sin((-111.8014094863518-$deg)*M_PI/180.0)); 
     230      break; 
     231    } 
     232    imagefilledpolygon( $image, $poly, 7, $color); 
     233  } 
     234   
    204235  //function draw Grid 
    205236  function drawGrid($projCallbackLong, $projCallbackLat) { 
     
    740771                        $wpcolor); 
    741772          } 
     773          if ($waypoint['wpformat'] & WP_CROSS_CLOCKWISE) { 
     774            $this->drawArrow($this->mapImage, ($wp1ProjLong+$wp2ProjLong)/2.0,  
     775                             ($wp1ProjLat+$wp2ProjLat)/2.0, 
     776                             atan2(($wp2ProjLat-$wp1ProjLat),($wp1ProjLong-$wp2ProjLong)), $this->colorWaypointsIndication); 
     777          } else if ($waypoint['wpformat'] & WP_CROSS_ANTI_CLOCKWISE) { 
     778            $this->drawArrow($this->mapImage, ($wp1ProjLong+$wp2ProjLong)/2.0,  
     779                             ($wp1ProjLat+$wp2ProjLat)/2.0, 
     780                             atan2(($wp2ProjLat-$wp1ProjLat),($wp1ProjLong-$wp2ProjLong))+180, $this->colorWaypointsIndication); 
     781          } 
    742782        } else { 
    743783 
     
    768808                        $this->colorBuoy); 
    769809          } 
    770            
     810          // FIXME more arrows ? 
     811          if ($waypoint['wpformat'] & WP_CROSS_CLOCKWISE) { 
     812            $this->drawArrow($this->mapImage, $wp1ProjLong+20*cos(deg2rad(90-$waypoint['laisser_au'])),  
     813                             $wp1ProjLat+20*sin(deg2rad(90-$waypoint['laisser_au'])),  
     814                             $waypoint['laisser_au'], $this->colorWaypointsIndication); 
     815          } else if ($waypoint['wpformat'] & WP_CROSS_ANTI_CLOCKWISE) { 
     816            $this->drawArrow($this->mapImage, $wp1ProjLong+20*cos(deg2rad(90-$waypoint['laisser_au'])),  
     817                             $wp1ProjLat+20*sin(deg2rad(90-$waypoint['laisser_au'])),  
     818                             $waypoint['laisser_au']+180, $this->colorWaypointsIndication); 
     819          } 
     820 
    771821          $distEP=500 ; $EP_coords1=giveEndPointCoordinates( $waypoint['latitude1'], $waypoint['longitude1'], $distEP, $wpheading ); 
    772822          array_push($poly_coords, $this->projLong($EP_coords1['longitude']),