/*************************************************************************** * Copyright (C) 2005 by Nicolas PASCAL * * nicolas.pascal@icare.univ-lille1.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include #include using namespace std; #include "filedata.h" #include "Hdf_file.hpp" #include "filedataexception.h" #include "statistic.h" #include "filedatareader.h" FileData::FileData(const string & name /*= ""*/, const string & mode /*= "r"*/):name(name),mode(mode),date(NULL) { if ( mode == "r" && !exists_file(name) ) { bad_file e(name); throw e; } if ( mode == "r" && ! file_can_be_opened_as(name,mode) ) { bad_file_opening_mode e(name); throw e; } date = new Date(); } FileData::~FileData() { delete date, date = NULL; } FileData::FileData( const FileData & fd ) { this->name=fd.name; this->mode=fd.mode; this->date=fd.date; } FileData &FileData::operator= (const FileData &fd) { if (&fd == this) return *this; // protect against self assignation this->name=fd.name; this->mode=fd.mode; this->date=fd.date; return *this; } const bool FileData::contain_time( const double time ) const { // printf( "t=%.15g t_min=.15g t_max=.15g\n", time, date->get_TAI93_time(), date->get_TAI93_time() + time_coverage); if (time==-1.) return true; double start = date->get_TAI93_time(); return ( time>=start && time<=start+time_coverage ); } /* void * FileData::read_data(const char sds_name[], int * start, int * stride, int * edges, int rank) { }*/ void FileData::check_geolocation(const float lat, const float lon) { if (lat < -90 || lat > 90) { g_exception e(__FILE__,__LINE__, "Invalid latitude " + MyTools::to_string(lat) + ". Must be in range [-90, 90]"); throw e; } if (lon < -180 || lon > 180) { g_exception e(__FILE__,__LINE__, "Invalid longitude " + MyTools::to_string(lon) + ". Must be in range [-180, 180]"); throw e; } }