google map 计算地图面积方法
花了几个小时把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 计算地图面积方法的更多相关文章
- Google Map API key 获取方法
要想使用google map api 必须从google网站上获取key之后才有权限使用,但是要想申请key必须要有证明书,也就是所谓的MD5.下面一步一步来说明: 步骤1: 如果你使用的是eclip ...
- Google Map 谷歌地图
<script> var map; function initMap() { var position = new google.maps.LatLng(1.539187, 103.647 ...
- 房产地图google map的初步应用点滴.3)(转)
房产地图google map的初步应用点滴.1)房产地图google map的初步应用点滴.2)房产地图google map的初步应用点滴.3) 房产地图google map的初步应用点滴.4) go ...
- 房产地图google map的初步应用点滴.2)(转)
房产地图google map的初步应用点滴.1)房产地图google map的初步应用点滴.2)房产地图google map的初步应用点滴.3) 房产地图google map的初步应用点滴.4) 本来 ...
- Android中Google地图路径导航,使用mapfragment地图上画出线路(google map api v2)详解
在这篇里我们只聊怎么在android中google map api v2地图上画出路径导航,用mapfragment而不是mapview,至于怎么去申请key,manifest.xml中加入的权限,系 ...
- Google Map API v2 (三)----- 地图上添加标记(Marker),标记info窗口,即指定经纬度获取地址字符串
接上篇 http://www.cnblogs.com/inkheart0124/p/3536322.html 1,在地图上打个标记 private MarkerOptions mMarkOption; ...
- Google Map API v2 步步为营(一) ----- 初见地图
官方文档:https://developers.google.com/maps/documentation/android/start?hl=zh-CN 先谷歌后百度.使用google的api基本上按 ...
- 房产地图google map的初步应用点滴.4)(转)
房产地图google map的初步应用点滴.1) 房产地图google map的初步应用点滴.2) 房产地图google map的初步应用点滴.3) 房产地图google map的初步应用点滴.4) ...
- 房产地图google map的初步应用点滴.1)(转)
房产地图google map的初步应用点滴.1)房产地图google map的初步应用点滴.2)房产地图google map的初步应用点滴.3) 房产地图google map的初步应用点滴.4) 以前 ...
随机推荐
- linux 学习干货
学习了第七章. 每一个键盘对应一个信号.主要的有: ^代表 Ctrl <Backspance> erase ,删除一个字符. ^W werase,删除一个单词 ^U / ^X kill , ...
- JavaScript的学习4
一.Array对象 ArrayObject.reverse() 将数组进行翻转 ArrayObject.shift() 删除数组中的第一个元素并将其返回 ArrayObject.unshi ...
- LeetCode 371. Sum of Two Integers
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Exam ...
- (Collection)347. Top K Frequent Elements
Given a non-empty array of integers, return the k most frequent elements. For example,Given [1,1,1,2 ...
- 阿里云CentOS6上配置iptables
参考:http://blog.abv.cn/?p=50 阿里云CentOS6默认没有启动iptables 1.检查iptables状态 [root@iZ94jj63a3sZ ~]# service i ...
- MariaDB 10.1配置
[mysqld]datadir=C:/Program Files/MariaDB 10.1/dataport=3306sql_mode="STRICT_TRANS_TABLES,NO_ENG ...
- Python格式化字符串和转义字符
地址:http://blog.chinaunix.net/uid-20794157-id-3038417.html Python格式化字符串的替代符以及含义 符 号 说 明 ...
- Django1.7+JQuery+Ajax集成小例子
Ajax的出现让Web展现了更新的活力,基本所有的语言,都动态支持Ajax与起服务端进行通信,并在页面实现无刷新动态交互. 下面是散仙使用Django+Jquery+Ajax的方式来模拟实现了一个验证 ...
- Add Office 365 Azure Directory into Windows Azure
Add Office 365 Azure Directory into Windows Azure Pre-Requisite: 1.Azure Subscription to the Microso ...
- JS定义函数的两种方式:函数声明和函数表达式
函数声明 关于函数声明的方式,它的一个重要的特性就是函数声明提升(function declaration hoisting),意思是在执行代码之前会先读取函数声明.这就意味着可以把函数声明放在调用它 ...