// (C)2007 Attila Kovacs <attila@submm.caltech.edu>


public class AIPSLegacyProjection extends SphericalProjection {
	SphericalProjection baseProjection;
	String name;
	String fitsID;
	Vector2D referenceOffsets;
	
	
	public AIPSLegacyProjection(SphericalProjection baseProjection, String name, String fitsID) {
		this.baseProjection = baseProjection;
		this.name = name;
		this.fitsID = fitsID;
	}
	
	@Override
	public String getFitsID() {
		return fitsID;
	}

	@Override
	public String getFullName() {
		return name;
	}
	
	@Override
	public void setReference(SphericalCoordinates celestialCoords, SphericalCoordinates nativeCoords) throws IllegalArgumentException {
		baseProjection.project(celestialCoords, referenceOffsets);
		super.setReference(celestialCoords, nativeCoords);
	}
		
	public final void project(SphericalCoordinates coords, CoordinatePair toProjected) {
		baseProjection.project(coords, toProjected);
		toProjected.x -= referenceOffsets.x;
		toProjected.y -= referenceOffsets.y;
	}
	
	public final void deproject(CoordinatePair projected, SphericalCoordinates toCoords) {
		projected.x += referenceOffsets.x;
		projected.y += referenceOffsets.y;
		baseProjection.deproject(projected, toCoords);		
	}
	
	
	@Override
	public final void getOffsets(double theta, double phi, CoordinatePair toOffset) {
		baseProjection.getOffsets(theta, phi, toOffset);
	}

	@Override
	public final double phi(CoordinatePair offset) {
		return baseProjection.phi(offset);
	}

	@Override
	public double theta(CoordinatePair offset) {
		return baseProjection.theta(offset);
	}

}
