calculate lat/lon from xy

@param Point $p
@return Point $p
349578
public function inverse($p)
    {
        /* Transformation */
        /* revert y, x */
        $tmp = $p->x;
        $p->x = $p->y;
        $p->y = $tmp;

        if ($this->czech) {
            $p->y *= -1.0;
            $p->x *= -1.0;
        }

        $ro = sqrt( $p->x * $p->x + $p->y * $p->y );
        $eps = atan2( $p->y, $p->x );
        $d = $eps / sin( $this->s0 );
        $s = 2. * (atan( pow( $this->ro0 / $ro, 1. / $this->n ) * tan( $this->s0 / 2. + $this->s45 ) ) - $this->s45);
        $u = asin( cos( $this->ad ) * sin( $s ) - sin( $this->ad ) * cos( $s ) * cos( $d ) );
        $deltav = asin( cos( $s ) * sin( $d ) / cos( $u ) );
        $p->x = $this->long0 - $deltav / $this->alfa;

        /* ITERATION FOR $lat */
        $fi1 = $u;
        $ok = 0;
        $iter = 0;
        do {
            $p->y = 2. * ( atan( pow( $this->k, -1. / $this->alfa ) *
                                pow( tan( $u / 2. + $this->s45 ), 1. / $this->alfa ) *
                                pow( (1. + $this->e * sin( $fi1 )) / (1. - $this->e * sin( $fi1 )), $this->e / 2. )
                      ) - $this->s45);
            if (abs( $fi1 - $p->y ) < 0.0000000001)
                $ok = 1;
            $fi1 = $p->y;
            $iter += 1;
        } while ($ok == 0 && $iter < 15);

        if ($iter >= 15) {
            Proj4php::reportError( "PHI3Z-CONV:Latitude failed to converge after 15 iterations" );
            //console.log('iter:', iter);
            return null;
        }

        return $p;
    }
26433
public final Point2D toXY(final double LAT, final double LON) {
        final double LATITUDE = (LAT * (-1)) + 90.0;
        final double LONGITUDE = LON + 180.0;

        final double X = Math.round(LONGITUDE * (WORLD_MAP.getWidth() / 360));
        final double Y = Math.round(LATITUDE * (WORLD_MAP.getHeight() / 180));

        return new java.awt.geom.Point2D.Double(X, Y);
    }
624757
function inverse$2(p) {
        var con, phi;
        var lat, lon;
        var x = (p.x - this.x0) * (1 / this.a);
        var y = (p.y - this.y0) * (1 / this.a);

        if (!this.es) {
            var f = Math.exp(x / this.k0);
            var g = 0.5 * (f - 1 / f);
            var temp = this.lat0 + y / this.k0;
            var h = Math.cos(temp);
            con = Math.sqrt((1 - Math.pow(h, 2)) / (1 + Math.pow(g, 2)));
            lat = Math.asin(con);

            if (y < 0) {
                lat = -lat;
            }

            if ((g === 0) && (h === 0)) {
                lon = 0;
            }
            else {
                lon = adjust_lon(Math.atan2(g, h) + this.long0);
            }
        }
        else { // ellipsoidal form
            con = this.ml0 + y / this.k0;
            phi = pj_inv_mlfn(con, this.es, this.en);

            if (Math.abs(phi) < HALF_PI) {
                var sin_phi = Math.sin(phi);
                var cos_phi = Math.cos(phi);
                var tan_phi = Math.abs(cos_phi) > EPSLN ? Math.tan(phi) : 0;
                var c = this.ep2 * Math.pow(cos_phi, 2);
                var cs = Math.pow(c, 2);
                var t = Math.pow(tan_phi, 2);
                var ts = Math.pow(t, 2);
                con = 1 - this.es * Math.pow(sin_phi, 2);
                var d = x * Math.sqrt(con) / this.k0;
                var ds = Math.pow(d, 2);
                con = con * tan_phi;

                lat = phi - (con * ds / (1 - this.es)) * 0.5 * (1 -
                    ds / 12 * (5 + 3 * t - 9 * c * t + c - 4 * cs -
                    ds / 30 * (61 + 90 * t - 252 * c * t + 45 * ts + 46 * c -
                    ds / 56 * (1385 + 3633 * t + 4095 * ts + 1574 * ts * t))));

                lon = adjust_lon(this.long0 + (d * (1 -
                    ds / 6 * (1 + 2 * t + c -
                    ds / 20 * (5 + 28 * t + 24 * ts + 8 * c * t + 6 * c -
                    ds / 42 * (61 + 662 * t + 1320 * ts + 720 * ts * t)))) / cos_phi));
            }
            else {
                lat = HALF_PI * sign(y);
                lon = 0;
            }
        }

        p.x = lon;
        p.y = lat;

        return p;
    }
