OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Types | Public Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
ossim::TiePoint Class Reference

Class for representing a single tiepoint on two or more images. More...

#include <TiePoint.h>

Inheritance diagram for ossim::TiePoint:
ossim::JsonInterface ATP::AutoTiePoint

Public Types

enum  Type { UNASSIGNED, MANUAL, AUTO, GCP }
 

Public Member Functions

 TiePoint ()
 
 TiePoint (const TiePoint &copy)
 
 TiePoint (const Json::Value &tp_json_node)
 Creates new tiepoint from JSON object formatted as: { "id": <unsigned int>="">, // may be ignored if not valid "type": "M"|"A"|"G" For “manual”, “auto”, or “GCP-associated” "imagePoints: [ { "imageId": <string>, "x": <double>, "y": <double>, "covariance": [ cxx, cyy, cxy ], "gcpId": <string> Only if associated with a GCP } ] }. More...
 
virtual ~TiePoint ()
 
unsigned int getImageCount () const
 
const std::string & getTiePointId () const
 
void setTiePointId (const std::string &id)
 
void getImagePoint (unsigned int index, std::string &imageId, ossimDpt &imagePoint, NEWMAT::SymmetricMatrix &cov) const
 Fetches the image point coordinates along with image ID and GCP ID if available. More...
 
void setImagePoint (std::shared_ptr< Image > image, const ossimDpt &imagePoint, const NEWMAT::SymmetricMatrix &cov)
 Sets image point value and associated measurement covariance for specified image ID. More...
 
Type getType () const
 
void setType (Type t)
 
const std::string & getGcpId () const
 
void setGcpId (const std::string &id)
 
virtual void loadJSON (const Json::Value &json)
 
virtual void saveJSON (Json::Value &json) const
 
virtual std::ostream & print (std::ostream &out) const
 
- Public Member Functions inherited from ossim::JsonInterface
 JsonInterface ()
 
virtual ~JsonInterface ()
 

Protected Attributes

Type m_type
 
std::string m_tiePointId
 
std::vector< std::shared_ptr< Image > > m_images
 
std::vector< ossimDptm_imagePoints
 
std::vector< NEWMAT::SymmetricMatrix > m_covariances
 
double m_gsd
 
std::string m_gcpId
 

Static Protected Attributes

static int s_runningId = 1
 

Friends

std::ostream & operator<< (std::ostream &out, const TiePoint &tp)
 

Detailed Description

Class for representing a single tiepoint on two or more images.

It also represents image-points associated with a ground control point.

Definition at line 28 of file TiePoint.h.

Member Enumeration Documentation

◆ Type

Enumerator
UNASSIGNED 
MANUAL 
AUTO 
GCP 

Definition at line 32 of file TiePoint.h.

32  {
33  UNASSIGNED,
34  MANUAL, //> The point was created or edited manually and contains at least a pair of image points
35  AUTO, //> Result of auto tie point generation and contains at least a pair of image points
36  GCP //> point is associated with a manually-entered ground control. Possibly multiple image points
37  };

Constructor & Destructor Documentation

◆ TiePoint() [1/3]

ossim::TiePoint::TiePoint ( )

Definition at line 18 of file TiePoint.cpp.

19 : m_type (UNASSIGNED),
20  m_gsd (0.0)
21 {
22 
23 }
double m_gsd
Definition: TiePoint.h:118

◆ TiePoint() [2/3]

ossim::TiePoint::TiePoint ( const TiePoint copy)

Definition at line 25 of file TiePoint.cpp.

References m_covariances, m_imagePoints, and m_images.

26 : m_type (copy.m_type),
27  m_gsd (copy.m_gsd),
28  m_gcpId (copy.m_gcpId)
29 {
30  for (size_t i=0; i<copy.m_images.size(); ++i)
31  m_images.push_back(copy.m_images[i]);
32 
33  for (size_t i=0; i<copy.m_imagePoints.size(); ++i)
34  m_imagePoints.push_back(copy.m_imagePoints[i]);
35 
36  for (size_t i=0; i<copy.m_covariances.size(); ++i)
37  m_covariances.push_back(copy.m_covariances[i]);
38 }
std::vector< NEWMAT::SymmetricMatrix > m_covariances
Definition: TiePoint.h:117
double m_gsd
Definition: TiePoint.h:118
std::vector< ossimDpt > m_imagePoints
Definition: TiePoint.h:116
std::vector< std::shared_ptr< Image > > m_images
Definition: TiePoint.h:115
std::string m_gcpId
Definition: TiePoint.h:119

◆ TiePoint() [3/3]

ossim::TiePoint::TiePoint ( const Json::Value &  tp_json_node)

Creates new tiepoint from JSON object formatted as: { "id": <unsigned int>="">, // may be ignored if not valid "type": "M"|"A"|"G" For “manual”, “auto”, or “GCP-associated” "imagePoints: [ { "imageId": <string>, "x": <double>, "y": <double>, "covariance": [ cxx, cyy, cxy ], "gcpId": <string> Only if associated with a GCP } ] }.

Definition at line 40 of file TiePoint.cpp.

References loadJSON().

41 : m_type (UNASSIGNED),
42  m_gsd (0.0)
43 {
44  loadJSON(json_node);
45 }
double m_gsd
Definition: TiePoint.h:118
virtual void loadJSON(const Json::Value &json)
Definition: TiePoint.cpp:126

◆ ~TiePoint()

ossim::TiePoint::~TiePoint ( )
virtual

Definition at line 47 of file TiePoint.cpp.

References m_covariances, m_imagePoints, and m_images.

48 {
49  m_images.clear();
50  m_imagePoints.clear();
51  m_covariances.clear();
52 }
std::vector< NEWMAT::SymmetricMatrix > m_covariances
Definition: TiePoint.h:117
std::vector< ossimDpt > m_imagePoints
Definition: TiePoint.h:116
std::vector< std::shared_ptr< Image > > m_images
Definition: TiePoint.h:115

Member Function Documentation

◆ getGcpId()

const std::string& ossim::TiePoint::getGcpId ( ) const
inline

Definition at line 92 of file TiePoint.h.

References m_gcpId.

92 { return m_gcpId; }
std::string m_gcpId
Definition: TiePoint.h:119

◆ getImageCount()

unsigned int ossim::TiePoint::getImageCount ( ) const
inline

Definition at line 63 of file TiePoint.h.

References m_images.

63 { return m_images.size(); }
std::vector< std::shared_ptr< Image > > m_images
Definition: TiePoint.h:115

◆ getImagePoint()

void ossim::TiePoint::getImagePoint ( unsigned int  index,
std::string &  imageId,
ossimDpt imagePoint,
NEWMAT::SymmetricMatrix &  cov 
) const

Fetches the image point coordinates along with image ID and GCP ID if available.

Parameters
indexInout index into the list of images containing this tiepoint
imageIdOutput image ID for the ccorresponding image point
imagePointimage coordinates
covimage point measurement covariance in (x, y) coordinates

Definition at line 70 of file TiePoint.cpp.

References m_covariances, m_imagePoints, m_images, and ossimDpt::makeNan().

74 {
75  // Search the PB index list for entry:
76  imagePoint.makeNan();
77  imageId.clear();
78 
79  if (index >= m_images.size())
80  return;
81 
82  imageId = m_images[index]->getImageId();
83  imagePoint = m_imagePoints[index];
84  if (m_covariances.size() > index)
85  cov = m_covariances[index];
86 }
std::vector< NEWMAT::SymmetricMatrix > m_covariances
Definition: TiePoint.h:117
std::vector< ossimDpt > m_imagePoints
Definition: TiePoint.h:116
std::vector< std::shared_ptr< Image > > m_images
Definition: TiePoint.h:115
void makeNan()
Definition: ossimDpt.h:65

◆ getTiePointId()

const std::string& ossim::TiePoint::getTiePointId ( ) const
inline

Definition at line 65 of file TiePoint.h.

References m_tiePointId.

65 { return m_tiePointId; }
std::string m_tiePointId
Definition: TiePoint.h:114

◆ getType()

Type ossim::TiePoint::getType ( ) const
inline

Definition at line 89 of file TiePoint.h.

References m_type.

89 { return m_type; }

◆ loadJSON()

void ossim::TiePoint::loadJSON ( const Json::Value &  json)
virtual

Implements ossim::JsonInterface.

Definition at line 126 of file TiePoint.cpp.

References AUTO, GCP, m_covariances, m_gcpId, m_imagePoints, m_images, m_type, MANUAL, and setTiePointId().

Referenced by TiePoint().

127 {
128  ostringstream xmsg;
129  xmsg<<__FILE__<<": TiePoint(JSON) --";
130 
131  // ID
132  setTiePointId(json_node["id"].asString());
133 
134  // Type
135  string tpType = json_node["type"].asString();
136  switch (tpType[0])
137  {
138  case 'M':
140  break;
141  case 'A':
143  break;
144  case 'G':
146  break;
147  default:
148  xmsg<<"Tiepoint JSON field \"type\" must be specified as 'M', 'A', or 'G'.";
149  throw ossimException(xmsg.str());
150  }
151 
152  // Read the GCP ID if present:
153  if (m_type == TiePoint::GCP)
154  m_gcpId = json_node["gcpId"].asString();
155 
156  // Image points
157  const Json::Value& imagePoints = json_node["imagePoints"];
158  if (!imagePoints || (imagePoints.size() < 1))
159  {
160  xmsg<<"Tiepoint JSON field \"imagePoints\" not found or is empty!";
161  throw ossimException(xmsg.str());
162  }
163 
164  // Loop over points on each image:
165  for (int i=0; i<imagePoints.size(); ++i)
166  {
167  const Json::Value& p = imagePoints[i];
168  if (!p || !(p["imageId"].isString()) || !(p["x"]) || !(p["y"]))
169  {
170  xmsg<<"Tiepoint JSON field \"imagePoints\" entry is ill-formed or not complete:\n"
171  <<p.toStyledString()<<endl;
172  throw ossimException(xmsg.str());
173  }
174 
175  string imageId = p["imageId"].asString();
176  string filename = p["filename"].asString();
177  shared_ptr<Image> image (new Image(imageId, filename));
178  m_images.push_back(image);
179 
180  ossimDpt xy(p["x"].asDouble(), p["y"].asDouble());
181  m_imagePoints.push_back(xy);
182 
183  const Json::Value& covariance = p["covariance"];
184  if (covariance.size() == 3)
185  {
186  NEWMAT::SymmetricMatrix c(2);
187  c(1, 1) = covariance[0].asDouble();
188  c(2, 2) = covariance[1].asDouble();
189  c(1, 2) = covariance[2].asDouble();
190  m_covariances.push_back(c);
191  }
192  }
193 }
std::vector< NEWMAT::SymmetricMatrix > m_covariances
Definition: TiePoint.h:117
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
std::vector< ossimDpt > m_imagePoints
Definition: TiePoint.h:116
void setTiePointId(const std::string &id)
Definition: TiePoint.cpp:54
std::vector< std::shared_ptr< Image > > m_images
Definition: TiePoint.h:115
std::string m_gcpId
Definition: TiePoint.h:119

◆ print()

std::ostream & ossim::TiePoint::print ( std::ostream &  out) const
virtual

Reimplemented in ATP::AutoTiePoint.

Definition at line 239 of file TiePoint.cpp.

References saveJSON().

240 {
241  Json::Value node;
242  saveJSON(node);
243  out << node.toStyledString();
244  return out;
245 }
virtual void saveJSON(Json::Value &json) const
Definition: TiePoint.cpp:195

◆ saveJSON()

void ossim::TiePoint::saveJSON ( Json::Value &  json) const
virtual

Implements ossim::JsonInterface.

Reimplemented in ATP::AutoTiePoint.

Definition at line 195 of file TiePoint.cpp.

References AUTO, GCP, m_covariances, m_imagePoints, m_images, m_tiePointId, m_type, and MANUAL.

Referenced by print().

196 {
197  // ID
198  json_node["id"] = m_tiePointId;
199 
200  // Type
201  string tpType = json_node["type"].asString();
202  switch (m_type)
203  {
204  case TiePoint::MANUAL:
205  json_node["type"] = "M";
206  break;
207  case TiePoint::AUTO:
208  json_node["type"] = "A";
209  break;
210  case TiePoint::GCP:
211  json_node["type"] = "G";
212  break;
213  default:
214  json_node["type"] = "UNNASSIGNED";
215  }
216 
217  // Image points
218  Json::Value jsonList (Json::arrayValue);
219  // Loop over points on each image:
220  for (int i=0; i<m_imagePoints.size(); ++i)
221  {
222  jsonList[i]["filename"] = m_images[i]->getFilename();
223  jsonList[i]["imageId"] = m_images[i]->getImageId();
224  jsonList[i]["x"] = m_imagePoints[i].x;
225  jsonList[i]["y"] = m_imagePoints[i].y;
226 
227  if (i<m_covariances.size())
228  {
229  Json::Value covJson (Json::arrayValue);
230  covJson[0] = m_covariances[i](1,1);
231  covJson[1] = m_covariances[i](2,2);
232  covJson[2] = m_covariances[i](1,2);
233  jsonList[i]["covariance"] = covJson;
234  }
235  }
236  json_node["imagePoints"] = jsonList;
237 }
std::vector< NEWMAT::SymmetricMatrix > m_covariances
Definition: TiePoint.h:117
std::vector< ossimDpt > m_imagePoints
Definition: TiePoint.h:116
std::string m_tiePointId
Definition: TiePoint.h:114
std::vector< std::shared_ptr< Image > > m_images
Definition: TiePoint.h:115

◆ setGcpId()

void ossim::TiePoint::setGcpId ( const std::string &  id)

Definition at line 120 of file TiePoint.cpp.

References GCP, m_gcpId, and m_type.

121 {
122  m_gcpId = id;
123  m_type = GCP;
124 }
std::string m_gcpId
Definition: TiePoint.h:119

◆ setImagePoint()

void ossim::TiePoint::setImagePoint ( std::shared_ptr< Image image,
const ossimDpt imagePoint,
const NEWMAT::SymmetricMatrix &  cov 
)

Sets image point value and associated measurement covariance for specified image ID.

If the image ID is not found, it will be added as new observation.

Definition at line 88 of file TiePoint.cpp.

References m_covariances, m_imagePoints, and m_images.

91 {
92  bool found = false;
93 
94  // Possible edit of existing point?
95  for (size_t i=0; i<m_images.size(); ++i)
96  {
97  if (m_images[i]->getImageId().compare(image->getImageId()) == 0)
98  {
99  found = true;
100  if (i >= m_imagePoints.size())
101  {
102  // This shouldn't happen, but go ahead and resize for this image:
103  m_imagePoints.resize(i+1);
104  m_covariances.resize(i+1);
105  }
106  m_imagePoints[i] = imagePoint;
107  m_covariances[i] = cov;
108  break;
109  }
110  }
111 
112  if (!found)
113  {
114  m_images.push_back(image);
115  m_imagePoints.push_back(imagePoint);
116  m_covariances.push_back(cov);
117  }
118 }
std::vector< NEWMAT::SymmetricMatrix > m_covariances
Definition: TiePoint.h:117
std::vector< ossimDpt > m_imagePoints
Definition: TiePoint.h:116
std::vector< std::shared_ptr< Image > > m_images
Definition: TiePoint.h:115

◆ setTiePointId()

void ossim::TiePoint::setTiePointId ( const std::string &  id)

Definition at line 54 of file TiePoint.cpp.

References m_tiePointId, and s_runningId.

Referenced by loadJSON().

55 {
56  if (id.empty())
57  {
58  // Generate ID based on date/time:
59  ostringstream tp1;
60  tp1<<"TP"<<s_runningId++;
61  m_tiePointId = tp1.str();
62  }
63  else
64  {
65  // Only accept if there is no ID existing:
66  m_tiePointId = id;
67  }
68 }
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
static int s_runningId
Definition: TiePoint.h:120
std::string m_tiePointId
Definition: TiePoint.h:114

◆ setType()

void ossim::TiePoint::setType ( Type  t)
inline

Definition at line 90 of file TiePoint.h.

References m_type.

90 { m_type = t; }

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const TiePoint tp 
)
friend

Definition at line 108 of file TiePoint.h.

109  { return tp.print(out); }

Member Data Documentation

◆ m_covariances

std::vector<NEWMAT::SymmetricMatrix> ossim::TiePoint::m_covariances
protected

Definition at line 117 of file TiePoint.h.

Referenced by getImagePoint(), loadJSON(), saveJSON(), setImagePoint(), TiePoint(), and ~TiePoint().

◆ m_gcpId

std::string ossim::TiePoint::m_gcpId
protected

Definition at line 119 of file TiePoint.h.

Referenced by getGcpId(), loadJSON(), and setGcpId().

◆ m_gsd

double ossim::TiePoint::m_gsd
protected

Definition at line 118 of file TiePoint.h.

◆ m_imagePoints

std::vector<ossimDpt> ossim::TiePoint::m_imagePoints
protected

◆ m_images

std::vector< std::shared_ptr<Image> > ossim::TiePoint::m_images
protected

◆ m_tiePointId

std::string ossim::TiePoint::m_tiePointId
protected

Definition at line 114 of file TiePoint.h.

Referenced by getTiePointId(), ATP::AutoTiePoint::print(), saveJSON(), and setTiePointId().

◆ m_type

Type ossim::TiePoint::m_type
protected

Definition at line 113 of file TiePoint.h.

Referenced by getType(), loadJSON(), saveJSON(), setGcpId(), and setType().

◆ s_runningId

int ossim::TiePoint::s_runningId = 1
staticprotected

Definition at line 120 of file TiePoint.h.

Referenced by setTiePointId().


The documentation for this class was generated from the following files: