Closed gucharbon closed 4 years ago
The problem here is that -- it's complicated. Especially now with extensions. I mean, when exactly do you consider two GPX tracks to be identical? Let's say both have the same tracks, segments, points, waypoints and routes. But one has an additional extension. Are they equal tracks -- yes. Are they equal gpx objects. Nope. What if extensions contain the same objects but extension prefixes are different? And so on...
Consider also that, in order to check equality (with extensions) -- you need to not only check all the usual object fields, but also traverse the extension(s) DOM elements. And that will be slow.
So, my suggestion -- you decide what equals(gpx1, gpx2) means for you. And implement it.
What I'd be interested in merging is an algorithm which finds if gpx1
and gpx2
are similar (even when not having the same points). For example, if two different GPX devices record the same track. But that's another story.
I'm using gpxpy==1.3.4 with Python 3.6.1 in Jupyter Notebook.
I use gpxpy to load data from GPX files.
I wanted to compare two GPX objects to see if they were equal, but I found out that creating two GPX objects from same file result in False when testing equality:
g1 = load_gpx("./data/demo.gpx")
g2 = load_gpx("./data/demo.gpx")
g1 == g2
=> FalseIn order to compare two objects I use
g1.to_xml() == g2.to_xml()
I tried to search in issues, but I did not found one related to equality. Could two gpx objects be different if they generate an identitcal string using
.to_xml()
method ? If no, what are the reasons for not overriding the default equality test ?Thanks for your work anyways !