sooren_66
یک شنبه 23 آبان 1395, 20:23 عصر
سلام دوستان کسی میتونه بگه این کد دقیقا" چه کاری رو انجام میده؟
public static synchronized double distance(Coordinate c1, Coordinate c2, double[] returnVals) {
// TODO check this now, might be different way of getting distance in new Simphony
GeodeticCalculator calculator = new GeodeticCalculator(ContextManager.roadProjection.g etCRS());
calculator.setStartingGeographicPoint(c1.x, c1.y);
calculator.setDestinationGeographicPoint(c2.x, c2.y);
double distance = calculator.getOrthodromicDistance();
if (returnVals != null && returnVals.length == 2) {
returnVals[0] = distance;
double angle = Math.toRadians(calculator.getAzimuth()); // Angle in range -PI to PI
// Need to transform azimuth (in range -180 -> 180 and where 0 points north)
// to standard mathematical (range 0 -> 360 and 90 points north)
if (angle > 0 && angle < 0.5 * Math.PI) { // NE Quadrant
angle = 0.5 * Math.PI - angle;
} else if (angle >= 0.5 * Math.PI) { // SE Quadrant
angle = (-angle) + 2.5 * Math.PI;
} else if (angle < 0 && angle > -0.5 * Math.PI) { // NW Quadrant
angle = (-1 * angle) + 0.5 * Math.PI;
} else { // SW Quadrant
angle = -angle + 0.5 * Math.PI;
}
returnVals[1] = angle;
}
return distance;
}
public static synchronized double distance(Coordinate c1, Coordinate c2, double[] returnVals) {
// TODO check this now, might be different way of getting distance in new Simphony
GeodeticCalculator calculator = new GeodeticCalculator(ContextManager.roadProjection.g etCRS());
calculator.setStartingGeographicPoint(c1.x, c1.y);
calculator.setDestinationGeographicPoint(c2.x, c2.y);
double distance = calculator.getOrthodromicDistance();
if (returnVals != null && returnVals.length == 2) {
returnVals[0] = distance;
double angle = Math.toRadians(calculator.getAzimuth()); // Angle in range -PI to PI
// Need to transform azimuth (in range -180 -> 180 and where 0 points north)
// to standard mathematical (range 0 -> 360 and 90 points north)
if (angle > 0 && angle < 0.5 * Math.PI) { // NE Quadrant
angle = 0.5 * Math.PI - angle;
} else if (angle >= 0.5 * Math.PI) { // SE Quadrant
angle = (-angle) + 2.5 * Math.PI;
} else if (angle < 0 && angle > -0.5 * Math.PI) { // NW Quadrant
angle = (-1 * angle) + 0.5 * Math.PI;
} else { // SW Quadrant
angle = -angle + 0.5 * Math.PI;
}
returnVals[1] = angle;
}
return distance;
}