Saturday, 15 February 2014

scala - Spatial cypher queries don't work -



scala - Spatial cypher queries don't work -

i configured spatial plugin neo4j next rest api calls:

post http://localhost:7474/db/data/ext/spatialplugin/graphdb/addsimplepointlayer { "layer" : "geom", "lat" : "lat", "lon" : "lon" } post http://localhost:7474/db/data/index/node/ { "name" : "geom", "config" : { "provider" : "spatial", "geometry_type" : "point", "lat" : "lat", "lon" : "lon" } }

i add together spatial nodes next scala code (embedded in play application):

val mergestatement = cypher( """ merge (location: location {placesid: {id}, name: {name}, lat: {lat}, lon: {lon}}) homecoming id(location) """ ).on("id" -> id, "name" -> name, "reference" -> reference, "lat" -> latitude, "lon" -> longitude) val nodeid = mergestatement().head[long]("id(location)") val bodya = jsobject(seq(("value",jsstring("dummy")),("key",jsstring("dummy")),("uri", jsstring(neo4jrest.baseurl + "node/" + nodeid.tostring)))) ws.url(neo4jrest.baseurl + "index/node/geom").withheaders("accept" -> "application.json").post(bodya) map { response => val bodyb = jsobject(seq(("layer",jsstring("geom")),("node", jsstring(neo4jrest.baseurl + "node/" + nodeid.tostring)))) ws.url(neo4jrest.baseurl + "ext/spatialplugin/graphdb/addnodetolayer").withheaders("accept" -> "application.json").post(bodyb) }

everything looks fine ,

post http://neo4jurl/db/data/ext/spatialplugin/graphdb/findgeometrieswithindistance` { "layer" : "geom", "pointx" : 8.5, "pointy" : 47.3, "distanceinkm" : 10 }

returns location nodes (and nodes spatial index - normal?)

post http://neo4jurl//db/data/cypher { "query" : "start node = node:geom('withindistance:[8.5,47.3, 10.0]') homecoming node" }

only returns

{ "columns" : [ "node" ], "data" : [] }

what wrong? missing?

you mixing layers indexes. cypher query works off indexes. don't create layer. create spatial index, , add together nodes spatial index, cypher see them.

see http://maxdemarzi.com/2014/01/31/neo4j-spatial-part-1/ example.

scala neo4j playframework-2.0 cypher anormcypher

No comments:

Post a Comment