Opened 5 years ago
Closed 5 years ago
#18249 closed enhancement (fixed)
[PATCH RFC] Allow unknown xml attributes to be added as a tag
Reported by: | taylor.smock | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | 19.10 |
Component: | Core | Version: | |
Keywords: | Cc: |
Description
My particular use case is Facebook's MapWithAI service. Their servers may return xml files like so:
<way action="modify" id="-2114083756721700337" orig_id="-1029494953913841" visible="true"> <nd ref="-2305936403060247"/> <nd ref="-450099595746256"/> <nd ref="-2326715710903465"/> <nd ref="-2310464635880342"/> <nd ref="-2091438534482471"/> <nd ref="-1071999706318230"/> <nd ref="-460847767791073"/> <nd ref="-2230168587232362"/> <nd ref="-600440557143555"/> <nd ref="-309740959722060"/> <tag k="highway" v="residential"/> <tag k="source" v="digitalglobe"/> </way>
(original url was https://www.facebook.com/maps/ml_roads?conflate_with_osm=true&theme=ml_road_vector&collaborator=josm&token=ASb3N5o9HbX8QWn8G_NtHIRQaYv3nuG2r7_f3vnGld3KhZNCxg57IsaQyssIaEw5rfRNsPpMwg4TsnrSJtIJms5m&hash=ASawRla3rBcwEjY4HIY&result_type=road_building_vector_xml&bbox=110.6099061,1.0411592,110.6168029,1.0484213 , but was edited for briefness)
It would be nice to be able to know what the additional attributes are (in this case orig_id
).
Attachments (3)
Change History (8)
by , 5 years ago
Attachment: | 18249.patch added |
---|
comment:2 by , 5 years ago
Looks ok. Can you please provide a unit test? This piece of code is critical.
follow-up: 4 comment:3 by , 5 years ago
I'll do that -- I didn't want to write a unit test until I knew that it wouldn't be changing.
For example, instead of adding tags, we change the primitive to use a map that holds the attributes, so getUniqueId()
would call attributes.get("id")
, and add a new method (along the lines of getAttribute(String attribute)
).
As another example, would it be a good idea to have a flag to add all attributes to tags as well?
comment:4 by , 5 years ago
Replying to taylor.smock:
For example, instead of adding tags, we change the primitive to use a map that holds the attributes, so
getUniqueId()
would callattributes.get("id")
I fear that it would be terrific in terms of allocated memory for large data sets.
by , 5 years ago
Attachment: | 18249.3.patch added |
---|
Remove switch statement in favor of directly calling each required attribute, to ensure that errors are thrown.
Allow unknown xml attributes to be added as tags, if requested. May have some slowdowns (since it now has a for loop with a switch).