WSL/SLF GitLab Repository

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

The MapProj class has been renamed in Coords. It now contains the coordinates...

The MapProj class has been renamed in Coords. It now contains the coordinates (lat,long) and (xcoord, ycoord) and should therefore be used as a storage and conversion class. The necessary changes have been made to the rest of the code so it uses this class, but it still does NOT use it as a storage of coordinates (which will have to be done in the future). This addressed partially issue 35.
parent ac6f3859
......@@ -88,7 +88,7 @@ METEOIO_OBJ = $(SRCDIR)/MeteoData.o \
$(SRCDIR)/DEMObject.o \
$(SRCDIR)/IOExceptions.o \
$(SRCDIR)/IOUtils.o \
$(SRCDIR)/MapProj.o \
$(SRCDIR)/Coords.o \
$(SRCDIR)/libinterpol2D.o \
$(SRCDIR)/libinterpol1D.o \
$(SRCDIR)/Meteo2DInterpolator.o \
......@@ -113,7 +113,7 @@ METEOIO_OBJ_POPC = $(SRCDIR)/IOInterface_par.o \
$(SRCDIR)/DEMObject_par.o \
$(SRCDIR)/IOExceptions_par.o \
$(SRCDIR)/IOUtils_par.o \
$(SRCDIR)/MapProj_par.o \
$(SRCDIR)/Coords_par.o \
$(SRCDIR)/libinterpol2D_par.o \
$(SRCDIR)/libinterpol1D_par.o \
$(SRCDIR)/Meteo2DInterpolator_par.o \
......
CC = g++ -DGNU
CFLAGS = -Wall -Wextra
DEBUG = -g -O0 -DDEBUG -ggdb
DEBUG = -g #-O3 # -DDEBUG -ggdb
METEOIODIR = ../../src
LIBS = -rdynamic -lstdc++ -ldl -L../../lib -lmeteoio
......@@ -20,15 +20,16 @@ INCLUDE_POPC=-I. -I$(METEOIODIR)
#####################
# TARGETS
#####################
all: meteo_reading dem_reading
all: meteo_reading dem_reading coordinates
meteo_reading: meteo_reading.o
$(CC) $(DEBUG) -o $@ meteo_reading.o ${LIBS}
dem_reading: dem_reading.o
$(CC) $(DEBUG) -o $@ dem_reading.o ${LIBS}
coordinates: coordinates.o
$(CC) $(DEBUG) -o $@ coordinates.o ${LIBS}
clean:
rm -rf *~ *.o *.out meteo_reading dem_reading
rm -rf *~ *.o *.out meteo_reading dem_reading coordinates
#include "MeteoIO.h"
using namespace std;
int main(int argc, char** argv) {
(void)argc;
//we create one point in the CH1903 coordinate system
//and we attribute it a set of coordinates (this is the Laret lake in Davos)
Coords point1("CH1903","");
point1.setXY(785425. , 191124.);
//First, we check the matching lat/long
printf("CH1903 to Lat/long\n");
printf("\t(%g , %g) -> (%g , %g)\n", point1.getEasting(), point1.getNorthing(), point1.getLat(), point1.getLon());
//Now we set up a local coordinate system, using as (0,0) the old observatory of Berne
//We use the Vincenty algorithm for the distance calculations (more precise but more intensive than the default)
point1.setProj("LOCAL","(46°57'08.66\",7°26'22.50\")");
point1.setDistances(Coords::GEO_VINCENTY);
//we print the new (x,y) coordinates
//we add (600000,200000) because in CH1903, the old observatory of Berne is (600000,200000)
printf("Lat/long to Local\n\t(%g , %g) -> (%g , %g)\n", point1.getLat(), point1.getLon(), point1.getEasting()+600000., point1.getNorthing()+200000.);
//we want again CH1903 coodinates -> we set up the projection to CH1903
point1.setProj("CH1903","");
//we print the (lat,long) and (x,y) coordinates once more to check that they still match what we had a the begining
printf("Lat/long to CH1903\n\t(%g , %g) -> (%g , %g)\n", point1.getLat(), point1.getLon(), point1.getEasting(), point1.getNorthing());
return 0;
}
......@@ -5,9 +5,14 @@ COORDIN = CH1903
COORDPARAM = -999
#COORDIN = PROJ4
#COORDPARAM = +init=epsg:21781
#COORDIN = PROJ4
#COORDPARAM = +proj=utm +ellps=WGS84 +zone=10
DEMSRC = ARC
DEMFILE = ./input/surface-grids/zwischberg.dem
#DEMFILE = ./input/surface-grids/zwischberg.dem
#DEMFILE = ./cypress.dem
DEMFILE = ./Switzerland_1000m.asc
#DEMFILE = ./test.dem
OUTPUT = ARC
OUTPATH = ./output/
......
......@@ -7,7 +7,7 @@
int main(int argc, char** argv) {
(void)argc;
Date_IO d1;
//Date_IO d1;
std::vector<MeteoData> vecMeteo;
std::vector<StationData> vecStation;
......@@ -18,16 +18,10 @@ int main(int argc, char** argv) {
raw_io = new IOHandler(cfg);
io = new BufferedIOHandler(*raw_io, cfg);
convertString(d1,argv[1]);
//convertString(d1,argv[1]);
Date_IO d1(2006, 01, 04, 23); //2005-12-12T24 fails while 2005-12-12T23 works (ie: remains in the same buffer)
io->readMeteoData(d1, vecMeteo, vecStation);
//writing some data out in order to prove that it really worked!
for (unsigned int ii=0; ii < vecMeteo.size(); ii++) {
std::cout << "---------- Station: " << (ii+1) << " / " << vecStation.size() << std::endl;
std::cout << vecStation[ii].toString() << std::endl;
std::cout << vecMeteo[ii].ta << std::endl;
}
delete io;
delete raw_io;
......
......@@ -46,8 +46,8 @@
* @section a3d_keywords Keywords
* This plugin uses the following keywords:
* - METEOPATH: string containing the path to the meteorological files (ie: where to find meteo1d.txt and meteo2d files)
* - COORDIN: input coordinate system (see MapProj)
* - COORDPARAM: extra input coordinates parameters (see MapProj)
* - COORDIN: input coordinate system (see Coords)
* - COORDPARAM: extra input coordinates parameters (see Coords)
* - SPECIALPTSFILE: a path+file name to the a file containing grid coordinates of special points of interest (for special outputs)
*/
......@@ -215,21 +215,18 @@ void A3DIO::read1DMeteo(const Date_IO& dateStart, const Date_IO& dateEnd,
cerr << "[E] reading configuration file: " << "\t" << e.what() << endl;
throw;
}
MapProj mymapproj(coordsys, coordparam);
//calculate coordinates if necessary
if(latitude==IOUtils::nodata || longitude==IOUtils::nodata) {
if(xcoord==IOUtils::nodata || ycoord==IOUtils::nodata) {
throw InvalidFormatException("Too many nodata values for coordinates conversion in file " + tmp, AT);
}
mymapproj.convert_to_WGS84(xcoord, ycoord, latitude, longitude);
} else if(xcoord!=IOUtils::nodata || ycoord!=IOUtils::nodata) {
double tmp_lat, tmp_lon;
mymapproj.convert_to_WGS84(xcoord, ycoord, tmp_lat, tmp_lon);
if(!checkEpsilonEquality(latitude, tmp_lat, 1.e-4) || !checkEpsilonEquality(longitude, tmp_lon, 1.e-4)) {
throw InvalidArgumentException("Latitude/longitude and Xcoord/Ycoord don't match in header of file " + tmp, AT);
}
//compute/check WGS coordinates (considered as the true reference)
Coords coordinate(coordsys, coordparam);
coordinate.setXY(xcoord, ycoord);
coordinate.setLatLon(latitude, longitude);
try {
coordinate.check();
} catch(...) {
std::cerr << "[E] Error in geographic coordinates in file " << tmp << "trapped at " << AT << endl;
throw;
}
sd.setStationData(xcoord, ycoord, altitude, "", latitude, longitude);
//Read one line, construct Date_IO object and see whether date is greater or equal than the date_in object
......@@ -576,7 +573,7 @@ void A3DIO::read2DMeteoHeader(const std::string& filename, std::map<std::string,
unsigned int columns = 0;
std::vector<std::string> vec_altitude, vec_xcoord, vec_ycoord, vec_names;
//Build MapProj object to convert easting/northing values to lat/long in WGS84
//Build Coords object to convert easting/northing values to lat/long in WGS84
std::string coordsys="", coordparam="";
try {
cfg.getValue("COORDIN", coordsys);
......@@ -584,7 +581,6 @@ void A3DIO::read2DMeteoHeader(const std::string& filename, std::map<std::string,
} catch(std::exception& e){
//problems while reading values for COORDIN or COORDPARAM
}
MapProj mymapproj(coordsys, coordparam);
fin.clear();
fin.open (filename.c_str(), ifstream::in);
......@@ -624,12 +620,15 @@ void A3DIO::read2DMeteoHeader(const std::string& filename, std::map<std::string,
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);
}
mymapproj.convert_to_WGS84(vecS[stationnr-1].eastCoordinate, vecS[stationnr-1].northCoordinate, vecS[stationnr-1].latitude, vecS[stationnr-1].longitude);
coordinate.setXY(vecS[stationnr-1].eastCoordinate, vecS[stationnr-1].northCoordinate);
vecS[stationnr-1].latitude = coordinate.getLat();
vecS[stationnr-1].longitude = coordinate.getLon();
}
}
......
......@@ -20,7 +20,7 @@
#include "IOInterface.h"
#include "MapProj.h"
#include "Coords.h"
#include "ConfigReader.h"
#include "IOExceptions.h"
#include "IOUtils.h"
......
......@@ -9,7 +9,7 @@ SET(meteoio_sources
Grid2DObject.cc
IOHandler.cc
LegacyIO.cc
MapProj.cc
Coords.cc
Meteo2DInterpolator.cc
BufferedIOHandler.cc
DEMObject.cc
......
This diff is collapsed.
......@@ -15,8 +15,8 @@
You should have received a copy of the GNU Lesser General Public License
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __MAPPROJ_H__
#define __MAPPROJ_H__
#ifndef __COORDS_H__
#define __COORDS_H__
#include "StationData.h"
#include "MeteoData.h"
......@@ -26,33 +26,56 @@
#include <string>
#include <map>
class MapProj; //forward declaration
class Coords; //forward declaration
typedef void(MapProj::*convfunc)(double, double, double&, double&) const;
typedef void(Coords::*convfunc)(double, double, double&, double&) const;
#ifdef _POPC_
class MapProj : POPBase {
class Coords : POPBase {
public:
void Serialize(POPBuffer &buf, bool pack);
#else
class MapProj {
class Coords {
#endif
public:
///Keywords for selecting the algorithm for computing geodesic distances
enum GEO_DISTANCES {
typedef enum GEO_DISTANCES {
GEO_COSINE, ///< Spherical law of cosine
GEO_VINCENTY ///< Vincenty ellispoid formula
};
} geo_distances;
//Constructors
MapProj();
MapProj(const std::string& coordinatesystem, const std::string& parameters="");
MapProj(const double& _lat_ref, const double& _long_ref);
Coords();
Coords(const std::string& coordinatesystem, const std::string& parameters="");
Coords(const double& _lat_ref, const double& _long_ref);
//Operators
bool operator==(const MapProj&) const; ///<Operator that tests for equality
bool operator!=(const MapProj&) const; ///<Operator that tests for inequality
bool operator==(Coords&); ///<Operator that tests for equality
bool operator!=(Coords&); ///<Operator that tests for inequality
//Getter methods
double getEasting();
double getNorthing();
double getLat();
double getLon();
//Setter methods
void setLatLon(const double _latitude, const double _longitude);
void setXY(const double _easting, const double _northing);
void setProj(const std::string& _coordinatesystem, const std::string& _parameters);
void setLocalRef(const double _ref_latitude, const double _ref_longitude);
void setLocalRef(const std::string _coordparam);
void setDistances(const geo_distances _algo);
void check();
double distance(Coords& destination);
//Static helper methods
static double dms_to_decimal(const std::string& dms);
static void parseLatLon(const std::string& coordinates, double& lat, double& lon);
static std::string decimal_to_dms(const double& decimal);
private:
//Coordinates conversions
void convert_to_WGS84(double easting, double northing, double& latitude, double& longitude) const;
void convert_from_WGS84(double latitude, double longitude, double& easting, double& northing) const;
......@@ -67,33 +90,31 @@ class MapProj {
void WGS84_to_local(double lat_in, double long_in, double& east_out, double& north_out) const;
void local_to_WGS84(double east_in, double north_in, double& lat_out, double& long_out) const;
//Static methods
static void WGS84_to_local(double lat_ref, double lon_ref, const double& lat, const double& lon, double& easting, double& northing, const enum GEO_DISTANCES algo=GEO_VINCENTY);
static void local_to_WGS84(double lat_ref, double lon_ref, const double& easting, const double& northing, double& lat, double& lon, const enum GEO_DISTANCES algo=GEO_VINCENTY);
static double cosineDistance(const double& lat1, const double& lon1, const double& lat2, const double& lon2, double& alpha);
static double cosineDistance(const double& lat1, const double& lon1, const double& lat2, const double& lon2);
static void cosineInverse(const double& lat_ref, const double& lon_ref, const double& distance, const double& bearing, double& lat, double& lon);
static double VincentyDistance(const double& lat1, const double& lon1, const double& lat2, const double& lon2, double& alpha);
static double VincentyDistance(const double& lat1, const double& lon1, const double& lat2, const double& lon2);
static void VincentyInverse(const double& lat_ref, const double& lon_ref, const double& distance, const double& bearing, double& lat, double& lon);
static double dms_to_decimal(const std::string& dms);
static void parseLatLon(const std::string& coordinates, double& lat, double& lon);
static std::string decimal_to_dms(const double& decimal);
//Distances calculations
void distance(Coords& destination, double& distance, double& bearing);
double cosineDistance(const double& lat1, const double& lon1, const double& lat2, const double& lon2, double& alpha) const;
void cosineInverse(const double& lat_ref, const double& lon_ref, const double& distance, const double& bearing, double& lat, double& lon) const;
double VincentyDistance(const double& lat1, const double& lon1, const double& lat2, const double& lon2, double& alpha) const;
void VincentyInverse(const double& lat_ref, const double& lon_ref, const double& distance, const double& bearing, double& lat, double& lon) const;
private:
void setDefaultValues();
void initializeMaps();
void setFunctionPointers();
int getUTMZone(const double latitude, const double longitude, std::string& zone_out) const;
private:
double latitude, longitude;
double easting, northing;
bool refresh_latlon, refresh_xy;
std::map<std::string, convfunc> to_wgs84;
std::map<std::string, convfunc> from_wgs84;
std::string coordsystem;
std::string coordparam;
convfunc convToWGS84, convFromWGS84;
double ref_latitude, ref_longitude;
geo_distances distance_algo;
///Keywords for selecting an ellipsoid to use
enum ELLIPSOIDS_NAMES {
......@@ -109,7 +130,6 @@ class MapProj {
double b;
};
static const struct ELLIPSOID ellipsoids[];
};
#endif
......@@ -30,7 +30,7 @@
* @author Gaël Rosset - Mathias Bavay
* @date 2009-07-20
*/
class DEMObject: public Grid2DObject {
class DEMObject : public Grid2DObject {
public:
Array2D<double> slope;
Array2D<double> azi;
......
......@@ -17,7 +17,7 @@
*/
#include "Grid2DObject.h"
#include "IOUtils.h"
#include "MapProj.h"
#include "Coords.h"
#include <cmath>
/*
......@@ -65,17 +65,24 @@ Grid2DObject::Grid2DObject(const Grid2DObject& _grid2Dobj, const unsigned int& _
}
void Grid2DObject::grid_to_WGS84(const unsigned int& i, const unsigned int& j, double& _latitude, double& _longitude)
{
{//HACK: redo these method correctly using the Coords object
const double easting = ((double)i+.5) * cellsize; //HACK: is the coordinate the center of the cell?
const double northing = ((double)j+.5) * cellsize;
MapProj::local_to_WGS84(latitude, longitude, easting, northing, _latitude, _longitude, MapProj::GEO_COSINE);
Coords coordinate(latitude, longitude); //TODO: add the distance algo as default param -> MapProj::GEO_COSINE
coordinate.setXY(easting, northing);
_latitude = coordinate.getLat();
_longitude = coordinate.getLon();
}
int Grid2DObject::WGS84_to_grid(const double& _latitude, const double& _longitude, unsigned int& i, unsigned int& j)
{
double easting, northing;
MapProj::WGS84_to_local(latitude, longitude, _latitude, _longitude, easting, northing, MapProj::GEO_COSINE);
Coords coordinate(latitude, longitude); //TODO: add the distance algo as default param -> MapProj::GEO_COSINE
coordinate.setLatLon(_latitude, _longitude);
easting = coordinate.getEasting();
northing = coordinate.getNorthing();
double x = floor(easting/cellsize);
double y = floor(northing/cellsize);
......@@ -153,27 +160,6 @@ void Grid2DObject::setValues(const unsigned int& _ncols, const unsigned int& _nr
//}
}
void Grid2DObject::checkCoordinates(const MapProj& proj)
{
//calculate/check coordinates if necessary
if(latitude==IOUtils::nodata || longitude==IOUtils::nodata) {
if(xllcorner==IOUtils::nodata || yllcorner==IOUtils::nodata) {
throw InvalidArgumentException("missing positional parameters (xll,yll) or (lat,long) for Grid2DObject", AT);
}
proj.convert_to_WGS84(xllcorner, yllcorner, latitude, longitude);
} else {
if(xllcorner==IOUtils::nodata || yllcorner==IOUtils::nodata) {
proj.convert_from_WGS84(latitude, longitude, xllcorner, yllcorner);
} else {
double tmp_lat, tmp_lon;
proj.convert_to_WGS84(xllcorner, yllcorner, tmp_lat, tmp_lon);
if(!IOUtils::checkEpsilonEquality(latitude, tmp_lat, 1.e-4) || !IOUtils::checkEpsilonEquality(longitude, tmp_lon, 1.e-4)) {
throw InvalidArgumentException("Latitude/longitude and xllcorner/yllcorner don't match for Grid2DObject", AT);
}
}
}
}
bool Grid2DObject::isSameGeolocalization(const Grid2DObject& target)
{
if( ncols==target.ncols && nrows==target.nrows &&
......
......@@ -20,7 +20,7 @@
#include "Array2D.h"
#include "IOExceptions.h"
#include "MapProj.h"
#include "Coords.h"
/**
* @class Grid2DObject
......@@ -142,14 +142,12 @@ class Grid2DObject{
double latitude, longitude;
protected:
static const MapProj NULL_proj;
//static const Coords NULL_proj; //HACK
void setValues(const unsigned int& ncols, const unsigned int& nrows,
const double& xllcorner, const double& yllcorner,
const double& latitude, const double& longitude, const double& cellsize/*,
const MapProj& proj=Grid2DObject::NULL_proj*/);
void checkCoordinates(const MapProj& proj);
};
#endif
......@@ -16,7 +16,7 @@
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Grid3DObject.h"
#include "MapProj.h"
#include "Coords.h"
Grid3DObject::Grid3DObject() : grid3D() //using Array3D default constructor
{
......@@ -98,27 +98,27 @@ void Grid3DObject::setValues(const unsigned int& _ncols, const unsigned int& _nr
//TODO: add WGS84_to_local methods to Grid3DObject (with/without terrain following coords)
void Grid3DObject::checkCoordinates(const MapProj& proj)
{
//HACK: altitude is missing!!
//calculate/check coordinates if necessary
if(latitude==IOUtils::nodata || longitude==IOUtils::nodata) {
if(xllcorner==IOUtils::nodata || yllcorner==IOUtils::nodata) {
throw InvalidArgumentException("missing positional parameters (xll,yll) or (lat,long) for Grid3DObject", AT);
}
proj.convert_to_WGS84(xllcorner, yllcorner, latitude, longitude);
} else {
if(xllcorner==IOUtils::nodata || yllcorner==IOUtils::nodata) {
proj.convert_from_WGS84(latitude, longitude, xllcorner, yllcorner);
} else {
double tmp_lat, tmp_lon;
proj.convert_to_WGS84(xllcorner, yllcorner, tmp_lat, tmp_lon);
if(!IOUtils::checkEpsilonEquality(latitude, tmp_lat, 1.e-4) || !IOUtils::checkEpsilonEquality(longitude, tmp_lon, 1.e-4)) {
throw InvalidArgumentException("Latitude/longitude and xllcorner/yllcorner don't match for Grid3DObject", AT);
}
}
}
}
// void Grid3DObject::checkCoordinates(const MapProj& proj)
// {
// //HACK: altitude is missing!!
// //calculate/check coordinates if necessary
// if(latitude==IOUtils::nodata || longitude==IOUtils::nodata) {
// if(xllcorner==IOUtils::nodata || yllcorner==IOUtils::nodata) {
// throw InvalidArgumentException("missing positional parameters (xll,yll) or (lat,long) for Grid3DObject", AT);
// }
// proj.convert_to_WGS84(xllcorner, yllcorner, latitude, longitude);
// } else {
// if(xllcorner==IOUtils::nodata || yllcorner==IOUtils::nodata) {
// proj.convert_from_WGS84(latitude, longitude, xllcorner, yllcorner);
// } else {
// double tmp_lat, tmp_lon;
// proj.convert_to_WGS84(xllcorner, yllcorner, tmp_lat, tmp_lon);
// if(!IOUtils::checkEpsilonEquality(latitude, tmp_lat, 1.e-4) || !IOUtils::checkEpsilonEquality(longitude, tmp_lon, 1.e-4)) {
// throw InvalidArgumentException("Latitude/longitude and xllcorner/yllcorner don't match for Grid3DObject", AT);
// }
// }
// }
// }
bool Grid3DObject::isSameGeolocalization(const Grid3DObject& target)
{//HACK: altitude is missing!!
......
......@@ -20,7 +20,7 @@
#include "Array3D.h"
#include "IOExceptions.h"
#include "MapProj.h"
#include "Coords.h"
/**
* @class Grid3DObject
......@@ -116,7 +116,7 @@ class Grid3DObject{
const double& xllcorner, const double& yllcorner,
const double& latitude, const double& longitude, const double& cellsize);
void checkCoordinates(const MapProj& proj);
// void checkCoordinates(const MapProj& proj);
};
#endif
......@@ -45,7 +45,7 @@
*
* It is the responsibility of the plugin to properly convert the units toward the SI as used in MeteoIO (see the MeteoData class for a list of parameters and their units)
*
* Various classes from MeteoIO can prove convenient for use by plugins: for example the MapProj class should be used for geographic coordinates conversions, while the ConfigReader class should be used for getting configuration information from the user's configuration file. Please do NOT implement your own version of this kind of feature in your plugin but exclusively rely on the matching classes of MeteoIO, extending them if necessary.
* Various classes from MeteoIO can prove convenient for use by plugins: for example the Coords class should be used for geographic coordinates conversions, while the ConfigReader class should be used for getting configuration information from the user's configuration file. Please do NOT implement your own version of this kind of feature in your plugin but exclusively rely on the matching classes of MeteoIO, extending them if necessary.
* Some example implementation can be found in ARCIO or A3DIO.
*
* @section plugins_registration Plugins registration
......
......@@ -70,9 +70,9 @@
*
*
* @section proj_sec Geographic projections
* The class MapProj is dedicated to geographic projections. It can use both internal algorithms and projections provided by <a href="http://trac.osgeo.org/proj/">libproj4</a>.
* The class Coords is dedicated to geographic projections. It can use both internal algorithms and projections provided by <a href="http://trac.osgeo.org/proj/">libproj4</a>.
* @subsection coord_conv Coordinate conversion
* The class MapProj takes one or two arguments describing the coordinate system of the input data and then converts back and forth with lat/long WGS84. It can be used to construct a local coordinate system, that is to say a metric grid whose origin is chosen by the user (through the lat/long parameters provided to the constructor). This is useful when working with multiple gridded coordinate system in order to get a common system that would still allow easy distances calculations. See the supported \ref mapproj_types "projections".
* The class Coords takes one or two arguments describing the coordinate system of the input data and then converts back and forth with lat/long WGS84. It can be used to construct a local coordinate system, that is to say a metric grid whose origin is chosen by the user (through the lat/long parameters provided to the constructor). This is useful when working with multiple gridded coordinate system in order to get a common system that would still allow easy distances calculations. See the supported \ref mapproj_types "projections".
* @subsection dist_sec Distances
* A few method used internally to work with custom, local grids are exposed to the user in order to easily compute distances beetwen points (using their lat/long). The algorithms can optionnaly be chosen (otherwise a default choice is used).
*
......
......@@ -30,7 +30,7 @@
#include "Date_IO.h"
#include "DynamicLibrary.h"
#include "BufferedIOHandler.h"
#include "MapProj.h"
#include "Coords.h"
#include "IOInterface.h"
#ifdef _POPC_
......
......@@ -28,7 +28,7 @@ Mutex mutexDemMap;
/**
*
*
*/
IOInterface* DEMLoader::generateIOInterface(
const std::string cDemFile,
......@@ -59,7 +59,7 @@ IOInterface* DEMLoader::generateIOInterface(
}
/**
*
*
*/
const DEMObject& DEMLoader::internal_loadSubDEM(const std::string cDemFile,
const std::string cDemCoordSystem,
......@@ -95,9 +95,13 @@ const DEMObject& DEMLoader::internal_loadSubDEM(const std::string cDemFile,
io->readDEM(dem);
//compute WGS coordinates (considered as the true reference)
double latll, longll, latur, longur;
MapProj mymapproj( cDemCoordSystem, "");
mymapproj.convert_to_WGS84(demXll, demYll, latll, longll);
mymapproj.convert_to_WGS84(demXur, demYur, latur, longur);
Coords coordinate( cDemCoordSystem, "");
coordinate.setXY(demXll, demYll);
latll = coordinate.getLat();
longll = coordinate.getLon();
coordinate.setXY(demXur, demYur);
latur = coordinate.getLat();
longur = coordinate.getLon();
//retrieving grid coordinates of a real world point
unsigned int i0,j0,i1,j1;
dem.WGS84_to_grid(latll, longll, i0,j0);
......@@ -115,7 +119,7 @@ const DEMObject& DEMLoader::internal_loadSubDEM(const std::string cDemFile,
}
/**
*
*
*/
const DEMObject& DEMLoader::internal_loadFullDEM(const std::string cDemFile,
const std::string cDemCoordSystem,
......
......@@ -31,8 +31,10 @@ void loadMeteoAndStationData(double* cMetadata, double* cData,
continue;
double latitude, longitude;
if (metaCoordinateSystem != "WGS84"){