Open reteptilian opened 4 years ago
It seems to me, as a newcomer in gpxpy, there are problems related to SimpleTZ (such as issue #190). I am not sure what is the best way: mod of SimpleTZ to a fully functional one, use of built-in zoneinfo in python 3.9+ (which is backported to 3.6+), keep SimpleTZ as simple as possible, etc.
Another workaround without the mod of gpxpy is to replace tzinfo.
import gpxpy
import matplotlib.pyplot as plt
import datetime as mod_datetime
def replace_tzinfo(dt):
return dt.replace(tzinfo=mod_datetime.timezone(dt.utcoffset()))
gpx = gpxpy.parse(gpx_file)
for track in gpx.tracks:
for segment in track.segments:
for point in segment.points:
point.time = replace_tzinfo(point.time)
point = gpx.tracks[0].segments[0].points[0]
plt.plot(point.time, point.longitude)
changing every .offset
to .utcoffset
makes the code ˝compile˝, but I'm not sure that's the intended behaviour
I ran into this error trying to plot points with matplotlib (see code below to repro).
I worked around it by modifying
SimpleTZ.__eq__
to do an isinstance check:Here is code to repro. This is with python 3.8.3, gpxpy 1.4.2 and matplotlib 3.2.2.
Stack trace: