@comment $Id: obsdata.texi,v 1.3 2003/03/05 17:15:07 cepek Exp $

@noindent The Gama observation data structures are designed 
to enable adjustment of any combination of possibly correlated
observations. 
@c
At its very early stage Gama was limited to adjustment of uncorrelated
observations. Only directions and distances were available and
observable's weight was stored together with the observed value in a
single object. A single array of pointers to observation objects was
sufficient for handling all observations. So called @emph{orientation
shifts} corresponding to directions measured form a point were stored
together with coordinations in @emph{point objects}.


@image{obsdata-fig,14cm} 


To enable adjustment of possibly correlated observations (like angles
derived from observed directions or already adjusted coordinates from
a previous adjustment) Gama has come with the concept of
@emph{clusters}. Cluster is an object with a common
variance-covariance matrix and a list of pointers to observation
objects (distances, directions, angles, etc.). Weights were removed
from observation objects and replaced with a pointer to the cluster to
which the observation belong. All clusters are joined in a common
object @code{ObservationData}; similarly to observations, each cluster
contains a pointer to its parent @code{Observation Data} object.
@emph{Orientation shifts} were separated from coordinates and are
stored in the cluster containing the bunch of directions and thus
number of orientations is not limited to one for a point.



This organisation of observational information has proved to be
effective.  Template classes @code{ObservationData} and @code{Cluster}
are used as base classes both in @code{gama-local} and @code{gama-w3}

@verbatim
template <class Observation>
  class ObservationData
  {
  public:    
    ClusterList<Observation>  CL;
    
    ObservationData();
    ObservationData(const ObservationData& cod);
    ~ObservationData();
    
    ObservationData& operator=(const ObservationData& cod);   
    template <class P> void for_each(const P& p) const;
  };

template <class Observation>  
  class Cluster 
  {
  public:
    const ObservationData<Observation>*  observation_data;
    ObservationList<Observation>         observation_list;
    GaMaLib::Cov                         covariance_matrix;  
    
    Cluster(const ObservationData<Observation>* od);
    virtual ~Cluster();
    
    virtual Cluster* clone(const ObservationData<Observation>*) const = 0;
    double stdDev(int i) const;
    int size() const;
    void update();
    int  activeCount() const;
    GaMaLib::Cov  activeCov() const; 
  };

@end verbatim

@noindent
The following template class @code{PointBase} for handling point
information is used in @code{gama-w3}. The template class
@code{PointBase} relies internally on @code{std::map} container but
comes with its own interface (in @code{gama-local} @code{std::map}
was used directly for storing points).

@verbatim
template <class Point>
  class PointBase
  {
    typedef std::map<typename Point::Name, Point*>  Points;

  public:    
    PointBase();
    PointBase(const PointBase& cod);
    ~PointBase();
    
    PointBase& operator=(const PointBase& cod);
    void put(const Point&);
    void put(Point*);
    Point*       find(const typename Point::Name&);
    const Point* find(const typename Point::Name&) const;
    void erase(const typename Point::Name&);
    void erase();
    
    class const_iterator;
    const_iterator  begin();
    const_iterator  end  ();

    class iterator;
    iterator  begin();
    iterator  end  ();
  };

@end verbatim

@noindent
Template classes @code{ObservationData} and @code{PointBase} are
defined in namespace @code{GNU_gama} and are located in the source
directory @code{gnu_gama}. 




