From 54084a0bc3dd7dbb7bd62340e627570d799e0aa5 Mon Sep 17 00:00:00 2001 From: eetnaviation Date: Tue, 1 Jul 2025 23:47:09 +0300 Subject: [PATCH] init --- .gitignore | 29 +++++++++++++++++++++++++++++ .idea/.gitignore | 8 ++++++++ .idea/misc.xml | 6 ++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ README.md | 2 ++ ThoriumBusParser.iml | 11 +++++++++++ src/DownloadPage.java | 25 +++++++++++++++++++++++++ src/Main.java | 7 +++++++ src/ParseGpsFile.java | 23 +++++++++++++++++++++++ 10 files changed, 125 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 README.md create mode 100644 ThoriumBusParser.iml create mode 100644 src/DownloadPage.java create mode 100644 src/Main.java create mode 100644 src/ParseGpsFile.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f68d109 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..6f29fee --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..8560875 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..302699c --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# ThoriumBusParser +A simple Java application to parse public transport data sources \ No newline at end of file diff --git a/ThoriumBusParser.iml b/ThoriumBusParser.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/ThoriumBusParser.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/DownloadPage.java b/src/DownloadPage.java new file mode 100644 index 0000000..0e1c055 --- /dev/null +++ b/src/DownloadPage.java @@ -0,0 +1,25 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; + +public class DownloadPage { + + public static String main(String inputUrl) throws IOException { + StringBuilder pageData = new StringBuilder(); + URL url = new URL(inputUrl); + URLConnection con = url.openConnection(); + + try (InputStream is = con.getInputStream(); + BufferedReader br = new BufferedReader(new InputStreamReader(is))) { + String line; + while ((line = br.readLine()) != null) { + pageData.append(line).append("\n"); + } + } + + return pageData.toString(); + } +} \ No newline at end of file diff --git a/src/Main.java b/src/Main.java new file mode 100644 index 0000000..b1afbae --- /dev/null +++ b/src/Main.java @@ -0,0 +1,7 @@ +import java.io.IOException; + +public class Main { + public static void main(String[] args) throws IOException { + System.out.println(ParseGpsFile.ParseTLT(DownloadPage.main("https://transport.tallinn.ee/gps.txt"))); + } +} \ No newline at end of file diff --git a/src/ParseGpsFile.java b/src/ParseGpsFile.java new file mode 100644 index 0000000..7c23083 --- /dev/null +++ b/src/ParseGpsFile.java @@ -0,0 +1,23 @@ +import java.util.HashMap; +import java.util.Map; + +public class ParseGpsFile { + + public static Map ParseTLT(String GpsFileDataInput) { + String[] GpsFileDataCS = GpsFileDataInput.split(","); + + Map dataMap = new HashMap<>(); + dataMap.put("VehicleType", Double.parseDouble(GpsFileDataCS[0])); + dataMap.put("VehicleLine", Double.parseDouble(GpsFileDataCS[1])); + dataMap.put("VehicleLongitude", Double.parseDouble(GpsFileDataCS[2])); + dataMap.put("VehicleLatitude", Double.parseDouble(GpsFileDataCS[3])); + dataMap.put("EmptyVal1", Double.parseDouble(GpsFileDataCS[4])); + dataMap.put("VehicleHeading", Double.parseDouble(GpsFileDataCS[5])); + dataMap.put("VehicleTAK", Double.parseDouble(GpsFileDataCS[6])); + dataMap.put("IsVehicleLowGroundVehicle", Double.parseDouble(GpsFileDataCS[7])); + dataMap.put("EmptyVal2", Double.parseDouble(GpsFileDataCS[8])); + dataMap.put("VehicleDestination", Double.parseDouble(GpsFileDataCS[9])); + + return dataMap; + } +} \ No newline at end of file