require location param when initialising a sentence

pull/8/head
Medad Rufus Newman 2022-05-09 21:27:52 +01:00
rodzic daaecf30b5
commit b2f118fec6
2 zmienionych plików z 7 dodań i 3 usunięć

Wyświetl plik

@ -86,7 +86,8 @@ public final class PayloadDecoder {
double longitude = sodaq.getLongitude();
double altitude = sodaq.getAltitude();
Instant instant = Instant.ofEpochSecond(sodaq.getTimeStamp());
Sentence sentence = new Sentence(callSign, counter, instant);
Location location = new Location(latitude, longitude, altitude);
Sentence sentence = new Sentence(callSign, counter, instant, location);
sentence.addField("lat", String.format(Locale.ROOT, "%.6f", latitude));
sentence.addField("lon", String.format(Locale.ROOT, "%.6f", longitude));
sentence.addField("alt", String.format(Locale.ROOT, "%.1f", altitude));
@ -116,7 +117,8 @@ public final class PayloadDecoder {
double latitude = parseDouble(fields.get("lat"));
double longitude = parseDouble(fields.get("lon"));
double altitude = parseDouble(fields.get("gpsalt"));
Sentence sentence = new Sentence(callSign, counter, time);
Location location = new Location(latitude, longitude, altitude);
Sentence sentence = new Sentence(callSign, counter, time, location);
sentence.addField("lat", String.format(Locale.ROOT, "%.6f", latitude));
sentence.addField("lon", String.format(Locale.ROOT, "%.6f", longitude));
sentence.addField("alt", String.format(Locale.ROOT, "%.1f", altitude));

Wyświetl plik

@ -23,6 +23,7 @@ public final class Sentence {
private final String callSign;
private final int id;
private final Instant time;
private final Location location;
private final CrcCcitt16 crc16 = new CrcCcitt16();
@ -38,10 +39,11 @@ public final class Sentence {
* @param id message sequence number
* @param time the creation time
*/
public Sentence(String callSign, int id, Instant time) {
public Sentence(String callSign, int id, Instant time, Location location ) {
this.callSign = callSign;
this.id = id;
this.time = Instant.from(time);
this.location = location;
}
/**