SubwayMap Class
Subway Map Object constructor
Item Index
Methods
- drawLabels
- drawRoute
- drawSubwayLines
- drawSubwayMap
- drawSubwayStations
- fillDropDown
- getCanvasX
- getCanvasY
- getIntersectionsByLineId
- getLineByName
- getLineWidth
- getSharedLines
- getStationById
- getStationColors
- getStationOnIntersectedLine
- getStationRadius
- getStationsBetween
- getStationsByIntersectionId
- getStationsByLineId
- getStationsToLine
- render
- roundRect
- setRoute
- testMap
Properties
Methods
drawLabels
()
private
Draws subway station labels on canvas
drawRoute
()
private
Draws the route
drawSubwayLines
()
private
Draws subway lines on canvas
drawSubwayMap
()
Description
Returns:
drawSubwayStations
()
private
Draws subway stations on canvas
fillDropDown
-
data
-
id
Fills dropdown menus with stations data
Parameters:
-
data
Objectan array of stations
-
id
Stringid of the select element
getCanvasX
-
X
Calculates X coordinate on the canvas plane
Parameters:
-
X
Numberrelative X coordinate
Returns:
X coordinate on the canvas plane
getCanvasY
-
Y
Calculates Y coordinate on the canvas plane
Parameters:
-
Y
Numberrelative Y coordinate
Returns:
Y coordinate on the canvas plane
getIntersectionsByLineId
-
line_id
Calculates an array of subway stations on a given subway line which intersects with other subway lines
Parameters:
-
line_id
Numbersubway line ID
Returns:
an array of subway stations
getLineByName
-
name
Gets a subway line object by subway line name
Parameters:
-
name
Stringsubway line name
Returns:
a subway line
getLineWidth
()
Number
private
Calculates subway line relative width
Returns:
width of the subway line
getStationById
-
id
Gets a subway station with by subway station ID
Parameters:
-
id
Numbersubway station ID
Returns:
a subway station
getStationColors
-
station
Calculates an array of colors for a given station
Parameters:
-
station
Objecta subway station
Returns:
an array of string which represents subway station color to be paint
getStationOnIntersectedLine
-
lineId
-
station
Gets a station object on a given line which has shared intersection with a given station
Parameters:
-
lineId
Numbersubway line ID
-
station
Objectsubway station
Returns:
a subway station
getStationRadius
()
Number
private
Calculates subway station relative radiues
Returns:
radius of the subway station
getStationsBetween
-
from
-
to
Gets an array of subway stations between station of origin and station of destination on the same subway line
Parameters:
-
from
Objectstation of origin
-
to
Objectstation of destination
Returns:
an array of subway stations
getStationsByIntersectionId
-
intersection_id
Calculates an array of subway stations with a passed intersection ID
Parameters:
-
intersection_id
Numberintersection ID
Returns:
an array of subway stations
getStationsByLineId
-
id
Gets an array of subway stations by subway line ID
Parameters:
-
id
Numbersubway line ID
Returns:
an array of subway stations
getStationsToLine
-
stationfrom
-
lineTo
Calculates an array of station between station of origin to closest intersection with passed subway line
Parameters:
-
stationfrom
Objectstation of origin
-
lineTo
Numbersubway line id
Returns:
an array of stations
render
()
Renders canvas
roundRect
-
ctx
-
x
-
y
-
width
-
height
-
radius
-
fill
-
stroke
Draws rounded rectangle on a canvas
Parameters:
-
ctx
Objecta canvas context
-
x
Numbercoordinate
-
y
Numbercoordinate
-
width
Number -
height
Number -
radius
Number -
fill
Boolean -
stroke
Boolean
setRoute
-
StationIdfrom
-
StationIdto
Calculates most optimal route between two given stations
Parameters:
-
StationIdfrom
NumberID of the station of origin
-
StationIdto
NumberID of the station of destination
Returns:
an array of stations
testMap
()
A method to test the subway map
Properties
route
Unknown
Array of subway stations, represents a route
subwayLines
Unknown
Array of subway lines