示例#1
0
  /**
   * Added this test after a bug was reported in JTS.transform for converting between WGS84 (2D) and
   * DefaultGeocentric.CARTESIAN (3D).
   */
  @Test
  public void transformCoordinate2DCRSTo3D() throws Exception {
    CoordinateReferenceSystem srcCRS = DefaultGeographicCRS.WGS84;
    CoordinateReferenceSystem targetCRS = DefaultGeocentricCRS.CARTESIAN;
    MathTransform transform = CRS.findMathTransform(srcCRS, targetCRS);

    Coordinate srcCoord = new Coordinate(0, 0);
    Coordinate dest0 = JTS.transform(srcCoord, null, transform);

    srcCoord.x = 180;
    Coordinate dest180 = JTS.transform(srcCoord, null, transform);

    // Only a perfunctory check on the return values - mostly we
    // just wanted to make sure there was no exception
    assertEquals(dest0.x, -dest180.x, TOL);
    assertEquals(dest0.y, dest180.y, TOL);
    assertEquals(dest0.z, dest180.z, TOL);
  }