<commit_before>// __BEGIN_LICENSE__
// 
// Copyright (C) 2006 United States Government as represented by the
// Administrator of the National Aeronautics and Space Administration
// (NASA).  All Rights Reserved.
// 
// Copyright 2006 <NAME>. All rights reserved.
// 
// This software is distributed under the NASA Open Source Agreement
// (NOSA), version 1.3.  The NOSA has been approved by the Open Source
// Initiative.  See the file COPYING at the top of the distribution
// directory tree for the complete NOSA document.
// 
// THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
// KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
// LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
// SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
// A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
// THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
// DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
// 
// __END_LICENSE__

/// \file BundleAdjust.h
/// 
/// Optimization classes for carrying out bundle adjustment of many
/// camera images.

#ifndef __VW_CAMERA_CONTROL_NETWORK_H__
#define __VW_CAMERA_CONTROL_NETWORK_H__

// STL
#include <string>
#include <vector>
#include <fstream>

#include <vw/Math/Vector.h>

namespace vw {
namespace camera {

  /// A ControlMeasure identifies a pixel in an image that corresponds
  /// to a control point.  In addition to the location of the pixel, the
  /// control measure also stores the uncertainty of the measurement,
  /// and a identifier for the image from which it was derived.
  class ControlMeasure {
    float m_col, m_row, m_col_sigma, m_row_sigma;
    std::string m_date_time, m_description;
    int m_image_id;
    bool m_ignore;

  public:

    // Constructor
    ControlMeasure( float col, float row, float col_sigma, float row_sigma, int image_id) :
      m_col(col), m_row(row), m_col_sigma(col_sigma), m_row_sigma(row_sigma), m_image_id(image_id) {

      m_date_time = "not recorded";
      m_description = "none";
      m_ignore = false;

    }

    ControlMeasure() : 
      m_col(0), m_row(0), m_col_sigma(0), m_row_sigma(0), m_image_id(0) {

      m_date_time = "not recorded";
      m_description = "none";
      m_ignore = false;

    }

    /// Return the pixel location for this measurement.
    Vector2 position() const { return Vector2(m_col, m_row); }

    /// Set the pixel location for this measurement.
    void set_position(float col, float row) { 
      m_col = col;
      m_row = row;
    }

    /// Set the pixel location for this measurement.
    void set_position(Vector2 position) { 
      m_col = position[0];
      m_row = position[1];
    }

    /// Return the measurement error for this point.
    Vector2 sigma() const { return Vector2(m_col_sigma, m_row_sigma); }

    /// Set the measurement error for this point.
    void set_sigma(float col_sigma, float row_sigma) {
      m_col_sigma = col_sigma;
      m_row_sigma = row_sigma;
    }

    /// Set the measurement error for this point.
    void set_sigma(Vector2 sigma) { 
      m_col_sigma = sigma[0]; 
      m_row_sigma = sigma[1];
    }
 
    /// Return the identifier for the image from which this control
    /// point was derived.  
    int image_id() const { return m_image_id; }

    /// Set the identifier for the image from which this control
    /// point was derived.  Any string value can be used here, but it
    /// should be something that can be used to locate the original
    /// image.
    void set_image_id(int image_id) { m_image_id = image_id; }


    /// Return the description of this control measure.  
    std::string description() const { return m_description; }

    /// Set the description of this control measure.  This typically
    /// includes a description of the source imagery used and the person
    /// or software that was used to make the measurement.
    void set_description(std::string const& description) { m_description = description; }


    /// Query when this control measurement was made.
    std::string date_time() const { return m_date_time; }

    /// Set when this control measurement was made.
    void set_date_time(std::string const& date_time) { m_date_time = date_time; }


    /// Query whether this control measurement should be ignored in a bundle adjustment.
    bool ignore() const { return m_ignore; }

    /// Set whether this control measurement should be ignored in a bundle adjustment.
    void set_ignore(bool state) { m_ignore = state; }
     
  };

  /// Two control meaures are considered equal if their position,
  /// sigma, and image_id are equal.
  inline bool operator==( ControlMeasure const& m1, ControlMeasure const& m2 ) {
    if (m1.position() == m2.position() &&
        m1.sigma() == m2.sigma() &&
        m1.image_id() == m2.image_id()) 
      return true;
    //else
    return false;
  }

  std::ostream& operator<<( std::ostream& os, ControlMeasure const& measure);

  /// ControlPoints are 3D locations in geographic coordinates (lon,
  /// lat, radius) that are associated with a certain number of
  /// ControlMeasures.  Each ControlMeasure is an observation where
  /// this ControlPoint was located in an image.
  class ControlPoint {

    std::string m_id;
    std::vector<ControlMeasure> m_measures;
    bool m_ignore;
    Vector3 m_position;
    Vector3 m_sigma;

