Modify

Opened 7 weeks ago

Closed 7 weeks 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)

18249.patch (4.5 KB) - added by taylor.smock 7 weeks ago.
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).
18249.1.patch (4.6 KB) - added by taylor.smock 7 weeks ago.
Add flag to avoid parsing uid and user twice.
18249.3.patch (9.7 KB) - added by taylor.smock 7 weeks ago.
Remove switch statement in favor of directly calling each required attribute, to ensure that errors are thrown.

Download all attachments as: .zip

Change History (8)

Changed 7 weeks ago by taylor.smock

Attachment: 18249.patch added

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).

comment:1 Changed 7 weeks ago by Don-vip

Milestone: 19.10

The user will be parsed twice with the patch.

Changed 7 weeks ago by taylor.smock

Attachment: 18249.1.patch added

Add flag to avoid parsing uid and user twice.

comment:2 Changed 7 weeks ago by Don-vip

Looks ok. Can you please provide a unit test? This piece of code is critical.

comment:3 Changed 7 weeks ago by taylor.smock

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 in reply to:  3 Changed 7 weeks ago by Don-vip

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 call attributes.get("id")

I fear that it would be terrific in terms of allocated memory for large data sets.

Changed 7 weeks ago by taylor.smock

Attachment: 18249.3.patch added

Remove switch statement in favor of directly calling each required attribute, to ensure that errors are thrown.

comment:5 Changed 7 weeks ago by Don-vip

Resolution: fixed
Status: newclosed

In 15470/josm:

fix #18249 - Allow unknown xml attributes to be added as tags (patch by taylor.smock)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.