~ubuntu-branches/ubuntu/hardy/libterralib/hardy

« back to all changes in this revision

Viewing changes to src/terralib/kernel/TeQuerierImpl.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2005-11-25 22:32:59 UTC
  • Revision ID: james.westby@ubuntu.com-20051125223259-3zubal8ux4ki4fjg
Tags: upstream-3.0.3b2
Import upstream version 3.0.3b2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/************************************************************************************
 
2
TerraLib - a library for developing GIS applications.
 
3
Copyright � 2001-2004 INPE and Tecgraf/PUC-Rio.
 
4
 
 
5
This code is part of the TerraLib library.
 
6
This library is free software; you can redistribute it and/or
 
7
modify it under the terms of the GNU Lesser General Public
 
8
License as published by the Free Software Foundation; either
 
9
version 2.1 of the License, or (at your option) any later version.
 
10
 
 
11
You should have received a copy of the GNU Lesser General Public
 
12
License along with this library.
 
13
 
 
14
The authors reassure the license terms regarding the warranties.
 
15
They specifically disclaim any warranties, including, but not limited to,
 
16
the implied warranties of merchantability and fitness for a particular purpose.
 
17
The library provided hereunder is on an "as is" basis, and the authors have no
 
18
obligation to provide maintenance, support, updates, enhancements, or modifications.
 
19
In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
 
20
indirect, special, incidental, or consequential damages arising out of the use
 
21
of this library and its documentation.
 
22
*************************************************************************************/
 
23
 
 
24
#include "TeQuerierImpl.h"
 
25
#include "TeTemporalSeries.h"
 
26
 
 
27
        
 
28
TeQuerierImpl::TeQuerierImpl(TeQuerierParams& par): params_(par), filledSerie_(false)
 
29
{
 
30
        ts_ = 0;
 
31
        if(par.chronon()!=TeNOCHRONON) //if there is a chronon, build ts
 
32
        {
 
33
                TeGroupingAttr::iterator it = par.groupAttr().begin();
 
34
                if(it!=par.groupAttr().end())
 
35
                        ts_ = new TeTemporalSeries(par.theme(), par.objId(), par.chronon(), it->first.name_, it->first.name_, it->second, it->second);
 
36
                else
 
37
                        ts_ = new TeTemporalSeries(par.chronon(), par.theme());
 
38
                ts_->buildFrameIntervals();
 
39
        }
 
40
}
 
41
 
 
42
TeQuerierImpl::~TeQuerierImpl() 
 
43
{       
 
44
        if(ts_)
 
45
                delete (ts_);
 
46
}
 
47
 
 
48
bool 
 
49
TeQuerierImpl::loadTimeFrameInstances(int frame)
 
50
{
 
51
        if(frame>-1) 
 
52
        {
 
53
                TeTSEntry ent;
 
54
                if(!getTSEntry(ent, frame))
 
55
                        return false;
 
56
                
 
57
                return(loadInstances(&ent));
 
58
        }
 
59
        else
 
60
                return(loadInstances());
 
61
}
 
62
 
 
63
bool 
 
64
TeQuerierImpl::getTSEntry(TeTSEntry& tsEntry, int frame)
 
65
{
 
66
        if(!ts_)
 
67
                return false;
 
68
 
 
69
        return(ts_->getTSEntry(tsEntry, frame)); 
 
70
}
 
71
 
 
72
int 
 
73
TeQuerierImpl::getNumTimeFrames()
 
74
{
 
75
        if(!ts_)
 
76
                return 0;
 
77
 
 
78
        return (ts_->numTimeFrames());
 
79
}
 
80
 
 
81
bool 
 
82
TeQuerierImpl::getTS(TeTemporalSeries& ts)
 
83
{
 
84
        if(!ts_)
 
85
                return false;
 
86
        
 
87
        ts = (*ts_);
 
88
        return true;
 
89
}
 
90
 
 
91
TeTSParams& 
 
92
TeQuerierImpl::getTSParams() 
 
93
 
94
        return (ts_->TSparams_); 
 
95
}