Find a Route Searching by a Custom Field Value

See files for this Use Case on the GitHub here

You can find routes by containing custom fields data.

Description

When viewing a planned route in the Route4Me's official website, you can bring up the details for any of the addresses.

In the address list, click on the address you want to view. At the bottom of address details list you can find custom data, dictionary like object. You can create any field name in custom data and assign to it any string data. The custom data is useful for adding additional information to an address and for searching them.

Solution

Optimization Parameters and addresses

Let us choose a Single Depot Multiple Driver option for this use case. You can create an optimization problem with these parameters:

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 the map as:

Create an Optimization

You can create new optimization for this use case example. 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 :: Single Depot, Multiple Driver, No Time Window
3 
4 ::See video tutorial here: http://support.route4me.com/route-planning-help.php?id=manual0:tutorial2:chapter2:subchapter1
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 "@single_depot_multiple_driver_notime_window_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=https://www.route4me.com/api.v4/optimization_problem.php
4 SET apikey=11111111111111111111111111111111
5 SET optprobid=38D4E661BB49089B92C7722F86ED7181
6 
7 ECHO ON
8 
9 curl -o file1.txt -g -X GET -k "%url%?api_key=%apikey%&optimization_problem_id=%optprobid%"
10 
11 timeout /t 30

See sample RESPONSE JSON data here

In the RESPONSE you can see an array of the addresses, which belongs to 5 generated routes:

"route_id": "43F55835F1E76003FF980547F77338BD"
"route_id": "5A5470EFF970C03AB919CDDBFB7C0E60"
"route_id": "B90FACD1ACD5A76FD22A43321FC28DF7"
"route_id": "BDBD0148A18BECE918E4A2F68F5326D8"
"route_id": "D514B1FF32A519AF49DF4DD7FD8A8577"

Let us to choose "route_id": "B90FACD1ACD5A76FD22A43321FC28DF7" and see its details.

Details of the Chosen Route

You can get more details of the route:

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=B90FACD1ACD5A76FD22A43321FC28DF7
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

You can draw the route on the map as:

Add Custom Data to the Route Destination

As you can see from last response file, there 19 addresses there. Let us to choose 15-th address with route_destination_id=177507929 (it's most standalone among all addresses and easy to see on the map) and add custom data to it.

HTTP Parameters (see JSON schema here)

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
route_id string Route ID GET
route_destination_id intenger Route destination ID GET
custom_fields array Array of custom fields with string values POST


From the cUrl example bellow you can see that:

1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/api.v4/address.php
4 
5 :: You should insert real test data and your API key for accurate testing
6 
7 SET apikey=11111111111111111111111111111111
8 SET routeid=B90FACD1ACD5A76FD22A43321FC28DF7
9 SET routedestinationid=177507929
10 
11 ECHO ON
12 
13 curl -o file1.txt -g -k -X PUT -H "Content-Type: application/json" -d "@update_route_destination_custom_data.json" "%url%?api_key=%apikey%&route_id=%routeid%&route_destination_id=%routedestinationid%"
14 
15 timeout /t 30

See sample response data (see here).

Pay attention to the parameter custom_fields:

"custom_fields": {
"cargo_place": "Leave the cargo near to the entrance door",
"message_for_client": "Next cargo will be delivered tomorrow morning" }
Attention
If you'll name fields with the words and backspaces between them, you can't search such fields' content, use underline symbol "_" instead of backspace.

Find a Route by Custom Fields Data

Now you can find a route containing the destination with appropiate custom data, even if this destination was moved from initial route to other one.

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

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
query string Text to be searched for GET


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

See sample response data (see here).