Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
An example geofence-computing server
Ruby
branch: master

This branch is 1 commit ahead of JohnMurray:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
spec
src
.gitignore
.rspec
Gemfile
Gemfile.lock
LICENSE.md
README.md
Rakefile
TODO
config.ru
console

README.md

Geofence Server in Ruby (a simple example)

This is a simple example project to showcase geofencing with Ruby and Mongo. There is a full write-up that can be found on my blog.

I make no promises about this server. To be honest it probably has lots of issues, could be done better, and definitely won't scale. But it's fun to look at and should give you some ideas when it comes to your own implementation.

Getting Started

Pull from github

git clone git://github.com/JohnMurray/geofence-server-example.git

Install Gems

cd geofence-server-example
bundle

Start Server

bundle exec thin -p 4242 start

Make requests!

# Create a fence
curl -d '[[0, 0], [0, 4], [4, 0], [4, 4]]' http://127.0.0.1:4242/fences

# Check that it was created 
curl http://127.0.0.1:4242/fences

# Query the fence
# Replace :id with the actual string-representation of a Mongo Document ID
# (You can find that by getting the fences with /fences)
curl http://127.0.0.1:4242/relative-to-fence/:id/lat/lon

Exploring with the Console

Once you've played around with the project's web server, you might want to take a look at the code. It's rather simple and could serve as a good starting point for you. If you really want to get hands one with the application you can start up the interactive console:

./console.rb
Something went wrong with that request. Please try again.