java implementation of spatial grid