千家信息网

常用的gis计算方法有哪些

发表于:2024-09-23 作者:千家信息网编辑
千家信息网最后更新 2024年09月23日,这篇文章主要为大家展示了"常用的gis计算方法有哪些",内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下"常用的gis计算方法有哪些"这篇文章吧。在系统开发中,有
千家信息网最后更新 2024年09月23日常用的gis计算方法有哪些

这篇文章主要为大家展示了"常用的gis计算方法有哪些",内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下"常用的gis计算方法有哪些"这篇文章吧。

在系统开发中,有时会用到一些常用的空间算法,引用一些类库是可以解决问题,但是有时类库的运行效率比较慢,引用的东西比较多,如果需要的方法不多,可以写一些简单的计算方法。

下边分享几个常用的gis计算方法:

//判断点是否在面里

public bool IsPointInPolygon(List poly, CVector point)

{

int i, j;

bool c = false;

for (i = 0, j = poly.Count - 1; i < poly.Count; j = i++)

{

if ((((poly[i].VY <= point.VY) && (point.VY < poly[j].VY))

|| ((poly[j].VY <= point.VY) && (point.VY < poly[i].VY)))

&& (point.VX < (poly[j].VX - poly[i].VX) * (point.VY - poly[i].VY)

/ (poly[j].VY - poly[i].VY) + poly[i].VX))

{

c = !c;

}

}

return c;

}

//计算弧度

public double Rad(double d)

{

return d * Math.PI / 180.0;

}

//计算角度

public static double RAngle(double d)

{

return d * 180.0 / Math.PI;

}

//计算两个坐标的中心点

public double[] ComputeMidPoint(double lat1, double long1, double lat2, double long2)

{

lat1 = Rad(lat1);

long1 = Rad(long1);

lat2 = Rad(lat2);

long2 = Rad(long2);

var Bx = Math.Cos(lat2) * Math.Cos(long2 - long1);

var By = Math.Cos(lat2) * Math.Sin(long2 - long1);

var _rlat = Math.Atan2(Math.Sin(lat1) + Math.Sin(lat2), Math.Sqrt((Math.Cos(lat1) + Bx) * (Math.Cos(lat1) + Bx) + By * By));

var _rlong = long1 + Math.Atan2(By, Math.Cos(lat1) + Bx);

return new double[] { _rlat, _rlong };

}

//计算一批点的四至坐标

public OCExtent GetPointsExtent(List PList)

{

OCExtent cET = new OCExtent();

for (int i = 0; i < PList.Count; i++)

{

CVector aP = PList[i];

if (i == 0)

{

cET.minX = aP.VX;

cET.maxX = aP.VX;

cET.minY = aP.VY;

cET.maxY = aP.VY;

}

else

{

if (cET.minX > aP.VX)

{

cET.minX = aP.VX;

}

else if (cET.maxX < aP.VX)

{

cET.maxX = aP.VX;

}

if (cET.minY > aP.VY)

{

cET.minY = aP.VY;

}

else if (cET.maxY < aP.VY)

{

cET.maxY = aP.VY;

}

}

}

return cET;

}

以上是"常用的gis计算方法有哪些"这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注行业资讯频道!

0