/** * Constructs a new coordinate system axis with the same values than the specified one. This * copy constructor provides a way to wrap an arbitrary implementation into a Geotools one or a * user-defined one (as a subclass), usually in order to leverage some implementation-specific * API. This constructor performs a shallow copy, i.e. the properties are not cloned. * * @param axis The coordinate system axis to copy. * @since 2.2 */ public DefaultCoordinateSystemAxis(final CoordinateSystemAxis axis) { super(axis); abbreviation = axis.getAbbreviation(); direction = axis.getDirection(); unit = axis.getUnit(); minimum = axis.getMinimumValue(); maximum = axis.getMaximumValue(); rangeMeaning = axis.getRangeMeaning(); }
/** * Returns {@code true} if the given axis is of kind "Wrap Around". * Defined here because used together with {@link #wrapAroundChanges wrapAroundChanges(…)}. * * @param axis the axis to test. * @return {@code true} if the given axis has "wrap around" range meaning. */ public static boolean isWrapAround(final CoordinateSystemAxis axis) { return RangeMeaning.WRAPAROUND.equals(axis.getRangeMeaning()); }
/** * Returns {@code true} if the given axis is non-null and has the * {@link RangeMeaning#WRAPAROUND WRAPAROUND} range meaning. * * @param axis the axis to test, or {@code null}. * @return {@code true} if the range meaning is {@code WRAPAROUND}. */ static boolean isWrapAround(final CoordinateSystemAxis axis) { return (axis != null) && RangeMeaning.WRAPAROUND.equals(axis.getRangeMeaning()); }
/** * Returns {@code true} if the given axis is non-null and has the * {@link RangeMeaning#WRAPAROUND WRAPAROUND} range meaning. * * @param axis the axis to test, or {@code null}. * @return {@code true} if the range meaning is {@code WRAPAROUND}. */ static boolean isWrapAround(final CoordinateSystemAxis axis) { return (axis != null) && RangeMeaning.WRAPAROUND.equals(axis.getRangeMeaning()); }
/** * Returns {@code true} if the given axis is of kind "Wrap Around". * Defined here because used together with {@link #wrapAroundChanges wrapAroundChanges(…)}. * * @param axis the axis to test. * @return {@code true} if the given axis has "wrap around" range meaning. */ public static boolean isWrapAround(final CoordinateSystemAxis axis) { return RangeMeaning.WRAPAROUND.equals(axis.getRangeMeaning()); }
final double minimum = axis.getMinimumValue(); final double maximum = axis.getMaximumValue(); final RangeMeaning rm = axis.getRangeMeaning(); if (RangeMeaning.EXACT.equals(rm)) { if (ordinates[i] < minimum) {
/** * Returns a new axis with the same properties than the given axis except the identifiers which are omitted, * and the minimum and maximum values which are set to the given values. */ private static CoordinateSystemAxis forRange(final CoordinateSystemAxis axis, final double min, final double max) { final Map<String,Object> properties = new HashMap<>(8); properties.putAll(IdentifiedObjects.getProperties(axis, EXCLUDES)); properties.put(DefaultCoordinateSystemAxis.MINIMUM_VALUE_KEY, min); properties.put(DefaultCoordinateSystemAxis.MAXIMUM_VALUE_KEY, max); properties.put(DefaultCoordinateSystemAxis.RANGE_MEANING_KEY, axis.getRangeMeaning()); return new DefaultCoordinateSystemAxis(properties, axis.getAbbreviation(), axis.getDirection(), axis.getUnit()); }
/** * Returns a new axis with the same properties than current axis except for the units. * * @param newUnit The unit for the new axis. * @return An axis using the specified unit. * @throws IncommensurableException If the specified unit is incompatible with the expected one. */ static CoordinateSystemAxis usingUnit(final CoordinateSystemAxis a, final Unit<?> newUnit) throws IncommensurableException { final Unit<?> unit = a.getUnit(); if (unit.equals(newUnit)) { return a; } final UnitConverter converter = unit.getConverterToAny(newUnit); final Map<String,Object> properties = new HashMap<>(PredefinedCS.getProperties(a, null)); properties.put(DefaultCoordinateSystemAxis.MINIMUM_VALUE_KEY, converter.convert(a.getMinimumValue())); properties.put(DefaultCoordinateSystemAxis.MAXIMUM_VALUE_KEY, converter.convert(a.getMaximumValue())); properties.put(DefaultCoordinateSystemAxis.RANGE_MEANING_KEY, a.getRangeMeaning()); // TODO: should be provided by getProperties return new DefaultCoordinateSystemAxis(properties, a.getAbbreviation(), a.getDirection(), newUnit); } }
/** * Creates a new coordinate system axis with the same values than the specified one. * This copy constructor provides a way to convert an arbitrary implementation into a SIS one * or a user-defined one (as a subclass), usually in order to leverage some implementation-specific API. * * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p> * * @param axis the coordinate system axis to copy. * * @see #castOrCopy(CoordinateSystemAxis) */ protected DefaultCoordinateSystemAxis(final CoordinateSystemAxis axis) { super(axis); abbreviation = axis.getAbbreviation(); direction = axis.getDirection(); unit = axis.getUnit(); minimumValue = axis.getMinimumValue(); maximumValue = axis.getMaximumValue(); rangeMeaning = axis.getRangeMeaning(); }
/** * Creates a new coordinate system axis with the same values than the specified one. * This copy constructor provides a way to convert an arbitrary implementation into a SIS one * or a user-defined one (as a subclass), usually in order to leverage some implementation-specific API. * * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p> * * @param axis the coordinate system axis to copy. * * @see #castOrCopy(CoordinateSystemAxis) */ protected DefaultCoordinateSystemAxis(final CoordinateSystemAxis axis) { super(axis); abbreviation = axis.getAbbreviation(); direction = axis.getDirection(); unit = axis.getUnit(); minimumValue = axis.getMinimumValue(); maximumValue = axis.getMaximumValue(); rangeMeaning = axis.getRangeMeaning(); }
/** * Creates an axis identical to the given one with an EPSG code added. * This is a helper method for {@link #testIdentifierRemoval()}. */ private static CoordinateSystemAxis addIdentifier(final CoordinateSystemAxis axis, final short epsg) { final Map<String,Object> properties = new HashMap<>(8); properties.putAll(IdentifiedObjects.getProperties(axis)); properties.put(DefaultCoordinateSystemAxis.IDENTIFIERS_KEY, new ImmutableIdentifier(null, "EPSG", String.valueOf(epsg))); properties.put(DefaultCoordinateSystemAxis.MINIMUM_VALUE_KEY, axis.getMinimumValue()); properties.put(DefaultCoordinateSystemAxis.MAXIMUM_VALUE_KEY, axis.getMaximumValue()); properties.put(DefaultCoordinateSystemAxis.RANGE_MEANING_KEY, axis.getRangeMeaning()); return new DefaultCoordinateSystemAxis(properties, axis.getAbbreviation(), axis.getDirection(), axis.getUnit()); }
for (int i=0; i<axes.length; i++) { CoordinateSystemAxis axis = cs.getAxis(i); final RangeMeaning rangeMeaning = axis.getRangeMeaning(); if (RangeMeaning.WRAPAROUND.equals(rangeMeaning)) { double min = axis.getMinimumValue();
properties.put(DefaultCoordinateSystemAxis.RANGE_MEANING_KEY, axis.getRangeMeaning());
for (int i=0; i<axes.length; i++) { CoordinateSystemAxis axis = cs.getAxis(i); if (RangeMeaning.WRAPAROUND.equals(axis.getRangeMeaning())) { double min = axis.getMinimumValue(); if (min < 0) {
final double minimum = axis.getMinimumValue(); final double maximum = axis.getMaximumValue(); final RangeMeaning rm = axis.getRangeMeaning(); if (RangeMeaning.EXACT.equals(rm)) { if (ordinate < minimum) ordinate = minimum;
/** * Asserts that the axis range is either fully missing, or defined to exactly the given properties. */ private static void verifyRange(final CoordinateSystemAxis axis, final double min, final double max, final RangeMeaning expected, final boolean isMandatory) { final double minimumValue = axis.getMinimumValue(); final double maximumValue = axis.getMaximumValue(); final RangeMeaning rangeMeaning = axis.getRangeMeaning(); if (isMandatory || rangeMeaning != null || minimumValue != Double.NEGATIVE_INFINITY || maximumValue != Double.POSITIVE_INFINITY) { assertEquals("axis.minimumValue", min, minimumValue, STRICT); assertEquals("axis.maximumValue", max, maximumValue, STRICT); assertEquals("axis.rangeMeaning", expected, rangeMeaning); } } }
assertEquals("alias", ref.getAlias(), axis.getAlias()); assertEquals("direction", ref.getDirection(), axis.getDirection()); assertEquals("rangeMeaning", ref.getRangeMeaning(), axis.getRangeMeaning()); assertEquals("unit", ref.getUnit().getSystemUnit(), axis.getUnit().getSystemUnit());
for(int i=0,n=cs.getDimension();i<n;i++){ final CoordinateSystemAxis axis = cs.getAxis(i); if(RangeMeaning.WRAPAROUND.equals(axis.getRangeMeaning())){ final DirectPosition start = new GeneralDirectPosition(crs); start.setOrdinate(i, axis.getMinimumValue());
/** * Compares only the properties which are known to be defined in {@link StandardDefinitions}. */ private static void compare(final CoordinateSystemAxis expected, final CoordinateSystemAxis actual) { assertEquals("name", expected.getName().getCode(), actual.getName().getCode()); assertEquals("abbreviation", expected.getAbbreviation(), actual.getAbbreviation()); assertEquals("unit", expected.getUnit(), actual.getUnit()); assertEquals("direction", expected.getDirection(), actual.getDirection()); assertEquals("minimumValue", expected.getMinimumValue(), actual.getMinimumValue(), STRICT); assertEquals("maximumValue", expected.getMaximumValue(), actual.getMaximumValue(), STRICT); assertEquals("rangeMeaning", expected.getRangeMeaning(), actual.getRangeMeaning()); }
/** * Compares the given coordinate system axis against the expected values. * * @param name the expected axis name code. * @param abbreviation the expected axis abbreviation. * @param direction the expected axis direction. * @param minimumValue the expected axis minimal value. * @param maximumValue the expected axis maximal value. * @param unit the expected axis unit of measurement. * @param rangeMeaning the expected axis range meaning. * @param axis the axis to verify. */ public static void assertAxisEquals(final String name, final String abbreviation, final AxisDirection direction, final double minimumValue, final double maximumValue, final Unit<?> unit, final RangeMeaning rangeMeaning, final CoordinateSystemAxis axis) { assertEquals("name", name, axis.getName().getCode()); assertEquals("abbreviation", abbreviation, axis.getAbbreviation()); assertEquals("direction", direction, axis.getDirection()); assertEquals("minimumValue", minimumValue, axis.getMinimumValue(), TestCase.STRICT); assertEquals("maximumValue", maximumValue, axis.getMaximumValue(), TestCase.STRICT); assertEquals("unit", unit, axis.getUnit()); assertEquals("rangeMeaning", rangeMeaning, axis.getRangeMeaning()); }