src/AlterPHP/Component/ToolBox/PolylineEncoder.php
public function dpEncode() {
        if(count($this->points) > 2) {
            
            $stack[] = array(0, count($this->points)-1);
            
            while(count($stack) > 0) {
                $current = array_pop($stack);
                $maxDist = 0;
                $absMaxDist = 0;
                
                for($i = $current[0]+1; $i < $current[1]; $i++) {
                    $temp = self::distance($this->points[$i], $this->points[$current[0]], $this->points[$current[1]]);
                    if($temp > $maxDist) {
                        $maxDist = $temp;
                        $maxLoc = $i;
                        if($maxDist > $absMaxDist) {
                            $absMaxDist = $maxDist;
                        }
                    }
                }
                
                if($maxDist > $this->verySmall) {
                    $dists[$maxLoc] = $maxDist;
                    array_push($stack, array($current[0], $maxLoc));
                    array_push($stack, array($maxLoc, $current[1]));
                }
            }
        }
    
        $encodedPoints = self::createEncodings($this->points, $dists);
        $encodedLevels = self::encodeLevels($this->points, $dists, $absMaxDist);
        $encodedPointsLiteral = str_replace('\\',"\\\\",$encodedPoints);
        
        $polyline["Points"] = $encodedPoints;
        $polyline["Levels"] = $encodedLevels;
        $polyline["PointsLiteral"] = $encodedPointsLiteral;
        $polyline["ZoomFactor"] = $this->zoomFactor;
        $polyline["NumLevels"] = $this->numLevels;
        
        return $polyline;
    }
public function dpEncode() {
        if(count($this->points) > 2) {
            
            $stack[] = array(0, count($this->points)-1);
            
            while(count($stack) > 0) {
                $current = array_pop($stack);
                $maxDist = 0;
                $absMaxDist = 0;
                
                for($i = $current[0]+1; $i < $current[1]; $i++) {
                    $temp = self::distance($this->points[$i], $this->points[$current[0]], $this->points[$current[1]]);
                    if($temp > $maxDist) {
                        $maxDist = $temp;
                        $maxLoc = $i;
                        if($maxDist > $absMaxDist) {
                            $absMaxDist = $maxDist;
                        }
                    }
                }
                
                if($maxDist > $this->verySmall) {
                    $dists[$maxLoc] = $maxDist;
                    array_push($stack, array($current[0], $maxLoc));
                    array_push($stack, array($maxLoc, $current[1]));
                }
            }
        }
    
        $encodedPoints = self::createEncodings($this->points, $dists);
        $encodedLevels = self::encodeLevels($this->points, $dists, $absMaxDist);
        $encodedPointsLiteral = str_replace('\\',"\\\\",$encodedPoints);
        
        $polyline["Points"] = $encodedPoints;
        $polyline["Levels"] = $encodedLevels;
        $polyline["PointsLiteral"] = $encodedPointsLiteral;
        $polyline["ZoomFactor"] = $this->zoomFactor;
        $polyline["NumLevels"] = $this->numLevels;
        
        return $polyline;
    }
public function dpEncode ( ) { if ( count ( $ this -> points ) > 2 ) { $ stack [ ] = array ( 0 , count ( $ this -> points ) - 1 ) ; while ( count ( $ stack ) > 0 ) { $ current = array_pop ( $ stack ) ; $ maxDist = 0 ; $ absMaxDist = 0 ; for ( $ i = $ current [ 0 ] + 1 ; $ i < $ current [ 1 ] ; $ i ++ ) { $ temp = self :: distance ( $ this -> points [ $ i ] , $ this -> points [ $ current [ 0 ] ] , $ this -> points [ $ current [ 1 ] ] ) ; if ( $ temp > $ maxDist ) { $ maxDist = $ temp ; $ maxLoc = $ i ; if ( $ maxDist > $ absMaxDist ) { $ absMaxDist = $ maxDist ; } } } if ( $ maxDist > $ this -> verySmall ) { $ dists [ $ maxLoc ] = $ maxDist ; array_push ( $ stack , array ( $ current [ 0 ] , $ maxLoc ) ) ; array_push ( $ stack , array ( $ maxLoc , $ current [ 1 ] ) ) ; } } } $ encodedPoints = self :: createEncodings ( $ this -> points , $ dists ) ; $ encodedLevels = self :: encodeLevels ( $ this -> points , $ dists , $ absMaxDist ) ; $ encodedPointsLiteral = str_replace ( '\\' , "\\\\" , $ encodedPoints ) ; $ polyline [ "Points" ] = $ encodedPoints ; $ polyline [ "Levels" ] = $ encodedLevels ; $ polyline [ "PointsLiteral" ] = $ encodedPointsLiteral ; $ polyline [ "ZoomFactor" ] = $ this -> zoomFactor ; $ polyline [ "NumLevels" ] = $ this -> numLevels ; return $ polyline ; }
It also returns the zoomFactor and numLevels
It also returns the zoomFactor and numLevels