API Docs for:
Show:

SubwayMap Class

Defined in: script.js:11

Subway Map Object constructor

Methods

drawLabels

() private

Defined in script.js:409

Draws subway station labels on canvas

drawRoute

() private

Defined in script.js:661

Draws the route

drawSubwayLines

() private

Defined in script.js:332

Draws subway lines on canvas

drawSubwayMap

()

Defined in script.js:690

Description

Returns:

drawSubwayStations

() private

Defined in script.js:378

Draws subway stations on canvas

fillDropDown

(
  • data
  • id
)

Defined in script.js:758

Fills dropdown menus with stations data

Parameters:

  • data Object

    an array of stations

  • id String

    id of the select element

getCanvasX

(
  • X
)
Number private

Defined in script.js:54

Calculates X coordinate on the canvas plane

Parameters:

  • X Number

    relative X coordinate

Returns:

Number:

X coordinate on the canvas plane

getCanvasY

(
  • Y
)
Number private

Defined in script.js:65

Calculates Y coordinate on the canvas plane

Parameters:

  • Y Number

    relative Y coordinate

Returns:

Number:

Y coordinate on the canvas plane

getIntersectionsByLineId

(
  • line_id
)
Object private

Defined in script.js:213

Calculates an array of subway stations on a given subway line which intersects with other subway lines

Parameters:

  • line_id Number

    subway line ID

Returns:

Object:

an array of subway stations

getLineByName

(
  • name
)
Object private

Defined in script.js:283

Gets a subway line object by subway line name

Parameters:

  • name String

    subway line name

Returns:

Object:

a subway line

getLineWidth

() Number private

Defined in script.js:34

Calculates subway line relative width

Returns:

Number:

width of the subway line

getSharedLines

(
  • lineOne
  • lineTwo
)
Object private

Defined in script.js:169

Calculates an array of subway lines which intersects two given lines

Parameters:

  • lineOne Number

    first subway line ID

  • lineTwo Number

    second subway line ID

Returns:

Object:

an aray of subway lines

getStationById

(
  • id
)
Object private

Defined in script.js:313

Gets a subway station with by subway station ID

Parameters:

  • id Number

    subway station ID

Returns:

Object:

a subway station

getStationColors

(
  • station
)
String private

Defined in script.js:232

Calculates an array of colors for a given station

Parameters:

  • station Object

    a subway station

Returns:

String:

an array of string which represents subway station color to be paint

getStationOnIntersectedLine

(
  • lineId
  • station
)
Object private

Defined in script.js:266

Gets a station object on a given line which has shared intersection with a given station

Parameters:

  • lineId Number

    subway line ID

  • station Object

    subway station

Returns:

Object:

a subway station

getStationRadius

() Number private

Defined in script.js:44

Calculates subway station relative radiues

Returns:

Number:

radius of the subway station

getStationsBetween

(
  • from
  • to
)
Object private

Defined in script.js:483

Gets an array of subway stations between station of origin and station of destination on the same subway line

Parameters:

  • from Object

    station of origin

  • to Object

    station of destination

Returns:

Object:

an array of subway stations

getStationsByIntersectionId

(
  • intersection_id
)
Object private

Defined in script.js:148

Calculates an array of subway stations with a passed intersection ID

Parameters:

  • intersection_id Number

    intersection ID

Returns:

Object:

an array of subway stations

getStationsByLineId

(
  • id
)
Object private

Defined in script.js:298

Gets an array of subway stations by subway line ID

Parameters:

  • id Number

    subway line ID

Returns:

Object:

an array of subway stations

getStationsToLine

(
  • stationfrom
  • lineTo
)
Object private

Defined in script.js:76

Calculates an array of station between station of origin to closest intersection with passed subway line

Parameters:

  • stationfrom Object

    station of origin

  • lineTo Number

    subway line id

Returns:

Object:

an array of stations

render

()

Defined in script.js:821

Renders canvas

roundRect

(
  • ctx
  • x
  • y
  • width
  • height
  • radius
  • fill
  • stroke
)

Defined in script.js:711

Draws rounded rectangle on a canvas

Parameters:

  • ctx Object

    a canvas context

  • x Number

    coordinate

  • y Number

    coordinate

  • width Number
  • height Number
  • radius Number
  • fill Boolean
  • stroke Boolean

setRoute

(
  • StationIdfrom
  • StationIdto
)
Object

Defined in script.js:562

Calculates most optimal route between two given stations

Parameters:

  • StationIdfrom Number

    ID of the station of origin

  • StationIdto Number

    ID of the station of destination

Returns:

Object:

an array of stations

testMap

()

Defined in script.js:531

A method to test the subway map

Properties

route

Unknown

Defined in script.js:22

Array of subway stations, represents a route

subwayLines

Unknown

Defined in script.js:28

Array of subway lines

that

Unknown

Defined in script.js:17