本文整理汇总了Java中org.gavaghan.geodesy.Ellipsoid类的典型用法代码示例。如果您正苦于以下问题:Java Ellipsoid类的具体用法?Java Ellipsoid怎么用?Java Ellipsoid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Ellipsoid类属于org.gavaghan.geodesy包,在下文中一共展示了Ellipsoid类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateTrackDistances
import org.gavaghan.geodesy.Ellipsoid; //导入依赖的package包/类
/**
* updates the distance information in the trackpoints of the track object.
*
* @param track
* Track object to update
* @throws java.lang.NullPointerException
* if track is empty
*/
public static void updateTrackDistances(Track track) {
Optional.ofNullable(Objects.requireNonNull(track).getTrackPoints()).ifPresent(trackPoints -> {
GeodeticCalculator geoCalc = new GeodeticCalculator();
Double distance = 0.0;
GlobalCoordinates lastCoordinate = null;
for (TrackPoint trackPoint : trackPoints) {
trackPoint.setDistance(distance);
GlobalCoordinates thisCoordinate =
new GlobalCoordinates(trackPoint.getLatitude(), trackPoint.getLongitude());
if (null != lastCoordinate) {
distance += geoCalc.calculateGeodeticCurve(Ellipsoid.WGS84, lastCoordinate, thisCoordinate)
.getEllipsoidalDistance();
}
lastCoordinate = thisCoordinate;
}
});
}
示例2: getDistance
import org.gavaghan.geodesy.Ellipsoid; //导入依赖的package包/类
/**
* Returns the geodetic distance of two Coordinates in kilometers.
*
* @param lat1
* @param lng1
* @param lat2
* @param lng2
* @return distance in km
*/
private double getDistance(double lat1, double lng1, double lat2, double lng2) {
// set position 1
GlobalPosition position1 = new GlobalPosition(lat1, lng1, 0.0);
// set position 2
GlobalPosition position2 = new GlobalPosition(lat2, lng2, 0.0);
// calculate the geodetic measurement
GeodeticMeasurement geoMeasurement = geoCalc
.calculateGeodeticMeasurement(Ellipsoid.WGS84, position1,
position2);
double p2pKilometers = geoMeasurement.getPointToPointDistance() / 1000.0;
return p2pKilometers;
}