1367617
function (cpt, bl) {
			var vY = bl[1].lat - bl[0].lat,
				vX = bl[0].lng - bl[1].lng;
			return (vX * (cpt.lat - bl[0].lat) + vY * (cpt.lng - bl[0].lng));
		}
1319657
def lonlat2xyz(lons, lats):
    """"""
    R = 6370997.0
    x_coords = R * da.cos(da.deg2rad(lats)) * da.cos(da.deg2rad(lons))
    y_coords = R * da.cos(da.deg2rad(lats)) * da.sin(da.deg2rad(lons))
    z_coords = R * da.sin(da.deg2rad(lats))
    return x_coords, y_coords, z_coords
906404
public function compareYCoord(Point $point, $precision = 1000)
    {
        return $this->compare($this->y, $point->y, $precision);
    }
399249
public function reduce( $p, $r )
    {
        $p = (double)$p;
        $r = (double)$r;
        $key = 0;
        while ( $key < $this->lastKey(-3) ) {
            $out = $key + 2;
            while (
                $out < $this->lastKey()
                && $this->_shortest($out, $key) < $p
                && $this->_distance($out, $key) < $r
            ) {
                $out++;
            }
            for ( $i = $key+1, $l = $out - 1; $i < $l; $i++ ) {
                unset($this->points[$i]);
            }
            $this->reindex();
            $key++;
        }
        return $this->points;
    }
1191499
public function inverse(float $p): float
    {
        if ($p < 0 || $p > 1) {
            throw new OutOfBoundsException("p must be between 0 and 1; given a p of $p");
        }
        if ($p == 1) {
            return \INF;
        }

        return -log(1 - $p) / $this->λ;
    }
103978
function forward(p) {
        var lon = p.x;
        var lat = p.y;
        // convert to radians
        if (lat * R2D > 90 && lat * R2D < -90 && lon * R2D > 180 && lon * R2D < -180) {
            return null;
        }

        var x, y;
        if (Math.abs(Math.abs(lat) - HALF_PI) <= EPSLN) {
            return null;
        }
        else {
            if (this.sphere) {
                x = this.x0 + this.a * this.k0 * adjust_lon(lon - this.long0);
                y = this.y0 + this.a * this.k0 * Math.log(Math.tan(FORTPI + 0.5 * lat));
            }
            else {
                var sinphi = Math.sin(lat);
                var ts = tsfnz(this.e, lat, sinphi);
                x = this.x0 + this.a * this.k0 * adjust_lon(lon - this.long0);
                y = this.y0 - this.a * this.k0 * Math.log(ts);
            }
            p.x = x;
            p.y = y;
            return p;
        }
    }
1051440
public function inverse($p)
    {
        /*
        $rh;  // Rho 
        $z;  // angle 
        $sinc;
        $cosc;
        $c;
        $lon;
        $lat;
        */

        $p->x = ($p->x - $this->x0) / $this->a;
        $p->y = ($p->y - $this->y0) / $this->a;

        $p->x /= $this->k0;
        $p->y /= $this->k0;

        if (($rh = sqrt($p->x * $p->x + $p->y * $p->y))) {
            $c = atan2( $rh, $this->rc );
            $sinc = sin( $c );
            $cosc = cos( $c );

            $lat = Common::asinz( $cosc * $this->sin_p14 + ($p->y * $sinc * $this->cos_p14) / $rh );
            $lon = atan2( $p->x * sinc, rh * $this->cos_p14 * $cosc - $p->y * $this->sin_p14 * $sinc );
            $lon = Common::adjust_lon( $this->long0 + $lon );
        } else {
            $lat = $this->phic0;
            $lon = 0.0;
        }

        $p->x = $lon;
        $p->y = $lat;

        return $p;
    }
901764
def lonlat2xyz(lon, lat):
    """"""
    lat = xu.deg2rad(lat)
    lon = xu.deg2rad(lon)
    x = xu.cos(lat) * xu.cos(lon)
    y = xu.cos(lat) * xu.sin(lon)
    z = xu.sin(lat)
    return x, y, z
950322
function(point) {
        var node = this.createElementNS(this.namespaces.gpx, "trkpt");
        node.setAttribute("lon", point.x);
        node.setAttribute("lat", point.y);
        return node;
    }
