花了几个小时把js的google计算地图面积的算法改成了c# 的。

  class Program
{
static void Main(string[] args)
{
// a = new qq.maps.LatLng(39.93, 116.44004334);
//b = new qq.maps.LatLng(39.93, 116.35421264);
//c = new qq.maps.LatLng(39.896775, 116.35421264);
//d = new qq.maps.LatLng(39.89, 116.44004334);
//29869510.924133233平方米 List<LatLng> a = new List<LatLng>();
a.Add(new LatLng() { Latitude = 39.93, Longitude = 116.44004334 });
a.Add(new LatLng() { Latitude = 39.93, Longitude = 116.35421264 });
a.Add(new LatLng() { Latitude = 39.896775, Longitude = 116.35421264 });
a.Add(new LatLng() { Latitude = 39.89, Longitude = 116.44004334 }); double area = computeArea(a, ); } static double computeArea(List<LatLng> x, double y)
{
return Math.Abs(computeSignedArea(x, y));
} static double computeSignedArea(List<LatLng> a, double b)
{
double c = ;
if (b > )
{
c = b;
}
double g = a.Count - ;
double e = ;
LatLng d = a[];
for (int i = ; i < g; i++)
{
e += Zm(d, a[i], a[i + ]);
}
return e * c * c;
} static double Zm(LatLng a, LatLng b, LatLng c)
{
return Tm(a, b, c) * Um(a, b, c);
} static double Tm(LatLng a, LatLng b, LatLng c)
{
List<LatLng> d = new List<LatLng>() { a, b, c, a };
List<double> e = new List<double>();
double f = ; for (int i = ; i < d.Count - ; i++)
{
e.Add(Uf(d[i], d[i + ]));
f += e[i];
}
f /= ;
double g = Math.Tan(f / ); for (int j = ; j < d.Count - ; j++)
{
g *= Math.Tan((f - e[j]) / );
} return * Math.Atan(Math.Sqrt(Math.Abs(g)));
}
static double Um(LatLng a, LatLng b, LatLng c)
{
List<LatLng> d = new List<LatLng>() { a, b, c }; double[,] e = new double[, ]; for (int i = ; i < 3; i++)
{
LatLng f = d[i];
double f1 = re(f);
double f2 = se(f);
e[i, ] = Math.Cos(f1) * Math.Cos(f2);
e[i, ] = Math.Cos(f1) * Math.Sin(f2);
e[i, ] = Math.Sin(f1);
}
return < e[, ] * e[, ] * e[, ] + e[, ] * e[, ] * e[, ] + e[, ] * e[, ] * e[, ] - e[, ] * e[, ] * e[, ] - e[, ] * e[, ] * e[, ] - e[, ] * e[, ] * e[, ] ? : -;
} static double Uf(LatLng a, LatLng b)
{
var c = re(a);
var d = re(b);
return * Math.Asin(Math.Sqrt(Math.Pow(Math.Sin((c - d) / ), ) + Math.Cos(c) * Math.Cos(d) * Math.Pow(Math.Sin((se(a) - se(b)) / ), )));
} static double re(LatLng a)
{
return Rd(a.Latitude);
}
static double se(LatLng a)
{
return Rd(a.Longitude);
} static double Rd(double a)
{
return Math.PI / * a;
} } partial struct LatLng
{
private double _Longitude;
public double Longitude
{
get
{
return _Longitude;
}
set
{
_Longitude = value;
}
} private double _Latitude;
public double Latitude
{
get
{
return _Latitude;
}
set
{
_Latitude = value;
}
} }
 double computeDistanceBetween(LngLat a, LngLat b, double c)
{
return Uf(a, b) * c;
}
public double ComputeLength(List<LngLat> a, double b = )
{
if (a.Count < )
{
return ;
}
double c = ;
if (b > )
{
c = b;
}
double g = a.Count - ;
double d = ; for (var e = ; e < g; ++e)
{
d += computeDistanceBetween(a[e], a[e + ], c);
}
return d;
}

