getJSON

Helper function to request any JSON file from the backend. Used to request the unprocessed and the octilinear metro graph JSONs.

getJSON(url: url, callback: any, method: callback)
Parameters
url (url) the JSON is requested from
callback (any)
method (callback) to be called upon receiving the Back-End response.

setupMap

Performs setup of a leaflet map on the Website for displaying the unprocessed metro map.

setupMap(point: any, zoom: any)
Parameters
point (any) the point the map should initially be focused on.
zoom (any) initial zoom level of the map. See Leaflet reference for more information on zoom levels.

setupGraph

Performs setup of a leaflet map on the Website for displaying the processed octilinear metro map.

setupGraph(point: any, zoom: any)
Parameters
point (any) the point the map should initially be focused on.
zoom (any) initial zoom level of the map. See Leaflet reference for more information on zoom levels.

fitMap

fits the map to all markers present on it. Markers represent stations, therefore this function allows us to zoom and pan the map in a way that all stations are in the picture.

fitMap()

drawLine

Draws a line on the target leaflet map specified.

drawLine(target: any, points: any, color: any, opacity: any, offset: any): any
Parameters
target (any) the map the line should be drawn on.
points (any) array of two points that the line should connect.
color (any) color of the new line.
opacity (any) opacity of the new line.
offset (any) offset of the new line to allow for multiple lines connecting two stations without them being drawn on top of each other. We use the leaflet.polylineoffset.js library for this.
Returns
any: line the line object just drawn.

drawMarker

Draws a marker on the target leaflet map specified.

drawMarker(target: any, point: any, color: any, info: any): any
Parameters
target (any) the map the marker should be drawn on.
point (any) the point in which the marker should be drawn as an array of two coordinates (lat, lng).
color (any) the fill color of the new marker.
info (any) the information the tooltip of the new marker should contain (used for station names in our case).
Returns
any: marker the marker object just drawn.

getMarkerByName

Used to link the map and graph views so that when hovering on a marker of one, the marker representing the same station on the other map gets highlighted as well.

getMarkerByName(array: any, name: any): any
Parameters
array (any) array holding markers to search for the marker we are hovering over.
name (any) name of the marker we are hovering over.
Returns
any: marker array that holds all markers matching the specified name

convertCoordinates

Helper function that converts WebMercator Coordinates to WGS84. We use the proj4.js library for this. All coordinates in the input JSON data are in WebMercator format and require conversion to WGS84 in order to work with leaflet.

convertCoordinates(point: any): any
Parameters
point (any) array of coordinates (lat, lng) to be converted.
Returns
any: point array of coordinates (lat, lng) in WGS84 format.

drawMetroMap

Draws the unprocessed metro map on the leaflet map by processing the JSON file previously received from the Back-End.

drawMetroMap()

drawMetroGraph

Draws the processed octilinear graph on the leaflet map by processing the JSON file previously received from the Back-End.

drawMetroGraph()

addRadioButtonEvents

Adds events for radio buttons on the Website for user interaction. The radio buttons allow to toggle the map overlay on the octilinear graph map view.

addRadioButtonEvents()

getOffsetDict

Generates a dictionary of offsets for when multiple lines exist on a single edge in order to offset these lines accordingly with the goal to avoid them being drawn on top of each other.

getOffsetDict(numLines: any): any
Parameters
numLines (any) number of lines we want to draw parallel to each other.
Returns
any: offsetDict dictionary of offsets for the lines

getFlipFactor

Gets the flip factor for a line, i.e. finds out whether its on the northern or southern semicircle and returns -1 or 1 to be used later on to flip the line in order to draw it parallel to other lines on an edge.

getFlipFactor(points: any): any
Parameters
points (any) array of two points the line connects.
Returns
any: number -1 or 1 as a flip factor.

setupScrollEvents

Performs setup for the scrolling events in order to use the website itself as a presentation.

setupScrollEvents()