Ignore:
Timestamp:
2009-09-06T23:07:33+02:00 (15 years ago)
Author:
Gubaer
Message:

new: rewrite of CombineWay action
new: conflict resolution dialog for CombineWay, including conflicts for different relation memberships
cleanup: cleanup in OsmReader, reduces memory footprint and reduces parsing time
cleanup: made most of the public fields in OsmPrimitive @deprecated, added accessors and changed the code
cleanup: replaced usages of @deprecated constructors for ExtendedDialog
fixed #3208: Combine ways brokes relation order

WARNING: this changeset touches a lot of code all over the code base. "latest" might become slightly unstable in the next days. Also experience incompatibility issues with plugins in the next few days.

Location:
trunk/src/org/openstreetmap/josm/data/osm
Files:
12 edited

Legend:

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

    r1990 r2070  
    3030
    3131    public int compareTo(OsmPrimitive other) {
    32         if (other instanceof Changeset) return Long.valueOf(id).compareTo(other.id);
     32        if (other instanceof Changeset) return Long.valueOf(getId()).compareTo(other.getId());
    3333        return 1;
    3434    }
     
    3737    public String getName() {
    3838        // no translation
    39         return "changeset " + id;
     39        return "changeset " + getId();
    4040    }
    4141
    4242    @Override
    4343    public String getLocalName(){
    44         return tr("Changeset {0}",id);
     44        return tr("Changeset {0}",getId());
    4545    }
    4646
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r2025 r2070  
    373373    protected void deleteWay(Way way) {
    374374        way.setNodes(null);
    375         way.delete(true);
     375        way.setDeleted(true);
    376376    }
    377377
     
    471471        return false;
    472472    }
     473
     474    public Set<Relation> getReferringRelations(Collection<? extends OsmPrimitive> primitives) {
     475        HashSet<Relation> ret = new HashSet<Relation>();
     476        if (primitives == null) return ret;
     477        Set<? extends OsmPrimitive> referred;
     478        if (primitives instanceof Set<?>) {
     479            referred = (Set<? extends OsmPrimitive>)primitives;
     480        } else {
     481            referred = new HashSet<OsmPrimitive>(primitives);
     482        }
     483        referred.remove(null); // just in case - remove null element from primitives
     484        for (Relation r: relations) {
     485            if (r.isDeleted() || r.incomplete) {
     486                continue;
     487            }
     488            Set<OsmPrimitive> memberPrimitives = r.getMemberPrimitives();
     489            memberPrimitives.retainAll(referred);
     490            if (!memberPrimitives.isEmpty()) {
     491                ret.add(r);
     492            }
     493        }
     494        return ret;
     495    }
    473496}
  • trunk/src/org/openstreetmap/josm/data/osm/Node.java

    r2017 r2070  
    1717
    1818    public final void setCoor(LatLon coor) {
    19         if(coor != null)
    20         {
     19        if(coor != null){
    2120            if(this.coor == null) {
    2221                this.coor = new CachedLatLon(coor);
     
    4746
    4847
     48    /**
     49     * Create a new local node with id 0.
     50     *
     51     */
     52    public Node() {
     53        this(0);
     54    }
     55
    4956
    5057    /**
     
    5259     */
    5360    public Node(long id) {
    54         this.id = id;
    55         incomplete = true;
     61        super(id);
    5662    }
    5763
     
    6066     */
    6167    public Node(Node clone) {
     68        super(clone.getId());
    6269        cloneFrom(clone);
    6370    }
    6471
    6572    public Node(LatLon latlon) {
     73        super(0);
    6674        setCoor(latlon);
    6775    }
    6876
    6977    public Node(EastNorth eastNorth) {
     78        super(0);
    7079        setEastNorth(eastNorth);
    7180    }
     
    8190
    8291    @Override public String toString() {
    83         if (coor == null) return "{Node id="+id+"}";
    84         return "{Node id="+id+",version="+version+",lat="+coor.lat()+",lon="+coor.lon()+"}";
     92        if (coor == null) return "{Node id="+getId()+"}";
     93        return "{Node id="+getId()+",version="+getVersion()+",lat="+coor.lat()+",lon="+coor.lon()+"}";
    8594    }
    8695
     
    101110
    102111    public int compareTo(OsmPrimitive o) {
    103         return o instanceof Node ? Long.valueOf(id).compareTo(o.id) : 1;
     112        return o instanceof Node ? Long.valueOf(getId()).compareTo(o.getId()) : 1;
    104113    }
    105114
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r2067 r2070  
    1010import java.util.Date;
    1111import java.util.HashMap;
     12import java.util.HashSet;
     13import java.util.LinkedList;
     14import java.util.List;
    1215import java.util.Locale;
    1316import java.util.Map;
     17import java.util.Set;
    1418import java.util.Map.Entry;
    1519
     
    3135abstract public class OsmPrimitive implements Comparable<OsmPrimitive> {
    3236
     37    static public <T extends OsmPrimitive>  List<T> getFilteredList(Collection<OsmPrimitive> list, Class<T> type) {
     38        if (list == null) return null;
     39        List<T> ret = new LinkedList<T>();
     40        for(OsmPrimitive p: list) {
     41            if (type.isInstance(p)) {
     42                ret.add(type.cast(p));
     43            }
     44        }
     45        return ret;
     46    }
     47
     48    static public <T extends OsmPrimitive>  Set<T> getFilteredSet(Collection<OsmPrimitive> set, Class<T> type) {
     49        if (set == null) return null;
     50        HashSet<T> ret = new HashSet<T>();
     51        for(OsmPrimitive p: set) {
     52            if (type.isInstance(p)) {
     53                ret.add(type.cast(p));
     54            }
     55        }
     56        return ret;
     57    }
     58
     59
    3360    /* mappaint data */
    3461    public ElemStyle mappaintStyle = null;
     
    7097     * the respective class.
    7198     *
    72      * @deprecated use {@see #getId()}. Don't assign an id, create a primitive with
     99     * @deprecated use {@see #getId()} and {@see #setId()}. Don't assign an id, create a primitive with
    73100     * the respective constructors.
    74101     */
     
    120147
    121148    /**
     149     * If set to true, this object is incomplete, which means only the id
     150     * and type is known (type is the objects instance class)
     151     */
     152    public boolean incomplete = false;
     153
     154    /**
     155     * Contains the version number as returned by the API. Needed to
     156     * ensure update consistency
     157     * @deprecated use {@see #getVersion()} and {@see #setVersion(long)}
     158     */
     159    @Deprecated
     160    public int version = 0;
     161
     162
     163    /**
     164     * Creates a new primitive with id 0.
     165     *
     166     */
     167    public OsmPrimitive() {
     168        this(0);
     169    }
     170
     171    /**
     172     * Creates a new primitive for the given id. If the id > 0, the primitive is marked
     173     * as incomplete.
     174     *
     175     * @param id the id. > 0 required
     176     * @throws IllegalArgumentException thrown if id < 0
     177     */
     178    public OsmPrimitive(long id) throws IllegalArgumentException {
     179        if (id < 0)
     180            throw new IllegalArgumentException(tr("expected id >= 0. Got {0}", id));
     181        this.id = id;
     182        this.version = 0;
     183        this.incomplete = id >0;
     184    }
     185
     186    /* ------------------------------------------------------------------------------------ */
     187    /* accessors                                                                            */
     188    /* ------------------------------------------------------------------------------------ */
     189
     190    /**
    122191     * Sets whether this primitive is selected or not.
    123192     *
     
    162231     *
    163232     * @return <code>true</code>, if the object has been deleted.
    164      * @see #delete(boolean)
     233     * @see #setDeleted(boolean)
    165234     */
    166235    public boolean isDeleted() {
     
    205274
    206275    /**
     276     * Replies the version number as returned by the API. The version is 0 if the id is 0 or
     277     * if this primitive is incomplete.
     278     *
     279     * @see #setVersion(int)
     280     */
     281    public long getVersion() {
     282        return version;
     283    }
     284
     285    /**
    207286     * Replies the id of this primitive.
    208287     *
     
    214293
    215294    /**
    216      * If set to true, this object is highlighted. Currently this is only used to
    217      * show which ways/nodes will connect
    218      */
    219     public volatile boolean highlighted = false;
    220 
    221     private int timestamp;
     295     * Sets the id and the version of this primitive if it is known to the OSM API.
     296     *
     297     * Since we know the id and its version it can't be incomplete anymore. incomplete
     298     * is set to false.
     299     *
     300     * @param id the id. > 0 required
     301     * @param version the version > 0 required
     302     * @throws IllegalArgumentException thrown if id <= 0
     303     * @throws IllegalArgumentException thrown if version <= 0
     304     */
     305    public void setOsmId(long id, int version) {
     306        if (id <= 0)
     307            throw new IllegalArgumentException(tr("id > 0 expected. Got {0}", id));
     308        if (version <= 0)
     309            throw new IllegalArgumentException(tr("version > 0 expected. Got {0}", version));
     310        this.id = id;
     311        this.version = version;
     312        this.incomplete = false;
     313    }
     314
     315    /**
     316     * Clears the id and version known to the OSM API. The id and the version is set to 0.
     317     * incomplete is set to false.
     318     *
     319     * <strong>Caution</strong>: Do not use this method on primitives which are already added to a {@see DataSet}.
     320     * Ways and relations might already refer to the primitive and clearing the OSM ID
     321     * result in corrupt data.
     322     *
     323     * Here's an example use case:
     324     * <pre>
     325     *     // create a clone of an already existing node
     326     *     Node copy = new Node(otherExistingNode);
     327     *
     328     *     // reset the clones OSM id
     329     *     copy.clearOsmId();
     330     * </pre>
     331     *
     332     */
     333    public void clearOsmId() {
     334        this.id = 0;
     335        this.version = 0;
     336        this.incomplete = false;
     337    }
    222338
    223339    public void setTimestamp(Date timestamp) {
     
    240356
    241357    /**
    242      * If set to true, this object is incomplete, which means only the id
    243      * and type is known (type is the objects instance class)
    244      */
    245     public boolean incomplete = false;
    246 
    247     /**
    248      * Contains the version number as returned by the API. Needed to
    249      * ensure update consistency
    250      */
    251     public int version = -1;
     358     * If set to true, this object is highlighted. Currently this is only used to
     359     * show which ways/nodes will connect
     360     */
     361    public volatile boolean highlighted = false;
     362
     363    private int timestamp;
    252364
    253365    private static Collection<String> uninteresting = null;
     
    288400    abstract public void visit(Visitor visitor);
    289401
    290     public final void delete(boolean deleted) {
     402    /**
     403     * Sets whether this primitive is deleted or not.
     404     *
     405     * Also marks this primitive as modified if deleted is true and sets selected to false.
     406     *
     407     * @param deleted  true, if this primitive is deleted; false, otherwise
     408     */
     409    public void setDeleted(boolean deleted) {
     410        this.modified = deleted;
    291411        this.deleted = deleted;
    292         setSelected(false);
    293         modified = true;
     412        this.selected = false;
    294413    }
    295414
  • trunk/src/org/openstreetmap/josm/data/osm/Relation.java

    r2017 r2070  
    22
    33import java.util.ArrayList;
     4import java.util.HashSet;
    45import java.util.List;
     6import java.util.Set;
    57
    68import org.openstreetmap.josm.data.osm.visitor.Visitor;
     
    1719     * All members of this relation. Note that after changing this,
    1820     * makeBackReferences and/or removeBackReferences should be called.
    19      */
     21     *
     22     * @deprecated use the improved API instead of accessing this list directly
     23     */
     24    @Deprecated
    2025    public final List<RelationMember> members = new ArrayList<RelationMember>();
    2126
     
    104109
    105110    /**
     111     * Create a new relation with id 0
     112     */
     113    public Relation() {
     114
     115    }
     116
     117    /**
    106118     * Create an identical clone of the argument (including the id)
    107119     */
    108120    public Relation(Relation clone) {
     121        super(clone.getId());
    109122        cloneFrom(clone);
    110123    }
    111124
    112125    /**
    113      * Create an incomplete Relation.
    114      */
    115     public Relation(long id) {
    116         this.id = id;
    117         incomplete = true;
    118     }
    119 
    120     /**
    121      * Create an empty Relation. Use this only if you set meaningful values
    122      * afterwards.
    123      */
    124     public Relation() {
    125     }
     126     * Creates a new relation for the given id. If the id > 0, the way is marked
     127     * as incomplete.
     128     *
     129     * @param id the id. > 0 required
     130     * @throws IllegalArgumentException thrown if id < 0
     131     */
     132    public Relation(long id) throws IllegalArgumentException {
     133        super(id);
     134    }
     135
    126136
    127137    @Override public void cloneFrom(OsmPrimitive osm) {
     
    138148        // return "{Relation id="+id+" version="+version+" members="+Arrays.toString(members.toArray())+"}";
    139149        // adding members in string increases memory usage a lot and overflows for looped relations
    140         return "{Relation id="+id+" version="+version+"}";
     150        return "{Relation id="+getId()+" version="+getVersion()+"}";
    141151    }
    142152
     
    152162
    153163    public int compareTo(OsmPrimitive o) {
    154         return o instanceof Relation ? Long.valueOf(id).compareTo(o.id) : -1;
     164        return o instanceof Relation ? Long.valueOf(getId()).compareTo(o.getId()) : -1;
    155165    }
    156166
     
    158168    public boolean isIncomplete() {
    159169        for (RelationMember m : members)
    160             if (m.member == null)
     170            if (m.getMember() == null)
    161171                return true;
    162172        return false;
     
    183193        ArrayList<RelationMember> todelete = new ArrayList<RelationMember>();
    184194        for (RelationMember member: members) {
    185             if (member.member == primitive) {
     195            if (member.getMember() == primitive) {
    186196                todelete.add(member);
    187197            }
     
    194204        return formatter.format(this);
    195205    }
     206
     207    /**
     208     * Replies the set of  {@see OsmPrimitive}s referred to by at least one
     209     * member of this relation
     210     *
     211     * @return the set of  {@see OsmPrimitive}s referred to by at least one
     212     * member of this relation
     213     */
     214    public Set<OsmPrimitive> getMemberPrimitives() {
     215        HashSet<OsmPrimitive> ret = new HashSet<OsmPrimitive>();
     216        for (RelationMember m: members) {
     217            if (m.getMember() != null) {
     218                ret.add(m.getMember());
     219            }
     220        }
     221        return ret;
     222    }
    196223}
  • trunk/src/org/openstreetmap/josm/data/osm/RelationMember.java

    r1937 r2070  
    66 * list is not sufficient.
    77 *
    8  * @author Frederik Ramm <frederik@remote.org>
    98 */
    109public class RelationMember {
    1110
     11    /**
     12     *
     13     * @deprecated use {@see #getRole()} or create a clone in order to assign a new role
     14     */
     15    @Deprecated
    1216    public String role;
     17
     18    /**
     19     *
     20     * @deprecated use {@see #getMember()} or create a clone in order to assign a new member
     21     */
     22    @Deprecated
    1323    public OsmPrimitive member;
    1424
     
    1929     */
    2030    public String getRole() {
    21         if (role == null) {
     31        if (role == null)
    2232            return "";
    23         } else {
    24             return role;
    25         }
     33        return role;
    2634    }
    2735
     
    4553
    4654    /**
    47     *
    48     * @return True if member is way
    49     * @since 1937
    50     */
     55     *
     56     * @return True if member is way
     57     * @since 1937
     58     */
    5159    public boolean isWay() {
    5260        return member instanceof Way;
     
    5462
    5563    /**
    56     *
    57     * @return True if member is node
    58     * @since 1937
    59     */
     64     *
     65     * @return True if member is node
     66     * @since 1937
     67     */
    6068    public boolean isNode() {
    6169        return member instanceof Node;
     
    7280
    7381    /**
    74     *
    75     * @return Member as way
    76     * @since 1937
    77     */
     82     *
     83     * @return Member as way
     84     * @since 1937
     85     */
    7886    public Way getWay() {
    7987        return (Way)member;
     
    8189
    8290    /**
    83     *
    84     * @return Member as node
    85     * @since 1937
    86     */
     91     *
     92     * @return Member as node
     93     * @since 1937
     94     */
    8795    public Node getNode() {
    8896        return (Node)member;
     
    9098
    9199    /**
    92     *
    93     * @return Member
    94     * @since 1937
    95     */
     100     *
     101     * @return Member
     102     * @since 1937
     103     */
    96104    public OsmPrimitive getMember() {
    97105        return member;
     
    101109    /**
    102110     * Default constructor. Does nothing.
    103      * @deprecated Use other constructors because RelationMember class will became immutable
     111     * @deprecated Use other constructors because RelationMember class will become immutable
    104112     * in the future
    105113     */
  • trunk/src/org/openstreetmap/josm/data/osm/Tag.java

    r2008 r2070  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.osm;
     3
     4import java.util.ArrayList;
     5import java.util.Collections;
     6import java.util.Iterator;
     7import java.util.List;
    38
    49/**
     
    2732     */
    2833    public Tag(String key) {
     34        this();
    2935        this.key = key == null ? "" : key;
    3036    }
  • trunk/src/org/openstreetmap/josm/data/osm/TagCollection.java

    r2017 r2070  
    66import java.util.ArrayList;
    77import java.util.Collection;
     8import java.util.Collections;
    89import java.util.HashMap;
    910import java.util.HashSet;
     
    571572            throw new IllegalStateException(tr("tag collection can't be applied to a primitive because there are keys with multiple values"));
    572573        for (Tag tag: tags) {
    573             primitive.put(tag.getKey(), tag.getValue());
     574            if (tag.getValue() == null || tag.getValue().equals("")) {
     575                primitive.remove(tag.getKey());
     576            } else {
     577                primitive.put(tag.getKey(), tag.getValue());
     578            }
    574579        }
    575580    }
     
    682687        return ret;
    683688    }
     689
     690    /**
     691     * Replies the concatenation of all tag values (concatenated by a semicolon)
     692     *
     693     * @return the concatenation of all tag values
     694     */
     695    public String getJoinedValues(String key) {
     696        StringBuffer buffer = new StringBuffer();
     697        List<String> values = new ArrayList<String>(getValues(key));
     698        values.remove("");
     699        Collections.sort(values);
     700        Iterator<String> iter = values.iterator();
     701        while (iter.hasNext()) {
     702            buffer.append(iter.next());
     703            if (iter.hasNext()) {
     704                buffer.append(";");
     705            }
     706        }
     707        return buffer.toString();
     708    }
    684709}
  • trunk/src/org/openstreetmap/josm/data/osm/User.java

    r2034 r2070  
    22package org.openstreetmap.josm.data.osm;
    33
     4import java.util.ArrayList;
    45import java.util.HashMap;
     6import java.util.List;
    57
    68/**
     
    1113 * is only one user object.
    1214 *
    13  * @author fred
    1415 *
    1516 */
    1617public class User {
     18    static private long uidCounter = 0;
     19    /**
     20     * the map of known users
     21     */
     22    private static HashMap<Long,User> userMap = new HashMap<Long,User>();
    1723
    18     /** storage for existing User objects. */
    19     private static HashMap<String,User> userMap = new HashMap<String,User>();
    2024
    21     /** the username. */
    22     public String name;
     25    private static long getNextLocalUid() {
     26        synchronized(User.class) {
     27            uidCounter--;
     28            return uidCounter;
     29        }
     30    }
    2331
    24     /** the user ID (since API 0.6) */
    25     public String uid;
     32    /**
     33     * Creates a local user with the given name
     34     *
     35     * @param name the name
     36     */
     37    public static User createLocalUser(String name) {
     38        User user = new User(getNextLocalUid(), name);
     39        userMap.put(user.getId(), user);
     40        return user;
     41    }
     42
     43    /**
     44     * Creates a user known to the OSM server
     45     *
     46     * @param uid  the user id
     47     * @param name the name
     48     */
     49    public static User  createOsmUser(long uid, String name) {
     50        User user = new User(uid, name);
     51        userMap.put(user.getId(), user);
     52        return user;
     53    }
     54
     55
     56    /**
     57     * Returns the user with user id <code>uid</code> or null if this user doesn't exist
     58     *
     59     * @param uid the user id
     60     * @return the user; null, if there is no user with  this id
     61     */
     62    public static User getById(long uid) {
     63        return userMap.get(uid);
     64    }
     65
     66    /**
     67     * Returns the list of users with name <code>name</code> or the empty list if
     68     * no such users exist
     69     *
     70     * @param name the user name
     71     * @return the list of users with name <code>name</code> or the empty list if
     72     * no such users exist
     73     */
     74    public static List<User> getByName(String name) {
     75        name = name == null ? "" : name;
     76        List<User> ret = new ArrayList<User>();
     77        for (User user: userMap.values()) {
     78            if (user.getName().equals(name)) {
     79                ret.add(user);
     80            }
     81        }
     82        return ret;
     83    }
     84
     85    /** the user name */
     86    private String name;
     87    /** the user id */
     88    private long uid;
     89
     90    /**
     91     * Replies the user name
     92     *
     93     * @return the user name. Never null, but may be the empty string
     94     */
     95    public String getName() {
     96        return name == null ? "" : name;
     97    }
     98
     99    /**
     100     * Replies the user id. If this user is known to the OSM server the positive user id
     101     * from the server is replied. Otherwise, a negative local value is replied.
     102     *
     103     * A negative local is only unique during an editing session. It is lost when the
     104     * application is closed and there is no guarantee that a negative local user id is
     105     * always bound to a user with the same name.
     106     *
     107     */
     108    public long getId() {
     109        return uid;
     110    }
    26111
    27112    /** private constructor, only called from get method. */
    28     private User(String name) {
     113    private User(long uid, String name) {
     114        this.uid = uid;
    29115        this.name = name;
    30116    }
    31117
    32     /** returns a new or existing User object that represents the given name. */
    33     public static User get(String name) {
    34         User user = userMap.get(name);
    35         if (user == null) {
    36             user = new User(name);
    37             userMap.put(name, user);
    38         }
    39         return user;
     118    public boolean isOsmUser() {
     119        return uid > 0;
     120    }
     121
     122    public boolean isLocalUser() {
     123        return uid < 0;
    40124    }
    41125
     
    45129        int result = 1;
    46130        result = prime * result + ((name == null) ? 0 : name.hashCode());
    47         result = prime * result + ((uid == null) ? 0 : uid.hashCode());
     131        result = prime * result + (int) (uid ^ (uid >>> 32));
    48132        return result;
    49133    }
     
    63147        } else if (!name.equals(other.name))
    64148            return false;
    65         if (uid == null) {
    66             if (other.uid != null)
    67                 return false;
    68         } else if (!uid.equals(other.uid))
     149        if (uid != other.uid)
    69150            return false;
    70151        return true;
  • trunk/src/org/openstreetmap/josm/data/osm/Way.java

    r2017 r2070  
    119119
    120120    /**
     121     * Creates a new way with id 0.
     122     *
     123     */
     124    public Way(){
     125    }
     126
     127    /**
    121128     * Create an identical clone of the argument (including the id).
    122129     *
     
    124131     */
    125132    public Way(Way original) {
     133        super(original.getId());
    126134        cloneFrom(original);
    127135    }
    128136
    129137    /**
    130      * Create an empty way without id. Use this only if you set meaningful
    131      * values yourself.
    132      */
    133     public Way() {
    134     }
    135 
    136     /**
    137      * Create an incomplete Way with a given id.
    138      *
    139      * @param id  the id. id > 0 required.
    140      */
    141     public Way(long id) {
    142         // FIXME: shouldn't we check for id > 0?
    143         //
    144         this.id = id;
    145         incomplete = true;
     138     * Creates a new way for the given id. If the id > 0, the way is marked
     139     * as incomplete.
     140     *
     141     * @param id the id. > 0 required
     142     * @throws IllegalArgumentException thrown if id < 0
     143     */
     144    public Way(long id) throws IllegalArgumentException {
     145        super(id);
    146146    }
    147147
     
    153153
    154154    @Override public String toString() {
    155         if (incomplete) return "{Way id="+id+" version="+version+" (incomplete)}";
    156         return "{Way id="+id+" version="+version+" nodes="+Arrays.toString(nodes.toArray())+"}";
     155        if (incomplete) return "{Way id="+getId()+" version="+getVersion()+" (incomplete)}";
     156        return "{Way id="+getId()+" version="+getVersion()+" nodes="+Arrays.toString(nodes.toArray())+"}";
    157157    }
    158158
     
    170170        if (o instanceof Relation)
    171171            return 1;
    172         return o instanceof Way ? Long.valueOf(id).compareTo(o.id) : -1;
     172        return o instanceof Way ? Long.valueOf(getId()).compareTo(o.getId()) : -1;
    173173    }
    174174
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/CollectBackReferencesVisitor.java

    r1937 r2070  
    4646    public void visit(Node n) {
    4747        for (Way w : ds.ways) {
    48             if (w.deleted || w.incomplete) continue;
     48            if (w.isDeleted() || w.incomplete) {
     49                continue;
     50            }
    4951            for (Node n2 : w.getNodes()) {
    5052                if (n == n2) {
     
    7274        // references.
    7375        for (Relation r : ds.relations) {
    74             if (r.incomplete || r.deleted) continue;
     76            if (r.incomplete || r.isDeleted()) {
     77                continue;
     78            }
    7579            for (RelationMember m : r.getMembers()) {
    7680                if (m.getMember() == p) {
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java

    r2025 r2070  
    236236        if (myPrimitivesWithDefinedIds.containsKey(other.getId())) {
    237237            P my = myPrimitivesWithDefinedIds.get(other.getId());
    238             if (my.version <= other.version) {
     238            if (my.getVersion() <= other.getVersion()) {
    239239                if (! my.isVisible() && other.isVisible()) {
    240240                    // should not happen
     
    243243                            + "their primitive with lower version {2} is not visible. "
    244244                            + "Can't deal with this inconsistency. Keeping my primitive. ",
    245                             Long.toString(my.getId()),Long.toString(my.version), Long.toString(other.version)
     245                            Long.toString(my.getId()),Long.toString(my.getVersion()), Long.toString(other.getVersion())
    246246                    ));
    247247                    merged.put(other, my);
     
    270270                    //
    271271                    merged.put(other, my);
    272                 } else if (my.isDeleted() && ! other.isDeleted() && my.version == other.version) {
     272                } else if (my.isDeleted() && ! other.isDeleted() && my.getVersion() == other.getVersion()) {
    273273                    // same version, but my is deleted. Assume mine takes precedence
    274274                    // otherwise too many conflicts when refreshing from the server
     
    288288                    my.cloneFrom(other);
    289289                    merged.put(other, my);
    290                 } else if (! my.isModified() && !other.isModified() && my.version == other.version) {
     290                } else if (! my.isModified() && !other.isModified() && my.getVersion() == other.getVersion()) {
    291291                    // both not modified. Keep mine
    292292                    //
    293293                    merged.put(other,my);
    294                 } else if (! my.isModified() && !other.isModified() && my.version < other.version) {
     294                } else if (! my.isModified() && !other.isModified() && my.getVersion() < other.getVersion()) {
    295295                    // my not modified but other is newer. clone other onto mine.
    296296                    //
    297297                    my.cloneFrom(other);
    298298                    merged.put(other,my);
    299                 } else if (my.isModified() && ! other.isModified() && my.version == other.version) {
     299                } else if (my.isModified() && ! other.isModified() && my.getVersion() == other.getVersion()) {
    300300                    // my is same as other but mine is modified
    301301                    // => keep mine
Note: See TracChangeset for help on using the changeset viewer.