- Holds the start and end coordinate of a gate or marker, and has a method to calculate the middle point - Each leg will hold a start Marker and end Marker #story[20]main
parent
45fcd22cc5
commit
d1d46f2cf5
@ -0,0 +1,74 @@
|
|||||||
|
package seng302.Model;
|
||||||
|
|
||||||
|
import org.geotools.referencing.GeodeticCalculator;
|
||||||
|
import seng302.GPSCoordinate;
|
||||||
|
import sun.java2d.loops.GeneralRenderer;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by esa46 on 29/03/17.
|
||||||
|
*/
|
||||||
|
public class Marker {
|
||||||
|
|
||||||
|
private GPSCoordinate averageGPSCoordinate;
|
||||||
|
private GPSCoordinate mark1;
|
||||||
|
private GPSCoordinate mark2;
|
||||||
|
|
||||||
|
public Marker(GPSCoordinate mark1) {
|
||||||
|
|
||||||
|
this.mark1 = mark1;
|
||||||
|
this.mark2 = mark1;
|
||||||
|
this.averageGPSCoordinate = calculateAverage();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Marker(GPSCoordinate mark1, GPSCoordinate mark2) {
|
||||||
|
|
||||||
|
this.mark1 = mark1;
|
||||||
|
this.mark2 = mark2;
|
||||||
|
this.averageGPSCoordinate = calculateAverage();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public GPSCoordinate getAverageGPSCoordinate() {
|
||||||
|
return averageGPSCoordinate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAverageGPSCoordinate(GPSCoordinate averageGPSCoordinate) {
|
||||||
|
this.averageGPSCoordinate = averageGPSCoordinate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GPSCoordinate getMark1() {
|
||||||
|
return mark1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMark1(GPSCoordinate mark1) {
|
||||||
|
this.mark1 = mark1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GPSCoordinate getMark2() {
|
||||||
|
return mark2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMark2(GPSCoordinate mark2) {
|
||||||
|
this.mark2 = mark2;
|
||||||
|
}
|
||||||
|
|
||||||
|
private GPSCoordinate calculateAverage() {
|
||||||
|
|
||||||
|
GeodeticCalculator calc = new GeodeticCalculator();
|
||||||
|
calc.setStartingGeographicPoint(mark1.getLongitude(), mark1.getLatitude());
|
||||||
|
calc.setDestinationGeographicPoint(mark2.getLongitude(), mark2.getLatitude());
|
||||||
|
double azimuth = calc.getAzimuth();
|
||||||
|
double distance = calc.getOrthodromicDistance();
|
||||||
|
|
||||||
|
GeodeticCalculator middleCalc = new GeodeticCalculator();
|
||||||
|
middleCalc.setStartingGeographicPoint(mark1.getLongitude(), mark1.getLatitude());
|
||||||
|
middleCalc.setDirection(azimuth, distance / 2);
|
||||||
|
Point2D middlePoint = middleCalc.getDestinationGeographicPoint();
|
||||||
|
return new GPSCoordinate(middlePoint.getY(), middlePoint.getX());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in new issue