开发者

Android google-maps longitude/latitude calculation question

I have seen it pretty often so far that for some reason the latitude or longitude values return by getLatitude() are multiplicated with 1E6 in Google-Maps-examples. What's the reason for this? W开发者_Python百科hy 1E6? What's wrong with the raw values returned by those functions ?


I think I've read somewhere that this is related to performance. getLatitute() returns a double which is floating-point datatype. Math on floating point datatypes is slow if the device doesn't support floating-point operations.

So by multiplying the double value with 1E6, degrees become microdegree and so the calculation can be done with integer math without loosing too much resolution.


Its not just Google maps, I work with some maritime chart APIs on Windows PCs & they use a mixture on decimal degrees & 1E7 degrees. It just seems to be the functions were written that way & no one is bothered to unify them all.


The reason they are multiplied by 1E6 is because the GeoPoint class (which is used to plot points on a Google Map) uses microdegree latitude and longitude as integers. Multiplying by 1E6 converts degrees into microdegrees. The reason Google chose to do it this way is up to debate, but it probably has to do with the fact that the Google Maps themselves are not extremely accurate, and using a raw double value to 10 or more decimal places returned by the GPS is an unnecessary level of accuracy to plot a point on a Google Map.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