/** * Reduces the specified CRS to a two-dimensional one. If the given CRS has more than two * dimensions, then a new one is created using only the axis at ({@link #axisDimensionX}, {@link * #axisDimensionY}) index. * * @param crs The coordinate reference system to reduce, or {@code null}. * @return A coordinate reference system with no more than 2 dimensions, or {@code null} if * {@code crs} was null. * @throws FactoryException if the given CRS can't be reduced to two dimensions. * @since 2.5 */ public CoordinateReferenceSystem reduce(final CoordinateReferenceSystem crs) throws FactoryException { // Reminder: is is garanteed that axisDimensionX < axisDimensionY if (crs == null || crs.getCoordinateSystem().getDimension() <= 2) { return crs; } if (FACTORIES == null) { FACTORIES = ReferencingFactoryContainer.instance(null); // No need to synchronize: this is not a big deal if // two ReferencingFactoryContainer instances are created. } final CoordinateReferenceSystem reducedCRS; reducedCRS = FACTORIES.separate(crs, new int[] {axisDimensionX, axisDimensionY}); assert reducedCRS.getCoordinateSystem().getDimension() == 2 : reducedCRS; return reducedCRS; }
sub[j] = dimensions[j + lowerIndex] - lowerDimension; targets[count++] = separate(source, sub);
/** * Reduces the specified CRS to a two-dimensional one. If the given CRS has more than two * dimensions, then a new one is created using only the axis at ({@link #axisDimensionX}, * {@link #axisDimensionY}) index. * * @param crs The coordinate reference system to reduce, or {@code null}. * @return A coordinate reference system with no more than 2 dimensions, * or {@code null} if {@code crs} was null. * @throws FactoryException if the given CRS can't be reduced to two dimensions. * * @since 2.5 */ public CoordinateReferenceSystem reduce(final CoordinateReferenceSystem crs) throws FactoryException { // Reminder: is is garanteed that axisDimensionX < axisDimensionY if (crs == null || crs.getCoordinateSystem().getDimension() <= 2) { return crs; } if (FACTORIES == null) { FACTORIES = ReferencingFactoryContainer.instance(null); // No need to synchronize: this is not a big deal if // two ReferencingFactoryContainer instances are created. } final CoordinateReferenceSystem reducedCRS; reducedCRS = FACTORIES.separate(crs, new int[] {axisDimensionX, axisDimensionY}); assert reducedCRS.getCoordinateSystem().getDimension() == 2 : reducedCRS; return reducedCRS; }