Proposed code for implementation of spatial db. Very close to old code. Not ideal, but okay for first release?