-
-
Notifications
You must be signed in to change notification settings - Fork 65
Possibility to add JOSM XML attributes to individual objects #278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is unlikely to get supported because the XML is written by the libosmium library which doesn't support the special JOSM additions to the file format. To support this we'd need to somehow store those extra "action" bits somewhere and make them accessible in the interface. But I believe JOSM can read |
Ah, you're right! Thanks for the suggestion. However, I'm encountering an issue with .osc generation in PyOsmium. If a modified object is original (its version number is 1), it gets a |
That's how the .osc file works. By definition an object with version 1 is always "created", an object with version >1 is always "modified". |
That’s strange. According to the documentation:
So if I modify an existing (version 1) object and it gets a I also checked OSMand, and it uses |
All of this stuff is really not that well documented and the behaviour may well be different in different applications. My understanding is that if you change an object you must give it a new version number. I can not see any difference between |
@joto is correct, pyosmium leaves writing files completely to libosmium. So the feature request needs to go there first. Although it sounds like diff files is the better way to go for you. Closing here as "currently not possible". |
Thanks for the input! The diff would be perfect, but since it adds a tag to existing objects, I can't use it. 😕 |
You can (and in fact, should) simply increase the version before writing your modified data into the diff file. pyosmium doesn't do that automatically for you but you can do it manually. |
Could you please tell me which part should I look at? The only thing I found is a read-only version number upon processing. |
You can change the version like any other attribute when writing out data using the replace function, see Writing data in the user manual. Here is a simple script that increases the version of all objects and writes them out again:
An
Results in the expected modify output:
|
Thanks for the suggestion, but I use Input (
Osmium script: import osmium
with osmium.BackReferenceWriter("out.osc", ref_src="in.opl", overwrite=True, remove_tags=False) as writer:
for o in osmium.FileProcessor("in.opl") \
.with_areas() \
.with_filter(osmium.filter.GeoInterfaceFilter()) \
.with_filter(osmium.filter.EntityFilter(osmium.osm.NODE | osmium.osm.WAY | osmium.osm.RELATION)):
o.replace(version=o.version + 1)
writer.add(o) Output ( <?xml version='1.0' encoding='UTF-8'?>
<osmChange version="0.6" generator="libosmium/2.20.0">
<create>
<node id="1" version="1" lat="13" lon="45"/>
</create>
</osmChange> |
I've edited my previous comment to add an example. I'm curious if this is something that can be solved out of the box. |
The replace function returns a copy of the object. You have to write out the copy. Change your code as follows:
and it should work with the backreference writer as well. |
*facepalm* Thanks! Case closed. |
My typical workflow is as follows:
To make the history viewer work in step 3 and display the upload button in step 4, the modified objects from step 2 need to include the
action=modify
attribute, as described in the JOSM file format documentation.Is this functionality currently supported in the latest release? If not, could you please consider adding it?
Additionally, I am unsure if this works with formats other than XML. However, since XML is human-readable, I believe it would suffice for most use cases.
JOSM r19293
osmium 4.0.2 (Python 3.12.8)
The text was updated successfully, but these errors were encountered: