本文整理了Java中org.apache.sis.util.Utilities.equalsIgnoreMetadata()
方法的一些代码示例,展示了Utilities.equalsIgnoreMetadata()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utilities.equalsIgnoreMetadata()
方法的具体详情如下:
包路径:org.apache.sis.util.Utilities
类名称:Utilities
方法名:equalsIgnoreMetadata
[英]Compares the specified objects for equality, ignoring metadata. If this method returns true, then:
org.apache.sis.referencing.CRS#findOperation(crs1, crs2, null)
will return an identity operation.Implementation note
This is a convenience method for the following method call: java
[中]比较指定对象的相等性,忽略元数据。如果此方法返回true,则:
*如果给定的两个对象是org。阿帕奇。姐妹。参考。活动使改变AbstractMathTransform,然后使用一个变换变换一组坐标值,将产生与使用另一个变换变换相同坐标值相同的结果。
*如果给定的两个对象是org。阿帕奇。姐妹。参考。crs。AbstractCRS(CRS),则对org.apache.sis.referencing.CRS#findOperation(crs1, crs2, null)
的调用将返回标识操作。
如果需要更宽松的比较,允许数值略有差异,那么可以使用#等近似(Object,Object)。
实施说明
这是以下方法调用的一个方便方法:java
代码示例来源:origin: apache/sis
/**
* If the authority defines an object equal, ignoring metadata, to the given object, returns that authority object.
* Otherwise returns the given object unchanged. We do not invoke this method for user-supplied CRS, but only for
* CRS or other objects created by {@code CoordinateOperationRegistry} as intermediate step.
*/
final <T extends IdentifiedObject> T toAuthorityDefinition(final Class<T> type, final T object) throws FactoryException {
if (codeFinder != null) {
codeFinder.setIgnoringAxes(false);
final IdentifiedObject candidate = codeFinder.findSingleton(object);
codeFinder.setIgnoringAxes(true);
if (Utilities.equalsIgnoreMetadata(object, candidate)) {
return type.cast(candidate);
}
}
return object;
}
代码示例来源:origin: org.apache.sis.core/sis-referencing
/**
* If the authority defines an object equal, ignoring metadata, to the given object, returns that authority object.
* Otherwise returns the given object unchanged. We do not invoke this method for user-supplied CRS, but only for
* CRS or other objects created by {@code CoordinateOperationRegistry} as intermediate step.
*/
final <T extends IdentifiedObject> T toAuthorityDefinition(final Class<T> type, final T object) throws FactoryException {
if (codeFinder != null) {
codeFinder.setIgnoringAxes(false);
final IdentifiedObject candidate = codeFinder.findSingleton(object);
codeFinder.setIgnoringAxes(true);
if (Utilities.equalsIgnoreMetadata(object, candidate)) {
return type.cast(candidate);
}
}
return object;
}
代码示例来源:origin: org.apache.sis.core/sis-referencing
final Datum d = components.get(i).getDatum();
for (int j=n; --j >= 0;) {
if (Utilities.equalsIgnoreMetadata(d, datum[j])) {
System.arraycopy(datum, j+1, datum, j, --n - j); // Remove the datum from the list.
continue next;
代码示例来源:origin: apache/sis
final Datum d = components.get(i).getDatum();
for (int j=n; --j >= 0;) {
if (Utilities.equalsIgnoreMetadata(d, datum[j])) {
System.arraycopy(datum, j+1, datum, j, --n - j); // Remove the datum from the list.
continue next;
代码示例来源:origin: Geomatys/geotoolkit
/**
* Make sure that the specified bounding box uses the same CRS than this one.
*
* @param bbox The other bounding box to test for compatibility.
* @throws MismatchedReferenceSystemException if the CRS are incompatibles.
*/
private void ensureCompatibleReferenceSystem(final BoundingBox bbox)
throws MismatchedReferenceSystemException {
if (crs != null) {
final CoordinateReferenceSystem other = bbox.getCoordinateReferenceSystem();
if (other != null) {
if (!Utilities.equalsIgnoreMetadata(crs, other)) {
throw new MismatchedReferenceSystemException(Errors.format(
Errors.Keys.MismatchedCoordinateReferenceSystem));
}
}
}
}
代码示例来源:origin: Geomatys/geotoolkit
/**
* Returns a new point with the same coordinates than this one, but transformed in the given
* CRS. This method never returns {@code this}, so the returned point usually doesn't need to
* be cloned.
*
* @param crs The CRS for the position to be returned.
* @return The same position than {@code this}, but transformed in the specified CRS.
* @throws TransformException if a coordinate transformation was required and failed.
*
* @since 2.3
*/
public DirectPosition inverseTransform(final CoordinateReferenceSystem crs)
throws TransformException
{
if (inverse == null || !Utilities.equalsIgnoreMetadata(sourceCRS, crs)) {
ensureNonNull("crs", crs);
setSourceCRS(crs);
inverse = forward.inverse();
}
return inverse.transform(this, null);
}
代码示例来源:origin: apache/sis
/**
* Sets the CRS of all given ares to a common value. An exception is thrown if incompatible CRS are found.
* This method does not verify the number of dimensions; this check should have been done by the caller.
*/
static void uniformize(final SubArea[] domains) {
CoordinateReferenceSystem common = null;
for (SubArea area : domains) {
do {
final CoordinateReferenceSystem crs = area.getCoordinateReferenceSystem();
if (common == null) {
common = crs;
} else if (crs != null && !Utilities.equalsIgnoreMetadata(common, crs)) {
throw new MismatchedReferenceSystemException(Errors.format(Errors.Keys.MismatchedCRS));
}
} while ((area = area.specialization) != null);
}
for (SubArea area : domains) {
do area.setCoordinateReferenceSystem(common);
while ((area = area.specialization) != null);
}
}
代码示例来源:origin: apache/sis
/**
* Ensures that the {@code actual} CRS uses a datum which is equals, ignoring metadata,
* to the datum of the {@code expected} CRS.
*
* @param param the parameter name, used only in case of error.
* @param expected the CRS containing the expected datum, or {@code null}.
* @param actual the CRS for which to check the datum, or {@code null}.
* @throws MismatchedDatumException if the two CRS use different datum.
*/
private static void ensureCompatibleDatum(final String param,
final CoordinateReferenceSystem expected,
final CoordinateReferenceSystem actual)
{
if ((expected instanceof SingleCRS) && (actual instanceof SingleCRS)) {
final Datum datum = ((SingleCRS) expected).getDatum();
if (datum != null && !Utilities.equalsIgnoreMetadata(datum, ((SingleCRS) actual).getDatum())) {
throw new MismatchedDatumException(Resources.format(
Resources.Keys.IncompatibleDatum_2, datum.getName(), param));
}
}
}
代码示例来源:origin: org.apache.sis.core/sis-metadata
/**
* Returns the conversion from the given CRS to the CRS of this extent, or {@code null} if none or unknown.
* The returned {@code MathTransform1D} may apply unit conversions or axis direction reversal, but usually
* not datum shift.
*
* @param source the CRS from which to perform the conversions, or {@code null} if unknown.
* @return the conversion from {@code source}, or {@code null} if none or unknown.
* @throws UnsupportedOperationException if the {@code sis-referencing} module is not on the classpath.
* @throws FactoryException if the coordinate operation factory is not available.
* @throws ClassCastException if the conversion is not an instance of {@link MathTransform1D}.
*/
private MathTransform1D getConversionFrom(final VerticalCRS source) throws FactoryException {
if (!Utilities.equalsIgnoreMetadata(verticalCRS, source) && verticalCRS != null && source != null) {
final MathTransform1D cv = (MathTransform1D) ReferencingServices.getInstance()
.getCoordinateOperationFactory(null, null, null, null)
.createOperation(source, verticalCRS).getMathTransform();
if (!cv.isIdentity()) {
return cv;
}
}
return null;
}
代码示例来源:origin: org.apache.sis.core/sis-referencing
/**
* Ensures that the {@code actual} CRS uses a datum which is equals, ignoring metadata,
* to the datum of the {@code expected} CRS.
*
* @param param the parameter name, used only in case of error.
* @param expected the CRS containing the expected datum, or {@code null}.
* @param actual the CRS for which to check the datum, or {@code null}.
* @throws MismatchedDatumException if the two CRS use different datum.
*/
private static void ensureCompatibleDatum(final String param,
final CoordinateReferenceSystem expected,
final CoordinateReferenceSystem actual)
{
if ((expected instanceof SingleCRS) && (actual instanceof SingleCRS)) {
final Datum datum = ((SingleCRS) expected).getDatum();
if (datum != null && !Utilities.equalsIgnoreMetadata(datum, ((SingleCRS) actual).getDatum())) {
throw new MismatchedDatumException(Resources.format(
Resources.Keys.IncompatibleDatum_2, datum.getName(), param));
}
}
}
代码示例来源:origin: apache/sis
/**
* Returns the conversion from the given CRS to the CRS of this extent, or {@code null} if none or unknown.
* The returned {@code MathTransform1D} may apply unit conversions or axis direction reversal, but usually
* not datum shift.
*
* @param source the CRS from which to perform the conversions, or {@code null} if unknown.
* @return the conversion from {@code source}, or {@code null} if none or unknown.
* @throws UnsupportedOperationException if the {@code sis-referencing} module is not on the classpath.
* @throws FactoryException if the coordinate operation factory is not available.
* @throws ClassCastException if the conversion is not an instance of {@link MathTransform1D}.
*/
private MathTransform1D getConversionFrom(final VerticalCRS source) throws FactoryException {
if (!Utilities.equalsIgnoreMetadata(verticalCRS, source) && verticalCRS != null && source != null) {
final MathTransform1D cv = (MathTransform1D) ReferencingServices.getInstance()
.getCoordinateOperationFactory(null, null, null, null)
.createOperation(source, verticalCRS).getMathTransform();
if (!cv.isIdentity()) {
return cv;
}
}
return null;
}
代码示例来源:origin: apache/sis
/**
* Asserts that normalization of the given CRS produces {@link HardCodedCRS#WGS84} (ignoring metadata).
*
* @param message the message to show in case of failure.
* @param createExpected {@code true} if we expect normalization to create a new CRS object.
* @param crs the CRS for which to test normalization.
*/
private static void assertNormalizedEqualsWGS84(final String message, final boolean createExpected,
final CoordinateReferenceSystem crs)
{
final GeographicCRS normalizedCRS = toNormalizedGeographicCRS(crs);
assertTrue(message, Utilities.equalsIgnoreMetadata(HardCodedCRS.WGS84, normalizedCRS));
assertEquals("New CRS instance expected:", createExpected, normalizedCRS != HardCodedCRS.WGS84);
}
代码示例来源:origin: org.apache.sis.core/sis-referencing
/**
* If the given CRS is two-dimensional, append an ellipsoidal height to it.
* It is caller's responsibility to ensure that the given CRS is geographic.
*/
private CoordinateReferenceSystem toGeodetic3D(CoordinateReferenceSystem crs,
final CoordinateReferenceSystem candidate) throws FactoryException
{
assert (crs instanceof GeodeticCRS) && (crs.getCoordinateSystem() instanceof EllipsoidalCS) : crs;
if (crs.getCoordinateSystem().getDimension() != 2) {
return crs;
}
/*
* The check for same class is a cheap way to ensure that the two CRS implement the same GeoAPI interface.
* This test is stricter than necessary, but the result should still not wrong if we miss an opportunity
* to return the existing instance.
*/
if (crs.getClass() == candidate.getClass() && candidate.getCoordinateSystem().getDimension() == 3) {
if (Utilities.equalsIgnoreMetadata(((SingleCRS) crs).getDatum(), ((SingleCRS) candidate).getDatum())) {
return candidate; // Keep the existing instance since it may contain useful metadata.
}
}
return toAuthorityDefinition(CoordinateReferenceSystem.class,
new CompoundCRSBuilder(factory, factorySIS).createCompoundCRS(derivedFrom(crs), crs, CommonCRS.Vertical.ELLIPSOIDAL.crs()));
}
代码示例来源:origin: apache/sis
/**
* If the given CRS is two-dimensional, append an ellipsoidal height to it.
* It is caller's responsibility to ensure that the given CRS is geographic.
*/
private CoordinateReferenceSystem toGeodetic3D(CoordinateReferenceSystem crs,
final CoordinateReferenceSystem candidate) throws FactoryException
{
assert (crs instanceof GeodeticCRS) && (crs.getCoordinateSystem() instanceof EllipsoidalCS) : crs;
if (crs.getCoordinateSystem().getDimension() != 2) {
return crs;
}
/*
* The check for same class is a cheap way to ensure that the two CRS implement the same GeoAPI interface.
* This test is stricter than necessary, but the result should still not wrong if we miss an opportunity
* to return the existing instance.
*/
if (crs.getClass() == candidate.getClass() && candidate.getCoordinateSystem().getDimension() == 3) {
if (Utilities.equalsIgnoreMetadata(((SingleCRS) crs).getDatum(), ((SingleCRS) candidate).getDatum())) {
return candidate; // Keep the existing instance since it may contain useful metadata.
}
}
return toAuthorityDefinition(CoordinateReferenceSystem.class,
new CompoundCRSBuilder(factory, factorySIS).createCompoundCRS(derivedFrom(crs), crs, CommonCRS.Vertical.ELLIPSOIDAL.crs()));
}
代码示例来源:origin: Geomatys/geotoolkit
/**
* Transforms the envelope from its current crs to WGS84 coordinate
* reference system. If the specified envelope is already in WGS84, then it
* is returned unchanged.
*
* @param envelope The envelope to transform.
* @param crs The CRS the envelope is currently in.
* @return The envelope transformed to be in WGS84 CRS.
* @throws TransformException If at least one coordinate can't be
* transformed.
*/
public static Envelope toGeographic(final Envelope envelope, final CoordinateReferenceSystem crs)
throws TransformException {
if (Utilities.equalsIgnoreMetadata(crs, CommonCRS.WGS84.normalizedGeographic())) {
return envelope;
}
final MathTransform transform;
try {
transform = CRS.findOperation(crs, CommonCRS.WGS84.normalizedGeographic(), null).getMathTransform();
} catch (FactoryException exception) {
throw new TransformException(Errors.format(Errors.Keys.CantTransformEnvelope, exception));
}
return transform(envelope, transform);
}
代码示例来源:origin: org.apache.sis.core/sis-referencing
if (targetDatum != null) {
final PrimeMeridian actual = targetDatum.getPrimeMeridian();
if (actual.getGreenwichLongitude() != 0 && !Utilities.equalsIgnoreMetadata(pm, actual)) {
throw new IllegalArgumentException(Resources.format(Resources.Keys.MismatchedPrimeMeridian_2,
IdentifiedObjects.getName(pm, null), IdentifiedObjects.getName(actual, null)));
代码示例来源:origin: apache/sis
if (targetDatum != null) {
final PrimeMeridian actual = targetDatum.getPrimeMeridian();
if (actual.getGreenwichLongitude() != 0 && !Utilities.equalsIgnoreMetadata(pm, actual)) {
throw new IllegalArgumentException(Resources.format(Resources.Keys.MismatchedPrimeMeridian_2,
IdentifiedObjects.getName(pm, null), IdentifiedObjects.getName(actual, null)));
代码示例来源:origin: org.apache.sis.core/sis-referencing
if (crs != null) {
final CoordinateReferenceSystem other = position.getCoordinateReferenceSystem();
if (other != null && !Utilities.equalsIgnoreMetadata(crs, other)) {
throw new MismatchedReferenceSystemException(Errors.format(Errors.Keys.MismatchedCRS));
代码示例来源:origin: org.apache.sis.core/sis-referencing
if (!equalsIgnoreMetadata(sourceDatum, targetDatum)) {
throw new OperationNotFoundException(notFoundMessage(sourceDatum, targetDatum));
代码示例来源:origin: apache/sis
/**
* Encodes the given position into a geohash. The default implementation transforms the given position
* to the coordinate reference system expected by the enclosing {@link GeohashReferenceSystem}, then
* delegates to {@link #encode(double, double)}.
*
* @param position the coordinate to encode.
* @return geohash encoding of the given position.
* @throws TransformException if an error occurred while transforming the given coordinate to a geohash reference.
*/
public String encode(DirectPosition position) throws TransformException {
ArgumentChecks.ensureNonNull("position", position);
final CoordinateReferenceSystem ps = position.getCoordinateReferenceSystem();
if (ps != null && !normalizedCRS.equals(ps, ComparisonMode.IGNORE_METADATA)) {
if (lastOp == null || !Utilities.equalsIgnoreMetadata(lastOp.getSourceCRS(), ps)) try {
lastOp = CRS.findOperation(ps, normalizedCRS, null);
} catch (FactoryException e) {
throw new GazetteerException(e.getLocalizedMessage(), e);
}
position = lastOp.getMathTransform().transform(position, null);
}
return encode(position.getOrdinate(1), position.getOrdinate(0));
}
内容来源于网络,如有侵权,请联系作者删除!