/** * A coordinate position consisting of all the {@linkplain #getMinimum minimal ordinates} for * each dimension for all points within the {@code Envelope}. * * @return The lower corner. */ @Override public DirectPosition getLowerCorner() { final int dim = ordinates.length / 2; final GeneralDirectPosition position = new GeneralDirectPosition(dim); System.arraycopy(ordinates, 0, position.ordinates, 0, dim); position.setCoordinateReferenceSystem(crs); return position; }
/** * Set this coordinate to the specified direct position. This method is identical to {@link * #setLocation(DirectPosition)}, but is slightly faster in the special case of an {@code * GeneralDirectPosition} implementation. * * @param position The new position for this point. * @throws MismatchedDimensionException if this point doesn't have the expected dimension. */ public final void setLocation(final GeneralDirectPosition position) throws MismatchedDimensionException { ensureDimensionMatch("position", position.ordinates.length, ordinates.length); setCoordinateReferenceSystem(position.crs); System.arraycopy(position.ordinates, 0, ordinates, 0, ordinates.length); }
/** * A coordinate position consisting of all the {@linkplain #getMaximum maximal ordinates} for * each dimension for all points within the {@code Envelope}. * * @return The upper corner. */ @Override public DirectPosition getUpperCorner() { final int dim = ordinates.length / 2; final GeneralDirectPosition position = new GeneralDirectPosition(dim); System.arraycopy(ordinates, dim, position.ordinates, 0, dim); position.setCoordinateReferenceSystem(crs); return position; }
/** * Sets the coordinate reference system in which the coordinate is given. The given CRS will be * used as: * * <p> * * <ul> * <li>the {@linkplain CoordinateOperation#getTargetCRS target CRS} for every call to {@link * #transform(DirectPosition)} * <li>the {@linkplain CoordinateOperation#getSourceCRS source CRS} for every call to {@link * #inverseTransform(CoordinateReferenceSystem)} * </ul> * * @param crs The new CRS for this direct position. * @throws MismatchedDimensionException if the specified CRS doesn't have the expected number of * dimensions. */ @Override public void setCoordinateReferenceSystem(final CoordinateReferenceSystem crs) throws MismatchedDimensionException { ensureNonNull("crs", crs); super.setCoordinateReferenceSystem(crs); forward = null; inverse = null; }
/** * A coordinate position consisting of all the {@linkplain #getCenter(int) middle ordinates} for * each dimension for all points within the {@code Envelope}. * * @return The median coordinates. * @since 2.5 */ public DirectPosition getMedian() { final GeneralDirectPosition position = new GeneralDirectPosition(ordinates.length / 2); for (int i = position.ordinates.length; --i >= 0; ) { position.ordinates[i] = getMedian(i); } position.setCoordinateReferenceSystem(crs); return position; }
/** * Set this coordinate to the specified direct position. If the specified position contains a * {@linkplain CoordinateReferenceSystem coordinate reference system}, then the CRS for this * position will be set to the CRS of the specified position. * * @param position The new position for this point. * @throws MismatchedDimensionException if this point doesn't have the expected dimension. * @since 2.2 */ public final void setLocation(final DirectPosition position) throws MismatchedDimensionException { ensureDimensionMatch("position", position.getDimension(), ordinates.length); setCoordinateReferenceSystem(position.getCoordinateReferenceSystem()); for (int i = 0; i < ordinates.length; i++) { ordinates[i] = position.getOrdinate(i); } }
minDP.setCoordinateReferenceSystem(crs); GeneralDirectPosition maxDP = new GeneralDirectPosition(maxCP); maxDP.setCoordinateReferenceSystem(crs);
minDP.setCoordinateReferenceSystem(crs); GeneralDirectPosition maxDP = new GeneralDirectPosition(maxCP); maxDP.setCoordinateReferenceSystem(crs);
pos.setCoordinateReferenceSystem(crs); copy(p1, pos.ordinates); gc.setStartingPosition(pos);
/** * Tests {@link GeneralDirectPosition#equals} method between different implementations. The * purpose of this test is also to run the assertion in the direct position implementations. */ @Test public void testEquals() { assertTrue(GeneralDirectPosition.class.desiredAssertionStatus()); assertTrue(DirectPosition2D.class.desiredAssertionStatus()); CoordinateReferenceSystem WGS84 = DefaultGeographicCRS.WGS84; DirectPosition p1 = new DirectPosition2D(WGS84, 48.543261561072285, -123.47009555832284); GeneralDirectPosition p2 = new GeneralDirectPosition(48.543261561072285, -123.47009555832284); assertFalse(p1.equals(p2)); assertFalse(p2.equals(p1)); p2.setCoordinateReferenceSystem(WGS84); assertTrue(p1.equals(p2)); assertTrue(p2.equals(p1)); } }
pos.setCoordinateReferenceSystem(crs); copy(p1, pos.ordinates); gc.setStartingPosition(pos);