Home > dm-appengine-geomodel

dm-appengine-geomodel

Dm-appengine-geomodel is a project mainly written in Ruby, based on the Apache-2.0 license.

Implementation of the geomodel library for dm-appengine

Implementation of the geomodel library for dm-appengine.

This is still a pretty early sketch, not even suited for testing... If you really want to try it:

require 'geomodel'

class Thing include DataMapper::Resource #Or include DataMapper::AppEngineResource is :geomodel

property :stuff, String property :location, GeoPt #You have to define a location property for

GeoModel to work. This way you have a choice

end #to define it as required or optional.

Lets create a new entity with a defined location

example = Thing.new example.location = AppEngine::Datastore::GeoPt.new(12.3, 45.9) example.save

Lets define 2 points for a bounding box

southwest = AppEngine::Datastore::GeoPt.new(10, 45) northeast = AppEngine::Datastore::GeoPt.new(11, 46)

Now we can do bounding box queries like this:

Thing.all(:location.gt => southwest, :location.lt => northeast)

or like this:

Thing.all(:location.gt => "10.23,45.01", :location.lt => "11.03,46.34")

in this case, we give the points as a string of format "lat,lng".

TODO:

Cut a gem.

Document code and write a decent README / tutorial.