Refine search
/** * Convenience method for checking coordinate reference system validity. * * @throws IllegalArgumentException if the CRS dimension is not valid. */ protected void checkCoordinateReferenceSystemDimension() throws MismatchedDimensionException { if (crs != null) { final int expected = getDimension(); final int dimension = crs.getCoordinateSystem().getDimension(); if (dimension > expected) { // check dimensions and choose ReferencedEnvelope or ReferencedEnvelope3D // or the factory method ReferencedEnvelope.reference( CoordinateReferenceSystem ) throw new MismatchedDimensionException( Errors.format( ErrorKeys.MISMATCHED_DIMENSION_$3, crs.getName().getCode(), Integer.valueOf(dimension), Integer.valueOf(expected))); } } }
/** @see org.geotools.data.coverage.grid.AbstractGridFormat#getReader(Object, Hints) */ @Override public AbstractGridCoverage2DReader getReader(Object source, Hints hints) { try { return new JP2KReader(source, hints); } catch (MismatchedDimensionException e) { if (LOGGER.isLoggable(Level.WARNING)) LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e); return null; } catch (DataSourceException e) { if (LOGGER.isLoggable(Level.WARNING)) LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e); return null; } catch (IOException e) { if (LOGGER.isLoggable(Level.WARNING)) LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e); return null; } }
/** Transforms the specified {@code ptSrc} and stores the result in {@code ptDst}. */ public DirectPosition transform(final DirectPosition ptSrc, DirectPosition ptDst) { if (ptDst == null) { ptDst = new GeneralDirectPosition(2); } else { final int dimension = ptDst.getDimension(); if (dimension != 2) { throw new MismatchedDimensionException( Errors.format(ErrorKeys.MISMATCHED_DIMENSION_$3, "ptDst", dimension, 2)); } } final double[] array = ptSrc.getCoordinate(); transform(array, 0, array, 0, 1); ptDst.setOrdinate(0, array[0]); ptDst.setOrdinate(1, array[1]); return ptDst; }
/** Returns the distance between the specified points. */ private static double distance(final DirectPosition source, final DirectPosition target) { final int otherDim = source.getDimension(); final int dimension = target.getDimension(); if (otherDim != dimension) { throw new MismatchedDimensionException( Errors.format(ErrorKeys.MISMATCHED_DIMENSION_$2, otherDim, dimension)); } double sum = 0; for (int i = 0; i < dimension; i++) { final double delta = source.getOrdinate(i) - target.getOrdinate(i); sum += delta * delta; } return Math.sqrt(sum / dimension); }
/** * Create a point with the provided ordinates * * @param ordinates * @return getPrimitiveFactory().createPoint(coordinates) * @throws MismatchedDimensionException */ public Point createPoint(double[] ordinates) throws MismatchedDimensionException { if (ordinates == null) throw new NullPointerException("Ordinates required to create a point"); int dimension = this.getCoordinateReferenceSystem().getCoordinateSystem().getDimension(); if (ordinates.length != dimension) throw new MismatchedDimensionException( "Create point requires " + dimension + " ordinates (" + ordinates.length + " provided"); return getPrimitiveFactory().createPoint(ordinates); }
final DirectPosition point, final StringBuffer toAppendTo, final FieldPosition position) throws IllegalArgumentException { final int dimension = point.getDimension(); final CoordinateSystem cs; if (crs != null) { if (dimension != formats.length) { throw new MismatchedDimensionException( Errors.format( ErrorKeys.MISMATCHED_DIMENSION_$3, formats.length)); cs = crs.getCoordinateSystem(); } else { cs = null; final double value = point.getOrdinate(i); final int fi = Math.min(i, formats.length - 1); final Object object;
final CoordinateReferenceSystem sourceCRS = point.getCoordinateReferenceSystem(); if (sourceCRS != null) { synchronized (this) { if (point.getDimension() < 2) { throw new MismatchedDimensionException( Errors.format(ErrorKeys.MISMATCHED_DIMENSION_$2, point.getDimension(), 2));
/** * Convenience method for checking coordinate reference system validity. * * @throws IllegalArgumentException if the CRS dimension is not valid. */ private void checkCoordinateReferenceSystemDimension() throws MismatchedDimensionException { if (crs != null) { final int expected = getDimension(); final int dimension = crs.getCoordinateSystem().getDimension(); if (dimension != expected) { throw new MismatchedDimensionException(Errors.format( ErrorKeys.MISMATCHED_DIMENSION_$3, crs.getName().getCode(), new Integer(dimension), new Integer(expected))); } } }
for (int i = 0; i < points.length; i++) { final DirectPosition point = points[i]; final int pointDim = point.getDimension(); if (pointDim != dimension) { throw new MismatchedDimensionException( Errors.format( ErrorKeys.MISMATCHED_DIMENSION_$3, final CoordinateSystem cs = crs.getCoordinateSystem(); if (!getCoordinateSystemType().isAssignableFrom(cs.getClass())) { throw new MismatchedReferenceSystemException(
/** Ensure the specified point is one-dimensional. */ static void checkDimension(final DirectPosition point) { final int dim = point.getDimension(); if (dim != 1) { throw new MismatchedDimensionException( Errors.format( ErrorKeys.MISMATCHED_DIMENSION_$2, Integer.valueOf(1), Integer.valueOf(dim))); } } /**
final CoordinateSystem cs = crs.getCoordinateSystem(); final int dimension = cs.getDimension(); if (dimension != 3) { throw new MismatchedDimensionException(Errors.format(ErrorKeys.MISMATCHED_DIMENSION_$2, new Integer(3), new Integer(dimension))); if (temporalCRS == null) { throw new IllegalArgumentException( Errors.format(ErrorKeys.ILLEGAL_COORDINATE_REFERENCE_SYSTEM));
newResolution = new double[targetCrs.getCoordinateSystem().getDimension()]; Arrays.fill(newResolution, 1); } else { if (targetCrs.getCoordinateSystem().getDimension() != newResolution.length) throw new MismatchedDimensionException("Destination resolution array length should be equals than target CRS dimension number." + "Destination resolution array length = "+newResolution.length+", CRS dimension number = "+targetCrs.getCoordinateSystem().getDimension()); center.setOrdinate(0, srcEnvelope.getMedian(srcMinOrdi)); center.setOrdinate(1, srcEnvelope.getMedian(srcMinOrdi+1));
/** * Ensure the specified point is one-dimensional. */ private static void checkDimension(final DirectPosition point) { final int dim = point.getDimension(); if (dim != 1) { throw new MismatchedDimensionException(Errors.format( ErrorKeys.MISMATCHED_DIMENSION_$2, 1, dim)); } }
throw new IllegalArgumentException(Errors.format( ErrorKeys.MISMATCHED_ENVELOPE_CRS_$2, crs.getName().getCode(), implicitCRS.getName().getCode())); crs2D = CRSUtilities.getCRS2D(crs); } catch (TransformException exception) { throw new MismatchedDimensionException(exception.getLocalizedMessage());
Errors.format( ErrorKeys.MISMATCHED_ENVELOPE_CRS_$2, crs.getName().getCode(), implicitCRS.getName().getCode())); throw new MismatchedDimensionException( Errors.format(ErrorKeys.CANT_SEPARATE_CRS_$1, crs));
/** Makes sure the specified dimensions are identical. */ private static void ensureSameDimension(final int dim1, final int dim2) throws MismatchedDimensionException { if (dim1 != dim2) { throw new MismatchedDimensionException( Errors.format(ErrorKeys.MISMATCHED_DIMENSION_$2, dim1, dim2)); } }
/** * 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); }
parameterBlock.addSource(inputImage); parameterBlock.setParameter("xOrigin", (float) gridPos.getOrdinate(0) + 0.5f); parameterBlock.setParameter("yOrigin", (float) gridPos.getOrdinate(1) + 0.5f); LOGGER.log(Level.WARNING, e.getMessage(), e); } catch (TransformException e) { LOGGER.log(Level.WARNING, e.getMessage(), e);
public PointImpl createPoint(Position position) throws MismatchedReferenceSystemException, MismatchedDimensionException { // Test ok if (position == null) { throw new IllegalArgumentException("Parameter position is null."); } if (position.getPosition().getDimension() != this.getDimension()) { throw new MismatchedDimensionException(); } DirectPosition copy = positionFactory.createDirectPosition(position.getPosition().getCoordinates()); return new PointImpl(copy); }
throw new MismatchedDimensionException(Errors.format(ErrorKeys.BAD_TRANSFORM_$1, Utilities.getShortClassName(transform)));