Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unified base mode colors and helper function #1

Merged
merged 3 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions emcommon_js/emcommon.diary.base_mode_colors.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions emcommon_js/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions src/emcommon/diary/base_mode_colors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
mode_colors = {
"pink": '#c32e85', # oklch(56% 0.2 350) # e-car
"red": '#c21725', # oklch(52% 0.2 25) # car
"orange": '#bf5900', # oklch(58% 0.16 50) # air, hsr
"green": '#008148', # oklch(53% 0.14 155) # bike, e-bike, moped
"blue": '#0074b7', # oklch(54% 0.14 245) # walk
"periwinkle": '#6356bf', # oklch(52% 0.16 285) # light rail, train, tram, subway
"magenta": '#9240a4', # oklch(52% 0.17 320) # bus
"grey": '#555555', # oklch(45% 0 0) # unprocessed / unknown
"taupe": '#7d585a', # oklch(50% 0.05 15) # ferry, trolleybus, user-defined modes
}

BASE_MODES = {
# BEGIN MotionTypes
"IN_VEHICLE": { "name": 'IN_VEHICLE', "icon": 'speedometer', "color": mode_colors["red"] },
"BICYCLING": { "name": 'BICYCLING', "icon": 'bike', "color": mode_colors["green"] },
"ON_FOOT": { "name": 'ON_FOOT', "icon": 'walk', "color": mode_colors["blue"] },
"UNKNOWN": { "name": 'UNKNOWN', "icon": 'help', "color": mode_colors["grey"] },
"WALKING": { "name": 'WALKING', "icon": 'walk', "color": mode_colors["blue"] },
"AIR_OR_HSR": { "name": 'AIR_OR_HSR', "icon": 'airplane', "color": mode_colors["orange"] },
# END MotionTypes
"CAR": { "name": 'CAR', "icon": 'car', "color": mode_colors["red"] },
"E_CAR": { "name": 'E_CAR', "icon": 'car-electric', "color": mode_colors["pink"] },
"E_BIKE": { "name": 'E_BIKE', "icon": 'bicycle-electric', "color": mode_colors["green"] },
"E_SCOOTER": { "name": 'E_SCOOTER', "icon": 'scooter-electric', "color": mode_colors["periwinkle"] },
"MOPED": { "name": 'MOPED', "icon": 'moped', "color": mode_colors["green"] },
"TAXI": { "name": 'TAXI', "icon": 'taxi', "color": mode_colors["red"] },
"BUS": { "name": 'BUS', "icon": 'bus-side', "color": mode_colors["magenta"] },
"AIR": { "name": 'AIR', "icon": 'airplane', "color": mode_colors["orange"] },
"LIGHT_RAIL": { "name": 'LIGHT_RAIL', "icon": 'train-car-passenger', "color": mode_colors["periwinkle"] },
"TRAIN": { "name": 'TRAIN', "icon": 'train-car-passenger', "color": mode_colors["periwinkle"] },
"TRAM": { "name": 'TRAM', "icon": 'fas fa-tram', "color": mode_colors["periwinkle"] },
"SUBWAY": { "name": 'SUBWAY', "icon": 'subway-variant', "color": mode_colors["periwinkle"] },
"FERRY": { "name": 'FERRY', "icon": 'ferry', "color": mode_colors["taupe"] },
"TROLLEYBUS": { "name": 'TROLLEYBUS', "icon": 'bus-side', "color": mode_colors["taupe"] },
"UNPROCESSED": { "name": 'UNPROCESSED', "icon": 'help', "color": mode_colors["grey"] },
"OTHER": { "name": 'OTHER', "icon": 'pencil-circle', "color": mode_colors["taupe"] },
};

def get_base_mode_by_key(motionName):
key = ('' + motionName).upper()
pop = key.split('.').pop() # if "MotionTypes.WALKING", then just take "WALKING"
return BASE_MODES.get(pop, BASE_MODES["UNKNOWN"])
1 change: 1 addition & 0 deletions src/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import emcommon.metrics.active_travel.active_travel_calculations as active_travel_calculations
import emcommon.survey.conditional_surveys as conditional_surveys
import emcommon.bluetooth.ble_matching as ble_matching
import emcommon.diary.base_mode_colors as base_mode_colors
import emcommon.metrics.footprint_calculations as footprint_calculations

def dict_to_js_obj(py_dict):
Expand Down