转换为GeoPoint [英] Conversion to GeoPoint

查看:32
本文介绍了转换为GeoPoint的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我有下一个奇怪的问题:我从SQL Server中以双精度形式恢复坐标,将其转换为float,然后转换为intE6.我设置了两张照片,一张是在转换为GeoPoint之前,另一张是在转换为GeoPoint之后.好吧,第一种似乎打印出正确的值,而第二种似乎显示出经度值失败.

Hello I have the next strange problem: I recover the coordinates from a sql server as a double, I convert it to float and after that I convert to intE6. I set two prints, one before the conversion to GeoPoint and other after that. Well, the first seems that print good values but in the second, the value of longitude value fails.

有一个例子:

float latitude = (float) json_data.getDouble("latitude");
float longitude = (float) json_data.getDouble("longitude");

Log.d("POINT",(int)(latitude*10E6)+" "+ (int)((longitude*10E6)));

GeoPoint p = new GeoPoint((int)(latitude*10E6), (int)(longitude*10E6));

Log.d("POINT", ""+p.getLatitudeE6()+" "+p.getLongitudeE6());

我在服务器中的值:-4.779396,37.878901

My values in server: -4.779396 , 37.878901

打印值:

-4779360 378789024

-4779360 378789024

-4779360 18789024

-4779360 18789024

感谢您的帮助!

推荐答案

而不是10E6使用1E6,因此将代码更改为以下内容:

instead 10E6 use 1E6, so change code to following:

GeoPoint p = new GeoPoint((int)(latitude*1E6), (int)(longitude*1E6));

因为10E6将得到与输入相同的数字,而1E6将数字乘以10会升为幂6.

as 10E6 will result into the same number, as input, whereas 1E6 will multiply number by 10 raise to power 6.

这篇关于转换为GeoPoint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