Skip to content

Commit

Permalink
Update API example for MIT-CAVE/cave_static#507
Browse files Browse the repository at this point in the history
  • Loading branch information
luisvasq committed Nov 22, 2024
1 parent 6bf2b5d commit 6bd8b77
Showing 1 changed file with 154 additions and 76 deletions.
230 changes: 154 additions & 76 deletions cave_api/cave_api/examples/kitchen_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,8 +895,8 @@ def execute_command(session_data, socket, command="init", **kwargs):
"longitude": 14,
},
},
"legendView": "full",
"showLegendGroupNames": False,
"legendView": "minimal",
"showLegendGroupNames": True,
"legendGroups": {
"lga": {
"name": "Legend Group A",
Expand All @@ -912,46 +912,15 @@ def execute_command(session_data, socket, command="init", **kwargs):
# "groupScaleWithZoom": True,
# "groupScale": 10,
"icon": "fa6/FaIgloo",
# NOTE: Example of overriding prop attributes in the legend
"props": {
"numericPropExampleA": {
"startGradientColor": "rgba(33, 200, 100, 1)",
"endGradientColor": "rgba(196, 220, 112, 1)",
"startSize": "40px",
"endSize": "60px",
# REVIEW: Preferred key name -> `default` or `fallback`?
# This would replace `nullColor` and `nullSize` and add the option of including a `name`
"default": {"name": "Undefined", "color": "rgba(128, 128, 128, 1)", "size": "20px"},
# REVIEW: Option to use separate names for color and size
# "default": {
# "color": {"name": "No Color", "color": "rgba(128, 128, 128, 1)"},
# "size": {"name": "No Size", "size": "20px"},
# }
},
"booleanPropExample": {
"options":{
"false": {"name": "Idle", "color": "rgba(255, 0, 0, 1)", "size": "15px"},
"true": {"name": "Active", "color": "rgba(0, 255, 0, 1)", "size": "30px"},
},
# REVIEW: Preferred key name -> `default` or `fallback`?
# This would replace `nullColor` and `nullSize` and add the option of including a `name`
"default": {"name": "Unknown", "color": "rgba(128, 128, 128, 1)", "size": "20px"},
# REVIEW: Option to use separate names for color and size
# "default": {
# "color": {"name": "No Color", "color": "rgba(128, 128, 128, 1)"},
# "size": {"name": "No Size", "size": "20px"},
# }
}
},
# REVIEW:
# Current implemented behavior on `cave_static`: `colorBy` and `sizeBy` dropdowns are populated with props
# that have at least one gradient/color or size range/option value after left-merging
# Current implemented behavior on `cave_static`: the `colorBy` and `sizeBy` dropdowns are populated
# with props that have at least one gradient/color or size range/option value after left-merging
# `legendGroups.lga.data.nodeTypeA.props` with `mapFeatures.data.nodeTypeA.props`.

# REVIEW: The following is not implemented yet:
# I think we could define a list of prop keys to specify which props should appear in the dropdowns by
# using `colorByOptions` and `sizeByOptions`. Note that `colorByOptions` and `sizeByOptions` would be
# different from the old structure and will only point to the keys.
#
# Alternatively (not implemented yet):
# We could define a list of prop keys to specify which props should appear in the dropdowns by
# using `colorByOptions` and `sizeByOptions`. Note that `colorByOptions` and `sizeByOptions` would
# be different from the old structure and will only point to the keys.
"colorByOptions": [],
"sizeByOptions": [],
},
Expand Down Expand Up @@ -1137,14 +1106,46 @@ def execute_command(session_data, socket, command="init", **kwargs):
"type": "selector",
"variant": "dropdown",
"options": {
"a": {"name": "A", "color": "rgba(128, 255, 255, 1)", "size": "3px"},
"b": {"name": "B", "color": "rgba(0, 153, 51, 1)", "size": "8px"},
"c": {"name": "C", "color": "rgba(0, 0, 128, 1)", "size": "13px"},
"d": {"name": "D", "color": "rgba(204, 0, 0, 1)", "size": "18px"},
"e": {"name": "E", "color": "rgba(153, 77, 0, 1)", "size": "23px"},
"f": {"name": "F", "color": "rgba(255, 25, 255, 1)", "size": "28px"},
"g": {"name": "G", "color": "rgba(0, 255, 0, 1)", "size": "33px"},
"h": {"name": "H", "color": "rgba(255, 255, 0, 1)", "size": "38px"},
"a": {
"name": "A",
"color": "rgba(128, 255, 255, 1)",
"size": "3px",
},
"b": {
"name": "B",
"color": "rgba(0, 153, 51, 1)",
"size": "8px",
},
"c": {
"name": "C",
"color": "rgba(0, 0, 128, 1)",
"size": "13px",
},
"d": {
"name": "D",
"color": "rgba(204, 0, 0, 1)",
"size": "18px",
},
"e": {
"name": "E",
"color": "rgba(153, 77, 0, 1)",
"size": "23px",
},
"f": {
"name": "F",
"color": "rgba(255, 25, 255, 1)",
"size": "28px",
},
"g": {
"name": "G",
"color": "rgba(0, 255, 0, 1)",
"size": "33px",
},
"h": {
"name": "H",
"color": "rgba(255, 255, 0, 1)",
"size": "38px",
},
},
},
},
Expand Down Expand Up @@ -1214,14 +1215,46 @@ def execute_command(session_data, socket, command="init", **kwargs):
"type": "selector",
"variant": "dropdown",
"options": {
"a": {"name": "A", "color": "rgba(128, 255, 255, 1)", "size": "3px"},
"b": {"name": "B", "color": "rgba(0, 153, 51, 1)", "size": "8px"},
"c": {"name": "C", "color": "rgba(0, 0, 128, 1)", "size": "13px"},
"d": {"name": "D", "color": "rgba(204, 0, 0, 1)", "size": "18px"},
"e": {"name": "E", "color": "rgba(153, 77, 0, 1)", "size": "23px"},
"f": {"name": "F", "color": "rgba(255, 25, 255, 1)", "size": "28px"},
"g": {"name": "G", "color": "rgba(0, 255, 0, 1)", "size": "33px"},
"h": {"name": "H", "color": "rgba(255, 255, 0, 1)", "size": "38px"},
"a": {
"name": "A",
"color": "rgba(128, 255, 255, 1)",
"size": "3px",
},
"b": {
"name": "B",
"color": "rgba(0, 153, 51, 1)",
"size": "8px",
},
"c": {
"name": "C",
"color": "rgba(0, 0, 128, 1)",
"size": "13px",
},
"d": {
"name": "D",
"color": "rgba(204, 0, 0, 1)",
"size": "18px",
},
"e": {
"name": "E",
"color": "rgba(153, 77, 0, 1)",
"size": "23px",
},
"f": {
"name": "F",
"color": "rgba(255, 25, 255, 1)",
"size": "28px",
},
"g": {
"name": "G",
"color": "rgba(0, 255, 0, 1)",
"size": "33px",
},
"h": {
"name": "H",
"color": "rgba(255, 255, 0, 1)",
"size": "38px",
},
},
},
},
Expand Down Expand Up @@ -1281,6 +1314,11 @@ def execute_command(session_data, socket, command="init", **kwargs):
"endGradientColor": "rgba(96, 2, 2, 1)",
"startSize": "30px",
"endSize": "45px",
"fallback": {
"name": "Undefined",
"color": "rgba(128, 128, 128, 1)",
"size": "20px",
},
"help": "Help for numeric prop example A",
},
"numericPropExampleB": {
Expand All @@ -1300,10 +1338,22 @@ def execute_command(session_data, socket, command="init", **kwargs):
"booleanPropExample": {
"name": "Boolean Prop Example",
"type": "toggle",
# REVIEW: Reusing the `options` structure from selector props for consistency, as the data types are similar in nature
"options":{
"false": {"name": "False", "color": "rgba(255, 0, 0, 1)", "size": "15px"},
"true": {"name": "True", "color": "rgba(0, 255, 0, 1)", "size": "30px"},
"options": {
"false": {
"name": "Idle",
"color": "rgba(255, 0, 0, 1)",
"size": "15px",
},
"true": {
"name": "Active",
"color": "rgba(0, 255, 0, 1)",
"size": "30px",
},
},
"fallback": {
"name": "Unknown",
"color": "rgba(128, 128, 128, 1)",
"size": "100px",
},
"help": "Help for boolean prop",
},
Expand All @@ -1312,14 +1362,46 @@ def execute_command(session_data, socket, command="init", **kwargs):
"type": "selector",
"variant": "dropdown",
"options": {
"a": {"name": "A", "color": "rgba(128, 255, 255, 1)", "size": "3px"},
"b": {"name": "B", "color": "rgba(0, 153, 51, 1)", "size": "8px"},
"c": {"name": "C", "color": "rgba(0, 0, 128, 1)", "size": "13px"},
"d": {"name": "D", "color": "rgba(204, 0, 0, 1)", "size": "18px"},
"e": {"name": "E", "color": "rgba(153, 77, 0, 1)", "size": "23px"},
"f": {"name": "F", "color": "rgba(255, 25, 255, 1)", "size": "28px"},
"g": {"name": "G", "color": "rgba(0, 255, 0, 1)", "size": "33px"},
"h": {"name": "H", "color": "rgba(255, 255, 0, 1)", "size": "38px"},
"a": {
"name": "A",
"color": "rgba(128, 255, 255, 1)",
"size": "3px",
},
"b": {
"name": "B",
"color": "rgba(0, 153, 51, 1)",
"size": "8px",
},
"c": {
"name": "C",
"color": "rgba(0, 0, 128, 1)",
"size": "13px",
},
"d": {
"name": "D",
"color": "rgba(204, 0, 0, 1)",
"size": "18px",
},
"e": {
"name": "E",
"color": "rgba(153, 77, 0, 1)",
"size": "23px",
},
"f": {
"name": "F",
"color": "rgba(255, 25, 255, 1)",
"size": "28px",
},
"g": {
"name": "G",
"color": "rgba(0, 255, 0, 1)",
"size": "33px",
},
"h": {
"name": "H",
"color": "rgba(255, 255, 0, 1)",
"size": "38px",
},
},
},
},
Expand Down Expand Up @@ -1362,8 +1444,6 @@ def execute_command(session_data, socket, command="init", **kwargs):
"unit": "A units",
"startGradientColor": "rgba(233, 0, 0, 1)",
"endGradientColor": "rgba(96, 2, 2, 1)",
# REVIEW: This approach removes the ability to set different min and max values for color and size.
# In the previous "map2" example, "min" was set to 0 and "max" to 250 specifically for the size range.
"startSize": "15px",
"endSize": "30px",
"help": "Help for numeric prop example A",
Expand All @@ -1378,16 +1458,14 @@ def execute_command(session_data, socket, command="init", **kwargs):
"legendMaxLabel": "Hi",
"startGradientColor": "rgba(233, 0, 0, 1)",
"endGradientColor": "rgba(96, 2, 2, 1)",
# REVIEW: This approach removes the ability to set different min and max values for color and size.
# In the previous "map2" example, "min" was set to 0 and "max" to 40 specifically for the size range.
"startSize": "5px",
"endSize": "15px",
"help": "Help for numeric prop example B",
},
"booleanPropExample": {
"name": "Boolean Prop Example",
"type": "toggle",
"options":{
"options": {
"false": {"color": "rgba(233, 0, 0, 1)"},
"true": {"color": "rgba(0, 233, 0, 1)"},
},
Expand Down Expand Up @@ -1427,11 +1505,11 @@ def execute_command(session_data, socket, command="init", **kwargs):
"booleanPropExample": {
"name": "Boolean Prop Example",
"type": "toggle",
"options":{
"options": {
"false": {"color": "rgba(233, 0, 0, 1)"},
"true": {"color": "rgba(0, 233, 0, 1)"},
},
"help": "Help for boolean prop",
"help": "Help for boolean prop",
},
},
"data": {
Expand Down Expand Up @@ -1495,7 +1573,7 @@ def execute_command(session_data, socket, command="init", **kwargs):
"booleanPropExample": {
"name": "Boolean Prop Example",
"type": "toggle",
"options":{
"options": {
"false": {"color": "rgba(233, 0, 0, 1)"},
"true": {"color": "rgba(0, 233, 0, 1)"},
},
Expand Down

0 comments on commit 6bd8b77

Please sign in to comment.