cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Assigning a nearest delivery agent for delivery in a city using neo4j

Hello everyone , I am doing  an college project on delivery service in a city, a one of  my use case is to assign a nearest delivery agent for delivery using delivery agent coordinates and order coordinates. I want to implement the above case using neo4j. please help me with that. 

1 REPLY 1

if you have the coordinates of each delivery agent and order location, then you can calculate their 'point' value and then calculate the distance between each point. You can iterate over the agents and find the one with the smallest distance.

Here is an example of converting lat/long coordinates to a point type, then calculate the distance between two points. 

with point({latitude: 12.78, longitude: 56.7}) as p1,
point({latitude: -5.248, longitude: 100.0}) as p2
return point.distance(p1,p2) as distance

https://neo4j.com/docs/cypher-manual/current/syntax/spatial/

 

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online