安卓GPS覆盖长区GPS

2023-09-04 07:18:52 作者:上卿

我使用的GPS和我在地图上添加一些超过打下点,所以我希望在我目前的位置是==过外行项目中删除的项目!问题是GPS不准确,我可能会在附近的地方覆盖项目,但不一样的经度和纬度。所以我想周围的叠加添加项目区称增量这样的问题是增量假设是肯定它不能是整数或浮点数它应该是什么将它添加到我的了躺在项目朗和纬度。 预先感谢

i'm using gps and i add some over lay points in the map so i want when my current location is == the over lay item remove the item ! the problem is the gps inaccuracy and i may be in place near the overlay item but not same longitude and lat. so i want to add area around the overlay item say a delta so the question is what the delta suppose to be for sure its cant be int or float what it should be to add it to my over lay item lang and latitude . Thank in advance

推荐答案

我不是很有经验的GPS在Android上,但在我看来,你应该能够计算距离从当前位置到覆盖项目并检查是否小于某个可接受的阈值。这只是需要一点向量运算:

I'm not very experienced with GPS on Android, but it seems to me that you should be able to calculate the distance from your current position to the overlay item and check if it is less than some acceptable threshold. This just takes a little vector math:

int XSquared = Math.pow(myPosition.x - Item.x, 2);
int YSquared = Math.pow(myPosition.y - Item.y, 2);
double distance = Math.sqrt(XSquared + YSquared);

if(distance < threshold)
   removeItem(item);

显然,这不是在code实际上将是什么样子,但我希望它会给你一些想法,以什么你需要做的。

Obviously this is not what the code will actually look like, but I hope it will give you some idea as to what you need to do.