예제 #1
0
function encodeLevels($points, $dists, $absMaxDist)
{
    global $numLevels, $forceEndpoints;
    $encoded_levels = "";
    if ($forceEndpoints) {
        $encoded_levels .= encodeNumber($numLevels - 1);
    } else {
        $encoded_levels .= encodeNumber($numLevels - computeLevel($absMaxDist) - 1);
    }
    for ($i = 1; $i < count($points) - 1; $i++) {
        if (isset($dists[$i])) {
            $encoded_levels .= encodeNumber($numLevels - computeLevel($dists[$i]) - 1);
        }
    }
    if ($forceEndpoints) {
        $encoded_levels .= encodeNumber($numLevels - 1);
    } else {
        $encoded_levels .= encodeNumber($numLevels - computeLevel($absMaxDist) - 1);
    }
    return $encoded_levels;
}
예제 #2
0
    function createStaticMap($forceRefresh=0) {

        $maxPoints=400;
        $width=350;
        $height=350;

        global $moduleRelPath,$baseInstallationPath;
        global $langEncodings,$currentlang;

        if ( is_file($this->getMapFilename())  && !$forceRefresh )  return $this->getMapRelPath();

        $filename=$this->getIGCFilename(1);
        $lines = file ($filename);
        if (!$lines) return;
        $i=0;
        $kml_file_contents="";


        $prevLat=0;
        $prevLon=0;


        $totLines=count($lines);
       // echo "tot line: ".$totLines;

        $mod0=0;
        if ($totLines > $maxPoints ){
            $reduceArray=getReduceArray($totLines ,$maxPoints);
            // print_r($recudeArray);
            $mod0=count($reduceArray);
            // $mod= ceil( $p / $this->maxPointNum );
        }


        // compute num of B lines
        $numLines=0;
        $points=0;
        $i++;
        foreach($lines as $line) {
            if ($line{0}=='B' && strlen($line) >= 23 && $line{24}!='V' ) {
                // real line
                $points++;
                if ($mod0>=1)  {
                    if ( $reduceArray[ $points % $mod0]  == 0  ) {
                        $lines[$i]{0}='X';
                        //unset($lines[$i]);
                        $i++;
                        continue;
                    }
                }
                $numLines++;
            } else {
                $lines[$i]{0}='X';
               // unset($lines[$i]);

            }
            $i++;
        }

        //echo "<BR>real b  lines: ".$numLines;
        //echo "<BR>lines left in arays: ".count($lines);

        foreach($lines as $line) {
            $line=trim($line);
            if  (strlen($line)==0) continue;
            if ($line{0}!='B') continue;
            if  ( strlen($line) < 23 ) 	continue;
            if ($line{24}=='V') continue;

            $thisPoint=new gpsPoint($line,$this->timezone);
            $lat=$thisPoint->lat;
            $lon=-$thisPoint->lon;

            $kml_file_contents.=encodeNumber($lat-$prevLat).encodeNumber($lon-$prevLon);

            $prevLat=$lat;
            $prevLon=$lon;

            $i++;
        }

        // write to file

        // echo "<br>encoded len: ".strlen ($kml_file_contents);

        $staticMap="https://maps.googleapis.com/maps/api/staticmap?path=color:0xff0000|weight:2|enc:$kml_file_contents&maptype=terrain&size=".$width."x".$height."&sensor=false";
        //echo "<br>".strlen($staticMap);

        // get from google
        $imgStr=file_get_contents($staticMap);
        echo "<br>".strlen($imgStr);

        $handle = fopen($this->getMapFilename(), "w");
        fwrite($handle, $imgStr);
        fclose($handle);

        echo "<img src='".$this->getMapRelPath()."'>";

        return $this->getMapRelPath();
    }
