0
votes

I'm looking for a very basic example of using neo4j spatial features from php, preferably with the use of this library neo4jphp

i want to store a list of venues with their latitude and longitude

how do i store such information? can the lat and long be stored with the other venue info in one node?

how do you find venues around some given point?

thanks

edit: with spatial features i mean the spatial plugin for neo4j

1
Unrelated to your question, but I'm just curious what you intend to use Neo4j for with your venues and lng/lat? What benefit will it give you? - Layke
for example you could display them on a map - bazo
Yeah, I mean specifically, why do you want to implement this in neo4j.? That's the bit i'm interested in. - Layke
If you figure out how to do this, please submit a feature request with some working code samples for neo4jphp. - Josh Adell
Layke: because i also want to use other neo4j features. Dont know of any other graph database with spatial support which also has a php client library. - bazo

1 Answers

0
votes

i would suggest to create a node for each venue, and then to create properties latitude and longitude for this type of node. then, you must also index these properties.

to solve the problem with venues around a given point, well, maybe creating some country supernodes could help - e.g. europe, middle europe, czech republic, Prague. but this requeires the db of such country names. i would rather create virtual country parts: imagine the world globe as a 2d map. than make a grid on it to get a matrix of NxM squares - the best would be divide it by using some global pattern like each +1 of latitude and longitude is a virtual country part.

after you got this virtual country parts than simply connect all your venue nodes to its supernode which have properties lat's+long's within this virtual country part. than, when searching for all nodes within you radius, you must find first the country part( or more parts when crossbordered) and then manualy check all nodes within this part(s) whether or not they fit into your radius.

at least you don't need to check all nodes but only a subset. i'm not aware of such an index solution which could handle the radius problem, only manual check is the only way.

do you need an example using neo4jphp? if so, i'll find some time to make one.

EDIT: i found that some solution already exist like https://github.com/neo4j/spatial so maybe my answer isn't appropriate and you should wait for an domain expert answer.