[josm-dev] How to update changes in dataSet ?
Dirk Stöcker
openstreetmap at dstoecker.de
Tue Jan 4 20:01:38 GMT 2011
On Tue, 4 Jan 2011, Flávio Henrique wrote:
> I thought the combineWayWorker method would take care of point 2 (removing
> the original way and adding the new one), as the sequenceCommand returned
> has the commands to delete ways. So, after calling Main.main.undoRedo.add(new
> SequenceCommand(tr("Your job"), cmds)), the command to delete the original
> way would be executed. I'm wrong here?
Correct. All dataset stay localto your function until you pass the command
to the command stack. Only afterwards the are executed "really". Otherwise
a proper undo would be impossible. You need to group changes, so they can
be undone in one step.
[ code snipped ]
Notes:
1) You don't use the returned way of a combine, so your code wont
find all possibilities. I don't know what you final goal is, but I would
make a loop around
changed = true;
while(changed)
{
changed = false;
for ...
changed = true in case combine worked at least once
}
and integrate the combined ways in subsequent calls and dropping the used
ones.
2) Only adding the first way to usedWays is wrong. Both ways are unusable
after combining and only the new returned one is to be used instead. It
may seem to work, but I doubt it is correct and probably leads to hard to
detect bugs.
Ciao
--
http://www.dstoecker.eu/ (PGP key available)
More information about the josm-dev
mailing list