Search in sources :

Example 66 with Way

use of uk.me.parabola.mkgmap.reader.osm.Way 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 67 with Way

use of uk.me.parabola.mkgmap.reader.osm.Way 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 68 with Way

use of uk.me.parabola.mkgmap.reader.osm.Way 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)

Example 69 with Way

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

the class RulesTest method makeWay.

private static Way makeWay() {
    Way way = new Way(1);
    way.addPoint(new Coord(1, 1));
    way.addPoint(new Coord(2, 2));
    return way;
}
Also used : Coord(uk.me.parabola.imgfmt.app.Coord) Way(uk.me.parabola.mkgmap.reader.osm.Way)

Example 70 with Way

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

the class RulesTest method evalWays.

private boolean[] evalWays(Op op) {
    boolean[] result = new boolean[testWays.size()];
    int count = 0;
    for (Way w : testWays) {
        result[count++] = op.eval(w);
    }
    return result;
}
Also used : Way(uk.me.parabola.mkgmap.reader.osm.Way)

Aggregations

Way (uk.me.parabola.mkgmap.reader.osm.Way)142 Test (org.junit.Test)94 TestUtils.makeRuleSet (func.lib.TestUtils.makeRuleSet)70 GType (uk.me.parabola.mkgmap.reader.osm.GType)60 Element (uk.me.parabola.mkgmap.reader.osm.Element)48 Coord (uk.me.parabola.imgfmt.app.Coord)31 ArrayList (java.util.ArrayList)18 MapPoint (uk.me.parabola.mkgmap.general.MapPoint)12 MapExitPoint (uk.me.parabola.mkgmap.general.MapExitPoint)11 List (java.util.List)8 Node (uk.me.parabola.mkgmap.reader.osm.Node)8 HashMap (java.util.HashMap)7 IdentityHashMap (java.util.IdentityHashMap)6 Map (java.util.Map)6 StringStyleFileLoader (func.lib.StringStyleFileLoader)5 CoordNode (uk.me.parabola.imgfmt.app.CoordNode)5 Relation (uk.me.parabola.mkgmap.reader.osm.Relation)5 CoordPOI (uk.me.parabola.mkgmap.reader.osm.CoordPOI)4 RestrictionRelation (uk.me.parabola.mkgmap.reader.osm.RestrictionRelation)4 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)3