java neo4j rest,通过JAVA API在REST上的Neo4j Spatial无法正常工作(对我来说)

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

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

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?

At first sight it appears that it ought to be possible:

// 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")

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 | in ''

| 59 | createInnerEngine in org.neo4j.cypher.javacompat.ExecutionEngine

| 43 | 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 | in net.foo.db.neo4j.Neo4JService

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?)

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.

解决方案

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.

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值