简体   繁体   English

在Java中将point1移至OSM映射上的point2方向

[英]Move point1 to the direction of point2 on an OSM map in Java

I want to move Point1 to the direction of Point2 on an OSM(Openstreetmap) Map in Java EE with the Vaadin Framework. 我想使用Vaadin框架在Java EE中的OSM(Openstreetmap)地图上将Point1移至Point2的方向。 The Wrapper there for the OSM (or any other Map) is called V-Leaflet. OSM(或任何其他Map)的包装程序称为V-Leaflet。

I was thinking about to add an Offset to the numeric Lat-/Lon coordinates(for example lat: 52.3; Lon: 10.4), but my problem is Point2. 我当时正在考虑向数字纬度/经度坐标添加偏移量(例如,纬度:52.3;经度:10.4),但是我的问题是Point2。 I don't have any idea, how i can get the offset for point1 relative to the point2, that the point1 moves right to the direction of point2. 我不知道如何获取point1相对于point2的偏移量,即point1向右移至point2的方向。

Maybe my approach is wrong. 也许我的方法是错误的。

Here is a little picture, to see my problem on the "Map": picture of the problem 这是一张小图片,可以在“地图”上看到我的问题: 问题的图片

best regards 最好的祝福

thunder

I solved it by myself, with using Vectors. 我自己使用Vectors解决了这个问题。

I converted point1 (a) and point2 (b) into a vector and then i'm calculating vector b - a, to get the distance. 我将point1(a)和point2(b)转换为向量,然后计算向量b-a以获得距离。

To move the point1 (a) with direction to point2 (b), you can just calculate (c): 要将point1(a)的方向移至point2(b),您只需计算(c):

c = a + (distance to move, for example: 1/2) * (a - b) c = a +(移动距离,例如:1/2)*(a-b)

best regards 最好的祝福

thunder

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM