Changeset 9716 in josm for trunk


Ignore:
Timestamp:
2016-02-02T23:01:02+01:00 (9 years ago)
Author:
Don-vip
Message:

fix #12467, see #12412 - presets no longer fit correct for boundary relations (regression from r9574)

Location:
trunk
Files:
2 edited

Legend:

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

    r9460 r9716  
    420420    @Override
    421421    public OsmPrimitiveType getDisplayType() {
    422         return isMultipolygon() ? OsmPrimitiveType.MULTIPOLYGON
    423         : OsmPrimitiveType.RELATION;
    424     }
    425 
     422        return isMultipolygon() && !isBoundary() ? OsmPrimitiveType.MULTIPOLYGON : OsmPrimitiveType.RELATION;
     423    }
     424
     425    /**
     426     * Determines if this relation is a boundary.
     427     * @return {@code true} if a boundary relation
     428     */
     429    public boolean isBoundary() {
     430        return "boundary".equals(get("type"));
     431    }
     432
     433    /**
     434     * Determines if this relation behaves as a multipolygon.
     435     * @return {@code true} if it's a real mutlipolygon or a boundary relation
     436     */
    426437    public boolean isMultipolygon() {
    427         return "multipolygon".equals(get("type")) || "boundary".equals(get("type"));
     438        return "multipolygon".equals(get("type")) || isBoundary();
    428439    }
    429440
  • trunk/test/unit/org/openstreetmap/josm/data/osm/RelationTest.java

    r8510 r9716  
    22package org.openstreetmap.josm.data.osm;
    33
     4import static org.junit.Assert.assertEquals;
    45import static org.junit.Assert.assertFalse;
     6import static org.junit.Assert.assertTrue;
    57
    68import org.junit.Assert;
     
    104106        Assert.assertEquals(new BBox(w1), r1.getBBox());
    105107    }
     108
     109    /**
     110     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/12467">Bug #12467</a>.
     111     * @throws Exception if any error occurs
     112     */
     113    @Test
     114    public void testTicket12467() throws Exception {
     115        Relation r = new Relation();
     116        r.put("type", "boundary");
     117        assertTrue(r.isBoundary());
     118        assertTrue(r.isMultipolygon());
     119        assertEquals(OsmPrimitiveType.RELATION, r.getDisplayType());
     120
     121        r.put("type", "multipolygon");
     122        assertFalse(r.isBoundary());
     123        assertTrue(r.isMultipolygon());
     124        assertEquals(OsmPrimitiveType.MULTIPOLYGON, r.getDisplayType());
     125
     126        r.put("type", "something_else");
     127        assertFalse(r.isBoundary());
     128        assertFalse(r.isMultipolygon());
     129        assertEquals(OsmPrimitiveType.RELATION, r.getDisplayType());
     130    }
    106131}
Note: See TracChangeset for help on using the changeset viewer.