KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jscience > geography > coordinates > crs > CompoundCRS


1 /*
2  * JScience - Java(TM) Tools and Libraries for the Advancement of Sciences.
3  * Copyright (C) 2006 - JScience (http://jscience.org/)
4  * All rights reserved.
5  *
6  * Permission to use, copy, modify, and distribute this software is
7  * freely granted, provided that this notice is preserved.
8  */

9 package org.jscience.geography.coordinates.crs;
10
11 import java.util.Collection JavaDoc;
12 import java.util.Set JavaDoc;
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 /**
22  * This class represents a coordinate reference system combining two or more
23  * distinct reference systems.
24  *
25  * @author <a HREF="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
26  * @version 3.0, February 13, 2006
27  */

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 JavaDoc {
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 JavaDoc();
50         }
51
52         public Collection JavaDoc getAlias() {
53             return EMPTY_SET;
54         }
55
56         public Set JavaDoc getIdentifiers() {
57             return EMPTY_SET;
58         }
59
60         public InternationalString getRemarks() {
61             throw new UnsupportedOperationException JavaDoc();
62         }
63
64         public String JavaDoc toWKT() throws UnsupportedOperationException JavaDoc {
65             throw new UnsupportedOperationException JavaDoc();
66         }};
67     
68     
69     public CompoundCRS(CoordinateReferenceSystem<C1> first, CoordinateReferenceSystem<C2> next) {
70         _first = first;
71         _next = next;
72     }
73
74     @Override JavaDoc
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 JavaDoc
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 JavaDoc
88     public CoordinateSystem getCoordinateSystem() {
89         return _coordinateSystem;
90     }
91    
92 }
Popular Tags