org.geotools.geometry.jts.JTS.orthodromicDistance()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(4.5k)|赞(0)|评价(0)|浏览(186)

本文整理了Java中org.geotools.geometry.jts.JTS.orthodromicDistance()方法的一些代码示例,展示了JTS.orthodromicDistance()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTS.orthodromicDistance()方法的具体详情如下:
包路径:org.geotools.geometry.jts.JTS
类名称:JTS
方法名:orthodromicDistance

JTS.orthodromicDistance介绍

[英]Computes the orthodromic distance between two points. This method:

  1. Transforms both points to geographic coordinates (latitude,longitude).
  2. Computes the orthodromic distance between the two points using ellipsoidal calculations.

The real work is performed by GeodeticCalculator. This convenience method simply manages a pool of pre-defined geodetic calculators for the given coordinate reference system in order to avoid repetitive object creation. If a large amount of orthodromic distances need to be computed, direct use of GeodeticCalculator provides better performance than this convenience method.
[中]计算两点之间的正射距离。此方法:
1.将两个点转换为地理坐标(纬度、经度)。
1.使用椭球体计算计算两点之间的正射距离。
实际工作由大地测量计算器完成。这种方便的方法只是为给定的坐标参考系管理一组预定义的大地测量计算器,以避免重复创建对象。如果需要计算大量的正射距离,直接使用大地测量计算器比这种方便的方法提供更好的性能。

代码示例

代码示例来源:origin: opentripplanner/OpenTripPlanner

length += JTS.orthodromicDistance(coordinates[i],
    coordinates[i + 1], worldCRS);

代码示例来源:origin: geotools/geotools

JTS.orthodromicDistance(
      new Coordinate(newCsLatLong[0], newCsLatLong[1]),
      new Coordinate(newCsLatLong[2], newCsLatLong[3]),
JTS.orthodromicDistance(
    new Coordinate(csLatLong[0], csLatLong[1]),
    new Coordinate(csLatLong[2], csLatLong[3]),

代码示例来源:origin: geotools/geotools

/** Tests the distance between points function */
@Test
public void testOrthodromicDistance() throws Exception {
  final Parser parser = new Parser();
  final DefaultProjectedCRS crs = (DefaultProjectedCRS) parser.parseObject(NAD83_BC);
  double d =
      JTS.orthodromicDistance(
          new Coordinate(1402848.1938534670, 651571.1729878788),
          new Coordinate(1389481.3104009738, 641990.9430108378),
          crs);
  double realValue = 16451.33114;
  assertEquals(realValue, d, 0.1);
}

代码示例来源:origin: org.opentripplanner/opentripplanner-routing

public static double orthodromicDistance(Coordinate a, Coordinate b) {
  try {
    return JTS.orthodromicDistance(a,b,WORLD_CRS);
  } catch (TransformException ex) {
    throw new IllegalStateException("error computing distance: a=" + a + " b=" + b,ex);
  }
}

代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-geocoder

Coordinate test;
test = new Coordinate(x + halfCrsWidth, y);
double deltaX = JTS.orthodromicDistance(coordinate, test, crs);
test = new Coordinate(x, y + halfCrsHeight);
double deltaY = JTS.orthodromicDistance(coordinate, test, crs);
if (Math.abs(deltaX - width / 2) < DISTANCE_PRECISION &&
    Math.abs(deltaY - height / 2) < DISTANCE_PRECISION) {

代码示例来源:origin: com.conveyal/gtfs-lib

/** Get the length of a linestring in meters */
  public static double getDistance(LineString tripGeometry) {
   double distance = 0;
   for (int i = 0; i < tripGeometry.getNumPoints() - 1; i++) {
    try {
     distance += JTS.orthodromicDistance(tripGeometry.getCoordinateN(i), tripGeometry.getCoordinateN(i + 1), DefaultGeographicCRS.WGS84);
    } catch (TransformException e) {
     throw new RuntimeException(e);
    }
   }

   return distance;
  }
}

代码示例来源:origin: org.geotools/gt2-render

/ envelope.getHeight() * imageHeight;
  double distance_ground = JTS.orthodromicDistance(new Coordinate(
      newCsLatLong[0], newCsLatLong[1]), new Coordinate(
      newCsLatLong[2], newCsLatLong[3]),
double diagonalGroundDistance = JTS.orthodromicDistance(new Coordinate(
    csLatLong[0], csLatLong[1]), new Coordinate(csLatLong[2],
    csLatLong[3]), DefaultGeographicCRS.WGS84);

代码示例来源:origin: org.geotools/gt-render

/ envelope.getHeight() * imageHeight;
  double distance_ground = JTS.orthodromicDistance(new Coordinate(
      newCsLatLong[0], newCsLatLong[1]), new Coordinate(
      newCsLatLong[2], newCsLatLong[3]),
double diagonalGroundDistance = JTS.orthodromicDistance(new Coordinate(
    csLatLong[0], csLatLong[1]), new Coordinate(csLatLong[2],
    csLatLong[3]), DefaultGeographicCRS.WGS84);

代码示例来源:origin: matsim-org/matsim

/**
 * Calculates the distance between two points. If the SRID is 0, a cartesian coordinate system is assumed and {@link
 * CartesianDistanceCalculator} is used, otherwise {@link JTS#orthodromicDistance(Coordinate, Coordinate,
 * CoordinateReferenceSystem)} is used.
 *
 * @param p1 the source point
 * @param p2 the target point
 * @return the distance between <tt>p1</tt> and <tt>p2</tt> or {@code Double.NaN} if the distance cannot be
 * calculated.
 * @throws RuntimeException if points have different SRIDs
 */
@Override
public double distance(Point p1, Point p2) {
  if (p1.getSRID() == p2.getSRID()) {
    if (p1.getSRID() == 0) {
      return CartesianDistanceCalculator.getInstance().distance(p1, p2);
    } else {
      try {
        return JTS.orthodromicDistance(p1.getCoordinate(), p2.getCoordinate(),
            CRSUtils.getCRS(p1.getSRID()));
      } catch (TransformException e) {
        e.printStackTrace();
        return Double.NaN;
      }
    }
  } else {
    throw new RuntimeException("Incompatible coordinate reference systems.");
  }
}

相关文章