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

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;
}
}