  public:
    typedef std::vector<ControlMeasure>::iterator iterator;
    typedef std::vector<ControlMeasure>::const_iterator const_iterator;<commit_msg>Added field that records the ephemereis time at which a control measure is observing. It's important for  pushbroom/pushframe cameras.<commit_after>// __BEGIN_LICENSE__
// 
// Copyright (C) 2006 United States Government as represented by the
// Administrator of the National Aeronautics and Space Administration
// (NASA).  All Rights Reserved.
// 
// Copyright 2006 <NAME>. All rights reserved.
// 
// This software is distributed under the NASA Open Source Agreement
// (NOSA), version 1.3.  The NOSA has been approved by the Open Source
// Initiative.  See the file COPYING at the top of the distribution
// directory tree for the complete NOSA document.
// 
// THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
// KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
// LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
// SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
// A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
// THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
// DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
// 
// __END_LICENSE__

/// \file BundleAdjust.h
/// 
/// Optimization classes for carrying out bundle adjustment of many
/// camera images.

#ifndef __VW_CAMERA_CONTROL_NETWORK_H__
#define __VW_CAMERA_CONTROL_NETWORK_H__

// STL
#include <string>
#include <vector>
#include <fstream>

#include <vw/Math/Vector.h>

namespace vw {
namespace camera {

  /// A ControlMeasure identifies a pixel in an image that corresponds
  /// to a control point.  In addition to the location of the pixel, the
  /// control measure also stores the uncertainty of the measurement,
  /// and a identifier for the image from which it was derived.
  class ControlMeasure {
    float m_col, m_row, m_col_sigma, m_row_sigma;
    std::string m_date_time, m_description;
    double m_ephemeris_time;
    int m_image_id;
    bool m_ignore;

  public:

    // Constructor
    ControlMeasure( float col, float row, float col_sigma, float row_sigma, int image_id) :
      m_col(col), m_row(row), m_col_sigma(col_sigma), m_row_sigma(row_sigma), m_image_id(image_id) {

      m_date_time = "not recorded";
      m_description = "none";
      m_ignore = false;

      m_ephemeris_time = 0;
    }

    ControlMeasure() : 
      m_col(0), m_row(0), m_col_sigma(0), m_row_sigma(0), m_image_id(0) {

      m_date_time = "not recorded";
      m_description = "none";
      m_ignore = false;

      m_ephemeris_time = 0;
    }

    /// Return the pixel location for this measurement.
    Vector2 position() const { return Vector2(m_col, m_row); }

    /// Set the pixel location for this measurement.
    void set_position(float col, float row) { 
      m_col = col;
      m_row = row;
    }

    /// Set the pixel location for this measurement.
    void set_position(Vector2 position) { 
      m_col = position[0];
      m_row = position[1];
    }

    /// Return the measurement error for this point.
    Vector2 sigma() const { return Vector2(m_col_sigma, m_row_sigma); }

    /// Set the measurement error for this point.
    void set_sigma(float col_sigma, float row_sigma) {
      m_col_sigma = col_sigma;
      m_row_sigma = row_sigma;
    }

    /// Set the measurement error for this point.
    void set_sigma(Vector2 sigma) { 
      m_col_sigma = sigma[0]; 
      m_row_sigma = sigma[1];
    }
 
    /// Return the identifier for the image from which this control
    /// point was derived.  
    int image_id() const { return m_image_id; }

    /// Set the identifier for the image from which this control
    /// point was derived.  Any string value can be used here, but it
    /// should be something that can be used to locate the original
    /// image.
    void set_image_id(int image_id) { m_image_id = image_id; }


    /// Return the description of this control measure.  
    std::string description() const { return m_description; }

    /// Set the description of this control measure.  This typically
    /// includes a description of the source imagery used and the person
    /// or software that was used to make the measurement.
    void set_description(std::string const& description) { m_description = description; }


    /// Query when this control measurement was made.
    std::string date_time() const { return m_date_time; }

    /// Set when this control measurement was made.
    void set_date_time(std::string const& date_time) { m_date_time = date_time; }

    /// Query whether this control measurement should be ignored in a bundle adjustment.
    bool ignore() const { return m_ignore; }

    /// Set whether this control measurement should be ignored in a bundle adjustment.
    void set_ignore(bool state) { m_ignore = state; }
     
    /// Query what was the ephemeris time of when this pixel was taken
    double ephemeris_time() const { return m_ephemeris_time; }
    
    /// Set the ephemeris time of when this pixel was taken
    void set_ephemeris_time( double const& time ) { m_ephemeris_time = time; }

  };

  /// Two control meaures are considered equal if their position,
  /// sigma, and image_id are equal.
  inline bool operator==( ControlMeasure const& m1, ControlMeasure const& m2 ) {
    if (m1.position() == m2.position() &&
        m1.sigma() == m2.sigma() &&
        m1.image_id() == m2.image_id() && 
	m1.ephemeris_time() == m2.ephemeris_time() ) 
      return true;
    //else
    return false;
  }

  std::ostream& operator<<( std::ostream& os, ControlMeasure const& measure);

  /// ControlPoints are 3D locations in geographic coordinates (lon,
  /// lat, radius) that are associated with a certain number of
  /// ControlMeasures.  Each ControlMeasure is an observation where
  /// this ControlPoint was located in an image.
  class ControlPoint {

    std::string m_id;
    std::vector<ControlMeasure> m_measures;
    bool m_ignore;
    Vector3 m_position;
    Vector3 m_sigma;

  public:
    typedef std::vector<ControlMeasure>::iterator iterator;
    typedef std::vector<ControlMeasure>::const_iterator const_iterator;
{'fraction_non_alphanumeric': 0.09025579604756609, 'fraction_numerical': 0.006501839336127984, 'mean_word_length': 3.080279232111693, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6935644', 'n_tokens_mistral': 3489, 'n_tokens_neox': 3327, 'n_words': 1275}