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) 以前 ...
随机推荐
- 问题解决_(转载)在VisualStudio 2012上使用MVC3出现错误的解决办法
错误: 找 不到方 法:“System.Collections.Generic.Dictionary`2<System.String,BlockParser> System.Web.Raz ...
- Phoenix -修复表索引
索引的修复可以通过2种方式,(关于pehoenix的索引的生命周期可以参考 https://community.hortonworks.com/articles/58818/phoenix-inde ...
- div,li,span自适应宽度换行问题
<ul class="news"> <li><span class="lbl">右对齐,换行显示的解决方法</s ...
- android bundle存放数据详解
转载自:android bundle存放数据详解 正如大家所知道,Activity之间传递数据,是将数据存放在Intent或者Bundle中 例如: 将数据存放倒Intent中传递: 将数据放到Bun ...
- Maven项目生成 jar直接运行
pom.xml配置如下:红色部分要注意 在eclipse中maven生成可运行的jar需要指定可运行的主程序 <?xml version="1.0" encoding=&qu ...
- C#如何分割多个空格分隔的字符串?
using System; using System.Text; using System.Text.RegularExpressions; namespace test { class Progra ...
- 脚本工具: 查看当前系统被写入的FD
#!/bin/bash touch /tmp/sn2 /tmp/sn4 /tmp/sn6 /tmp/sn3 redir=/dev/null which lsof >&/dev/null ...
- phthon
没什么特别的,我们项目的跨平台代码都是在Windows环境下编码,然后跨平台编译调试,C++和Python代码都是如此.我们用C++实现底层和框架,用ctypes将纯C的API给Python化,然后用 ...
- leetcode6:Zigzag Conversion@Python
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like ...
- 思达index网站
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...