bridges 3.4.4__tar.gz → 3.4.5.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bridges-3.4.4/bridges.egg-info → bridges-3.4.5.dev1}/PKG-INFO +1 -1
- bridges-3.4.5.dev1/bridges/bar_chart.py +214 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/bridges.py +35 -24
- bridges-3.4.5.dev1/bridges/data_src_dependent/county.py +77 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/data_src_dependent/data_source.py +70 -6
- bridges-3.4.5.dev1/bridges/data_src_dependent/state.py +61 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1/bridges.egg-info}/PKG-INFO +1 -1
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges.egg-info/SOURCES.txt +3 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/setup.py +1 -1
- {bridges-3.4.4 → bridges-3.4.5.dev1}/LICENSE +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/MANIFEST.in +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/README.md +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/__init__.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/array.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/array1d.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/array2d.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/array3d.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/audio_channel.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/audio_clip.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/avl_tree_element.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/bfs_benchmark.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/bin_tree_element.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/blocking_game.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/bst_element.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/camera.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/circ_dl_element.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/circ_sl_element.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/circle.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/color.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/color_grid.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/connector.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/data_src_dependent/__init__.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/data_src_dependent/actor_movie_imdb.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/data_src_dependent/amenity.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/data_src_dependent/cancer_incidence.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/data_src_dependent/city.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/data_src_dependent/earthquake_usgs.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/data_src_dependent/elevation.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/data_src_dependent/game.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/data_src_dependent/gutenberg_book.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/data_src_dependent/gutenberg_meta.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/data_src_dependent/lru_cache.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/data_src_dependent/movie_actor_wiki_data.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/data_src_dependent/osm.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/data_src_dependent/reddit.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/data_src_dependent/shakespeare.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/data_src_dependent/song.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/data_src_dependent/world_cities.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/dl_element.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/edge.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/element.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/element_visualizer.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/game_cell.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/game_grid.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/gamebase.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/gamebase3D.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/graph_adj_list.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/graph_adj_matrix.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/graph_benchmark.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/grid.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/input_helper.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/input_state_machine.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/kd_tree_element.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/keypress_listener.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/light.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/line_chart.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/link_visualizer.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/mesh.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/ml_element.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/named_color.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/named_symbol.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/non_blocking_game.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/non_blocking_game3D.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/page_rank_benchmark.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/particle_system.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/polygon.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/polyline.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/primitives.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/rectangle.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/scene.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/shortest_path_benchmark.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/sl_element.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/socket_connection.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/sorting_benchmark.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/symbol.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/symbol_collection.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/symbol_group.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/text.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges/tree_element.py +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges.egg-info/dependency_links.txt +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges.egg-info/requires.txt +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/bridges.egg-info/top_level.txt +0 -0
- {bridges-3.4.4 → bridges-3.4.5.dev1}/setup.cfg +0 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class BarChart:
|
|
5
|
+
"""
|
|
6
|
+
@brief Support for drawing Bar charts.
|
|
7
|
+
|
|
8
|
+
Bar charts (https://en.wikipedia.org/wiki/Bar_chart) are used to
|
|
9
|
+
represent categorical data as a series of rectangular bars with length
|
|
10
|
+
proportional to the values they represent.
|
|
11
|
+
|
|
12
|
+
Series in a bar chart provides data for a number of categories
|
|
13
|
+
(sometimes called bins). Categories are defined using
|
|
14
|
+
BarChart.categories and the series are added using BarChart.add_data_series().
|
|
15
|
+
The series are rendered in the order in which they were added. Once
|
|
16
|
+
a series has been added, it can not be modified.
|
|
17
|
+
|
|
18
|
+
One should always define the categories before adding data. Changing the
|
|
19
|
+
categories after series have been added will throw exceptions;
|
|
20
|
+
adding series with different number of values than the number of
|
|
21
|
+
categories will throw an exception.
|
|
22
|
+
|
|
23
|
+
The Bar charts can have a title, subtitle. The charts can be
|
|
24
|
+
horizontal or vertically oriented, using BarChart.orientation.
|
|
25
|
+
|
|
26
|
+
A tooltip indicating the value of a series in a particular bin is
|
|
27
|
+
displayed by hovering on a bar. One can append a string to the
|
|
28
|
+
value using barchart.tooltip_suffix to specify units in the tooltip if desired.
|
|
29
|
+
|
|
30
|
+
@sa See tutorial on using BarChart at:
|
|
31
|
+
https://bridgesuncc.github.io/tutorials/BarChart.html
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
# constructor method
|
|
35
|
+
|
|
36
|
+
def __init__(self):
|
|
37
|
+
self._c_label = ""
|
|
38
|
+
self._v_label = ""
|
|
39
|
+
self._title = ""
|
|
40
|
+
self._sub_title = ""
|
|
41
|
+
self._tt_suffix = ""
|
|
42
|
+
self._orientation = "horizontal"
|
|
43
|
+
self._series_data = []
|
|
44
|
+
self._cats = []
|
|
45
|
+
|
|
46
|
+
# simple getters and setters to access attributes
|
|
47
|
+
def get_data_structure_type(self):
|
|
48
|
+
return "BarChart"
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def title(self) -> str:
|
|
53
|
+
"""
|
|
54
|
+
Title of the plot
|
|
55
|
+
"""
|
|
56
|
+
return self._title
|
|
57
|
+
|
|
58
|
+
@title.setter
|
|
59
|
+
def title(self, plot_title: str) -> None:
|
|
60
|
+
"""
|
|
61
|
+
Title of the plot
|
|
62
|
+
"""
|
|
63
|
+
self._title = plot_title
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
def sub_title(self) -> str:
|
|
67
|
+
"""
|
|
68
|
+
Subtitle of the plot
|
|
69
|
+
"""
|
|
70
|
+
return self._sub_title
|
|
71
|
+
|
|
72
|
+
@sub_title.setter
|
|
73
|
+
def sub_title(self, plot_sub_title: str) -> None:
|
|
74
|
+
"""
|
|
75
|
+
Subtitle of the plot
|
|
76
|
+
"""
|
|
77
|
+
self._sub_title = plot_sub_title
|
|
78
|
+
|
|
79
|
+
@property
|
|
80
|
+
def value_label(self) -> str:
|
|
81
|
+
"""
|
|
82
|
+
Label for the value axis
|
|
83
|
+
"""
|
|
84
|
+
return self._v_label
|
|
85
|
+
|
|
86
|
+
@value_label.setter
|
|
87
|
+
def value_label(self, value_label: str) -> None:
|
|
88
|
+
"""
|
|
89
|
+
Label for the value axis
|
|
90
|
+
"""
|
|
91
|
+
self._v_label = value_label
|
|
92
|
+
|
|
93
|
+
@property
|
|
94
|
+
def categories_label(self) -> str:
|
|
95
|
+
"""
|
|
96
|
+
Label for the categories axis
|
|
97
|
+
"""
|
|
98
|
+
return self._c_label
|
|
99
|
+
|
|
100
|
+
@categories_label.setter
|
|
101
|
+
def categories_label(self, c_label: str) -> None:
|
|
102
|
+
"""
|
|
103
|
+
Label for the categories axis
|
|
104
|
+
"""
|
|
105
|
+
self._c_label = c_label
|
|
106
|
+
|
|
107
|
+
@property
|
|
108
|
+
def orientation(self) -> str:
|
|
109
|
+
"""
|
|
110
|
+
Orientation of the bar chart.
|
|
111
|
+
|
|
112
|
+
Will always be either "horizontal" or "vertical"
|
|
113
|
+
"""
|
|
114
|
+
return self._orientation
|
|
115
|
+
|
|
116
|
+
@orientation.setter
|
|
117
|
+
def orientation(self, orient) -> str:
|
|
118
|
+
"""
|
|
119
|
+
Sets orientation of the bar chart.
|
|
120
|
+
|
|
121
|
+
Must be either "horizontal" or "vertical". Will throw an exception otherwise.
|
|
122
|
+
"""
|
|
123
|
+
if orient != "horizontal" and orient != "vertical":
|
|
124
|
+
raise ValueError ("Bar chart orientation must be either \"horizontal\" or \"vertical\"")
|
|
125
|
+
self._orientation = orient
|
|
126
|
+
|
|
127
|
+
@property
|
|
128
|
+
def tooltip_suffix(self) -> str:
|
|
129
|
+
"""
|
|
130
|
+
the tooltip suffix
|
|
131
|
+
|
|
132
|
+
This string is appended to the values in the hover tooltip.
|
|
133
|
+
"""
|
|
134
|
+
return self._tt_suffix
|
|
135
|
+
|
|
136
|
+
@tooltip_suffix.setter
|
|
137
|
+
def tooltip_suffix(self, suffix: str) -> None:
|
|
138
|
+
"""
|
|
139
|
+
the tooltip suffix
|
|
140
|
+
|
|
141
|
+
This string is appended to the values in the hover tooltip.
|
|
142
|
+
"""
|
|
143
|
+
self._tt_suffix = suffix
|
|
144
|
+
|
|
145
|
+
@property
|
|
146
|
+
def categories(self) -> list[str]:
|
|
147
|
+
"""
|
|
148
|
+
Categories for this bar chart
|
|
149
|
+
"""
|
|
150
|
+
return self._cats
|
|
151
|
+
|
|
152
|
+
@categories.setter
|
|
153
|
+
def categories(self, series_bins: list[str]) -> None:
|
|
154
|
+
"""
|
|
155
|
+
Set the categories for the bar chart
|
|
156
|
+
|
|
157
|
+
will throw an exception if there are already data series defined.
|
|
158
|
+
"""
|
|
159
|
+
if len (self._series_data) >0:
|
|
160
|
+
raise RuntimeError("Can't change categoriess after series have been added.")
|
|
161
|
+
self._cats = series_bins
|
|
162
|
+
|
|
163
|
+
def add_data_series(self, name:str, values:list[float]) -> None:
|
|
164
|
+
"""
|
|
165
|
+
Add a series of data
|
|
166
|
+
|
|
167
|
+
This will throw an exception if the data vector does not have the same
|
|
168
|
+
size as the number of categories.
|
|
169
|
+
|
|
170
|
+
This will throw exceptions if two series have the same name.
|
|
171
|
+
|
|
172
|
+
Args:
|
|
173
|
+
name indicates the name of the data to add
|
|
174
|
+
values values of that serie for each category
|
|
175
|
+
"""
|
|
176
|
+
if len(values) != len (self.categories):
|
|
177
|
+
raise ValueError("The data vector should have the same size as the number of categories.")
|
|
178
|
+
|
|
179
|
+
for others in self._series_data:
|
|
180
|
+
if name == others[0]:
|
|
181
|
+
raise ValueError("Can't have two series with the same name.")
|
|
182
|
+
|
|
183
|
+
self._series_data.append ((name, values))
|
|
184
|
+
|
|
185
|
+
#Gets the data structure representation as a JSON string
|
|
186
|
+
#Returns: data structure reprsentation (json string)
|
|
187
|
+
def get_data_structure_representation(self):
|
|
188
|
+
bins = {
|
|
189
|
+
"xAxis": {
|
|
190
|
+
"categories": self.categories
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
series = []
|
|
194
|
+
for key, value in self._series_data:
|
|
195
|
+
temp_dict = {
|
|
196
|
+
"name": key,
|
|
197
|
+
"data": value
|
|
198
|
+
}
|
|
199
|
+
series.append(temp_dict)
|
|
200
|
+
#print(series)
|
|
201
|
+
json_dict = {
|
|
202
|
+
"plot_title": self.title,
|
|
203
|
+
"subtitle": self.subtitle,
|
|
204
|
+
"x_label": self.categories_label,
|
|
205
|
+
"y_label": self.value_label,
|
|
206
|
+
"tooltip_suffix": self.tooltip_suffix,
|
|
207
|
+
"alignment": self.orientation,
|
|
208
|
+
"xaxis_data": { "xAxis": {"categories": self.categories} },
|
|
209
|
+
"yaxis_data": {"series": series}
|
|
210
|
+
}
|
|
211
|
+
json_output = json.dumps(json_dict)
|
|
212
|
+
return json_dict
|
|
213
|
+
|
|
214
|
+
|
|
@@ -100,7 +100,7 @@ class Bridges:
|
|
|
100
100
|
self._link_label_flag = False
|
|
101
101
|
self._post_url_flag = True
|
|
102
102
|
self._map_overlay = False
|
|
103
|
-
self.
|
|
103
|
+
self.map = {}
|
|
104
104
|
self._window = [0.0, 0.0, 0.0, 0.0]
|
|
105
105
|
self.ds_handle = None
|
|
106
106
|
self.vis_type = ""
|
|
@@ -168,6 +168,16 @@ class Bridges:
|
|
|
168
168
|
"""
|
|
169
169
|
self._json_flag = flag
|
|
170
170
|
|
|
171
|
+
def set_map(self, map_info:list):
|
|
172
|
+
"""
|
|
173
|
+
This method serializes all the state and county objects in the map_info for sending to the server
|
|
174
|
+
:param map_info: is a list of state objects with their counties
|
|
175
|
+
:return: none
|
|
176
|
+
"""
|
|
177
|
+
self.map = map_info
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
171
181
|
def post_visualization_link(self, flag:bool):
|
|
172
182
|
"""
|
|
173
183
|
This method controls (with a flag) if the visualization url is printed to the console or not.
|
|
@@ -182,7 +192,7 @@ class Bridges:
|
|
|
182
192
|
Returns:
|
|
183
193
|
None
|
|
184
194
|
"""
|
|
185
|
-
|
|
195
|
+
ds_str = ""
|
|
186
196
|
|
|
187
197
|
if self.vis_type == "Tree" or self.vis_type == "BinaryTree" or self.vis_type == "AVLTree" or\
|
|
188
198
|
self.vis_type == "SinglyLinkedList" or self.vis_type == "DoublyLinkedList" or \
|
|
@@ -190,11 +200,11 @@ class Bridges:
|
|
|
190
200
|
self.vis_type == "CircularDoublyLinkedList" or self.vis_type == "Array" or \
|
|
191
201
|
self.vis_type == "GraphAdjacencyList" or self.vis_type == "ColorGrid" or self.vis_type == "GraphAdjacencyMatrix" or \
|
|
192
202
|
self.vis_type == "largegraph" or self.vis_type == "KdTree" or self.vis_type == "SymbolCollection" or \
|
|
193
|
-
self.vis_type == "GameGrid" or self.vis_type == "BinarySearchTree" or self.vis_type == "LineChart" or \
|
|
203
|
+
self.vis_type == "GameGrid" or self.vis_type == "BinarySearchTree" or self.vis_type == "LineChart" or self.vis_type == "BarChart" or \
|
|
194
204
|
self.vis_type == "Audio" or self.vis_type == "SymbolCollectionV2" or self.vis_type == "Scene":
|
|
195
|
-
|
|
205
|
+
ds_str = self.ds_handle.get_data_structure_representation()
|
|
196
206
|
|
|
197
|
-
|
|
207
|
+
ds_dict = {
|
|
198
208
|
"visual": self.vis_type,
|
|
199
209
|
"title": self._title,
|
|
200
210
|
"description": self._description,
|
|
@@ -202,14 +212,15 @@ class Bridges:
|
|
|
202
212
|
"map_overlay": self._map_overlay,
|
|
203
213
|
"element_label_flag": self._element_label_flag,
|
|
204
214
|
"link_label_flag": self._link_label_flag,
|
|
205
|
-
"map": self.
|
|
215
|
+
"map": self.map,
|
|
206
216
|
}
|
|
207
217
|
if self.window is not None and len(self.window) == 4:
|
|
208
|
-
|
|
218
|
+
ds_dict['window'] = self.window
|
|
209
219
|
|
|
210
|
-
|
|
220
|
+
ds_dict.update(ds_str)
|
|
211
221
|
|
|
212
|
-
|
|
222
|
+
#adds default for serializing objects
|
|
223
|
+
ds_json = json.dumps(ds_dict, default = lambda x: x.__dict__)
|
|
213
224
|
if self._json_flag or self._debug:
|
|
214
225
|
print(ds_json)
|
|
215
226
|
|
|
@@ -290,21 +301,21 @@ class Bridges:
|
|
|
290
301
|
"""
|
|
291
302
|
self._map_overlay = flag
|
|
292
303
|
|
|
293
|
-
@property
|
|
294
|
-
def map(self)->list:
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
@map.setter
|
|
298
|
-
def map(self, new_map:list) ->None:
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
304
|
+
# @property
|
|
305
|
+
# def map(self)->list:
|
|
306
|
+
# return self._map
|
|
307
|
+
|
|
308
|
+
# @map.setter
|
|
309
|
+
# def map(self, new_map:list) ->None:
|
|
310
|
+
# """
|
|
311
|
+
# Setter function for the svg map overlay describing which map to use and the information from that map.
|
|
312
|
+
# Args:
|
|
313
|
+
# new_map: is a list with the first element describing which map: "us" or "world", and the second element
|
|
314
|
+
# describing what part of the map: a state name or country name respectively.
|
|
315
|
+
# Returns:
|
|
316
|
+
# None
|
|
317
|
+
# """
|
|
318
|
+
# self._map = new_map
|
|
308
319
|
|
|
309
320
|
def set_coord_system_type(self, coord):
|
|
310
321
|
"""
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
class County:
|
|
4
|
+
|
|
5
|
+
def __init__(self, id: str, code: str, county: str, state: str):
|
|
6
|
+
self._geoid = id
|
|
7
|
+
self._fips_code = code
|
|
8
|
+
self._county_name = county
|
|
9
|
+
self._state_name = state
|
|
10
|
+
self._stroke_color = 'green'
|
|
11
|
+
self._stroke_width = 0.5
|
|
12
|
+
self._fill_color = 'blue'
|
|
13
|
+
self._hide = False
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def geoid(self):
|
|
17
|
+
return self._geoid
|
|
18
|
+
|
|
19
|
+
@geoid.setter
|
|
20
|
+
def geoid(self, value):
|
|
21
|
+
self._geoid = value
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def fips_code(self):
|
|
25
|
+
return self._fips_code
|
|
26
|
+
|
|
27
|
+
@fips_code.setter
|
|
28
|
+
def fips_code(self, value):
|
|
29
|
+
self._fips_code = value
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def county_name(self):
|
|
33
|
+
return self._county_name
|
|
34
|
+
|
|
35
|
+
@county_name.setter
|
|
36
|
+
def county_name(self, value):
|
|
37
|
+
self._county_name = value
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def state_name(self):
|
|
41
|
+
return self._state_name
|
|
42
|
+
|
|
43
|
+
@state_name.setter
|
|
44
|
+
def state_name(self, value):
|
|
45
|
+
self._state_name = value
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def stroke_color(self):
|
|
49
|
+
return self._stroke_color
|
|
50
|
+
|
|
51
|
+
@stroke_color.setter
|
|
52
|
+
def stroke_color(self, value):
|
|
53
|
+
self._stroke_color = value
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def stroke_width(self):
|
|
57
|
+
return self._stroke_width
|
|
58
|
+
|
|
59
|
+
@stroke_width.setter
|
|
60
|
+
def stroke_width(self, value):
|
|
61
|
+
self._stroke_width = value
|
|
62
|
+
|
|
63
|
+
@property
|
|
64
|
+
def fill_color(self):
|
|
65
|
+
return self._fill_color
|
|
66
|
+
|
|
67
|
+
@fill_color.setter
|
|
68
|
+
def fill_color(self, value):
|
|
69
|
+
self._fill_color = value
|
|
70
|
+
|
|
71
|
+
@property
|
|
72
|
+
def hide(self):
|
|
73
|
+
return self._hide
|
|
74
|
+
|
|
75
|
+
@hide.setter
|
|
76
|
+
def hide(self, value):
|
|
77
|
+
self._hide = value
|
|
@@ -2,6 +2,7 @@ import json
|
|
|
2
2
|
import requests
|
|
3
3
|
import pickle
|
|
4
4
|
import urllib.parse
|
|
5
|
+
import os
|
|
5
6
|
|
|
6
7
|
from bridges.data_src_dependent.earthquake_usgs import *
|
|
7
8
|
from bridges.data_src_dependent import actor_movie_imdb
|
|
@@ -21,10 +22,13 @@ from bridges.data_src_dependent.amenity import *
|
|
|
21
22
|
from bridges.data_src_dependent.actor_movie_imdb import *
|
|
22
23
|
from bridges.color_grid import ColorGrid
|
|
23
24
|
from bridges.color import Color
|
|
25
|
+
from bridges.data_src_dependent.state import *
|
|
26
|
+
from bridges.data_src_dependent.county import *
|
|
24
27
|
from SPARQLWrapper import SPARQLWrapper, JSON
|
|
25
28
|
|
|
26
29
|
|
|
27
30
|
source_type = "live"
|
|
31
|
+
_debug = False
|
|
28
32
|
|
|
29
33
|
def set_source_type(t) -> None:
|
|
30
34
|
global source_type
|
|
@@ -83,6 +87,8 @@ def get_game_data():
|
|
|
83
87
|
url = "http://bridgesdata.herokuapp.com/api/games"
|
|
84
88
|
PARAMS = {"Accept: application/json"}
|
|
85
89
|
|
|
90
|
+
if _debug:
|
|
91
|
+
print ("Accessing "+url)
|
|
86
92
|
r = requests.get(url=url, params=str(PARAMS))
|
|
87
93
|
|
|
88
94
|
r = r.json()
|
|
@@ -206,7 +212,8 @@ def get_world_cities_data(**kwargs) -> List[City]:
|
|
|
206
212
|
url = url + 'limit=' + str(kwargs['limit']) + '&'
|
|
207
213
|
url = url[:-1] # remove last &
|
|
208
214
|
|
|
209
|
-
|
|
215
|
+
if _debug:
|
|
216
|
+
print(url)
|
|
210
217
|
PARAMS = {"Accept: application/json"}
|
|
211
218
|
|
|
212
219
|
r = requests.get(url=url, params=str(PARAMS))
|
|
@@ -222,6 +229,36 @@ def get_world_cities_data(**kwargs) -> List[City]:
|
|
|
222
229
|
return wrapper
|
|
223
230
|
|
|
224
231
|
|
|
232
|
+
def get_map(state_name = []):
|
|
233
|
+
|
|
234
|
+
wrapper = []
|
|
235
|
+
|
|
236
|
+
url = "http://bridgesdata.herokuapp.com/api/us_map?state="
|
|
237
|
+
for i in range(len(state_name)):
|
|
238
|
+
url += state_name[i] + ","
|
|
239
|
+
url = url[:-1]
|
|
240
|
+
PARAMS = {"Accept: application/json"}
|
|
241
|
+
|
|
242
|
+
if _debug:
|
|
243
|
+
print ("Accessing "+url)
|
|
244
|
+
r = requests.get(url = url, params = str(PARAMS))
|
|
245
|
+
|
|
246
|
+
r = r.json()
|
|
247
|
+
|
|
248
|
+
state_info = r['data']
|
|
249
|
+
|
|
250
|
+
for i in range(len(state_info)):
|
|
251
|
+
temp_state = State(state_info[i]['_id']["input"])
|
|
252
|
+
for j in range(len(state_info[i]['counties'])):
|
|
253
|
+
current_county = state_info[i]['counties'][j]
|
|
254
|
+
temp_state.counties.append(County(current_county['properties']['GEOID'],
|
|
255
|
+
current_county['properties']['FIPS_CODE'],
|
|
256
|
+
current_county['properties']['COUNTY_STATE_CODE'],
|
|
257
|
+
current_county['properties']['COUNTY_STATE_NAME']))
|
|
258
|
+
wrapper.append(temp_state)
|
|
259
|
+
|
|
260
|
+
return wrapper
|
|
261
|
+
|
|
225
262
|
|
|
226
263
|
|
|
227
264
|
def _parse_actor_movie_imdb(item) -> ActorMovieIMDB:
|
|
@@ -255,8 +292,11 @@ def get_actor_movie_imdb_data(count = 0) -> ActorMovieIMDB:
|
|
|
255
292
|
wrapper = []
|
|
256
293
|
|
|
257
294
|
url = "http://bridgesdata.herokuapp.com/api/imdb?limit=" + str(count)
|
|
295
|
+
if _debug:
|
|
296
|
+
print ("accessing "+url)
|
|
258
297
|
PARAMS = {"Accept: application/json"}
|
|
259
298
|
|
|
299
|
+
|
|
260
300
|
r = requests.get(url=url, params=str(PARAMS))
|
|
261
301
|
# print(r.status_code, r.reason)
|
|
262
302
|
|
|
@@ -284,7 +324,9 @@ def get_actor_movie_imdb_data2() -> List[ActorMovieIMDB]:
|
|
|
284
324
|
Exception if the request fails
|
|
285
325
|
"""
|
|
286
326
|
url = "https://bridgesdata.herokuapp.com/api/imdb2"
|
|
287
|
-
|
|
327
|
+
if _debug:
|
|
328
|
+
print ("Accessing "+url)
|
|
329
|
+
|
|
288
330
|
r = requests.get(url = url)
|
|
289
331
|
status = r.status_code
|
|
290
332
|
|
|
@@ -330,6 +372,8 @@ def get_earthquake_usgs_data(count = 0) -> List[EarthquakeUSGS]:
|
|
|
330
372
|
PARAMS = {"Accept: application/json"}
|
|
331
373
|
|
|
332
374
|
if count <= 0:
|
|
375
|
+
if _debug:
|
|
376
|
+
print ("Accessing: "+url)
|
|
333
377
|
r = requests.get(url=url, params=str(PARAMS))
|
|
334
378
|
r = r.json()
|
|
335
379
|
for i in range(len(r)):
|
|
@@ -337,6 +381,8 @@ def get_earthquake_usgs_data(count = 0) -> List[EarthquakeUSGS]:
|
|
|
337
381
|
G = r[i]["geometry"]["coordinates"]
|
|
338
382
|
wrapper.append(EarthquakeUSGS(V["mag"], G[0], G[1], V["place"], V["title"], V["url"], V["time"]))
|
|
339
383
|
else:
|
|
384
|
+
if _debug:
|
|
385
|
+
print ("Accessing: "+url)
|
|
340
386
|
r = requests.get(url=latest_url, params=str(PARAMS))
|
|
341
387
|
data = r.json()
|
|
342
388
|
D = data["Earthquakes"]
|
|
@@ -377,6 +423,8 @@ def get_shakespeare_data(endpoint = "", textonly = False) -> List[Shakespeare]:
|
|
|
377
423
|
if textonly:
|
|
378
424
|
url += "?format=simple"
|
|
379
425
|
|
|
426
|
+
if _debug:
|
|
427
|
+
print ("Accessing "+url)
|
|
380
428
|
r = requests.get(url = url, params = str(PARAMS))
|
|
381
429
|
r = r.json()
|
|
382
430
|
|
|
@@ -409,6 +457,8 @@ def get_gutenberg_book_data(num = 0) -> List[GutenbergBook]:
|
|
|
409
457
|
if num > 0:
|
|
410
458
|
url += "?limit=" + str(num)
|
|
411
459
|
|
|
460
|
+
if _debug:
|
|
461
|
+
print ("Accessing "+url)
|
|
412
462
|
r = requests.get(url=url, params = str(PARAMS))
|
|
413
463
|
r = r.json()
|
|
414
464
|
|
|
@@ -460,6 +510,8 @@ def get_cancer_incident_data(num = 0) -> List[CancerIncidence]:
|
|
|
460
510
|
if num > 0:
|
|
461
511
|
url += "?limit="+str(num)
|
|
462
512
|
|
|
513
|
+
if _debug:
|
|
514
|
+
print ("Accessing "+url)
|
|
463
515
|
r = requests.get(url=url, params=str(PARAMS))
|
|
464
516
|
r = r.json()
|
|
465
517
|
|
|
@@ -525,6 +577,8 @@ def get_song(songTitle, artistName = None) -> Song:
|
|
|
525
577
|
if len(artistName):
|
|
526
578
|
url += "?artistName=" + urllib.parse.quote(artistName)
|
|
527
579
|
|
|
580
|
+
if _debug:
|
|
581
|
+
print ("Accessing "+url)
|
|
528
582
|
r = requests.get(url = url, params = str(PARAMS))
|
|
529
583
|
if r.status_code != 200:
|
|
530
584
|
raise ConnectionError("HTTP Request Failed. Error Code: " + str(r.status_code) + " when accessing "+url)
|
|
@@ -574,6 +628,8 @@ def get_song_data() -> List[Song]:
|
|
|
574
628
|
url = "http://bridgesdata.herokuapp.com/api/songs/"
|
|
575
629
|
params = {"Accept: application/json"}
|
|
576
630
|
|
|
631
|
+
if _debug:
|
|
632
|
+
print ("Accessing "+url)
|
|
577
633
|
r = requests.get(url=url, params=str(params))
|
|
578
634
|
r = r.json()
|
|
579
635
|
|
|
@@ -734,6 +790,8 @@ def _get_assignment(server: str, user: str, assignment: int, subassignment: int
|
|
|
734
790
|
url = "{}/assignmentJSON/{}.{}/{}".format(server, assignment, subassignment_fixed, user)
|
|
735
791
|
params = "Accept: application/json"
|
|
736
792
|
|
|
793
|
+
if _debug:
|
|
794
|
+
print ("Accessing "+url)
|
|
737
795
|
request = requests.get(url, params)
|
|
738
796
|
if request.ok:
|
|
739
797
|
return request.content
|
|
@@ -751,6 +809,8 @@ def _osm_server_request(url):
|
|
|
751
809
|
url: url for server to process
|
|
752
810
|
|
|
753
811
|
"""
|
|
812
|
+
if _debug:
|
|
813
|
+
print ("Accessing "+url)
|
|
754
814
|
request = requests.get(url)
|
|
755
815
|
if not request.ok:
|
|
756
816
|
if request.status_code == 404:
|
|
@@ -790,7 +850,6 @@ def get_osm_data(*args) -> OsmData:
|
|
|
790
850
|
"""
|
|
791
851
|
import os
|
|
792
852
|
|
|
793
|
-
debug = True
|
|
794
853
|
|
|
795
854
|
if (len(args) == 2):
|
|
796
855
|
location = args[0]
|
|
@@ -810,7 +869,7 @@ def get_osm_data(*args) -> OsmData:
|
|
|
810
869
|
|
|
811
870
|
lru = lru_cache.lru_cache(30)
|
|
812
871
|
|
|
813
|
-
if
|
|
872
|
+
if _debug:
|
|
814
873
|
print ("url: "+url)
|
|
815
874
|
print ("hash_url: "+hash_url)
|
|
816
875
|
|
|
@@ -876,6 +935,8 @@ def _server_request(url):
|
|
|
876
935
|
|
|
877
936
|
For internal use only
|
|
878
937
|
"""
|
|
938
|
+
if _debug:
|
|
939
|
+
print ("Requesting "+url)
|
|
879
940
|
request = requests.get(url)
|
|
880
941
|
if not request.ok:
|
|
881
942
|
if request.status_code == 404:
|
|
@@ -1157,8 +1218,6 @@ def get_a_gutenberg_book_metadata(id) -> GutenbergMeta:
|
|
|
1157
1218
|
|
|
1158
1219
|
meta = GutenbergMeta()
|
|
1159
1220
|
for node in data['book_list']:
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
1221
|
meta.id = node["id"]
|
|
1163
1222
|
meta.title = node['title']
|
|
1164
1223
|
meta.lang = node["lang"]
|
|
@@ -1245,3 +1304,8 @@ def reddit_data(subreddit, time_request = -9999) -> Reddit:
|
|
|
1245
1304
|
|
|
1246
1305
|
class DataSource:
|
|
1247
1306
|
pass
|
|
1307
|
+
|
|
1308
|
+
force = os.getenv("FORCE_BRIDGES_DATADEBUG", "")
|
|
1309
|
+
if (force != ""):
|
|
1310
|
+
_debug = True
|
|
1311
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
class State:
|
|
4
|
+
|
|
5
|
+
def __init__(self, state: str):
|
|
6
|
+
self._state_name = state
|
|
7
|
+
self._stroke_color = 'blue'
|
|
8
|
+
self._counties = []
|
|
9
|
+
self._view_counties = True
|
|
10
|
+
self._stroke_width = 0.5
|
|
11
|
+
self._fill_color = 'blue'
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@property
|
|
15
|
+
def state_name(self):
|
|
16
|
+
return self._state_name
|
|
17
|
+
|
|
18
|
+
@state_name.setter
|
|
19
|
+
def state_name(self, value):
|
|
20
|
+
self._state_name = value
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
def stroke_color(self):
|
|
24
|
+
return self._stroke_color
|
|
25
|
+
|
|
26
|
+
@stroke_color.setter
|
|
27
|
+
def stroke_color(self, value):
|
|
28
|
+
self._stroke_color = value
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def counties(self):
|
|
32
|
+
return self._counties
|
|
33
|
+
|
|
34
|
+
@counties.setter
|
|
35
|
+
def counties(self, value):
|
|
36
|
+
self._counties = value
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def view_counties(self):
|
|
40
|
+
return self._view_counties
|
|
41
|
+
|
|
42
|
+
@view_counties.setter
|
|
43
|
+
def view_counties(self, value):
|
|
44
|
+
self._view_counties = value
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def stroke_width(self):
|
|
48
|
+
return self._stroke_width
|
|
49
|
+
|
|
50
|
+
@stroke_width.setter
|
|
51
|
+
def stroke_width(self, value):
|
|
52
|
+
self._stroke_width = value
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def fill_color(self):
|
|
56
|
+
return self._fill_color
|
|
57
|
+
|
|
58
|
+
@fill_color.setter
|
|
59
|
+
def fill_color(self, value):
|
|
60
|
+
self._fill_color = value
|
|
61
|
+
|
|
@@ -10,6 +10,7 @@ bridges/array3d.py
|
|
|
10
10
|
bridges/audio_channel.py
|
|
11
11
|
bridges/audio_clip.py
|
|
12
12
|
bridges/avl_tree_element.py
|
|
13
|
+
bridges/bar_chart.py
|
|
13
14
|
bridges/bfs_benchmark.py
|
|
14
15
|
bridges/bin_tree_element.py
|
|
15
16
|
bridges/blocking_game.py
|
|
@@ -73,6 +74,7 @@ bridges/data_src_dependent/actor_movie_imdb.py
|
|
|
73
74
|
bridges/data_src_dependent/amenity.py
|
|
74
75
|
bridges/data_src_dependent/cancer_incidence.py
|
|
75
76
|
bridges/data_src_dependent/city.py
|
|
77
|
+
bridges/data_src_dependent/county.py
|
|
76
78
|
bridges/data_src_dependent/data_source.py
|
|
77
79
|
bridges/data_src_dependent/earthquake_usgs.py
|
|
78
80
|
bridges/data_src_dependent/elevation.py
|
|
@@ -85,4 +87,5 @@ bridges/data_src_dependent/osm.py
|
|
|
85
87
|
bridges/data_src_dependent/reddit.py
|
|
86
88
|
bridges/data_src_dependent/shakespeare.py
|
|
87
89
|
bridges/data_src_dependent/song.py
|
|
90
|
+
bridges/data_src_dependent/state.py
|
|
88
91
|
bridges/data_src_dependent/world_cities.py
|
|
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|
|
5
5
|
|
|
6
6
|
setuptools.setup(
|
|
7
7
|
name="bridges",
|
|
8
|
-
version="3.4.
|
|
8
|
+
version="3.4.5.dev1",
|
|
9
9
|
author="BRIDGES",
|
|
10
10
|
author_email="bridges.uncc@gmail.com",
|
|
11
11
|
description="Bridging Real-world Infrastructure Designed to Goal-align, Engage, and Stimulate, an NSF TUES",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|