mirror of
https://github.com/permissionlesstech/georelays.git
synced 2026-07-24 21:45:19 +00:00
Fix automated relay map generation (#12)
This commit is contained in:
@@ -31,11 +31,13 @@ jobs:
|
|||||||
- name: Install Python dependencies
|
- name: Install Python dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install matplotlib pandas numpy folium scipy
|
# Matplotlib 3.11 raises a LinearRing error with Cartopy 0.25.0.
|
||||||
|
# Keep this at the last version known to render all three maps.
|
||||||
|
pip install matplotlib==3.10.9 pandas numpy folium scipy
|
||||||
# Install cartopy and its dependencies
|
# Install cartopy and its dependencies
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y libproj-dev proj-bin proj-data libgeos-dev
|
sudo apt-get install -y libproj-dev proj-bin proj-data libgeos-dev
|
||||||
pip install cartopy
|
pip install cartopy==0.25.0
|
||||||
|
|
||||||
- name: Generate relay maps
|
- name: Generate relay maps
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -198,55 +198,35 @@ def main():
|
|||||||
|
|
||||||
# Ensure the assets directory exists
|
# Ensure the assets directory exists
|
||||||
os.makedirs('assets', exist_ok=True)
|
os.makedirs('assets', exist_ok=True)
|
||||||
|
|
||||||
try:
|
# Read the relay data
|
||||||
# Read the relay data
|
df = pd.read_csv('nostr_relays.csv')
|
||||||
df = pd.read_csv('nostr_relays.csv')
|
|
||||||
|
# Filter out rows with missing or invalid coordinates
|
||||||
# Filter out rows with missing or invalid coordinates
|
df = df.dropna(subset=['Latitude', 'Longitude'])
|
||||||
df = df.dropna(subset=['Latitude', 'Longitude'])
|
|
||||||
|
# Filter out invalid coordinates
|
||||||
# Filter out invalid coordinates
|
df = df[(df['Latitude'] >= -90) & (df['Latitude'] <= 90) &
|
||||||
df = df[(df['Latitude'] >= -90) & (df['Latitude'] <= 90) &
|
(df['Longitude'] >= -180) & (df['Longitude'] <= 180)]
|
||||||
(df['Longitude'] >= -180) & (df['Longitude'] <= 180)]
|
|
||||||
|
# Generate maps. Any failure must propagate so CI cannot commit a partial
|
||||||
# Generate maps
|
# update while reporting a successful workflow.
|
||||||
# 1. Interactive HTML map
|
relay_count_interactive = create_interactive_map(
|
||||||
relay_count_interactive = create_interactive_map(
|
df,
|
||||||
df,
|
'assets/relay_locations_interactive.html'
|
||||||
'assets/relay_locations_interactive.html'
|
)
|
||||||
)
|
relay_count_static = create_static_map(
|
||||||
|
df,
|
||||||
# 2. Static PNG map
|
'assets/relay_locations_static.png'
|
||||||
try:
|
)
|
||||||
relay_count_static = create_static_map(
|
relay_count_heatmap = create_heatmap(
|
||||||
df,
|
df,
|
||||||
'assets/relay_locations_static.png'
|
'assets/relay_locations_heatmap.png'
|
||||||
)
|
)
|
||||||
except Exception as e:
|
|
||||||
print(f"Error creating static map: {e}")
|
print(f"Generated interactive map with {relay_count_interactive} relays")
|
||||||
relay_count_static = 0
|
print(f"Generated static map with {relay_count_static} relays")
|
||||||
|
print(f"Generated heatmap with {relay_count_heatmap} relays")
|
||||||
# 3. Heatmap
|
|
||||||
try:
|
|
||||||
from scipy.ndimage import gaussian_filter
|
|
||||||
relay_count_heatmap = create_heatmap(
|
|
||||||
df,
|
|
||||||
'assets/relay_locations_heatmap.png'
|
|
||||||
)
|
|
||||||
except ImportError:
|
|
||||||
print("Could not create heatmap: scipy not installed")
|
|
||||||
relay_count_heatmap = 0
|
|
||||||
|
|
||||||
# Print summary
|
|
||||||
print(f"Generated interactive map with {relay_count_interactive} relays")
|
|
||||||
if relay_count_static > 0:
|
|
||||||
print(f"Generated static map with {relay_count_static} relays")
|
|
||||||
if relay_count_heatmap > 0:
|
|
||||||
print(f"Generated heatmap with {relay_count_heatmap} relays")
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Error generating relay maps: {e}")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user