本文整理汇总了Java中org.geotools.referencing.GeodeticCalculator.setStartingPosition方法的典型用法代码示例。如果您正苦于以下问题:Java GeodeticCalculator.setStartingPosition方法的具体用法?Java GeodeticCalculator.setStartingPosition怎么用?Java GeodeticCalculator.setStartingPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.referencing.GeodeticCalculator
的用法示例。
在下文中一共展示了GeodeticCalculator.setStartingPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: distanceInCrs
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
private double distanceInCrs(double inMeters,
double[] refXY,
CoordinateReferenceSystem crs) throws TransformException {
double dist = 0;
// calculate the distance in meters of 0.01 * refY in the ref CRS
double[] sp = {refXY[0], refXY[1]};
double[] dp = {refXY[0], refXY[1] * 1.01};
GeodeticCalculator gc = new GeodeticCalculator(crs);
gc.setStartingPosition(new DirectPosition2D(crs, sp[0], sp[1]));
gc.setDestinationPosition(new DirectPosition2D(crs, dp[0], dp[1]));
double refY01InMeters = gc.getOrthodromicDistance();
// now, calculate the CRS distance as a proportional of 0.01 * refY
dist = inMeters * (refXY[1] * 0.01) / refY01InMeters;
return dist;
}
示例2: getUnitLength
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
private double getUnitLength(String mapCrsKey, Bbox mapBounds) throws LayerException {
try {
if (null == mapBounds) {
throw new LayerException(ExceptionCode.MAP_MAX_EXTENT_MISSING);
}
Crs crs = geoService.getCrs2(mapCrsKey);
GeodeticCalculator calculator = new GeodeticCalculator(crs);
Coordinate center = new Coordinate(0.5 * (mapBounds.getX() + mapBounds.getMaxX()),
0.5 * (mapBounds.getY() + mapBounds.getMaxY()));
calculator.setStartingPosition(new DirectPosition2D(crs, center.getX(), center.getY()));
calculator.setDestinationPosition(new DirectPosition2D(crs, center.getX() + 1, center.getY()));
return calculator.getOrthodromicDistance();
} catch (TransformException e) {
throw new LayerException(e, ExceptionCode.TRANSFORMER_CREATE_LAYER_TO_MAP_FAILED);
}
}