summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilian Peev <epeev@google.com>2019-05-10 21:17:55 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-05-10 21:17:55 -0700
commitec1886060e0b8fea37755631cbcc5d331ecd1ec5 (patch)
tree2b2af09316234e159648c63ba97a96173fa4bc24
parent3663c2c50d146a507e222cb6c2cef32dde2b09c3 (diff)
parentd7e0bad295d80a7fd2b3d8d55eb7dd2b24de4b13 (diff)
downloaddynamic_depth-ec1886060e0b8fea37755631cbcc5d331ecd1ec5.tar.gz
Sync libdynamic_depth to CL #247448495 am: d2455c3e60
am: d7e0bad295 Change-Id: I4ddd0ee942be60c1e53995e252cdf58c4168c247
-rw-r--r--internal/dynamic_depth/container.cc9
-rw-r--r--internal/dynamic_depth/device.cc18
-rw-r--r--internal/dynamic_depth/earth_pose.cc8
-rw-r--r--internal/dynamic_depth/pose.cc6
-rw-r--r--internal/xmpmeta/xml/const.cc2
-rw-r--r--internal/xmpmeta/xml/const.h1
6 files changed, 27 insertions, 17 deletions
diff --git a/internal/dynamic_depth/container.cc b/internal/dynamic_depth/container.cc
index e7a35dd..ff84a40 100644
--- a/internal/dynamic_depth/container.cc
+++ b/internal/dynamic_depth/container.cc
@@ -2,15 +2,18 @@
#include "android-base/logging.h"
#include "dynamic_depth/const.h"
+#include "xmpmeta/xml/const.h"
using ::dynamic_depth::xmpmeta::xml::Deserializer;
using ::dynamic_depth::xmpmeta::xml::Serializer;
+using ::dynamic_depth::xmpmeta::xml::XmlConst;
namespace dynamic_depth {
constexpr char kNamespaceHref[] =
"http://ns.google.com/photos/dd/1.0/container/";
constexpr char kDirectory[] = "Directory";
+constexpr char kResourceType[] = "Resource";
// Private constructor.
Container::Container() {}
@@ -92,6 +95,12 @@ bool Container::Serialize(Serializer* serializer) const {
serializer->CreateSerializer(
DynamicDepthConst::Namespace(DynamicDepthConst::Container()),
DynamicDepthConst::Container());
+ if (!container_serializer->WriteProperty(XmlConst::RdfPrefix(),
+ XmlConst::RdfParseType(),
+ kResourceType)) {
+ return false;
+ }
+
std::unique_ptr<Serializer> directory_serializer =
container_serializer->CreateListSerializer(DynamicDepthConst::Container(),
kDirectory);
diff --git a/internal/dynamic_depth/device.cc b/internal/dynamic_depth/device.cc
index 399ea74..84b1720 100644
--- a/internal/dynamic_depth/device.cc
+++ b/internal/dynamic_depth/device.cc
@@ -35,14 +35,14 @@ std::unique_ptr<Device> ParseFields(const xmlDocPtr& xmlDoc) {
// Find and parse the Device node.
// Only these two fields are required to be present; the rest are optional.
// TODO(miraleung): Search for Device by namespace.
- xmlNodePtr device_node =
- DepthFirstSearch(xmlDoc, DynamicDepthConst::Device());
- if (device_node == nullptr) {
- LOG(ERROR) << "No device node found";
+ xmlNodePtr description_node =
+ DepthFirstSearch(xmlDoc, XmlConst::RdfDescription());
+ if (description_node == nullptr) {
+ LOG(ERROR) << "No rdf description found";
return nullptr;
}
- const DeserializerImpl deserializer(device_node);
+ const DeserializerImpl deserializer(description_node);
auto cameras = Cameras::FromDeserializer(deserializer);
if (cameras == nullptr) {
LOG(ERROR) << "No cameras found";
@@ -186,12 +186,6 @@ bool Device::Serialize(xmlDocPtr* xmlDoc) {
return false;
}
- // Create a node here instead of through a new deserializer, otherwise
- // an extraneous prefix will be written to the node name.
- xmlNodePtr device_node =
- xmlNewNode(nullptr, ToXmlChar(DynamicDepthConst::Device()));
- xmlAddChild(root_node, device_node);
-
PopulateNamespaces();
xmlNsPtr prev_ns = root_node->ns;
for (const auto& entry : namespaces_) {
@@ -202,7 +196,7 @@ bool Device::Serialize(xmlDocPtr* xmlDoc) {
}
// Set up serialization on the first description node in the extended section.
- SerializerImpl device_serializer(namespaces_, device_node);
+ SerializerImpl device_serializer(namespaces_, root_node);
// Serialize elements.
if (params_->container &&
diff --git a/internal/dynamic_depth/earth_pose.cc b/internal/dynamic_depth/earth_pose.cc
index cd5e0a7..db9e2b3 100644
--- a/internal/dynamic_depth/earth_pose.cc
+++ b/internal/dynamic_depth/earth_pose.cc
@@ -2,6 +2,8 @@
#include <math.h>
+#include <cmath>
+
#include "android-base/logging.h"
#include "dynamic_depth/const.h"
@@ -25,9 +27,9 @@ const std::vector<float> NormalizeQuaternion(const std::vector<float>& quat) {
if (quat.size() < 4) {
return std::vector<float>();
}
- float length =
- sqrt((quat[0] * quat[0]) + (quat[1] * quat[1]) + (quat[2] * quat[2])) +
- (quat[3] * quat[3]);
+ float length = std::sqrt((quat[0] * quat[0]) + (quat[1] * quat[1]) +
+ (quat[2] * quat[2])) +
+ (quat[3] * quat[3]);
const std::vector<float> normalized = {quat[0] / length, quat[1] / length,
quat[2] / length, quat[3] / length};
return normalized;
diff --git a/internal/dynamic_depth/pose.cc b/internal/dynamic_depth/pose.cc
index 63c0740..ae9a1c9 100644
--- a/internal/dynamic_depth/pose.cc
+++ b/internal/dynamic_depth/pose.cc
@@ -2,6 +2,8 @@
#include <math.h>
+#include <cmath>
+
#include "android-base/logging.h"
#include "dynamic_depth/const.h"
@@ -25,8 +27,8 @@ const std::vector<float> NormalizeQuaternion(const std::vector<float>& quat) {
if (quat.size() < 4) {
return std::vector<float>();
}
- float length = sqrt((quat[0] * quat[0]) + (quat[1] * quat[1]) +
- (quat[2] * quat[2]) + (quat[3] * quat[3]));
+ float length = std::sqrt((quat[0] * quat[0]) + (quat[1] * quat[1]) +
+ (quat[2] * quat[2]) + (quat[3] * quat[3]));
const std::vector<float> normalized = {quat[0] / length, quat[1] / length,
quat[2] / length, quat[3] / length};
return normalized;
diff --git a/internal/xmpmeta/xml/const.cc b/internal/xmpmeta/xml/const.cc
index 5af3c16..4a20f1d 100644
--- a/internal/xmpmeta/xml/const.cc
+++ b/internal/xmpmeta/xml/const.cc
@@ -23,6 +23,8 @@ const char* XmlConst::RdfSeq() { return "Seq"; }
const char* XmlConst::RdfLi() { return "li"; }
+const char* XmlConst::RdfParseType() { return "parseType"; }
+
// XML metadata constants.
const char* XmlConst::NsAttrName() { return "xmlns"; }
diff --git a/internal/xmpmeta/xml/const.h b/internal/xmpmeta/xml/const.h
index 8a1998a..e540b07 100644
--- a/internal/xmpmeta/xml/const.h
+++ b/internal/xmpmeta/xml/const.h
@@ -17,6 +17,7 @@ struct XmlConst {
static const char* RdfPrefix();
static const char* RdfSeq();
static const char* RdfLi();
+ static const char* RdfParseType();
// XML metadata.
static const char* NsAttrName();