From 22c4c5a3523ded85187918f76d33ef22a23f142b Mon Sep 17 00:00:00 2001 From: Clemens Zagler Date: Tue, 17 Sep 2024 14:12:40 +0200 Subject: [PATCH] skyalps-gtfs: fix shapes related issues #37 --- .../src/main/java/com/opendatahub/JobScheduler.java | 4 ++-- .../src/main/java/com/opendatahub/file/GTFSWriter.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/flighdata-skyalps-gtfs/src/main/java/com/opendatahub/JobScheduler.java b/flighdata-skyalps-gtfs/src/main/java/com/opendatahub/JobScheduler.java index 1b05b3b..5ec635b 100644 --- a/flighdata-skyalps-gtfs/src/main/java/com/opendatahub/JobScheduler.java +++ b/flighdata-skyalps-gtfs/src/main/java/com/opendatahub/JobScheduler.java @@ -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(); } @@ -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 { diff --git a/flighdata-skyalps-gtfs/src/main/java/com/opendatahub/file/GTFSWriter.java b/flighdata-skyalps-gtfs/src/main/java/com/opendatahub/file/GTFSWriter.java index 115aef5..bf14aa2 100644 --- a/flighdata-skyalps-gtfs/src/main/java/com/opendatahub/file/GTFSWriter.java +++ b/flighdata-skyalps-gtfs/src/main/java/com/opendatahub/file/GTFSWriter.java @@ -174,9 +174,9 @@ public static void writeFeedInfo(List feedInfos) throws Exception writeCsv("feed_info.txt", csv); } - public static void writeShape(List shapes) throws Exception { + public static void writeShapes(List 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 @@ -195,6 +195,6 @@ public static void writeShape(List shapes) throws Exception { String.valueOf(shape.shape_pt_sequence()), shape.shape_dist_traveled())); - writeCsv("shape.txt", csv); + writeCsv("shapes.txt", csv); } }