Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

omglocality.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Tim Sutton   *
00003  *   tim@linfiniti.com   *
00004  *                                                                         *
00005  *   This program is free software{} you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation{} either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY{} without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program{} if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #include "omglocality.h"
00022 
00023 OmgLocality::OmgLocality() :
00024   mId(""),
00025   mLabel(""),
00026   mLatitude(0),
00027   mLongitude(0),
00028   mAbundance(1) //presume presence
00029 {
00030 
00031 }
00032 OmgLocality::~OmgLocality()
00033 {
00034 
00035 }
00036 //
00037 // accessors
00038 //
00039 QString OmgLocality::id() const
00040 {
00041   return mId;
00042 }
00043 QString OmgLocality::label() const
00044 {
00045   return mLabel;
00046 }
00047 float OmgLocality::latitude() const
00048 {
00049   return mLatitude;
00050 }
00051 float OmgLocality::longitude() const
00052 {
00053   return mLongitude;
00054 }
00055 float OmgLocality::abundance() const
00056 {
00057   return mAbundance;
00058 }
00059 OmgSampleVector OmgLocality::samples() const
00060 {
00061   return mSamples;
00062 }
00063 
00064 //
00065 // Mutators
00066 //
00067 void OmgLocality::setId(QString theId)
00068 {
00069   mId = theId;
00070 }
00071 void OmgLocality::setLabel(QString theLabel)
00072 {
00073   mLabel = theLabel;
00074 }
00075 void OmgLocality::setLatitude(float theLatitude)
00076 {
00077   mLatitude = theLatitude;
00078 }
00079 void OmgLocality::setLongitude(float theLongitude)
00080 {
00081   mLongitude = theLongitude;
00082 }
00083 void OmgLocality::setAbundance(float theAbundance)
00084 {
00085   mAbundance = theAbundance;
00086 }
00087 void OmgLocality::setSamples(OmgSampleVector theSamples)
00088 {
00089   mSamples = theSamples;
00090 }
00091 
00092 //helper functions
00093 QString OmgLocality::toString()
00094 {
00095   QString myString;
00096   myString = mId + " " + mLabel +  " " + QString::number(mLongitude) + " " + QString::number(mLatitude);
00097   //loop through all the samples...
00098   for (int i=0;i<mSamples.count();i++)
00099   {
00100     myString+=" " + QString::number(mSamples.at(i));
00101   }
00102   return myString;
00103 }
00104 QString OmgLocality::toHtml()
00105 {
00106   //NOTE we assume that you will be adding html to a table
00107   QString myString;
00108   myString="        "; //spacer to prettify html
00109   myString+="<tr><td>\"";
00110   myString+=mId;
00111   myString+="</td><td>";
00112   myString+=QString::number(mLongitude);
00113   myString+="</td><td>";
00114   myString+=QString::number(mLatitude);
00115   myString+="</td><td>";
00116   //loop through all the samples...
00117   for (int i=0;i<mSamples.count();i++)
00118   {
00119     myString+=QString::number(mSamples.at(i)) + " ";
00120   }
00121   myString+="</td></tr>";
00122   return myString;
00123 
00124 }
00125 QString OmgLocality::toXml()
00126 {
00127   QString myString;
00128   myString="        "; //spacer to prettify xml
00129   myString+="<Point Id=\"" + mId + "\" X=\"";
00130   myString+=QString::number(mLongitude);
00131   myString+="\" Y=\"";
00132   myString+=QString::number(mLatitude);
00133   // this should be ignored by the omlib
00134   // but is used for de/serialising 
00135   // localities in the desktop so dont remove it
00136   myString+="\" Abundance=\"";
00137   myString+=QString::number(mAbundance);
00138   myString+="\" Sample=\"";
00139   //loop through all the samples...
00140   for (int i=0;i<mSamples.count();i++)
00141   {
00142     if (i>0) myString += " ";
00143     myString+=QString::number(mSamples.at(i)) ;
00144   }
00145   myString+="\"/>\n";
00146   return myString;
00147 }
00148 
00149 bool OmgLocality::isValid()
00150 {
00151   if (mId.isEmpty())
00152   {
00153     return false;
00154   }
00155   if (mLabel.isEmpty())
00156   {
00157     return false;
00158   }
00159   if (mLatitude==0)
00160   {
00161     return false;
00162   }
00163   if (mLongitude==0)
00164   {
00165     return false;
00166   }
00167   return true;
00168 }
00169     
00170 

Generated on Mon Apr 28 15:08:48 2008 for openModellerDesktop by  doxygen 1.4.1-20050210