visnetmap 0.1.3.6__tar.gz → 0.2.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: visnetmap
3
- Version: 0.1.3.6
3
+ Version: 0.2.1
4
4
  Summary: A short description of my package
5
5
  Author-email: "Peng (Atsaniik) Yang" <peng.yang@uef.fi>
6
6
  Project-URL: Homepage, https://github.com/Atsaniik/visnetmap
@@ -1,11 +1,11 @@
1
1
  # pyproject.toml
2
2
  [build-system]
3
- requires = ["setuptools>=61.0.0"]
3
+ requires = ["setuptools>=66.0.0"]
4
4
  build-backend = "setuptools.build_meta"
5
5
 
6
6
  [project]
7
7
  name = "visnetmap" # The name that will appear on PyPI
8
- version = "0.1.3.6"
8
+ version = "0.2.1"
9
9
  authors = [
10
10
  {name = "Peng (Atsaniik) Yang", email = "peng.yang@uef.fi"},
11
11
  ]
@@ -8,14 +8,14 @@ Usage
8
8
  from visnetmap import visnet, netMap, latLong, nx2vis
9
9
  """
10
10
 
11
- from visnet_base import (
11
+ from .visnet_base import (
12
12
  base64_from_url,
13
13
  base64_from_loc,
14
14
  nx2vis,
15
15
  visnet,
16
16
  )
17
17
 
18
- from netmap_base import (
18
+ from .netmap_base import (
19
19
  latLong,
20
20
  netMap,
21
21
  )
@@ -27,4 +27,4 @@ __all__ = [
27
27
  "visnet",
28
28
  "latLong",
29
29
  "netMap",
30
- ]
30
+ ]
@@ -7,13 +7,15 @@ import time
7
7
  def latLong(place):
8
8
  user_agent = random.randint(10000, 99999)
9
9
  geolocator = Nominatim(user_agent=str(user_agent))
10
- location = geolocator.geocode(place)
10
+ location = geolocator.geocode(place,timeout=11)
11
+ if location is None:
12
+ raise ValueError(f"Could not geocode place: {place}")
11
13
  latitude = location.latitude
12
14
  longitude = location.longitude
13
15
  full_address = location.address
14
16
  return latitude, longitude, full_address
15
17
 
16
- def netMap(cities_data, connections_data, title="Network Map", maximum_nodes=100, writeHTML="network_map.html", default_size=5,browserView =False ):
18
+ def netMap(cities_data, connections_data, title="Network Map", maximum_nodes=100, folder_path=None,writeHTML="network_map.html", default_size=12,browserView =False,tile_layer="esri_gray" ):
17
19
  """
18
20
  cities_data (list): {
19
21
  "node": "New York", "lat": 40.7128, "lon": -74.0060, "size": 15,
@@ -26,6 +28,39 @@ def netMap(cities_data, connections_data, title="Network Map", maximum_nodes=100
26
28
  "default_size": node size 5
27
29
  },
28
30
  maximum_nodes: maximum nodes to display initially
31
+
32
+ tile_layer : str, optional
33
+ Name of the map tile layer to use as the background map.
34
+
35
+ Supported values depend on the `tile_layers` dictionary defined inside
36
+ the function.
37
+
38
+ Recommended available options:
39
+
40
+ "esri_gray"
41
+ Esri World Light Gray Canvas.
42
+ Good for network visualizations because the background is
43
+ visually simple and does not compete with nodes and edges.
44
+
45
+ "esri_street"
46
+ Esri World Street Map.
47
+ More detailed street-map style.
48
+
49
+ "esri_satellite"
50
+ Esri World Imagery.
51
+ Satellite imagery background.
52
+
53
+ "osm"
54
+ OpenStreetMap public tile server.
55
+
56
+ Warning:
57
+ This may return HTTP 403 if the application is blocked by
58
+ OpenStreetMap's public tile servers or does not comply with
59
+ their tile usage policy. For reliable use, prefer another
60
+ tile provider or use your own tile service.
61
+
62
+ Default is "esri_gray".
63
+
29
64
  """
30
65
  df_nodes = pd.DataFrame(cities_data)
31
66
  if not df_nodes['lat'].apply(lambda x: isinstance(x, (int, float)) and not isinstance(x, bool)).all():
@@ -87,6 +122,49 @@ def netMap(cities_data, connections_data, title="Network Map", maximum_nodes=100
87
122
  unique_colors = sorted(set(city['color'] for city in cities_data))
88
123
  unique_hovers = sorted(set(city['node_hover'] for city in cities_data))
89
124
 
125
+
126
+
127
+ tile_layers = {
128
+ "esri_gray": """
129
+ L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}', {
130
+ maxZoom: 16,
131
+ attribution: 'Tiles &copy; Esri'
132
+ }).addTo(map);
133
+ """,
134
+
135
+ "esri_street": """
136
+ L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
137
+ maxZoom: 19,
138
+ attribution: 'Tiles &copy; Esri'
139
+ }).addTo(map);
140
+ """,
141
+
142
+ "esri_satellite": """
143
+ L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
144
+ maxZoom: 19,
145
+ attribution: 'Tiles &copy; Esri'
146
+ }).addTo(map);
147
+ """,
148
+
149
+ "osm": """
150
+ L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
151
+ maxZoom: 19,
152
+ attribution: '&copy; OpenStreetMap contributors'
153
+ }).addTo(map);
154
+ """
155
+ }
156
+
157
+ if tile_layer not in tile_layers:
158
+ raise ValueError(
159
+ f"Unknown tile_layer '{tile_layer}'. "
160
+ f"Available options are: {list(tile_layers.keys())}"
161
+ )
162
+
163
+ selected_tile_layer = tile_layers[tile_layer]
164
+
165
+
166
+
167
+
90
168
  html_content = f"""
