From a9cdc30a512b5db894039beaff9ca2955b886af3 Mon Sep 17 00:00:00 2001 From: Joerg Schultze-Lutter Date: Sat, 13 Apr 2024 12:31:11 +0200 Subject: [PATCH] added posmsg location image, updates to airport/repeater databases, code cleanup --- docs/DEPENDENCIES.md | 21 +----- requirements.txt | 3 + src/airport_data_modules.py | 9 ++- src/email_modules.py | 123 +++++++++++++++++++++++++++++++--- src/geo_conversion_modules.py | 16 +++-- src/mpad_config.py | 10 ++- src/parser_test.py | 52 +++++++++++++- src/repeater_modules.py | 23 ++++--- src/skyfield_modules.py | 22 ++++-- src/staticmap.py | 95 ++++++++++++++++++++++++++ 10 files changed, 316 insertions(+), 58 deletions(-) create mode 100644 src/staticmap.py diff --git a/docs/DEPENDENCIES.md b/docs/DEPENDENCIES.md index 0d18fef..3742987 100644 --- a/docs/DEPENDENCIES.md +++ b/docs/DEPENDENCIES.md @@ -2,27 +2,12 @@ ## Python Library Dependencies -The following Python packages need to be installed (see also [requirements.txt](../requirements.txt)): - -- [activesoup](https://github.com/jelford/activesoup) required: version 0.3.0 or greater -- [apscheduler](https://github.com/agronholm/apscheduler) -- [aprslib](https://github.com/rossengeorgiev/aprs-python) -- [beautifulsoup4](https://www.crummy.com/software/BeautifulSoup/) -- [expiringdict](https://pypi.org/project/expiringdict/) -- [geopy](https://github.com/geopy/geopy) -- [iso3166](https://github.com/deactivated/python-iso3166) -- [maidenhead](https://github.com/space-physics/maidenhead) -- [pymgrs](https://github.com/aydink/pymgrs) Note: this is __not__ a pip package; download the mgrs.py file and save it in the src directory -- [requests](https://github.com/psf/requests) -- [skyfield](https://github.com/skyfielders/python-skyfield) -- [timezonefinder](https://github.com/MrMinimal64/timezonefinder) -- [unidecode](https://github.com/avian2/unidecode) -- [us](https://github.com/unitedstates/python-us) -- [utm](https://github.com/Turbo87/utm) -- [xmltodict](https://github.com/martinblech/xmltodict) +All dependencies are included in [requirements.txt](../requirements.txt). Install via ```pip install -r requirements.txt``` If you install MPAD and its components on a Raspberry Pi, the skyfield package requires you to install ```apt-get install libatlas-base-dev``` as a separate dependency. +Dependent on your OS' flavor, you may be required to install the following additional packages: ```apt-get install libgeos-dev libopenjp2-7``` + ## API Dependencies - [aprs.fi](https://aprs.fi/page/api) - thank you Hessu! diff --git a/requirements.txt b/requirements.txt index e9cc12a..12b504f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,3 +13,6 @@ unidecode>=1.3.2 us>=2.0.2 utm>=0.7.0 xmltodict>=0.12.0 +pillow<10.0.0 +py-staticmaps==0.4.0 +mgrs>=1.4.6 diff --git a/src/airport_data_modules.py b/src/airport_data_modules.py index 1e373e6..3539c42 100644 --- a/src/airport_data_modules.py +++ b/src/airport_data_modules.py @@ -26,6 +26,7 @@ import math import logging from utility_modules import check_if_file_exists, build_full_pathname +from mpad_config import mpad_airport_stations_filename # icao https://www.aviationweather.gov/docs/metar/stations.txt @@ -36,7 +37,7 @@ def read_local_airport_data_file( - airport_stations_filename: str = "airport_stations.txt", + airport_stations_filename: str = mpad_airport_stations_filename, ): """ Imports the ICAO/IATA data from a local file. Creates dictionaries for @@ -47,7 +48,6 @@ def read_local_airport_data_file( airport_stations_filename : 'str' local file that is to be parsed. File format: see https://www.aviationweather.gov/docs/metar/stations.txt - default filename: "airport_stations.txt" Returns ======= @@ -326,7 +326,7 @@ def validate_icao(icao_code: str): def update_local_airport_stations_file( - airport_stations_filename: str = "airport_stations.txt", + airport_stations_filename: str = mpad_airport_stations_filename, ): """ Imports the ICAO/IATA data from the web and saves it to a local file. @@ -336,7 +336,6 @@ def update_local_airport_stations_file( airport_stations_filename : 'str' This local file will hold the content from https://www.aviationweather.gov/docs/metar/stations.txt. - Default filename is "airport_stations.txt" Returns ======= @@ -345,7 +344,7 @@ def update_local_airport_stations_file( """ # This is the fixed name of the URL Source that we are going to download - file_url = "https://www.aviationweather.gov/docs/metar/stations.txt" + file_url = "https://weather.ral.ucar.edu/surface/stations.txt" success: bool = False absolute_path_filename = build_full_pathname(file_name=airport_stations_filename) diff --git a/src/email_modules.py b/src/email_modules.py index 5c7407f..f47e6b5 100644 --- a/src/email_modules.py +++ b/src/email_modules.py @@ -23,6 +23,7 @@ import smtplib import imaplib from email.message import EmailMessage +from email.utils import make_msgid import re import datetime import mpad_config @@ -32,6 +33,7 @@ convert_latlon_to_utm, convert_latlon_to_mgrs, ) +from staticmap import render_png_map from utility_modules import read_program_config logging.basicConfig( @@ -39,8 +41,11 @@ ) logger = logging.getLogger(__name__) -# The following two variables define the templates for the outgoing email -# The first one is simple plain text whereas the second one is HTML +# The following three variables define the templates for the outgoing email +# Template 1 = plain text (also used as fallback format) +# Templates 2 and 3 = html data with/without image with user's position +# template without user's position is only used in case +# we were unable to generate the image # # YES - I KNOW. Normal people would import this from a file. Welcome to Team Different. @@ -71,7 +76,7 @@ Proudly made in the district of Holzminden, Lower Saxony, Germany. 73 de DF1JSL """ -html_template = """\ +html_template_without_image = """\

Automated email - please do not respond

APRS position data for REPLACE_MESSAGECALLSIGN on the Internet: