public void readZones(String file, String idHeader) { Collection<SimpleFeature> features = ShapeFileReader.getAllFeatures(file); if (features.size() != zones.size()) { throw new RuntimeException("Features#: " + features.size() + "; zones#: " + zones.size()); } for (SimpleFeature ft : features) { String id = ft.getAttribute(idHeader).toString(); Zone z = zones.get(Id.create(id, Zone.class)); z.setMultiPolygon((MultiPolygon)ft.getDefaultGeometry()); } } }
public void testNodesShape() { String netFileName = "test/scenarios/equil/network.xml"; String outputFileShp = getOutputDirectory() + "./network.shp"; Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); final Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).readFile(netFileName); new Nodes2ESRIShape(network,outputFileShp, "DHDN_GK4").write(); Collection<SimpleFeature> writtenFeatures = ShapeFileReader.getAllFeatures(outputFileShp); Assert.assertEquals(network.getNodes().size(), writtenFeatures.size()); } }
public void testSelectedPlansActsShape() throws IOException { String outputDir = getOutputDirectory(); String outShp = getOutputDirectory() + "acts.shp"; Scenario scenario = ScenarioUtils.createScenario(super.loadConfig(null)); Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).parse(new GZIPInputStream(getClass().getResourceAsStream("/test/scenarios/berlin/network.xml.gz"))); Population population = scenario.getPopulation(); new PopulationReader(scenario).parse(new GZIPInputStream(getClass().getResourceAsStream("/test/scenarios/berlin/plans_hwh_1pct.xml.gz"))); CoordinateReferenceSystem crs = MGC.getCRS("DHDN_GK4"); SelectedPlans2ESRIShape sp = new SelectedPlans2ESRIShape(population, network, crs, outputDir); sp.setOutputSample(0.05); sp.setActBlurFactor(100); sp.setWriteActs(true); sp.setWriteLegs(false); sp.write(); Collection<SimpleFeature> writtenFeatures = ShapeFileReader.getAllFeatures(outShp); Assert.assertEquals(2235, writtenFeatures.size()); }
public void testSelectedPlansLegsShape() throws IOException { String outputDir = getOutputDirectory(); String outShp = getOutputDirectory() + "legs.shp"; Scenario scenario = ScenarioUtils.createScenario(super.loadConfig(null)); Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).parse(new GZIPInputStream(getClass().getResourceAsStream("/test/scenarios/berlin/network.xml.gz"))); Population population = scenario.getPopulation(); new PopulationReader(scenario).parse(new GZIPInputStream(getClass().getResourceAsStream("/test/scenarios/berlin/plans_hwh_1pct.xml.gz"))); CoordinateReferenceSystem crs = MGC.getCRS("DHDN_GK4"); SelectedPlans2ESRIShape sp = new SelectedPlans2ESRIShape(population, network, crs, outputDir); sp.setOutputSample(0.05); sp.setLegBlurFactor(100); sp.setWriteActs(false); sp.setWriteLegs(true); sp.write(); Collection<SimpleFeature> writtenFeatures = ShapeFileReader.getAllFeatures(outShp); Assert.assertEquals(1431, writtenFeatures.size()); }
public void testPolygonLanesShape() { String netFileName = "test/scenarios/equil/network.xml"; String outputFileP = getOutputDirectory() + "./network.shp"; Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); scenario.getConfig().global().setCoordinateSystem("DHDN_GK4"); final Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).readFile(netFileName); FeatureGeneratorBuilderImpl builder = new FeatureGeneratorBuilderImpl(network, "DHDN_GK4"); CoordinateReferenceSystem crs = MGC.getCRS("DHDN_GK4"); builder.setWidthCoefficient(1); builder.setFeatureGeneratorPrototype(PolygonFeatureGenerator.class); builder.setWidthCalculatorPrototype(LanesBasedWidthCalculator.class); builder.setCoordinateReferenceSystem(crs); new Links2ESRIShape(network,outputFileP, builder).write(); Collection<SimpleFeature> writtenFeatures = ShapeFileReader.getAllFeatures(outputFileP); Assert.assertEquals(network.getLinks().size(), writtenFeatures.size()); }
public void testPolygonCapacityShape() { String netFileName = "test/scenarios/equil/network.xml"; String outputFileP = getOutputDirectory() + "./network.shp"; Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); scenario.getConfig().global().setCoordinateSystem("DHDN_GK4"); final Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).readFile(netFileName); FeatureGeneratorBuilderImpl builder = new FeatureGeneratorBuilderImpl(network, "DHDN_GK4"); CoordinateReferenceSystem crs = MGC.getCRS("DHDN_GK4"); builder.setWidthCoefficient(0.001); builder.setFeatureGeneratorPrototype(PolygonFeatureGenerator.class); builder.setWidthCalculatorPrototype(CapacityBasedWidthCalculator.class); builder.setCoordinateReferenceSystem(crs); new Links2ESRIShape(network,outputFileP, builder).write(); Collection<SimpleFeature> writtenFeatures = ShapeFileReader.getAllFeatures(outputFileP); Assert.assertEquals(network.getLinks().size(), writtenFeatures.size()); }
public void testPolygonFreespeedShape() { String netFileName = "test/scenarios/equil/network.xml"; String outputFileP = getOutputDirectory() + "./network.shp"; Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); scenario.getConfig().global().setCoordinateSystem("DHDN_GK4"); final Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).readFile(netFileName); FeatureGeneratorBuilderImpl builder = new FeatureGeneratorBuilderImpl(network, "DHDN_GK4"); CoordinateReferenceSystem crs = MGC.getCRS("DHDN_GK4"); builder.setWidthCoefficient(1); builder.setFeatureGeneratorPrototype(PolygonFeatureGenerator.class); builder.setWidthCalculatorPrototype(LanesBasedWidthCalculator.class); builder.setCoordinateReferenceSystem(crs); new Links2ESRIShape(network,outputFileP, builder).write(); Collection<SimpleFeature> writtenFeatures = ShapeFileReader.getAllFeatures(outputFileP); Assert.assertEquals(network.getLinks().size(), writtenFeatures.size()); }
public void testLineStringShape() { String netFileName = "test/scenarios/equil/network.xml"; String outputFileShp = getOutputDirectory() + "./network.shp"; Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); scenario.getConfig().global().setCoordinateSystem("DHDN_GK4"); final Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).readFile(netFileName); FeatureGeneratorBuilderImpl builder = new FeatureGeneratorBuilderImpl(network, "DHDN_GK4"); CoordinateReferenceSystem crs = MGC.getCRS("DHDN_GK4"); builder.setWidthCoefficient(1); builder.setFeatureGeneratorPrototype(LineStringBasedFeatureGenerator.class); builder.setWidthCalculatorPrototype(LanesBasedWidthCalculator.class); builder.setCoordinateReferenceSystem(crs); new Links2ESRIShape(network,outputFileShp, builder).write(); Collection<SimpleFeature> writtenFeatures = ShapeFileReader.getAllFeatures(outputFileShp); Assert.assertEquals(network.getLinks().size(), writtenFeatures.size()); }