Skip to content

Commit

Permalink
use avro network instead of geojson
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Jun 10, 2024
1 parent d4b028b commit dfe1f24
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import org.apache.avro.file.DataFileWriter;
import org.apache.avro.generic.GenericData;
import org.apache.avro.generic.GenericDatumWriter;
import org.apache.avro.io.DatumWriter;
import org.apache.avro.specific.SpecificDatumWriter;
import org.apache.commons.lang3.mutable.MutableObject;
import org.locationtech.jts.geom.Geometry;
import org.matsim.api.core.v01.Coord;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
import java.util.regex.Pattern;


/**
* Note that {@link CreateAvroNetwork} offers a more efficient way to store network data, which also loads much faster in the browser.
*/
@CommandLine.Command(name = "network-geojson", description = "Create geojson representation of a network.")
@CommandSpec(requireNetwork = true, produces = "network.geojson")
public class CreateGeoJsonNetwork implements MATSimAppCommand {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public void configure(Header header, Layout layout) {
viz.height = 12.;
// viz.datasets.csvFile = data.compute(AirPollutionAnalysis.class, "emissions_per_link_per_m.csv");
viz.datasets.csvFile = data.computeWithPlaceholder(AirPollutionAnalysis.class, "emissions_per_link_per_m.%s", "csv");

// TODO: switch this class to use map plot and avro network
viz.network = data.compute(CreateGeoJsonNetwork.class, "network.geojson");
viz.display.color.columnName = "CO2_TOTAL [g/m]";
viz.display.color.dataset = "csvFile";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.matsim.simwrapper.dashboard;

import org.matsim.application.analysis.noise.NoiseAnalysis;
import org.matsim.application.prepare.network.CreateGeoJsonNetwork;
import org.matsim.application.prepare.network.CreateAvroNetwork;
import org.matsim.simwrapper.Dashboard;
import org.matsim.simwrapper.Header;
import org.matsim.simwrapper.Layout;
Expand Down Expand Up @@ -53,7 +53,7 @@ public void configure(Header header, Layout layout) {
viz.zoom = data.context().mapZoomLevel;
viz.minValue = minDb;
viz.maxValue = maxDb;
viz.setShape(data.compute(CreateGeoJsonNetwork.class, "network.geojson", "--with-properties"), "id");
viz.setShape(data.compute(CreateAvroNetwork.class, "network.avro", "--with-properties"), "id");
viz.addDataset("noise", data.compute(NoiseAnalysis.class, "emission_per_day.csv"));
viz.display.lineColor.dataset = "noise";
viz.display.lineColor.columnName = "value";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.matsim.application.analysis.LogFileAnalysis;
import org.matsim.application.analysis.traffic.TrafficAnalysis;
import org.matsim.application.prepare.network.CreateAvroNetwork;
import org.matsim.application.prepare.network.CreateGeoJsonNetwork;
import org.matsim.simwrapper.Dashboard;
import org.matsim.simwrapper.Header;
import org.matsim.simwrapper.Layout;
Expand Down Expand Up @@ -36,8 +35,7 @@ public void configure(Header header, Layout layout) {
viz.height = 7.5;
viz.width = 2.0;

// viz.setShape(data.compute(CreateAvroNetwork.class, "network.avro", "--with-properties"), "id");
viz.setShape(data.compute(CreateGeoJsonNetwork.class, "network.geojson", "--with-properties"), "id");
viz.setShape(data.compute(CreateAvroNetwork.class, "network.avro", "--with-properties"), "id");
viz.addDataset("traffic", data.compute(TrafficAnalysis.class, "traffic_stats_by_link_daily.csv"));

viz.display.lineColor.dataset = "traffic";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.apache.commons.lang.StringUtils;
import org.matsim.application.analysis.traffic.CountComparisonAnalysis;
import org.matsim.application.prepare.network.CreateGeoJsonNetwork;
import org.matsim.application.prepare.network.CreateAvroNetwork;
import org.matsim.simwrapper.Dashboard;
import org.matsim.simwrapper.Header;
import org.matsim.simwrapper.Layout;
Expand Down Expand Up @@ -212,7 +212,7 @@ private void createTab(Layout layout, List<String> argList, String tabName, Set<
viz.title = "Relative traffic volumes";
viz.height = 8.0;

viz.setShape(data.withDefaultContext().compute(CreateGeoJsonNetwork.class, "network.geojson", "--with-properties"), "id");
viz.setShape(data.withDefaultContext().compute(CreateAvroNetwork.class, "network.avro", "--with-properties"), "id");
viz.addDataset("counts", data.compute(CountComparisonAnalysis.class, "count_comparison_daily.csv", args));

viz.center = data.withDefaultContext().context().getCenter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.matsim.api.core.v01.TransportMode;
import org.matsim.application.analysis.traffic.TrafficAnalysis;
import org.matsim.application.prepare.network.CreateGeoJsonNetwork;
import org.matsim.application.prepare.network.CreateAvroNetwork;
import org.matsim.simwrapper.Dashboard;
import org.matsim.simwrapper.Header;
import org.matsim.simwrapper.Layout;
Expand Down Expand Up @@ -76,7 +76,7 @@ public void configure(Header header, Layout layout) {
viz.center = data.context().getCenter();
viz.zoom = data.context().mapZoomLevel;

viz.setShape(data.compute(CreateGeoJsonNetwork.class, "network.geojson"), "id");
viz.setShape(data.compute(CreateAvroNetwork.class, "network.avro"), "id");

viz.addDataset("traffic", data.compute(TrafficAnalysis.class, "traffic_stats_by_link_daily.csv"));

Expand Down

0 comments on commit dfe1f24

Please sign in to comment.