简体   繁体   English

Neo4j在红宝石中的空间

[英]Neo4j spatial in ruby

I recently started playing with neo4j graph database in a Rails application and loved how rich the neo4j is. 我最近开始在Rails应用程序中使用neo4j图形数据库,并且喜欢neo4j的丰富程度。 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 ). 虽然我看到通过neo4j-spatial对neo4j有空间支持,但我没有在ruby应用程序中看到一个例子来启动我(使用neo4j-spatial的ruby端口)。

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. 我最初想要完成的是让User模型和Poi模型都具有lat, lng属性并进行查询: 向我展示离我最远10公里的Poi,但我不知道我该怎么走关于使用红宝石宝石。 All I have found on the subject is this blog spot . 我在这个主题上发现的就是这个博客点

Does anyone know how am I supposed to do this in ruby? 有谁知道我应该如何在红宝石中做到这一点? Thanks! 谢谢!

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. 我建议分叉和更新它,或者使用直接的Java API,请参阅Spatial ruby​​刚刚包含的原始java方法。

Lemme know if you want to contribute and update, would be great! Lemme知道你是否想要贡献和更新,会很棒!

I wrote the gem as a simple wrapper. 我把gem写成一个简单的包装器。 It depends on neo4j.rb so you get all the necessary ruby on rails capabilities from that. 这取决于neo4j.rb,所以你可以从中获得所有必需的ruby on rails功能。 Then it includes the spatial dependencies also. 然后它还包括空间依赖性。 In addition it provides utilities for wrapping OSM import and export and dynamic layer support. 此外,它还提供了用于包装OSM导入和导出以及动态层支持的实用程序。 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. 无论如何,你可以通过jruby直接包装所有java API来免费获得。

My recommendation would be to use neo4j-spatial.rb and then use the neo4j.rb capabilities to build your model. 我的建议是使用neo4j-spatial.rb然后使用neo4j.rb功能来构建你的模型。 Access the simple point layer directly from jruby and just add your new nodes to that. 直接从jruby访问简单的点图层,只需将新节点添加到该点。 Then you can call the distance search function, also from jruby. 然后你可以调用距离搜索功能,也可以从jruby调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM