30 const tinyxml2::XMLElement* sub_node = xml_node.FirstChildElement(
"geometry");
34 sub_node = sub_node->NextSiblingElement(
"geometry");
42 CHECK_NOTNULL(curve_segment);
51 int checker = tinyxml2::XML_SUCCESS;
53 checker += xml_node.QueryDoubleAttribute(
"sOffset", &s);
54 checker += xml_node.QueryDoubleAttribute(
"x", &ptx);
55 checker += xml_node.QueryDoubleAttribute(
"y", &pty);
56 checker += xml_node.QueryDoubleAttribute(
"length", &length);
58 if (checker == tinyxml2::XML_SUCCESS) {
59 curve_segment->set_s(s);
61 double output_x = 0.0;
62 double output_y = 0.0;
63 double output_z = 0.0;
65 WGS84ToUTM(ptx, pty, ptz, &output_x, &output_y, &output_z);
67 curve_segment->mutable_start_position()->set_x(output_x);
68 curve_segment->mutable_start_position()->set_y(output_y);
69 curve_segment->set_length(length);
72 const auto sub_node = xml_node.FirstChildElement(
"pointSet");
74 PbLineSegment* line_segment = curve_segment->mutable_line_segment();
79 std::string err_msg =
"Error geometry object";
85 const tinyxml2::XMLElement* sub_node = xml_node.FirstChildElement(
"point");
90 int checker = tinyxml2::XML_SUCCESS;
91 checker += sub_node->QueryDoubleAttribute(
"x", &ptx);
92 checker += sub_node->QueryDoubleAttribute(
"y", &pty);
94 if (checker != tinyxml2::XML_SUCCESS) {
95 std::string err_msg =
"Error parsing geometry point attributes";
99 PbPoint3D* pt = line_segment->add_point();
100 double output_x = 0.0;
101 double output_y = 0.0;
102 double output_z = 0.0;
103 WGS84ToUTM(ptx, pty, ptz, &output_x, &output_y, &output_z);
107 sub_node = sub_node->NextSiblingElement(
"point");
115 const tinyxml2::XMLElement* sub_node =
116 xml_node.FirstChildElement(
"cornerGlobal");
121 int checker = tinyxml2::XML_SUCCESS;
122 checker += sub_node->QueryDoubleAttribute(
"x", &ptx);
123 checker += sub_node->QueryDoubleAttribute(
"y", &pty);
124 checker += sub_node->QueryDoubleAttribute(
"z", &ptz);
126 if (checker != tinyxml2::XML_SUCCESS) {
127 std::string err_msg =
"Error parsing cornerGlobal point attributes";
132 double output_x = 0.0;
133 double output_y = 0.0;
134 double output_z = 0.0;
135 WGS84ToUTM(ptx, pty, ptz, &output_x, &output_y, &output_z);
140 sub_node = sub_node->NextSiblingElement(
"cornerGlobal");
150 const auto sub_node = xml_node.FirstChildElement(
"centerPoint");
151 ACHECK(sub_node !=
nullptr);
152 int checker = tinyxml2::XML_SUCCESS;
156 checker += sub_node->QueryDoubleAttribute(
"x", &ptx);
157 checker += sub_node->QueryDoubleAttribute(
"y", &pty);
158 checker += sub_node->QueryDoubleAttribute(
"z", &ptz);
160 if (checker != tinyxml2::XML_SUCCESS) {
161 std::string err_msg =
"Error parse point attributes";
165 double output_x = 0.0;
166 double output_y = 0.0;
167 double output_z = 0.0;
168 WGS84ToUTM(ptx, pty, ptz, &output_x, &output_y, &output_z);
177 std::string value = s;
178 std::transform(value.begin(), value.end(), value.begin(),
179 [](
unsigned char c) { return std::toupper(c); });
185 double* output_x,
double* output_y,
193 for (
int i = 0; i < curve.segment_size(); ++i) {
201 const tinyxml2::XMLElement& xml_node,
const std::string& name,
202 std::string* value) {
203 CHECK_NOTNULL(value);
204 const char* val = xml_node.Attribute(name.c_str());
205 if (val ==
nullptr) {
206 return tinyxml2::XML_NO_ATTRIBUTE;
210 return tinyxml2::XML_SUCCESS;
A general class to denote the return status of an API call.
static Status OK()
generate a success status.
static void WGS84ToUTM(const double x, const double y, const double z, double *output_x, double *output_y, double *output_z)
static Status ParseGeometry(const tinyxml2::XMLElement &xml_node, PbCurveSegment *curve_segment)
static std::string ToUpper(const std::string &s)
static double CurveLength(const PbCurve &curve)
static tinyxml2::XMLError QueryStringAttribute(const tinyxml2::XMLElement &xml_node, const std::string &name, std::string *value)
static Status ParsePointSet(const tinyxml2::XMLElement &xml_node, PbLineSegment *line_segment)
static Status ParseCurve(const tinyxml2::XMLElement &xml_node, PbCurve *curve)
static Status ParseOutline(const tinyxml2::XMLElement &xml_node, PbPolygon *polygon)
static Status ParsePoint(const tinyxml2::XMLElement &xml_node, PbPoint3D *pt)
#define RETURN_IF_ERROR(expr)
repeated CurveSegment segment