Modify

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#12370 closed enhancement (fixed)

[patch] adapted osm file filter to other file types

Reported by: kolesar Owned by: team
Priority: normal Milestone: 16.02
Component: Core Version:
Keywords: Cc:

Description

There was a noticable difference between handling .osm files and other file types in open/save dialogs. Dropdown list contained these items:

    [...]
    GPX Files (*.gpx, *.gpx.gz, *.bz2)
    OSM Server Files (*.osm *.xml)
    OSM Server Files gpx compressed (*.osm.gz)
    OSM Server Files bzip2 compressed (*.osm.bz2 *.osm.bz)
    OSM Server Files zip compressed (*.osm.zip)
    OsmChange File (*.osc, *.osc.gz, *.osc.bz2)
    [...]

It was very confusing that some file types were listed with compressed suffixes except OSM files where different compression suffixes had separate entries in the list. My proposal:

    [...]
    GPX Files (*.gpx, *.gpx.gz, *.bz2)
    OSM Server Files (*.osm, *.xml, *.osm.gz, *.osm.bz2, *.osm.bz, *.osm.zip)
    OsmChange File (*.osc, *.osc.gz, *.osc.bz2)
    [...]

Attached patch.

Attachments (4)

OsmFileFilter.patch (7.2 KB) - added by kolesar 3 years ago.
NonDefaultFileExtension.patch (2.4 KB) - added by kolesar 3 years ago.
OsmFileFilter.2.patch (11.9 KB) - added by kolesar 3 years ago.
OsmFileFilter.3.patch (11.9 KB) - added by kolesar 3 years ago.

Download all attachments as: .zip

Change History (29)

Changed 3 years ago by kolesar

Attachment: OsmFileFilter.patch added

comment:1 Changed 3 years ago by bastiK

This indicates, that we can export as zip file, which is not the case. Also the idea is that you can just enter the file name without file extension, click the "bzip2 compressed" item and JOSM will add the correct file extension (avoiding typos).

Also it is a simpler concept to have one output format per line, rather than auto-detect from the entered file extension (without further confirmation or feedback). I fear some users might not understand this.

For the "Open" dialog, it shouldn't matter, though.

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

comment:2 in reply to:  1 ; Changed 3 years ago by kolesar

Replying to bastiK:

This indicates, that we can export as zip file, which is not the case. Also the idea is that you can just enter the file name without file extension, click the "bzip2 compressed" item and JOSM will add the correct file extension (avoiding typos).

Also it is a simpler concept to have one output format per line, rather than auto-detect from the entered file extension (without further confirmation or feedback). I fear some users might not understand this.

You are right, saving .osm.zip is not implemented. Then why does JOSM read this format? Probably some tools create such files. Is this special case needed to be listed in the dialog?

Simple solution to hide .osm.zip at saving: delete *.osm.zip from displayed extensions (not from real filter), this way users still see *.osm.zip in filtered list and able to open them, while open and save dialog does not list them.

Another solution: using different file filter for saving. In this case open dialog can list *.osm.zip while save does not.

I understand ideas behind keeping one item for one output format but there are several arguments against:

  • saving gpx files has only one item, listing uncompressed and compressed variants
  • uncompressed osm files had two variants (*.osm *.xml)
  • bzipped osm files had two variants (*.osm.bz2 *.osm.bz)

Current situation may be more confusing for users than proposed.

If user needs to save in a compressed format regulary, since [9461] can set default extension to compressed.

comment:3 in reply to:  2 ; Changed 3 years ago by bastiK

Replying to kolesar:

Another solution: using different file filter for saving. In this case open dialog can list *.osm.zip while save does not.

I understand ideas behind keeping one item for one output format but there are several arguments against:

  • saving gpx files has only one item, listing uncompressed and compressed variants
  • uncompressed osm files had two variants (*.osm *.xml)
  • bzipped osm files had two variants (*.osm.bz2 *.osm.bz)

Current situation may be more confusing for users than proposed.

In open file dialog, we can list all related formats in one line, as you suggest. Then, in file save dialog, we should simplify (*.osm,*.xml) to just (*.osm) in order to avoid confusion (but still accept .xml file extension if entered as file name). Similarly, just write "(osm.bz2)" instead of "(*.osm.bz2 *.osm.bz)" in file save dialog.

For consistency, gpx, gpx.bz2, etc. should be split like it is done for .osm.

If user needs to save in a compressed format regulary, since [9461] can set default extension to compressed.

I'm aiming for user friendliness - advanced preference is the exact opposite of that. :)

comment:4 in reply to:  3 ; Changed 3 years ago by kolesar

Replying to bastiK:

In open file dialog, we can list all related formats in one line, as you suggest. Then, in file save dialog, we should simplify (*.osm,*.xml) to just (*.osm) in order to avoid confusion (but still accept .xml file extension if entered as file name). Similarly, just write "(osm.bz2)" instead of "(*.osm.bz2 *.osm.bz)" in file save dialog.

