function [y] = GPSGuassCalc(x, length, terr)

rho = 26570;
Phi = rand(1,length)*pi/2;
Theta = rand(1,length)*2*pi;
a = rho.*cos(Phi).*cos(Theta);
b = rho.*cos(Phi).*sin(Theta);
c = rho.*sin(Phi);
R=((a+19.053).^2+(b-11.318).^2+(c-6370).^2).^(1/2);
t = .0001 + R./299792.458;

t = t + terr*1e-8;

light = 299792.458;

for j=1:20
    for i=1:length
       f(i,1) = (x(1) - a(i))^2 + (x(2) - b(i))^2 + (x(3) - c(i))^2 - (light*(t(i) - x(4)))^2;
       dF(i,:) = [2*(x(1)-a(i)) 2*(x(2)-b(i)) 2*(x(3)-c(i)) 2*light^2*(t(i)-x(4))];
    end
    y = x - dF\f;
    x=y;
end
end