如何向GPS坐标添加值

问题描述 投票:0回答:1

我有一些经纬度的gps坐标列表。如何在纬度的float变量的末尾添加随机int值。我已经尝试过了...

float log = 77.567635f;
Random rand = new Random();
int r = rand.Next(1, 20);

假设r的值为12,我想添加到日志'77 .567635'+ r。

我的预期结果将是'77 .567647'

c# coordinates add
1个回答
0
投票

我将首先指定浮点数的精度。例如,如果精度为0.000001(如您的示例),则可以将随机生成的数字乘以该精度,并将其添加到坐标中。

float log = 77.567635f;
Random rand = new Random();
float r = rand.Next(1, 20) * 0.000001;
log = log+r;
© www.soinside.com 2019 - 2024. All rights reserved.