Changeset 4339 in josm


Ignore:
Timestamp:
2011-08-26T21:34:44+02:00 (8 years ago)
Author:
stoecker
Message:

fix #6592 - patch by simon04 - Exception showing history of incomplete objects

Location:
trunk/src/org/openstreetmap/josm
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/history/HistoryNode.java

    r3083 r4339  
    55
    66import org.openstreetmap.josm.data.coor.LatLon;
     7import org.openstreetmap.josm.data.osm.Node;
    78import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    89
     
    2021        super(id, version, visible, user, uid, changesetId, timestamp);
    2122        setCoords(coords);
     23    }
     24
     25    public HistoryNode(Node p) {
     26        super(p);
     27        setCoords(p.getCoor());
    2228    }
    2329
  • trunk/src/org/openstreetmap/josm/data/osm/history/HistoryOsmPrimitive.java

    r3083 r4339  
    1111import java.util.Map;
    1212
     13import org.openstreetmap.josm.data.osm.Node;
     14import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1315import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    1416import org.openstreetmap.josm.data.osm.PrimitiveId;
     17import org.openstreetmap.josm.data.osm.Relation;
    1518import org.openstreetmap.josm.data.osm.SimplePrimitiveId;
     19import org.openstreetmap.josm.data.osm.Way;
    1620import org.openstreetmap.josm.tools.CheckParameterUtil;
    1721
     
    7074    }
    7175
     76    public HistoryOsmPrimitive(OsmPrimitive p) {
     77        this(p.getId(), p.getVersion(), p.isVisible(),
     78                p.getUser() == null ? null : p.getUser().getName(),
     79                p.getUser() == null ? 0 : p.getUser().getId(),
     80                p.getChangesetId(), p.getTimestamp());
     81    }
     82
     83    public static HistoryOsmPrimitive forOsmPrimitive(OsmPrimitive p) {
     84        if (p instanceof Node) {
     85            return new HistoryNode((Node) p);
     86        } else if (p instanceof Way) {
     87            return new HistoryWay((Way) p);
     88        } else if (p instanceof Relation) {
     89            return new HistoryRelation((Relation) p);
     90        } else {
     91            return null;
     92        }
     93    }
     94
    7295    public long getId() {
    7396        return id;
  • trunk/src/org/openstreetmap/josm/data/osm/history/HistoryRelation.java

    r3083 r4339  
    99
    1010import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
     11import org.openstreetmap.josm.data.osm.Relation;
    1112import org.openstreetmap.josm.tools.CheckParameterUtil;
    1213
     
    1819public class HistoryRelation extends HistoryOsmPrimitive{
    1920
    20     private ArrayList<RelationMember> members;
     21    private ArrayList<RelationMember> members = new ArrayList<RelationMember>();
    2122
    2223    /**
     
    3637            Date timestamp) throws IllegalArgumentException {
    3738        super(id, version, visible, user, uid, changesetId, timestamp);
    38         members = new ArrayList<RelationMember>();
    3939    }
    4040    /**
     
    5858            this.members.addAll(members);
    5959        }
     60    }
     61
     62    public HistoryRelation(Relation p) {
     63        super(p);
    6064    }
    6165
  • trunk/src/org/openstreetmap/josm/data/osm/history/HistoryWay.java

    r3083 r4339  
    1010
    1111import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
     12import org.openstreetmap.josm.data.osm.Way;
    1213/**
    1314 * Represents an immutable OSM way in the context of a historical view on
     
    1718public class HistoryWay extends HistoryOsmPrimitive {
    1819
    19     private ArrayList<Long> nodeIds;
     20    private ArrayList<Long> nodeIds = new ArrayList<Long>();
    2021
    2122    public HistoryWay(long id, long version, boolean visible, String user, long uid, long changesetId, Date timestamp) {
    2223        super(id, version, visible, user, uid, changesetId, timestamp);
    23         nodeIds = new ArrayList<Long>();
    2424    }
    2525
     
    2727        this(id, version, visible, user, uid, changesetId, timestamp);
    2828        this.nodeIds.addAll(nodeIdList);
     29    }
     30
     31    public HistoryWay(Way p) {
     32        super(p);
    2933    }
    3034
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java

    r4223 r4339  
    145145    protected boolean canShowAsLatest(OsmPrimitive primitive) {
    146146        if (primitive == null) return false;
    147         if (primitive.isNew()) return false;
     147        if (primitive.isNew() || !primitive.isUsable()) return false;
     148       
     149        //try creating a history primitive. if that fails, the primitive cannot be used.
     150        try {
     151            HistoryOsmPrimitive.forOsmPrimitive(primitive);
     152        } catch (Exception ign) {
     153            return false;
     154        }
     155
    148156        if (history == null) return false;
    149         // only show latest of the same version if it is
    150         // modified
     157        // only show latest of the same version if it is modified
    151158        if (history.getByVersion(primitive.getVersion()) != null)
    152159            return primitive.isModified();
Note: See TracChangeset for help on using the changeset viewer.