Refine search
/** * Constructs a position using the specified coordinate reference system. The number of * dimensions is inferred from the coordinate reference system. * * @param crs The coordinate reference system to be given to this position. * @since 2.2 */ public GeneralDirectPosition(final CoordinateReferenceSystem crs) { this(crs.getCoordinateSystem().getDimension()); this.crs = crs; }
/** * Returns the dimension of the specified coordinate system, or {@code 0} if the coordinate * system is null. */ static int getDimension(final CoordinateReferenceSystem crs) { return (crs != null) ? crs.getCoordinateSystem().getDimension() : 0; }
/** * Returns the dimension of this coverage. This is a shortcut for <code> * {@linkplain #crs}.getCoordinateSystem().getDimension()</code>. * * @return The dimension of this coverage. */ public final int getDimension() { return crs.getCoordinateSystem().getDimension(); }
/** * Constructs an empty envelope with the specified coordinate reference system. All ordinates * are initialized to 0. * * @param crs The coordinate reference system. * @since 2.2 */ public GeneralEnvelope(final CoordinateReferenceSystem crs) { // Uncomment next line if Sun fixes RFE #4093999 // ensureNonNull("envelope", envelope); this(crs.getCoordinateSystem().getDimension()); this.crs = crs; }
public int getDimension() { return crs.getCoordinateSystem().getDimension(); }
writer.write("<low>" + lower + "</low>\n"); writer.write("<high>" + upper + "</high>\n"); final CoordinateSystem cs = crs.getCoordinateSystem(); for (int i = 0; i < cs.getDimension(); i++) { writer.write("<axisName>" + cs.getAxis(i).getName().getCode() + "</axisName>\n");
/** Ensure that the dimension of the specified CRS is not greater than the specified value. */ private static void ensureValidDimension(final CoordinateReferenceSystem crs, final int dim) { if (crs.getCoordinateSystem().getDimension() > dim) { throw new IllegalArgumentException(); // TODO: provides a localized message. } }
/** * Determine the number of dimensions based on the CRS metadata. * * @return Number of dimensions expected based on metadata, default of 2 */ int getD() { CoordinateReferenceSystem crs = (CoordinateReferenceSystem) parameter.metadata.get(Parameter.CRS); if (crs == null) { return 2; } else { return crs.getCoordinateSystem().getDimension(); } }
/** * Returns a source CRS compatible with the given target CRS. This method try to returns a CRS * which would not thrown an {@link NoninvertibleTransformException} if attempting to transform * from "target" to "source" (reminder: Warp works on <strong>inverse</strong> transforms). * * @param sourceCRS2D The two-dimensional source CRS. Actually, this method accepts arbitrary * dimension provided that are not greater than {@code sourceCRS}, but in theory it is 2D. * @param sourceCRS The n-dimensional source CRS. * @param targetCRS The n-dimensional target CRS. */ private static CoordinateReferenceSystem compatibleSourceCRS( final CoordinateReferenceSystem sourceCRS2D, final CoordinateReferenceSystem sourceCRS, final CoordinateReferenceSystem targetCRS) { final int dim2D = sourceCRS2D.getCoordinateSystem().getDimension(); return (targetCRS.getCoordinateSystem().getDimension() == dim2D && sourceCRS.getCoordinateSystem().getDimension() > dim2D) ? sourceCRS2D : sourceCRS; }
/** * Determine the number of dimensions based on the CRS metadata. * * @return Number of dimensions expected based on metadata, default of 2 */ int getD() { try { CoordinateReferenceSystem crs = (CoordinateReferenceSystem) parameter.metadata.get(Parameter.CRS); if (crs == null) { return 2; } else { return crs.getCoordinateSystem().getDimension(); } } catch (Throwable t) { return 2; } }
/** Returns {@code true} if the specified {@code crs} starts with the specified {@code head}. */ private static final boolean startsWith( final CoordinateReferenceSystem crs, final CoordinateReferenceSystem head) { final int dimension = head.getCoordinateSystem().getDimension(); return crs.getCoordinateSystem().getDimension() >= dimension && CRS.equalsIgnoreMetadata(CRSUtilities.getSubCRS(crs, 0, dimension), head); }
/** * Returns the coordinate reference system in which the coordinates are given. * * @return The coordinate reference system, or {@code null}. */ public final CoordinateReferenceSystem getCoordinateReferenceSystem() { assert crs == null || crs.getCoordinateSystem().getDimension() == getDimension(); return crs; }
/** * Factory method to create the correct ReferencedEnvelope implementation for the provided * CoordinateReferenceSystem. * * @param crs CoordinateReferenceSystem used to select ReferencedEnvelope implementation * @return ReferencedEnvelope, ReferencedEnvelope3D if it is 3d */ public static ReferencedEnvelope create(CoordinateReferenceSystem crs) { if (crs != null && crs.getCoordinateSystem().getDimension() > 2) { return new ReferencedEnvelope3D(crs); } return new ReferencedEnvelope(crs); }
/** * Checks if a reference coordinate system has the expected number of dimensions. * * @param name The argument name. * @param crs The coordinate reference system to check. * @param expected The expected number of dimensions. */ private static void checkDimension( final String name, final CoordinateReferenceSystem crs, final int expected) { final int actual = crs.getCoordinateSystem().getDimension(); if (actual != expected) { throw new IllegalArgumentException( Errors.format(ErrorKeys.MISMATCHED_DIMENSION_$3, name, actual, expected)); } }
private int indexOf(CoordinateReferenceSystem crs, Set<AxisDirection> direction) { CoordinateSystem cs = crs.getCoordinateSystem(); for (int index = 0; index < cs.getDimension(); index++) { CoordinateSystemAxis axis = cs.getAxis(index); if (direction.contains(axis.getDirection())) return index; } return -1; } }
public PointArray createPointArray(double[] array) { return getPositionFactory() .createPointArray( array, 0, array.length / crs.getCoordinateSystem().getDimension()); }
MockDirectPosition() { this(new double[crs.getCoordinateSystem().getDimension()]); }
public int getCoordinateDimension() { return crs.getCoordinateSystem().getDimension(); }
public int getDimension() { return crs.getCoordinateSystem().getDimension(); }
public int getDimension() { return crs.getCoordinateSystem().getDimension(); }