通过JAVA API在REST上的Neo4j Spatial无法正常工作(对我来说) [英] Neo4j Spatial over REST through the JAVA API not working (for me)

查看:115
本文介绍了通过JAVA API在REST上的Neo4j Spatial无法正常工作(对我来说)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过Neo4J开发Grails应用程序,我还希望将其导出为GIS数据库.

I'm working on a Grails app over Neo4J which I'd like to also export as a GIS database.

查看有关如何在GeoServer/uDig中使用neo4j的示例,看来空间集成仅通过嵌入式neo4j数据库进行.

Looking at the examples for how to use neo4j in GeoServer/uDig it appears that the Spatial integration is only via embedded neo4j databases.

有人知道是否有可能进行设置,以便我的Neo4J通过REST可用,以便我可以从许多地方连接到它?

Does anyone know whether it's possible to set things up so that my Neo4J is available over REST, so that I can interface to it from a variety of places?

乍一看似乎应该可行:

// Works with this embedded database
//def graphDb = new GraphDatabaseFactory().newEmbeddedDatabase("/tmp/foo.db");

// Doesn't work with this REST database
graphDb = new RestGraphDatabase("http://localhost:7474/db/data");

Transaction tx = graphDb.beginTx()

SpatialDatabaseService spatialService = new SpatialDatabaseService(graphDb)
SimplePointLayer layer = spatialService.createSimplePointLayer("points")

使用嵌入式数据库,就可以很好地创建空间索引. 但是,使用REST数据库,我只会得到一个空指针:

With an embedded database, the spatial index gets created just fine. However, with the REST database, I just get a null pointer:

Caused by NullPointerException: null
->>  149 | createCompiler in org.neo4j.cypher.ExecutionEngine
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|     48 | <init>    in     ''
|     59 | createInnerEngine in org.neo4j.cypher.javacompat.ExecutionEngine
|     43 | <init>    in     ''
|     41 | getReferenceNode in org.neo4j.gis.spatial.utilities.ReferenceNodes
|     78 | getSpatialRoot in org.neo4j.gis.spatial.SpatialDatabaseService
|    114 | getLayer  in     ''
|    259 | containsLayer in     ''
|    303 | createLayer in     ''
|    287 | createSimplePointLayer in     ''
|    267 | createSimplePointLayer in     ''
|     37 | <init>    in net.foo.db.neo4j.Neo4JService

SpatialDatabaseService采用了GraphDatabaseService,所以我对为什么它不能与REST一起使用感到困惑.

The SpatialDatabaseService takes a GraphDatabaseService, so I'm confused as to why it doesn't work with a REST one.

这是错误或功能(还是我的误解?)

Is this a bug or a feature (or a misunderstanding on my part?)

我当然可以使用create index API创建空间索引:

I can, of course, use the create index API to create a spatial index:

graphDb.index().forNodes( "points", ["provider": "spatial", "geometry_type": "point", "lat": "lat", "lon":"lon"])

这样行得通,但是我不能那样创建新层.

so that works, but I can't create new layer that way.

推荐答案

RestGraphDatabase是一个伪造的数据库,不能提供所有功能. 从理论上讲,它可以工作,但非常浪费,因为每个可能的嵌入式操作都将根据http请求通过网络进行传输.

The RestGraphDatabase is a fake database which doesn't offer all capabilities. It could be made work in theory but would be very wasteful as each presumably embedded operation would go over the wire as http requests.

将Spatial作为插件安装到服务器,然后通过插件REST方法访问它.

Install Spatial as Plugin to your server and then access it via the plugin REST methods.

请参阅: http://neo4j-contrib.github.io/spatial /#spatial-server-plugin

这篇关于通过JAVA API在REST上的Neo4j Spatial无法正常工作(对我来说)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