91
169
  <!DOCTYPE html>
92
170
  <html>
@@ -226,10 +304,8 @@ def netMap(cities_data, connections_data, title="Network Map", maximum_nodes=100
226
304
  let lonMax = 180;
227
305
 
228
306
  const map = L.map('map').setView([20, 0], 2);
229
- L.tileLayer('https://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png', {{
230
- maxZoom: 19,
231
- attribution: '© OpenStreetMap contributors'
232
- }}).addTo(map);
307
+
308
+ {selected_tile_layer}
233
309
 
234
310
 
235
311
 
@@ -575,7 +651,11 @@ def netMap(cities_data, connections_data, title="Network Map", maximum_nodes=100
575
651
  from pathlib import Path
576
652
  if writeHTML is None:
577
653
  writeHTML ='map.html'
578
- folder_path = Path(f"{Path(__file__).parent.resolve()}/mapOutPut/")
654
+ if folder_path is None:
655
+
656
+ folder_path = Path(f"{Path(__file__).parent.resolve()}/mapOutPut/")
657
+ else:
658
+ folder_path = Path(folder_path)
579
659
  folder_path.mkdir(parents=True, exist_ok=True)
580
660
  writeOut = f"{folder_path}/{writeHTML}"
581
661
 
@@ -670,4 +750,4 @@ if __name__ == "__main__":
670
750
  },
671
751
  ]
672
752
 
673
- netMap(cities, connections, title="net map", writeHTML='simple.html', maximum_nodes=9,browserView=True)
753
+ netMap(cities, connections, title="net map", writeHTML='simple.html', maximum_nodes=9,browserView=True)
@@ -269,6 +269,7 @@ def visnet(
269
269
  network_subtitle: str | None = None,
270
270
  description_df: pd.DataFrame | None = None,
271
271
  description_title: str = "Introduce your network",
272
+ folder_path = None,
272
273
  writeHTML: str | None = "network_visualization.html",
273
274
  browserView: bool = False,
274
275
  min_default_node_size: int | float = 0,
@@ -2141,8 +2142,11 @@ def visnet(
2141
2142
  from pathlib import Path
2142
2143
  if writeHTML is None:
2143
2144
  writeHTML = 'network.html'
2144
-
2145
- folder_path = Path(f"{Path(__file__).parent.resolve()}/netOutPut/")
2145
+ if folder_path is None:
2146
+ folder_path = Path(f"{Path(__file__).parent.resolve()}/netOutPut/")
2147
+
2148
+ else:
2149
+ folder_path = Path(folder_path)
2146
2150
  folder_path.mkdir(parents=True, exist_ok=True)
2147
2151
  writeOut = f"{folder_path}/{writeHTML}"
2148
2152
 
@@ -2221,4 +2225,4 @@ if __name__ == "__main__":
2221
2225
  edge = {"from": random.randint(1, 20), "to": i , "width": width, "color": {"color": "#131112"}, "arrows": "to", "title": f"to {i} width {width}"}
2222
2226
  edges2.append(edge)
2223
2227
 
2224
- visnet(nodes=nodes2, edges=edges2, network_title='Large Network', browserView=True, writeHTML='test_large.html', min_default_node_size=1, min_default_edge_width=1, maximum_display=100)
2228
+ visnet(nodes=nodes2, edges=edges2, network_title='Large Network', browserView=True, writeHTML='test_large.html', min_default_node_size=1, min_default_edge_width=1, maximum_display=100)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: visnetmap
3
- Version: 0.1.3.6
3
+ Version: 0.2.1
4
4
  Summary: A short description of my package
5
5
  Author-email: "Peng (Atsaniik) Yang" <peng.yang@uef.fi>
6
6
  Project-URL: Homepage, https://github.com/Atsaniik/visnetmap
File without changes
File without changes
File without changes