5 个解决方案
#1
我从网上找了一个公式
http://www.gissky.net/blog/more.asp?name=GisBlog&id=904
并依据公式写了一个自己的程序,可是算出来的完全不对,还请大家多多指点
using System;
class tempDistance
{
static double earthR=12756/2;
static double GetDistance(double bw1,double dj1,double bw2,double dj2)
{
double getdistance=Math.PI*earthR/180*Math.Acos(Math.Sin(bw1)*Math.Sin(bw2)+Math.Cos(bw1)*Math.Cos(bw2)*Math.Cos(dj1-dj2));
return getdistance;
}
public static void Main()
{
double bw1,dj1,bw2,dj2;
bw1=28.0;
dj1=120.6;
bw2=30.0;
dj2=130.0;
double gd=GetDistance(bw1,dj1,bw2,dj2);
Console.WriteLine(gd.ToString());
Console.ReadLine();
}
}
http://www.gissky.net/blog/more.asp?name=GisBlog&id=904
并依据公式写了一个自己的程序,可是算出来的完全不对,还请大家多多指点
using System;
class tempDistance
{
static double earthR=12756/2;
static double GetDistance(double bw1,double dj1,double bw2,double dj2)
{
double getdistance=Math.PI*earthR/180*Math.Acos(Math.Sin(bw1)*Math.Sin(bw2)+Math.Cos(bw1)*Math.Cos(bw2)*Math.Cos(dj1-dj2));
return getdistance;
}
public static void Main()
{
double bw1,dj1,bw2,dj2;
bw1=28.0;
dj1=120.6;
bw2=30.0;
dj2=130.0;
double gd=GetDistance(bw1,dj1,bw2,dj2);
Console.WriteLine(gd.ToString());
Console.ReadLine();
}
}
#2
我用其它软件得到我程序中所用两点的大至距离为:933KM
#3
// 计算已知经纬度的两点间的距离
// Thu 2005.08.04
using System;
struct JWD
{
double JD, JF, JM;
double WD, WF, WM;
public double Jd, Wd, J, W;
public const double Ea = 6378137; // 赤道半径
public const double Eb = 6356725; // 极半径
public readonly double Ec;
public readonly double Ed;
// 构造函数, 经度: a 度, b 分, c 秒; 纬度: d 度, e 分, f 秒
public JWD(double a, double b, double c, double d, double e, double f)
{
JD=a; JF=b; JM=c; WD=d; WF=e; WM=f;
Jd = JD + JF / 60 + JM / 3600;
Wd = WD + WF / 60 + WM / 3600;
J = Jd * Math.PI / 180;
W = Wd * Math.PI / 180;
Ec = Eb + (Ea - Eb) * (90-Wd) / 90;
Ed = Ec * Math.Cos(W);
}
}
class Test
{
static void Main()
{
JWD A0 = new JWD(120, 36, 0, 28, 0, 0);
JWD A1 = new JWD(130, 0, 0, 30, 0, 0);
Calc(A0, A1);
}
static void Calc(JWD A, JWD B)
{
double dx = (B.J - A.J) * A.Ed;
double dy = (B.W - A.W) * A.Ec;
double d = Math.Sqrt(dx * dx + dy * dy);
Console.WriteLine("{0:N1}M", d);
}
}
/* 程序输出:
949,373.0M
*/
// Thu 2005.08.04
using System;
struct JWD
{
double JD, JF, JM;
double WD, WF, WM;
public double Jd, Wd, J, W;
public const double Ea = 6378137; // 赤道半径
public const double Eb = 6356725; // 极半径
public readonly double Ec;
public readonly double Ed;
// 构造函数, 经度: a 度, b 分, c 秒; 纬度: d 度, e 分, f 秒
public JWD(double a, double b, double c, double d, double e, double f)
{
JD=a; JF=b; JM=c; WD=d; WF=e; WM=f;
Jd = JD + JF / 60 + JM / 3600;
Wd = WD + WF / 60 + WM / 3600;
J = Jd * Math.PI / 180;
W = Wd * Math.PI / 180;
Ec = Eb + (Ea - Eb) * (90-Wd) / 90;
Ed = Ec * Math.Cos(W);
}
}
class Test
{
static void Main()
{
JWD A0 = new JWD(120, 36, 0, 28, 0, 0);
JWD A1 = new JWD(130, 0, 0, 30, 0, 0);
Calc(A0, A1);
}
static void Calc(JWD A, JWD B)
{
double dx = (B.J - A.J) * A.Ed;
double dy = (B.W - A.W) * A.Ec;
double d = Math.Sqrt(dx * dx + dy * dy);
Console.WriteLine("{0:N1}M", d);
}
}
/* 程序输出:
949,373.0M
*/
#4
非常感谢!
能提供一下你程序的原理或思路吗?
能提供一下你程序的原理或思路吗?
#5
弧线的计算,高中数学的.自己去翻翻.大部分没有做相关方面,应该都是忘光了
#1
我从网上找了一个公式
http://www.gissky.net/blog/more.asp?name=GisBlog&id=904
并依据公式写了一个自己的程序,可是算出来的完全不对,还请大家多多指点
using System;
class tempDistance
{
static double earthR=12756/2;
static double GetDistance(double bw1,double dj1,double bw2,double dj2)
{
double getdistance=Math.PI*earthR/180*Math.Acos(Math.Sin(bw1)*Math.Sin(bw2)+Math.Cos(bw1)*Math.Cos(bw2)*Math.Cos(dj1-dj2));
return getdistance;
}
public static void Main()
{
double bw1,dj1,bw2,dj2;
bw1=28.0;
dj1=120.6;
bw2=30.0;
dj2=130.0;
double gd=GetDistance(bw1,dj1,bw2,dj2);
Console.WriteLine(gd.ToString());
Console.ReadLine();
}
}
http://www.gissky.net/blog/more.asp?name=GisBlog&id=904
并依据公式写了一个自己的程序,可是算出来的完全不对,还请大家多多指点
using System;
class tempDistance
{
static double earthR=12756/2;
static double GetDistance(double bw1,double dj1,double bw2,double dj2)
{
double getdistance=Math.PI*earthR/180*Math.Acos(Math.Sin(bw1)*Math.Sin(bw2)+Math.Cos(bw1)*Math.Cos(bw2)*Math.Cos(dj1-dj2));
return getdistance;
}
public static void Main()
{
double bw1,dj1,bw2,dj2;
bw1=28.0;
dj1=120.6;
bw2=30.0;
dj2=130.0;
double gd=GetDistance(bw1,dj1,bw2,dj2);
Console.WriteLine(gd.ToString());
Console.ReadLine();
}
}
#2
我用其它软件得到我程序中所用两点的大至距离为:933KM
#3
// 计算已知经纬度的两点间的距离
// Thu 2005.08.04
using System;
struct JWD
{
double JD, JF, JM;
double WD, WF, WM;
public double Jd, Wd, J, W;
public const double Ea = 6378137; // 赤道半径
public const double Eb = 6356725; // 极半径
public readonly double Ec;
public readonly double Ed;
// 构造函数, 经度: a 度, b 分, c 秒; 纬度: d 度, e 分, f 秒
public JWD(double a, double b, double c, double d, double e, double f)
{
JD=a; JF=b; JM=c; WD=d; WF=e; WM=f;
Jd = JD + JF / 60 + JM / 3600;
Wd = WD + WF / 60 + WM / 3600;
J = Jd * Math.PI / 180;
W = Wd * Math.PI / 180;
Ec = Eb + (Ea - Eb) * (90-Wd) / 90;
Ed = Ec * Math.Cos(W);
}
}
class Test
{
static void Main()
{
JWD A0 = new JWD(120, 36, 0, 28, 0, 0);
JWD A1 = new JWD(130, 0, 0, 30, 0, 0);
Calc(A0, A1);
}
static void Calc(JWD A, JWD B)
{
double dx = (B.J - A.J) * A.Ed;
double dy = (B.W - A.W) * A.Ec;
double d = Math.Sqrt(dx * dx + dy * dy);
Console.WriteLine("{0:N1}M", d);
}
}
/* 程序输出:
949,373.0M
*/
// Thu 2005.08.04
using System;
struct JWD
{
double JD, JF, JM;
double WD, WF, WM;
public double Jd, Wd, J, W;
public const double Ea = 6378137; // 赤道半径
public const double Eb = 6356725; // 极半径
public readonly double Ec;
public readonly double Ed;
// 构造函数, 经度: a 度, b 分, c 秒; 纬度: d 度, e 分, f 秒
public JWD(double a, double b, double c, double d, double e, double f)
{
JD=a; JF=b; JM=c; WD=d; WF=e; WM=f;
Jd = JD + JF / 60 + JM / 3600;
Wd = WD + WF / 60 + WM / 3600;
J = Jd * Math.PI / 180;
W = Wd * Math.PI / 180;
Ec = Eb + (Ea - Eb) * (90-Wd) / 90;
Ed = Ec * Math.Cos(W);
}
}
class Test
{
static void Main()
{
JWD A0 = new JWD(120, 36, 0, 28, 0, 0);
JWD A1 = new JWD(130, 0, 0, 30, 0, 0);
Calc(A0, A1);
}
static void Calc(JWD A, JWD B)
{
double dx = (B.J - A.J) * A.Ed;
double dy = (B.W - A.W) * A.Ec;
double d = Math.Sqrt(dx * dx + dy * dy);
Console.WriteLine("{0:N1}M", d);
}
}
/* 程序输出:
949,373.0M
*/
#4
非常感谢!
能提供一下你程序的原理或思路吗?
能提供一下你程序的原理或思路吗?
#5
弧线的计算,高中数学的.自己去翻翻.大部分没有做相关方面,应该都是忘光了