Opened 11 years ago

Closed 11 years ago

#4288 closed defect (fixed)

[PATCH] image files as parameters when starting JOSM leads to IOException

Reported by: Cobra Owned by: team
Priority: normal Milestone:
Component: Core Version: latest
Keywords: Cc: bomm


JOSM can open .osm and .gpx files directly when starting it and passing the file names as paramter, but when trying the same trick with geotagged images leads to this - one error window and one exception per image, all alike:

java -jar josm-latest.jar 201001*.gpx IMG_*.JPG

(...) Could not import 'IMG_2582.JPG'.
	at org.openstreetmap.josm.actions.OpenFileAction.openFile(
	at org.openstreetmap.josm.Main.downloadFromParamString(
	at org.openstreetmap.josm.Main.postConstructorProcessCmdLine(
	at org.openstreetmap.josm.gui.MainApplication$
	at java.awt.event.InvocationEvent.dispatch(
	at java.awt.EventQueue.dispatchEvent(
	at java.awt.EventDispatchThread.pumpOneEventForFilters(
	at java.awt.EventDispatchThread.pumpEventsForFilter(
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(
	at java.awt.EventDispatchThread.pumpEvents(
	at java.awt.EventDispatchThread.pumpEvents(

josm revision is 2729

Attachments (1)

patch-4288.diff (12.7 KB) - added by bomm 11 years ago.
patch to process a list of files specified as command line params

Download all attachments as: .zip

Change History (5)

comment:1 Changed 11 years ago by bomm

Cc: bomm added
Summary: image files as parameters when starting JOSM leads to IOExceptionimage files as parameters when starting JOSM leads to IOException [analyzed]

according to the comments in, a subclass has to override only one of
importData(File file) and importData(List<File> files) overrides isBatchImporter() to return true and overrides importData(List<File> files) but not importData(File file) unconditionally calls importData(File file) for every importer that accepts the current file. This leads to the error messages.

One solution would be to require overriding/implementing importData(File file) even for batch importers.
For this would mean something like this:

public void importData(File file) throws IOException, IllegalDataException {

LinkedList<File> files = new LinkedList<File>();
GeoImageLayer.create(files, gpx);


but this is probably not correct because the GeoImageLayer should be created from all images not from a single file.

The main problem seems to be that postConstructorProcessCmdLine(Map<String, Collection<String>> args) in calls downloadFromParamString(false, s) individually for every single file which calls OpenFileAction.openFile(f). The current implementation works well when a directory name is specified instead of a set of file names.

If specifying image files on the command line is required, all file names must be added to a list before actually processing them. Unfortunately does not know that a file will be processed by a batch importer. Maybe a batch importer can handle this itself if it gets notified again after the last file.
The importer could add all files to a list as long as it accepts the file. When the importer is called with a file that is not accepted, it could process all remembered files. The importers would need a notification after the last file of the command line to process all pending files.

With this solution the JpgImporter would create the GeoImageLayer either when a a file with a different extension is specified after a set of JPEG files or when the end of the command line is reached.
If the batch importerts transparently batch their files, it might no longer be necessary to distinguish beween single-file importers and batch importers.

comment:2 Changed 11 years ago by bastiK

Possible, but I think there is an easier way to do it:

Collect all files from the command line into a list and then run OpenFileAction on it.

Changed 11 years ago by bomm

Attachment: patch-4288.diff added

patch to process a list of files specified as command line params

comment:3 Changed 11 years ago by bomm

Summary: image files as parameters when starting JOSM leads to IOException [analyzed][PATCH] image files as parameters when starting JOSM leads to IOException

uploaded a patch

comment:4 Changed 11 years ago by stoecker

Resolution: fixed
Status: newclosed

(In [2798]) fix commandline file loading - closes #4288 - patch by bomm

Modify Ticket

Change Properties
Set your email in Preferences
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.