android - 找到离给定位置最近的折线索引
问题描述
如何从折线中的位置获取最近的点?我已经使用下面的代码来完成我的工作
但它给了我这样的输出:
List<LatLng> points = new ArrayList<>();
points.add(new LatLng(2, 2));
points.add(new LatLng(4, 2));
points.add(new LatLng(4, 4));
points.add(new LatLng(2, 4));
points.add(new LatLng(2, 2));
LatLng testPoint = new LatLng(3, 0);
LatLng nearestPoint = findNearestPoint(testPoint, points);
Log.e("NEAREST POINT: ", "" + nearestPoint); // lat/lng: (3.0,2.0)
但是我想要最接近给定点的折线的索引(包含折线列表的ArrayList),我尝试了很多方法,但没有一个成功。
如果您有解决方案,请告诉我。
解决方案
推荐阅读
- android - 找不到 org.codehaus.groovy:groovy-all:2.4.12
- r - 如何调整现有代码以在 R 中进行样本预测
- c# - Ajax 在参数中使用 C# 对象发布到控制器操作
- c# - 我应该使用 async/await 同时运行 3 个操作吗?
- spring - spring 集成错误处理不同类型
- android - Firebase 控制台消息未显示在模拟器或设备上
- gearman - Gearman拒绝连接到mysql
- cuda - 在 CUDA 中的大型数组转换期间删除项目
- machine-learning - .predict 返回二进制结果而不是百分比
- git - 当#movingtogitlab:是否有可能将所有导入的项目设置为公开?