spatial icon indicating copy to clipboard operation
spatial copied to clipboard

Can I use spatial from NodeJS

Open cayasso opened this issue 11 years ago • 6 comments

Can I use spatial from node, perhaps from the node-neo4j driver or any other?

cayasso avatar Jan 08 '14 16:01 cayasso

This depends on how you want to use spatial. Most of the spatial capabilities are only available through the Java API (and therefor only through embedded support, like Ruby neo4j.rb). The REST API has some standard LBS support (distance searches of points). node-neo4j works through REST, so it will only access these features. If that is all you need perhaps it is good enough.

There is also a node.js driver for the Java API called neo4j-embedded. See http://joewhite86.wordpress.com/2013/07/08/introducing-neo4j-embedded-a-neo4j-driver-for-node-js/. Perhaps this will allow for direct access to the full spatial capabilities.

I've never tried spatial from JS or node.js, so I cannot really comment on how easy or difficult these options are. It would be interesting to try though!

craigtaverner avatar Jan 09 '14 20:01 craigtaverner

I am using it via node / rest api. Take a look at this gist: https://gist.github.com/thomasfr/8103037 After adding the layer and the spatial index, you actually just need cypher,.. almost. When adding new nodes you have to add this nodes also via a rest call to the spatial index manually.

thomasfr avatar Jan 11 '14 16:01 thomasfr

Regarding your questions: you should be able to use the node-neo4j "driver" as it is just a wrapper module around neo4js rest api. All cypher queries are just sent over to the cypher endpoint and the response gets parsed and returned. The only additional http request you will have to make is step 4 from this gist https://gist.github.com/thomasfr/8103037 after each node creation.

I have created two issues for a more convenient way of using neo4j/spatial over http and cypher only: https://github.com/neo4j/spatial/issues/125 https://github.com/neo4j/neo4j/issues/2048

cheers

thomasfr avatar Feb 25 '14 16:02 thomasfr

@thomasfr That's awesome, I will give it a try in a project I am working on, thank you!

cayasso avatar Feb 25 '14 17:02 cayasso

@thomasfr how do you go about updating / deleting a node in the geo index using the rest API? Have you figured that out?

skevy avatar Mar 04 '15 16:03 skevy

Did you successful query spatial node with NodeJS ?

pangguoming avatar Oct 14 '15 02:10 pangguoming