Skip to content

Commit

Permalink
Fix usage of deprecated methods and classes (#206)
Browse files Browse the repository at this point in the history
* Use VehicleUtils for accessTime, egressTime, doorOperationMode
* Add missing Deprecated annotation
* Remove unused network argument from RouteUtils.createNetworkRoute(..)
* Replace deprecated ShapeFileWriter with GeoFileWriter
  • Loading branch information
marecabo authored Apr 23, 2024
1 parent 21c8b79 commit 7c2bd89
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 18 deletions.
7 changes: 4 additions & 3 deletions src/main/java/org/matsim/pt2matsim/hafas/HafasConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.matsim.pt2matsim.tools.debug.ScheduleCleaner;
import org.matsim.vehicles.VehicleCapacity;
import org.matsim.vehicles.VehicleType;
import org.matsim.vehicles.VehicleUtils;
import org.matsim.vehicles.Vehicles;
import org.matsim.vehicles.VehiclesFactory;

Expand Down Expand Up @@ -182,9 +183,9 @@ private static void createTransitRoutesFromFPLAN(List<FPLANRoute> routes, Transi
// using default values for vehicle type
vehicleType.setLength(defaultVehicleType.length);
vehicleType.setWidth(defaultVehicleType.width);
vehicleType.setAccessTime(defaultVehicleType.accessTime);
vehicleType.setEgressTime(defaultVehicleType.egressTime);
vehicleType.setDoorOperationMode(defaultVehicleType.doorOperation);
VehicleUtils.setAccessTime(vehicleType, defaultVehicleType.accessTime);
VehicleUtils.setEgressTime(vehicleType, defaultVehicleType.egressTime);
VehicleUtils.setDoorOperationMode(vehicleType, defaultVehicleType.doorOperation);
vehicleType.setPcuEquivalents(defaultVehicleType.pcuEquivalents);

VehicleCapacity vehicleCapacity = vehicleType.getCapacity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ protected TransitRoute createTransitRoute(Osm.Relation relation) {
}
}

NetworkRoute networkRoute = (linkSequenceForward.size() == 0 ? null : RouteUtils.createNetworkRoute(linkSequenceForward, null));
NetworkRoute networkRoute = (linkSequenceForward.size() == 0 ? null : RouteUtils.createNetworkRoute(linkSequenceForward));

if(stopSequenceForward.size() == 0) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import org.matsim.api.core.v01.network.Node;
import org.matsim.core.utils.collections.CollectionUtils;
import org.matsim.core.utils.geometry.geotools.MGC;
import org.matsim.core.utils.gis.GeoFileWriter;
import org.matsim.core.utils.gis.PointFeatureFactory;
import org.matsim.core.utils.gis.PolylineFeatureFactory;
import org.matsim.core.utils.gis.ShapeFileWriter;
import org.matsim.pt2matsim.tools.NetworkTools;
import org.opengis.feature.simple.SimpleFeature;

Expand Down Expand Up @@ -94,7 +94,7 @@ public void convertNodes(String nodesOutputFile) {
nodeFeatures.add(f);
}

ShapeFileWriter.writeGeometries(nodeFeatures, nodesOutputFile);
GeoFileWriter.writeGeometries(nodeFeatures, nodesOutputFile);
}

public void convertLinks(String linksOutputFile) {
Expand Down Expand Up @@ -125,7 +125,7 @@ public void convertLinks(String linksOutputFile) {
linkFeatures.add(f);
}

ShapeFileWriter.writeGeometries(linkFeatures, linksOutputFile);
GeoFileWriter.writeGeometries(linkFeatures, linksOutputFile);
}

private Coordinate[] getCoordinates(Link link) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
import org.matsim.core.utils.collections.CollectionUtils;
import org.matsim.core.utils.collections.MapUtils;
import org.matsim.core.utils.geometry.geotools.MGC;
import org.matsim.core.utils.gis.GeoFileWriter;
import org.matsim.core.utils.gis.PointFeatureFactory;
import org.matsim.core.utils.gis.PolylineFeatureFactory;
import org.matsim.core.utils.gis.ShapeFileWriter;
import org.matsim.pt.transitSchedule.api.*;
import org.matsim.pt2matsim.tools.NetworkTools;
import org.matsim.pt2matsim.tools.ScheduleTools;
Expand Down Expand Up @@ -144,7 +144,7 @@ public void stopRefLinks2Polylines(String outputFile) {
}
}

