Changeset 7112 in josm for trunk


Ignore:
Timestamp:
2014-05-12T21:45:02+02:00 (6 years ago)
Author:
simon04
Message:

fix #9880 - Recognise building=(!yes) relations as buildings (name formatter)

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/DefaultNameFormatter.java

    r7098 r7112  
    461461        } else if (nameTag.startsWith("?") && OsmUtils.isFalse(relation.get(nameTag.substring(1)))) {
    462462            return null;
     463        } else if (nameTag.startsWith("?")) {
     464            return trc_lazy(nameTag, I18n.escape(relation.get(nameTag.substring(1))));
    463465        } else {
    464466            return trc_lazy(nameTag, I18n.escape(relation.get(nameTag)));
  • trunk/test/unit/org/openstreetmap/josm/gui/DefaultNameFormatterTest.java

    r7109 r7112  
    22package org.openstreetmap.josm.gui;
    33
     4import static org.hamcrest.CoreMatchers.is;
     5import static org.junit.Assert.assertThat;
    46import static org.junit.Assert.assertTrue;
    57
     
    1719import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    1820import org.openstreetmap.josm.data.osm.Relation;
     21import org.openstreetmap.josm.data.osm.Way;
    1922import org.openstreetmap.josm.gui.tagging.TaggingPresetReader;
    2023import org.openstreetmap.josm.gui.tagging.TaggingPresets;
     
    7679        }
    7780    }
     81
     82    @Test
     83    public void testRelationName() throws Exception {
     84        assertThat(getFormattedRelationName("X=Y"), is("relation (0, 0 members)"));
     85        assertThat(getFormattedRelationName("name=Foo"), is("relation (\"Foo\", 0 members)"));
     86        assertThat(getFormattedRelationName("type=route route=tram ref=123"), is("route (\"123\", 0 members)"));
     87        assertThat(getFormattedRelationName("type=multipolygon building=yes"), is("multipolygon (\"building\", 0 members)"));
     88        assertThat(getFormattedRelationName("type=multipolygon building=yes ref=123"), is("multipolygon (\"123\", 0 members)"));
     89        assertThat(getFormattedRelationName("type=multipolygon building=yes addr:housenumber=123"), is("multipolygon (\"building\", 0 members)"));
     90        assertThat(getFormattedRelationName("type=multipolygon building=residential addr:housenumber=123"), is("multipolygon (\"residential\", 0 members)"));
     91    }
     92
     93    @Test
     94    public void testWayName() throws Exception {
     95        assertThat(getFormattedWayName("building=yes"), is("building (0 nodes)"));
     96        assertThat(getFormattedWayName("building=yes addr:housenumber=123"), is("House number 123 (0 nodes)"));
     97        assertThat(getFormattedWayName("building=yes addr:housenumber=123 addr:street=FooStreet"), is("House number 123 at FooStreet (0 nodes)"));
     98        assertThat(getFormattedWayName("building=yes addr:housenumber=123 addr:housename=FooName"), is("House FooName (0 nodes)"));
     99    }
     100
     101    static String getFormattedRelationName(String tagsString) {
     102        return DefaultNameFormatter.getInstance().format((Relation) TestUtils.createPrimitive("relation " + tagsString));
     103    }
     104
     105    static String getFormattedWayName(String tagsString) {
     106        return DefaultNameFormatter.getInstance().format((Way) TestUtils.createPrimitive("way " + tagsString));
     107    }
    78108}
Note: See TracChangeset for help on using the changeset viewer.