Move CLI code out of qsomap.py

qsomap.py is now a library with no own functionality.
This commit is contained in:
Thomas Kolb 2023-11-13 20:02:29 +01:00
parent bdd29c2fa6
commit 6193cf445d
2 changed files with 24 additions and 21 deletions

24
cli.py Executable file
View file

@ -0,0 +1,24 @@
#!/usr/bin/env python3
import sys
import qsomap
import argparse
parser = argparse.ArgumentParser(
description="Render an azimuthal equidistant map of the world " +
"centered on the given point")
parser.add_argument(metavar='ref-lat', type=float, dest='ref_lat',
help='Reference Latitude')
parser.add_argument(metavar='ref-lon', type=float, dest='ref_lon',
help='Reference Longitude')
parser.add_argument('-o', '--output-file', type=argparse.FileType('w'),
help='The output SVG file (default: print to stdout)',
default=sys.stdout)
parser.add_argument('-a', '--adif', type=argparse.FileType('r'),
required=False,
help='ADIF log to load and display on the map')
args = parser.parse_args()
qsomap.render(args.ref_lat, args.ref_lon, args.output_file, args.adif)

21
qsomap.py Executable file → Normal file
View file

@ -9,7 +9,6 @@ import matplotlib.pyplot as pp
from matplotlib.colors import hsv_to_rgb from matplotlib.colors import hsv_to_rgb
import json import json
import random import random
import argparse
LABEL_MIN_FONT_SIZE = 2 LABEL_MIN_FONT_SIZE = 2
LABEL_MAX_FONT_SIZE = 40 LABEL_MAX_FONT_SIZE = 40
@ -615,23 +614,3 @@ def render(ref_lat, ref_lon, output_stream, adif_stream):
pp.show() pp.show()
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Render an azimuthal equidistant map of the world " +
"centered on the given point")
parser.add_argument(metavar='ref-lat', type=float, dest='ref_lat',
help='Reference Latitude')
parser.add_argument(metavar='ref-lon', type=float, dest='ref_lon',
help='Reference Longitude')
parser.add_argument('-o', '--output-file', type=argparse.FileType('w'),
help='The output SVG file (default: print to stdout)',
default=sys.stdout)
parser.add_argument('-a', '--adif', type=argparse.FileType('r'),
required=False,
help='ADIF log to load and display on the map')
args = parser.parse_args()
render(args.ref_lat, args.ref_lon, args.output_file, args.adif)