Search in sources :

Example 21 with Element

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

the class AddAccessActionTest method testNoValue.

/**
 * If a substitution tag has no value then the value of the tag is not
 * changed by the action.
 */
@Test
public void testNoValue() {
    Action act = new AddAccessAction("${noexist}", true);
    Element el = stdElement();
    String val = "before";
    el.addTag("mkgmap:bicycle", val);
    act.perform(el);
    assertSame("no substitution", val, el.getTag("mkgmap:bicycle"));
}
Also used : Element(uk.me.parabola.mkgmap.reader.osm.Element) Test(org.junit.Test)

Example 22 with Element

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

the class AddAccessActionTest method testOverwriteValue.

/**
 * If modify is set to true all access tags should be set
 * no matter if they are set before.
 */
@Test
public void testOverwriteValue() {
    Action act = new AddAccessAction("${access}", true);
    Element el = stdElement();
    el.addTag("mkgmap:bicycle", "yes");
    act.perform(el);
    for (String accessTag : ACCESS_TAGS.keySet()) {
        assertEquals("no overwrite", "no", el.getTag(accessTag));
    }
}
Also used : Element(uk.me.parabola.mkgmap.reader.osm.Element) Test(org.junit.Test)

Example 23 with Element

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

the class AddTagActionTest method testNoValue.

/**
 * If a substitution tag has no value then the value of the tag is not
 * changed by the action.
 */
@Test
public void testNoValue() {
    Action act = new AddTagAction("a", "Road ${noexist}, name ${name:cy}", true);
    Element el = stdElement();
    String val = "before";
    el.addTag("a", val);
    act.perform(el);
    assertSame("no substitution", val, el.getTag("a"));
}
Also used : Element(uk.me.parabola.mkgmap.reader.osm.Element) Test(org.junit.Test)

Example 24 with Element

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

the class AddTagActionTest method testBareSubst.

/**
 * Simple test, substituting the whole string.
 */
@Test
public void testBareSubst() {
    Action act = new AddTagAction("a", "${ref}", false);
    Element el = stdElement();
    act.perform(el);
    assertEquals("subst ref", REFVAL, el.getTag("a"));
}
Also used : Element(uk.me.parabola.mkgmap.reader.osm.Element) Test(org.junit.Test)

Example 25 with Element

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

the class AddTagActionTest method testNumberWithUnit.

/**
 * Test substitutions that get a conversion factor applied to them.
 */
@Test
public void testNumberWithUnit() {
    Action act = new AddTagAction("result", "${ele|conv:m=>ft}", false);
    Element el = stdElement();
    el.addTag("ele", "100");
    act.perform(el);
    assertEquals("subst ref", "328", el.getTag("result"));
}
Also used : Element(uk.me.parabola.mkgmap.reader.osm.Element) 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