For consistency, gpx, gpx.bz2, etc. should be split like it is done for .osm.

Combining at load and splitting at save can also be confusing.

I did not like file filter in save dialog when working directory had both .osm and .osm.gz files. It hides osm files that have different compression.

Check open/save dialogs of GIMP. It works the same way I have suggested. Filter list contains entries like JPEG image (*.jpg, *.jpeg, *.jpe) for both open and save.

Changed 3 years ago by kolesar

comment:5 Changed 3 years ago by kolesar

Attached NonDefaultFileExtension.patch that is needed to work with #12369 (default extension for saving files read from preferences). If I set osm.gz as default save extension, save fails with message No Exporter found! Nothing saved..

SaveActionBase.doInternalSave can't find the appropriate FileExporter. First extension (= defaultExtension) in combined OSM file filter starts with osm, ExtensionFileFilter looks given extension in all exporters but it checks only defaultExtension(). I have extended this method with a second lookup when accept() is called for every filter.

I chose this way instead simply change the existing single loop because if the same extension is used in more than one exporter, the exporter matching defaultExtension should be selected.

Modification of SaveActionBase was needed to apply the given extension, overriding default of FileExporter.

comment:6 in reply to:  4 ; Changed 3 years ago by bastiK

Replying to kolesar:

Combining at load and splitting at save can also be confusing.

I don't find it confusing, but if you think so, we can split it always.

I did not like file filter in save dialog when working directory had both .osm and .osm.gz files. It hides osm files that have different compression.

It is never perfect. Maybe an entry "all formats" at the bottom (not default) like in file open?

Check open/save dialogs of GIMP. It works the same way I have suggested. Filter list contains entries like JPEG image (*.jpg, *.jpeg, *.jpe) for both open and save.

I don't mind having multiple aliases of a single format listed in one entry in file save dialog, but you mentioned it as a problem, so I suggested a solution. By the way, Gimp also has .xcf and compression formats .xcf.bz2 and .xcf.gz as separate entries.

comment:7 Changed 3 years ago by bastiK

In 9466/josm:

see #12370, see #12369 - fix problems with default file extension (patch by kolesar)
[patch] adapted osm file filter to other file types

comment:8 in reply to:  6 ; Changed 3 years ago by kolesar

Replying to bastiK:

Replying to kolesar:

Combining at load and splitting at save can also be confusing.

I don't find it confusing, but if you think so, we can split it always.

I did not like file filter in save dialog when working directory had both .osm and .osm.gz files. It hides osm files that have different compression.

It is never perfect. Maybe an entry "all formats" at the bottom (not default) like in file open?

Check open/save dialogs of GIMP. It works the same way I have suggested. Filter list contains entries like JPEG image (*.jpg, *.jpeg, *.jpe) for both open and save.

I don't mind having multiple aliases of a single format listed in one entry in file save dialog, but you mentioned it as a problem, so I suggested a solution. By the way, Gimp also has .xcf and compression formats .xcf.bz2 and .xcf.gz as separate entries.

You are right, Gimp is also inconsistent. Save As dialog contains only XCF variants, you have to go back and select Export if you want another file format. Export lists several extensions per row, for example the JPEGs mentioner earlier.

Extensions grouped in one row do not mean the same file content. There is GIMP compressed XJT image (*.xjt, *.xjtgz, *.xjtbz2) that works the same way as saving GPX in JOSM. Content compression depends on extension.

I think it's more friendly for a user to have a single line for a format. If list of formats grow too large (while height of dropdown list is limited), it's difficult to overview the available options.

File type and file compression are different dimensions. In the dropdown of file types I expect unique rows for each types.

comment:9 Changed 3 years ago by bastiK

@others: comments?

comment:10 Changed 3 years ago by stoecker

I think the splited lines are better (with the changes mentioned in comment:3). But I also find the fact disturbing in many applications, that this restricts the displayed files with different compression. Can we make one combined exporter, which includes all types and only display an individual part/default? Then add that exporter multiple times with different defaults/texts?

That way we'd have a combination of both solutions.

comment:11 Changed 3 years ago by simon04

While working on #7058, I also came across this "asymmetry" between OSM and other file types. I left it unchanged since it has been in use for several years w/o problems and it's difficult to make the compression feature available in an easy manner.

Btw: Inkscape provides 4 SVG types – (uncompressed|compressed) (plain|Inkscape) SVG

comment:12 in reply to:  8 Changed 3 years ago by bastiK

Replying to kolesar:

I think it's more friendly for a user to have a single line for a format. If list of formats grow too large (while height of dropdown list is limited), it's difficult to overview the available options.

File type and file compression are different dimensions. In the dropdown of file types I expect unique rows for each types.

Okay, I think we exchanged all arguments and agree to disagree. :)
You can update the patch using suggestions by the team or close the ticket and leave it at that.

comment:13 Changed 3 years ago by kolesar

I will update patch using suggestions.

comment:14 Changed 3 years ago by bastiK

Another idea: Change

OSM Server Files (*.osm *.xml)

