All tutorials

Logistics

intermediate

This tutorial outlines the steps to integrate what3words into a logistics system. More specifically, we will look at how to recognise a 3 word address that is attached to a delivery and how to convert that 3 word address into a coordinate. We’ll also look at how to include a what3words field into the system, so that employees can manually enter a 3 word address.

The end goal is that your logistics system will be able to handle deliveries with a 3 word address from entry to completion.

Using our API wrappers is a straightforward way of integrating quickly with our API. For full set up and installation details, check out our wrapper pages:

Java: https://developer.what3words.com/tutorial/java/
Python: https://developer.what3words.com/tutorial/python/
JavaScript: https://developer.what3words.com/tutorial/javascript/
PHP: https://developer.what3words.com/tutorial/php/
Swift: https://developer.what3words.com/tutorial/swift/
Objective-C: https://developer.what3words.com/tutorial/objective-c/
Android: https://developer.what3words.com/tutorial/android/

1
2

Recognise a 3 word address attached to a delivery

For every delivery flowing into your system, you will need to check whether it has a 3 word address as part of its information. While it is becoming more standard to pass 3 word addresses in a ‘what3words’ field, it is still common that 3 word addresses are passed in Address Line 1, 2 or 3, or a number of other fields. For this reason it’s best to check every field.

We check each field for a 3 word address by using a regular expression (RegEx). Our “full search” RegEx will only match a string that looks like a 3 word address e.g. “filled.count.soap” (or ///filled.count.soap).

You can find our ‘full’ RegEx below (see our RegEx tutorial here for more information):

String text = "index.home.raft";
String regex = "(?:\\p{L}\\p{M}*){1,}[.。。・・︒។։။۔።।](?:\\p{L}\\p{M}*){1,}[.。。・・︒។։။۔።।](?:\\p{L}\\p{M}*){1,}";

Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(text);

if (matcher.find())
  System.out.println(text + " is the format of a three word address");
else
  System.out.println(text + " is not a three word address");
Copied
3

Convert the 3 word address into a coordinate

If a 3 word address is detected, we then need to convert this 3 word address into a coordinate, so that we can calculate routes etc.

Use the convert-to-coordinates endpoint of the what3words API to obtain the latitude and longitude of the 3 word address. Store these coordinates as part of the delivery’s information.

Using our wrappers this can be done as follows:

// Convert a 3 word address to coordinates
ConvertToCoordinates coordinates = api.convertToCoordinates("filled.count.soap")
        .execute();
System.out.println("Coordinates: " + coordinates);
Copied
4

Adding an input box for a 3 word address

It’s often the case that addressing information is gathered along the way in a delivery system. In such cases, it may be necessary to add a 3 word address to a delivery.

We can use the what3words AutoSuggest Component to quickly create an input field for a 3 word address, which includes AutoSuggest functionality that will automatically display a drop-down list of relevant 3 word address suggestions as your operative types. This greatly reduces errors on input.

You can find out more about the AutoSuggest Component here.

Development Checklist

  • Get an API key
  • Recognise a 3 word address attached to a delivery using a regular expression
  • Convert the 3 word address into a coordinate using the what3words API.
  • Add an input box for a 3 word address to your delivery system

Add a 3 word address input fieldDetect if text looks like a 3 word addressUse 3 word addresses within an address search

Related tutorials