Skip to content

Instantly share code, notes, and snippets.

@karussell
Last active February 10, 2020 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karussell/ff4f855a07ea0eb2ada26625ecb415d4 to your computer and use it in GitHub Desktop.
Save karussell/ff4f855a07ea0eb2ada26625ecb415d4 to your computer and use it in GitHub Desktop.
Cluster API
{
"configuration" : {
"routing" : {
"profile" : "car"
},
"clustering" : {
"max_quantity" : 10,
"min_quantity" : 5,
"num_clusters" : 5
}
},
"customers" : [ {
"address" : {
"lon" : 11.5600,
"lat" : 48.1637
},
"quantity" : 2,
"id" : "6719"
}, {
"address" : {
"lon" : 11.6419,
"lat" : 48.1619
},
"quantity" : 1,
"id" : "6765"
}, {
"address" : {
"lon" : 11.5426,
"lat" : 48.1352
},
"quantity" : 1,
"id" : "6897"
}, {
"address" : {
"lon" : 11.5947,
"lat" : 48.1278
},
"quantity" : 1,
"id" : "6945"
}, {
"address" : {
"lon" : 11.5693,
"lat" : 48.1629
},
"quantity" : 1,
"id" : "6947"
}, {
"address" : {
"lon" : 11.6479,
"lat" : 48.1405
},
"quantity" : 1,
"id" : "6948"
}, {
"address" : {
"lon" : 11.6313,
"lat" : 48.1198
},
"quantity" : 2,
"id" : "6951"
}, {
"address" : {
"lon" : 11.4104,
"lat" : 48.1517
},
"quantity" : 1,
"id" : "6952"
}, {
"address" : {
"lon" : 11.6254,
"lat" : 48.2000
},
"quantity" : 1,
"id" : "6953"
}, {
"address" : {
"lon" : 11.5565,
"lat" : 48.1495
},
"quantity" : 1,
"id" : "6954"
}, {
"address" : {
"lon" : 11.5612,
"lat" : 48.1575
},
"quantity" : 1,
"id" : "6955"
}, {
"address" : {
"lon" : 11.5804,
"lat" : 48.1369
},
"quantity" : 1,
"id" : "7070"
}, {
"address" : {
"lon" : 11.6193,
"lat" : 48.1300
},
"quantity" : 2,
"id" : "9087"
}, {
"address" : {
"lon" : 11.4891,
"lat" : 48.0847
},
"quantity" : 1,
"id" : "9195"
}, {
"address" : {
"lon" : 11.6303,
"lat" : 48.1684
},
"quantity" : 1,
"id" : "8122"
}, {
"address" : {
"lon" : 11.5047,
"lat" : 48.1867
},
"quantity" : 1,
"id" : "9066"
}, {
"address" : {
"lon" : 11.5441,
"lat" : 48.1367
},
"quantity" : 1,
"id" : "9090"
}, {
"address" : {
"lon" : 11.6431,
"lat" : 48.1024
},
"quantity" : 1,
"id" : "9267"
}, {
"address" : {
"lon" : 11.5267,
"lat" : 48.1125
},
"quantity" : 1,
"id" : "9276"
}]
}

Query via curl. Please note the job_id field is an internal field and will be removed

curl -X POST -H "Content-Type: application/json" "https://graphhopper.com/api/1/cluster?key=YOUR_KEY" -d @request.json 
{
  "copyrights" : [ "GraphHopper", "OpenStreetMap contributors" ],
  "job_id" : "eb10bcef-8386-4c48-8364-5d58efcfde19",
  "status" : "finished",
  "waiting_time_in_queue" : 0,
  "processing_time" : 219,
  "clusters" : [ {
    "quantity" : 5.0,
    "ids" : [ "6719", "6947", "6954", "6955" ]
  }, {
    "quantity" : 4.0,
    "ids" : [ "6765", "6953", "8122", "9066" ]
  }, {
    "quantity" : 5.0,
    "ids" : [ "6897", "6952", "9195", "9090", "9276" ]
  }, {
    "quantity" : 4.0,
    "ids" : [ "6945", "7070", "9087" ]
  }, {
    "quantity" : 4.0,
    "ids" : [ "6948", "6951", "9267" ]
  } ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment