本文整理汇总了Java中org.geotools.referencing.GeodeticCalculator.setDestinationGeographicPoint方法的典型用法代码示例。如果您正苦于以下问题:Java GeodeticCalculator.setDestinationGeographicPoint方法的具体用法?Java GeodeticCalculator.setDestinationGeographicPoint怎么用?Java GeodeticCalculator.setDestinationGeographicPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.referencing.GeodeticCalculator
的用法示例。
在下文中一共展示了GeodeticCalculator.setDestinationGeographicPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDistance
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
/**
* Returns the distance between two coordinates given as longitude and
* latitude
*
* @param firstLongitude
* @param firstLatitude
* @param secondLongitude
* @param secondLatitude
* @return distance (round to long)
*/
public static Long getDistance(final Double firstLongitude, final Double firstLatitude, final Double secondLongitude, final Double secondLatitude) {
Double distance = 0.0;
final GeodeticCalculator cal = new GeodeticCalculator();
cal.setStartingGeographicPoint(firstLongitude, firstLatitude);
cal.setDestinationGeographicPoint(secondLongitude, secondLatitude);
distance = cal.getOrthodromicDistance();
final int totalmeters = distance.intValue();
final int km = totalmeters / 1000;
float remaining_cm = (float) (distance - totalmeters) * 10000;
remaining_cm = Math.round(remaining_cm);
// System.out.println("Distance = " + km + "km " + meters + "m " + cm +
// "cm");
return distance.longValue();
}
示例2: calcPixelSize
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
public void calcPixelSize()
{
double[] pixelsize = {0.0, 0.0};
// should be in the image reader class
// get pixel size
double[] latlonorigin = getGeoFromPixel(0, 0, "EPSG:4326");
double[] latlon = getGeoFromPixel(100, 0, "EPSG:4326");
// use the geodetic calculator class to calculate distances in meters
GeodeticCalculator gc = new GeodeticCalculator();
gc.setStartingGeographicPoint(latlonorigin[0], latlonorigin[1]);
gc.setDestinationGeographicPoint(latlon[0], latlon[1]);
pixelsize[0] = gc.getOrthodromicDistance() / 100;
latlon = getGeoFromPixel(0, 100, "EPSG:4326");
gc.setDestinationGeographicPoint(latlon[0], latlon[1]);
pixelsize[1] = gc.getOrthodromicDistance() / 100;
this.pixelSize=pixelsize;
}
示例3: getImageAzimuth
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
/**
*
*/
public double getImageAzimuth(){
double az = 0;
try{
//compute the azimuth considering the two left corners of the image
//azimuth angle in degrees between 0 and +180
double[] endingPoint = getGeoTransform().getGeoFromPixel(getWidth() / 2, 0);//, "EPSG:4326");
double[] startingPoint = getGeoTransform().getGeoFromPixel(getWidth() / 2, getHeight() - 1);//, "EPSG:4326");
GeodeticCalculator gc = new GeodeticCalculator();
gc.setStartingGeographicPoint(startingPoint[0], startingPoint[1]);
gc.setDestinationGeographicPoint(endingPoint[0], endingPoint[1]);
az = gc.getAzimuth();
}catch(GeoTransformException ge){
logger.warn(ge.getLocalizedMessage());
}
return az;
}
示例4: distance
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
public static Vector3D distance(GeoPoint p, GeoPoint q) {
GeodeticCalculator calc = new GeodeticCalculator();
calc.setStartingGeographicPoint(p.lon, p.lat);
calc.setDestinationGeographicPoint(q.lon, q.lat);
double dist = calc.getOrthodromicDistance();
double alpha = calc.getAzimuth(); // The azimuth, in decimal degrees
// from -180° to +180°.
Rotation r = new Rotation(RotationOrder.ZXZ, 0, 0,
-FastMath.toRadians(alpha));
Vector3D trip = r.applyTo(new Vector3D(0, 1, 0)).scalarMultiply(dist);
trip = new Vector3D(trip.getX(), trip.getY(), q.ele - p.ele);
// in meters
return trip;
}
示例5: calculateOrthometricLength
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
/**
* This method calculates the orthometric length in meters of a LineString
* given in SRID EPSG:4326. LineString must be in WGS84 (EPSG:4326). If no
* SRID defined or other SRID defined than EPSG:4326 the method will return
* 0. Furthermore 0 is returned, if the LineString is null.
*
* @param line
* @param calc
* @return
*/
public static double calculateOrthometricLength(LineString line) {
double distance = 0;
if (line != null) {
if (line.getSRID() == 4326) {
GeodeticCalculator calc = new GeodeticCalculator();
for (int i = 0; i < line.getCoordinates().length - 1; i++) {
Coordinate p1 = line.getCoordinates()[i];
Coordinate p2 = line.getCoordinates()[i + 1];
calc.setStartingGeographicPoint(p1.x, p2.y);
calc.setDestinationGeographicPoint(p2.x, p2.y);
distance += calc.getOrthodromicDistance();
}
}
}
return distance;
}
示例6: testWithGeotools
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
public void testWithGeotools() throws MatrixException {
Coordinate c1 = new Coordinate(11, 46, 0);
Coordinate c2 = new Coordinate(11.001, 46.001, 0);
GeodeticCalculator gc = new GeodeticCalculator(DefaultGeographicCRS.WGS84);
gc.setStartingGeographicPoint(c1.x, c1.y);
gc.setDestinationGeographicPoint(c2.x, c2.y);
double orthodromicDistance = gc.getOrthodromicDistance();
ENU enu = new ENU(c1);
Coordinate ce1 = enu.wgs84ToEnu(c1);
Coordinate ce2 = enu.wgs84ToEnu(c2);
double distance = ce1.distance(ce2);
assertTrue(isDeltaOk(orthodromicDistance, distance));
Coordinate c1Back = enu.enuToWgs84(ce1);
Coordinate c2Back = enu.enuToWgs84(ce2);
assertEquals(0, c1.distance(c1Back), 0.000001);
assertEquals(0, c2.distance(c2Back), 0.000001);
}
示例7: computeDistance
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
public static GeodeticCalculator computeDistance(GeoTransform gt,Point initPosition,Point endPosition,Point imagePosition) throws GeoTransformException {
double[] init = gt.getGeoFromPixel(initPosition.x, initPosition.y);
double[] end = null;
GeodeticCalculator gc = new GeodeticCalculator();
//Point2D initPoint = new Point2D.Double(init[1], init[0]);
gc.setStartingGeographicPoint(init[0], init[1]);
//Point2D endPoint = null;
if (endPosition != null) {
end = gt.getGeoFromPixel(endPosition.x, endPosition.y);
//endPoint = new Point2D.Double(end[1], end[0]);
gc.setDestinationGeographicPoint(end[0], end[1]);
} else {
end = gt.getGeoFromPixel(imagePosition.x, imagePosition.y);
//endPoint = new Point2D.Double(end[1], end[0]);
gc.setDestinationGeographicPoint(end[0], end[1]);
}
return gc;
}
示例8: getImageAzimuth
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
public double getImageAzimuth() throws GeoTransformException {
double az = 0;
//compute the azimuth considering the two left corners of the image
//azimuth angle in degrees between 0 and +180
double[] endingPoint = getGeoTransform().getGeoFromPixel(getWidth() / 2, 0);
double[] startingPoint = getGeoTransform().getGeoFromPixel(getWidth() / 2, getHeight() - 1);
GeodeticCalculator gc = new GeodeticCalculator();
gc.setStartingGeographicPoint(startingPoint[0], startingPoint[1]);
gc.setDestinationGeographicPoint(endingPoint[0], endingPoint[1]);
az = gc.getAzimuth();
return az;
}
示例9: getDistanceBetweenTwoPoints
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
/**
* Computes the distance between two points.
*
* @param from the origin point.
* @param to the end point.
* @return the orthodromic distance between the given points.
*/
public static double getDistanceBetweenTwoPoints( Point2D from, Point2D to)
{
GeodeticCalculator calc = new GeodeticCalculator();
calc.setStartingGeographicPoint( from );
calc.setDestinationGeographicPoint( to);
return calc.getOrthodromicDistance();
}
示例10: calcAirLineDistInMeters
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
@Override
public BigDecimal calcAirLineDistInMeters(GeoLocation a, GeoLocation b) {
GeodeticCalculator calculator = new GeodeticCalculator();
calculator.setStartingGeographicPoint(a.getLongitude().doubleValue(), a.getLatitude().doubleValue());
calculator.setDestinationGeographicPoint(b.getLongitude().doubleValue(), b.getLatitude().doubleValue());
return new BigDecimal(calculator.getOrthodromicDistance());
}
示例11: populateProfilesForSingleLog
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
/**
* Extracts profile information from logs.
*
* @param log the log to analyze.
* @param size the number of points in the log (as off: int size = log.points.size(); )
* @param xProfile the array of to put the progressive distance in.
* @param yProfile the array of to put the elevation in.
* @param xPlanim the array of to put the x coord in.
* @param yPlanim the array of to put the y coord in.
* @param timestampArray the array of to put the times in.
*/
public static void populateProfilesForSingleLog( GpsLog log, int size, double[] xProfile, double[] yProfile, double[] xPlanim,
double[] yPlanim, long[] timestampArray ) {
GeodeticCalculator gc = new GeodeticCalculator(DefaultGeographicCRS.WGS84);
double runningDistance = 0;
for( int i = 0; i < size - 1; i++ ) {
GpsPoint p1 = log.points.get(i);
GpsPoint p2 = log.points.get(i + 1);
double lon1 = p1.lon;
double lat1 = p1.lat;
double altim1 = p1.altim;
long utc1 = p1.utctime;
double lon2 = p2.lon;
double lat2 = p2.lat;
double altim2 = p2.altim;
long utc2 = p2.utctime;
gc.setStartingGeographicPoint(lon1, lat1);
gc.setDestinationGeographicPoint(lon2, lat2);
double distance = gc.getOrthodromicDistance();
runningDistance += distance;
if (i == 0) {
xProfile[i] = 0.0;
yProfile[i] = altim1;
xPlanim[i] = lon1;
yPlanim[i] = lat1;
timestampArray[i] = utc1;
}
xProfile[i + 1] = runningDistance;
yProfile[i + 1] = altim2;
xPlanim[i + 1] = lon2;
yPlanim[i + 1] = lat2;
timestampArray[i + 1] = utc2;
}
}
示例12: calculateOrthoDistance
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
private double calculateOrthoDistance(Geometry g1, Geometry g2) {
double distance = 0.0;
Point c1 = g1.getCentroid();
Point c2 = g2.getCentroid();
GeodeticCalculator calc = new GeodeticCalculator(DefaultGeographicCRS.WGS84);
calc.setStartingGeographicPoint(c1.getX(), c1.getY());
calc.setDestinationGeographicPoint(c2.getX(), c2.getY());
distance = calc.getOrthodromicDistance();
return distance;
}
示例13: main
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
/**
* take two pairs of lat/long and return bearing and distance.
*
* @param args
*/
public static void main(String[] args) {
DefaultGeographicCRS crs = DefaultGeographicCRS.WGS84;
if (args.length != 4) {
System.err.println("Need 4 numbers lat_1 lon_1 lat_2 lon_2");
return;
}
GeometryFactory geomFactory = new GeometryFactory();
Point[] points = new Point[2];
for (int i = 0, k = 0; i < 2; i++, k += 2) {
double x = Double.valueOf(args[k]);
double y = Double.valueOf(args[k + 1]);
if (CRS.getAxisOrder(crs).equals(AxisOrder.NORTH_EAST)) {
System.out.println("working with a lat/lon crs");
points[i] = geomFactory.createPoint(new Coordinate(x, y));
} else {
System.out.println("working with a lon/lat crs");
points[i] = geomFactory.createPoint(new Coordinate(y, x));
}
}
double distance = 0.0;
GeodeticCalculator calc = new GeodeticCalculator(crs);
calc.setStartingGeographicPoint(points[0].getX(), points[0].getY());
calc.setDestinationGeographicPoint(points[1].getX(), points[1].getY());
distance = calc.getOrthodromicDistance();
double bearing = calc.getAzimuth();
Measure<Double, Length> dist = Measure.valueOf(distance, SI.METER);
System.out.println(dist.doubleValue(SI.KILOMETER) + " Km");
System.out.println(dist.doubleValue(NonSI.MILE) + " miles");
System.out.println("Bearing " + bearing + " degrees");
}
示例14: measure
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
@Override
public double measure(
final Coordinate c1,
final Coordinate c2 ) {
try {
return JTS.orthodromicDistance(
c1,
c2,
getCRS());
}
catch (final TransformException e) {
throw new RuntimeException(
"Failed to transform coordinates to provided CRS",
e);
}
catch (final java.lang.AssertionError ae) {
// weird error with orthodromic distance..when distance is too close
// (0.05 meter), it fails the tolerance test
LOGGER.info(
"when distance is too close(0.05 meter), it fails the tolerance test",
ae);
final GeodeticCalculator calc = new GeodeticCalculator(
getCRS());
calc.setStartingGeographicPoint(
c1.x,
c1.y);
calc.setDestinationGeographicPoint(
c2.x,
c2.y);
return ((DefaultEllipsoid) calc.getEllipsoid()).orthodromicDistance(
calc.getStartingGeographicPoint().getX(),
calc.getStartingGeographicPoint().getY(),
calc.getDestinationGeographicPoint().getX(),
calc.getDestinationGeographicPoint().getY());
}
}
示例15: getGeodeticSegmentLength
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
private static double getGeodeticSegmentLength(double minx, double miny, double maxx, double maxy) {
final GeodeticCalculator calculator = new GeodeticCalculator(DefaultGeographicCRS.WGS84);
double rminx = rollLongitude(minx);
double rminy = rollLatitude(miny);
double rmaxx = rollLongitude(maxx);
double rmaxy = rollLatitude(maxy);
calculator.setStartingGeographicPoint(rminx, rminy);
calculator.setDestinationGeographicPoint(rmaxx, rmaxy);
return calculator.getOrthodromicDistance();
}