Using MongoDB's Geospacial index with 3d data

2019-02-16 06:36发布

I have a set of documents each of which contain a point in 3-space stored in a MongoDB collection. MongoDB currently has Geospatial Indexes only for 2-space. Is there a way of leveraging the Geospacial Index to do similar queries on 3-space data?

1条回答
forever°为你锁心
2楼-- · 2019-02-16 07:09

You could kludge it by compressing one of the dimensions, but you would lose half your precision.

Say if they were 64 bit keys and you wanted to store three 32 bit coordinates: [(x << 32) + y, z]

Heck, you can even interleave three and store it in one key:

xxx

yyy

zzz

xyzxyzyz

查看更多
登录 后发表回答