本文整理汇总了Java中org.geotools.referencing.GeodeticCalculator.setDirection方法的典型用法代码示例。如果您正苦于以下问题:Java GeodeticCalculator.setDirection方法的具体用法?Java GeodeticCalculator.setDirection怎么用?Java GeodeticCalculator.setDirection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.referencing.GeodeticCalculator
的用法示例。
在下文中一共展示了GeodeticCalculator.setDirection方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDestinationFrom
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
public GPXEntry getDestinationFrom(GPXEntry v) {
// assert time.after(v.time);
double x = getX();
double y = getY();
double z = getZ();
Vector3D mirror = new Vector3D(y, x, z);
// Velocity newv = new Velocity(
// new Vector3D(v.getY(), v.getX(), v.getZ()), v.time.getTime());
// reference:
// http://stackoverflow.com/questions/3917340/geotools-how-to-do-dead-reckoning-and-course-calculations-using-geotools-class
GeodeticCalculator calc = new GeodeticCalculator();
// It's odd! setStartingGeographicPoint accept longitude first
calc.setStartingGeographicPoint(v.lon, v.lat);
// calc.setDirection(FastMath.toDegrees(Math.PI / 2 - v.getAzimuth()),
// v.getHorizontalSpeed() * diff);
calc.setDirection(FastMath.toDegrees(mirror.getAlpha()), getNorm());
Point2D p = calc.getDestinationGeographicPoint();
// It's odd! getDestinationGeographicPoint returns longitude first
return new GPXEntry(p.getY(), p.getX(), getZ(), time.getTime());
}
示例2: getBoxShape
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
/**
* Returns boundaries of a box shape which centre is the point defined by the
* given longitude and latitude. The distance between the center point and the
* edges of the box is defined in meters by the given distance. Based on standard
* EPSG:4326 long/lat projection. The result is an array of length 4 where
* the values at each index are:
*
* <ul>
* <li>Index 0: Maximum latitude (north edge of box shape).</li>
* <li>Index 1: Maxium longitude (east edge of box shape).</li>
* <li>Index 2: Minimum latitude (south edge of box shape).</li>
* <li>Index 3: Minumum longitude (west edge of box shape).</li>
* </ul>
*
* @param longitude the longitude.
* @param latitude the latitude.
* @param distance the distance in meters to each box edge.
* @return an array of length 4.
*/
public static double[] getBoxShape( double longitude, double latitude, double distance )
{
double[] box = new double[4];
GeodeticCalculator calc = new GeodeticCalculator();
calc.setStartingGeographicPoint( longitude, latitude );
calc.setDirection( 0, distance );
Point2D north = calc.getDestinationGeographicPoint();
calc.setDirection( 90, distance );
Point2D east = calc.getDestinationGeographicPoint();
calc.setDirection( 180, distance );
Point2D south = calc.getDestinationGeographicPoint();
calc.setDirection( -90, distance );
Point2D west = calc.getDestinationGeographicPoint();
box[0] = north.getY();
box[1] = east.getX();
box[2] = south.getY();
box[3] = west.getX();
return box;
}
示例3: main
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
public static void main(final String[] args) {
GeodeticCalculator calc = new GeodeticCalculator();
KMLPath mypath = new KMLPath();
boolean mustClose = false;
PrintStream ps = null;
try {
File f = new File(args[0]);
if(f.exists()) {
f.delete();
}
ps = new PrintStream(new BufferedOutputStream(new FileOutputStream(f, false)));
mustClose=true;
}
catch(Exception e) {
ps = System.out;
}
Point2D start = new Point2D.Double(13.25197, 52.44378);
for(double A=0.0; A<=180.0; ++A) {
calc.setStartingGeographicPoint(start);
calc.setDirection(A, A*30);
Point2D mypoint = calc.getDestinationGeographicPoint();
mypath.addPoint(mypoint);
}
mypath.generatePath(ps);
if(mustClose) {
ps.close();
}
}
示例4: getMetersAsWGS84
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
/**
* Converts meters to degrees, based on a given coordinate in 90 degrees direction.
*
* @param meters the meters to convert.
* @param c the position to consider.
* @return the converted degrees.
*/
public static double getMetersAsWGS84( double meters, Coordinate c ) {
GeodeticCalculator gc = new GeodeticCalculator(DefaultGeographicCRS.WGS84);
gc.setStartingGeographicPoint(c.x, c.y);
gc.setDirection(90, meters);
Point2D destinationGeographicPoint = gc.getDestinationGeographicPoint();
double degrees = Math.abs(destinationGeographicPoint.getX() - c.x);
return degrees;
}
示例5: farthestPoint
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
/** farther point in longitudinal axis given a latitude */
private static Point farthestPoint(
final CoordinateReferenceSystem crs,
final Point point,
final double meters ) {
final GeodeticCalculator calc = new GeodeticCalculator(
crs);
calc.setStartingGeographicPoint(
point.getX(),
point.getY());
calc.setDirection(
90,
meters);
Point2D dest2D = calc.getDestinationGeographicPoint();
// if this flips over the date line then try the other direction
if (dest2D.getX() < point.getX()) {
calc.setDirection(
-90,
meters);
dest2D = calc.getDestinationGeographicPoint();
}
return point.getFactory().createPoint(
new Coordinate(
dest2D.getX(),
dest2D.getY()));
}
示例6: add
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
public GeoPoint add(Step step) {
Step mirror = new Step(step.getY(), step.getX(), step.getZ(),
step.time.getTime());
GeodeticCalculator calc = new GeodeticCalculator();
calc.setStartingGeographicPoint(lon, lat);
calc.setDirection(FastMath.toDegrees(mirror.getAlpha()),
mirror.getNorm());
Point2D p = calc.getDestinationGeographicPoint();
double newlat = p.getY();
double newlon = p.getX();
double newele = ele + step.getZ();
return new GeoPoint(newlat, newlon, newele, step.time.getTime());
}
示例7: test
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
@Ignore
@Test
public void test() {
// double[] cardanx90 = { 3.1415926 / 2, 0, 0 };
// double[] cardany90 = { 0, 3.1415926 / 2, 0 };
// double[] cardan = { -1.714632, -0.030732, -1.910005 };
double[] cardan = { -1.714632, -0.030732, -1.910005 };
// double[] cardan = { 0, 0, 0 };
// ZEROPOINTVECTOR;
// Double roll = FastMath.toDegrees(cardan[0]); // y
// Double pitch = FastMath.toDegrees(cardan[1]); // x
// Double yaw = FastMath.toDegrees(cardan[2]); // z
// System.out.println(roll.toString() + ',' + pitch.toString() + ','
// + yaw.toString());
//
// Attitude att = new Attitude(cardan, 100);
// Vector3D worldVel = att.getVelocity(10);
// System.out.println(worldVel.toString());
//
// Rotation r = new Rotation(RotationOrder.ZXZ, cardan[2], cardan[0],
// cardan[1]);
// worldVel = r.applyTo(new Vector3D(0, 0, -1));
// System.out.println(worldVel.scalarMultiply(10).toString());
//
// Attitude att = new Attitude(cardan, 100);
// Rotation calib = new Rotation(RotationOrder.ZXZ, 0, 0, Math.PI/2);
// Rotation zerocalib = new Rotation(RotationOrder.ZXZ, 0, 0, 0);
// Attitude newatt = att.calibrate(calib);
// Attitude zeroatt = att.calibrate(zerocalib);
// System.out.println(att.toString());
// System.out.println(zeroatt.toString());
// System.out.println(newatt.toString());
GeoPoint p = new GeoPoint(1.298167, 103.788173, 0, 0);
// GeoPosition q = new GeoPosition(1.300103, 103.790265, 0, 0);
// GeoPosition r = new GeoPosition(1.299014, 103.790849, 0, 0);
GeoPoint s = new GeoPoint(1.298167, 103.790265, 0, 0);
GeoPoint t = new GeoPoint(1.300103, 103.788173, 0, 0);
Vector3D u = new Vector3D(1, 0, 0);
Vector3D v = new Vector3D(0, 1, 0);
System.out.println(u.getAlpha() + "\t" + v.getAlpha());
System.out.println(GeoPoint.distance(p, s).getAlpha() + "\t"
+ GeoPoint.distance(p, t).getAlpha());
GeodeticCalculator calc = new GeodeticCalculator();
calc.setStartingGeographicPoint(103.788173, 1.298167);
calc.setDirection(90, 100);
Point2D dest = calc.getDestinationGeographicPoint();
System.out.println(dest.toString());
}
示例8: buildSurroundingGeometries
import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
/**
* Build geometries with the provided coordinate at the center. The width of
* the geometry is twice the distance provided. More than one geometry is
* return when passing the date line.
*
* @param distances
* [x,y] = [longitude, latitude]
* @param unit
* @param coordinate
* @return
*/
public List<Geometry> buildSurroundingGeometries(
final double[] distances,
final Unit<Length> unit,
Coordinate coordinate ) {
List<Geometry> geos = new LinkedList<Geometry>();
GeodeticCalculator geoCalc = new GeodeticCalculator();
geoCalc.setStartingGeographicPoint(
coordinate.x,
coordinate.y);
try {
geoCalc.setDirection(
0,
unit.getConverterTo(
SI.METER).convert(
distances[1]));
DirectPosition north = geoCalc.getDestinationPosition();
geoCalc.setDirection(
90,
unit.getConverterTo(
SI.METER).convert(
distances[0]));
DirectPosition east = geoCalc.getDestinationPosition();
geoCalc.setStartingGeographicPoint(
coordinate.x,
coordinate.y);
geoCalc.setDirection(
-90,
unit.getConverterTo(
SI.METER).convert(
distances[0]));
DirectPosition west = geoCalc.getDestinationPosition();
geoCalc.setDirection(
180,
unit.getConverterTo(
SI.METER).convert(
distances[1]));
DirectPosition south = geoCalc.getDestinationPosition();
double x1 = west.getOrdinate(0);
double x2 = east.getOrdinate(0);
double y1 = north.getOrdinate(1);
double y2 = south.getOrdinate(1);
handleBoundaries(
geos,
coordinate,
x1,
x2,
y1,
y2);
return geos;
}
catch (IllegalArgumentException | IndexOutOfBoundsException | TransformException | ConversionException ex) {
LOGGER.error(
"Unable to build geometry",
ex);
}
return null;
}