Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using MongoDB's Geospacial index with 3d data

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?

like image 606
John F. Miller Avatar asked Mar 25 '11 17:03

John F. Miller


People also ask

Does MongoDB support geospatial index?

MongoDB provides the following geospatial index types to support the geospatial queries.

What is 2dsphere index in MongoDB?

A 2dsphere index supports queries that calculate geometries on an earth-like sphere. 2dsphere index supports all MongoDB geospatial queries: queries for inclusion, intersection and proximity. For more information on geospatial queries, see Geospatial Queries.

What is geospatial index?

The geospatial index supports distance, containment, and intersection queries for various geometric 2D shapes. You should mainly be using AQL queries to perform these types of operations. The index can operate in two different modes, depending on if you want to use the GeoJSON data-format or not.

Can MongoDB query use multiple indexes?

MongoDB can use the intersection of multiple indexes to fulfill queries. In general, each index intersection involves two indexes; however, MongoDB can employ multiple/nested index intersections to resolve a query.


1 Answers

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

like image 185
Chad Brewbaker Avatar answered Oct 04 '22 18:10

Chad Brewbaker