Modify

Opened 14 years ago

Closed 8 years ago

#4029 closed enhancement (fixed)

save editing session similar to other GIS app

Reported by: emmanuel.sambale@… Owned by:
Priority: normal Milestone:
Component: Core Version:
Keywords: session Cc: nakor, Pedja

Description

When editing in JOSM, I usually load several gps traces, an OSM file and a some WMS. I often upload/download changes. But when I close JOSM I need to reload all the traces, etc. I want something like a qgis project file to save my editing session for future edits.

Attachments (1)

output.txt (26.1 KB ) - added by Nakor 13 years ago.
Temporary patch

Download all attachments as: .zip

Change History (48)

comment:1 by Nakor, 13 years ago

Cc: nakor added

I was thinking of a similar thing:

When closing JOSM it would save layer names with associated files (or set of files) + current view in a session file.
When loading JOSM layers would be reconstructed from that list and current view would be restored.

comment:2 by Nakor, 13 years ago

Owner: changed from team to Nakor
Status: newassigned

by Nakor, 13 years ago

Attachment: output.txt added

Temporary patch

comment:3 by Nakor, 13 years ago

I attached a temporary patch. It works quite well with Osm and Gpx layer. It fails with Image Layers. Other are not yet implemented.

As explained on the mailing list I am having trouble with getting the layer sometimes a they are created in the background. Just look for FIXME in the code.

comment:4 by anonymous, 13 years ago

There are 2 threads: Event Dispatch Thread (EDT) and the main worker thread (Main.worker). User interaction happens in EDT and to change a GUI element, you must be in EDT. The worker thread is for long processes (e.g. opening a file or removing duplicate nodes in validator) so that the GUI does not freeze. When you are in EDT, you can schedule a task for the worker thread like this:

Main.worker.submit(heavyTask);

When you are in the worker thread you can submit a task for the EDT like this:

SwingUtilities.invokeLater(uiStuff);

In this basic setup you will not know from one thread when a certain task has finished in the other thread. So this does not work:

final Object result = null;
Runnable loader = new Runnable() {
  public void run() {
    result = loadAlot();
  }           
}
Main.worker.submit(loader);
System.err.println(result);

But luckily the second task will not start before the first has finished, so this works:

final Object result = null;
Runnable loader = new Runnable() {
  public void run() {
    result = loadAlot();
  }           
}
Runnable postProcessing = new Runnable() {
  public void run() {
    System.err.println(result);
  }           
}
Main.worker.submit(loader);
Main.worker.submit(postProcessing);

(The reverse is also true, i.e. submitting 2 GUI tasks from the worker, the first finishes first.)

Most of the stuff that you are dealing with happens in the worker thread. This is from OsmImporter:

    protected void importData(InputStream in, File associatedFile) throws IllegalDataException {
        DataSet dataSet = OsmReader.parseDataSet(in, NullProgressMonitor.INSTANCE);
        final OsmDataLayer layer = new OsmDataLayer(dataSet, associatedFile.getName(), associatedFile);
        // FIXME: remove UI stuff from IO subsystem
        //
        Runnable uiStuff = new Runnable() {
            public void run() {
                Main.main.addLayer(layer);
                layer.onPostLoadFromFile();
            }
        };
        if (SwingUtilities.isEventDispatchThread()) {
            uiStuff.run();
        } else {
            SwingUtilities.invokeLater(uiStuff);
        }
    }

As the comment says, it might be a good idea to remove the gui stuff from the importer and move it into the OpenFileAction and SessionImporter (?) respectively.

comment:5 by bastiK, 13 years ago

anonymous is me

comment:6 by bastiK, 13 years ago

Another thing: you should probably move the code for reading and writing the xml data to the individual layer files. After all, there might be all kinds of layers from plugins, like OpenStreetBugs and so on...

comment:7 by Nakor, 13 years ago

Owner: Nakor removed
Status: assignednew

comment:8 by Nakor, 13 years ago

Not sure when I'll have time to look into this again. Anyone is free to implement it using the preliminary work I did if they want.

Last edited 13 years ago by Nakor (previous) (diff)

comment:9 by bastiK, 13 years ago

Summary: save editing session similar to other GIS app[patch - unfinished] save editing session similar to other GIS app

comment:10 by stoecker, 13 years ago

