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
Changes from 1 commit
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
Next Next commit
Unified base mode colors and helper function
louisg1337 committed Jul 9, 2024
commit a9d83509da8403df891a1ff5f568ad3e5fa151e1
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.

7 changes: 4 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 @@
modeColors = {
louisg1337 marked this conversation as resolved.
Show resolved Hide resolved
"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
}

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

def getBaseModeByKey(motionName):
louisg1337 marked this conversation as resolved.
Show resolved Hide resolved
key = ('' + motionName).toUpperCase()
pop = key.split('.').pop() # if "MotionTypes.WALKING", then just take "WALKING"
return (pop and BaseModes[pop]) or BaseModes["UNKNOWN"]
louisg1337 marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions src/index.py
Original file line number Diff line number Diff line change
@@ -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

def dict_to_js_obj(py_dict):
"""