[josm-dev] How to update changes in dataSet ?

Dirk Stöcker openstreetmap at dstoecker.de
Tue Jan 4 18:59:28 GMT 2011


On Tue, 4 Jan 2011, Flávio Henrique wrote:

> I did'nt changed any of your code. Just use them.
> Basically what I'm doing is:
> -> using mouse to select all my data and intercepting the selection in
> SelectionManager.getObjectsInRectangle method
> -> I iterate the ways selected, using nc.getCurrentDataSet().getWays(), and
> search ways that have a particular tag with same value, using
> way.get("id_log").
> -> So I call CombineWayAction().combineWaysWorker(sameWays) to combine them.
>
> The point is: as I have now only ways that can't be combined with all of
> your segments (sometimes with hundreds of segments), I'm trying to combine
> only those possible. So I call the combineWaysWorker method only with two
> segments. If do not work, I try the first segment with a different segment
> of the same way. If works I grab a differente way I repeat the process,
> until all possibles segments could be combined.
>
> The code to combine the ways is working fine, as I can see the combined
> segments on GUI (I'm using debug mode).
>
> Maybe my mistake is call nc.getCurrentDataSet().getWays() to get the updated
> dataSet after the first call ? Maybe this method returns only the original
> dataSet (unchanged)? There's another method to bring the updated (with the
> combined way) dataSet?
>
> Or, although the GUI shows the updated data (the way combined) I still need
> to apply the commands? If so, how?

I don' understand your description, so probably some code would be better. 
But generally I think you violate a basic principle: Take data from 
the dataset, modify it and then give it back.

Your description sounds like you mix the modify and give back steps.
  - You have a dataset containing all the ways you want to process.
  - When you combined two ways, then you get a way object back. You need to
    remove the original ways (from your local dataset) and add the new one
    instead.
  - When you are finished with everything you call the UndoRedo-Action to
    make you changes permanent.

Intermixing the points 2 and 3 will very likely produce a larger number of 
problems.

Ciao
-- 
http://www.dstoecker.eu/ (PGP key available)


More information about the josm-dev mailing list