Skip to content

Commit

Permalink
skyalps-gtfs: fix shapes related issues #37
Browse files Browse the repository at this point in the history
  • Loading branch information
clezag committed Sep 17, 2024
1 parent 3681853 commit 22c4c5a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public void calculateGtfs() throws Exception {
GTFSWriter.writeRoutes(gtfsRoutes);
GTFSWriter.writeTrips(gtfsTrips);
GTFSWriter.writeFeedInfo(gtfsFeedInfos);
GTFSWriter.writeShape(gtfsShapes);
GTFSWriter.writeShapes(gtfsShapes);

uploadToS3();
}
Expand All @@ -196,7 +196,7 @@ private static double haversineDist(double lat1, double lon1, double lat2, doubl
Math.sin(lat1 * (Math.PI/180)) * Math.sin(lat2 * (Math.PI/180)) +
Math.cos(lat1 * (Math.PI/180)) * Math.cos(lat2 * (Math.PI/180)) * Math.cos(theta * (Math.PI/180))
);
return distance * 1.609344;
return distance * 1609.344;
}

private void uploadToS3() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ public static void writeFeedInfo(List<FeedInfoValue> feedInfos) throws Exception
writeCsv("feed_info.txt", csv);
}

public static void writeShape(List<ShapeValue> shapes) throws Exception {
public static void writeShapes(List<ShapeValue> shapes) throws Exception {
var csv = newCsv();
addRow(csv, " shape_id", "shape_pt_lat", "shape_pt_lon", "shape_pt_sequence", "shape_dist_traveled");
addRow(csv, "shape_id", "shape_pt_lat", "shape_pt_lon", "shape_pt_sequence", "shape_dist_traveled");

shapes.stream()
// shapes unique per ID/sequence
Expand All @@ -195,6 +195,6 @@ public static void writeShape(List<ShapeValue> shapes) throws Exception {
String.valueOf(shape.shape_pt_sequence()),
shape.shape_dist_traveled()));

writeCsv("shape.txt", csv);
writeCsv("shapes.txt", csv);
}
}

0 comments on commit 22c4c5a

Please sign in to comment.