def combination_2_n(l):
n, r = len(l), []
for i in range(0, n, 1):
s = i + 1
for ii in range(s, n, 1):
r.append([l[i], l[ii]])
return r
# l1, l2 = [23, 123], [24, 124]
def rad(d):
return d * np.pi / 180.0 def compute_diff(l1, l2):
lat1, lng1 = l1
lat2, lng2 = l2
radLat1, radLat2 = rad(lat1), rad(lat2)
a = radLat1 - radLat2
b = rad(lng1) - rad(lng2)
inner_ = math.sqrt(math.pow(math.sin(a / 2), 2) +
math.cos(radLat1) * math.cos(radLat2) * math.pow(math.sin(b / 2), 2))
s = 2 * math.asin(inner_)
s = s * 6378.137
s = math.ceil(s * 10000) / 10000;
return s # 0-设置2组经纬度距离阈值(初始值:100米);
# 1-如果只有一组组经纬度,则直接接受;基于经纬度条数的分布数据,认为“在保证距离阈值的情况下,
# 取距离(并列)最近的2点的经纬度的算数平均数”是可行的;
# latlon_l = [[142, 343], [12, 6557], [3, 666], [434, 33], [142, 6557]] def compute_macwithres_nominal_latlon(latlon_l, point_dis_threshold=500):
n, r = len(latlon_l), {}
if n == 1:
return {0: latlon_l[0]}
elif n > 1:
c_pair = combination_2_n(latlon_l)
for i in c_pair:
dis = compute_diff(i[0], i[1])
if dis > point_dis_threshold:
continue
if dis not in r:
r[dis] = []
r[dis].append(i)
if r == {}:
return {}
else:
min = sorted(r, reverse=False)[0]
return {min: r[min][0]}

combination_m_n的更多相关文章

随机推荐

  1. [Python Cookbook] Numpy Array Slicing and Indexing

    1-D Array Indexing Use bracket notation [ ] to get the value at a specific index. Remember that inde ...

  2. Codeforces Round #324 (Div. 2) Marina and Vasya 乱搞推理

    原题链接:http://codeforces.com/contest/584/problem/C 题意: 定义$f(s1,s2)$为$s1,s2$不同的字母的个数.现在让你构造一个串$s3$,使得$f ...

  3. Java多线程总结之由synchronized说开去

    更新完毕,结贴,以后有新的想法再开新帖 这几天不断添加新内容,给个大概的提纲吧,方面朋友们阅读,各部分是用分割线隔开了的: synchronized与wait()/notify() JMM与synch ...

  4. 2016集训测试赛(十九)Problem A: 24点大师

    Solution 这到题目有意思. 首先题目描述给我们提供了一种非常管用的模型. 按照题目的方法, 我们可以轻松用暴力解决20+的问题; 关键在于如何构造更大的情况: 我们发现 \[ [(n + n) ...

  5. IIS配置支持apk文件下载

    写在前面 最近项目中涉及到移动端的东西,有一个功能是要下载apk文件,apk为安卓安装程序,但是iis默认是不支持该类型的文件下载的. 解决方案 找到该站点,并切换到功能视图 找到MIME类型,双击进 ...

  6. VS2010 MFC中 窗口分割的实现

    分割窗口概述 分割窗口,顾名思义,就是将一个窗口分割成多个窗格,在每个窗格中都包含有视图,或者是同一类型的视图,或者是不同类型的视图. MFC分割窗口的方式有两种,动态分割和静态分割. 动态分割窗口通 ...

  7. java编程思想第四版第9章

    练习3: public class MainTest { public static void main(String args[]){ Bcycle b=new Bcycle(); b.print( ...

  8. TestNG的參数化測试、共享线程池配置、參数默认值配置

    在使用TestNG进行測试时,常常会使用到一些參数化配置,比方数据库.连接池.线程池数. 使用TestNG的參数@Parameter注解进行自己主动化读取 原创文章,版权全部.同意转载,标明出处:ht ...

  9. mysql rpm安装,以及修改charset

    http://my.oschina.net/u/1156660/blog/343154?fromerr=tmDGGiDL 修改charset: http://stackoverflow.com/que ...

  10. Spring技术笔记(一)

    一.控制反转(IoC)&依赖注入(DI) 1.控制反转: 所谓的控制反转就是应用本身不负责依赖对象的创建及维护, 依赖对象的创建及维护是由外部容器负责的. 这样控制权就由应用转移到了外部容器, ...