ShapeFileWriter.writeGeometries(lineFeatures, outputFile);
GeoFileWriter.writeGeometries(lineFeatures, outputFile);
}


Expand Down Expand Up @@ -181,7 +181,7 @@ public void stopFacilities2Points(String pointOutputFile) {
pointFeatures.add(pf);
}

ShapeFileWriter.writeGeometries(pointFeatures, pointOutputFile);
GeoFileWriter.writeGeometries(pointFeatures, pointOutputFile);
}

/**
Expand Down Expand Up @@ -229,7 +229,7 @@ public void routes2Polylines(String outputFile, boolean useNetworkLinks) {
}
}

ShapeFileWriter.writeGeometries(features, outputFile);
GeoFileWriter.writeGeometries(features, outputFile);
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/matsim/pt2matsim/tools/CoordTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ public static Map<TransitStopFacility, Boolean> getStopsInAreaBool(TransitSchedu
*
* @deprecated not used anywhere
*/
@Deprecated
public static int getBorderCrossType(Coord SWcut, Coord NEcut, Coord fromCoord, Coord toCoord) {
int fromSector = getAreaOfInterestSector(SWcut, NEcut, fromCoord);
int toSector = getAreaOfInterestSector(SWcut, NEcut, toCoord);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/matsim/pt2matsim/tools/ScheduleTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ public static VehicleType createDefaultVehicleType(String id, String defaultVehi
VehicleType vehicleType = vf.createVehicleType(vTypeId);
vehicleType.setLength(defaultValues.length);
vehicleType.setWidth(defaultValues.width);
vehicleType.setAccessTime(defaultValues.accessTime);
vehicleType.setEgressTime(defaultValues.egressTime);
vehicleType.setDoorOperationMode(defaultValues.doorOperation);
VehicleUtils.setAccessTime(vehicleType, defaultValues.accessTime);
VehicleUtils.setEgressTime(vehicleType, defaultValues.egressTime);
VehicleUtils.setDoorOperationMode(vehicleType, defaultValues.doorOperation);
vehicleType.setPcuEquivalents(defaultValues.pcuEquivalents);
vehicleType.setNetworkMode(defaultValues.transportMode.name);

Expand Down Expand Up @@ -317,7 +317,7 @@ public static void routeSchedule(TransitSchedule schedule, Network network, Sche

// add link sequence to schedule
if(linkIdSequence != null) {
transitRoute.setRoute(RouteUtils.createNetworkRoute(linkIdSequence, network));
transitRoute.setRoute(RouteUtils.createNetworkRoute(linkIdSequence));
}
} else {
log.warn("Route " + transitRoute.getId() + " on line " + transitLine.getId() + " has no stop sequence");
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/matsim/pt2matsim/tools/ShapeTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
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.GeoFileWriter;
import org.matsim.core.utils.gis.PolylineFeatureFactory;
import org.matsim.core.utils.gis.ShapeFileWriter;
import org.matsim.pt2matsim.gtfs.GtfsFeed;
import org.matsim.pt2matsim.gtfs.GtfsFeedImpl;
import org.matsim.pt2matsim.gtfs.lib.GtfsDefinitions;
Expand Down Expand Up @@ -228,7 +228,7 @@ public static void writeGtfsTripsToFile(GtfsFeed gtfsFeed, Set<String> serviceId
}
}
}
ShapeFileWriter.writeGeometries(features, outFile);
GeoFileWriter.writeGeometries(features, outFile);
}

/**
Expand Down Expand Up @@ -257,7 +257,7 @@ public static void writeESRIShapeFile(Collection<? extends RouteShape> shapes, S
features.add(f);
}
}
ShapeFileWriter.writeGeometries(features, filename);
GeoFileWriter.writeGeometries(features, filename);

}

Expand Down

0 comments on commit 7c2bd89

Please sign in to comment.