Summary: [patch - unfinished] save editing session similar to other GIS app(patch - unfinished) save editing session similar to other GIS app

comment:11 by bastiK, 12 years ago

In [4668/josm]:

session support (first part, see #4029)

Idea: Save and load the current session, i.e. list of open layers and possibly more.
This change includes only support for reading session files and only for osm-data layers.

session.svg: Public Domain

comment:12 by bastiK, 12 years ago

Here is the general idea:

A .jos file looks like this, and contains meta-data in a human readable format:

<?xml version="1.0" encoding="utf-8"?>
<josm-session version="0.1">
    <layers>
        <layer index="1" name="test.osm" type="osm-data" version="0.1">
            <file>file:/home/user/test.osm</file>
        </layer>
        <layer index="2" name="test2.osm" type="osm-data" version="0.1">
            <file>file:/home/user/test2.osm</file>
        </layer>
    </layers>
</josm-session>

A .joz file is a zip archive that contains at least one .jos file. In this case, data files (.osm, .gpx, .png) can be included in the zip archive, so the file gets self contained.

I can see two primarily use cases:

  • Save work in progress and easily restore the selection of layers, viewport etc. after restarting JOSM.
  • Distribute packages from a website, e.g. for bug-fixing. You could even include map paint styles and presets or ensure that a certain projection is selected.

(Menu entry is currently hidden, unlock with session=true.)

comment:13 by Zverikk, 12 years ago

Don't forget saving current position and zoom :)

comment:14 by bastiK, 12 years ago

In [4685/josm]:

session support (second part: "save as", see #4029)

still osm-data layer is the only implemented layer type

comment:15 by bastiK, 12 years ago

The basic setup for exporting and importing the list of layers is finished. Now we need to add more layer types.

comment:16 by bastiK, 12 years ago

I don't know how to export a marker layer to a file. Normally the markers come from a gpx file, but not always - the user can add additional audio playback bookmarks and so on.

comment:17 by bastiK, 12 years ago

Ticket #7656 has been marked as a duplicate of this ticket.

comment:18 by bastiK, 12 years ago

Summary: (patch - unfinished) save editing session similar to other GIS appsave editing session similar to other GIS app

comment:19 by skyper, 12 years ago

Ticket #7718 has been marked as a duplicate of this ticket.

comment:20 by skyper, 12 years ago

Cc: Pedja added

comment:21 by bastiK, 12 years ago

Ticket #7809 has been marked as a duplicate of this ticket.

comment:22 by bastiK, 12 years ago

Ticket #7810 has been marked as a duplicate of this ticket.

comment:23 by bastiK, 12 years ago

In [5391]:

add session support for imagery layers

comment:24 by bastiK, 12 years ago

In 5501/josm:

add session support for gpx layers (see #4029)

comment:25 by bastiK, 12 years ago

In 5505/josm:

add session support for geoimage layers (see #4029)

comment:26 by bastiK, 11 years ago

In 5551/josm:

see #4029 - remember layer visibility/opacity

comment:27 by anonymous, 11 years ago

Will this also remember other settings, such as suppress errors from TMS layer etc. The reason I ask is that I sometimes uses a OpenSeaMap layer as layover to see existing seamarks rendered. This layer returns errors for each tile without any seamarks as it returns Error 404 instead of a blank tile. I generally deselect the "show errors" on this layer to avoid cluttering the screen with error messages

in reply to:  27 comment:28 by bastiK, 11 years ago

Replying to anonymous:

Will this also remember other settings, such as suppress errors from TMS layer etc. The reason I ask is that I sometimes uses a OpenSeaMap layer as layover to see existing seamarks rendered. This layer returns errors for each tile without any seamarks as it returns Error 404 instead of a blank tile. I generally deselect the "show errors" on this layer to avoid cluttering the screen with error messages

Not yet, but I'll put it on the TODO list.

comment:29 by bastiK, 11 years ago

In 5670/josm:

session: save & restore map position and scale (see #4029)

comment:30 by bastiK, 11 years ago

In 5684/josm:

add session support for marker layers (see #4029)

The data is exported to a separate GPX file that contains one waypoint for each marker.
This is not very elegant, because most of the time, all the info is already contained in the original GPX File.
However, when dealing with audio markers, they can be synchronized, or additional markers are added
at certain playback positions. This info must be retained.
Another complication is, that two or more MarkerLayers can be merged to one.

All these problems are avoided by explicitly exporting the markers to a separate file (as done in this commit).

comment:31 by bastiK, 11 years ago

Most of the changes in [5684] affect only the code for the (unpublished) session feature, so I hope it doesn't introduce any bugs for the release next week. :)

in reply to:  31 comment:32 by Don-vip, 11 years ago

Replying to bastiK:

I hope it doesn't introduce any bugs for the release next week. :)

This particular change, no, but older ones did broke a bunch of plugins (compile errors):

  • globalsat
  • gpxfilter
  • openvisible
  • livegps
  • public_transport

I have myself broken reverter plugin with r5680, fix on the way :)

comment:33 by bastiK, 11 years ago

Ok, plugins updated in [o29222], [o29223].

comment:34 by bastiK, 11 years ago

In 6129/josm:

see #4029 - session menu now visible in expert mode - Please report bugs and feature requests!

in reply to:  34 comment:35 by Don-vip, 11 years ago

Replying to bastiK:

see #4029 - session menu now visible in expert mode - Please report bugs and feature requests!

ok :)

  1. Start JOSM
  2. File -> Session -> Save as
    Build-Date: 2013-08-13 11:43:28
    Revision: 6142
    Is-Local-Build: true
    
    Identification: JOSM/1.5 (6142 SVN fr) Windows 8 64-Bit
    Memory Usage: 198 MB / 1813 MB (89 MB allocated, but free)
    Java version: 1.7.0_25, Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM
    
    java.lang.NullPointerException
    	at org.openstreetmap.josm.actions.SessionSaveAsAction$SessionSaveAsDialog.initialize(SessionSaveAsAction.java:149)
    	at org.openstreetmap.josm.actions.SessionSaveAsAction$SessionSaveAsDialog.<init>(SessionSaveAsAction.java:140)
    	at org.openstreetmap.josm.actions.SessionSaveAsAction.actionPerformed(SessionSaveAsAction.java:63)
    	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    	at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
    

comment:36 by Don-vip, 11 years ago

Can you see also if you can do some code refactorization here ?
http://donvip.fr/sonar/resource/index/josm:org.openstreetmap.josm.io.session.GpxTracksSessionExporter?display_title=true&metric=88
It seems some strings have not been updated in GPX exporter because they refer "OSM data".

comment:37 by bastiK, 11 years ago

In 6149/josm:

see #4029 - disable session save action when mapview is not showing

comment:38 by bastiK, 11 years ago

In 6150/josm:

see #4029 - fix: strings not updated after copy & paste

in reply to:  36 comment:39 by bastiK, 11 years ago

Replying to Don-vip:

Can you see also if you can do some code refactorization here ?
http://donvip.fr/sonar/resource/index/josm:org.openstreetmap.josm.io.session.GpxTracksSessionExporter?display_title=true&metric=88

I'm aware that there is some code duplication and eventually, some refactorization is needed. But for now, I'd like to keep it simple.

It seems some strings have not been updated in GPX exporter because they refer "OSM data".

Thanks, fixed.

comment:40 by bastiK, 11 years ago

In 6205/josm:

see #4029 - fix problem when MapView is about to be loaded (nmea import)

comment:41 by StephaneP, 11 years ago

Hi !

This new feature is really helpful, thank you for your work !

Do you think you could include the cadastre-fr plugin layers in the sessions ?

Cadastre plugin :
http://wiki.openstreetmap.org/wiki/FR:JOSM/Fr:Plugin/Cadastre-fr
https://github.com/openstreetmap/josm-plugins/tree/master/cadastre-fr

comment:42 by bastiK, 11 years ago

Hi StepaneP, can you open a new ticket for cadastre support?

comment:43 by StephaneP, 11 years ago

Hi bastiK,

Sure i can : #9052

comment:44 by Don-vip, 10 years ago

In 6245/josm:

see #9032, see #4029 - Allow to load session from standard I/O mechanisms (local and remote files) + javadoc

comment:45 by Zverikk, 10 years ago

Tried to save/load session, works nice, but there's room for improvement :)
See tickets #9113, #9114, #9115, #9116

comment:46 by AlfonZ, 10 years ago

Keywords: session added

comment:47 by simon04, 8 years ago

Resolution: fixed
Status: newclosed

This one is fixed and in use for 2 years.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
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.