Identify a Route by a Custom ID and Remove a Specific Destination

See files for this Use Case on the GitHub here

Description

You can identify a route with a custom ID and remove a specific destination.

Solution

Optimization Parameters and addresses

Please pay attention to the following set of parameters, so you can select the correct ones for this specific use case:

ParameterTypeDescriptionHTTP method
api_keystringAPI KEY of the userGET
redirectintegerif equal to 1, will be redirected, if 0 - notGET
addressesarrayValid JSON array of Address objects. Click here to see the JSON SchemaPOST
parametersRoute ParametersValid JSON string of RouteParameters object. Click here to see the JSON SchemaPOST

You can see the addresses on a map as:

Create an Optimization

You can create new optimization for this use case. From the cUrl example bellow you can see that:

ParameterTypeDescription
api_keystringAPI KEY of the user
input dataPOST dataValid JSON object string. Click here to see the JSON Schema
1 @ECHO OFF
2 :: Multiple Depot, Multiple Driver with 24 Stops, Time Window
3 
4 ::See video tutorial here: http://support.route4me.com/route-planning-help.php?id=manual0:tutorial2:chapter2:subchapter2
5 
6 SET URL=https://www.route4me.com/api.v4/optimization_problem.php
7 SET apikey=11111111111111111111111111111111
8 SET route_path_output=Points
9 
10 ECHO ON
11 
12 curl -o file1.txt -g -X POST -k -d "@multi_depot_multi_driver_24stops_tw_data.json" "%URL%?api_key=%apikey%&route_path_output=%route_path_output%"
13 
14 timeout /t 30

You can expect an Optimization problem (see link), which generated some routes already.

View the Optimization details

You can get more details from the newly created optimization problem:

The endpoint: https://www.route4me.com/api.v4/optimization_problem.php

HTTP Parameters

AttributeTypeDescriptionHTTP
method
api_keystringAPI KEY of the userGET
optimization_problem_idstringOptimization problem IDGET


1 @ECHO OFF
2 
3 SET url=http://www.route4me.com/api.v4/optimization_problem.php
4 SET apikey=11111111111111111111111111111111
5 SET optprobid=8E23ED7EEC79D27E5B2F092023FF055E
6 
7 ECHO ON
8 curl -o file1.txt -g -X GET -k "%URL%?api_key=%apikey%&optimization_problem_id=%optprobid%"
9 
10 timeout /t 30

See sample RESPONSE JSON data here

System will send a RESPONSE with an array of the addresses that belongs to 5 generated routes:

"route_id": "3F0F18E21A3A4411027EC277449D2878" - 5 addresses;
"route_id": "4F9A4259F7C80127349ED8BB7F62A9E9" - 5 addresses;
"route_id": "9F019B4481C6566F7E338136DAC0B89E" - 11 addresses;
"route_id": "A1D840B5A4CE2A5D3840CA3C99593A6F" - 5 addresses;
"route_id": "D2F21FAD3F92C55ADA81FC841CCA3A1A" - 5 addresses.

Details of an Optimized Route

You can get more details of these routes (see below the one route example, you can also get details of the other 4 routes using the same method by adjusting the parameter route_id):

The endpoint: https://www.route4me.com/api.v4/route.php

HTTP Parameters

AttributeTypeDescriptionHTTP
method
api_keystringAPI KEY of the userGET
route_idstringRoute IDGET
route_path_outputstringIf equal to 'Poitns', you'll get an array of the path points to next addressGET


1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/api.v4/route.php
4 SET apikey=11111111111111111111111111111111
5 SET routeid=9F019B4481C6566F7E338136DAC0B89E
6 SET rpo=Points
7 
8 ECHO ON
9 
10 curl -o file1.txt -g -k -X GET "%url%?route_id=%routeid%&api_key=%apikey%&route_path_output=%rpo%"
11 
12 timeout /t 30

See sample RESPONSE JSON data here

Note
System will send a RESPONSE with an array of the fields path_to_next. Those will be used to draw routes on a map, exactly as they generated by Route4Me API.

You can see a route drawn on the map by the Route4Me API as:

Change Route ID

You can add custom ID to a route.

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
route_id string Route ID GET
route_id string New Route ID POST


From the cUrl example bellow you can see that:

Input file content is:

{
"route_id": "9F019B4481C6566F7E338136DAC0B899"
}
1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/api.v4/route.php
4 SET apikey=11111111111111111111111111111111
5 SET routeid=9F019B4481C6566F7E338136DAC0B89E
6 
7 ECHO ON
8 
9 curl -o file1.txt -g -k -X PUT -H "Content-Type: application/json" -d "@set_custom_id_data.json" "%url%?api_key=%apikey%&route_id=%routeid%"
10 
11 timeout /t 30

See sample RESPONSE JSON data here

You can retrieve the optimization problem as described above. Please note that now we have 6 routes - one additional route with route_id = 9F019B4481C6566F7E338136DAC0B899 is a clone of the route with route_id = 9F019B4481C6566F7E338136DAC0B89E but with some addresses removed (see link here)

Remove Destination From a Route

As you remember, one standalone address has a label on the map image above. Let us remove this address out of the route.

The endpoint: https://www.route4me.com/api.v4/route.php

Http method: DELETE

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
route_id string Route ID GET
route_destination_id integer Route destination ID GET


1 @ECHO OFF
2 SET url=https://www.route4me.com/api.v4/address.php
3 SET apikey=11111111111111111111111111111111
4 SET routeid=9F019B4481C6566F7E338136DAC0B89E
5 SET routedestinationid=184536231
6 
7 ECHO ON
8 
9 curl -o file1.txt -g -X DELETE -k "%url%?api_key=%apikey%&route_id=%torouteid%&route_destination_id=%routedestinationid%"
10 
11 timeout /t 30

You can expect this response:

{
"deleted": true,
"route_destination_id": 184536231
}

Now you have only 10 addresses. You can once again retrieve information about the route as described above. See sample RESPONSE JSON data here