Adding spatial points as properties in the java api


(N) #1

I would like to add org.neo4j.graphdb.spatial.Points as properties via the java api within a user-defined procedure. However, I can't find a constructor for this class. As a work-around, I'm doing:

Map<String, Object> pointQueryResult = dbService.execute("RETURN point({ x:" + x + ", y:" + y + ", z:" + z + ", crs:'cartesian-3D'}) AS point").next();
myNode.setProperty("location", (Point) pointQueryResult.get("point"))

But I think it would be faster if I didn't have to execute a cypher query to get back the Point. Is there a way to do this?

(Craig Taverner) #2

The original thinking was that people using the Java API would probably already have existing data models and would like to pass their existing java objects into the API, and need only implement the interface to do so. For this reason there are currently no public implementations of this interface for your use.

I personally have probably written a few trivial implementation of the interface for various projects. It should be quite easy to implement your own in a way that suites your code and use case. If you really want a pre-implemented object, there are some private implementations available, but none are part of the public API and so subject to change between releases. It is safer to implement your own.