Gerry
Gerry

Reputation: 5336

Neo4j spatial in ruby

I recently started playing with neo4j graph database in a Rails application and loved how rich the neo4j is. Although I saw that there is spatial support for neo4j via neo4j-spatial I haven't seen an example in a ruby application to get me started (using the ruby port of neo4j-spatial).

What I want to accomplish at first is to have a User model and a Poi model both having lat, lng attributes and make a query: Show me the Poi's that are at most 10km away from me but I have no idea how I have to go about using the ruby gem. All I have found on the subject is this blog spot.

Does anyone know how am I supposed to do this in ruby? Thanks!

Upvotes: 0

Views: 394

Answers (2)

Craig Taverner
Craig Taverner

Reputation: 769

I wrote the gem as a simple wrapper. It depends on neo4j.rb so you get all the necessary ruby on rails capabilities from that. Then it includes the spatial dependencies also. In addition it provides utilities for wrapping OSM import and export and dynamic layer support. It does not provide utilities to wrap the simple point layer which you seem to want. However you kind of get that for free anyway with jruby directly wrapping all of the java API for you.

My recommendation would be to use neo4j-spatial.rb and then use the neo4j.rb capabilities to build your model. Access the simple point layer directly from jruby and just add your new nodes to that. Then you can call the distance search function, also from jruby.

Upvotes: 1

Peter Neubauer
Peter Neubauer

Reputation: 1700

I think the ruby gem is a bit out of date. I suggest either forking and updating it, or use straight Java APIs for that, see the original java methods that the Spatial ruby just wraps.

Lemme know if you want to contribute and update, would be great!

Upvotes: 1

Related Questions