@Test public void testAxisUsingUnit() { assertNull("Should detect that no axis change is needed", DefaultCartesianCS.PROJECTED.axisUsingUnit(SI.METER)); final Unit<Length> KILOMETER = SI.KILO(SI.METER); final CoordinateSystemAxis[] axis = DefaultCartesianCS.PROJECTED.axisUsingUnit(KILOMETER); assertNotNull(axis); assertEquals("Expected two-dimensional", 2, axis.length); assertEquals(KILOMETER, axis[0].getUnit()); assertEquals(KILOMETER, axis[1].getUnit()); assertEquals(AxisDirection.EAST, axis[0].getDirection()); assertEquals(AxisDirection.NORTH, axis[1].getDirection()); assertEquals("Easting", axis[0].getName().getCode()); assertEquals("Northing", axis[1].getName().getCode()); }
final CoordinateSystemAxis[] axisUsingUnit(final Unit<?> unit) throws IllegalArgumentException { CoordinateSystemAxis[] newAxis = null; for (int i=0; i<axis.length; i++) { CoordinateSystemAxis a = axis[i]; if (!unit.equals(a.getUnit())) { DefaultCoordinateSystemAxis converted; if (a instanceof DefaultCoordinateSystemAxis) { converted = (DefaultCoordinateSystemAxis) a; } else { converted = new DefaultCoordinateSystemAxis(a); a = converted; } converted = converted.usingUnit(unit); if (converted != a) { if (newAxis == null) { newAxis = new CoordinateSystemAxis[axis.length]; System.arraycopy(axis, 0, newAxis, 0, i); } newAxis[i] = converted; } } } return newAxis; }
AbstractCS extends AbstractIdentifiedObject implements CoordinateSystem { final CoordinateSystemAxis[] axisUsingUnit(final Unit<?> unit) throws IllegalArgumentException { CoordinateSystemAxis[] newAxis = null; for (int i=0; i<axis.length; i++) { CoordinateSystemAxis a = axis[i]; if (!unit.equals(a.getUnit())) { DefaultCoordinateSystemAxis converted; if (a instanceof DefaultCoordinateSystemAxis) { converted = (DefaultCoordinateSystemAxis) a; } else { converted = new DefaultCoordinateSystemAxis(a); a = converted; } converted = converted.usingUnit(unit); if (converted != a) { if (newAxis == null) { newAxis = new CoordinateSystemAxis[axis.length]; System.arraycopy(axis, 0, newAxis, 0, i); } newAxis[i] = converted; } } } return newAxis; } }
AbstractCS extends AbstractIdentifiedObject implements CoordinateSystem { final CoordinateSystemAxis[] axisUsingUnit(final Unit<?> unit) throws IllegalArgumentException { CoordinateSystemAxis[] newAxis = null; for (int i=0; i<axis.length; i++) { CoordinateSystemAxis a = axis[i]; if (!unit.equals(a.getUnit())) { DefaultCoordinateSystemAxis converted; if (a instanceof DefaultCoordinateSystemAxis) { converted = (DefaultCoordinateSystemAxis) a; } else { converted = new DefaultCoordinateSystemAxis(a); a = converted; } converted = converted.usingUnit(unit); if (converted != a) { if (newAxis == null) { newAxis = new CoordinateSystemAxis[axis.length]; System.arraycopy(axis, 0, newAxis, 0, i); } newAxis[i] = converted; } } } return newAxis; } AbstractCS(final CoordinateSystem cs);  AbstractCS(final String name, final CoordinateSystemAxis[] axis);  AbstractCS(final Map<String,?> properties, final CoordinateSystemAxis[] axis); }
AbstractCS extends AbstractIdentifiedObject implements CoordinateSystem { final CoordinateSystemAxis[] axisUsingUnit(final Unit<?> unit) throws IllegalArgumentException { CoordinateSystemAxis[] newAxis = null; for (int i=0; i<axis.length; i++) { CoordinateSystemAxis a = axis[i]; if (!unit.equals(a.getUnit())) { DefaultCoordinateSystemAxis converted; if (a instanceof DefaultCoordinateSystemAxis) { converted = (DefaultCoordinateSystemAxis) a; } else { converted = new DefaultCoordinateSystemAxis(a); a = converted; } converted = converted.usingUnit(unit); if (converted != a) { if (newAxis == null) { newAxis = new CoordinateSystemAxis[axis.length]; System.arraycopy(axis, 0, newAxis, 0, i); } newAxis[i] = converted; } } } return newAxis; } AbstractCS(final CoordinateSystem cs);  AbstractCS(final String name, final CoordinateSystemAxis[] axis);  AbstractCS(final Map<String,?> properties, final CoordinateSystemAxis[] axis); int getDimension(); CoordinateSystemAxis getAxis(final int dimension); static Matrix swapAndScaleAxis(final CoordinateSystem sourceCS,
                                          final CoordinateSystem targetCS); static CoordinateSystem standard(final CoordinateSystem cs); Measure distance(final double[] coord1, final double[] coord2); @Override boolean equals(final AbstractIdentifiedObject object, final boolean compareMetadata); @Override int hashCode(); }
AbstractCS extends AbstractIdentifiedObject implements CoordinateSystem { final CoordinateSystemAxis[] axisUsingUnit(final Unit<?> unit) throws IllegalArgumentException { CoordinateSystemAxis[] newAxis = null; for (int i=0; i<axis.length; i++) { CoordinateSystemAxis a = axis[i]; if (!unit.equals(a.getUnit())) { DefaultCoordinateSystemAxis converted; if (a instanceof DefaultCoordinateSystemAxis) { converted = (DefaultCoordinateSystemAxis) a; } else { converted = new DefaultCoordinateSystemAxis(a); a = converted; } converted = converted.usingUnit(unit); if (converted != a) { if (newAxis == null) { newAxis = new CoordinateSystemAxis[axis.length]; System.arraycopy(axis, 0, newAxis, 0, i); } newAxis[i] = converted; } } } return newAxis; } AbstractCS(final CoordinateSystem cs);  AbstractCS(final String name, final CoordinateSystemAxis[] axis);  AbstractCS(final Map<String,?> properties, final CoordinateSystemAxis[] axis); int getDimension(); CoordinateSystemAxis getAxis(final int dimension); static Matrix swapAndScaleAxis(final CoordinateSystem sourceCS,
                                          final CoordinateSystem targetCS); static CoordinateSystem standard(final CoordinateSystem cs); Measure distance(final double[] coord1, final double[] coord2); @Override boolean equals(final AbstractIdentifiedObject object, final boolean compareMetadata); @Override int hashCode();  }