WSL/SLF GitLab Repository

Commit b40dedb4 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

The class Stationdata now properly uses the new Coords class. All usual...

The class Stationdata now properly uses the new Coords class. All usual dependencies have been fixed (A3DIO.cc) but not (yet) the optional plugins. The Coords class has been modified so that it computes the matching coordinates as soon as possible instead of the previous implementation that was delaying it as much as possible (thus making "const Coords..." impossible).

The includes have been cleaned up (compilation was failing because of multiple "using namespace" in header files) and all "using namespace" have been removed from header files (please don't put any of these back!!). The doxygen comments has been updated.
parent d393958b
......@@ -141,9 +141,9 @@ void A3DIO::readMeteoData(const Date_IO& dateStart, const Date_IO& dateEnd,
//note: they have to be entirely corresponding (for every date)
try {
read2DMeteo(vecMeteo, vecStation);
} catch(exception& e){
cerr << "[E] No meteo2d data found or error while reading it, using only Meteo1D data: "
<< endl << "\t" << e.what() << endl;
} catch(std::exception& e){
std::cerr << "[E] No meteo2d data found or error while reading it, using only Meteo1D data: "
<< std::endl << "\t" << e.what() << std::endl;
}
}
......@@ -189,7 +189,7 @@ void A3DIO::read1DMeteo(const Date_IO& dateStart, const Date_IO& dateEnd,
}
fin.clear();
fin.open (tmp.c_str(), ifstream::in);
fin.open (tmp.c_str(), std::ifstream::in);
if (fin.fail()) {
throw FileAccessException(tmp,AT);
}
......@@ -212,22 +212,22 @@ void A3DIO::read1DMeteo(const Date_IO& dateStart, const Date_IO& dateEnd,
cfg.getValue("COORDPARAM", coordparam, ConfigReader::nothrow);
} catch(std::exception& e) {
//problems while reading values for COORDIN or COORDPARAM
cerr << "[E] reading configuration file: " << "\t" << e.what() << endl;
std::cerr << "[E] reading configuration file: " << "\t" << e.what() << std::endl;
throw;
}
//compute/check WGS coordinates (considered as the true reference)
Coords coordinate(coordsys, coordparam);
coordinate.setXY(xcoord, ycoord);
coordinate.setLatLon(latitude, longitude);
Coords location(coordsys, coordparam);
location.setXY(xcoord, ycoord);
location.setLatLon(latitude, longitude);
try {
coordinate.check();
location.check();
} catch(...) {
std::cerr << "[E] Error in geographic coordinates in file " << tmp << "trapped at " << AT << endl;
std::cerr << "[E] Error in geographic coordinates in file " << tmp << "trapped at " << AT << std::endl;
throw;
}
sd.setStationData(xcoord, ycoord, altitude, "", latitude, longitude);
sd.setStationData(location, "");
//Read one line, construct Date_IO object and see whether date is greater or equal than the date_in object
IOUtils::skipLines(fin, 1, eoln); //skip rest of line
......@@ -242,13 +242,13 @@ void A3DIO::read1DMeteo(const Date_IO& dateStart, const Date_IO& dateEnd,
} while((tmpdata.date < dateStart) && (!eofreached));
if ((dateEnd < dateStart) && (!eofreached)){ //Special case
vecMeteo.push_back( vector<MeteoData>() );
vecStation.push_back( vector<StationData>() );
vecMeteo.push_back( std::vector<MeteoData>() );
vecStation.push_back( std::vector<StationData>() );
vecMeteo[0].push_back(tmpdata);
vecStation[0].push_back(sd);
} else if ((tmpdata.date <= dateEnd) && (!eofreached)) {
vecMeteo.push_back( vector<MeteoData>() );
vecStation.push_back( vector<StationData>() );
vecMeteo.push_back( std::vector<MeteoData>() );
vecStation.push_back( std::vector<StationData>() );
}
while ((tmpdata.date <= dateEnd) && (!eofreached)) {
......@@ -263,7 +263,7 @@ void A3DIO::read1DMeteo(const Date_IO& dateStart, const Date_IO& dateEnd,
}
//cout << "Size of buffer: " << vecMeteo[0].size() << " " << tmp_date.toString() << endl;
} catch(...) {
cout << "[e] " << AT << ": "<< endl;
std::cout << "[e] " << AT << ": "<< std::endl;
cleanup();
throw;
}
......@@ -298,7 +298,7 @@ bool A3DIO::readMeteoDataLine(std::string& line, MeteoData& tmpdata, std::string
}
}
tmpdata.setMeteoData(tmp_date, tmp_values[0], tmp_values[1], tmp_values[2], nodata, tmp_values[3], tmp_values[4], tmp_values[5], nodata, nodata, nodata);
tmpdata.setMeteoData(tmp_date, tmp_values[0], tmp_values[1], tmp_values[2], IOUtils::nodata, tmp_values[3], tmp_values[4], tmp_values[5], IOUtils::nodata, IOUtils::nodata, IOUtils::nodata);
return false;
}
......@@ -335,7 +335,7 @@ bool A3DIO::readMeteoDataLine(std::string& line, MeteoData& tmpdata, std::string
stations = getNrOfStations(filenames, hashStations);
constructMeteo2DFilenames(startDate, startDate, filenames);//get filenames for current year
cerr << "[I] Number of 2D meteo stations: " << stations << endl;
std::cerr << "[I] Number of 2D meteo stations: " << stations << std::endl;
if (stations < 1) {
throw InvalidFormatException("No StationData found in 2D Meteo Files", AT);
......@@ -354,8 +354,8 @@ bool A3DIO::readMeteoDataLine(std::string& line, MeteoData& tmpdata, std::string
//init vecStation with proper StationData, vecMeteo with nodata
for (unsigned int jj=0; jj<tmpvecS.size(); jj++){
vecMeteo.push_back( vector<MeteoData>() );
vecStation.push_back( vector<StationData>() );
vecMeteo.push_back( std::vector<MeteoData>() );
vecStation.push_back( std::vector<StationData>() );
for (unsigned int ii=0; ii<vecMeteo[0].size(); ii++){
//NOTE: there needs to be the same amount of 1D and 2D data
vecStation[jj+1].push_back(tmpvecS[jj]);
......@@ -420,11 +420,11 @@ void A3DIO::constructMeteo2DFilenames(const Date_IO& startDate, const Date_IO& e
std::stringstream ss;
ss << yyyy;
string precFilename = tmp + "/prec" + ss.str() + ".txt";
string rhFilename = tmp + "/rhum" + ss.str() + ".txt";
string taFilename = tmp + "/tair" + ss.str() + ".txt";
string wspdFilename = tmp + "/wspd" + ss.str() + ".txt";
string wdirFilename = tmp + "/wdir" + ss.str() + ".txt";
std::string precFilename = tmp + "/prec" + ss.str() + ".txt";
std::string rhFilename = tmp + "/rhum" + ss.str() + ".txt";
std::string taFilename = tmp + "/tair" + ss.str() + ".txt";
std::string wspdFilename = tmp + "/wspd" + ss.str() + ".txt";
std::string wdirFilename = tmp + "/wdir" + ss.str() + ".txt";
filenames.push_back(precFilename);
filenames.push_back(rhFilename);
......@@ -453,7 +453,7 @@ unsigned int A3DIO::getNrOfStations(std::vector<std::string>& filenames, std::ma
std::string filename = filenames[ii];
fin.clear();
fin.open (filename.c_str(), ifstream::in);
fin.open (filename.c_str(), std::ifstream::in);
if (fin.fail()) throw FileAccessException(filename, AT);
char eoln = IOUtils::getEoln(fin); //get the end of line character for the file
......@@ -489,7 +489,7 @@ void A3DIO::read2DMeteoData(const std::string& filename, const std::string& para
int tmp_ymdh[4];
fin.clear();
fin.open (filename.c_str(), ifstream::in);
fin.open (filename.c_str(), std::ifstream::in);
if (fin.fail()) {
throw FileAccessException(filename, AT);
}
......@@ -583,7 +583,7 @@ void A3DIO::read2DMeteoHeader(const std::string& filename, std::map<std::string,
}
fin.clear();
fin.open (filename.c_str(), ifstream::in);
fin.open (filename.c_str(), std::ifstream::in);
if (fin.fail()) {
throw FileAccessException(filename, AT);
}
......@@ -612,23 +612,23 @@ void A3DIO::read2DMeteoHeader(const std::string& filename, std::map<std::string,
}
for (unsigned int ii=4; ii<columns; ii++) {
unsigned int stationnr = hashStations[vec_names.at(ii)];
if ((!IOUtils::convertString(vecS.at(stationnr-1).altitude, vec_altitude.at(ii), std::dec))
|| (!IOUtils::convertString(vecS.at(stationnr-1).eastCoordinate, vec_xcoord.at(ii), std::dec))
|| (!IOUtils::convertString(vecS.at(stationnr-1).northCoordinate, vec_ycoord.at(ii), std::dec))
|| (!IOUtils::convertString(vecS.at(stationnr-1).stationName, vec_names.at(ii), std::dec))) {
unsigned int stationnr = hashStations[vec_names.at(ii)];
double altitude, easting, northing, stationName;
if ((!IOUtils::convertString(altitude, vec_altitude.at(ii), std::dec))
|| (!IOUtils::convertString(easting, vec_xcoord.at(ii), std::dec))
|| (!IOUtils::convertString(northing, vec_ycoord.at(ii), std::dec))
|| (!IOUtils::convertString(stationName, vec_names.at(ii), std::dec))) {
throw ConversionFailedException("Conversion of station description failed in " + filename, AT);
}
Coords coordinate(coordsys, coordparam);
//calculate coordinates if necessary
if(vecS[stationnr-1].latitude==IOUtils::nodata || vecS[stationnr-1].longitude==IOUtils::nodata) {
if(vecS[stationnr-1].eastCoordinate==IOUtils::nodata || vecS[stationnr-1].northCoordinate==IOUtils::nodata) {
throw InvalidFormatException("Too many nodata values for coordinates conversion in file " + filename, AT);
}
coordinate.setXY(vecS[stationnr-1].eastCoordinate, vecS[stationnr-1].northCoordinate);
vecS[stationnr-1].latitude = coordinate.getLat();
vecS[stationnr-1].longitude = coordinate.getLon();
vecS[stationnr-1].stationName = stationName;
vecS[stationnr-1].position.setProj(coordsys, coordparam);
vecS[stationnr-1].position.setXY(easting, northing, altitude, false);
//calculate/check coordinates if necessary
try {
vecS[stationnr-1].position.check();
} catch (...) {
std::cerr << "[E] Too many nodata values for coordinates conversion in file " << filename << " at " << AT << std::endl;
}
}
......@@ -647,7 +647,7 @@ void A3DIO::readSpecialPoints(POINTSArray& pts)
}
fin.clear();
fin.open (filename.c_str(), ifstream::in);
fin.open (filename.c_str(), std::ifstream::in);
if (fin.fail()) {
throw FileAccessException(filename,AT);
}
......
......@@ -42,7 +42,7 @@ void ConfigReader::addFile(const std::string& filename_in)
void ConfigReader::addCmdLine(const std::string& cmd_line)
{
sourcename = string("Command line");
sourcename = std::string("Command line");
parseCmdLine(cmd_line);
}
......@@ -139,7 +139,7 @@ std::string ConfigReader::getSourceName()
return sourcename;
}
unsigned int ConfigReader::findKeys(vector<string>& vecResult,
unsigned int ConfigReader::findKeys(std::vector<std::string>& vecResult,
const std::string keystart,
const std::string section) const
{
......
......@@ -122,7 +122,7 @@ class ConfigReader {
*/
template <class T> void getValue(const std::string& key,
const std::string& section,
vector<T>& vecT,
std::vector<T>& vecT,
const unsigned int& options=0) const {
try {
vecT.clear();
......@@ -178,7 +178,7 @@ class ConfigReader {
* unsigned int nrOfMatches = getKeys(myVec, "TA::", "Filters");
* @endcode
*/
unsigned int findKeys(vector<string>& vecResult,
unsigned int findKeys(std::vector<std::string>& vecResult,
const std::string keystart, const std::string section="GENERAL") const;
//LEGACY
......
......@@ -24,6 +24,8 @@
#define PI 3.141592653589
#endif
using namespace IOUtils;
const struct Coords::ELLIPSOID Coords::ellipsoids[] = {
{ 6378137., 6356752.3142 }, //E_WGS84
{ 6378137., 6356752.3141 }, //E_GRS80
......@@ -33,29 +35,51 @@ const struct Coords::ELLIPSOID Coords::ellipsoids[] = {
{ 6378160., 6356774.719 } //E_GRS67
};
bool Coords::operator==(Coords& in)
bool Coords::operator==(const Coords& in) const
{//check that two Coords objects represent the same location
const bool comparison = ( checkEpsilonEquality(getLat(), in.getLat(), 1.e-4) &&
checkEpsilonEquality(getLon(), in.getLon(), 1.e-4) );
const double earth_radius = 6371e3; //in meters
const double grid_epsilon = 5.; //in meters
const double long_epsilon = grid_epsilon / earth_radius; //in degrees. small angle, so sin(x)=x
const double lat_epsilon = long_epsilon/2.; //in degrees. Since long is for 360deg and lat only 180
const bool comparison = ( IOUtils::checkEpsilonEquality(getLat(), in.getLat(), lat_epsilon) &&
IOUtils::checkEpsilonEquality(getLon(), in.getLon(), long_epsilon) );
return comparison;
}
bool Coords::operator!=(Coords& in)
bool Coords::operator!=(const Coords& in) const
{
return !(*this==in);
}
Coords& Coords::operator=(const Coords& source) {
if(this != &source) {
altitude = source.altitude;
latitude = source.latitude;
longitude = source.longitude;
easting = source.easting;
northing = source.northing;
ref_latitude = source.ref_latitude;
ref_longitude = source.ref_longitude;
distance_algo = source.distance_algo;
coordsystem = source.coordsystem;
coordparam = source.coordparam;
initializeMaps();
setFunctionPointers();
}
return *this;
}
/**
* @brief Default constructor
* This constructor builds a dummy object that performs no conversions but can be used for comparison
* purpose. This is more or less the euqivalent of NULL for a pointer...
* purpose. This is more or less the equivalent of NULL for a pointer...
*/
Coords::Coords()
{
coordsystem = "NULL";
coordparam = "NULL";
initializeMaps();
setDefaultValues();
setProj("NULL", "NULL");
}
/**
......@@ -92,89 +116,62 @@ Coords::Coords(const double& _lat_ref, const double& _long_ref)
setProj("LOCAL", "");
}
double Coords::getEasting() {
if(refresh_xy==true) {
if((latitude==IOUtils::nodata) || (longitude==IOUtils::nodata)) {
InvalidArgumentException("missing positional parameters (easting,northing) or (lat,long) for coordinate", AT);
}
convert_from_WGS84(latitude, longitude, easting, northing);
refresh_xy=false;
}
double Coords::getEasting() const {
return easting;
}
double Coords::getNorthing() {
if(refresh_xy==true) {
if((latitude==IOUtils::nodata) || (longitude==IOUtils::nodata)) {
InvalidArgumentException("missing positional parameters (easting,northing) or (lat,long) for coordinate", AT);
}
convert_from_WGS84(latitude, longitude, easting, northing);
refresh_xy=false;
}
double Coords::getNorthing() const {
return northing;
}
double Coords::getLat() {
if(refresh_latlon==true) {
if((easting==IOUtils::nodata) || (northing==IOUtils::nodata)) {
InvalidArgumentException("missing positional parameters (easting,northing) or (lat,long) for coordinate", AT);
}
convert_to_WGS84(easting, northing, latitude, longitude);
refresh_latlon=false;
}
double Coords::getLat() const {
return latitude;
}
double Coords::getLon() {
if(refresh_latlon==true) {
if((easting==IOUtils::nodata) || (northing==IOUtils::nodata)) {
InvalidArgumentException("missing positional parameters (easting,northing) or (lat,long) for coordinate", AT);
}
convert_to_WGS84(easting, northing, latitude, longitude);
refresh_latlon=false;
}
double Coords::getLon() const {
return longitude;
}
void Coords::setLatLon(const double _latitude, const double _longitude) {
double Coords::getAltitude() const {
return altitude;
}
void Coords::setLatLon(const double _latitude, const double _longitude, const double _altitude, const bool _update) {
latitude = _latitude;
longitude = _longitude;
refresh_latlon = false;
refresh_xy = true;
if(_altitude!=IOUtils::nodata) {
altitude = _altitude;
}
if(coordsystem!="NULL" && _update==true) {
convert_from_WGS84(latitude, longitude, easting, northing);
}
}
void Coords::setXY(const double _easting, const double _northing) {
void Coords::setXY(const double _easting, const double _northing, const double _altitude, const bool _update) {
easting = _easting;
northing = _northing;
refresh_latlon = true;
refresh_xy = false;
if(_altitude!=IOUtils::nodata) {
altitude = _altitude;
}
if(coordsystem!="NULL" && _update==true) {
convert_to_WGS84(easting, northing, latitude, longitude);
}
}
void Coords::setProj(const std::string& _coordinatesystem, const std::string& _parameters) {
//the latitude/longitude had not been calculated, so we do it first in order to have our reference
//before further conversions (usage scenario: giving a x,y and then converting to anyother x,y in another system
if((refresh_latlon = true) && (latitude!=IOUtils::nodata) && (longitude!=IOUtils::nodata)) {
getLat(); //refreshes both lat and lon
if(coordsystem!="NULL") {
//the convert method will check for nodata
convert_to_WGS84(easting, northing, latitude, longitude);
}
coordsystem = _coordinatesystem;
coordparam = _parameters;
setFunctionPointers();
//We consider lat/long as the reference. This means that if thex have a value, it will NOT be recomputed
if((latitude==IOUtils::nodata) || (longitude==IOUtils::nodata)) {
//latitude and longitude were not already known, so they will have to be recomputed
refresh_latlon = true;
if((easting==IOUtils::nodata) || (northing==IOUtils::nodata)) {
refresh_xy = true;
} else {
refresh_xy = false;
}
} else {
//known latitude and longitude, so they are kept as reference
refresh_latlon = false;
refresh_xy = true;
}
//since lat/long is our reference, we refresh x,y
convert_from_WGS84(latitude, longitude, easting, northing);
}
void Coords::setLocalRef(const double _ref_latitude, const double _ref_longitude) {
......@@ -183,18 +180,24 @@ void Coords::setLocalRef(const double _ref_latitude, const double _ref_longitude
}
ref_latitude = _ref_latitude;
ref_longitude = _ref_longitude;
refresh_xy = true;
if(coordsystem=="LOCAL") {
convert_from_WGS84(latitude, longitude, easting, northing);
}
}
void Coords::setLocalRef(const std::string _coordparam) {
coordparam = _coordparam;
parseLatLon(coordparam, ref_latitude, ref_longitude);
refresh_xy = true;
if(coordsystem=="LOCAL") {
convert_from_WGS84(latitude, longitude, easting, northing);
}
}
void Coords::setDistances(const geo_distances _algo) {
distance_algo = _algo;
refresh_xy = true;
if(coordsystem=="LOCAL") {
convert_from_WGS84(latitude, longitude, easting, northing);
}
}
/**
......@@ -208,20 +211,28 @@ void Coords::setDistances(const geo_distances _algo) {
void Coords::check()
{
//calculate/check coordinates if necessary
if(coordsystem=="LOCAL" && (ref_latitude==IOUtils::nodata || ref_longitude==IOUtils::nodata)) {
throw InvalidArgumentException("please define a reference point for LOCAL coordinate system", AT);
}
if(latitude==IOUtils::nodata || longitude==IOUtils::nodata) {
if(easting==IOUtils::nodata || northing==IOUtils::nodata) {
throw InvalidArgumentException("missing positional parameters (easting,northing) or (lat,long) for coordinate", AT);
}
refresh_latlon = true;
refresh_xy = false;
convert_to_WGS84(easting, northing, latitude, longitude);
} else {
if(easting==IOUtils::nodata || northing==IOUtils::nodata) {
refresh_latlon = false;
refresh_xy = true;
convert_from_WGS84(latitude, longitude, easting, northing);
} else {
double tmp_lat, tmp_lon;
convert_to_WGS84(easting, northing, tmp_lat, tmp_lon);
if(!IOUtils::checkEpsilonEquality(latitude, tmp_lat, 1.e-4) || !IOUtils::checkEpsilonEquality(longitude, tmp_lon, 1.e-4)) {
const double earth_radius = 6371e3; //in meters
const double grid_epsilon = 5.; //in meters
const double long_epsilon = grid_epsilon / earth_radius; //in degrees. small angle, so sin(x)=x
const double lat_epsilon = long_epsilon/2.; //in degrees. Since long is for 360deg and lat only 180
if(!IOUtils::checkEpsilonEquality(latitude, tmp_lat, lat_epsilon) || !IOUtils::checkEpsilonEquality(longitude, tmp_lon, long_epsilon)) {
throw InvalidArgumentException("Latitude/longitude and xllcorner/yllcorner don't match for coordinate", AT);
}
}
......@@ -249,7 +260,12 @@ double Coords::distance(Coords& destination) {
*/
void Coords::convert_to_WGS84(double easting, double northing, double& latitude, double& longitude) const
{
(this->*convToWGS84)(easting, northing, latitude, longitude);
if((easting!=IOUtils::nodata) && (northing!=IOUtils::nodata)) {
(this->*convToWGS84)(easting, northing, latitude, longitude);
} else {
latitude = IOUtils::nodata;
longitude = IOUtils::nodata;
}
}
/**
......@@ -261,7 +277,12 @@ void Coords::convert_to_WGS84(double easting, double northing, double& latitude,
*/
void Coords::convert_from_WGS84(double latitude, double longitude, double& easting, double& northing) const
{
(this->*convFromWGS84)(latitude, longitude, easting, northing);
if((latitude!=IOUtils::nodata) && (longitude!=IOUtils::nodata)) {
(this->*convFromWGS84)(latitude, longitude, easting, northing);
} else {
easting = IOUtils::nodata;
northing = IOUtils::nodata;
}
}
/**
......@@ -336,8 +357,8 @@ lat, double& lon) {
throw InvalidFormatException("Can not parse given lat/lon: "+coordinates,AT);
}
lat = dms_to_decimal(string(lat_str));
lon = dms_to_decimal(string(lon_str));
lat = dms_to_decimal(std::string(lat_str));
lon = dms_to_decimal(std::string(lon_str));
}
/**
......@@ -713,22 +734,24 @@ void Coords::WGS84_to_local(double lat_in, double long_in, double& east_out, dou
double distance;
if((ref_latitude==IOUtils::nodata) || (ref_longitude==IOUtils::nodata)) {
throw InvalidArgumentException("No reference coordinate provided for LOCAL projection", AT);
}
switch(distance_algo) {
case GEO_COSINE:
distance = cosineDistance(ref_latitude, ref_longitude, lat_in, long_in, alpha);
break;
case GEO_VINCENTY:
distance = VincentyDistance(ref_latitude, ref_longitude, lat_in, long_in, alpha);
break;
default:
throw InvalidArgumentException("Unrecognized geodesic distance algorithm selected", AT);
east_out = IOUtils::nodata;
north_out = IOUtils::nodata;
//throw InvalidArgumentException("No reference coordinate provided for LOCAL projection", AT);
} else {
switch(distance_algo) {
case GEO_COSINE:
distance = cosineDistance(ref_latitude, ref_longitude, lat_in, long_in, alpha);
break;
case GEO_VINCENTY:
distance = VincentyDistance(ref_latitude, ref_longitude, lat_in, long_in, alpha);
break;
default:
throw InvalidArgumentException("Unrecognized geodesic distance algorithm selected", AT);
}
east_out = distance*sin(alpha*to_rad);
north_out = distance*cos(alpha*to_rad);
}
east_out = distance*sin(alpha*to_rad);
north_out = distance*cos(alpha*to_rad);
}
......@@ -746,19 +769,31 @@ void Coords::local_to_WGS84(double east_in, double north_in, double& lat_out, do
const double bearing = fmod( atan2(east_in, north_in)*to_deg+360. , 360.);
if((ref_latitude==IOUtils::nodata) || (ref_longitude==IOUtils::nodata)) {
throw InvalidArgumentException("No reference coordinate provided for LOCAL projection", AT);
lat_out = IOUtils::nodata;
long_out = IOUtils::nodata;
//throw InvalidArgumentException("No reference coordinate provided for LOCAL projection", AT);
} else {
switch(distance_algo) {
case GEO_COSINE:
cosineInverse(ref_latitude, ref_longitude, distance, bearing, lat_out, long_out);
break;
case GEO_VINCENTY:
VincentyInverse(ref_latitude, ref_longitude, distance, bearing, lat_out, long_out);
break;
default:
throw InvalidArgumentException("Unrecognized geodesic distance algorithm selected", AT);
}
}
}
switch(distance_algo) {
case GEO_COSINE:
cosineInverse(ref_latitude, ref_longitude, distance, bearing, lat_out, long_out);
break;
case GEO_VINCENTY:
VincentyInverse(ref_latitude, ref_longitude, distance, bearing, lat_out, long_out);
break;
default:
throw InvalidArgumentException("Unrecognized geodesic distance algorithm selected", AT);
}
void Coords::NULL_to_WGS84(double /*east_in*/, double /*north_in*/, double& /*lat_out*/, double& /*long_out*/) const
{
throw InvalidArgumentException("The projection has not been initialized!", AT);
}
void Coords::WGS84_to_NULL(double /*lat_in*/, double /*long_in*/, double& /*east_out*/, double& /*north_out*/) const
{
throw InvalidArgumentException("The projection has not been initialized!", AT);
}
/**
......@@ -963,6 +998,8 @@ void Coords::initializeMaps() {
from_wgs84["PROJ4"] = &Coords::WGS84_to_PROJ4;
to_wgs84["LOCAL"] = &Coords::local_to_WGS84;
from_wgs84["LOCAL"] = &Coords::WGS84_to_local;
to_wgs84["NULL"] = &Coords::NULL_to_WGS84;
from_wgs84["NULL"] = &Coords::WGS84_to_NULL;
}
void Coords::setFunctionPointers() {
......@@ -987,10 +1024,10 @@ void Coords::setFunctionPointers() {
void Coords::setDefaultValues() {
//sets safe defaults for all internal variables (except function pointers and maps)
latitude = longitude = IOUtils::nodata;
altitude = IOUtils::nodata;
easting = northing = IOUtils::nodata;