[josm-dev] Changes in JOSM core (referrers)

Jiri Klement jiri.klement at gmail.com
Sun Nov 8 12:45:02 GMT 2009


Hi,

I did some changes in JOSM core, that might bring some tickets in
following days.

First of all, Dataset now have map of primitives, that makes searching
for primitive by id much faster. It's used by addPrimitive method to
throw an exception if somebody is trying to add the same primitive
twice to the dataset (see r2398 for problem discoverd by this check),
removePrimitive prints warning if somebody tries to remove nonexisting
primitive. Also selection code was changed

Another thing is reference to dataset in OsmPrimitive. This reference
is set by Dataset.addPrimitive() method and reset by
Dataset.removePrimitive. If primitive is part of more than one dataset
then DataIntegrityProblemException is thrown. That was cause for
#3863.

Having reference to dataset in OsmPrimitive allowed new feature -
referrers (list of primitives that reference another primitive, for
example Way referrening nodes). For referrers to work reliably it is
necessary for every primitive to be part of exactly one dataset.
That's not true in JOSM so I've used a workaround - every primitive
have list of all referrers but method getReferrers() return only those
primitives that are part of the same dataset.

This workaround has one annoying consequence - it might cause memory
leaks. For example in following code:
Way wtemp = new Way(existingWay)
wtemp is temporary way, existingWay is some way in the dataset. wtemp
will be added as referrer to existingWay nodes and never released by
GC. I'm not sure yet if it's considerable and needs to be fixed (for
example by using SoftReference for primitives that don't have Dataset)

--
Jiri




More information about the josm-dev mailing list