to

OSM Server Files (*.osm ...)

and make it accept all .osm related file-types (.osm, .osm.gz, .osm.bz2, ...). Keep the other entries. Then it looks like you have one entry for each (sub-)type, but in fact the first one covers all.

Changed 3 years ago by kolesar

Attachment: OsmFileFilter.2.patch added

comment:15 Changed 3 years ago by kolesar

New patch creates only one item in Open dialog that accepts all OSM variants:

    OSM Server Files (*.osm)

Save dialog has three rows for OSM files:

    OSM Server Files (*.osm)
    OSM Server Files bzip2 compressed (*.osm.bz2, *.osm.bz)
    OSM Server Files gzip compressed (*.osm.gz)

Each row will list files corresponding the name. *.xml is accepted everywhere and *.osm.zip, *.xml.zip is accepted for opening.

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

comment:16 Changed 3 years ago by bastiK

Thanks!

  • Open dialog should list all supported variants in parentheses. Otherwise there is no indication that JOSM can open a zip- / gzip- / bzip2-compressed osm files.
  • Please make the patch against current subversion trunk, not against previously patched tree.
  • We have a coding style that adds curly brackets for each if, unless it is followed by return (or maybe throw).

Changed 3 years ago by kolesar

Attachment: OsmFileFilter.3.patch added

comment:17 Changed 3 years ago by kolesar

Added compressed extensions to open dialog:

    OSM Server Files (*.osm, *.osm.gz, *.osm.bz2, *.osm.zip, *.xml)

Did not include compressed variants of *.xml, is it right?

Patches were made against trunk, not previously patched tree. I use git mirror that seems to follow subversion quickly. I like git much more than svn. Can I still use git?

Added curly brace after if. Usage was not declared in DevelopersGuide/StyleGuide, now added.

comment:18 in reply to:  17 ; Changed 3 years ago by bastiK

In file save dialog, I see now the filter 'All Formats (*.gpx *.osm *.nmea *jpg ...)'. Firstly, a osm data layer cannot be saved as .nmea or .jpg, so the option should not be there. Secondly, I would prefer the entry 'OSM Server Files (*.osm)' as default, as this is the most natural format for an osm layer and probably most frequently used.

Replying to kolesar:

Added compressed extensions to open dialog:

    OSM Server Files (*.osm, *.osm.gz, *.osm.bz2, *.osm.zip, *.xml)

Did not include compressed variants of *.xml, is it right?

Yes, would be too much.

Patches were made against trunk, not previously patched tree. I use git mirror that seems to follow subversion quickly. I like git much more than svn. Can I still use git?

Your patch was fine, my bad.

Added curly brace after if. Usage was not declared in DevelopersGuide/StyleGuide, now added.

Thanks. We have an ant task "checkstyle", but not sure if this rule is included.

comment:19 in reply to:  18 Changed 3 years ago by Don-vip

Replying to bastiK:

Thanks. We have an ant task "checkstyle", but not sure if this rule is included.

It is not because it triggered a LOT of warnings. I customized the checkstyle config to have something suitable to us. I don't think we can tell Checkstyle "it's ok if next instruction is return or throw".

comment:20 in reply to:  18 ; Changed 3 years ago by kolesar

Replying to bastiK:

In file save dialog, I see now the filter 'All Formats (*.gpx *.osm *.nmea *jpg ...)'. Firstly, a osm data layer cannot be saved as .nmea or .jpg, so the option should not be there. Secondly, I would prefer the entry 'OSM Server Files (*.osm)' as default, as this is the most natural format for an osm layer and probably most frequently used.

Which platform and which file chooser shows "All Formats" in save dialog? I have tested Linux and Windows with and without native option. Only open dialog shows that.

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

comment:21 Changed 3 years ago by bastiK

Resolution: fixed
Status: newclosed

In 9537/josm:

applied #12370 - adapted osm file filter to other file types (patch by kolesar)

comment:22 in reply to:  20 ; Changed 3 years ago by bastiK

Replying to kolesar:

Which platform and which file chooser shows "All Formats" in save dialog? I have tested Linux and Windows with and without native option. Only open dialog shows that.

I still had the advanced option save.extension.osm=osm.gz on, which causes this. Unrelated to the current ticket of course.

comment:23 Changed 3 years ago by bastiK

Milestone: 16.02

comment:24 in reply to:  22 Changed 3 years ago by kolesar

Replying to bastiK:

Replying to kolesar:

Which platform and which file chooser shows "All Formats" in save dialog? I have tested Linux and Windows with and without native option. Only open dialog shows that.

I still had the advanced option save.extension.osm=osm.gz on, which causes this. Unrelated to the current ticket of course.

I also have this option set to osm.gz but "All formats" is not listed on the save dialog. The proper compression option is selected automatically: OSM Server Files gzip compressed (*.osm.gz).

comment:25 Changed 3 years ago by bastiK

Now it works. Probably a typo in the preference value as with unknown extension it will show "All formats".

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.