1 9 package org.jscience.geography.coordinates.crs; 10 11 import java.util.Collection ; 12 import java.util.Set ; 13 14 import javax.measure.quantities.Angle; 15 import javax.measure.quantities.Duration; 16 import javax.measure.quantities.Length; 17 import javax.measure.quantities.Quantity; 18 import javax.measure.units.Unit; 19 20 import javolution.util.FastSet; 21 22 import org.jscience.geography.coordinates.Coordinates; 23 import org.opengis.metadata.Identifier; 24 import org.opengis.metadata.citation.Citation; 25 import org.opengis.metadata.extent.Extent; 26 import org.opengis.referencing.cs.AxisDirection; 27 import org.opengis.referencing.cs.CoordinateSystem; 28 import org.opengis.util.InternationalString; 29 import org.opengis.referencing.cs.CoordinateSystemAxis; 30 31 38 public abstract class CoordinateReferenceSystem<C extends Coordinates> 39 implements org.opengis.referencing.crs.CoordinateReferenceSystem { 40 41 42 45 protected static class AbsolutePosition { 46 47 50 public Quantity<Angle> latitudeWGS84; 51 52 55 public Quantity<Angle> longitudeWGS84; 56 57 60 public Quantity<Length> heightWGS84; 61 62 65 public Quantity<Duration> timeUTC; 66 } 67 68 77 public <T extends Coordinates> CoordinatesConverter<C, T> getConverterTo( 78 CoordinateReferenceSystem<T> that) { 79 return new GeneralConverter<T>(that); 80 } 81 82 private class GeneralConverter<T extends Coordinates> implements 84 CoordinatesConverter<C, T> { 85 private final CoordinateReferenceSystem<T> _toCRS; 86 87 private GeneralConverter(CoordinateReferenceSystem<T> toCRS) { 88 _toCRS = toCRS; 89 } 90 91 public T convert(C source) { 92 AbsolutePosition position = positionOf(source, 93 new AbsolutePosition()); 94 return _toCRS.coordinatesOf(position); 95 } 96 } 97 98 107 protected abstract C coordinatesOf(AbsolutePosition position); 108 109 121 protected abstract AbsolutePosition positionOf(C coordinates, 122 AbsolutePosition position); 123 124 130 public abstract CoordinateSystem getCoordinateSystem(); 131 132 136 142 public Extent getValidArea() { 143 return null; 144 } 145 146 150 public InternationalString getScope() { 151 throw new UnsupportedOperationException (); 152 } 153 154 159 public Identifier getName() { 160 return new Name(CoordinateReferenceSystem.this.getClass().getName()); 161 } 162 163 168 public Collection getAlias() { 169 return EMPTY_SET; 170 } 171 172 178 public Set getIdentifiers() { 179 return EMPTY_SET; 180 } 181 182 188 public InternationalString getRemarks() { 189 return null; 190 } 191 192 202 public String toWKT() throws UnsupportedOperationException { 203 throw new UnsupportedOperationException (); 204 } 205 206 static class Axis implements CoordinateSystemAxis { 208 209 private final Name _name; 210 211 private final String _abbreviation; 212 213 private final Unit _unit; 214 215 private final AxisDirection _direction; 216 217 public Axis(final String name, String abbreviation, Unit unit, 218 AxisDirection direction) { 219 _name = new Name(name); 220 _abbreviation = abbreviation; 221 _unit = unit; 222 _direction = direction; 223 } 224 225 public final Identifier getName() { 226 return _name; 227 } 228 229 public final String getAbbreviation() { 230 return _abbreviation; 231 } 232 233 public final Unit getUnit() { 234 return _unit; 235 } 236 237 public final AxisDirection getDirection() { 238 return _direction; 239 } 240 241 public Collection getAlias() { 242 return EMPTY_SET; 243 } 244 245 public Set getIdentifiers() { 246 return EMPTY_SET; 247 } 248 249 public InternationalString getRemarks() { 250 throw new UnsupportedOperationException (); 251 } 252 253 public String toWKT() throws UnsupportedOperationException { 254 throw new UnsupportedOperationException (); 255 } 256 257 } 258 259 static class Name implements Identifier { 261 final String _value; 262 263 public Name(String value) { 264 _value = value; 265 } 266 267 public String getCode() { 268 return _value; 269 } 270 271 public Citation getAuthority() { 272 throw new UnsupportedOperationException (); 273 } 274 275 public String getVersion() { 276 throw new UnsupportedOperationException (); 277 } 278 } 279 280 static final FastSet<?> EMPTY_SET = new FastSet<Object >(); 281 } | Popular Tags |