1 9 package org.jscience.geography.coordinates.crs; 10 11 import java.util.Collection ; 12 import java.util.Set ; 13 14 import org.jscience.geography.coordinates.CompoundCoordinates; 15 import org.jscience.geography.coordinates.Coordinates; 16 import org.opengis.metadata.Identifier; 17 import org.opengis.referencing.cs.CoordinateSystem; 18 import org.opengis.referencing.cs.CoordinateSystemAxis; 19 import org.opengis.util.InternationalString; 20 21 28 public class CompoundCRS<C1 extends Coordinates, C2 extends Coordinates> 29 extends CoordinateReferenceSystem<CompoundCoordinates<C1, C2>> { 30 31 final CoordinateReferenceSystem<C1> _first; 32 33 final CoordinateReferenceSystem<C2> _next; 34 35 final CoordinateSystem _coordinateSystem = new CoordinateSystem() { 36 37 public int getDimension() { 38 return _first.getCoordinateSystem().getDimension() + 39 _next.getCoordinateSystem().getDimension(); 40 } 41 42 public CoordinateSystemAxis getAxis(int dimension) throws IndexOutOfBoundsException { 43 int firstDimension = _first.getCoordinateSystem().getDimension(); 44 return (dimension < firstDimension) ? _first.getCoordinateSystem().getAxis(dimension) : 45 _next.getCoordinateSystem().getAxis(dimension - firstDimension); 46 } 47 48 public Identifier getName() { 49 throw new UnsupportedOperationException (); 50 } 51 52 public Collection getAlias() { 53 return EMPTY_SET; 54 } 55 56 public Set getIdentifiers() { 57 return EMPTY_SET; 58 } 59 60 public InternationalString getRemarks() { 61 throw new UnsupportedOperationException (); 62 } 63 64 public String toWKT() throws UnsupportedOperationException { 65 throw new UnsupportedOperationException (); 66 }}; 67 68 69 public CompoundCRS(CoordinateReferenceSystem<C1> first, CoordinateReferenceSystem<C2> next) { 70 _first = first; 71 _next = next; 72 } 73 74 @Override 75 protected CompoundCoordinates<C1, C2> coordinatesOf(AbsolutePosition position) { 76 C1 c1 = _first.coordinatesOf(position); 77 C2 c2 = _next.coordinatesOf(position); 78 return new CompoundCoordinates<C1, C2>(c1, c2); 79 } 80 81 @Override 82 protected AbsolutePosition positionOf(CompoundCoordinates<C1, C2> coordinates, AbsolutePosition position) { 83 AbsolutePosition firstPosition = _first.positionOf(coordinates.getFirst(), position); 84 return _next.positionOf(coordinates.getNext(), firstPosition); 85 } 86 87 @Override 88 public CoordinateSystem getCoordinateSystem() { 89 return _coordinateSystem; 90 } 91 92 } | Popular Tags |