@Test public void testRepeatingActs() { final MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); PopulationReaderMatsimV4 reader = new PopulationReaderMatsimV4(scenario); final Population population = scenario.getPopulation(); String str = "<?xml version=\"1.0\" ?>"+ "<!DOCTYPE plans SYSTEM \"http://www.matsim.org/files/dtd/plans_v4.dtd\">"+ "<plans>"+ "<person id=\"1\">"+ " <plan>"+ " <act type=\"h\" x=\"-25000\" y=\"0\" end_time=\"06:00\" />"+ " <leg mode=\"walk\" />"+ " <act type=\"w\" x=\"10000\" y=\"0\" dur=\"03:30\" />"+ " <act type=\"l\" x=\"10000\" y=\"0\" dur=\"00:30\" />"+ " </plan>"+ "</person>"+ "</plans>"; reader.parse(new ByteArrayInputStream(str.getBytes())); Plan plan = population.getPersons().get(Id.create(1, Person.class)).getSelectedPlan(); Assert.assertEquals(4, plan.getPlanElements().size()); Assert.assertTrue(plan.getPlanElements().get(0) instanceof Activity); Assert.assertTrue(plan.getPlanElements().get(1) instanceof Leg); Assert.assertTrue(plan.getPlanElements().get(2) instanceof Activity); Assert.assertTrue(plan.getPlanElements().get(3) instanceof Activity); }
@Test public void testRepeatingLegs() { final MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); PopulationReaderMatsimV4 reader = new PopulationReaderMatsimV4(scenario); final Population population = scenario.getPopulation(); String str = "<?xml version=\"1.0\" ?>"+ "<!DOCTYPE plans SYSTEM \"http://www.matsim.org/files/dtd/plans_v4.dtd\">"+ "<plans>"+ "<person id=\"1\">"+ " <plan>"+ " <act type=\"h\" x=\"-25000\" y=\"0\" end_time=\"06:00\" />"+ " <leg mode=\"walk\" />"+ " <leg mode=\"pt\" />"+ " <leg mode=\"walk\" />"+ " <act type=\"w\" x=\"10000\" y=\"0\" dur=\"03:30\" />"+ " </plan>"+ "</person>"+ "</plans>"; reader.parse(new ByteArrayInputStream(str.getBytes())); Plan plan = population.getPersons().get(Id.create(1, Person.class)).getSelectedPlan(); Assert.assertEquals(5, plan.getPlanElements().size()); Assert.assertTrue(plan.getPlanElements().get(0) instanceof Activity); Assert.assertTrue(plan.getPlanElements().get(1) instanceof Leg); Assert.assertTrue(plan.getPlanElements().get(2) instanceof Leg); Assert.assertTrue(plan.getPlanElements().get(3) instanceof Leg); Assert.assertTrue(plan.getPlanElements().get(4) instanceof Activity); }
"</person>"+ "</plans>"; reader.parse(new ByteArrayInputStream(str.getBytes()));