4Shipping - Maps API

2018

Introduction

4Shipping's app matches demand and supply for inland shipping. In 2017, it was selected as one of the four most promising startups in the PortXL accelerator programme.

Briefing

4Shipping's app enables shippers to present their cargo to a network of skippers. As the platform grew quickly, it became increasingly important to only present relevant cargo to skippers. The goal was to only present the cargo when a skipper was close to the pick-up point and when the skipper had no other cargo to transport at that time.

Result

My role in this project was to create an application that took care of all the geo-related operations, such as routing. I set up an application that could be accessed via a REST API. The initial version included an end-point that provided the distances between one or more origins and destinations. This enables the 4shipping app to notify skippers about new cargo only when the cargo is located within a reasonably short distance. The distance is calculated by applying Dijkstra’s algorithm to a network of all the waterways in Europe.

Example of the distance matrix end-point


POST /distance-matrices

{
  "data": {
    "type": "distance-matrices",
    "attributes": {
      "origins": [
        {
          "id": "ship-1-Dordrecht",
          "longitude": 4.681961,
          "latitude": 51.820424
        }
      ],
      "destinations": [
        {
          "id": "load-1-Maasvlakte",
          "longitude": 4.052662,
          "latitude": 51.967371
        },
        {
          "id": "load-2-Zaltbommel",
          "longitude": 5.255232,
          "latitude": 51.817114
        }
      ]
    }
  }
}
            

Response: 201 Created

{
  "data": {
    "type": "distance-matrices",
    "id": "1",
    "attributes": {
      "origins": [
        {
          "id": "ship-1-Dordrecht",
          "longitude": 4.681961,
          "latitude": 51.820424
        }
      ],
      "destinations": [
        {
          "id": "load-1-Maasvlakte",
          "longitude": 4.052662,
          "latitude": 51.967371
        },
        {
          "id": "load-2-Zaltbommel",
          "longitude": 5.255232,
          "latitude": 51.817114
        }
      ],
      "calculations": [
        {
          "origin-id": "ship-1-Dordrecht",
          "destination-id": "load-1-Maasvlakte",
          "distance": 581321,
          "status": "OK"
        },
        {
          "origin-id": "ship-1-Dordrecht",
          "destination-id": "load-2-Zaltbommel",
          "distance": 43664,
          "status": "OK"
        }
      ]
    }
  }
}
            

In this project my tasks included specifying and implementing a REST API to provide map-related functionalities. This project made me more experienced in working with Docker, PHP (7.2), Laravel Lumen, the JSON:API specification, PostgreSQL and PostGIS.

Tools and languages used: PHP (7.2), Laravel Lumen, Docker, Docker Compose, PostgreSQL (10), PostGIS, Dijkstra algorithm, unit-testing, PHPUnit, GIT, Bitbucket, REST APIs, JSON:API specification, AWS EC2.