use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testContinue.
/**
* Test the continue keyword. If a type is marked with this word, then
* further matches are performed and this might result in more types
* being added.
*/
@Test
public void testContinue() {
RuleSet rs = makeRuleSet("highway=primary [0x1 continue]" + "highway=primary [0x2 continue]" + "highway=primary [0x3]" + "highway=primary [0x4]");
Way el = new Way(1);
el.addTag("highway", "primary");
final List<GType> list = new ArrayList<>();
rs.resolveType(el, new TypeResult() {
public void add(Element el, GType type) {
list.add(type);
}
});
GType type = list.get(0);
assertEquals("first type", 1, type.getType());
assertEquals("continue search", true, type.isContinueSearch());
assertEquals("number of result types", 3, list.size());
assertEquals("type of first", 1, list.get(0).getType());
assertEquals("type of second", 2, list.get(1).getType());
assertEquals("type of third", 3, list.get(2).getType());
}
use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testNEAtTopWithRE.
@Test
public void testNEAtTopWithRE() {
RuleSet rs = makeRuleSet("a != 'fred' & a ~ '.*' [0x2]");
Element el = new Way(1);
el.addTag("a", "tom");
GType type = getFirstType(rs, el);
assertNotNull(type);
assertEquals(2, type.getType());
}
use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testOptimizeWithOr.
/**
* Failure of the optimiser to promote the correct term to the front.
* Example from mailing list.
*/
@Test
public void testOptimizeWithOr() {
String s = "highway ~ '(secondary|tertiary|unclassified|residential|minor|living_street|service)' " + "& oneway=* " + "& (cycleway=opposite | cycleway=opposite_lane | cycleway=opposite_track )" + "[0x2 ]";
RuleSet rs = makeRuleSet(s);
Element el = new Way(1);
el.addTag("highway", "tertiary");
el.addTag("oneway", "1");
el.addTag("cycleway", "opposite_track");
GType type = getFirstType(rs, el);
assertNotNull(type);
assertEquals(2, type.getType());
el.addTag("cycleway", "fred");
type = getFirstType(rs, el);
assertNull(type);
el.addTag("cycleway", "opposite");
type = getFirstType(rs, el);
assertNotNull(type);
// Copy for LinkedOp which remembers the last matched element
el = el.copy();
el.addTag("cycleway", "opposite_lane");
type = getFirstType(rs, el);
assertNotNull(type);
el.addTag("highway", "fred");
type = getFirstType(rs, el);
assertNull(type);
}
use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testIncludeAsTagName2.
@Test
public void testIncludeAsTagName2() {
RuleSet rs = makeRuleSet("include = yes [0x2]");
Way way = new Way(1);
way.addTag("include", "yes");
GType type = getFirstType(rs, way);
assertNotNull(type);
assertEquals(2, type.getType());
}
use of uk.me.parabola.mkgmap.reader.osm.Way in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testGType.
/**
* Tests for the road classification and other parts of the GType.
*/
@Test
public void testGType() {
RuleSet rs = makeRuleSet("highway=motorway " + "[0x1 road_class=4 road_speed=7 default_name='motor way']\n");
Element el = new Way(1);
el.addTag("highway", "motorway");
GType type = getFirstType(rs, el);
assertNotNull(type);
// Check that the correct class and speed are returned.
assertEquals("class", 4, type.getRoadClass());
assertEquals("class", 7, type.getRoadSpeed());
assertEquals("default name", "motor way", type.getDefaultName());
}
Aggregations