当前位置: 首页>>代码示例>>Java>>正文


Java GeodeticCalculator.getOrthodromicDistance方法代码示例

本文整理汇总了Java中org.geotools.referencing.GeodeticCalculator.getOrthodromicDistance方法的典型用法代码示例。如果您正苦于以下问题:Java GeodeticCalculator.getOrthodromicDistance方法的具体用法?Java GeodeticCalculator.getOrthodromicDistance怎么用?Java GeodeticCalculator.getOrthodromicDistance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.geotools.referencing.GeodeticCalculator的用法示例。


在下文中一共展示了GeodeticCalculator.getOrthodromicDistance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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;
	}
 
开发者ID:ianmalcolm,项目名称:DeadReckoning,代码行数:20,代码来源:GeoPoint.java

示例2: 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();
}
 
开发者ID:bptlab,项目名称:Unicorn,代码行数:28,代码来源:GeoUtils.java

示例3: 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;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:19,代码来源:AffineGeoTransform.java

示例4: 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;
}
 
开发者ID:GIScience,项目名称:osmgpxmapmatcher,代码行数:27,代码来源:Util.java

示例5: 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);
    
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:24,代码来源:TestENU.java

示例6: 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;
}
 
开发者ID:geobeyond,项目名称:fluxomajic,代码行数:22,代码来源:FluxoFilterFunction.java

示例7: 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);
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:17,代码来源:ConfigurationDtoPostProcessor.java

示例8: 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();
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:16,代码来源:GeoUtils.java

示例9: 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());
}
 
开发者ID:Contargo,项目名称:iris,代码行数:10,代码来源:GisServiceImpl.java

示例10: 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;
    }
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:50,代码来源:OmsGeopaparazzi4Converter.java

示例11: 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;
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:12,代码来源:AutoProjection.java

示例12: 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");
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:41,代码来源:OrthodromicDistance2.java

示例13: 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();
}
 
开发者ID:geobeyond,项目名称:fluxomajic,代码行数:11,代码来源:FluxoFilterFunction.java

示例14: recurseRefineGroups

import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
/**
 * Check through the groups to see if any are closer than the threshold.
 * 
 * @param depth
 * @return
 */
private Boolean recurseRefineGroups(int depth) {
	
	depth++;
	
	if (depth > 50)
	{
		log.error("Infinite recursion detected.  Bailing out");
		return false;
	}
	
	if (groups.size() == 1)
	{
		log.info("One one group so no need to refine further");
		return false;
	}
	
	GeodeticCalculator gc = new GeodeticCalculator();
	
	for (int i = 0; i < groups.size(); i++)
	{
		ArrayList<FHFile> focusedgroup = groups.get(i);
		
		for (int j = 0; j < groups.size(); j++)
		{
			if (j == i)
				continue;
			ArrayList<FHFile> searchgroup = groups.get(j);
			
			for (FHFile f1 : focusedgroup)
			{
				gc.setStartingGeographicPoint(f1.getFirstLongitudeDbl(), f1.getFirstLatitudeDbl());
				
				for (FHFile f2 : searchgroup)
				{
					gc.setDestinationGeographicPoint(f2.getFirstLongitudeDbl(), f2.getFirstLatitudeDbl());
					Double distance = gc.getOrthodromicDistance();
					if (distance <= distanceThreshold * 1000)
					{
						// Merge groups i and j
						ArrayList<FHFile> mergedgroups = new ArrayList<FHFile>();
						ArrayList<ArrayList<FHFile>> newgroups = new ArrayList<ArrayList<FHFile>>();
						mergedgroups.addAll(focusedgroup);
						mergedgroups.addAll(searchgroup);
						newgroups.add(mergedgroups);
						for (int k = 0; k < groups.size(); k++)
						{
							ArrayList<FHFile> othergroup = groups.get(k);
							if (k != i && k != j)
							{
								newgroups.add(othergroup);
							}
						}
						
						groups = newgroups;
						
						recurseRefineGroups(depth);
						return true;
					}
				}
			}
			
		}
		
	}
	
	return false;
}
 
开发者ID:petebrew,项目名称:fhaes,代码行数:74,代码来源:FHCluster.java

示例15: searchGroupsForMatch

import org.geotools.referencing.GeodeticCalculator; //导入方法依赖的package包/类
/**
 * Search through the existing groups to see if the specified file is close enough to group, otherwise place it in it's own group.
 * 
 * @param file
 * @return
 */
private Boolean searchGroupsForMatch(FHFile file) {
	
	if (file == null)
	{
		return false;
	}
	
	if (file.getFirstLatitudeDbl() == null || file.getFirstLongitudeDbl() == null)
	{
		log.warn("File " + file.getName() + " has no location information so skipping");
		filesWithNoCoords.add(file);
		return false;
	}
	
	GeodeticCalculator gc = new GeodeticCalculator();
	gc.setStartingGeographicPoint(file.getFirstLongitudeDbl(), file.getFirstLatitudeDbl());
	
	for (ArrayList<FHFile> group : groups)
	{
		for (FHFile f : group)
		{
			if (f.equals(file))
			{
				
				log.error("Found file in group already so skipping");
				return true;
			}
			
			gc.setDestinationGeographicPoint(f.getFirstLongitudeDbl(), f.getFirstLatitudeDbl());
			
			Double distance = gc.getOrthodromicDistance();
			log.debug("Distance between " + file.getName() + " and " + f.getName() + " is " + distance.intValue() + "m");
			
			if (distance <= distanceThreshold * 1000)
			{
				group.add(file);
				return true;
			}
		}
	}
	
	// No matches found so create a new group for the file
	ArrayList<FHFile> newgroup = new ArrayList<FHFile>();
	newgroup.add(file);
	groups.add(newgroup);
	return true;
}
 
开发者ID:petebrew,项目名称:fhaes,代码行数:54,代码来源:FHCluster.java


注:本文中的org.geotools.referencing.GeodeticCalculator.getOrthodromicDistance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。