Commit 5aa450e0 authored by Morten Ofstad's avatar Morten Ofstad
Browse files

Merge branch feature/morten.ofstad/MetadataUpdates with refs/heads/master into...

Merge branch feature/morten.ofstad/MetadataUpdates with refs/heads/master into refs/merge-requests/129/train
parents 665f1139 8af8556c
Pipeline #1487 passed with stages
in 8 minutes and 31 seconds
......@@ -24,6 +24,7 @@
#include <OpenVDS/VolumeDataChannelDescriptor.h>
#include <OpenVDS/VolumeData.h>
#include <OpenVDS/VolumeDataAccess.h>
#include <OpenVDS/KnownMetadata.h>
#include "generated_docstrings.h"
......@@ -66,6 +67,7 @@ private:
#include <pybind11/stl.h>
#include <pybind11/numpy.h>
#include <pybind11/attr.h>
#include <pybind11/operators.h>
namespace py = pybind11;
namespace native = OpenVDS;
......
......@@ -23,6 +23,43 @@ void
PyKnownMetadata::initModule(py::module& m)
{
//AUTOGEN-BEGIN
// KnownAxisNames
py::class_<KnownAxisNames, std::unique_ptr<KnownAxisNames>>
KnownAxisNames_(m,"KnownAxisNames", OPENVDS_DOCSTRING(KnownAxisNames));
// KnownMetadata
py::class_<KnownMetadata, std::unique_ptr<KnownMetadata>>
KnownMetadata_(m,"KnownMetadata", OPENVDS_DOCSTRING(KnownMetadata));
KnownMetadata_.def_static("categorySurveyCoordinateSystem", static_cast<const char *(*)()>(&KnownMetadata::CategorySurveyCoordinateSystem), OPENVDS_DOCSTRING(KnownMetadata_CategorySurveyCoordinateSystem));
KnownMetadata_.def_static("surveyCoordinateSystemOrigin", static_cast<native::MetadataKey(*)()>(&KnownMetadata::SurveyCoordinateSystemOrigin), OPENVDS_DOCSTRING(KnownMetadata_SurveyCoordinateSystemOrigin));
KnownMetadata_.def_static("surveyCoordinateSystemInlineSpacing", static_cast<native::MetadataKey(*)()>(&KnownMetadata::SurveyCoordinateSystemInlineSpacing), OPENVDS_DOCSTRING(KnownMetadata_SurveyCoordinateSystemInlineSpacing));
KnownMetadata_.def_static("surveyCoordinateSystemCrosslineSpacing", static_cast<native::MetadataKey(*)()>(&KnownMetadata::SurveyCoordinateSystemCrosslineSpacing), OPENVDS_DOCSTRING(KnownMetadata_SurveyCoordinateSystemCrosslineSpacing));
KnownMetadata_.def_static("surveyCoordinateSystemIJKOrigin", static_cast<native::MetadataKey(*)()>(&KnownMetadata::SurveyCoordinateSystemIJKOrigin), OPENVDS_DOCSTRING(KnownMetadata_SurveyCoordinateSystemIJKOrigin));
KnownMetadata_.def_static("surveyCoordinateSystemIStepVector", static_cast<native::MetadataKey(*)()>(&KnownMetadata::SurveyCoordinateSystemIStepVector), OPENVDS_DOCSTRING(KnownMetadata_SurveyCoordinateSystemIStepVector));
KnownMetadata_.def_static("surveyCoordinateSystemJStepVector", static_cast<native::MetadataKey(*)()>(&KnownMetadata::SurveyCoordinateSystemJStepVector), OPENVDS_DOCSTRING(KnownMetadata_SurveyCoordinateSystemJStepVector));
KnownMetadata_.def_static("surveyCoordinateSystemKStepVector", static_cast<native::MetadataKey(*)()>(&KnownMetadata::SurveyCoordinateSystemKStepVector), OPENVDS_DOCSTRING(KnownMetadata_SurveyCoordinateSystemKStepVector));
KnownMetadata_.def_static("categoryTraceCoordinates" , static_cast<const char *(*)()>(&KnownMetadata::CategoryTraceCoordinates), OPENVDS_DOCSTRING(KnownMetadata_CategoryTraceCoordinates));
KnownMetadata_.def_static("tracePositions" , static_cast<native::MetadataKey(*)()>(&KnownMetadata::TracePositions), OPENVDS_DOCSTRING(KnownMetadata_TracePositions));
KnownMetadata_.def_static("traceVerticalOffsets" , static_cast<native::MetadataKey(*)()>(&KnownMetadata::TraceVerticalOffsets), OPENVDS_DOCSTRING(KnownMetadata_TraceVerticalOffsets));
KnownMetadata_.def_static("energySourcePointNumbers" , static_cast<native::MetadataKey(*)()>(&KnownMetadata::EnergySourcePointNumbers), OPENVDS_DOCSTRING(KnownMetadata_EnergySourcePointNumbers));
KnownMetadata_.def_static("ensembleNumbers" , static_cast<native::MetadataKey(*)()>(&KnownMetadata::EnsembleNumbers), OPENVDS_DOCSTRING(KnownMetadata_EnsembleNumbers));
KnownMetadata_.def_static("categoryWrittenRegion" , static_cast<const char *(*)()>(&KnownMetadata::CategoryWrittenRegion), OPENVDS_DOCSTRING(KnownMetadata_CategoryWrittenRegion));
KnownMetadata_.def_static("writtenRegion" , static_cast<native::MetadataKey(*)()>(&KnownMetadata::WrittenRegion), OPENVDS_DOCSTRING(KnownMetadata_WrittenRegion));
KnownMetadata_.def_static("categoryImportInformation" , static_cast<const char *(*)()>(&KnownMetadata::CategoryImportInformation), OPENVDS_DOCSTRING(KnownMetadata_CategoryImportInformation));
KnownMetadata_.def_static("importInformationDisplayName", static_cast<native::MetadataKey(*)()>(&KnownMetadata::ImportInformationDisplayName), OPENVDS_DOCSTRING(KnownMetadata_ImportInformationDisplayName));
KnownMetadata_.def_static("importInformationInputFileName", static_cast<native::MetadataKey(*)()>(&KnownMetadata::ImportInformationInputFileName), OPENVDS_DOCSTRING(KnownMetadata_ImportInformationInputFileName));
KnownMetadata_.def_static("importInformationInputFileSize", static_cast<native::MetadataKey(*)()>(&KnownMetadata::ImportInformationInputFileSize), OPENVDS_DOCSTRING(KnownMetadata_ImportInformationInputFileSize));
KnownMetadata_.def_static("importInformationInputTimeStamp", static_cast<native::MetadataKey(*)()>(&KnownMetadata::ImportInformationInputTimeStamp), OPENVDS_DOCSTRING(KnownMetadata_ImportInformationInputTimeStamp));
KnownMetadata_.def_static("importInformationImportTimeStamp", static_cast<native::MetadataKey(*)()>(&KnownMetadata::ImportInformationImportTimeStamp), OPENVDS_DOCSTRING(KnownMetadata_ImportInformationImportTimeStamp));
KnownMetadata_.def_static("categorySEGY" , static_cast<const char *(*)()>(&KnownMetadata::CategorySEGY), OPENVDS_DOCSTRING(KnownMetadata_CategorySEGY));
KnownMetadata_.def_static("SEGYTextHeader" , static_cast<native::MetadataKey(*)()>(&KnownMetadata::SEGYTextHeader), OPENVDS_DOCSTRING(KnownMetadata_SEGYTextHeader));
KnownMetadata_.def_static("SEGYBinaryHeader" , static_cast<native::MetadataKey(*)()>(&KnownMetadata::SEGYBinaryHeader), OPENVDS_DOCSTRING(KnownMetadata_SEGYBinaryHeader));
KnownMetadata_.def_static("SEGYEndianness" , static_cast<native::MetadataKey(*)()>(&KnownMetadata::SEGYEndianness), OPENVDS_DOCSTRING(KnownMetadata_SEGYEndianness));
KnownMetadata_.def_static("SEGYDataEndianness" , static_cast<native::MetadataKey(*)()>(&KnownMetadata::SEGYDataEndianness), OPENVDS_DOCSTRING(KnownMetadata_SEGYDataEndianness));
KnownMetadata_.def_static("SEGYDataSampleFormatCode" , static_cast<native::MetadataKey(*)()>(&KnownMetadata::SEGYDataSampleFormatCode), OPENVDS_DOCSTRING(KnownMetadata_SEGYDataSampleFormatCode));
KnownMetadata_.def_static("SEGYPrimaryKey" , static_cast<native::MetadataKey(*)()>(&KnownMetadata::SEGYPrimaryKey), OPENVDS_DOCSTRING(KnownMetadata_SEGYPrimaryKey));
//AUTOGEN-END
}
......@@ -228,9 +228,13 @@ PyMetadata::initModule(py::module& m)
py::class_<MetadataKey, std::unique_ptr<MetadataKey>>
MetadataKey_(m,"MetadataKey", OPENVDS_DOCSTRING(MetadataKey));
MetadataKey_.def_readwrite("type" , &MetadataKey::type , OPENVDS_DOCSTRING(MetadataKey_type));
MetadataKey_.def_readwrite("category" , &MetadataKey::category , OPENVDS_DOCSTRING(MetadataKey_category));
MetadataKey_.def_readwrite("name" , &MetadataKey::name , OPENVDS_DOCSTRING(MetadataKey_name));
MetadataKey_.def(py::init< >(), OPENVDS_DOCSTRING(MetadataKey_MetadataKey));
MetadataKey_.def(py::init<native::MetadataType, const char *, const char *>(), py::arg("type"), py::arg("category"), py::arg("name"), OPENVDS_DOCSTRING(MetadataKey_MetadataKey_2));
MetadataKey_.def("type" , static_cast<native::MetadataType(MetadataKey::*)() const>(&MetadataKey::Type), OPENVDS_DOCSTRING(MetadataKey_Type));
MetadataKey_.def("category" , static_cast<const char *(MetadataKey::*)() const>(&MetadataKey::Category), OPENVDS_DOCSTRING(MetadataKey_Category));
MetadataKey_.def("name" , static_cast<const char *(MetadataKey::*)() const>(&MetadataKey::Name), OPENVDS_DOCSTRING(MetadataKey_Name));
MetadataKey_.def(py::self == py::self);
MetadataKey_.def(py::self != py::self);
// MetadataKeyRange
py::class_<MetadataKeyRange, std::unique_ptr<MetadataKeyRange>>
......@@ -295,8 +299,6 @@ PyMetadata::initModule(py::module& m)
MetadataWriteAccess_.def("clearMetadata" , static_cast<void(MetadataWriteAccess::*)(const char *, const char *)>(&MetadataWriteAccess::ClearMetadata), py::arg("category"), py::arg("name"), OPENVDS_DOCSTRING(MetadataWriteAccess_ClearMetadata));
MetadataWriteAccess_.def("clearMetadata" , static_cast<void(MetadataWriteAccess::*)(const char *)>(&MetadataWriteAccess::ClearMetadata), py::arg("category"), OPENVDS_DOCSTRING(MetadataWriteAccess_ClearMetadata_2));
m.def("operator_eq" , static_cast<bool(*)(const native::MetadataKey &, const native::MetadataKey &)>(&operator==), py::arg("a"), py::arg("b"), OPENVDS_DOCSTRING(operator_eq));
// MetadataContainer
py::class_<MetadataContainer, MetadataReadAccess, MetadataWriteAccess, std::unique_ptr<MetadataContainer>>
MetadataContainer_(m,"MetadataContainer", OPENVDS_DOCSTRING(MetadataContainer));
......@@ -360,7 +362,7 @@ PyMetadata::initModule(py::module& m)
MetadataReadAccess_.def("getMetadata", [](MetadataReadAccess* self, native::MetadataKey const& key)
{
return GetMetadata(self, key.category, key.name, key.type);
return GetMetadata(self, key.Category(), key.Name(), key.Type());
}, py::arg("key"));
MetadataReadAccess_.def("getMetadata", [](MetadataReadAccess* self, const char* category, const char* name, native::MetadataType type)
{
......@@ -379,7 +381,7 @@ PyMetadata::initModule(py::module& m)
MetadataKey_.def("__repr__", [](MetadataKey* self)
{
const char* type = "unknown";
switch(self->type)
switch(self->Type())
{
case MetadataType::Int : type = "Int" ; break;
case MetadataType::IntVector2 : type = "IntVector2" ; break;
......@@ -396,7 +398,7 @@ PyMetadata::initModule(py::module& m)
case MetadataType::String : type = "String" ; break;
case MetadataType::BLOB : type = "BLOB" ; break;
}
return std::string("MetadataKey(category='") + self->category + "', name='" + self->name + "', type=MetadataType." + type + ")";
return std::string("MetadataKey(category='") + self->Category() + "', name='" + self->Name() + "', type=MetadataType." + type + ")";
});
}
......@@ -494,6 +494,182 @@ static const char *__doc_OpenVDS_InterpolationMethod_Nearest = R"doc(< Snap to t
static const char *__doc_OpenVDS_InterpolationMethod_Triangular = R"doc(< Triangular interpolation used to interpolate heightmap data)doc";
static const char *__doc_OpenVDS_KnownAxisNames = R"doc()doc";
static const char *__doc_OpenVDS_KnownAxisNames_AxisNameCrossline =
R"doc(String representing the name of the axis corresponding to the
crossline spacing.)doc";
static const char *__doc_OpenVDS_KnownAxisNames_AxisNameDepth =
R"doc(String representing the name of the axis corresponding to the negative
z direction.)doc";
static const char *__doc_OpenVDS_KnownAxisNames_AxisNameI =
R"doc(String representing the name of the axis corresponding to the I step
vector (SurveyCoordinateSystemIStep))doc";
static const char *__doc_OpenVDS_KnownAxisNames_AxisNameInline =
R"doc(String representing the name of the axis corresponding to the inline
spacing.)doc";
static const char *__doc_OpenVDS_KnownAxisNames_AxisNameJ =
R"doc(String representing the name of the axis corresponding to the J step
vector (SurveyCoordinateSystemIStep))doc";
static const char *__doc_OpenVDS_KnownAxisNames_AxisNameK =
R"doc(String representing the name of the axis corresponding to the K step
vector (SurveyCoordinateSystemKStep))doc";
static const char *__doc_OpenVDS_KnownAxisNames_AxisNameSample =
R"doc(String representing the name of the axis corresponding to the negative
z direction.)doc";
static const char *__doc_OpenVDS_KnownAxisNames_AxisNameTime =
R"doc(String representing the name of the axis corresponding to the negative
z direction.)doc";
static const char *__doc_OpenVDS_KnownAxisNames_AxisNameX =
R"doc(String representing the name of the axis that maps directly to the X
coordinate in the XYZ coordinate system)doc";
static const char *__doc_OpenVDS_KnownAxisNames_AxisNameY =
R"doc(String representing the name of the axis that maps directly to the Y
coordinate in the XYZ coordinate system)doc";
static const char *__doc_OpenVDS_KnownAxisNames_AxisNameZ =
R"doc(String representing the name of the axis that maps directly to the Z
coordinate in the XYZ coordinate system)doc";
static const char *__doc_OpenVDS_KnownMetadata = R"doc()doc";
static const char *__doc_OpenVDS_KnownMetadata_CategoryImportInformation =
R"doc(The metadata in the ImportInformation category contains information
about the initial import to VDS. That is, information about the
original file (file name, last modification time etc.) and when/how it
was imported. The intended use is e.g. to give a default file name for
an export operation or to inform the user about whether the VDS was
imported from some particular file.)doc";
static const char *__doc_OpenVDS_KnownMetadata_CategorySEGY =
R"doc(The metadata in the SEGY category is intended to capture information
required to re-create the original SEG-Y file. It is only present if
the VDS was imported from a SEG-Y file.)doc";
static const char *__doc_OpenVDS_KnownMetadata_CategorySurveyCoordinateSystem =
R"doc(The metadata in the survey coordinate system category contains either
information used to transform from an Inline/Crossline annotation
system to XY (Easting, Northing) coordinates or information used to
transform from an I/J/K annotation system to XYZ coordinates. <para>
In the Inline/Crossline system, the step vector for dimension 0 (Which
can be named either Time, Depth or Sample) is always negative Z
direction. The origin is the position of (inline, crossline) (0, 0),
the inline spacing is the (X, Y) step when the inline position
increments by 1 and the crossline spacing is the (X, Y) step when the
crossline position increments by 1. </para> <para> In the I/J/K
system, all three dimensions have 3D step vectors allowing for any
affine tranform to XYZ coordinates. The IJK origin is the position of
(I, J, K) (0, 0, 0), the I step vector is the (X, Y, Z) step when the
I position increments by 1, the J step vector is the (X, Y, Z) step
when the J position increments by 1 and the K step vector is the (X,
Y, Z) step when the K position increments by 1. </para> <para> It is
also possible to define the X, Y, Z coordinates directly by using
X/Y/Z as the axis names. </para> <para> Any dimensions which have
names that are not recognized or are missing the Spacing metadata will
be given a unit vector perpendicular to the recognized dimensions.
</para>)doc";
static const char *__doc_OpenVDS_KnownMetadata_CategoryTraceCoordinates =
R"doc(The metadata in the TraceCoordinates category is used for positioning
of 2D seismic. It relates to the 'Trace' dimension of the VDS where
the annotation coordinate is used to look up in the arrays in this
category. This allows using the same positions with subsetted and
interpolated or decimated data.)doc";
static const char *__doc_OpenVDS_KnownMetadata_CategoryWrittenRegion =
R"doc(The metadata in the WrittenRegion category is used to indicate which
area is written in a sparsely populated VDS. The guarantee is that
values outside the written area will be NoValue if UseNoValue is True,
and ValueRange.Min if UseNoValue is False.)doc";
static const char *__doc_OpenVDS_KnownMetadata_EnergySourcePointNumbers =
R"doc(An array of scalar int32 values defining the energy source point
number for each trace.)doc";
static const char *__doc_OpenVDS_KnownMetadata_EnsembleNumbers =
R"doc(An array of scalar int32 values defining the ensemble number for each
trace.)doc";
static const char *__doc_OpenVDS_KnownMetadata_ImportInformationDisplayName =
R"doc(An informative name that can be displayed to a user but is not
necessarily a valid file name.)doc";
static const char *__doc_OpenVDS_KnownMetadata_ImportInformationImportTimeStamp = R"doc(The time in ISO8601 format when the data was imported to VDS.)doc";
static const char *__doc_OpenVDS_KnownMetadata_ImportInformationInputFileName =
R"doc(The original input file name. In cases where the input is not a simple
file this should still be a valid file name that can be used as the
default for a subsequent export operation.)doc";
static const char *__doc_OpenVDS_KnownMetadata_ImportInformationInputFileSize =
R"doc(The total size (in bytes) of the input file(s), which is an integer
stored as a double because there is no 64-bit integer metadata type.)doc";
static const char *__doc_OpenVDS_KnownMetadata_ImportInformationInputTimeStamp = R"doc(The last modified time of the input in ISO8601 format.)doc";
static const char *__doc_OpenVDS_KnownMetadata_SEGYBinaryHeader = R"doc(The original binary header of the SEG-Y file)doc";
static const char *__doc_OpenVDS_KnownMetadata_SEGYDataEndianness =
R"doc(The endianness of the data samples in the SEG-Y file if different from
the header endianness. This is a non-standard feature, but some SEG-Y
files use it. (0=BigEndian)(1=LittleEndian))doc";
static const char *__doc_OpenVDS_KnownMetadata_SEGYDataSampleFormatCode =
R"doc(The data sample format code of the data samples imported from the
SEG-Y file. (0=Unknown)(1=IBMFloat)(2=Int32)(3=Int16)(4=FixedPoint)(5=
IEEEFloat)(6=IEEEDouble)(7=Int24)(8=Int8)(9=Int64)(10=UInt32)(11=UInt1
6)(12=UInt64)(15=UInt24)(16=UInt8))doc";
static const char *__doc_OpenVDS_KnownMetadata_SEGYEndianness = R"doc(The endianness of the SEG-Y file (0=BigEndian)(1=LittleEndian))doc";
static const char *__doc_OpenVDS_KnownMetadata_SEGYPrimaryKey =
R"doc(The primary key (i.e. sort order) of the original SEG-Y file. VDSs are
expected to transpose crossline-oriented seismic to use the standard
(Sample, Crossline, Inline) axis triple, so in order to export the
file in the original order we need to know which dimension to loop
over.)doc";
static const char *__doc_OpenVDS_KnownMetadata_SEGYTextHeader = R"doc(The original text header of the SEG-Y file)doc";
static const char *__doc_OpenVDS_KnownMetadata_SurveyCoordinateSystemCrosslineSpacing = R"doc(The XY spacing between units in the Crossline annotation dimension.)doc";
static const char *__doc_OpenVDS_KnownMetadata_SurveyCoordinateSystemIJKOrigin =
R"doc(The XYZ position of the origin of the annotation (I/J/K) coordinate
system.)doc";
static const char *__doc_OpenVDS_KnownMetadata_SurveyCoordinateSystemIStepVector = R"doc(The step vector corresponding to dimension named 'I')doc";
static const char *__doc_OpenVDS_KnownMetadata_SurveyCoordinateSystemInlineSpacing = R"doc(The XY spacing between units in the Inline annotation dimension.)doc";
static const char *__doc_OpenVDS_KnownMetadata_SurveyCoordinateSystemJStepVector = R"doc(The step vector corresponding to dimension named 'J')doc";
static const char *__doc_OpenVDS_KnownMetadata_SurveyCoordinateSystemKStepVector = R"doc(The step vector corresponding to dimension named 'K')doc";
static const char *__doc_OpenVDS_KnownMetadata_SurveyCoordinateSystemOrigin =
R"doc(The XY position of the origin of the annotation
(Inline/Crossline/Time) coordinate system.)doc";
static const char *__doc_OpenVDS_KnownMetadata_TracePositions =
R"doc(An array of DoubleVector2 defining the position for each trace, where
(0, 0) is treated as an undefined position.)doc";
static const char *__doc_OpenVDS_KnownMetadata_TraceVerticalOffsets =
R"doc(An array of doubles defining the offset for each trace from the
vertical start position in the Time/Depth/Sample dimension of the VDS)doc";
static const char *__doc_OpenVDS_KnownMetadata_WrittenRegion =
R"doc(An array of scalar int32 values defining the 6D min and max (NDBox) of
the written region)doc";
static const char *__doc_OpenVDS_M4 = R"doc()doc";
static const char *__doc_OpenVDS_M4_data = R"doc()doc";
......@@ -630,7 +806,7 @@ static const char *__doc_OpenVDS_MetadataContainer_m_names = R"doc()doc";
static const char *__doc_OpenVDS_MetadataContainer_m_stringData = R"doc()doc";
static const char *__doc_OpenVDS_MetadataKey = R"doc(A metadata key uniquely identifies a piece of metadata)doc";
static const char *__doc_OpenVDS_MetadataKey = R"doc(A metadata key uniquely identifies a metadata item)doc";
static const char *__doc_OpenVDS_MetadataKeyRange =
R"doc(A range of metadata keys that can be iterated over using range-based
......@@ -646,11 +822,58 @@ static const char *__doc_OpenVDS_MetadataKeyRange_m_begin = R"doc()doc";
static const char *__doc_OpenVDS_MetadataKeyRange_m_end = R"doc()doc";
static const char *__doc_OpenVDS_MetadataKey_category = R"doc()doc";
static const char *__doc_OpenVDS_MetadataKey_Category =
R"doc(Get the category of metadata that this key identifies
Returns:
--------
The category of the metadata that this key identifies)doc";
static const char *__doc_OpenVDS_MetadataKey_MetadataKey = R"doc(Default constructor)doc";
static const char *__doc_OpenVDS_MetadataKey_MetadataKey_2 =
R"doc(Constructor
Parameters:
-----------
type :
The type of the metadata that this key identifies. The possible
types are (Int, Float, Double, {Int,Float,Double}Vector{2,3,4},
String or BLOB).
category :
The category of the metadata that this key identifies. A category
is a collection of related metadata items, e.g.
SurveyCoordinateSystem consists of Origin, InlineSpacing,
CrosslineSpacing and Unit metadata.
name :
The name of the metadata that this key identifies)doc";
static const char *__doc_OpenVDS_MetadataKey_Name =
R"doc(Get the name of metadata that this key identifies
Returns:
--------
The name of the metadata that this key identifies)doc";
static const char *__doc_OpenVDS_MetadataKey_Type =
R"doc(Get the type of metadata that this key identifies
static const char *__doc_OpenVDS_MetadataKey_name = R"doc()doc";
Returns:
--------
The type of the metadata that this key identifies)doc";
static const char *__doc_OpenVDS_MetadataKey_m_category = R"doc()doc";
static const char *__doc_OpenVDS_MetadataKey_m_name = R"doc()doc";
static const char *__doc_OpenVDS_MetadataKey_type = R"doc()doc";
static const char *__doc_OpenVDS_MetadataKey_m_type = R"doc()doc";
static const char *__doc_OpenVDS_MetadataKey_operator_eq = R"doc()doc";
static const char *__doc_OpenVDS_MetadataKey_operator_ne = R"doc()doc";
static const char *__doc_OpenVDS_MetadataReadAccess = R"doc(Interface for read access to Metadata)doc";
......@@ -2978,8 +3201,6 @@ static const char *__doc_OpenVDS_operator_bor = R"doc()doc";
static const char *__doc_OpenVDS_operator_bor_2 = R"doc()doc";
static const char *__doc_OpenVDS_operator_eq = R"doc()doc";
static const char *__doc_OpenVDS_rangeSize = R"doc()doc";
static const char *__doc_PyMetadata = R"doc()doc";
......
......@@ -320,6 +320,11 @@ def try_generate_trampoline_function(node, all_, restype, arglist, params):
sig += argnames
return sig
relational_operators = {
"operator_eq": ".def(py::self == py::self);",
"operator_ne": ".def(py::self != py::self);",
}
def generate_function(node, all_, output, indent, parent_prefix, context):
if node.get_num_template_arguments() >= 0:
# Don't generate wrappers for template specializations
......@@ -327,6 +332,12 @@ def generate_function(node, all_, output, indent, parent_prefix, context):
params = get_args(node, all_)
argnames = get_argnames(node, all_)
overload_name = resolve_overload_name(node, all_)
fnname = getpyname(sanitize_name(node.spelling))
if fnname in relational_operators.keys():
code = relational_operators[fnname]
line = indent + parent_prefix + code
output.append(line)
return
restype = fixname(node.result_type.spelling)
arglist = fixarglist(fixname(node.displayname[node.displayname.find('('):]), node, all)
method_prefix = ''
......@@ -337,7 +348,7 @@ def generate_function(node, all_, output, indent, parent_prefix, context):
if node.is_const_method():
method_suffix = " const"
code = """.def({0:30}, static_cast<{1}({2}*){3}{4}>(&{5}){7}, {6});""".format(
q(getpyname(sanitize_name(node.spelling))),
q(fnname),
restype,
method_prefix,
arglist,
......@@ -347,7 +358,6 @@ def generate_function(node, all_, output, indent, parent_prefix, context):
argnames
)
line = ''
fnname = getpyname(sanitize_name(node.spelling))
if not can_generate_function(restype, arglist):
try:
code = """.def({0:30}, {1}, {2});""".format(
......
......@@ -177,14 +177,14 @@ void CreateVolumeDataLayout(VDS &vds)
static void copyMetadataToContainer(MetadataContainer &container, const MetadataReadAccess &readAccess)
{
std::unordered_set<std::string> copied;
std::unordered_set<std::string> categories;
for (auto &key : readAccess.GetMetadataKeys())
{
if (copied.count(key.category))
{
continue;
}
container.CopyMetadata(key.category, &readAccess);
categories.insert(key.Category());
}
for (auto &category : categories)
{
container.CopyMetadata(category.c_str(), &readAccess);
}
}
......
This diff is collapsed.
......@@ -53,12 +53,60 @@ enum class MetadataType
BLOB
};
/// \brief A metadata key uniquely identifies a piece of metadata
struct MetadataKey
/// <summary>
/// A metadata key uniquely identifies a metadata item
/// </summary>
class MetadataKey
{
MetadataType type;
const char *category;
const char *name;
MetadataType m_type;
const char *m_category;
const char *m_name;
public:
/// <summary>
/// Default constructor
/// </summary>
MetadataKey() : m_type(), m_category(), m_name() {}
/// <summary>
/// Constructor
/// </summary>
/// <param name="type">
/// The type of the metadata that this key identifies. The possible types are (Int, Float, Double, {Int,Float,Double}Vector{2,3,4}, String or BLOB).
/// </param>
/// <param name="category">
/// The category of the metadata that this key identifies. A category is a collection of related metadata items, e.g. SurveyCoordinateSystem consists of Origin, InlineSpacing, CrosslineSpacing and Unit metadata.
/// </param>
/// <param name="name">
/// The name of the metadata that this key identifies
/// </param>
MetadataKey(MetadataType type, const char *category, const char *name) : m_type(type), m_category(category), m_name(name) {}
/// <summary>
/// Get the type of metadata that this key identifies
/// </summary>
/// <returns>
/// The type of the metadata that this key identifies
/// </returns>
MetadataType Type() const { return m_type; }
/// <summary>
/// Get the category of metadata that this key identifies
/// </summary>
/// <returns>
/// The category of the metadata that this key identifies
/// </returns>
const char *Category() const { return m_category; }
/// <summary>
/// Get the name of metadata that this key identifies
/// </summary>
/// <returns>
/// The name of the metadata that this key identifies
/// </returns>
const char *Name() const { return m_name; }
bool operator==(const MetadataKey& other) const { return m_type == other.m_type && strcmp(m_category, other.m_category) == 0 && strcmp(m_name, other.m_name) == 0; }
bool operator!=(const MetadataKey& other) const { return m_type != other.m_type || strcmp(m_category, other.m_category) != 0 || strcmp(m_name, other.m_name) != 0; }
};
/// \brief A range of metadata keys that can be iterated over using range-based 'for'
......@@ -169,8 +217,6 @@ public:
virtual void ClearMetadata(const char* category) = 0; ///< Clear the metadata with the given category
};
inline bool operator==(const MetadataKey& a, const MetadataKey& b) { return a.type == b.type && strcmp(a.category, b.category) == 0 && strcmp(a.name, b.name) == 0; }
} // end namespace OpenVDS
namespace std
......@@ -180,8 +226,8 @@ struct hash<OpenVDS::MetadataKey>
{
std::size_t operator()(const OpenVDS::MetadataKey &k) const
{
size_t const h1= std::hash<std::string>()(k.category);
size_t const h2= std::hash<std::string>()(k.name);
size_t const h1= std::hash<std::string>()(k.Category());
size_t const h2= std::hash<std::string>()(k.Name());
return h1 ^ (h2 << 1);
}
};
......@@ -245,53 +291,53 @@ public:
{
for (auto &key : metadataReadAccess->GetMetadataKeys())
{
if (strcmp(key.category, category) == 0)
if (strcmp(key.Category(), category) == 0)
{
switch(key.type)
switch(key.Type())
{
case MetadataType::Int:
SetMetadataInt(key.category, key.name, metadataReadAccess->GetMetadataInt(key.category, key.name));
SetMetadataInt(key.Category(), key.Name(), metadataReadAccess->GetMetadataInt(key.Category(), key.Name()));
break;
case MetadataType::IntVector2:
SetMetadataIntVector2(key.category, key.name, metadataReadAccess->GetMetadataIntVector2(key.category, key.name));
SetMetadataIntVector2(key.Category(), key.Name(), metadataReadAccess->GetMetadataIntVector2(key.Category(), key.Name()));
break;
case MetadataType::IntVector3:
SetMetadataIntVector3(key.category, key.name, metadataReadAccess->GetMetadataIntVector3(key.category, key.name));
SetMetadataIntVector3(key.Category(), key.Name(), metadataReadAccess->GetMetadataIntVector3(key.Category(), key.Name()));
break;
case MetadataType::IntVector4:
SetMetadataIntVector4(key.category, key.name, metadataReadAccess->GetMetadataIntVector4(key.category, key.name));
SetMetadataIntVector4(key.Category(), key.Name(), metadataReadAccess->GetMetadataIntVector4(key.Category(), key.Name()));
break;
case MetadataType::Float:
SetMetadataFloat(key.category, key.name, metadataReadAccess->GetMetadataFloat(key.category, key.name));
SetMetadataFloat(key.Category(), key.Name(), metadataReadAccess->GetMetadataFloat(key.Category(), key.Name()));
break;
case MetadataType::FloatVector2:
SetMetadataFloatVector2(key.category, key.name, metadataReadAccess->GetMetadataFloatVector2(key.category, key.name));
SetMetadataFloatVector2(key.Category(), key.Name(), metadataReadAccess->GetMetadataFloatVector2(key.Category(), key.Name()));
break;
case MetadataType::FloatVector3:
SetMetadataFloatVector3(key.category, key.name, metadataReadAccess->GetMetadataFloatVector3(key.category, key.name));
SetMetadataFloatVector3(key.Category(), key.Name(), metadataReadAccess->GetMetadataFloatVector3(key.Category(), key.Name()));
break;
case MetadataType::FloatVector4:
SetMetadataFloatVector4(key.category, key.name, metadataReadAccess->GetMetadataFloatVector4(key.category, key.name));
SetMetadataFloatVector4(key.Category(), key.Name(), metadataReadAccess->GetMetadataFloatVector4(key.Category(), key.Name()));
break;
case MetadataType::Double:
SetMetadataDouble(key.category, key.name, metadataReadAccess->GetMetadataDouble(key.category, key.name));
SetMetadataDouble(key.Category(), key.Name(), metadataReadAccess->GetMetadataDouble(key.Category(), key.Name()));
break;
case MetadataType::DoubleVector2:
SetMetadataDoubleVector2(key.category, key.name, metadataReadAccess->GetMetadataDoubleVector2(key.category, key.name));
SetMetadataDoubleVector2(key.Category(), key.Name(), metadataReadAccess->GetMetadataDoubleVector2(key.Category(), key.Name()));
break;
case MetadataType::DoubleVector3:
SetMetadataDoubleVector3(key.category, key.name, metadataReadAccess->GetMetadataDoubleVector3(key