Skip to content

Commit

Permalink
Update API examples for MIT-CAVE/cave_static#507
Browse files Browse the repository at this point in the history
  • Loading branch information
luisvasq committed Dec 3, 2024
1 parent 3bd6f9d commit aff703c
Show file tree
Hide file tree
Showing 11 changed files with 342 additions and 281 deletions.
39 changes: 33 additions & 6 deletions cave_api/cave_api/examples/data_external_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,9 @@ def execute_command(session_data, socket, command="init", **kwargs):
"data": {
"state": {
"value": True,
"icon": "bs/BsHexagon",
"colorBy": "populationDensity",
"colorByOptions": {
"populationDensity": {
"startGradientColor": "rgba(255, 0, 0, 255)",
"endGradientColor": "rgba(0, 255, 0, 255)",
},
},
"colorByOptions": ["populationDensity"],
},
},
},
Expand Down Expand Up @@ -167,6 +163,37 @@ def execute_command(session_data, socket, command="init", **kwargs):
"name": "Population Density",
"type": "num",
"help": "The state's population density in people per square mile",
"colorGradient": {
"scale": "log",
"scaleParams": {"base": 10},
"data": [
{
"value": "min",
"color": "rgb(200, 230, 255)",
"label": "Very Sparse",
},
{
"value": 10,
"color": "rgb(120, 180, 240)",
"label": "Sparse",
},
{
"value": 100,
"color": "rgb(50, 130, 220)",
"label": "Moderate",
},
{
"value": 1000,
"color": "rgb(255, 140, 0)",
"label": "Dense",
},
{
"value": "max",
"color": "rgb(255, 0, 0)",
"label": "Very Dense",
},
],
},
"unit": "People per Square Mile",
},
},
Expand Down
1 change: 1 addition & 0 deletions cave_api/cave_api/examples/kitchen_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -1741,6 +1741,7 @@ def execute_command(session_data, socket, command="init", **kwargs):
{
"value": "max",
"color": "rgb(255, 0, 0)",
"label": "Very Dense",
},
],
},
Expand Down
225 changes: 118 additions & 107 deletions cave_api/cave_api/examples/map_feature_all_3D.py

Large diffs are not rendered by default.

