Modify

Opened 3 years ago

Last modified 3 years ago

#21663 new enhancement

[PATCH] Keep changeset tags when write to file.

Reported by: javiersanp Owned by: team
Priority: normal Milestone:
Component: Core Version:
Keywords: changeset Cc:

Description (last modified by Don-vip)

Currently Josm suport reading of changeset tags in OSM XML files. See this file, for example: https://github.com/OSM-es/catastro-import/raw/master/38024/u00210.osm.gz

It includes this change set tags:

<?xml version='1.0' encoding='UTF-8'?>
<osm version='0.6' generator='CatAtom2Osm 1.3.7'>
<changeset>
  <tag k="comment" v="#Spanish_Cadastre_Buildings_Import 38024 Los Llanos de Aridane u00210"/>
  <tag k="generator" v="CatAtom2Osm 1.3.7"/>
  <tag k="url" v="https://wiki.openstreetmap.org/wiki/Spanish_Cadastre/Buildings_Import"/>
  <tag k="source:date" v="2021-09-11"/>
  <tag k="source" v="Direcci&#243;n General del Catastro"/>
  <tag k="type" v="import"/>
</changeset>
<node...

These tags appears correctly in the preferences tab of the upload to OSM dialog.

The problem is that the changeset tags are ommited when writing to a OSM file back again (Ctrl+S).

<?xml version='1.0' encoding='UTF-8'?>
<osm version='0.6' generator='JOSM'>
  <node...

The changeset tags are essential during an import process. There are import processes that requires users to manually review each file in Josm before upload it. With the current changeset tags in the file, the upload is correcty taged and the user don't have to deal with this. Exceptionally, this process could take more time than expected so the user writes the file to disk with his changes to continue editing later. This will ruin the changeset tags and will require that the user write them in the upload dialog.

The propossed solution is to change the code to keep current <changeset> section when writing to a file (.osm or .osm.gz).

Attachments (1)

Captura de pantalla de 2021-12-20 21-15-58.png (349.7 KB ) - added by anonymous 3 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 by Don-vip, 3 years ago

Description: modified (diff)

comment:2 by stoecker, 3 years ago

Hmm. But we do not really support loading changeset files. We simply load it as a OSM-data file, as the format is similar. All the other semantics of the changeset file aren't guaranteed to be correct. I'd think that adding special code to keep the changeset tag will result in a number of strange issues in the later processing stages of such files.

JOSM isn't really the correct tool to process such files.

comment:3 by anonymous, 3 years ago

Sorry but I think I have not been able to explain myself clearly.

1) I'm NOT speaking of OsmChange files. The example file I give in the url IS a OSM XML file. If you download it, open it in JOSM and save in another file, both files have exactly the same structure. The only difference between them is the numbering of the nodes id and the lack of changeset section.

2) JOSM already have code that loads the changeset tags from the file. The demostration is that all the changeset tags contained in the file are automatically filled in the Preferences Tab of the Upload to Osm Dialog when Expert Mode is on (attached screenshot).

See addHashTagsFromDataSet in https://github.com/JOSM/josm/blob/master/src/org/openstreetmap/josm/gui/io/UploadDialogModel.java

This method take the changeset tags from data.model.DataSet.getChangeSetTags

And are loaded in io.AbstractReader.processChangesetAfterParsing

When io.OsmWriter.write recives a DataSet data, it already contains the info I want in the output available in it. I feel confident to write the code for what I want, but not the tests.

The data in those files (OSM files, not OsmChange files) needs to be reviewed and changed in a GUI editor by human editors. That's why JOSM is used. It have been done since 4 years ago. https://wiki.openstreetmap.org/wiki/Spanish_Cadastre/Buildings_import

comment:4 by anonymous, 3 years ago

This change in OsmWriter illustrates what I'm calling for.

    /**
     * Writes the full OSM file for the given data set (header, data sources, osm data, footer).
     * @param data OSM data set
     * @since 12800
     */
    public void write(DataSet data) {
        header(data.getDownloadPolicy(), data.getUploadPolicy(), data.isLocked());
        writeDataSources(data);
        writeChangeset(data);
        writeContent(data);
        footer();
    }


    /**
     * Writes data changeset tags.
     * @param ds data set
     */
    public void writeChangeset(DataSet ds) {
        Map<String, String> cstags = ds.getChangeSetTags();
        if (cstags.size() > 0) {
            out.println("  <changeset>");
            for (Entry<String, String> e : cstags.entrySet()) {
                out.append("    <tag k='").append(XmlWriter.encode(e.getKey()));
                out.append("' v='").append(XmlWriter.encode(e.getValue())).append("' />");
                out.println();
            }
            out.println("  </changeset>");
        }
    }

edit by @gaben: added syntax highlight

Last edited 3 years ago by gaben (previous) (diff)

comment:5 by stoecker, 3 years ago

Summary: Keep changeset tags when write to file.[PATCH] Keep changeset tags when write to file.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain team.
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from team to the specified user.
Next status will be 'needinfo'. The owner will be changed from team to javiersanp.
as duplicate The resolution will be set to duplicate. Next status will be 'closed'. The specified ticket will be cross-referenced with this ticket.
The owner will be changed from team to anonymous. Next status will be 'assigned'.

Add Comment


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