Changeset 3107 in josm


Ignore:
Timestamp:
2010-03-10T19:11:58+01:00 (10 years ago)
Author:
jttt
Message:

Fix #4624 Relations not rendered right away

Location:
trunk
Files:
2 edited

Legend:

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

    r3102 r3107  
    334334    @Override
    335335    public BBox getBBox() {
    336         if (bbox == null) {
    337             calculateBBox(new HashSet<PrimitiveId>());
     336        if (getDataSet() == null)
     337            return calculateBBox(new HashSet<PrimitiveId>());
     338        else {
    338339            if (bbox == null) {
    339                 bbox = new BBox(0, 0, 0, 0); // No members
    340             }
    341         }
    342         return  bbox;
     340                bbox = calculateBBox(new HashSet<PrimitiveId>());
     341                if (bbox == null) {
     342                    bbox = new BBox(0, 0, 0, 0); // No members
     343                }
     344            }
     345            return  bbox;
     346        }
    343347    }
    344348
     
    374378        super.setDataset(dataSet);
    375379        checkMembers();
     380        bbox = null; // bbox might have changed if relation was in ds, was removed, modified, added back to dataset
    376381    }
    377382
     
    401406    /**
    402407     * Replies true if at least one child primitive is incomplete
    403      * 
     408     *
    404409     * @return true if at least one child primitive is incomplete
    405410     */
     
    414419     * Replies a collection with the incomplete children this relation
    415420     * refers to
    416      * 
     421     *
    417422     * @return the incomplete children. Empty collection if no children are incomplete.
    418423     */
  • trunk/test/unit/org/openstreetmap/josm/data/osm/RelationTest.java

    r2982 r3107  
    6565    }
    6666
     67    @Test
     68    public void testBBoxNotInDataset() {
     69        Node n1 = new Node(new LatLon(10, 10));
     70        Node n2 = new Node(new LatLon(20, 20));
     71        Way w1 = new Way();
     72        w1.addNode(n1);
     73        w1.addNode(n2);
     74        Relation r1 = new Relation();
     75        r1.getBBox();
     76        r1.addMember(new RelationMember("", w1));
     77
     78        Assert.assertEquals(new BBox(w1), r1.getBBox());
     79
     80        DataSet ds = new DataSet();
     81        ds.addPrimitive(n1);
     82        ds.addPrimitive(n2);
     83        ds.addPrimitive(w1);
     84        ds.addPrimitive(r1);
     85
     86        Assert.assertEquals(new BBox(w1), r1.getBBox());
     87
     88        ds.removePrimitive(r1);
     89
     90        n1.setCoor(new LatLon(30, 40));
     91        Assert.assertEquals(new BBox(w1), r1.getBBox());
     92
     93        ds.addPrimitive(r1);
     94        Assert.assertEquals(new BBox(w1), r1.getBBox());
     95    }
     96
    6797}
Note: See TracChangeset for help on using the changeset viewer.