Use rebar for building GeoCouch

Instead of using Emake, use rebar to build GeoCouch.
This will make it easier for future dependencies.
The output directory for the beam files changed from "build"
to "ebin".

Change-Id: Idbe9e2ef4197e5886f7ed6627d3689c9f530714f
Reviewed-on: http://review.couchbase.org/9825
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
Prepare for polygon search

Internal functions can be re-used for the polygon search if
the geometry types are converted to atoms, which is the way
they are stored in the Erlang term representation.

Change-Id: I0b946648976938bc875ac1970731afe9c48c7c66
Reviewed-on: http://review.couchbase.org/10093
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
Pull in dependencies for geometry search

Geometry search needs a WKT parser as well
as Erlgeom to calculate the intersections.

To checkout the dependencies use ./rebar get-deps

Change-Id: I6b7109f5ffe70723a175816de997a96fa7ed8e0a
Reviewed-on: http://review.couchbase.org/13786
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
Geometry search for GeoCouch

Spatial indexes can now be searched with a geometry,
e.g. a polygon. The query parameter is "geometry"
the value needs to be URL encoded Well-Known Text.
Supported geometry types are (Multi)Point, (Multi)LineString,
(Multi)Polygon.

Example:
curl -X GET 'http://localhost:5984/places/_design/main/_spatial/points?geometry=POLYGON((-21.0+58.9,+21.0+-61.1,+113.9+-54.3,+150.4+72.289067198883,+-21.0+58.9))'

Change-Id: I7b3b6fc8e6f8e2109e61a77834cfad1ec0ae28df
Reviewed-on: http://review.couchbase.org/10095
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
Make geometry search work with spatial merging

Geometry search wasn't working with spatial merging. This
fixes it and it also adds a test, to prevent future regression.

Change-Id: Ib0de1f5acb03ef4252f4dcff01a6d87e67f835dd
Reviewed-on: http://review.couchbase.org/13827
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
Revert "Make geometry search work with spatial merging"

This reverts commit dc9864e84be40b09af3ee6f8c9d4b67fca13d268.

Change-Id: Ibdce766381b96f66194bcdf7bc5f4d9bedb87254
Reviewed-on: http://review.couchbase.org/14784
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
Revert "Pull in dependencies for geometry search"

This reverts commit b090085f06d9c1a3aaf828fb05ecc52273e81372.

Change-Id: Iae434720b2a80ac17260347df85803fe3a87bcaa
Reviewed-on: http://review.couchbase.org/14786
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
Revert "Geometry search for GeoCouch"

This reverts commit 5f6e9f193b9173ccc072fd8ffefbacfa6d37303d.

Change-Id: I78d57e28b8e7c6f54c5d9d5102b324893363ff46
Reviewed-on: http://review.couchbase.org/14785
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>