Add spatial helper functions

Add some functions including tests that will be used in the subsequent
commits.

Change-Id: I07b9f9410cfc41709c50d33df5241742e892eff4
Reviewed-on: http://review.couchbase.org/39636
Reviewed-by: Dave Rigby <daver@couchbase.com>
Reviewed-by: Sarath Lakshman <sarath@couchbase.com>
Tested-by: buildbot <build@couchbase.com>