I started learning mongodb and was trying to figure out which way is better suited for a large 2d tile map if I need to store a large number of tiles. In my case, the player has to fill in the free 4 tiles (quad 2x2) - this is a kind of castle.
Let's assume that the database contains a document like this:
{
"_id": {
"$oid": "62ad13e2a4658cfa758956d4"
},
"data": {
"player_id": "asdfadsf-asdfasdfas-fasdfsdaf-asdffds"
},
"location": [[
[ 0, 0],
[ 0, 1],
[ 1, 1],
[ 1, 0],
]]
}
Is it possible to make a geospatial query to find a free random 2x2 square for the next castle that never intersects with the first one? Maybe the mongo geospatial query is not suitable for this case?