1009084
public function inverse($p)
    {
        $x = $p->x;
        $y = $p->y;

        $L = atan(sinh(($x - $this->xs) / $this->n2) / cos(($y - $this->ys) / $this->n2));
        $lat1 = asin(sin(($y - $this->ys) / $this->n2 ) / cosh(($x - $this->xs) / $this->n2));
        $LC = Common::latiso(0.0, $lat1, sin($lat1));

        $p->x = $this->lc + $L / $this->rs;
        $p->y = Common::invlatiso($this->e, ($LC - $this->cp) / $this->rs);

        return $p;
    }
468218
function inverse$16(p) {

        var x = p.x;
        var y = p.y;

        p.x = adjust_lon(this.long0 + ((x - this.x0) / (this.a * this.rc)));
        p.y = adjust_lat(this.lat0 + ((y - this.y0) / (this.a)));
        return p;
    }
1170468
public function forward($p)
    {
        // Forward equations
        $lam = $p->x;
        $phi = $p->y;
        $lam = Common::adjust_lon($lam - $this->long0);

        if ($this->sphere) {
            $x = asin(cos($phi) * sin($lam));
            $y = atan2(tan($phi), cos($lam)) - $this->phi0;
        } else {
            // ellipsoid
            $this->n = sin($phi);
            $this->c = cos($phi);
            $y = Common::pj_mlfn($phi, $this->n, $this->c, $this->en);
            $this->n = 1.0 / sqrt(1.0 - $this->es * $this->n * $this->n);
            $this->tn = tan($phi);
            $this->t = $this->tn * $this->tn;
            $this->a1 = $lam * $this->c;
            $this->c *= $this->es * $this->c / (1 - $this->es);
            $this->a2 = $this->a1 * $this->a1;
            $x = $this->n * $this->a1 * (1.0 - $this->a2 * $this->t * ($this->C1 - (8.0 - $this->t + 8.0 * $this->c) * $this->a2 * $this->C2));
            $y -= $this->m0 - $this->n * $this->tn * $this->a2 * (0.5 + (5. - $this->t + 6. * $this->c) * $this->a2 * $this->C3);
        }

        $p->x = $this->a * $x + $this->x0;
        $p->y = $this->a * $y + $this->y0;

        return $p;
    }
196859
public function geocentric_from_wgs84(Point $p)
    {
        Proj4php::reportDebug('geocentric_from_wgs84('.$p->x.','.$p->y.")\n");

        if ($this->datum_type == Common::PJD_3PARAM) {
            Proj4php::reportDebug("+x=".$this->datum_params[0]."\n");
            Proj4php::reportDebug("+y=".$this->datum_params[1]."\n");
            Proj4php::reportDebug("+z=".$this->datum_params[2]."\n");
            $p->x -= $this->datum_params[0];
            $p->y -= $this->datum_params[1];
            $p->z -= $this->datum_params[2];
        } elseif ($this->datum_type == Common::PJD_7PARAM) {
            Proj4php::reportDebug("Dx=".$this->datum_params[0]."\n");
            Proj4php::reportDebug("Dy=".$this->datum_params[1]."\n");
            Proj4php::reportDebug("Dz=".$this->datum_params[2]."\n");
            Proj4php::reportDebug("Rx=".$this->datum_params[3]."\n");
            Proj4php::reportDebug("Ry=".$this->datum_params[4]."\n");
            Proj4php::reportDebug("Rz=".$this->datum_params[5]."\n");
            Proj4php::reportDebug("M=".$this->datum_params[6]."\n");

            $Dx_BF = $this->datum_params[0];
            $Dy_BF = $this->datum_params[1];
            $Dz_BF = $this->datum_params[2];
            $Rx_BF = $this->datum_params[3];
            $Ry_BF = $this->datum_params[4];
            $Rz_BF = $this->datum_params[5];
            $M_BF = $this->datum_params[6];

            $x_tmp = ($p->x - $Dx_BF) / $M_BF;
            $y_tmp = ($p->y - $Dy_BF) / $M_BF;
            $z_tmp = ($p->z - $Dz_BF) / $M_BF;

            $p->x = $x_tmp + $Rz_BF * $y_tmp - $Ry_BF * $z_tmp;
            $p->y = -$Rz_BF * $x_tmp + $y_tmp + $Rx_BF * $z_tmp;
            $p->z = $Ry_BF * $x_tmp - $Rx_BF * $y_tmp + $z_tmp;
        }
    }
