bridges 3.4.5.dev1__tar.gz → 3.4.6__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.5.dev1/bridges.egg-info → bridges-3.4.6}/PKG-INFO +11 -2
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/bar_chart.py +6 -6
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/bridges.py +12 -4
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/color.py +52 -28
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/color_grid.py +10 -13
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/data_src_dependent/cancer_incidence.py +1 -1
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/data_src_dependent/data_source.py +29 -11
- bridges-3.4.5.dev1/bridges/data_src_dependent/county.py → bridges-3.4.6/bridges/data_src_dependent/us_county.py +27 -3
- bridges-3.4.5.dev1/bridges/data_src_dependent/state.py → bridges-3.4.6/bridges/data_src_dependent/us_state.py +19 -4
- bridges-3.4.6/bridges/map.py +15 -0
- bridges-3.4.6/bridges/us_map.py +104 -0
- bridges-3.4.6/bridges/world_map.py +50 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6/bridges.egg-info}/PKG-INFO +11 -2
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges.egg-info/SOURCES.txt +5 -2
- {bridges-3.4.5.dev1 → bridges-3.4.6}/setup.py +1 -1
- {bridges-3.4.5.dev1 → bridges-3.4.6}/LICENSE +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/MANIFEST.in +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/README.md +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/__init__.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/array.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/array1d.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/array2d.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/array3d.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/audio_channel.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/audio_clip.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/avl_tree_element.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/bfs_benchmark.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/bin_tree_element.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/blocking_game.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/bst_element.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/camera.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/circ_dl_element.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/circ_sl_element.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/circle.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/connector.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/data_src_dependent/__init__.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/data_src_dependent/actor_movie_imdb.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/data_src_dependent/amenity.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/data_src_dependent/city.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/data_src_dependent/earthquake_usgs.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/data_src_dependent/elevation.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/data_src_dependent/game.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/data_src_dependent/gutenberg_book.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/data_src_dependent/gutenberg_meta.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/data_src_dependent/lru_cache.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/data_src_dependent/movie_actor_wiki_data.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/data_src_dependent/osm.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/data_src_dependent/reddit.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/data_src_dependent/shakespeare.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/data_src_dependent/song.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/data_src_dependent/world_cities.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/dl_element.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/edge.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/element.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/element_visualizer.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/game_cell.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/game_grid.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/gamebase.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/gamebase3D.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/graph_adj_list.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/graph_adj_matrix.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/graph_benchmark.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/grid.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/input_helper.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/input_state_machine.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/kd_tree_element.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/keypress_listener.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/light.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/line_chart.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/link_visualizer.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/mesh.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/ml_element.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/named_color.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/named_symbol.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/non_blocking_game.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/non_blocking_game3D.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/page_rank_benchmark.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/particle_system.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/polygon.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/polyline.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/primitives.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/rectangle.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/scene.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/shortest_path_benchmark.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/sl_element.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/socket_connection.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/sorting_benchmark.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/symbol.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/symbol_collection.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/symbol_group.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/text.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges/tree_element.py +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges.egg-info/dependency_links.txt +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges.egg-info/requires.txt +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/bridges.egg-info/top_level.txt +0 -0
- {bridges-3.4.5.dev1 → bridges-3.4.6}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: bridges
|
|
3
|
-
Version: 3.4.
|
|
3
|
+
Version: 3.4.6
|
|
4
4
|
Summary: Bridging Real-world Infrastructure Designed to Goal-align, Engage, and Stimulate, an NSF TUES
|
|
5
5
|
Home-page: https://github.com/BridgesUNCC/bridges-python
|
|
6
6
|
Author: BRIDGES
|
|
@@ -15,6 +15,15 @@ Requires-Dist: requests>=2.21.0
|
|
|
15
15
|
Requires-Dist: webcolors>=1.8.1
|
|
16
16
|
Requires-Dist: python-socketio[client]>=4.3.0
|
|
17
17
|
Requires-Dist: SPARQLWrapper>=1.8.4
|
|
18
|
+
Dynamic: author
|
|
19
|
+
Dynamic: author-email
|
|
20
|
+
Dynamic: classifier
|
|
21
|
+
Dynamic: description
|
|
22
|
+
Dynamic: description-content-type
|
|
23
|
+
Dynamic: home-page
|
|
24
|
+
Dynamic: requires-dist
|
|
25
|
+
Dynamic: requires-python
|
|
26
|
+
Dynamic: summary
|
|
18
27
|
|
|
19
28
|
# bridges-python
|
|
20
29
|
|
|
@@ -37,7 +37,7 @@ class BarChart:
|
|
|
37
37
|
self._c_label = ""
|
|
38
38
|
self._v_label = ""
|
|
39
39
|
self._title = ""
|
|
40
|
-
self.
|
|
40
|
+
self._subtitle = ""
|
|
41
41
|
self._tt_suffix = ""
|
|
42
42
|
self._orientation = "horizontal"
|
|
43
43
|
self._series_data = []
|
|
@@ -63,18 +63,18 @@ class BarChart:
|
|
|
63
63
|
self._title = plot_title
|
|
64
64
|
|
|
65
65
|
@property
|
|
66
|
-
def
|
|
66
|
+
def subtitle(self) -> str:
|
|
67
67
|
"""
|
|
68
68
|
Subtitle of the plot
|
|
69
69
|
"""
|
|
70
|
-
return self.
|
|
70
|
+
return self._subtitle
|
|
71
71
|
|
|
72
|
-
@
|
|
73
|
-
def
|
|
72
|
+
@subtitle.setter
|
|
73
|
+
def subtitle(self, plot_sub_title: str) -> None:
|
|
74
74
|
"""
|
|
75
75
|
Subtitle of the plot
|
|
76
76
|
"""
|
|
77
|
-
self.
|
|
77
|
+
self._subtitle = plot_sub_title
|
|
78
78
|
|
|
79
79
|
@property
|
|
80
80
|
def value_label(self) -> str:
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from bridges.connector import *
|
|
2
2
|
from bridges import ColorGrid
|
|
3
|
+
from bridges.us_map import *
|
|
3
4
|
import os
|
|
4
5
|
|
|
5
6
|
import json
|
|
@@ -32,8 +33,8 @@ class Bridges:
|
|
|
32
33
|
@date 2015, 2016, 2017, 2018, 2019, 2020, 2021
|
|
33
34
|
"""
|
|
34
35
|
|
|
35
|
-
_MaxTitleSize =
|
|
36
|
-
_MaxDescSize =
|
|
36
|
+
_MaxTitleSize = 200
|
|
37
|
+
_MaxDescSize = 1000
|
|
37
38
|
_projection_options = {"cartesian", "albersusa", "equirectangular", "window"}
|
|
38
39
|
_debug = False
|
|
39
40
|
|
|
@@ -171,13 +172,18 @@ class Bridges:
|
|
|
171
172
|
def set_map(self, map_info:list):
|
|
172
173
|
"""
|
|
173
174
|
This method serializes all the state and county objects in the map_info for sending to the server
|
|
175
|
+
|
|
176
|
+
See tutorial at https://bridgesuncc.github.io/tutorials/Map.html
|
|
177
|
+
|
|
174
178
|
:param map_info: is a list of state objects with their counties
|
|
175
179
|
:return: none
|
|
176
180
|
"""
|
|
181
|
+
if isinstance(map_info, Map):
|
|
182
|
+
self.set_map_overlay(map_info.get_overlay())
|
|
183
|
+
self.set_coord_system_type(map_info.get_projection())
|
|
177
184
|
self.map = map_info
|
|
178
185
|
|
|
179
186
|
|
|
180
|
-
|
|
181
187
|
def post_visualization_link(self, flag:bool):
|
|
182
188
|
"""
|
|
183
189
|
This method controls (with a flag) if the visualization url is printed to the console or not.
|
|
@@ -192,6 +198,8 @@ class Bridges:
|
|
|
192
198
|
Returns:
|
|
193
199
|
None
|
|
194
200
|
"""
|
|
201
|
+
if isinstance(self.ds_handle, Map):
|
|
202
|
+
self.set_map(self.ds_handle)
|
|
195
203
|
ds_str = ""
|
|
196
204
|
|
|
197
205
|
if self.vis_type == "Tree" or self.vis_type == "BinaryTree" or self.vis_type == "AVLTree" or\
|
|
@@ -212,7 +220,7 @@ class Bridges:
|
|
|
212
220
|
"map_overlay": self._map_overlay,
|
|
213
221
|
"element_label_flag": self._element_label_flag,
|
|
214
222
|
"link_label_flag": self._link_label_flag,
|
|
215
|
-
"map": self.map,
|
|
223
|
+
"map": (self.map.get_map_representation() if isinstance(self.map, Map) else self.map),
|
|
216
224
|
}
|
|
217
225
|
if self.window is not None and len(self.window) == 4:
|
|
218
226
|
ds_dict['window'] = self.window
|
|
@@ -235,12 +235,28 @@ class Color(object):
|
|
|
235
235
|
col_name = None
|
|
236
236
|
if args:
|
|
237
237
|
errorcondition = True
|
|
238
|
-
if len(args) == 1
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
238
|
+
if len(args) == 1:
|
|
239
|
+
thetype = type(args[0])
|
|
240
|
+
if thetype == list:
|
|
241
|
+
self.red = args[0][0]
|
|
242
|
+
self.green = args[0][1]
|
|
243
|
+
self.blue = args[0][2]
|
|
244
|
+
self.alpha = args[0][3]
|
|
245
|
+
errorcondition=False
|
|
246
|
+
elif thetype is str:
|
|
247
|
+
col_name = args[0]
|
|
248
|
+
try:
|
|
249
|
+
web_color = webcolors.name_to_rgb(col_name)
|
|
250
|
+
self.set_color(web_color.red, web_color.green, web_color.blue)
|
|
251
|
+
errorcondition=False
|
|
252
|
+
except ValueError:
|
|
253
|
+
raise ValueError(col_name + " is not a valid color name")
|
|
254
|
+
elif thetype is Color:
|
|
255
|
+
self.red = args[0].red
|
|
256
|
+
self.green = args[0].green
|
|
257
|
+
self.blue = args[0].blue
|
|
258
|
+
self.alpha = args[0].alpha
|
|
259
|
+
errorcondition = False
|
|
244
260
|
if len(args) == 4 or len(args) == 3:
|
|
245
261
|
self.red = args[0]
|
|
246
262
|
self.green = args[1]
|
|
@@ -248,21 +264,16 @@ class Color(object):
|
|
|
248
264
|
if len(args) == 4:
|
|
249
265
|
self.alpha = args[3]
|
|
250
266
|
errorcondition = False
|
|
251
|
-
elif len(args) == 1:
|
|
252
|
-
if type(args[0]) is str:
|
|
253
|
-
col_name = args[0]
|
|
254
|
-
errorcondition=False
|
|
255
|
-
elif type(args[0]) is Color:
|
|
256
|
-
self.red = args[0].red
|
|
257
|
-
self.green = args[0].green
|
|
258
|
-
self.blue = args[0].blue
|
|
259
|
-
self.alpha = args[0].alpha
|
|
260
|
-
errorcondition = False
|
|
261
267
|
if errorcondition:
|
|
262
268
|
raise ValueError("To use Color constructor pass 3 RGB values and a float alpha value or a color name or a Color object")
|
|
263
269
|
elif kwargs:
|
|
264
270
|
if 'col_name' in kwargs:
|
|
265
271
|
col_name = kwargs['col_name']
|
|
272
|
+
try:
|
|
273
|
+
web_color = webcolors.name_to_rgb(col_name)
|
|
274
|
+
self.set_color(web_color.red, web_color.green, web_color.blue)
|
|
275
|
+
except ValueError:
|
|
276
|
+
raise ValueError(col_name + " is not a valid color name")
|
|
266
277
|
if 'r' in kwargs:
|
|
267
278
|
self.red = kwargs['r']
|
|
268
279
|
if 'red' in kwargs:
|
|
@@ -280,12 +291,6 @@ class Color(object):
|
|
|
280
291
|
if 'alpha' in kwargs:
|
|
281
292
|
self.alpha = kwargs['alpha']
|
|
282
293
|
|
|
283
|
-
if col_name is not None:
|
|
284
|
-
try:
|
|
285
|
-
web_color = webcolors.name_to_rgb(col_name)
|
|
286
|
-
self.set_color(web_color.red, web_color.green, web_color.blue)
|
|
287
|
-
except ValueError:
|
|
288
|
-
raise ValueError(col_name + " is not a valid color name")
|
|
289
294
|
|
|
290
295
|
def get_byte_representation(self) -> list:
|
|
291
296
|
"""
|
|
@@ -298,14 +303,24 @@ class Color(object):
|
|
|
298
303
|
b = self.blue
|
|
299
304
|
a = round(255 * self.alpha)
|
|
300
305
|
|
|
301
|
-
bytebuffer =
|
|
302
|
-
|
|
303
|
-
bytebuffer.append(g)
|
|
304
|
-
bytebuffer.append(b)
|
|
305
|
-
bytebuffer.append(a)
|
|
306
|
-
|
|
306
|
+
bytebuffer = [r,g,b,a]
|
|
307
|
+
|
|
307
308
|
return bytebuffer
|
|
308
309
|
|
|
310
|
+
def write_byte_representation(self, bytebuffer: list[int]) -> None:
|
|
311
|
+
"""
|
|
312
|
+
Writes the RGBA values as list of ints from 0-255
|
|
313
|
+
Assumes bytebuffer is a list of size 4
|
|
314
|
+
"""
|
|
315
|
+
bytebuffer[0] = self.red
|
|
316
|
+
bytebuffer[1] = self.green
|
|
317
|
+
bytebuffer[2] = self.blue
|
|
318
|
+
bytebuffer[3] = round(255 * self.alpha)
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
309
324
|
def __eq__(self, other):
|
|
310
325
|
"""deep equality check, by value of each RGBA value"""
|
|
311
326
|
if not isinstance(other, self.__class__):
|
|
@@ -315,3 +330,12 @@ class Color(object):
|
|
|
315
330
|
self.green == other.green and
|
|
316
331
|
self.blue == other.blue and
|
|
317
332
|
self.alpha == other.alpha)
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
def _get_representation(self):
|
|
336
|
+
'''
|
|
337
|
+
Should not be needed externally.
|
|
338
|
+
This is used internally to derive BRIDGES JSON representation for colors
|
|
339
|
+
'''
|
|
340
|
+
return [str(self.red), str(self.green),
|
|
341
|
+
str(self.blue), str(self.alpha)]
|
|
@@ -83,6 +83,7 @@ class ColorGrid(Grid):
|
|
|
83
83
|
total_count = 0
|
|
84
84
|
pos = 0
|
|
85
85
|
last = self.grid[0][0]
|
|
86
|
+
colorbuffer = [0, 0, 0, 0]
|
|
86
87
|
|
|
87
88
|
while pos < self.grid_size[0] * self.grid_size[1]:
|
|
88
89
|
posY = pos / self.grid_size[1]
|
|
@@ -98,27 +99,23 @@ class ColorGrid(Grid):
|
|
|
98
99
|
else:
|
|
99
100
|
total_count += count
|
|
100
101
|
img_bytes.append(count-1)
|
|
101
|
-
last
|
|
102
|
-
|
|
103
|
-
for k in range(len(last)):
|
|
104
|
-
img_bytes.append(last[k])
|
|
102
|
+
last.write_byte_representation(colorbuffer)
|
|
103
|
+
img_bytes.extend(colorbuffer)
|
|
105
104
|
|
|
106
105
|
count = 1
|
|
107
106
|
last = current
|
|
108
107
|
if count == 256:
|
|
109
108
|
total_count += count
|
|
110
109
|
img_bytes.append(count-1)
|
|
111
|
-
last
|
|
112
|
-
|
|
113
|
-
img_bytes.append(last[k])
|
|
110
|
+
last.write_byte_representation(colorbuffer)
|
|
111
|
+
img_bytes.extend(colorbuffer)
|
|
114
112
|
count = 0
|
|
115
113
|
pos += 1
|
|
116
114
|
total_count += count
|
|
117
115
|
if count > 0:
|
|
118
116
|
img_bytes.append(count-1)
|
|
119
|
-
last
|
|
120
|
-
|
|
121
|
-
img_bytes.append(last[k])
|
|
117
|
+
last.write_byte_representation(colorbuffer)
|
|
118
|
+
img_bytes.extend(colorbuffer)
|
|
122
119
|
|
|
123
120
|
if total_count != self.grid_size[0] * self.grid_size[1]:
|
|
124
121
|
print("Something broke in getRLE construction")
|
|
@@ -132,14 +129,14 @@ class ColorGrid(Grid):
|
|
|
132
129
|
bytearray: representing the colors of grid cells
|
|
133
130
|
"""
|
|
134
131
|
img_bytes = bytearray()
|
|
132
|
+
colorbuffer = [0, 0, 0, 0]
|
|
135
133
|
for i in range(self.grid_size[0]):
|
|
136
134
|
if self.grid[i] is not None:
|
|
137
135
|
for j in range(self.grid_size[1]):
|
|
138
136
|
if self.grid[i][j] is not None:
|
|
139
137
|
color = self.grid[i][j]
|
|
140
|
-
color
|
|
141
|
-
|
|
142
|
-
img_bytes.append(color[k])
|
|
138
|
+
color.write_byte_representation(colorbuffer)
|
|
139
|
+
img_bytes.extend(colorbuffer)
|
|
143
140
|
return img_bytes
|
|
144
141
|
|
|
145
142
|
def get_data_structure_representation(self) -> dict:
|
|
@@ -12,7 +12,7 @@ class CancerIncidence:
|
|
|
12
12
|
This object is generally not created by the user, to see how its created check
|
|
13
13
|
out bridges::data_src_dependent::data_source::get_cancer_incident_data()
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
https://www.cdc.gov/united-states-cancer-statistics/public-use/index.html
|
|
16
16
|
Data: Courtesy of Corgis Datasets, 2017
|
|
17
17
|
|
|
18
18
|
@author Kalpathi Subramanian
|
|
@@ -22,8 +22,8 @@ from bridges.data_src_dependent.amenity import *
|
|
|
22
22
|
from bridges.data_src_dependent.actor_movie_imdb import *
|
|
23
23
|
from bridges.color_grid import ColorGrid
|
|
24
24
|
from bridges.color import Color
|
|
25
|
-
from bridges.data_src_dependent.
|
|
26
|
-
from bridges.data_src_dependent.
|
|
25
|
+
from bridges.data_src_dependent.us_state import *
|
|
26
|
+
from bridges.data_src_dependent.us_county import *
|
|
27
27
|
from SPARQLWrapper import SPARQLWrapper, JSON
|
|
28
28
|
|
|
29
29
|
|
|
@@ -229,8 +229,11 @@ def get_world_cities_data(**kwargs) -> List[City]:
|
|
|
229
229
|
return wrapper
|
|
230
230
|
|
|
231
231
|
|
|
232
|
-
def
|
|
233
|
-
|
|
232
|
+
def get_us_map_county_data(state_name = [], view_counties = True):
|
|
233
|
+
'''
|
|
234
|
+
returns a list of USState objects.
|
|
235
|
+
See https://bridgesuncc.github.io/tutorials/Map.html on how to use these objects
|
|
236
|
+
'''
|
|
234
237
|
wrapper = []
|
|
235
238
|
|
|
236
239
|
url = "http://bridgesdata.herokuapp.com/api/us_map?state="
|
|
@@ -248,18 +251,33 @@ def get_map(state_name = []):
|
|
|
248
251
|
state_info = r['data']
|
|
249
252
|
|
|
250
253
|
for i in range(len(state_info)):
|
|
251
|
-
temp_state =
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
254
|
+
temp_state = USState(state_info[i]['_id']["input"])
|
|
255
|
+
temp_state._view_counties = view_counties
|
|
256
|
+
if view_counties:
|
|
257
|
+
for j in range(len(state_info[i]['counties'])):
|
|
258
|
+
current_county = state_info[i]['counties'][j]
|
|
259
|
+
temp_state.counties.append(USCounty(current_county['properties']['GEOID'],
|
|
260
|
+
current_county['properties']['FIPS_CODE'],
|
|
261
|
+
current_county['properties']['COUNTY_STATE_CODE'],
|
|
262
|
+
current_county['properties']['COUNTY_STATE_NAME']))
|
|
258
263
|
wrapper.append(temp_state)
|
|
259
264
|
|
|
260
265
|
return wrapper
|
|
261
266
|
|
|
262
267
|
|
|
268
|
+
all_states = ["Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"]
|
|
269
|
+
|
|
270
|
+
def get_us_map_data():
|
|
271
|
+
'''
|
|
272
|
+
See https://bridgesuncc.github.io/tutorials/Map.html on how to use these objects
|
|
273
|
+
'''
|
|
274
|
+
return get_us_map_county_data(all_states, False)
|
|
275
|
+
|
|
276
|
+
def get_all_us_map_county_data():
|
|
277
|
+
'''
|
|
278
|
+
See https://bridgesuncc.github.io/tutorials/Map.html on how to use these objects
|
|
279
|
+
'''
|
|
280
|
+
return get_us_map_county_data(all_states, True)
|
|
263
281
|
|
|
264
282
|
def _parse_actor_movie_imdb(item) -> ActorMovieIMDB:
|
|
265
283
|
"""
|
|
@@ -1,15 +1,39 @@
|
|
|
1
|
+
from bridges.color import *
|
|
1
2
|
|
|
3
|
+
class USCounty:
|
|
4
|
+
"""
|
|
5
|
+
@brief Class that holds US County information
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
This object is used alongside with the USMap object. Each county
|
|
8
|
+
has a stroke color and fill color attributes. Each county has a geoid
|
|
9
|
+
and FIPS code for identification. The geoid is used as the key in the
|
|
10
|
+
USState object to effic
|
|
4
11
|
|
|
12
|
+
Each County object contains its county name, state name, geoid, fips code,
|
|
13
|
+
stroke color, stroke width, fill color, stroke color
|
|
14
|
+
|
|
15
|
+
A tutorial on how to use the these objects is available at:
|
|
16
|
+
https://bridgesuncc.github.io/tutorials/Map.html
|
|
17
|
+
|
|
18
|
+
@author Erik Saule, Kalpathi Subramanian
|
|
19
|
+
@date 12/30/24
|
|
20
|
+
"""
|
|
5
21
|
def __init__(self, id: str, code: str, county: str, state: str):
|
|
22
|
+
"""
|
|
23
|
+
@brief Constructor with county related parameters
|
|
24
|
+
|
|
25
|
+
@param id GeoId of the county
|
|
26
|
+
@param code FIPS ID Code of the county
|
|
27
|
+
@param county name of county
|
|
28
|
+
@param state state containing county
|
|
29
|
+
"""
|
|
6
30
|
self._geoid = id
|
|
7
31
|
self._fips_code = code
|
|
8
32
|
self._county_name = county
|
|
9
33
|
self._state_name = state
|
|
10
|
-
self._stroke_color = '
|
|
34
|
+
self._stroke_color = Color('blue')
|
|
11
35
|
self._stroke_width = 0.5
|
|
12
|
-
self._fill_color = '
|
|
36
|
+
self._fill_color = Color('red')
|
|
13
37
|
self._hide = False
|
|
14
38
|
|
|
15
39
|
@property
|
|
@@ -1,15 +1,30 @@
|
|
|
1
|
+
from bridges.color import *
|
|
1
2
|
|
|
3
|
+
class USState:
|
|
4
|
+
"""
|
|
5
|
+
@brief Class for USState and its attributes
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
Each State object contains its name, stroke color, stroke width,
|
|
8
|
+
fill color, and a list of counties
|
|
9
|
+
A tutorial on how to use the these objects is available at:
|
|
10
|
+
https://bridgesuncc.github.io/tutorials/Map.html
|
|
11
|
+
|
|
12
|
+
@author Erik Saule, Kalpathi Subramanian
|
|
13
|
+
@date Last modified Dec 30, 2024
|
|
14
|
+
"""
|
|
4
15
|
|
|
5
16
|
def __init__(self, state: str):
|
|
17
|
+
"""
|
|
18
|
+
@brief Constructor for a specific state
|
|
19
|
+
|
|
20
|
+
@param state sets default values for the state
|
|
21
|
+
"""
|
|
6
22
|
self._state_name = state
|
|
7
|
-
self._stroke_color = '
|
|
23
|
+
self._stroke_color = Color('red')
|
|
8
24
|
self._counties = []
|
|
9
25
|
self._view_counties = True
|
|
10
26
|
self._stroke_width = 0.5
|
|
11
|
-
self._fill_color = 'blue'
|
|
12
|
-
|
|
27
|
+
self._fill_color = Color('blue')
|
|
13
28
|
|
|
14
29
|
@property
|
|
15
30
|
def state_name(self):
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
class Map:
|
|
3
|
+
'''This is meant to be a base class for all map visualization'''
|
|
4
|
+
'''Likely never instantiated explicitly'''
|
|
5
|
+
def __init__(self):
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
def get_projection(self):
|
|
9
|
+
return None
|
|
10
|
+
|
|
11
|
+
def get_overlay(self):
|
|
12
|
+
return None
|
|
13
|
+
|
|
14
|
+
def get_map_representation(self):
|
|
15
|
+
return None
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
from bridges.map import *
|
|
2
|
+
|
|
3
|
+
class USMap(Map):
|
|
4
|
+
"""
|
|
5
|
+
@brief This class provides an API to building, displaying and
|
|
6
|
+
manipulating US maps and counties in BRIDGES
|
|
7
|
+
|
|
8
|
+
In the current implementation, we can draw a US map with all state
|
|
9
|
+
boundaries, a map with all US state and county boundaries, or
|
|
10
|
+
specify a set of states and display the state and/or county
|
|
11
|
+
boundaries.
|
|
12
|
+
|
|
13
|
+
Functions are provided to access each US state or county and color
|
|
14
|
+
its boundary or its interior using the stroke color and fill color
|
|
15
|
+
functions. This lets us build map based applications where the fill
|
|
16
|
+
fill color can be used to represent different data attributes, such
|
|
17
|
+
population counts, election statistics or any attribute at the state
|
|
18
|
+
or county level.
|
|
19
|
+
|
|
20
|
+
See the Maps tutorials for examples of the usage of the US Map API at
|
|
21
|
+
https://bridgesuncc.github.io/tutorials/Map.html
|
|
22
|
+
|
|
23
|
+
"""
|
|
24
|
+
def get_projection(self):
|
|
25
|
+
return "albersusa"
|
|
26
|
+
|
|
27
|
+
def get_overlay(self):
|
|
28
|
+
return True
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def get_data_structure_type(self):
|
|
32
|
+
"""
|
|
33
|
+
Getter for the data structure type as a JSON string
|
|
34
|
+
Returns
|
|
35
|
+
str: the data structure type
|
|
36
|
+
"""
|
|
37
|
+
return "us_map"
|
|
38
|
+
|
|
39
|
+
def get_data_structure_representation(self):
|
|
40
|
+
"""
|
|
41
|
+
Getter for the data structure's JSON representatoin
|
|
42
|
+
Returns:
|
|
43
|
+
str: the data structure representation
|
|
44
|
+
"""
|
|
45
|
+
#This is only used to make a dummy data structure for use when
|
|
46
|
+
#the map is passed as a datastructure and not as an overlay
|
|
47
|
+
return {"map_dummy": True}
|
|
48
|
+
|
|
49
|
+
def _county_to_obj(self, co):
|
|
50
|
+
return {
|
|
51
|
+
"_geoid" : co.geoid,
|
|
52
|
+
"_fips_code" : co.fips_code,
|
|
53
|
+
"_county_name": co.county_name,
|
|
54
|
+
"_state_name": co.state_name,
|
|
55
|
+
"_stroke_color": co.stroke_color._get_representation(),
|
|
56
|
+
"_stroke_width": co.stroke_width,
|
|
57
|
+
"_fill_color": co.fill_color._get_representation(),
|
|
58
|
+
"_hide" : co.hide
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
def _state_to_obj(self, st):
|
|
63
|
+
return {
|
|
64
|
+
"_state_name" : st.state_name,
|
|
65
|
+
"_stroke_color" : st.stroke_color._get_representation(),
|
|
66
|
+
"_stroke_width": st.stroke_width,
|
|
67
|
+
"_fill_color": st.fill_color._get_representation(),
|
|
68
|
+
"_view_counties": st.view_counties,
|
|
69
|
+
"_counties": [self._county_to_obj(st.counties[i]) for i in range(0,len(st.counties)) ]
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
def get_map_representation(self):
|
|
73
|
+
"""
|
|
74
|
+
@brief gets the JSON representation of the map data
|
|
75
|
+
|
|
76
|
+
Uses functions to convert the state and country attributes to objects
|
|
77
|
+
before serialization into a JSON string
|
|
78
|
+
"""
|
|
79
|
+
data = [ self._state_to_obj(self._states[i]) for i in range(0,len(self._states)) ]
|
|
80
|
+
|
|
81
|
+
return data
|
|
82
|
+
|
|
83
|
+
def __init__(self,states = []):
|
|
84
|
+
"""
|
|
85
|
+
@brief Constructor: creates an objecdt with the given state data
|
|
86
|
+
|
|
87
|
+
@param states state and county information for a set of states
|
|
88
|
+
"""
|
|
89
|
+
self._states = states
|
|
90
|
+
|
|
91
|
+
@property
|
|
92
|
+
def states(self):
|
|
93
|
+
'''
|
|
94
|
+
Returns a list of USState objects
|
|
95
|
+
'''
|
|
96
|
+
return self._states
|
|
97
|
+
|
|
98
|
+
@states.setter
|
|
99
|
+
def states(self, value):
|
|
100
|
+
'''
|
|
101
|
+
value: a list of USState objects
|
|
102
|
+
'''
|
|
103
|
+
self._states = value
|
|
104
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from bridges.map import *
|
|
2
|
+
|
|
3
|
+
class WorldMap(Map):
|
|
4
|
+
"""
|
|
5
|
+
@brief This class provides an API to displaying world maps in BRIDGES
|
|
6
|
+
|
|
7
|
+
See the Maps tutorials for examples of the usage of the US Map API at
|
|
8
|
+
https://bridgesuncc.github.io/tutorials/Map.html
|
|
9
|
+
|
|
10
|
+
"""
|
|
11
|
+
def get_projection(self):
|
|
12
|
+
return "equirectangular"
|
|
13
|
+
|
|
14
|
+
def get_overlay(self):
|
|
15
|
+
return True
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def get_data_structure_type(self):
|
|
19
|
+
"""
|
|
20
|
+
Getter for the data structure type as a JSON string
|
|
21
|
+
Returns
|
|
22
|
+
str: the data structure type
|
|
23
|
+
"""
|
|
24
|
+
return "world_map"
|
|
25
|
+
|
|
26
|
+
def get_data_structure_representation(self):
|
|
27
|
+
"""
|
|
28
|
+
Getter for the data structure's JSON representatoin
|
|
29
|
+
Returns:
|
|
30
|
+
str: the data structure representation
|
|
31
|
+
"""
|
|
32
|
+
#This is only used to make a dummy data structure for use when
|
|
33
|
+
#the map is passed as a datastructure and not as an overlay
|
|
34
|
+
return {"map_dummy": True}
|
|
35
|
+
|
|
36
|
+
def get_map_representation(self):
|
|
37
|
+
"""
|
|
38
|
+
@brief gets the JSON representation of the map data
|
|
39
|
+
|
|
40
|
+
Uses functions to convert the state and country attributes to objects
|
|
41
|
+
before serialization into a JSON string
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
return "all"
|
|
45
|
+
|
|
46
|
+
def __init__(self):
|
|
47
|
+
"""
|
|
48
|
+
@brief Constructor: creates an object
|
|
49
|
+
|
|
50
|
+
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: bridges
|
|
3
|
-
Version: 3.4.
|
|
3
|
+
Version: 3.4.6
|
|
4
4
|
Summary: Bridging Real-world Infrastructure Designed to Goal-align, Engage, and Stimulate, an NSF TUES
|
|
5
5
|
Home-page: https://github.com/BridgesUNCC/bridges-python
|
|
6
6
|
Author: BRIDGES
|
|
@@ -15,6 +15,15 @@ Requires-Dist: requests>=2.21.0
|
|
|
15
15
|
Requires-Dist: webcolors>=1.8.1
|
|
16
16
|
Requires-Dist: python-socketio[client]>=4.3.0
|
|
17
17
|
Requires-Dist: SPARQLWrapper>=1.8.4
|
|
18
|
+
Dynamic: author
|
|
19
|
+
Dynamic: author-email
|
|
20
|
+
Dynamic: classifier
|
|
21
|
+
Dynamic: description
|
|
22
|
+
Dynamic: description-content-type
|
|
23
|
+
Dynamic: home-page
|
|
24
|
+
Dynamic: requires-dist
|
|
25
|
+
Dynamic: requires-python
|
|
26
|
+
Dynamic: summary
|
|
18
27
|
|
|
19
28
|
# bridges-python
|
|
20
29
|
|
|
@@ -42,6 +42,7 @@ bridges/keypress_listener.py
|
|
|
42
42
|
bridges/light.py
|
|
43
43
|
bridges/line_chart.py
|
|
44
44
|
bridges/link_visualizer.py
|
|
45
|
+
bridges/map.py
|
|
45
46
|
bridges/mesh.py
|
|
46
47
|
bridges/ml_element.py
|
|
47
48
|
bridges/named_color.py
|
|
@@ -64,6 +65,8 @@ bridges/symbol_collection.py
|
|
|
64
65
|
bridges/symbol_group.py
|
|
65
66
|
bridges/text.py
|
|
66
67
|
bridges/tree_element.py
|
|
68
|
+
bridges/us_map.py
|
|
69
|
+
bridges/world_map.py
|
|
67
70
|
bridges.egg-info/PKG-INFO
|
|
68
71
|
bridges.egg-info/SOURCES.txt
|
|
69
72
|
bridges.egg-info/dependency_links.txt
|
|
@@ -74,7 +77,6 @@ bridges/data_src_dependent/actor_movie_imdb.py
|
|
|
74
77
|
bridges/data_src_dependent/amenity.py
|
|
75
78
|
bridges/data_src_dependent/cancer_incidence.py
|
|
76
79
|
bridges/data_src_dependent/city.py
|
|
77
|
-
bridges/data_src_dependent/county.py
|
|
78
80
|
bridges/data_src_dependent/data_source.py
|
|
79
81
|
bridges/data_src_dependent/earthquake_usgs.py
|
|
80
82
|
bridges/data_src_dependent/elevation.py
|
|
@@ -87,5 +89,6 @@ bridges/data_src_dependent/osm.py
|
|
|
87
89
|
bridges/data_src_dependent/reddit.py
|
|
88
90
|
bridges/data_src_dependent/shakespeare.py
|
|
89
91
|
bridges/data_src_dependent/song.py
|
|
90
|
-
bridges/data_src_dependent/
|
|
92
|
+
bridges/data_src_dependent/us_county.py
|
|
93
|
+
bridges/data_src_dependent/us_state.py
|
|
91
94
|
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.6",
|
|
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
|