/** * Returns the position of the specified {@link CoordinateSystemAxis} in this <code>CoordinateSystem</code>, * or -1 if it is not an axis of this instance. * * @param axis * @return */ public int getAxisIndex(CoordinateSystemAxis axis) { int i = 0; for (CoordinateSystemAxis a : axes) { if (a.equals(axis)) return i; i++; } return -1; }
/** * Returns a list of all the directions of this systems * * @return a List of Coordinate system axis directions. */ public List<CoordinateSystemAxisDirection> getAxisDirections(){ List<CoordinateSystemAxisDirection> directions = new ArrayList<CoordinateSystemAxisDirection>(axes.length); for (CoordinateSystemAxis a: axes){ directions.add(a.getAxisDirection()); } return directions; }
/** * Returns the normal order value for the axes of this systems in the order that the axes have been defined for this * system. * * @return a List of Coordinate system axis directions. */ public List<Integer> getAxisNormalOrder(){ List<Integer> order = new ArrayList<Integer>(axes.length); for (CoordinateSystemAxis a: axes){ order.add(a.getNormalOrder()); } return order; }
/** * Returns the <code>Unit</code> of the axis at the specified position. * * @param index * @return */ public Unit getAxisUnit(int index) { return this.axes[index].getUnit(); }
/** * Returns the <code>Unit</code> for this <code>CoordinateReferenceSystem</code>. * * @return the <code>Unit</code> */ public Unit getUnit() { return getAxis(0).getUnit(); }
public double getCoordinate(CoordinateSystemAxis axis) { return getCoordinate(axis.getNormalOrder()); }
/** * Return the axis that corresponds to the i-th element in the coordinates for a {@code Position} * in this {@code CoordinateSystem}. * * @param i the 0-base index for a coordinate * @return the axis * @throws java.lang.IndexOutOfBoundsException if i > getCoordinateDimension() - 1 */ public CoordinateSystemAxis getAxisForComponentIndex(int i) { List<Integer> order = getAxisNormalOrder(); int oIdx = order.get(i); for (CoordinateSystemAxis a : axes) { if(a.getAxisDirection().defaultNormalOrder == oIdx) return a; } throw new IllegalStateException(); //if we get this, there is a programming error }
public static <P extends Position> boolean hasAxisOrder(CoordinateReferenceSystem<P> crs, int order) { CoordinateSystemAxis[] axes = crs.getCoordinateSystem().getAxes(); for (CoordinateSystemAxis axis : axes) { if (axis.getNormalOrder() == order) { return true; } } return false; }
/** * Gets the coordinate value for the specified axis * * * @param axis the CoordinateSystemAxis for which to get the coordinate * @return the coordinate value for the specified axis * @throws IllegalArgumentException if the specified axis is not present in the {@code CoordinateReferenceSystem} * of this instance * * @Deprecated Use {@code getCoordinate(CoordinateSystemAxis axis)} * */ @Deprecated public double getCoordinate(CoordinateSystemAxis axis, CoordinateReferenceSystem<?> crs) { int idx = crs.getAxisIndex(axis); if (idx == -1) throw new IllegalArgumentException("Not an axis of this coordinate reference system."); return getCoordinate(axis.getNormalOrder()); }