diff --git a/.github/workflows/code-coverage.yaml b/.github/workflows/code-coverage.yaml
index 20ffe41971a..a5a28e1fdef 100644
--- a/.github/workflows/code-coverage.yaml
+++ b/.github/workflows/code-coverage.yaml
@@ -15,9 +15,9 @@ jobs:
uses: actions/checkout@v4
- name: Setup Java
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
- java-version: 17
+ java-version: 21
distribution: 'zulu'
cache: 'maven'
@@ -26,7 +26,7 @@ jobs:
run: mvn verify -P jacoco --batch-mode --also-make --projects matsim -Dmaven.test.redirectTestOutputToFile -Dmatsim.preferLocalDtds=true
- name: Push coverage to CodeCov
- uses: codecov/codecov-action@v3
+ uses: codecov/codecov-action@v4
with:
files: ./matsim/target/site/jacoco/jacoco.xml
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
index 021bae1c67c..c3601652607 100644
--- a/.github/workflows/codeql.yml
+++ b/.github/workflows/codeql.yml
@@ -19,15 +19,15 @@ jobs:
uses: actions/checkout@v4
- name: Setup Java
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
- java-version: 17
+ java-version: 21
distribution: 'zulu'
cache: 'maven'
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
- uses: github/codeql-action/init@v2
+ uses: github/codeql-action/init@v3
with:
languages: 'java'
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -41,9 +41,9 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
- uses: github/codeql-action/autobuild@v2
+ uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@v2
+ uses: github/codeql-action/analyze@v3
with:
category: "/language:java"
diff --git a/.github/workflows/deploy-dtds.yaml b/.github/workflows/deploy-dtds.yaml
new file mode 100644
index 00000000000..bb48f61d27b
--- /dev/null
+++ b/.github/workflows/deploy-dtds.yaml
@@ -0,0 +1,24 @@
+name: deploy-dtds-on-website
+
+on:
+ push:
+ branches:
+ - master
+ paths:
+ - matsim/src/main/resources/dtd
+
+jobs:
+ rsync-dtds:
+ name: sync DTDs to website
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: rsync dtds
+ uses: burnett01/rsync-deployments@7.0.1
+ with:
+ switches: -avz
+ path: matsim/src/main/resources/dtd/
+ remote_path: ~/httpdocs/files/dtd/
+ remote_host: ${{ secrets.WEBSITE_DEPLOY_HOST }}
+ remote_user: ${{ secrets.WEBSITE_DEPLOY_USER }}
+ remote_key: ${{ secrets.WEBSITE_SSH_PRIVATE_KEY }}
diff --git a/.github/workflows/deploy-on-pr-merge.yaml b/.github/workflows/deploy-on-pr-merge.yaml
index 332a3dfe178..44828163634 100644
--- a/.github/workflows/deploy-on-pr-merge.yaml
+++ b/.github/workflows/deploy-on-pr-merge.yaml
@@ -20,9 +20,9 @@ jobs:
uses: actions/checkout@v4
- name: Setup Java
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
- java-version: 17
+ java-version: 21
distribution: 'zulu'
cache: 'maven'
server-id: 'matsim-releases'
@@ -46,7 +46,7 @@ jobs:
- name: Submit Dependency Graph
# Generate a complete dependency graph and submit the graph to the GitHub repository.
# The goal is to improve security alerts from dependabot, because dependabot is not able to compute the complete dependency graph.
- uses: advanced-security/maven-dependency-submission-action@v3
+ uses: advanced-security/maven-dependency-submission-action@v4
env:
MAVEN_OPTS: -Xmx2g
diff --git a/.github/workflows/deploy-on-release-created.yaml b/.github/workflows/deploy-on-release-created.yaml
index 7c37d3c6f7d..a490c614a91 100644
--- a/.github/workflows/deploy-on-release-created.yaml
+++ b/.github/workflows/deploy-on-release-created.yaml
@@ -14,9 +14,9 @@ jobs:
uses: actions/checkout@v4
- name: Setup Java
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
- java-version: 17
+ java-version: 21
distribution: 'zulu'
cache: 'maven'
server-id: matsim-releases
diff --git a/.github/workflows/deploy-weekly.yaml b/.github/workflows/deploy-weekly.yaml
index 0861a80ff91..f30f7371684 100644
--- a/.github/workflows/deploy-weekly.yaml
+++ b/.github/workflows/deploy-weekly.yaml
@@ -15,9 +15,9 @@ jobs:
uses: actions/checkout@v4
- name: Setup Java
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
- java-version: 17
+ java-version: 21
distribution: 'zulu'
cache: 'maven'
server-id: 'matsim-releases'
diff --git a/.github/workflows/full-integration.yaml b/.github/workflows/full-integration.yaml
index 57789d54a8c..a75ea5767da 100644
--- a/.github/workflows/full-integration.yaml
+++ b/.github/workflows/full-integration.yaml
@@ -1,6 +1,7 @@
name: full-integration
on:
+ workflow_dispatch:
schedule:
- cron: '30 0 * * *' # daily at 0:30 UTC
@@ -13,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [ubuntu-latest, windows-latest]
+ os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Prepare git
@@ -24,9 +25,9 @@ jobs:
uses: actions/checkout@v4
- name: Setup Java
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
- java-version: 17
+ java-version: 21
distribution: 'zulu'
cache: 'maven'
diff --git a/.github/workflows/verify-push.yaml b/.github/workflows/verify-push.yaml
index f2a5b59d8ee..f7f5bce3718 100644
--- a/.github/workflows/verify-push.yaml
+++ b/.github/workflows/verify-push.yaml
@@ -66,6 +66,7 @@ jobs:
- contribs/simwrapper
- contribs/sbb-extensions
- contribs/simulatedannealing
+ - contribs/small-scale-traffic-generation
- benchmark
steps:
@@ -75,7 +76,7 @@ jobs:
- name: Detect changes against master
# we only want to build matsim (module) if changes are not limited to contribs
id: detect-changes
- uses: dorny/paths-filter@v2
+ uses: dorny/paths-filter@v3
if: ${{matrix.module == 'matsim'}}
with:
filters: |
@@ -84,9 +85,9 @@ jobs:
- name: Setup Java
if: ${{matrix.module != 'matsim' || steps.detect-changes.outputs.outside-contribs == 'true'}}
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
- java-version: 17
+ java-version: 21
distribution: 'zulu'
cache: 'maven'
diff --git a/.gitignore b/.gitignore
index 96f823b9a9c..6adadab9bb5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,5 +12,8 @@ matsimExamples
matsim/docs/doxygen/html
matsim/src/main/java/Doxyfile
+# VS Code files
+.vscode
+
# ignore output directories:
output/
diff --git a/benchmark/pom.xml b/benchmark/pom.xml
index 43ee7d820b2..22db5bc0464 100644
--- a/benchmark/pom.xml
+++ b/benchmark/pom.xml
@@ -4,7 +4,7 @@
org.matsim
matsim-all
- 16.0-SNAPSHOT
+ 2025.0-SNAPSHOT
4.0.0
jar
@@ -33,16 +33,20 @@
org.matsim
matsim
- 16.0-SNAPSHOT
+ 2025.0-SNAPSHOT
org.matsim
matsim-examples
- 16.0-SNAPSHOT
+ 2025.0-SNAPSHOT
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-engine
+
+
+ org.junit.jupiter
+ junit-jupiter
diff --git a/contribs/README.md b/contribs/README.md
index f29f739c4ef..4507e513d46 100644
--- a/contribs/README.md
+++ b/contribs/README.md
@@ -46,6 +46,7 @@ The MATSim core development team cannot make any guarantee that these extensions
| [shared_mobility](shared_mobility/README.md) | Simulate human-driven shared mobility (i.e., micromobility)
| [signals](signals/README.md) | Simulate traffic lights microscopically
| [simwrapper](simwrapper/README.md) | Creates dashboards automatically with [SimWrapper](https://simwrapper.github.io/)
+| [small-scale-traffic-generation](small-scale-traffic-generation/README.md) | Tool to generate small-scale commercial traffic
| [socnetsim](socnetsim/README.md) | Social network simulation
| [sumo](sumo/README.md) | Converter and integrations for [SUMO](https://sumo.dlr.de/])
| [taxi](taxi/README.md) | Taxi service functionality
diff --git a/contribs/accessibility/pom.xml b/contribs/accessibility/pom.xml
index 300f8fb1bd1..c4ead8bf378 100644
--- a/contribs/accessibility/pom.xml
+++ b/contribs/accessibility/pom.xml
@@ -2,7 +2,7 @@
org.matsim
contrib
- 16.0-SNAPSHOT
+ 2025.0-SNAPSHOT
4.0.0
org.matsim.contrib
@@ -37,12 +37,12 @@
org.matsim.contrib
matrixbasedptrouter
- 16.0-SNAPSHOT
+ 2025.0-SNAPSHOT
org.matsim.contrib
roadpricing
- 16.0-SNAPSHOT
+ 2025.0-SNAPSHOT
net.sf.trove4j
@@ -52,7 +52,7 @@
org.openstreetmap.osmosis
osmosis-core
- 0.48.3
+ ${osmosis.version}
@@ -65,12 +65,12 @@
org.openstreetmap.osmosis
osmosis-xml
- 0.48.3
+ ${osmosis.version}
org.matsim.contrib
analysis
- 16.0-SNAPSHOT
+ 2025.0-SNAPSHOT
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityUtils.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityUtils.java
index db9adc47ccd..1ed755c12b6 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityUtils.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityUtils.java
@@ -20,6 +20,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.geotools.api.feature.simple.SimpleFeature;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryFactory;
@@ -39,9 +40,8 @@
import org.matsim.core.network.NetworkUtils;
import org.matsim.core.network.algorithms.TransportModeNetworkFilter;
import org.matsim.core.utils.geometry.CoordUtils;
-import org.matsim.core.utils.gis.ShapeFileReader;
+import org.matsim.core.utils.gis.GeoFileReader;
import org.matsim.facilities.*;
-import org.opengis.feature.simple.SimpleFeature;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
@@ -225,7 +225,7 @@ public static final ActivityFacilities createFacilityForEachLink(String facility
public static final ActivityFacilities createFacilityFromBuildingShapefile(String shapeFileName, String identifierCaption, String numberOfHouseholdsCaption) {
- ShapeFileReader shapeFileReader = new ShapeFileReader();
+ GeoFileReader shapeFileReader = new GeoFileReader();
Collection features = shapeFileReader.readFileAndInitialize(shapeFileName);
ActivityFacilities facilities = FacilitiesUtils.createActivityFacilities("DensitiyFacilities");
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/FeatureSHP.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/FeatureSHP.java
index 9ff4d3711ed..2e5cee46039 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/FeatureSHP.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/FeatureSHP.java
@@ -24,11 +24,11 @@
import java.util.HashSet;
import java.util.Set;
-import org.geotools.data.DataStore;
-import org.geotools.data.FileDataStoreFinder;
+import org.geotools.api.data.DataStore;
+import org.geotools.api.data.FileDataStoreFinder;
+import org.geotools.api.data.SimpleFeatureSource;
+import org.geotools.api.feature.simple.SimpleFeature;
import org.geotools.data.simple.SimpleFeatureIterator;
-import org.geotools.data.simple.SimpleFeatureSource;
-import org.opengis.feature.simple.SimpleFeature;
/**
* Utility class for reading shape (.shp) files.
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/GridUtils.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/GridUtils.java
index b8cfc04417f..6e5aa187364 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/GridUtils.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/GridUtils.java
@@ -20,7 +20,6 @@
import org.matsim.facilities.ActivityFacility;
import org.matsim.facilities.FacilitiesUtils;
import org.matsim.utils.gis.shp2matsim.ShpGeometryUtils;
-import org.opengis.feature.simple.SimpleFeature;
public final class GridUtils {
// used from outside, e.g. in vsp playgrounds
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/VoronoiExample.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/VoronoiExample.java
index 24544971132..d1fe1df43d7 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/VoronoiExample.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/VoronoiExample.java
@@ -22,23 +22,23 @@
import java.util.Collection;
import java.util.List;
+import org.geotools.api.feature.simple.SimpleFeature;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.Polygon;
import org.locationtech.jts.triangulate.VoronoiDiagramBuilder;
import org.matsim.contrib.matrixbasedptrouter.utils.BoundingBox;
-import org.matsim.core.utils.gis.ShapeFileWriter;
-import org.opengis.feature.simple.SimpleFeature;
+import org.matsim.core.utils.gis.GeoFileWriter;
/**
* @author dziemke
*/
class VoronoiExample {
-
+
public static void main(String[] args) {
GeometryFactory geometryFactory = new GeometryFactory();
-
+
Collection sites = new ArrayList<>();
sites.add(new Coordinate(70, 70));
sites.add(new Coordinate(50, 150));
@@ -48,16 +48,16 @@ public static void main(String[] args) {
sites.add(new Coordinate(250, 150));
sites.add(new Coordinate(350, 50));
sites.add(new Coordinate(370, 170));
-
+
VoronoiDiagramBuilder voronoiDiagramBuilder = new VoronoiDiagramBuilder();
- voronoiDiagramBuilder.setSites(sites);
-
+ voronoiDiagramBuilder.setSites(sites);
+
List polygons = voronoiDiagramBuilder.getSubdivision().getVoronoiCellPolygons(geometryFactory);
-
+
BoundingBox boundingBox = BoundingBox.createBoundingBox(0, 0, 400, 200);
Polygon boundingPolygon = VoronoiGeometryUtils.createBoundingPolygon(boundingBox);
Collection cutGeometries = VoronoiGeometryUtils.cutPolygonsByBoundary(polygons, boundingPolygon);
Collection features = VoronoiGeometryUtils.createFeaturesFromPolygons(cutGeometries);
- ShapeFileWriter.writeGeometries(features, "/Users/dominik/voronoi_test.shp");
+ GeoFileWriter.writeGeometries(features, "/Users/dominik/voronoi_test.shp");
}
}
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/VoronoiGeometryUtils.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/VoronoiGeometryUtils.java
index 76e7273fd87..bcf0edc7b73 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/VoronoiGeometryUtils.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/VoronoiGeometryUtils.java
@@ -27,6 +27,8 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.geotools.api.feature.simple.SimpleFeature;
+import org.geotools.api.feature.simple.SimpleFeatureType;
import org.geotools.feature.simple.SimpleFeatureBuilder;
import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
import org.locationtech.jts.geom.Coordinate;
@@ -40,8 +42,6 @@
import org.matsim.core.utils.geometry.CoordUtils;
import org.matsim.facilities.ActivityFacilities;
import org.matsim.facilities.ActivityFacility;
-import org.opengis.feature.simple.SimpleFeature;
-import org.opengis.feature.simple.SimpleFeatureType;
/**
* @author dziemke
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/gis/CRSUtils.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/gis/CRSUtils.java
index a7171739b6a..92f3d94c5b8 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/gis/CRSUtils.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/gis/CRSUtils.java
@@ -24,18 +24,18 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.geotools.api.metadata.Identifier;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.NoSuchAuthorityCodeException;
+import org.geotools.api.referencing.crs.CRSAuthorityFactory;
+import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
+import org.geotools.api.referencing.operation.MathTransform;
+import org.geotools.api.referencing.operation.TransformException;
import org.geotools.referencing.CRS;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.Point;
-import org.opengis.metadata.Identifier;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.NoSuchAuthorityCodeException;
-import org.opengis.referencing.crs.CRSAuthorityFactory;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.TransformException;
/**
* Utility-class providing functionality related to coordinate reference
@@ -94,7 +94,7 @@ public static int getSRID(CoordinateReferenceSystem crs) {
/*
* Randomly get one identifier.
*/
- Identifier identifier = (Identifier) (crs.getIdentifiers().iterator().next());
+ Identifier identifier = crs.getIdentifiers().iterator().next();
if (identifier == null) {
return 0;
} else {
@@ -118,7 +118,7 @@ public static MathTransform findTransform(Geometry source, Geometry target) {
CoordinateReferenceSystem targetCRS = getCRS(target.getSRID());
try {
- return CRS.findMathTransform(sourceCRS, targetCRS);
+ return CRS.findMathTransform(sourceCRS, targetCRS);
} catch (FactoryException e) {
e.printStackTrace();
return null;
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/gis/ZoneLayer.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/gis/ZoneLayer.java
index c39948b714f..28bc2c41059 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/gis/ZoneLayer.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/gis/ZoneLayer.java
@@ -24,13 +24,13 @@
import java.util.List;
import java.util.Set;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
+import org.geotools.api.referencing.operation.MathTransform;
import org.geotools.referencing.CRS;
import org.locationtech.jts.geom.Point;
import org.locationtech.jts.index.SpatialIndex;
import org.locationtech.jts.index.quadtree.Quadtree;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
/**
* Representation of a spatial index containing zones backed by a quadtree.
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/osm/CombinedOsmSink.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/osm/CombinedOsmSink.java
index f7e39f4b588..7c5c1bcf2d2 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/osm/CombinedOsmSink.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/osm/CombinedOsmSink.java
@@ -22,6 +22,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.geotools.api.feature.simple.SimpleFeature;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryFactory;
@@ -41,7 +42,6 @@
import org.matsim.facilities.ActivityOption;
import org.matsim.facilities.FacilitiesUtils;
import org.matsim.utils.objectattributes.ObjectAttributes;
-import org.opengis.feature.simple.SimpleFeature;
import org.openstreetmap.osmosis.core.container.v0_6.BoundContainer;
import org.openstreetmap.osmosis.core.container.v0_6.EntityContainer;
import org.openstreetmap.osmosis.core.container.v0_6.EntityProcessor;
@@ -89,7 +89,7 @@ class CombinedOsmSink implements Sink {
private Map typeCount = new HashMap<>();
- private List landUseAreas = new ArrayList ();
+ private List landUseAreas = new ArrayList<>();
private int featureErrorCounter = 0;
private int buildingErrorCounter = 0;
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/osm/LandUseBuildingSink.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/osm/LandUseBuildingSink.java
index 0a5989ad5e8..3b55793e0d6 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/osm/LandUseBuildingSink.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/osm/LandUseBuildingSink.java
@@ -22,6 +22,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.geotools.api.feature.simple.SimpleFeature;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryFactory;
@@ -40,7 +41,6 @@
import org.matsim.facilities.ActivityOption;
import org.matsim.facilities.FacilitiesUtils;
import org.matsim.utils.objectattributes.ObjectAttributes;
-import org.opengis.feature.simple.SimpleFeature;
import org.openstreetmap.osmosis.core.container.v0_6.BoundContainer;
import org.openstreetmap.osmosis.core.container.v0_6.EntityContainer;
import org.openstreetmap.osmosis.core.container.v0_6.EntityProcessor;
@@ -69,11 +69,11 @@ class LandUseBuildingSink implements Sink {
private Map relationMap;
private ActivityFacilities facilities;
private ObjectAttributes facilityAttributes;
- private Map landUseTypeMap = new HashMap<>();
- private Map buildingTypeMap = new HashMap<>();
+ private final Map landUseTypeMap;
+ private Map buildingTypeMap;
private Map typeCount = new HashMap<>();
- private List features = new ArrayList ();
+ private List features = new ArrayList<>();
private double buildingTypeFromVicinityRange;
private String[] tagsToIgnoreBuildings;
diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/GeoJsonPolygonFeatureWriter.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/GeoJsonPolygonFeatureWriter.java
index c022be98067..f0e3dc08db3 100644
--- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/GeoJsonPolygonFeatureWriter.java
+++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/GeoJsonPolygonFeatureWriter.java
@@ -1,6 +1,6 @@
package org.matsim.contrib.accessibility.utils;
-import org.json.simple.JSONValue;
+import com.google.gson.Gson;
import org.matsim.api.core.v01.Coord;
import java.util.*;
@@ -34,7 +34,7 @@ public String asGeoJson() {
featureCollectionMap.put("features", featuresList);
featureCollectionMap.put("crs", parseCRS());
featureCollectionMap.put("bbox", boundingBox.getBoundingBox());
- return JSONValue.toJSONString(featureCollectionMap);
+ return new Gson().toJson(featureCollectionMap);
}
private List
+ *
+ * defaultArgs could be used to provide defaults when calling this method here; they would go in addition to what is coming in from "upstream" which is typically the command line.
+ *
+ * There are many execution paths that can be reached from this class, but a typical one for matsim-scenarios seems to be:
+ * - This method runs MATSimApplication.run( TheScenarioClass.class , args ).
+ * - That run class will instantiate an instance of TheScenarioClass (*), then do some args consistenty checking, then call the piccoli execute method.
+ * - The piccoli execute method will essentially call the "call" method of MATSimApplication.
+ * - I think that in the described execution path, this.config in that call method will initially be null. (The ctor of MATSimApplication was called via reflection at (*); I think that it was called there without a config argument.)
+ * - This call method then will do:
+ * - getCustomModules() (which is empty by default but can be overriden)
+ * - ConfigUtils.loadConfig(...) _without_ passing on the args
+ * - prepareConfig(...) (which is empty by default but is typically overridden, in this case in OpenBerlinScenario). In our case, this sets the typical scoring params and the typical replanning strategies.
+ *
- next one can override the config from some yaml file provided as a commandline option
+ *
- next args is parsed and set
+ *
- then some standard CL options are detected and set
+ *
- then createScenario(config) is called (which can be overwritten but is not)
+ *
- then prepareScenario(scenario) is called (which can be overwritten but is not)
+ *
- then a standard controler is created from scenario
+ *
- then prepareControler is called which can be overwritten
+ *
+ *
+ *
+ *
+ * @param clazz class of the scenario to run
+ * @param args pass arguments from the main method
+ * @param defaultArgs predefined default arguments that will always be present
+ */
+ public static void runWithDefaults(Class extends MATSimApplication> clazz, String[] args, String... defaultArgs) {
+
+ if (ApplicationUtils.isRunFromDesktop() && args.length == 0) {
+
+ System.setProperty("MATSIM_GUI_DESKTOP", "true");
+
+ if (defaultArgs.length > 0) {
+ String value = String.join(ARGS_DELIMITER, defaultArgs);
+ System.setProperty("MATSIM_GUI_ARGS", value);
+ }
+
+ // args are empty when run from desktop and is not used
+ run(clazz, "gui");
+
+ } else {
+ // run if no other command is present
+ if (args.length > 0) {
+ // valid command is present
+ if (args[0].equals("run") || args[0].equals("prepare") || args[0].equals("analysis") || args[0].equals("gui") ){
+ // If this is a run command, the default args can be applied
+ if (args[0].equals("run"))
+ args = ApplicationUtils.mergeArgs(args, defaultArgs);
+
+ } else {
+ // Automatically add run command
+ String[] runArgs = ApplicationUtils.mergeArgs(new String[]{"run"}, defaultArgs);
+ args = ApplicationUtils.mergeArgs(runArgs, args);
+ }
+
+ } else
+ // Automatically add run command
+ args = ApplicationUtils.mergeArgs(new String[]{"run"}, defaultArgs);
+
+ log.info("Running {} with: {}", clazz.getSimpleName(), String.join(" ", args));
+
+ run(clazz, args);
+ }
+ }
+
/**
* Calls an application class and forwards any exceptions.
*
@@ -512,7 +509,7 @@ public static Controler prepare(MATSimApplication app, Config config, String...
config = tmp != null ? tmp : config;
if (app.specs != null) {
- applySpecs(config, app.specs);
+ ApplicationUtils.applyConfigUpdate(config, app.specs);
}
if (app.remainingArgs != null) {
@@ -744,7 +741,7 @@ public Integer call() throws Exception {
}
/**
- * Option to switch post processing behavour
+ * Option to switch post-processing behaviour
*/
public enum PostProcessOption {
diff --git a/contribs/application/src/main/java/org/matsim/application/commands/RunScenario.java b/contribs/application/src/main/java/org/matsim/application/RunScenario.java
similarity index 67%
rename from contribs/application/src/main/java/org/matsim/application/commands/RunScenario.java
rename to contribs/application/src/main/java/org/matsim/application/RunScenario.java
index 3221069de95..460d5585ee5 100644
--- a/contribs/application/src/main/java/org/matsim/application/commands/RunScenario.java
+++ b/contribs/application/src/main/java/org/matsim/application/RunScenario.java
@@ -1,12 +1,11 @@
-package org.matsim.application.commands;
+package org.matsim.application;
-import org.matsim.application.MATSimApplication;
import picocli.CommandLine;
import java.util.concurrent.Callable;
@CommandLine.Command(name = "run", description = "Run the scenario")
-public class RunScenario implements Callable {
+class RunScenario implements Callable {
@CommandLine.ParentCommand
private MATSimApplication app;
diff --git a/contribs/application/src/main/java/org/matsim/application/commands/ShowGUI.java b/contribs/application/src/main/java/org/matsim/application/ShowGUI.java
similarity index 51%
rename from contribs/application/src/main/java/org/matsim/application/commands/ShowGUI.java
rename to contribs/application/src/main/java/org/matsim/application/ShowGUI.java
index 443f6a5cccb..6400262eb95 100644
--- a/contribs/application/src/main/java/org/matsim/application/commands/ShowGUI.java
+++ b/contribs/application/src/main/java/org/matsim/application/ShowGUI.java
@@ -1,14 +1,14 @@
-package org.matsim.application.commands;
+package org.matsim.application;
-import org.matsim.application.MATSimApplication;
import org.matsim.run.gui.Gui;
import picocli.CommandLine;
+import java.io.File;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
@CommandLine.Command(name = "gui", description = "Run the scenario through the MATSim GUI")
-public class ShowGUI implements Callable {
+class ShowGUI implements Callable {
@CommandLine.ParentCommand
private MATSimApplication parent;
@@ -26,10 +26,27 @@ public Integer call() throws Exception {
name = name.substring(MATSimApplication.COLOR.length(), name.length() - 4);
}
- Future f = Gui.show(name, parent.getClass());
+ File configFile = null;
+
+ // Try to load default config file
+ if (parent.getDefaultScenario() != null && new File(parent.getDefaultScenario()).exists())
+ configFile = new File(parent.getDefaultScenario());
+
+ // override the default if present
+ if (parent.getConfigPath() != null && parent.getConfigPath().exists())
+ configFile = parent.getConfigPath();
+
+ Future f = Gui.show(name, parent.getClass(), configFile);
Gui gui = f.get();
+ // Set the current working directory to be used in the gui, when run from the command line
+ // If the gui is run from desktop, the working directory is not overwritten
+
+ // Assumption is that starting something from command line, the user expects that the working directory remains the same
+ if (!System.getProperty("MATSIM_GUI_DESKTOP", "false").equals("true"))
+ gui.setWorkingDirectory(new File(""));
+
while (gui.isShowing())
Thread.sleep(250);
diff --git a/contribs/application/src/main/java/org/matsim/application/analysis/LogFileAnalysis.java b/contribs/application/src/main/java/org/matsim/application/analysis/LogFileAnalysis.java
index 36345aa2a79..5000c232482 100644
--- a/contribs/application/src/main/java/org/matsim/application/analysis/LogFileAnalysis.java
+++ b/contribs/application/src/main/java/org/matsim/application/analysis/LogFileAnalysis.java
@@ -171,7 +171,6 @@ private void renderWarnings(BufferedWriter writer, Set warnings) throws
} else {
Map> grouped = warnings.stream().collect(Collectors.groupingBy(w -> w.module, Collectors.toList()));
- writer.write(String.format("Warnings found in %d module%s ❌
\n\n", grouped.size(), grouped.size() > 1 ? "s" : ""));
for (Map.Entry> e : grouped.entrySet()) {
@@ -188,9 +187,7 @@ private void renderWarnings(BufferedWriter writer, Set warnings) throws
writer.write("""