本文整理汇总了Java中net.sf.geographiclib.Geodesic类的典型用法代码示例。如果您正苦于以下问题:Java Geodesic类的具体用法?Java Geodesic怎么用?Java Geodesic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Geodesic类属于net.sf.geographiclib包,在下文中一共展示了Geodesic类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: intercept
import net.sf.geographiclib.Geodesic; //导入依赖的package包/类
@Override
public double intercept(Point a, Point b, Point c) {
if (a.getX() == b.getX() && a.getY() == b.getY()) {
return 0;
}
Intercept inter = new Intercept(Geodesic.WGS84);
GeodesicData ci =
inter.intercept(a.getY(), a.getX(), b.getY(), b.getX(), c.getY(), c.getX());
GeodesicData ai = Geodesic.WGS84.Inverse(a.getY(), a.getX(), ci.lat2, ci.lon2);
GeodesicData ab = Geodesic.WGS84.Inverse(a.getY(), a.getX(), b.getY(), b.getX());
return (Math.abs(ai.azi1 - ab.azi1) < 1) ? ai.s12 / ab.s12 : (-1) * ai.s12 / ab.s12;
}
示例2: interpolate
import net.sf.geographiclib.Geodesic; //导入依赖的package包/类
@Override
public Point interpolate(Point a, Point b, double f) {
GeodesicData inv = Geodesic.WGS84.Inverse(a.getY(), a.getX(), b.getY(), b.getX());
GeodesicData pos = Geodesic.WGS84.Line(inv.lat1, inv.lon1, inv.azi1).Position(inv.s12 * f);
return new Point(pos.lon2, pos.lat2);
}
示例3: azimuth
import net.sf.geographiclib.Geodesic; //导入依赖的package包/类
@Override
public double azimuth(Point a, Point b, double f) {
double azi = 0;
if (f < 0 + 1E-10) {
azi = Geodesic.WGS84.Inverse(a.getY(), a.getX(), b.getY(), b.getX()).azi1;
} else if (f > 1 - 1E-10) {
azi = Geodesic.WGS84.Inverse(a.getY(), a.getX(), b.getY(), b.getX()).azi2;
} else {
Point c = interpolate(a, b, f);
azi = Geodesic.WGS84.Inverse(a.getY(), a.getX(), c.getY(), c.getX()).azi2;
}
return azi < 0 ? azi + 360 : azi;
}
示例4: envelope
import net.sf.geographiclib.Geodesic; //导入依赖的package包/类
@Override
public Envelope2D envelope(Point c, double radius) {
Envelope2D env = new Envelope2D();
double ymax = Geodesic.WGS84.Direct(c.getY(), c.getX(), 0, radius).lat2;
double ymin = Geodesic.WGS84.Direct(c.getY(), c.getX(), -180, radius).lat2;
double xmax = Geodesic.WGS84.Direct(c.getY(), c.getX(), 90, radius).lon2;
double xmin = Geodesic.WGS84.Direct(c.getY(), c.getX(), -90, radius).lon2;
env.setCoords(xmin, ymin, xmax, ymax);
return env;
}
示例5: intercept
import net.sf.geographiclib.Geodesic; //导入依赖的package包/类
/**
* Interception of a point <i>b</i> to a geodesic <i>a</i>.
* <p>
*
* @param lata1 latitude of point <i>1</i> of geodesic <i>a</i> (degrees).
* @param lona1 longitude of point <i>1</i> of geodesic <i>a</i> (degrees).
* @param lata2 latitude of point <i>2</i> of geodesic <i>a</i> (degrees).
* @param lona2 longitude of point <i>2</i> of geodesic <i>a</i> (degrees).
* @param latb1 latitude of point <i>b</i> (degrees).
* @param lonb1 longitude of point <i>b</i> (degrees).
* @return a {@link GeodesicData} object, defining a geodesic from point <i>b</i> to the
* intersection point, with the following fields: <i>lat1</i>, <i>lon1</i>, <i>azi1</i>,
* <i>lat2</i>, <i>lon2</i>, <i>azi2</i>, <i>s12</i>, <i>a12</i>.
* <p>
* <i>lat1</i> should be in the range [−90°, 90°]; <i>lon1</i> and
* <i>azi1</i> should be in the range [−540°, 540°). The values of
* <i>lon2</i> and <i>azi2</i> returned are in the range [−180°, 180°).
*/
public GeodesicData intercept(double lata1, double lona1, double lata2, double lona2,
double latb1, double lonb1) {
if (lata1 == lata2 && lona1 == lona2) {
return earth.Inverse(latb1, lonb1, lata1, lona1);
}
GeodesicData inv = Geodesic.WGS84.Inverse(lata1, lona1, lata2, lona2);
GeodesicData est =
Geodesic.WGS84.Line(inv.lat1, inv.lon1, inv.azi1).Position(inv.s12 * 0.5);
double latb2 = est.lat2, latb2_ = Double.NaN, lonb2_ = Double.NaN, lonb2 = est.lon2;
for (int i = 0; i < maxit; ++i) {
GnomonicData xa1 = gnom.Forward(latb2, lonb2, lata1, lona1);
GnomonicData xa2 = gnom.Forward(latb2, lonb2, lata2, lona2);
GnomonicData xb1 = gnom.Forward(latb2, lonb2, latb1, lonb1);
Vector va1 = new Vector(xa1.x, xa1.y, 1);
Vector va2 = new Vector(xa2.x, xa2.y, 1);
Vector la = va1.cross(va2);
Vector lb = new Vector(la.y, -(la.x), la.x * xb1.y - la.y * xb1.x);
Vector p0 = la.cross(lb);
p0 = p0.multiply(1d / p0.z);
latb2_ = latb2;
lonb2_ = lonb2;
GnomonicData rev = gnom.Reverse(latb2, lonb2, p0.x, p0.y);
latb2 = rev.lat;
lonb2 = rev.lon;
if (Math.abs(lonb2_ - lonb2) < eps && Math.abs(latb2_ - latb2) < eps) {
break;
}
}
return earth.Inverse(latb1, lonb1, latb2, lonb2);
}
示例6: ShapeAsPointsBuilder
import net.sf.geographiclib.Geodesic; //导入依赖的package包/类
public ShapeAsPointsBuilder() {
points = new LinkedList<>();
wgs84 = Geodesic.WGS84;
step = 1;
}
示例7: distance
import net.sf.geographiclib.Geodesic; //导入依赖的package包/类
@Override
public double distance(Point a, Point b) {
return Geodesic.WGS84.Inverse(a.getY(), a.getX(), b.getY(), b.getX()).s12;
}
示例8: azimuth
import net.sf.geographiclib.Geodesic; //导入依赖的package包/类
private static double azimuth(Point a, Point b, boolean left) {
GeodesicData geod = Geodesic.WGS84.Inverse(a.getY(), a.getX(), b.getY(), b.getX());
double azi = left ? geod.azi1 : geod.azi2;
return azi < 0 ? azi + 360 : azi;
}
示例9: evaluateSingleSet
import net.sf.geographiclib.Geodesic; //导入依赖的package包/类
/**
* Calculate the precition and median error on a collection of images
* @param resultFile : file of the results
* @param collection : collection of image IDs
* @param minRangeScale : minimum precision range
* @param maxRangeScale : minimum precision range
* @param oneLine : print results in one line
*/
private static void evaluateSingleSet(String resultFile, Set<String> collection,
int minRangeScale, int maxRangeScale, boolean oneLine){
// function that calculates the distance between two lat/lon points
Geodesic geo = new Geodesic(6378.1370D, 298.257223563);
// Initialize result containers
Map<Integer, Integer> estimationResultMap = initializeResultMap(minRangeScale, maxRangeScale);
List<Double> distances = new ArrayList<Double>();
// Estimated and total item counters
int estimations = 0;
// File reader
EasyBufferedReader reader = new EasyBufferedReader(resultFile);
String line;
while((line = reader.readLine()) != null){
if(collection == null || collection.contains(line.split("\t")[0])){
try{
// Pairs of lat/lon points
Double[] estimatedLocation =
{Double.parseDouble(line.split("\t")[4]),
Double.parseDouble(line.split("\t")[3])};
Double[] groundTruthLocation =
{Double.parseDouble(line.split("\t")[2]),
Double.parseDouble(line.split("\t")[1])};
// calculate distance
double distance = geo.Inverse(groundTruthLocation[0], groundTruthLocation[1],
estimatedLocation[0], estimatedLocation[1]).s12;
// store results
for(int i=minRangeScale;i<maxRangeScale;i++){
if(distance < Math.pow(10, i)){
estimationResultMap.put(i, estimationResultMap.get(i) + 1);
}
}
distances.add(distance);
estimations++;
}catch (ArrayIndexOutOfBoundsException e){ // line is not in the right format
System.out.println(e.getMessage());
}
}
}
reader.close();
DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(2);
// print results
if(oneLine){
logger.info("Items: " + estimations + "\[email protected]: " + df.format(
(float)estimationResultMap.get(0)/estimations*100) + "%\tm.error: " +
df.format(Utils.median(distances)) + "km");
}else{
logger.info("Total items: " + estimations);
printPrecisionResults(estimationResultMap, estimations, minRangeScale, maxRangeScale);
logger.info("Median Distance Error: " + df.format(Utils.median(distances)) + "km");
}
}
示例10: Intercept
import net.sf.geographiclib.Geodesic; //导入依赖的package包/类
/**
* Constructor for Intercept.
* <p>
*
* @param earth the {@link Geodesic} object to use for geodesic calculations. By default the
* WGS84 ellipsoid should be used.
*/
public Intercept(Geodesic earth) {
this.earth = earth;
this.gnom = new Gnomonic(this.earth);
}
示例11: Intersect
import net.sf.geographiclib.Geodesic; //导入依赖的package包/类
/**
* Constructor for Intersect.
* <p>
* @param earth
* the {@link Geodesic} object to use for geodesic calculations. By
* default the WGS84 ellipsoid should be used.
*/
public Intersect(Geodesic earth) {
this.earth = earth;
this.gnom = new Gnomonic(this.earth);
}