Skip to content

Commit

Permalink
Add color attribute to Route for shuttle maps
Browse files Browse the repository at this point in the history
This will enable the Shuttles tab to draw the rail lines in the correct
colors. The existing line maps use a set of hard-coded colors, which is
why we'd never loaded this attribute from the API before.
  • Loading branch information
digitalcora committed Nov 26, 2019
1 parent b4866e6 commit c4fac9e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 42 deletions.
1 change: 1 addition & 0 deletions apps/routes/lib/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ defmodule Routes.Parser do
type: attributes["type"],
name: name(attributes),
long_name: attributes["long_name"],
color: attributes["color"],
direction_names: direction_bound_attrs(attributes["direction_names"]),
direction_destinations: direction_attrs(attributes["direction_destinations"]),
description: parse_gtfs_desc(attributes["description"])
Expand Down
4 changes: 4 additions & 0 deletions apps/routes/lib/route.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ defmodule Routes.Route do
type: 0,
name: "",
long_name: "",
color: "",
direction_names: %{0 => "Outbound", 1 => "Inbound"},
direction_destinations: :unknown,
description: :unknown,
Expand All @@ -16,6 +17,7 @@ defmodule Routes.Route do
type: 0..4,
name: String.t(),
long_name: String.t(),
color: String.t(),
direction_names: %{0 => String.t(), 1 => String.t()},
direction_destinations: %{0 => String.t(), 1 => String.t()} | :unknown,
description: gtfs_route_desc,
Expand Down Expand Up @@ -202,6 +204,7 @@ defmodule Routes.Route do
type: type,
name: name,
long_name: long_name,
color: color,
direction_names: direction_names,
direction_destinations: direction_destinations,
description: description,
Expand All @@ -220,6 +223,7 @@ defmodule Routes.Route do
type: type,
name: name,
long_name: long_name,
color: color,
direction_names: %{
"0" => direction_names[0],
"1" => direction_names[1]
Expand Down
4 changes: 4 additions & 0 deletions apps/routes/test/repo_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ defmodule Routes.RepoTest do
type: 1,
name: "Red Line",
long_name: "Red Line",
color: "DA291C",
direction_names: %{0 => "Southbound", 1 => "Northbound"},
direction_destinations: %{0 => "Ashmont/Braintree", 1 => "Alewife"},
description: :rapid_transit
Expand All @@ -29,6 +30,7 @@ defmodule Routes.RepoTest do
type: 0,
name: "Green Line B",
long_name: "Green Line B",
color: "00843D",
direction_names: %{0 => "Westbound", 1 => "Eastbound"},
direction_destinations: %{0 => "Boston College", 1 => "Park Street"},
description: :rapid_transit
Expand All @@ -45,6 +47,7 @@ defmodule Routes.RepoTest do
type: 3,
name: "SL1",
long_name: "Logan Airport - South Station",
color: "7C878E",
direction_destinations: %{0 => "Logan Airport", 1 => "South Station"},
description: :key_bus_route
}
Expand All @@ -60,6 +63,7 @@ defmodule Routes.RepoTest do
type: 3,
name: "23",
long_name: "Ashmont - Ruggles via Washington Street",
color: "FFC72C",
direction_destinations: %{0 => "Ashmont", 1 => "Ruggles"},
description: :key_bus_route
}
Expand Down
6 changes: 4 additions & 2 deletions apps/routes/test/route_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ defmodule Routes.RouteTest do
id: "Red",
long_name: "Red Line",
name: "Red Line",
type: 1
type: 1,
color: "DA291C"
}

expected = %{
Expand All @@ -207,7 +208,8 @@ defmodule Routes.RouteTest do
id: "Red",
long_name: "Red Line",
name: "Red Line",
type: 1
type: 1,
color: "DA291C"
}

assert Route.to_json_safe(route) == expected
Expand Down
6 changes: 4 additions & 2 deletions apps/site/test/site/realtime_schedule_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ defmodule Site.RealtimeScheduleTest do
id: "Orange",
long_name: "Orange Line",
name: "Orange Line",
type: 1
type: 1,
color: "ED8B00"
}

@route_with_patterns [
Expand Down Expand Up @@ -251,7 +252,8 @@ defmodule Site.RealtimeScheduleTest do
id: "Orange",
long_name: "Orange Line",
name: "Orange Line",
type: 1
type: 1,
color: "ED8B00"
}
}
]
Expand Down
39 changes: 1 addition & 38 deletions apps/site/test/site_web/controllers/helpers_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -360,43 +360,6 @@ defmodule SiteWeb.ControllerHelpersTest do
end

test "green_routes/0" do
assert green_routes() == [
%Routes.Route{
description: :rapid_transit,
direction_names: %{0 => "Westbound", 1 => "Eastbound"},
direction_destinations: %{0 => "Boston College", 1 => "Park Street"},
id: "Green-B",
long_name: "Green Line B",
name: "Green Line B",
type: 0
},
%Routes.Route{
description: :rapid_transit,
direction_names: %{0 => "Westbound", 1 => "Eastbound"},
direction_destinations: %{0 => "Cleveland Circle", 1 => "North Station"},
id: "Green-C",
long_name: "Green Line C",
name: "Green Line C",
type: 0
},
%Routes.Route{
description: :rapid_transit,
direction_names: %{0 => "Westbound", 1 => "Eastbound"},
direction_destinations: %{0 => "Riverside", 1 => "Government Center"},
id: "Green-D",
long_name: "Green Line D",
name: "Green Line D",
type: 0
},
%Routes.Route{
description: :rapid_transit,
direction_names: %{0 => "Westbound", 1 => "Eastbound"},
direction_destinations: %{0 => "Heath Street", 1 => "Lechmere"},
id: "Green-E",
long_name: "Green Line E",
name: "Green Line E",
type: 0
}
]
assert Enum.map(green_routes(), & &1.id) == ["Green-B", "Green-C", "Green-D", "Green-E"]
end
end

0 comments on commit c4fac9e

Please sign in to comment.