Modify

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)

18249.patch (4.5 KB ) - added by taylor.smock 5 years 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 5 years ago.
Add flag to avoid parsing uid and user twice.
18249.3.patch (9.7 KB ) - added by taylor.smock 5 years 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)

by taylor.smock, 5 years ago

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 by Don-vip, 5 years ago

Milestone: 19.10

The user will be parsed twice with the patch.

by taylor.smock, 5 years ago

Attachment: 18249.1.patch added

Add flag to avoid parsing uid and user twice.

comment:2 by Don-vip, 5 years ago

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

comment:3 by taylor.smock, 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?

in reply to:  3 comment:4 by Don-vip, 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 call attributes.get("id")

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

by taylor.smock, 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.

comment:5 by Don-vip, 5 years ago

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. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.