google map 计算地图面积方法的更多相关文章

  1. Google Map API key 获取方法

    要想使用google map api 必须从google网站上获取key之后才有权限使用,但是要想申请key必须要有证明书,也就是所谓的MD5.下面一步一步来说明: 步骤1: 如果你使用的是eclip ...

  2. Google Map 谷歌地图

    <script> var map; function initMap() { var position = new google.maps.LatLng(1.539187, 103.647 ...

  3. 房产地图google map的初步应用点滴.3)(转)

    房产地图google map的初步应用点滴.1)房产地图google map的初步应用点滴.2)房产地图google map的初步应用点滴.3) 房产地图google map的初步应用点滴.4) go ...

  4. 房产地图google map的初步应用点滴.2)(转)

    房产地图google map的初步应用点滴.1)房产地图google map的初步应用点滴.2)房产地图google map的初步应用点滴.3) 房产地图google map的初步应用点滴.4) 本来 ...

  5. Android中Google地图路径导航,使用mapfragment地图上画出线路(google map api v2)详解

    在这篇里我们只聊怎么在android中google map api v2地图上画出路径导航,用mapfragment而不是mapview,至于怎么去申请key,manifest.xml中加入的权限,系 ...

  6. Google Map API v2 (三)----- 地图上添加标记(Marker),标记info窗口,即指定经纬度获取地址字符串

    接上篇 http://www.cnblogs.com/inkheart0124/p/3536322.html 1,在地图上打个标记 private MarkerOptions mMarkOption; ...

  7. Google Map API v2 步步为营(一) ----- 初见地图

    官方文档:https://developers.google.com/maps/documentation/android/start?hl=zh-CN 先谷歌后百度.使用google的api基本上按 ...

  8. 房产地图google map的初步应用点滴.4)(转)

    房产地图google map的初步应用点滴.1) 房产地图google map的初步应用点滴.2) 房产地图google map的初步应用点滴.3) 房产地图google map的初步应用点滴.4) ...

  9. 房产地图google map的初步应用点滴.1)(转)

    房产地图google map的初步应用点滴.1)房产地图google map的初步应用点滴.2)房产地图google map的初步应用点滴.3) 房产地图google map的初步应用点滴.4) 以前 ...

随机推荐

  1. js 取得 Unix时间戳(Unix timestamp)

    js 取得 Unix时间戳 Unix时间戳(Unix timestamp),或称Unix时间(Unix time).POSIX时间(POSIX time),是一种时间表示方式,定义为从格林威治时间19 ...

  2. Pycharm注册码(2016.2)

    43B4A73YYJ-eyJsaWNlbnNlSWQiOiI0M0I0QTczWVlKIiwibGljZW5zZWVOYW1lIjoibGFuIHl1IiwiYXNzaWduZWVOYW1lIjoiI ...

  3. Tableau 地图无法识别怎么办

    Tableau地图是一个很优秀的工具,可以选择城市或者省份作为单位来显示地图. 前几天做了一个省份的感觉很好,今天用城市做单位居然有些城市识别不了,其中包括贵阳和宿迁.   换了拼音之后贵阳能够识别了 ...

  4. centos 解压jdk安装包方式安装jdk 出现 java/lang/NoClassDefFoundError: java/lang/Object 错误

    安装完JDK ,设定环境变量后出现这个错误: [root@localhost lib]# javacError occurred during initialization of VMjava/lan ...

  5. Eclipse导入Tomcat源码(转)

    想要研究下Tomcat的体系结构或者源码,最好将Tomcat的源码导入到ide中,编写实例进行代码跟踪(debug). 这里参考了网上一些资料,将自己操作过程记个流水账. 准备: 1.Tomcat源码 ...

  6. C#实用技能篇

    Redis配置文件详解 如果不指定配置文件,redis也可以启动,此时,redis使用默认的内置配置.不过在正式环境,常常通过配置文件[通常叫redis.conf]来配置redis. redis.co ...

  7. Android基础开发文档汇总

    一.Android 基本组件 1. Android中PackageManager使用示例 :  http://blog.csdn.net/qinjuning/article/details/68678 ...

  8. android 动态设置控件宽高度

    Android 代码里直接使用 setWidth() 和 setHeight()设置宽高度是没用的. 解决办法是 改用setLayoutParams()方法 如设置宽高内容自适应: setLayout ...

  9. C# 访问MongoDB 通用方法类

    using MongoDB.Driver; using System; namespace MongoDBDemo { public class MongoDb { public MongoDb(st ...

  10. [转]DevExpress.XtraGrid.GridControl gridView自动列宽代码

    gridView1.OptionsView.ColumnAutoWidth = false;   for (int I = 0; I < gridView1.Columns.Count; I++ ...