Make addFITSKeywordAsProperty work
This commit is contained in:
+3
-3
@@ -34,6 +34,7 @@ namespace LibXISF
|
|||||||
std::vector<std::string> splitString(const std::string &str, char delimiter);
|
std::vector<std::string> splitString(const std::string &str, char delimiter);
|
||||||
void deserializeVariant(const pugi::xml_node &node, Variant &variant, const ByteArray &data);
|
void deserializeVariant(const pugi::xml_node &node, Variant &variant, const ByteArray &data);
|
||||||
void serializeVariant(pugi::xml_node &node, const Variant &variant);
|
void serializeVariant(pugi::xml_node &node, const Variant &variant);
|
||||||
|
Variant variantFromString(Variant::Type type, const String &str);
|
||||||
|
|
||||||
static std::unordered_map<String, Image::Type> imageTypeToEnum;
|
static std::unordered_map<String, Image::Type> imageTypeToEnum;
|
||||||
static std::unordered_map<Image::Type, String> imageTypeToString;
|
static std::unordered_map<Image::Type, String> imageTypeToString;
|
||||||
@@ -344,13 +345,12 @@ void Image::addFITSKeyword(const FITSKeyword &keyword)
|
|||||||
_fitsKeywords.push_back(keyword);
|
_fitsKeywords.push_back(keyword);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Image::addFITSKeywordAsProperty(const String &name, const Variant &value)
|
bool Image::addFITSKeywordAsProperty(const String &name, const String &value)
|
||||||
{
|
{
|
||||||
if(fitsNameToPropertyIdTypeConvert.count(name))
|
if(fitsNameToPropertyIdTypeConvert.count(name))
|
||||||
{
|
{
|
||||||
auto &c = fitsNameToPropertyIdTypeConvert.at(name);
|
auto &c = fitsNameToPropertyIdTypeConvert.at(name);
|
||||||
Property prop(c.first, value);
|
Property prop(c.first, variantFromString(c.second, value));
|
||||||
//prop.value.convert(c.second);
|
|
||||||
updateProperty(prop);
|
updateProperty(prop);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ public:
|
|||||||
/** Add image property while doing automatic conversion of FITS name to XISF property
|
/** Add image property while doing automatic conversion of FITS name to XISF property
|
||||||
* For example OBSERVER => Observer:Name, SITELAT => Observation:Location:Latitude
|
* For example OBSERVER => Observer:Name, SITELAT => Observation:Location:Latitude
|
||||||
*/
|
*/
|
||||||
bool addFITSKeywordAsProperty(const String &name, const Variant &value);
|
bool addFITSKeywordAsProperty(const String &name, const String &value);
|
||||||
|
|
||||||
void* imageData();
|
void* imageData();
|
||||||
const void* imageData() const;
|
const void* imageData() const;
|
||||||
|
|||||||
+21
@@ -371,6 +371,27 @@ void serializeVariant(pugi::xml_node &node, const Variant &variant)
|
|||||||
node.append_attribute("value").set_value(ss.str().c_str());
|
node.append_attribute("value").set_value(ss.str().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Variant variantFromString(Variant::Type type, const String &str)
|
||||||
|
{
|
||||||
|
Variant variant;
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case Variant::Type::Int32: variant = fromChars<Int32>(str.c_str(), str.c_str() + str.size()); break;
|
||||||
|
case Variant::Type::Float32: variant = fromChars<Float32>(str.c_str(), str.c_str() + str.size()); break;
|
||||||
|
case Variant::Type::Float64: variant = fromChars<Float64>(str.c_str(), str.c_str() + str.size()); break;
|
||||||
|
case Variant::Type::String: variant = str; break;
|
||||||
|
case Variant::Type::TimePoint:
|
||||||
|
{
|
||||||
|
std::istringstream ss(str);
|
||||||
|
std::tm tm = {};
|
||||||
|
ss >> std::get_time(&tm, "%Y-%m-%dT%H:%M:%SZ");
|
||||||
|
variant = tm;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
return variant;
|
||||||
|
}
|
||||||
|
|
||||||
Variant::Type Variant::type() const
|
Variant::Type Variant::type() const
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user