Skip to content

Commit

Permalink
Support saving of heading to session file
Browse files Browse the repository at this point in the history
  • Loading branch information
michal-josef-spacek committed Jul 6, 2021
1 parent babf56e commit 90b0904
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
13 changes: 10 additions & 3 deletions src/main/java/cuploader/ImmutableCoordinate.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,29 @@
public class ImmutableCoordinate {
private final double latitude;
private final double longitude;
private final String heading;

public ImmutableCoordinate(double latitude, double longitude) {
public ImmutableCoordinate(double latitude, double longitude, String heading) {
this.latitude = latitude;
this.longitude = longitude;
this.heading = heading;
}

public ImmutableCoordinate(String latitude, String longitude) {
public ImmutableCoordinate(String latitude, String longitude, String heading) {
this.latitude = Double.parseDouble(latitude.replace(",", "."));
this.longitude = Double.parseDouble(longitude.replace(",", "."));
this.heading = heading;
}

public double getLat() {
return latitude;
}

public double getLon() {
return longitude;
}

public String getHeading() {
return heading;
}
}
6 changes: 5 additions & 1 deletion src/main/java/cuploader/PFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ public final class PFile extends javax.swing.JPanel implements KeyListener {
public SessionFile returnData() {
ImmutableCoordinate coorToExport = null;
if (coor != null) {
coorToExport = new ImmutableCoordinate(coor.getLatDouble(), coor.getLonDouble());
coorToExport = new ImmutableCoordinate(
coor.getLatDouble(),
coor.getLonDouble(),
coor.getHeading()
);
}
SessionFile sessionFile = new SessionFile(
tDate.getText(), // date
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/cuploader/frames/FCoord.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private ImmutableCoordinate getMapPosition() {
GeoPosition centerPosition = mapViewer.getCenterPosition();
double latitude = centerPosition.getLatitude();
double longitude = centerPosition.getLongitude();
return new ImmutableCoordinate(latitude, longitude);
return new ImmutableCoordinate(latitude, longitude, "");
}

private Point getPoint(ImmutableCoordinate coordinate) {
Expand All @@ -77,7 +77,7 @@ private Point getPoint(ImmutableCoordinate coordinate) {

private ImmutableCoordinate getMapPosition(Point point) {
GeoPosition position = mapViewer.convertPointToGeoPosition(point);
return new ImmutableCoordinate(position.getLatitude(), position.getLongitude());
return new ImmutableCoordinate(position.getLatitude(), position.getLongitude(), "");
}

private void setMapPosition(ImmutableCoordinate coor, int coorZoom) {
Expand Down Expand Up @@ -155,7 +155,7 @@ public FCoord(int number, boolean multiEdit) {
Coord fileCoord = Data.getFiles().get(number).coor;

if(!multiEdit && fileCoord != null) {
setMapPosition(new ImmutableCoordinate(fileCoord.getLat(), fileCoord.getLon()), 2);
setMapPosition(new ImmutableCoordinate(fileCoord.getLat(), fileCoord.getLon(), ""), 2);
DecimalFormat df = new DecimalFormat("#.######", DecimalFormatSymbols.getInstance(Locale.US));
GeoPosition coordinate = mapViewer.getCenterPosition();
tCoor.setText(df.format(coordinate.getLatitude()) + ";" + df.format(coordinate.getLongitude()));
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/cuploader/frames/FFileLoading.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ public void run() {
Coord coord = null;
if (coordinate != null) {
coord = new Coord(coordinate.getLat(), coordinate.getLon());
if (!coordinate.getHeading().isEmpty()) {
coord.setHeading(coordinate.getHeading());
}
}
f = new PFile(file, Data.getFiles().size(), false, false,
sessionFile.getName(),
Expand Down

0 comments on commit 90b0904

Please sign in to comment.