16 int TiePoint::s_runningId = 1;
19 : m_type (UNASSIGNED),
26 : m_type (copy.m_type),
28 m_gcpId (copy.m_gcpId)
30 for (
size_t i=0; i<copy.
m_images.size(); ++i)
41 : m_type (UNASSIGNED),
73 NEWMAT::SymmetricMatrix& cov)
const 82 imageId =
m_images[index]->getImageId();
90 const NEWMAT::SymmetricMatrix& cov)
95 for (
size_t i=0; i<
m_images.size(); ++i)
97 if (
m_images[i]->getImageId().compare(image->getImageId()) == 0)
129 xmsg<<__FILE__<<
": TiePoint(JSON) --";
135 string tpType = json_node[
"type"].asString();
148 xmsg<<
"Tiepoint JSON field \"type\" must be specified as 'M', 'A', or 'G'.";
154 m_gcpId = json_node[
"gcpId"].asString();
157 const Json::Value& imagePoints = json_node[
"imagePoints"];
158 if (!imagePoints || (imagePoints.size() < 1))
160 xmsg<<
"Tiepoint JSON field \"imagePoints\" not found or is empty!";
165 for (
int i=0; i<imagePoints.size(); ++i)
167 const Json::Value& p = imagePoints[i];
168 if (!p || !(p[
"imageId"].isString()) || !(p[
"x"]) || !(p[
"y"]))
170 xmsg<<
"Tiepoint JSON field \"imagePoints\" entry is ill-formed or not complete:\n" 171 <<p.toStyledString()<<endl;
175 string imageId = p[
"imageId"].asString();
176 string filename = p[
"filename"].asString();
177 shared_ptr<Image> image (
new Image(imageId, filename));
180 ossimDpt xy(p[
"x"].asDouble(), p[
"y"].asDouble());
183 const Json::Value& covariance = p[
"covariance"];
184 if (covariance.size() == 3)
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();
201 string tpType = json_node[
"type"].asString();
205 json_node[
"type"] =
"M";
208 json_node[
"type"] =
"A";
211 json_node[
"type"] =
"G";
214 json_node[
"type"] =
"UNNASSIGNED";
218 Json::Value jsonList (Json::arrayValue);
222 jsonList[i][
"filename"] =
m_images[i]->getFilename();
223 jsonList[i][
"imageId"] =
m_images[i]->getImageId();
229 Json::Value covJson (Json::arrayValue);
233 jsonList[i][
"covariance"] = covJson;
236 json_node[
"imagePoints"] = jsonList;
243 out << node.toStyledString();
virtual void saveJSON(Json::Value &json) const
std::vector< NEWMAT::SymmetricMatrix > m_covariances
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
This code was derived from https://gist.github.com/mshockwave.
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.
std::vector< ossimDpt > m_imagePoints
void setTiePointId(const std::string &id)
Class representing an Image as used by ossim-msp services.
void setGcpId(const std::string &id)
std::vector< std::shared_ptr< Image > > m_images
virtual void loadJSON(const Json::Value &json)
Class for representing a single tiepoint on two or more images.
virtual std::ostream & print(std::ostream &out) const
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.
std::basic_ostream< char > ostream
Base class for char output streams.