Bringing visibility to advancements in the public transportation network of Seville.
Advancements in technology are not appreciated until you shine a light on them. A great example is the future Metro Line 3 in Seville, Spain. Funding has recently been secured for the construction of half of the line, but most inhabitants of the city are unaware of this.
The project aims to bring visibility to the advancements in the public transportation network of the city. Three new lines are planned, as shown on the map below:
In a nutshell, the website allows the user to select an origin and destination address. It will then calculate the shortest route to the destination, taking into account the new, still under construction metro line.
The user gets an outline of the route steps, as well as a summary that indicates how much time is saved on the route with the new metro line compared to the time it would have taken with the current public transportation network.
The project is built with Next.js and Tailwind CSS for the frontend. The backend also runs on Next.js, and consumes the Google Maps API to calculate routes.
The Google Maps API unfortunately does not allow adding custom public transport lines to the map. In order to work around this key limitation and calculate the route including the new metro line, a custom algorithm had to be developed, which works as follows:
This provides a rough estimate of what the route would look like when the new metro line is finally completed.
This is a fragment of the routing code corresponding to the metro segment:
const stops = Math.abs(indexDestination - indexOrigin); // 2 minutes to enter the station + 1.5 minutes per station + 2 minutes to exit const travelTime = stops * TRAVEL_TIME_PER_STATION; const totalTime = TIME_TO_ENTER_STATION * 2 + travelTime;
Leaflet was used to render the map and draw paths, tooltips and other elements on it. The metro stops are represented in a JSON file, which is then used to draw the metro stations on the map.
Here's a sample station:
{ "name": "Prado de San Sebastián", "coords": [37.380604, -5.987247], "correspondence": "L3" }
For the route segments calculated using the Google Directions service, the API provides a polyline that can be drawn on the map with colors representing the different bus lines.