Create a Polygon Territory Around a Geographic Area

You can create a Territory zone with polygon shape around geographic area.

Description

Territory zones can be very useful for route planning and optimization. For example, you can set up a trigger when a vehicle is entering or leaving a Territory zone or you can use a Territory zone for group addresses searching etc. Territory based optimization is also convenient if you want to see how close is specific area to regional office / warehouse locations. Based on that information you can easily assign you customers with nearest available personnel. You can create a Territory zone of three different shapes: circle, polygon and rectangle.

Solution

Choose a Geographic Area

Suppose your logistic company got new customers in Huston city, Texas. You have 9 locations (addresses to visit) in total. You can enter these addresses in your address book belonging to your Route4Me account. You can find the list of these addresses on our GitHub all_contacts_data.json. You can extract the addresses one by one and insert those in the JSON input file. Then you run batch script as described bellow. Please note that the endpoint can get only one address on input.

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
input data POST data Valid JSON string of the Address book location. Click here to see the JSON Schema POST


From the cUrl example bellow you can see that:

1 ECHO OFF
2 SET url=https://www.route4me.com/api.v4/address_book.php
3 SET apikey=11111111111111111111111111111111
4 
5 ECHO ON
6 
7 :: Needs clarification - requires member_id, altough ir is sent
8 
9 curl -o file1.txt -k -X POST -d "@add_contact_to_addressbook_data.json" "%url%?api_key=%apikey%&member_id=1"
10 
11 timeout /t 30

Our system will respond with Address book location object (see link).

You can do above described steps for the rest 8 addresses too (you can see all response JSON files here: Response files)).

On the Route4Me's map you can see all 9 locations as:

Make Territory Zone around Geographic Area

We have 9 new addresses in the Address book with following address_id:

"address_id": 8762599,
"address_id": 8762600,
"address_id": 8762601,
"address_id": 8762629,
"address_id": 8762630,
"address_id": 8762631,
"address_id": 8762632,
"address_id": 8762633,
"address_id": 8762634

Let us inscribe all of them in a Territory zone.

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
input data POST data Valid JSON string of the Territory object. Click here to see the JSON Schema POST


From the cUrl example bellow you can see that:

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

See sample RESPONSE JSON data here

On the Route4Me's map you can see created Territory zone as:

Note
Alternatively, you can create polygon shape with Google Earth service and then download it as kml file. For your convenience, under Route4Me web application you can copy content of the kml file, paste it inside the form and you'll get Avoidance zone on Route4Me map. Note of caution: please, use this kml sample file as a template, as not every polygon kml sample format can be correctly accepted by Route4Me web application.
Attention
In the kml file points are given as: longitude, latitude, attitude.