1 9 package org.jscience.geography.coordinates; 10 11 import org.jscience.geography.coordinates.crs.CompoundCRS; 12 13 20 public class CompoundCoordinates<C1 extends Coordinates, C2 extends Coordinates> 21 extends Coordinates<CompoundCRS<C1, C2>> { 22 23 26 private final C1 _first; 27 28 31 private final C2 _next; 32 33 39 public CompoundCoordinates(C1 first, C2 next) { 40 _first = first; 41 _next = next; 42 } 43 44 49 public C1 getFirst() { 50 return _first; 51 } 52 53 58 public C2 getNext() { 59 return _next; 60 } 61 62 @SuppressWarnings ("unchecked") 63 @Override 64 public CompoundCRS<C1, C2> getCoordinateReferenceSystem() { 65 return new CompoundCRS<C1, C2>(_first.getCoordinateReferenceSystem(), 66 _next.getCoordinateReferenceSystem()); 67 } 68 69 public int getDimension() { 71 return _first.getDimension() + _next.getDimension(); 72 } 73 74 public double getOrdinate(int dimension) throws IndexOutOfBoundsException { 76 final int firstDimension = _first.getDimension(); 77 if (dimension < firstDimension) { 78 return _first.getOrdinate(dimension); 79 } else { 80 return _next.getOrdinate(dimension - firstDimension); 81 } 82 } 83 84 } | Popular Tags |