Search in sources :

Example 41 with Element

use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.

the class ValueBuilderTest method testTranslitLatin1.

@Test
public void testTranslitLatin1() {
    ValueBuilder vb = new ValueBuilder("${name|latin1}");
    Element el = new Way(1);
    el.addTag("name", "frêdş");
    String s = vb.build(el, null);
    assertEquals("frêds", s);
}
Also used : Element(uk.me.parabola.mkgmap.reader.osm.Element) Way(uk.me.parabola.mkgmap.reader.osm.Way) Test(org.junit.Test)

Example 42 with Element

use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.

the class ValueBuilderTest method testUsedTags.

@Test
public void testUsedTags() {
    ValueBuilder vb = new ValueBuilder("${name}");
    Element el = new Way(1);
    el.addTag("name", "fred");
    el.addTag("highway", "primary");
    vb.build(el, null);
    Set<String> exp = new HashSet<>();
    exp.add("name");
    assertEquals(exp, vb.getUsedTags());
}
Also used : Element(uk.me.parabola.mkgmap.reader.osm.Element) Way(uk.me.parabola.mkgmap.reader.osm.Way) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 43 with Element

use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.

the class ValueBuilderTest method testSubstWithSpace.

@Test
public void testSubstWithSpace() {
    ValueBuilder vb = new ValueBuilder("${name|subst:abc=>x y z }!");
    Element el = new Way(1);
    el.addTag("name", "Tabc");
    String s = vb.build(el, null);
    assertEquals("Tx y z !", s);
}
Also used : Element(uk.me.parabola.mkgmap.reader.osm.Element) Way(uk.me.parabola.mkgmap.reader.osm.Way) Test(org.junit.Test)

Example 44 with Element

use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.

the class ValueBuilderTest method testSpacedQuotedArgs.

@Test
public void testSpacedQuotedArgs() {
    ValueBuilder vb = new ValueBuilder("${name | subst:'abc=>x|y' | subst:'defg=>w|w' | def:'unset string' }");
    Element el = new Way(1);
    // No tags set, so default value will be applied.
    String s = vb.build(el, null);
    assertEquals("name not set, so default is applied", "unset string", s);
    // Name tag is set, so substitutions are made
    el.addTag("name", "abc defg");
    s = vb.build(el, null);
    assertEquals("substitutions in name", "x|y w|w", s);
}
Also used : Element(uk.me.parabola.mkgmap.reader.osm.Element) Way(uk.me.parabola.mkgmap.reader.osm.Way) Test(org.junit.Test)

Example 45 with Element

use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.

the class ValueBuilderTest method testExample.

@Test
public void testExample() {
    ValueBuilder vb = new ValueBuilder("${name|subst:'^(Doctor|Dokter) ~>Dr '}");
    Element el = new Way(1);
    el.addTag("name", "Doctor Who");
    String s = vb.build(el, null);
    assertEquals("Dr Who", s);
}
Also used : Element(uk.me.parabola.mkgmap.reader.osm.Element) Way(uk.me.parabola.mkgmap.reader.osm.Way) Test(org.junit.Test)

Aggregations

Element (uk.me.parabola.mkgmap.reader.osm.Element)94 Test (org.junit.Test)75 Way (uk.me.parabola.mkgmap.reader.osm.Way)48 GType (uk.me.parabola.mkgmap.reader.osm.GType)25 TestUtils.makeRuleSet (func.lib.TestUtils.makeRuleSet)23 Action (uk.me.parabola.mkgmap.osmstyle.actions.Action)15 Rule (uk.me.parabola.mkgmap.reader.osm.Rule)8 ArrayList (java.util.ArrayList)7 Node (uk.me.parabola.mkgmap.reader.osm.Node)7 Relation (uk.me.parabola.mkgmap.reader.osm.Relation)7 Coord (uk.me.parabola.imgfmt.app.Coord)5 StringStyleFileLoader (func.lib.StringStyleFileLoader)4 Map (java.util.Map)4 GeneralRelation (uk.me.parabola.mkgmap.reader.osm.GeneralRelation)4 TypeResult (uk.me.parabola.mkgmap.reader.osm.TypeResult)4 HashMap (java.util.HashMap)3 IdentityHashMap (java.util.IdentityHashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Area (uk.me.parabola.imgfmt.app.Area)2