Skip to content

Commit

Permalink
Merge branch 'master' into freespeed-model
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Mar 16, 2024
2 parents 086d3d4 + 9ddb2e3 commit ce5bf59
Show file tree
Hide file tree
Showing 333 changed files with 6,842 additions and 3,180 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-on-pr-merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/verify-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,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: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
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;

Expand Down Expand Up @@ -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<SimpleFeature> features = shapeFileReader.readFileAndInitialize(shapeFileName);

ActivityFacilities facilities = FacilitiesUtils.createActivityFacilities("DensitiyFacilities");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@
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.matsim.core.utils.gis.GeoFileWriter;
import org.opengis.feature.simple.SimpleFeature;

/**
* @author dziemke
*/
class VoronoiExample {

public static void main(String[] args) {
GeometryFactory geometryFactory = new GeometryFactory();

Collection<Coordinate> sites = new ArrayList<>();
sites.add(new Coordinate(70, 70));
sites.add(new Coordinate(50, 150));
Expand All @@ -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<Polygon> polygons = voronoiDiagramBuilder.getSubdivision().getVoronoiCellPolygons(geometryFactory);

BoundingBox boundingBox = BoundingBox.createBoundingBox(0, 0, 400, 200);
Polygon boundingPolygon = VoronoiGeometryUtils.createBoundingPolygon(boundingBox);
Collection<Geometry> cutGeometries = VoronoiGeometryUtils.cutPolygonsByBoundary(polygons, boundingPolygon);
Collection<SimpleFeature> features = VoronoiGeometryUtils.createFeaturesFromPolygons(cutGeometries);
ShapeFileWriter.writeGeometries(features, "/Users/dominik/voronoi_test.shp");
GeoFileWriter.writeGeometries(features, "/Users/dominik/voronoi_test.shp");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import org.matsim.core.utils.geometry.CoordinateTransformation;
import org.matsim.core.utils.geometry.geotools.MGC;
import org.matsim.core.utils.geometry.transformations.TransformationFactory;
import org.matsim.core.utils.gis.ShapeFileWriter;
import org.matsim.core.utils.gis.GeoFileWriter;
import org.matsim.facilities.ActivityFacility;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
Expand All @@ -74,7 +74,7 @@ public GeoserverUpdater (String crs, String name, Map<Id<ActivityFacility>, Geom
this.pushing2Geoserver = pushing2Geoserver;
this.createQGisOutput = createQGisOutput;
}

private Map<Tuple<ActivityFacility, Double>, Map<String,Double>> accessibilitiesMap = new HashMap<>() ;

@Override
Expand All @@ -95,16 +95,16 @@ public void finish() {
SimpleFeatureTypeBuilder featureTypeBuilder = createFeatureTypeBuilder();
SimpleFeatureType featureType = featureTypeBuilder.buildFeatureType();
DefaultFeatureCollection featureCollection = createFeatureCollection(geometryFactory, featureType);

if (outputDirectory != null) {
File file = new File(outputDirectory);
file.mkdirs();
}

if (createQGisOutput) {
ShapeFileWriter.writeGeometries(featureCollection, outputDirectory + "/result.shp");
GeoFileWriter.writeGeometries(featureCollection, outputDirectory + "/result.shp");
}

if (pushing2Geoserver) {
updateOnGeoserver(featureType, featureCollection);
}
Expand All @@ -130,7 +130,7 @@ private DefaultFeatureCollection createFeatureCollection(GeometryFactory geometr
LOG.info("Start creating features from accessibility data.");
DefaultFeatureCollection featureCollection = new DefaultFeatureCollection("internal", featureType);
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType);

CoordinateTransformation transformation = TransformationFactory.getCoordinateTransformation(this.crs, TransformationFactory.WGS84);

for (Entry<Tuple<ActivityFacility, Double>, Map<String, Double>> entry : accessibilitiesMap.entrySet()) {
Expand All @@ -145,10 +145,10 @@ private DefaultFeatureCollection createFeatureCollection(GeometryFactory geometr
i++;
}
featureBuilder.add(geometryFactory.createPolygon(transformedCoordinates));

featureBuilder.add(Integer.parseInt(entry.getKey().getFirst().getId().toString()));
featureBuilder.add(entry.getKey().getSecond());

for (Modes4Accessibility modeEnum : Modes4Accessibility.values()) {
String mode = modeEnum.toString();
Double accessibility = entry.getValue().get(mode);
Expand Down Expand Up @@ -188,14 +188,14 @@ private void updateOnGeoserver(SimpleFeatureType featureType, DefaultFeatureColl
// There have been errors with the data store if the dependency "gt-jdbc-postgis", version 13.0 was missing!
DataStore dataStore = DataStoreFinder.getDataStore(params);
LOG.info("dataStore = " + dataStore);

// Remove schema in case it already exists
try {
dataStore.removeSchema(name);
} catch (IllegalArgumentException e) {
LOG.warn("Could not remove schema. Probably, it has not existed yet.");
}

dataStore.createSchema(featureType);
SimpleFeatureStore featureStore = (SimpleFeatureStore) dataStore.getFeatureSource(name);
featureStore.addFeatures(featureCollection);
Expand Down
Loading

0 comments on commit ce5bf59

Please sign in to comment.