use of uk.me.parabola.mkgmap.reader.osm.Element 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.Element 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());
}
use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testIncludeFile.
@Test
public void testIncludeFile() {
StyleFileLoader loader = new StringStyleFileLoader(new String[][] { { "lines", "include incfile;" }, { "incfile", "highway=secondary [0x3]" } });
RuleSet rs = makeRuleSet(loader);
Element el = new Way(1);
el.addTag("highway", "secondary");
GType type = getFirstType(rs, el);
assertNotNull(type);
assertEquals(3, type.getType());
}
use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testWildcardTop.
/**
* You can now have a wild card at the top level.
*/
@Test
public void testWildcardTop() {
RuleSet rs = makeRuleSet("highway=* {set a=fred} [0x1]\n");
assertNotNull("rule found", rs);
Element el = new Way(1);
el.addTag("highway", "secondary");
GType type = getFirstType(rs, el);
assertNotNull("can find match", type);
assertEquals("correct type", 1, type.getType());
assertEquals("tag set", "fred", el.getTag("a"));
}
use of uk.me.parabola.mkgmap.reader.osm.Element in project mkgmap by openstreetmap.
the class RuleFileReaderTest method testRegexp.
/**
* Check for the regexp handling.
*/
@Test
public void testRegexp() {
RuleSet rs = makeRuleSet("highway=* & name ~ 'blue.*' [0x2]\n");
assertNotNull("rule found", rs);
// Set up element with matching name
Element el = new Way(1);
el.addTag("highway", "secondary");
el.addTag("name", "blue sq");
GType type = getFirstType(rs, el);
assertNotNull("matched regexp", type);
assertEquals("matched type", 2, type.getType());
// change name to one that should not match
el.addTag("name", "yellow");
type = getFirstType(rs, el);
assertNull("no match for yello", type);
}
Aggregations