예제 #3
0
 function createStaticMap($forceRefresh = 0)
 {
     $maxPoints = 250;
     $width = 450;
     $height = 450;
     global $moduleRelPath, $baseInstallationPath;
     global $langEncodings, $currentlang, $CONF;
     if (is_file($this->getMapFilename()) && !$forceRefresh) {
         return $this->getMapRelPath();
     }
     $filename = $this->getIGCFilename(1);
     $lines = file($filename);
     if (!$lines) {
         return;
     }
     $i = 0;
     $kml_file_contents = "";
     $prevLat = 0;
     $prevLon = 0;
     $totLines = 0;
     foreach ($lines as $line) {
         if ($line[0] == 'B' && strlen($line) >= 23 && $line[24] != 'V') {
             $totLines++;
         }
     }
     //$totLines=count($lines);
     // echo "tot line: ".$totLines;
     $mod0 = 0;
     if ($totLines > $maxPoints) {
         $reduceArray = getReduceArray($totLines, $maxPoints);
         // print_r($recudeArray);
         $mod0 = count($reduceArray);
         // $mod= ceil( $p / $this->maxPointNum );
     }
     // compute num of B lines
     $numLines = 0;
     $points = 0;
     $i++;
     foreach ($lines as $line) {
         if ($line[0] == 'B' && strlen($line) >= 23 && $line[24] != 'V') {
             // real line
             $points++;
             if ($mod0 >= 1) {
                 if ($reduceArray[$points % $mod0] == 0) {
                     $lines[$i][0] = 'X';
                     //unset($lines[$i]);
                     $i++;
                     continue;
                 }
             }
             $numLines++;
         } else {
             $lines[$i][0] = 'X';
             // unset($lines[$i]);
         }
         $i++;
     }
     //echo "<BR>real b  lines: ".$numLines;
     //echo "<BR>lines left in arays: ".count($lines);
     foreach ($lines as $line) {
         $line = trim($line);
         if (strlen($line) == 0) {
             continue;
         }
         if ($line[0] != 'B') {
             continue;
         }
         if (strlen($line) < 23) {
             continue;
         }
         if ($line[24] == 'V') {
             continue;
         }
         $thisPoint = new gpsPoint($line, $this->timezone);
         $lat = $thisPoint->lat;
         $lon = -$thisPoint->lon;
         $kml_file_contents .= encodeNumber($lat - $prevLat) . encodeNumber($lon - $prevLon);
         $prevLat = $lat;
         $prevLon = $lon;
         $i++;
     }
     // write to file
     // echo "<br>encoded len: ".strlen ($kml_file_contents);
     $flightScore = new flightScore($this->flightID);
     $flightScore->getFromDB();
     $defaultMethodID = $CONF['scoring']['default_set'];
     $scoreDetails = $flightScore->scores[$defaultMethodID][$flightScore->bestScoreType];
     //print_r($scoreDetails);
     $j = 0;
     $markers = "";
     for ($i = 1; $i <= 7; $i++) {
         if ($scoreDetails['tp'][$i]) {
             $newPoint = new gpsPoint($scoreDetails['tp'][$i], $this->timezone);
             //$url.=urlencode('|'.sprintf("%.3f",$newPoint->lat).','.sprintf("%.3f",-$newPoint->lon));
             if ($j == 0) {
                 $color = '0x0000ff';
                 $t = 'T';
             } else {
                 $color = '0x00ff00';
                 $t = $j;
             }
             if (!$scoreDetails['tp'][$i + 1]) {
                 $t = "L";
                 $color = '0xffff00';
             }
             $markers .= "&markers=" . urlencode("color:{$color}|label:{$t}|" . sprintf("%.3f", $newPoint->lat) . "," . sprintf("%.3f", -$newPoint->lon));
             $j++;
         }
     }
     $staticMap = "https://maps.googleapis.com/maps/api/staticmap?path=color:0xff0000|weight:2|enc:{$kml_file_contents}" . $markers . "&maptype=terrain&size=" . $width . "x" . $height . "&sensor=false";
     //echo "<br>".$staticMap;
     // get from google
     $imgStr = file_get_contents($staticMap);
     // echo "<br>".strlen($imgStr);
     $handle = fopen($this->getMapFilename(), "w");
     fwrite($handle, $imgStr);
     fclose($handle);
     // echo "<img src='".$this->getMapRelPath()."'>";
     return $this->getMapRelPath();
 }
예제 #4
0
파일: model.class.php 프로젝트: roc/Borax
 public function getEncodedId()
 {
     return encodeNumber($this->id);
 }