A SimpleGeo Ruby client.
For the specific documentation on APIs (and the full list of parameters) see:
help.simplegeo.com/faqs/api-documentation/endpoints
Start by requiring SimpleGeo and setting your authentication credentials:
require 'simple_geo' SimpleGeo::Client.set_credentials('token', 'secret')
record = SimpleGeo::Client.get_record('com.simplegeo.global.geonames', '5373629')
records = SimpleGeo::Client.get_records('com.simplegeo.global.geonames', ['1234', '5678'])
record = SimpleGeo::Record.new({ :id => '1234', :created => Time.now, :lat => 37.759650000000001, :lon => -122.42608, :layer => 'com.example.testlayer', :properties => { :test_property => 'foobar' } }) SimpleGeo::Client.add_record(record)
record = SimpleGeo::Client.get_record('com.example.testlayer', '1234') record.lat = 40.714269 record.lon = -74.005973 SimpleGeo::Client.add_record(record)
records = [ SimpleGeo::Record.new({ :id => '1234', :created => Time.now, :lat => 37.759650000000001, :lon => -122.42608, :layer => 'com.example.testlayer', :properties => { :test_property => 'foobar' } }), SimpleGeo::Record.new({ :id => '5678', :created => Time.now, :lat => 37.755470000000003, :lon => -122.420646, :layer => 'com.example.testlayer', :properties => { :mad_prop => 'baz' } }) ] SimpleGeo::Client.add_records('com.example.testlayer', records)
SimpleGeo::Client.delete_record('1234')
history = SimpleGeo::Client.get_history('com.example.testlayer', '1234')
See help.simplegeo.com/faqs/api-documentation/endpoints for other optional params
# by lat, lon records = SimpleGeo::Client.get_nearby_records('com.example.testlayer', :lat => 37.759650000000001, :lon => -122.42608) # by geohash records = SimpleGeo::Client.get_nearby_records('com.example.testlayer', :geohash => '9q8yy1ujcsfm')
nearby_address = SimpleGeo::Client.get_nearby_address(37.759650000000001, -122.42608)
# by day density_info = SimpleGeo::Client.get_density(37.75965, -122.42608, 'sat') # by hour density_info = SimpleGeo::Client.get_density(37.75965, -122.42608, 'sat', '16' )
For more examples see: spec/client_spec.rb
-
Fork the project.
-
Make your feature addition or bug fix.
-
Add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-
Send me a pull request. Bonus points for topic branches.
Copyright © 2010 Dan Dofter. See LICENSE for details.