50 changes: 26 additions & 24 deletions cave_api/cave_api/examples/map_feature_arcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,10 @@ def execute_command(session_data, socket, command="init", **kwargs):
"data": {
"truckRoutes": {
"value": True,
"sizeBy": "capacity",
"colorBy": "preferredRoute",
"colorByOptions": {
"capacity": {
"min": 0,
"max": 105,
"startGradientColor": "rgba(233, 0, 0, 1)",
"endGradientColor": "rgba(96, 2, 2, 1)",
},
"preferredRoute": {
"false": "rgba(255, 0, 0, 1)",
"true": "rgba(0, 255, 0, 1)",
},
},
"sizeByOptions": {
"capacity": {
"min": 0,
"max": 80,
"startSize": "5px",
"endSize": "10px",
},
},
"colorByOptions": ["capacity", "preferredRoute"],
"sizeBy": "capacity",
"sizeByOptions": ["capacity"],
},
},
},
Expand All @@ -87,15 +69,35 @@ def execute_command(session_data, socket, command="init", **kwargs):
"capacity": {
"name": "Capacity",
"type": "num",
"help": "The warehouse capacity in cubic feet",
"min": 0,
"max": 105,
"unit": "Cubic Feet",
"legendNotation": "precision",
"legendPrecision": 0,
"help": "The warehouse capacity in cubic feet",
"colorGradient": {
"notation": "precision",
"precision": 0,
"data": [
{"value": "min", "color": "rgb(233 0 0)"},
{"value": "max", "color": "rgb(96 2 2)"},
],
},
"sizeGradient": {
"notation": "precision",
"precision": 0,
"data": [
{"value": "min", "size": "5px"},
{"value": "max", "size": "10px"},
],
},
},
"preferredRoute": {
"name": "Preferred Route",
"type": "toggle",
"help": "Whether the route is preferred",
"options": {
"false": {"color": "rgb(255 0 0)"},
"true": {"color": "rgb(0 255 0)"},
},
},
},
"data": {
Expand Down
50 changes: 26 additions & 24 deletions cave_api/cave_api/examples/map_feature_arcs_geojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,10 @@ def execute_command(session_data, socket, command="init", **kwargs):
"data": {
"specialRoutes": {
"value": True,
"sizeBy": "capacity",
"colorBy": "preferredRoute",
"colorByOptions": {
"capacity": {
"min": 0,
"max": 105,
"startGradientColor": "rgba(233, 0, 0, 1)",
"endGradientColor": "rgba(96, 2, 2, 1)",
},
"preferredRoute": {
"false": "rgba(255, 0, 0, 1)",
"true": "rgba(0, 255, 0, 1)",
},
},
"sizeByOptions": {
"capacity": {
"min": 0,
"max": 80,
"startSize": "5px",
"endSize": "10px",
},
},
"colorByOptions": ["capacity", "preferredRoute"],
"sizeBy": "capacity",
"sizeByOptions": ["capacity"],
},
},
},
Expand All @@ -97,15 +79,35 @@ def execute_command(session_data, socket, command="init", **kwargs):
"capacity": {
"name": "Capacity",
"type": "num",
"help": "The warehouse capacity in cubic feet",
"min": 0,
"max": 105,
"unit": "Cubic Feet",
"legendNotation": "precision",
"legendPrecision": 0,
"help": "The warehouse capacity in cubic feet",
"colorGradient": {
"notation": "precision",
"precision": 0,
"data": [
{"value": "min", "color": "rgb(233 0 0)"},
{"value": "max", "color": "rgb(96 2 2)"},
],
},
"sizeGradient": {
"notation": "precision",
"precision": 0,
"data": [
{"value": "min", "size": "5px"},
{"value": "max", "size": "10px"},
],
},
},
"preferredRoute": {
"name": "Preferred Route",
"type": "toggle",
"help": "Whether the route is preferred",
"options": {
"false": {"color": "rgb(255 0 0)"},
"true": {"color": "rgb(0 255 0)"},
},
},
},
"data": {
Expand Down
50 changes: 26 additions & 24 deletions cave_api/cave_api/examples/map_feature_arcs_multisegment.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,10 @@ def execute_command(session_data, socket, command="init", **kwargs):
"data": {
"unusualRoutes": {
"value": True,
"sizeBy": "capacity",
"colorBy": "preferredRoute",
"colorByOptions": {
"capacity": {
"min": 0,
"max": 105,
"startGradientColor": "rgba(233, 0, 0, 1)",
"endGradientColor": "rgba(96, 2, 2, 1)",
},
"preferredRoute": {
"false": "rgba(255, 0, 0, 1)",
"true": "rgba(0, 255, 0, 1)",
},
},
"sizeByOptions": {
"capacity": {
"min": 0,
"max": 80,
"startSize": "5px",
"endSize": "10px",
},
},
"colorByOptions": ["capacity", "preferredRoute"],
"sizeBy": "capacity",
"sizeByOptions": ["capacity"],
},
},
},
Expand All @@ -87,15 +69,35 @@ def execute_command(session_data, socket, command="init", **kwargs):
"capacity": {
"name": "Capacity",
"type": "num",
"help": "The warehouse capacity in cubic feet",
"min": 0,
"max": 105,
"unit": "Cubic Feet",
"legendNotation": "precision",
"legendPrecision": 0,
"help": "The warehouse capacity in cubic feet",
"colorGradient": {
"notation": "precision",
"precision": 0,
"data": [
{"value": "min", "color": "rgb(233 0 0)"},
{"value": "max", "color": "rgb(96 2 2)"},
],
},
"sizeGradient": {
"notation": "precision",
"precision": 0,
"data": [
{"value": "min", "size": "5px"},
{"value": "max", "size": "10px"},
],
},
},
"preferredRoute": {
"name": "Preferred Route",
"type": "toggle",
"help": "Whether the route is preferred",
"options": {
"false": {"color": "rgb(255 0 0)"},
"true": {"color": "rgb(0 255 0)"},
},
},
},
"data": {
Expand Down
29 changes: 15 additions & 14 deletions cave_api/cave_api/examples/map_feature_geos.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,9 @@ def execute_command(session_data, socket, command="init", **kwargs):
"data": {
"custom": {
"value": True,
"colorBy": "booleanPropExample",
"colorByOptions": {
"numericPropExampleC": {
"min": 0,
"max": 100,
"startGradientColor": "rgba(233, 0, 0, 1)",
"endGradientColor": "rgba(96, 2, 2, 1)",
},
"booleanPropExample": {
"false": "rgba(255, 0, 0, 1)",
"true": "rgba(0, 255, 0, 1)",
},
},
"icon": "bs/BsHexagon",
"colorBy": "booleanPropExample",
"colorByOptions": ["numericPropExampleC", "booleanPropExample"],
},
},
},
Expand All @@ -79,13 +68,25 @@ def execute_command(session_data, socket, command="init", **kwargs):
"numericPropExampleC": {
"name": "Numeric Prop Example C",
"type": "num",
"help": "Help with the example numeric prop for this Custom",
"min": 0,
"max": 100,
"unit": "units",
"help": "Help with the example numeric prop for this Custom",
"colorGradient": {
"data": [
{"value": "min", "color": "rgb(233 0 0)"},
{"value": "max", "color": "rgb(96 2 2)"},
],
},
},
"booleanPropExample": {
"name": "Boolean Prop Example",
"type": "toggle",
"help": "Help for boolean prop",
"options": {
"false": {"color": "rgb(255 0 0)"},
"true": {"color": "rgb(0 255 0)"},
},
},
},
"data": {
Expand Down
Loading

0 comments on commit aff703c

Please sign in to comment.