This commit is contained in:
2025-07-01 23:47:09 +03:00
commit 54084a0bc3
10 changed files with 125 additions and 0 deletions

29
.gitignore vendored Normal file
View File

@ -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

8
.idea/.gitignore generated vendored Normal file
View File

@ -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

6
.idea/misc.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/ThoriumBusParser.iml" filepath="$PROJECT_DIR$/ThoriumBusParser.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# ThoriumBusParser
A simple Java application to parse public transport data sources

11
ThoriumBusParser.iml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

25
src/DownloadPage.java Normal file
View File

@ -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();
}
}

7
src/Main.java Normal file
View File

@ -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")));
}
}

23
src/ParseGpsFile.java Normal file
View File

@ -0,0 +1,23 @@
import java.util.HashMap;
import java.util.Map;
public class ParseGpsFile {
public static Map<String, Double> ParseTLT(String GpsFileDataInput) {
String[] GpsFileDataCS = GpsFileDataInput.split(",");
Map<String, Double> 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;
}
}