Changeset 2320 in josm for trunk


Ignore:
Timestamp:
2009-10-25T19:01:00+01:00 (14 years ago)
Author:
Gubaer
Message:

see #3775: JOSM tries to upload a new relation that references a unuploaded way

File:
1 edited

Legend:

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

    r2273 r2320  
    5959            }
    6060            if (osm.isNew() && !osm.isDeleted()) {
    61                 toAdd.addLast(osm);
     61                toAdd.add(osm);
    6262            } else if (osm.isModified() && !osm.isDeleted()) {
    63                 toUpdate.addLast(osm);
     63                toUpdate.add(osm);
    6464            } else if (osm.isDeleted() && !osm.isNew() && osm.isModified()) {
    65                 toDelete.addFirst(osm);
     65                toDelete.add(osm);
    6666            }
    6767        }
    6868        sortDeleted();
     69        sortNew();
    6970    }
    7071
     
    9293                        else if (o2 instanceof Way && o1 instanceof Relation)
    9394                            return -1;
     95
     96                        return 0;
     97                    }
     98                }
     99        );
     100    }
     101
     102    /**
     103     * Ensures that primitives are added in the following order: Nodes, then Ways,
     104     * then Relations.
     105     *
     106     */
     107    protected void sortNew() {
     108        Collections.sort(
     109                toAdd,
     110                new Comparator<OsmPrimitive>() {
     111                    public int compare(OsmPrimitive o1, OsmPrimitive o2) {
     112                        if (o1 instanceof Node && o2 instanceof Node)
     113                            return 0;
     114                        else if (o1 instanceof Node)
     115                            return -1;
     116                        else if (o2 instanceof Node)
     117                            return 1;
     118
     119                        if (o1 instanceof Way && o2 instanceof Way)
     120                            return 0;
     121                        else if (o1 instanceof Way && o2 instanceof Relation)
     122                            return -1;
     123                        else if (o2 instanceof Way && o1 instanceof Relation)
     124                            return 1;
    94125
    95126                        return 0;
     
    127158            }
    128159        }
     160        sortNew();
    129161        sortDeleted();
    130162    }
Note: See TracChangeset for help on using the changeset viewer.