1.0e-7 ) { $con = $eccent * $sinphi; return (( 1.0 - $eccent * $eccent) * ($sinphi / (1.0 - $con * $con) - (.5 / $eccent) * log( (1.0 - $con) / (1.0 + $con) ))); } return (2.0 * $sinphi); } /** * Function to eliminate roundoff errors in asin * * @param type $x * @return type */ public function asinz( $x ) { return asin( abs( $x ) > 1.0 ? ($x > 1.0 ? 1.0 : -1.0) : $x ); #if( abs( $x ) > 1.0 ) { # $x = ($x > 1.0) ? 1.0 : -1.0; #} #return asin( $x ); } /** * following functions from gctpc cproj.c for transverse mercator projections * * @param type $x * @return type */ public function e0fn( $x ) { return (1.0 - 0.25 * $x * (1.0 + $x / 16.0 * (3.0 + 1.25 * $x))); } /** * * @param type $x * @return type */ public function e1fn( $x ) { return (0.375 * $x * (1.0 + 0.25 * $x * (1.0 + 0.46875 * $x))); } /** * * @param type $x * @return type */ public function e2fn( $x ) { return (0.05859375 * $x * $x * (1.0 + 0.75 * $x)); } /** * * @param type $x * @return type */ public function e3fn( $x ) { return ($x * $x * $x * (35.0 / 3072.0)); } /** * * @param type $e0 * @param type $e1 * @param type $e2 * @param type $e3 * @param type $phi * @return type */ public function mlfn( $e0, $e1, $e2, $e3, $phi ) { return ($e0 * $phi - $e1 * sin( 2.0 * $phi ) + $e2 * sin( 4.0 * $phi ) - $e3 * sin( 6.0 * $phi )); } /** * * @param type $esinp * @param type $exp * @return type */ public function srat( $esinp, $exp ) { return (pow( (1.0 - $esinp) / (1.0 + $esinp), $exp )); } /** * Function to return the sign of an argument * * @param type $x * @return type */ public function sign( $x ) { return $x < 0.0 ? -1 : 1; } /** * Function to adjust longitude to -180 to 180; input in radians * * @param type $x * @return type */ public function adjust_lon( $x ) { return (abs( $x ) < M_PI) ? $x : ($x - ($this->sign( $x ) * $this->TWO_PI) ); } /** * IGNF - DGR : algorithms used by IGN France * Function to adjust latitude to -90 to 90; input in radians * * @param type $x * @return type */ public function adjust_lat( $x ) { $x = (abs( $x ) < M_PI_2) ? $x : ($x - ($this->sign( $x ) * M_PI) ); return $x; } /** * Latitude Isometrique - close to tsfnz ... * * @param type $eccent * @param float $phi * @param type $sinphi * @return string */ public function latiso( $eccent, $phi, $sinphi ) { if( abs( $phi ) > M_PI_2 ) return +NaN; if( $phi == M_PI_2 ) return INF; if( $phi == -1.0 * M_PI_2 ) return -1.0 * INF; $con = $eccent * $sinphi; return log( tan( (M_PI_2 + $phi) / 2.0 ) ) + $eccent * log( (1.0 - $con) / (1.0 + $con) ) / 2.0; } /** * * @param type $x * @param type $L * @return type */ public function fL( $x, $L ) { return 2.0 * atan( $x * exp( $L ) ) - M_PI_2; } /** * Inverse Latitude Isometrique - close to ph2z * * @param type $eccent * @param type $ts * @return type */ public function invlatiso( $eccent, $ts ) { $phi = $this->fL( 1.0, $ts ); $Iphi = 0.0; $con = 0.0; do { $Iphi = $phi; $con = $eccent * sin( $Iphi ); $phi = $this->fL( exp( $eccent * log( (1.0 + $con) / (1.0 - $con) ) / 2.0 ), $ts ); } while( abs( $phi - $Iphi ) > 1.0e-12 ); return $phi; } /** * Grande Normale * * @param type $a * @param type $e * @param type $sinphi * @return type */ public function gN( $a, $e, $sinphi ) { $temp = $e * $sinphi; return $a / sqrt( 1.0 - $temp * $temp ); } /** * code from the PROJ.4 pj_mlfn.c file; this may be useful for other projections * * @param type $es * @return type */ public function pj_enfn( $es ) { $en = array( ); $en[0] = $this->C00 - $es * ($this->C02 + $es * ($this->C04 + $es * ($this->C06 + $es * $this->C08))); $en[1] = es * ($this->C22 - $es * ($this->C04 + $es * ($this->C06 + $es * $this->C08))); $t = $es * $es; $en[2] = $t * ($this->C44 - $es * ($this->C46 + $es * $this->C48)); $t *= $es; $en[3] = $t * ($this->C66 - $es * $this->C68); $en[4] = $t * $es * $this->C88; return $en; } /** * * @param type $phi * @param type $sphi * @param type $cphi * @param type $en * @return type */ public function pj_mlfn( $phi, $sphi, $cphi, $en ) { $cphi *= $sphi; $sphi *= $sphi; return ($en[0] * $phi - $cphi * ($en[1] + $sphi * ($en[2] + $sphi * ($en[3] + $sphi * $en[4])))); } /** * * @param type $arg * @param type $es * @param type $en * @return type */ public function pj_inv_mlfn( $arg, $es, $en ) { $k = (float) 1 / (1 - $es); $phi = $arg; for( $i = Proj4php::$common->MAX_ITER; $i; --$i ) { /* rarely goes over 2 iterations */ $s = sin( $phi ); $t = 1. - $es * $s * $s; //$t = $this->pj_mlfn($phi, $s, cos($phi), $en) - $arg; //$phi -= $t * ($t * sqrt($t)) * $k; $t = ($this->pj_mlfn( $phi, $s, cos( $phi ), $en ) - $arg) * ($t * sqrt( $t )) * $k; $phi -= $t; if( abs( $t ) < Proj4php::$common->EPSLN ) return $phi; } Proj4php::reportError( "cass:pj_inv_mlfn: Convergence error" ); return $phi; } }