Comments (3)
Yes, I'm aware of this problem.
I just pushed a quickfix for this here: 75381db
It will sort the attributes each time if there is more than one attribute.
Now, this has a small performance penalty and it works only with python2. I'll try to think for a better solution. Of course, ideas are welcome.
from gpxpy.
how about using OrderedDict? It exists since Python 2.7
--- a/gpxpy/gpx.py
+++ b/gpxpy/gpx.py
@@ -2582,11 +2582,11 @@ class GPX:
self.creator = 'gpx.py -- https://github.com/tkrajina/gpxpy'
v = version.replace('.', '/')
-
xml_attributes = {
-
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
-
'xmlns': 'http://www.topografix.com/GPX/%s' % v,
-
'xsi:schemaLocation': 'http://www.topografix.com/GPX/%s http://www.topografix.com/GPX/%s/gpx.xsd' % (v, v)
-
}
-
xml_attributes = mod_collections.OrderedDict([
-
('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'),
-
('xmlns', 'http://www.topografix.com/GPX/%s' % v),
-
('xsi:schemaLocation', 'http://www.topografix.com/GPX/%s http://www.topografix.com/GPX/%s/gpx.xsd' % (v, v))
-
]) content = mod_gpxfield.gpx_fields_to_xml(self, 'gpx', version, custom_attributes=xml_attributes)
from gpxpy.
Yes, it makes sense. Although, now that I look at it, the custom_attributes
named parameter is used only once, so even the dict.sort()
wouldn't be such a problem. But, on the other side, there is no sort()
for {}.items()
in py3. And if OrderedDict
is the only reason to break py2.6, I'll just not sort but expect the attrs to be a list:
...and it will work everywhere.
Thanks for your help!
from gpxpy.
Related Issues (20)
- Uphill Downhill are not accurate HOT 2
- GPX parsing not working with extension HOT 2
- NameError: free variable 'from_start_to_end' referenced before assignment in enclosing scope HOT 1
- Setup.py method is being deprecated in python package
- Confusion!
- Wrong distance? 10.4 km instead of 7.6 km HOT 1
- Save nsmap of GPX in GPXTrack, GPXTrackSegment and GPXTrackPoint
- GPX track all messed up HOT 1
- Tag a release to ship improvements since 1.5.0 HOT 1
- TypeError in gpxfield since 1.6.0 release HOT 1
- Changes Backported To 1.5.0 HOT 2
- Typo in __repr__ of SimpleTZ HOT 1
- [newbie] Wrong return type on GPXTrackSegment.get_duration() HOT 1
- create CI testing scripts HOT 1
- feature request: include distance_from_start in NearestLocationsData class HOT 1
- Is Header malformed
- Check for GPX root node on parse HOT 1
- Custom attributes in `to_xml` not escaped properly
- Wrong type annotation for radians in method elevation angle?
- to_xml removes metadata extensions without the name tag present HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gpxpy.