本文整理了Java中org.apache.sis.test.Assert.assertEqualsIgnoreMetadata()
方法的一些代码示例,展示了Assert.assertEqualsIgnoreMetadata()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.assertEqualsIgnoreMetadata()
方法的具体详情如下:
包路径:org.apache.sis.test.Assert
类名称:Assert
方法名:assertEqualsIgnoreMetadata
[英]Asserts that the two given objects are equal ignoring metadata. See ComparisonMode#IGNORE_METADATA for more information.
[中]断言两个给定对象相等,忽略元数据。有关详细信息,请参阅ComparisonMode#IGNORE_元数据。
代码示例来源:origin: apache/sis
/**
* Compares a projected CRS parsed from a WKT with a the CRS built from EPSG database.
* The later is taken as the reference.
*/
private static void compare(final String wkt, final int epsg) throws FactoryException {
final CoordinateReferenceSystem crs = CRS.fromWKT(wkt);
final EPSGFactory factory = TestFactorySource.factory;
assumeNotNull(factory);
final CoordinateReferenceSystem reference = factory.createProjectedCRS(Integer.toString(epsg));
assertEqualsIgnoreMetadata(reference, crs);
}
}
代码示例来源:origin: apache/sis
/**
* Tests {@link CoordinateSystems#replaceAxes(CoordinateSystem, AxisFilter)}
* without change of coordinate system type.
*/
@Test
public void testReplaceAxes() {
final EllipsoidalCS sourceCS = HardCodedCS.GEODETIC_3D;
final EllipsoidalCS targetCS = HardCodedCS.ELLIPSOIDAL_gon; // What we want to get.
final CoordinateSystem actualCS = CoordinateSystems.replaceAxes(sourceCS, new AxisFilter() {
@Override
public boolean accept(final CoordinateSystemAxis axis) {
return Units.isAngular(axis.getUnit());
}
@Override
public Unit<?> getUnitReplacement(CoordinateSystemAxis axis, Unit<?> unit) {
if (Units.isAngular(unit)) {
unit = Units.GRAD;
}
return unit;
}
});
assertEqualsIgnoreMetadata(targetCS, actualCS);
}
代码示例来源:origin: apache/sis
/**
* Implementation of {@link #testConsistency()} for a single WKT.
*
* @throws ParseException if the parsing failed.
*/
private void testConsistency(final String wkt) throws ParseException {
final Object expected = parser.parseObject(wkt);
final String reformat = format.format(expected);
final Object reparsed = format.parseObject(reformat);
assertEqualsIgnoreMetadata(expected, reparsed);
}
代码示例来源:origin: apache/sis
/**
* Tests {@link CoordinateSystems#replaceAxes(CoordinateSystem, AxisFilter)}
* with a change of coordinate system type.
*/
@Test
@DependsOnMethod("testReplaceAxes")
public void testReplaceAxesWithTypeChange() {
final EllipsoidalCS sourceCS = HardCodedCS.GEODETIC_3D;
final VerticalCS targetCS = HardCodedCS.ELLIPSOIDAL_HEIGHT; // What we want to get.
final CoordinateSystem actualCS = CoordinateSystems.replaceAxes(sourceCS, new AxisFilter() {
@Override
public boolean accept(final CoordinateSystemAxis axis) {
return Units.isLinear(axis.getUnit());
}
});
assertEqualsIgnoreMetadata(targetCS, actualCS);
}
代码示例来源:origin: apache/sis
/**
* Tests {@link CRS#compound(CoordinateReferenceSystem...)}.
*
* @throws FactoryException if an error occurred while creating a compound CRS.
*
* @since 0.8
*/
@Test
public void testCompound() throws FactoryException {
try {
CRS.compound();
fail("Should not accept empty array.");
} catch (IllegalArgumentException e) {
final String message = e.getMessage();
assertTrue(message, message.contains("components"));
}
assertSame(HardCodedCRS.WGS84, CRS.compound(HardCodedCRS.WGS84));
assertEqualsIgnoreMetadata(HardCodedCRS.WGS84_3D, CRS.compound(HardCodedCRS.WGS84, HardCodedCRS.ELLIPSOIDAL_HEIGHT));
}
代码示例来源:origin: apache/sis
/**
* Verifies the values of the given vertical extent.
*/
private static void verifyVerticalExtent(final CommonCRS.Vertical expectedCRS, final VerticalExtent extent) {
assertEquals(-10, extent.getMinimumValue(), STRICT);
assertEquals( 70, extent.getMaximumValue(), STRICT);
assertEqualsIgnoreMetadata(expectedCRS.crs(), extent.getVerticalCRS());
}
代码示例来源:origin: apache/sis
/**
* Asserts that the two given arrays contains objects that are equal ignoring metadata.
* See {@link ComparisonMode#IGNORE_METADATA} for more information.
*
* @param expected the expected objects (array can be {@code null}).
* @param actual the actual objects (array can be {@code null}).
*
* @since 0.7
*/
public static void assertArrayEqualsIgnoreMetadata(final Object[] expected, final Object[] actual) {
if (expected != actual) {
if (expected == null) {
assertNull("Expected null array.", actual);
} else {
assertNotNull("Expected non-null array.", actual);
final int length = StrictMath.min(expected.length, actual.length);
for (int i=0; i<length; i++) try {
assertEqualsIgnoreMetadata(expected[i], actual[i]);
} catch (AssertionError e) {
throw new AssertionError(Exceptions.formatChainedMessages(null, "Comparison failure at index "
+ i + " (a " + Classes.getShortClassName(actual[i]) + ").", e), e);
}
assertEquals("Unexpected array length.", expected.length, actual.length);
}
}
}
代码示例来源:origin: apache/sis
final Object[] components = CRS.getSingleComponents(compound).toArray();
assertEquals(2, components.length);
assertEqualsIgnoreMetadata(temporal, components[0]);
assertInstanceOf("Shall be a three-dimensional geographic CRS.", GeographicCRS.class, components[1]);
assertAxisDirectionsEqual("Shall be a three-dimensional geographic CRS.",
代码示例来源:origin: apache/sis
final Object[] components = CRS.getSingleComponents(compound).toArray();
assertEquals(2, components.length);
assertEqualsIgnoreMetadata(temporal, components[0]);
assertInstanceOf("Shall be a three-dimensional projected CRS.", ProjectedCRS.class, components[1]);
assertAxisDirectionsEqual("Shall be a three-dimensional projected CRS.",
代码示例来源:origin: apache/sis
/**
* Tests {@link CRS#getHorizontalComponent(CoordinateReferenceSystem)}.
*/
@Test
@DependsOnMethod("testIsHorizontalCRS")
public void testGetHorizontalComponent() {
assertNull(CRS.getHorizontalComponent(HardCodedCRS.TIME));
assertNull(CRS.getHorizontalComponent(HardCodedCRS.ELLIPSOIDAL_HEIGHT));
assertNull(CRS.getHorizontalComponent(HardCodedCRS.GEOCENTRIC));
assertSame(HardCodedCRS.WGS84, CRS.getHorizontalComponent(HardCodedCRS.WGS84));
assertSame(HardCodedCRS.WGS84_φλ, CRS.getHorizontalComponent(HardCodedCRS.WGS84_φλ));
assertEqualsIgnoreMetadata(HardCodedCRS.WGS84, CRS.getHorizontalComponent(HardCodedCRS.WGS84_3D));
}
代码示例来源:origin: apache/sis
/**
* Tests getting the horizontal and vertical components of a three-dimensional projected CRS.
*
* @since 0.8
*/
@Test
public void testComponentsOfProjectedCRS() {
final ProjectedCRS volumetric = HardCodedConversions.mercator3D();
assertFalse("isHorizontalCRS", CRS.isHorizontalCRS(volumetric));
assertNull("getTemporalComponent", CRS.getTemporalComponent(volumetric));
assertNull("getVerticalComponent", CRS.getVerticalComponent(volumetric, false));
assertEqualsIgnoreMetadata(HardCodedCRS.ELLIPSOIDAL_HEIGHT, CRS.getVerticalComponent(volumetric, true));
final SingleCRS horizontal = CRS.getHorizontalComponent(volumetric);
assertInstanceOf("getHorizontalComponent", ProjectedCRS.class, horizontal);
assertEquals("dimension", 2, horizontal.getCoordinateSystem().getDimension());
assertTrue("isHorizontalCRS", CRS.isHorizontalCRS(horizontal));
}
代码示例来源:origin: apache/sis
Collections.singletonMap(DefaultGeographicCRS.NAME_KEY, CRS84.getName()),
CRS84.getDatum(), CRS84.getCoordinateSystem());
assertEqualsIgnoreMetadata(CRS84, search); // Required condition for next test.
代码示例来源:origin: apache/sis
/**
* Tests {@link CRS#getVerticalComponent(CoordinateReferenceSystem, boolean)}.
*/
@Test
public void testGetVerticalComponent() {
assertNull(CRS.getVerticalComponent(HardCodedCRS.TIME, false));
assertNull(CRS.getVerticalComponent(HardCodedCRS.TIME, true));
assertNull(CRS.getVerticalComponent(HardCodedCRS.WGS84, false));
assertNull(CRS.getVerticalComponent(HardCodedCRS.WGS84, true));
assertSame(HardCodedCRS.ELLIPSOIDAL_HEIGHT, CRS.getVerticalComponent(HardCodedCRS.ELLIPSOIDAL_HEIGHT, false));
assertSame(HardCodedCRS.ELLIPSOIDAL_HEIGHT, CRS.getVerticalComponent(HardCodedCRS.ELLIPSOIDAL_HEIGHT, true));
assertSame(HardCodedCRS.GRAVITY_RELATED_HEIGHT, CRS.getVerticalComponent(HardCodedCRS.GEOID_4D, false));
assertSame(HardCodedCRS.GRAVITY_RELATED_HEIGHT, CRS.getVerticalComponent(HardCodedCRS.GEOID_4D, true));
assertNull(CRS.getVerticalComponent(HardCodedCRS.WGS84_3D, false));
assertEqualsIgnoreMetadata(HardCodedCRS.ELLIPSOIDAL_HEIGHT,
CRS.getVerticalComponent(HardCodedCRS.WGS84_3D, true));
}
内容来源于网络,如有侵权,请联系作者删除!