/** @class FindRefAltLatLon.cpp @author Brian Magill @creation date 6/4/2007 $Date:$ $Revision:$ @copyright (©) Copyright 2006 by GATS Inc. 11864 Canon Blvd., Suite 101, Newport News, VA 23606 All Rights Reserved. No part of this software or publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise without the prior written permission of GATS Inc. @brief Finds the latitude and longitude at the 83 km tangent altitude */ #include "FindRefAltLatLon.h" #include using namespace std; pair FindRefAltLatLon::operator() (valarray const &tanAlt, valarray const &tanLat, valarray const &tanLon) const { pair result; unsigned long i; bool sunSet = false; if (tanAlt.size() == 0) throw runtime_error("FindRefAltLatLon::Error, altitude array must contain data!"); if (tanAlt.size() != tanLat.size() ) throw runtime_error("FindRefAltLatLon::Error, altitude and latitude array sizes differ"); if (tanAlt.size() != tanLon.size() ) throw runtime_error("FindRefAltLatLon::Error, altitude and longitude array sizes differ"); if (tanAlt.max() < altRef ) throw runtime_error("FindRefAltLatLon::Error, minimum tangent altitude is greater than reference altitude"); if (altRef < tanAlt.min()) throw runtime_error("FindRefAltLatLon::Error, maximum tangent altitude is less than than reference altitude"); if (tanAlt[0] > tanAlt.min()) sunSet = true; if (sunSet) for(i = 0; i < tanAlt.size(); i++) { if (tanAlt[i] <= altRef) { result = pair(tanLat[i], tanLon[i]); break; } } else for(i = 0; i < tanAlt.size(); i++) { if (tanAlt[i] >= altRef) { result = pair(tanLat[i], tanLon[i]); break; } } return result; };