Skip to content
Bucky Wolfe edited this page Aug 27, 2014 · 12 revisions

Handling Geospatial data

One potential option for handling geospatial resolution would be to use ardb with eredis.

When a client sends us a position update, we could store the positional x and y coordinates with ARDB's GeoAdd.

After the client has sent us their positional data, we use that update to trigger otmpd:get_nearby_players, which would retrieve the results of an ARDB GeoSearch query (within a radius TBD). After we've preformed the lookup, we'd send the positional updates back to the client.

One limitation with this approach is that GeoAdd doesn't appear to have any way to update data for existing records. If this assumption is accurate, we'll need to make otmpd:get_nearby_players aware that multiple records may exist for a player until the stale entries are pruned. Perhaps store geodata with a keyname of $sessionid@+%s%N and prune by splitting on @ and deleting all but the record with the highest timestamp. This filtering mechanism whould be present in otmpd:get_nearby_players, but the actual db pruning should probably occur in a seperate erlang process, operating on a tight timer loop (or even better, a pub/sub queue subscription, so we could prune as soon as an entry is added).

Clone this wiki locally