예제 #1
0
  /** Tests the transformations of an envelope. */
  @Test
  public void testEnvelopeTransformation() throws FactoryException, TransformException {
    final CoordinateReferenceSystem mapCRS = CRS.parseWKT(WKT.UTM_10N);
    final CoordinateReferenceSystem WGS84 = DefaultGeographicCRS.WGS84;
    final MathTransform crsTransform = CRS.findMathTransform(WGS84, mapCRS, true);
    assertFalse(crsTransform.isIdentity());

    final GeneralEnvelope firstEnvelope, transformedEnvelope, oldEnvelope;
    firstEnvelope = new GeneralEnvelope(new double[] {-124, 42}, new double[] {-122, 43});
    firstEnvelope.setCoordinateReferenceSystem(WGS84);

    transformedEnvelope = CRS.transform(crsTransform, firstEnvelope);
    transformedEnvelope.setCoordinateReferenceSystem(mapCRS);

    oldEnvelope = CRS.transform(crsTransform.inverse(), transformedEnvelope);
    oldEnvelope.setCoordinateReferenceSystem(WGS84);

    assertTrue(oldEnvelope.contains(firstEnvelope, true));
    assertTrue(oldEnvelope.equals(firstEnvelope, 0.02, true));
  }
예제 #2
0
  /**
   * Tests the transformations of an envelope when the two CRS have identify transforms but
   * different datum names
   */
  @Test
  public void testEnvelopeTransformation2() throws FactoryException, TransformException {
    final CoordinateReferenceSystem WGS84Altered = CRS.parseWKT(WKT.WGS84_ALTERED);
    final CoordinateReferenceSystem WGS84 = DefaultGeographicCRS.WGS84;
    final MathTransform crsTransform = CRS.findMathTransform(WGS84, WGS84Altered, true);
    assertTrue(crsTransform.isIdentity());

    final GeneralEnvelope firstEnvelope;
    firstEnvelope = new GeneralEnvelope(new double[] {-124, 42}, new double[] {-122, 43});
    firstEnvelope.setCoordinateReferenceSystem(WGS84);

    // this triggered a assertion error in GEOT-2934
    Envelope transformed = CRS.transform(firstEnvelope, WGS84Altered);

    // check the envelope is what we expect
    assertEquals(transformed.getCoordinateReferenceSystem(), WGS84Altered);
    double EPS = 1e-9;
    assertEquals(transformed.getMinimum(0), firstEnvelope.getMinimum(0), EPS);
    assertEquals(transformed.getMinimum(1), firstEnvelope.getMinimum(1), EPS);
    assertEquals(transformed.getMaximum(0), firstEnvelope.getMaximum(0), EPS);
    assertEquals(transformed.getMaximum(1), firstEnvelope.getMaximum(1), EPS);
  }
예제 #3
0
 /**
  * Tests an ESRI code.
  *
  * @todo Not yet working.
  */
 @Test
 @Ignore
 public void testESRICode() throws Exception {
   String wkt =
       "PROJCS[\"Albers_Conic_Equal_Area\",\n"
           + "  GEOGCS[\"GCS_North_American_1983\",\n"
           + "    DATUM[\"D_North_American_1983\",\n"
           + "    SPHEROID[\"GRS_1980\",6378137.0,298.257222101]],\n"
           + "    PRIMEM[\"Greenwich\",0.0],\n"
           + "    UNIT[\"Degree\",0.0174532925199433]],\n"
           + "  PROJECTION[\"Equidistant_Conic\"],\n"
           + "  PARAMETER[\"False_Easting\",0.0],\n"
           + "  PARAMETER[\"False_Northing\",0.0],\n"
           + "  PARAMETER[\"Central_Meridian\",-96.0],\n"
           + "  PARAMETER[\"Standard_Parallel_1\",33.0],\n"
           + "  PARAMETER[\"Standard_Parallel_2\",45.0],\n"
           + "  PARAMETER[\"Latitude_Of_Origin\",39.0],\n"
           + "  UNIT[\"Meter\",1.0]]";
   CoordinateReferenceSystem crs = CRS.parseWKT(wkt);
   final CoordinateReferenceSystem WGS84 = DefaultGeographicCRS.WGS84;
   final MathTransform crsTransform = CRS.findMathTransform(WGS84, crs, true);
   assertFalse(crsTransform.isIdentity());
 }