Changeset 6801 in josm


Ignore:
Timestamp:
2014-02-02T20:13:06+01:00 (6 years ago)
Author:
simon04
Message:

fix #9656 - Repair upload order of objects to be deleted (regression from r6776)

Location:
trunk
Files:
2 edited

Legend:

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

    r6776 r6801  
    237237
    238238        LinkedList<OsmPrimitive> newToDelete = new LinkedList<OsmPrimitive>();
    239         newToDelete.addAll(Utils.filteredCollection(toDelete, Node.class));
    240         newToDelete.addAll(Utils.filteredCollection(toDelete, Way.class));
    241239        graph = new RelationUploadDependencyGraph(Utils.filteredCollection(toDelete, Relation.class), false);
    242240        newToDelete.addAll(graph.computeUploadOrder());
     241        newToDelete.addAll(Utils.filteredCollection(toDelete, Way.class));
     242        newToDelete.addAll(Utils.filteredCollection(toDelete, Node.class));
    243243        toDelete = newToDelete;
    244244    }
  • trunk/test/unit/org/openstreetmap/josm/data/osm/APIDataSetTest.java

    r6776 r6801  
    175175
    176176        APIDataSet apiDataSet = new APIDataSet();
    177         apiDataSet.init(ds);
     177        // add r1 first to test functionality of APIDataSet#adjustRelationUploadOrder()
     178        apiDataSet.getPrimitivesToDelete().add(r1);
     179        apiDataSet.getPrimitivesToDelete().add(r2);
     180        apiDataSet.getPrimitivesToDelete().add(r3);
     181        apiDataSet.getPrimitivesToDelete().add(r4);
    178182        try {
    179183            apiDataSet.adjustRelationUploadOrder();
     
    186190        assertEquals(true, toDelete.indexOf(r2) < toDelete.indexOf(r1));
    187191        assertEquals(true, toDelete.indexOf(r3) < toDelete.indexOf(r1));
    188         assertEquals(true, toDelete.indexOf(r3) < toDelete.indexOf(r1));
     192    }
     193
     194    @Test // for ticket #9656
     195    public void deleteWay() {
     196        DataSet ds = new DataSet();
     197        final Way way = new Way(1, 2);
     198        way.put("highway", "unclassified");
     199        ds.addPrimitive(way);
     200
     201        final Node n1 = new Node(2);
     202        ds.addPrimitive(n1);
     203        way.addNode(n1);
     204
     205        final Node n2 = new Node(3);
     206        ds.addPrimitive(n2);
     207        way.addNode(n2);
     208
     209        Relation r1 = new Relation(4, 2);
     210        ds.addPrimitive(r1);
     211        r1.put("name", "r1");
     212        r1.addMember(new RelationMember("foo", way));
     213
     214
     215        r1.setDeleted(true);
     216        way.setDeleted(true);
     217        n1.setDeleted(true);
     218        n2.setDeleted(true);
     219
     220        APIDataSet apiDataSet = new APIDataSet();
     221        apiDataSet.init(ds);
     222        try {
     223            apiDataSet.adjustRelationUploadOrder();
     224        } catch (CyclicUploadDependencyException e) {
     225            fail("unexpected exception:" + e);
     226        }
     227        List<OsmPrimitive> toDelete = apiDataSet.getPrimitivesToDelete();
     228
     229        assertEquals(4, toDelete.size());
     230        assertEquals(true, toDelete.indexOf(way) < toDelete.indexOf(n1));
     231        assertEquals(true, toDelete.indexOf(way) < toDelete.indexOf(n2));
     232        assertEquals(true, toDelete.indexOf(r1) < toDelete.indexOf(way));
    189233    }
    190234
Note: See TracChangeset for help on using the changeset viewer.