- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我需要计算从 lat/lng GPS 点 P 到由另外 2 个 lat/lng GPS 点 A 和 B 描述的线段的最短距离。
'交叉航迹距离'帮助我计算 P 与 A 和 B 描述的大圆之间的最短距离。
然而,这不是我想要的。我需要 P 和 A-B 的 segment 线之间的距离,而不是整个大圆。
我使用了来自 http://www.movable-type.co.uk/scripts/latlong.html 的以下实现
Formula: dxt = asin( sin(δ13) ⋅ sin(θ13−θ12) ) ⋅ R
where:
δ13 is (angular) distance from start point to third point
θ13 is (initial) bearing from start point to third point
θ12 is (initial) bearing from start point to end point
R is the earth’s radius
在第一个图像中,由绿色线表示的交叉轨道距离是正确的,并且确实是到线段 AB 的最短距离。
在第二张图片中显示了交叉轨道距离的问题,在这种情况下,我希望最短距离是简单距离 AP,但是交叉轨道距离给出了红色<指示的距离/strong> 行。
如何更改我的算法以考虑到这一点,或检查点 X 是否在 AB 内。有可能通过计算来做到这一点吗?还是迭代是唯一可能的(昂贵的)解决方案? (沿AB取N个点,计算P点到所有这些点的最小距离)
为了简单起见,图像中的所有线条都是直的。实际上,这些是大圆上的小弧
最佳答案
首先,一些术语:
我们的弧线是从 p1 到 p2 绘制的。
我们的第三点是p3。
与大圆相交的虚点是 p4。
p1 由 lat1,lon1 定义; p2 通过 lat2,lon2;等
dis12 是 p1 到 p2 的距离;等
bear12 是从 p1 到 p2 的方位角;等
dxt 是交叉轨道距离。
dxa是跨弧距离,我们的目标!
请注意,交叉轨道公式依赖于相对方位,bear13-bear12
我们有 3 个案例要处理。
案例1:相对方位角为钝角。所以,dxa=dis13。
案例 2.1:相对方位是锐角,并且 p4 落在我们的弧上。所以,dxa=dxt。
案例 2.2: 相对方位是锐角的,并且 p4 超出了我们的弧度。所以,dxa=dis23
算法:
第一步:如果相对方位角是钝角,dxa=dis13
完毕!
第 2 步:如果相对方位是锐角:
2.1:寻找dxt。
2.3:寻找dis12。
2.4:查找dis14。
2.4:如果 dis14>dis12,dxa=dis23。
完毕!
2.5:如果我们到达这里,dxa=abs(dxt)
MATLAB代码:
function [ dxa ] = crossarc( lat1,lon1,lat2,lon2,lat3,lon3 )
%// CROSSARC Calculates the shortest distance in meters
%// between an arc (defined by p1 and p2) and a third point, p3.
%// Input lat1,lon1,lat2,lon2,lat3,lon3 in degrees.
lat1=deg2rad(lat1); lat2=deg2rad(lat2); lat3=deg2rad(lat3);
lon1=deg2rad(lon1); lon2=deg2rad(lon2); lon3=deg2rad(lon3);
R=6371000; %// Earth's radius in meters
%// Prerequisites for the formulas
bear12 = bear(lat1,lon1,lat2,lon2);
bear13 = bear(lat1,lon1,lat3,lon3);
dis13 = dis(lat1,lon1,lat3,lon3);
diff = abs(bear13-bear12);
if diff > pi
diff = 2 * pi - diff;
end
%// Is relative bearing obtuse?
if diff>(pi/2)
dxa=dis13;
else
%// Find the cross-track distance.
dxt = asin( sin(dis13/R)* sin(bear13 - bear12) ) * R;
%// Is p4 beyond the arc?
dis12 = dis(lat1,lon1,lat2,lon2);
dis14 = acos( cos(dis13/R) / cos(dxt/R) ) * R;
if dis14>dis12
dxa=dis(lat2,lon2,lat3,lon3);
else
dxa=abs(dxt);
end
end
end
function [ d ] = dis( latA, lonA, latB, lonB )
%DIS Finds the distance between two lat/lon points.
R=6371000;
d = acos( sin(latA)*sin(latB) + cos(latA)*cos(latB)*cos(lonB-lonA) ) * R;
end
function [ b ] = bear( latA,lonA,latB,lonB )
%BEAR Finds the bearing from one lat/lon point to another.
b=atan2( sin(lonB-lonA)*cos(latB) , ...
cos(latA)*sin(latB) - sin(latA)*cos(latB)*cos(lonB-lonA) );
end
示例输出:演示所有案例。请参阅下面的 map 。
>> crossarc(-10.1,-55.5,-15.2,-45.1,-10.5,-62.5)
ans =
7.6709e+05
>> crossarc(40.5,60.5,50.5,80.5,51,69)
ans =
4.7961e+05
>> crossarc(21.72,35.61,23.65,40.7,25,42)
ans =
1.9971e+05
map 上那些相同的输出!
演示案例 1:
演示案例 2.1:
演示案例 2.2:
归功于:http://www.movable-type.co.uk/scripts/latlong.html
对于公式
和:http://www.darrinward.com/lat-long/?id=1788764
用于生成 map 图像。
关于matlab - Lat/Lng 点到 Minor Arc 段的距离,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32771458/
Minor GC是用来清理Eden空间的吧?但我使用 jstat 来查看我的 GC 日志。当 Eden 空间已满 90% 时,有 95% 的 Minor GC 发生。然而有时我发现伊甸园空间几乎是空的
由于获得major.minor.release格式,我正在尝试更改svn修订号。 在我的配置中,每次提交时 svn 修订号都会增加 1。 应该可以改吧? 我正在研究如何使用 perl 来做到这一点,但
例如,如何创建一个小模式,将默认前景色更改为灰色,并在退出小模式后,前景色恢复为黑色?当您不希望某些文本在您的肩膀上被看到时,此模式可能很有用。 现在,我运行以下代码将文本颜色变为灰色: (set-f
我用谷歌搜索发现大多数文章都这么说 “当 JVM 无法为新对象分配空间时,总会触发 Minor GC,” 但是从visualVM中,我发现minor gc发生得非常频繁。我可以看到Eden空间将被回收
我将一些 sticknfind 信标与 android (sticknfind android SDK) 一起使用。如何从我的源代码中的信标获取主要和次要值?我使用了应用程序:StickNFind B
我已经为 Linux 编写了一个 platform_driver。现在,我希望它成为/dev/myDrv 下的字符设备。 现在,驱动程序没有出现在/dev/myDrv 中,尽管我使用“insmod”成
java version "1.6.0_17" Java(TM) SE Runtime Environment (build 1.6.0_17-b04) Java HotSpot(TM) 64-Bit
我正在尝试为 Android 开发 BLE 应用程序。 有什么方法可以检测和读取 Android 设备上的 Beacon 的 UDID、Major、Minor? 我已经阅读了 RadiusNetwor
我已经对谷歌饼图和隐藏的切片标签进行了大量研究,但没有找到切片外的任何标签,所以我希望有另一种解决方案而不是 already suggested on SO . 我生成了很多不同的图表类型,为了更好的
概念: ● 新生代 GC(Minor GC):从年轻代空间(包括 Eden 和 Survivor 区域)回收内存被称为 Minor GC,因为 Java 对象大多都具备朝生夕灭的特性,所以 Minor
我们发现次要 GC 暂停时间有所增加。该应用程序是一个用 Java 编写的服务器,每秒执行 500 个事务。CMS 收集后,暂停时间减少,但运行数小时后暂停时间再次增加。我已使用 vmstat 检查了
我经常遇到较高的次要 GC 暂停时间(约 9 秒)。 该应用程序是一个用 Java 编写的服务器,每秒执行 3 个事务。 尽管没有 I/O 过多 Activity 堆参数是: -Xms1G -Xmx1
我之前使用2G new Age内存,我看到minor gc每10秒发生一次,每次需要0.1-0.15秒,我想减少minor gc频率,所以我将new Age内存设置为3G。之后,minor gc 每
我正试图在大型企业 Java 应用程序中了解垃圾回收。我有 GC 日志并开始使用各种工具查看它们 - 这里的屏幕截图是使用 GCViewer 完成的. (遗憾的是,没有包含更详细的 GC 信息的日志.
在semantic versioning一般规则是仅在引入向后兼容功能时才增加次要编号,否则必须增加主要编号。 same approach ,但具有不同的算法,由 libtool 使用。 我有一个问题
您将如何编写一个 build.xml 文件,既不使用自定义代码也不使用外部依赖项(例如 shell 脚本): 生成major.minor.revision 形式的内部版本号(例如,01.02.34)。
最近项目更新jdk,由之前的1.7更新到1.8。下载并安装好新的jdk以后,编译、启动tomcat的时候,报错了,提示:“unsupported major.minor version xxx ”。
是否可以合并:lighters当存在某种事件次要模式组合时,在模式线上?如果是,那请问怎么办? 例子: 次要模式 1 的 :lighter 为 " -" 次要模式二的 :lighter 为 " +"
我似乎无法弄清楚检测 iBeacons 时主要值和次要值的相关性或重要性。当我注册和配置我的 Gimbal 信标时,我给它一组特定的 UUID、主要和次要值,然后当我使用 cordova iBeaco
无法导入项目。从build.gradle导入时,给出不受支持的Major.Minor版本51错误 最佳答案 (从another solution复制) 解: 我的解决方案是编辑/Application
我是一名优秀的程序员,十分优秀!