128386
public function inverse($p) {
        $p->x -= $this->x0;
        $p->y -= $this->y0;
        $x = $p->x / $this->a;
        $y = $p->y / $this->a;

        if( $this->sphere ) {
            $cosz = 0.0;
            #$rh;
            $sinz = 0.0;

            $rh = sqrt(($x * $x) + ($y * $y));
            $phi = $rh * 0.5;

            if ($phi > 1.0) {
                Proj4php::reportError('laea:Inv:DataError');
                return null;
            }

            $phi = 2. * asin( $phi );

            if ($this->mode == $this->OBLIQ || $this->mode == $this->EQUIT) {
                $sinz = sin($phi);
                $cosz = cos($phi);
            }
            switch( $this->mode ) {
                case $this->EQUIT:
                    $phi = (abs( $rh ) <= Common::EPSLN) ? 0. : asin( $y * $sinz / $rh );
                    $x *= $sinz;
                    $y = $cosz * $rh;
                    break;
                case $this->OBLIQ:
                    $phi = (abs( $rh ) <= Common::EPSLN) ? $this->phi0 : asin( $cosz * $this->sinph0 + $y * $sinz * $this->cosph0 / $rh );
                    $x *= $sinz * $this->cosph0;
                    $y = ($cosz - sin( $phi ) * $this->sinph0) * $rh;
                    break;
                case $this->N_POLE:
                    $y = -$y;
                    $phi = Common::HALF_PI - $phi;
                    break;
                case $this->S_POLE:
                    $phi -= Common::HALF_PI;
                    break;
            }

            $lam = ($y == 0.0 && ($this->mode == $this->EQUIT || $this->mode == $this->OBLIQ)) ? 0. : atan2($x, $y);
        } else {
            /*
            $cCe;
            $sCe;
            $q;
            $rho;
            */
            $ab = 0.0;

            switch($this->mode) {
                case $this->EQUIT:
                case $this->OBLIQ:
                    $x /= $this->dd;
                    $y *= $this->dd;
                    $rho = sqrt( $x * $x + $y * $y );

                    if ($rho < Common::EPSLN) {
                        $p->x = 0.;
                        $p->y = $this->phi0;
                        return $p;
                    }

                    $sCe = 2. * asin( .5 * $rho / $this->rq );
                    $cCe = cos( $sCe );
                    $x *= ($sCe = sin($sCe));

                    if ($this->mode == $this->OBLIQ) {
                        $ab = $cCe * $this->sinb1 + $y * $sCe * $this->cosb1 / $rho;
                        $q = $this->qp * $ab;
                        $y = $rho * $this->cosb1 * $cCe - $y * $this->sinb1 * $sCe;
                    } else {
                        $ab = $y * $sCe / $rho;
                        $q = $this->qp * $ab;
                        $y = $rho * $cCe;
                    }
                    break;
                case $this->N_POLE:
                    $y = -$y;
                case $this->S_POLE:
                    $q = ($x * $x + $y * $y);

                    if ( ! $q) {
                        $p->x = 0.;
                        $p->y = $this->phi0;
                        return $p;
                    }
                    /*
                      q = $this->qp - q;
                     */
                    $ab = 1.0 - $q / $this->qp;

                    if ($this->mode == $this->S_POLE) {
                        $ab = - $ab;
                    }
                    break;
            }
            $lam = atan2($x, $y);
            $phi = $this->authlat(asin($ab), $this->apa);
        }

        /*
          $Rh = sqrt($p->x *$p->x +$p->y * $p->y);
          $temp = Rh / (2.0 * $this->a);

          if (temp > 1) {
          Proj4php::reportError("laea:Inv:DataError");
          return null;
          }

          $z = 2.0 * Common::asinz(temp);
          $sin_z=sin(z);
          $cos_z=cos(z);

          $lon =$this->long0;
          if (abs(Rh) > Common::EPSLN) {
          $lat = Common::asinz($this->sin_lat_o * cos_z +$this-> cos_lat_o * sin_z *$p->y / Rh);
          $temp =abs($this->lat0) - Common::HALF_PI;
          if (abs(temp) > Common::EPSLN) {
          temp = cos_z -$this->sin_lat_o * sin(lat);
          if(temp!=0.0) lon=Common::adjust_lon($this->long0+atan2($p->x*sin_z*$this->cos_lat_o,temp*Rh));
          } else if ($this->lat0 < 0.0) {
          lon = Common::adjust_lon($this->long0 - atan2(-$p->x,$p->y));
          } else {
          lon = Common::adjust_lon($this->long0 + atan2($p->x, -$p->y));
          }
          } else {
          lat = $this->lat0;
          }
         */
        //return(OK);
        $p->x = Common::adjust_lon($this->long0 + $lam);
        $p->y = $phi;
        return $p;
    }