/** * Returns the CRS of the specified point. If the CRS of the previous point is known, it can be * specified. This method will then ensure that the two CRS are compatibles. */ private static CoordinateReferenceSystem getCoordinateReferenceSystem( final DirectPosition point, CoordinateReferenceSystem previousCRS) throws MismatchedReferenceSystemException { final CoordinateReferenceSystem candidate = point.getCoordinateReferenceSystem(); if (candidate != null) { if (previousCRS == null) { return candidate; } /* * We use strict 'equals' instead of 'equalsIgnoreCase' because if the metadata * are not identical, we have no easy way to choose which CRS is the "main" one. */ if (!previousCRS.equals(candidate)) { throw new MismatchedReferenceSystemException( Errors.format(ErrorKeys.MISMATCHED_COORDINATE_REFERENCE_SYSTEM)); } } return previousCRS; }
private void ensureCompatibleReferenceSystem(DirectPosition location) { if (crs != null) { final CoordinateReferenceSystem other = location.getCoordinateReferenceSystem(); if (other != null) { if (!CRS.equalsIgnoreMetadata(crs, other)) { throw new MismatchedReferenceSystemException( Errors.format(ErrorKeys.MISMATCHED_COORDINATE_REFERENCE_SYSTEM)); } } } }
/** * Returns the common CRS of specified points. * * @param minDP The first position. * @param maxDP The second position. * @return Their common CRS, or {@code null} if none. * @throws MismatchedReferenceSystemException if the two positions don't use the same CRS. */ static CoordinateReferenceSystem getCoordinateReferenceSystem( final DirectPosition minDP, final DirectPosition maxDP) throws MismatchedReferenceSystemException { final CoordinateReferenceSystem crs1 = minDP.getCoordinateReferenceSystem(); final CoordinateReferenceSystem crs2 = maxDP.getCoordinateReferenceSystem(); if (crs1 == null) { return crs2; } else { if (crs2 != null && !crs1.equals(crs2)) { throw new MismatchedReferenceSystemException( Errors.format(ErrorKeys.MISMATCHED_COORDINATE_REFERENCE_SYSTEM)); } return crs1; } }
/** * 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 incompatible. */ protected void ensureCompatibleReferenceSystem(final BoundingBox bbox) throws MismatchedReferenceSystemException { if (crs != null) { final CoordinateReferenceSystem other = bbox.getCoordinateReferenceSystem(); if (other != null) { if (!CRS.equalsIgnoreMetadata(crs, other)) { throw new MismatchedReferenceSystemException( Errors.format(ErrorKeys.MISMATCHED_COORDINATE_REFERENCE_SYSTEM)); } } } } /**
/** * 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 (!CRS.equalsIgnoreMetadata(crs, other)) { throw new MismatchedReferenceSystemException( Errors.format(ErrorKeys.MISMATCHED_COORDINATE_REFERENCE_SYSTEM)); } } } }
/** * Make sure that the specified location uses the same CRS as this one. * * @param location * @throws MismatchedReferenceSystemException if the CRS are incompatible. */ protected void ensureCompatibleReferenceSystem(DirectPosition location) { if (crs != null) { final CoordinateReferenceSystem other = location.getCoordinateReferenceSystem(); if (other != null) { if (!CRS.equalsIgnoreMetadata(crs, other)) { throw new MismatchedReferenceSystemException( Errors.format(ErrorKeys.MISMATCHED_COORDINATE_REFERENCE_SYSTEM)); } } } } /** Returns the coordinate reference system associated with this envelope. */
final CoordinateSystem cs = crs.getCoordinateSystem(); if (!getCoordinateSystemType().isAssignableFrom(cs.getClass())) { throw new MismatchedReferenceSystemException( Errors.format(ErrorKeys.UNSUPPORTED_COORDINATE_SYSTEM_$1, cs.getName()));
|| CRS.equalsIgnoreMetadata(crs, ddpp[2].getCoordinateReferenceSystem()) || CRS.equalsIgnoreMetadata(crs, ddpp[3].getCoordinateReferenceSystem()))) { throw new MismatchedReferenceSystemException( "Region of interest defined by mismatched DirectPositions.");
/** * 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 (!CRS.equalsIgnoreMetadata(crs, other)) { throw new MismatchedReferenceSystemException(Errors.format( ErrorKeys.MISMATCHED_COORDINATE_REFERENCE_SYSTEM)); } } } }
/** * 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)); } } } }
/** * Constructs an envelope defined by two direct positions. * The CRS of the envelope will be the CRS of the given direct positions, which shall be the equal. * * @param lowerCorner the limits in the direction of decreasing ordinate values for each dimension. * @param upperCorner the limits in the direction of increasing ordinate values for each dimension. * @throws MismatchedReferenceSystemException if the CRS of the two position are not equal. * @throws MismatchedDimensionException if the two positions do not have the same dimension. * @throws IllegalArgumentException if an ordinate value in the lower corner is greater than * the corresponding ordinate value in the upper corner. */ public SimpleEnvelope(final DirectPosition lowerCorner, final DirectPosition upperCorner) throws MismatchedDimensionException, MismatchedReferenceSystemException { crs = lowerCorner.getCoordinateReferenceSystem(); // May be null. if (!Objects.equals(crs, upperCorner.getCoordinateReferenceSystem())) { throw new MismatchedReferenceSystemException(); } final int dimension = lowerCorner.getDimension(); if (dimension != upperCorner.getDimension()) { throw new MismatchedDimensionException(); } ordinates = new double[dimension * 2]; setCorners(ordinates, lowerCorner, upperCorner); }
.getCoordinateReferenceSystem(); if (!CRS.equalsIgnoreMetadata(thisCRS,exteriorCRS)) { throw new MismatchedReferenceSystemException(); throw new MismatchedReferenceSystemException();
final CoordinateReferenceSystem crs = envelope.getCoordinateReferenceSystem(); if (crs != null && !equalsIgnoreMetadata(crs, sourceCRS)) { throw new MismatchedReferenceSystemException( Errors.format(ErrorKeys.MISMATCHED_COORDINATE_REFERENCE_SYSTEM));