I need to save longitude/latitude coordinates in mongodb and I'm not sure how to store them. No examples I see online show conversion to string or splitting up the decimal parts into 2 ints. I'm assuming that in order to enable geo indexing, I'd have to store them as doubles, so for example:
{ _id : 100, pos: { long : 126.9, lat : 35.2 }, type : "restaurant"}
I need at least 6 decimal places of precision, so how does this work in mongodb?
MongoDB supports double
datatype. It is used for all floating point numbers. As MongoDB implements BSON spec, we may think of it's double as of BSON double. Which is 8 bytes (64-bit IEEE 754 floating point)
according to the specification. And it supports 15-17 significant digits.
So do not worry.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With