Skip to content

Commit

Permalink
Merge branch 'gh23'
Browse files Browse the repository at this point in the history
  • Loading branch information
kordejong committed Mar 19, 2024
2 parents bd21ee7 + 1ac90b8 commit 03e5ee3
Show file tree
Hide file tree
Showing 89 changed files with 5,030 additions and 5,392 deletions.
3 changes: 3 additions & 0 deletions source/data_model/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ if(LUE_DATA_MODEL_WITH_UTILITIES OR LUE_BUILD_VIEW)
endif()

if(LUE_DATA_MODEL_WITH_UTILITIES)
add_subdirectory(gdal)
list(APPEND doxygen_input ${CMAKE_CURRENT_SOURCE_DIR}/gdal)

add_subdirectory(translate)
list(APPEND doxygen_input ${CMAKE_CURRENT_SOURCE_DIR}/translate)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ namespace lue {

void expand(Count nr_objects, ID const* ids, hdf5::Shape::value_type const* shapes);

void expand(ID id, hdf5::Shape const& shape);
void expand(ID id, hdf5::Shape const& shape, void const* no_data_value = nullptr);

bool contains(ID id) const;

Array operator[](ID id) const;

private:

void expand_core(ID id, hdf5::Shape const& shape);
void expand_core(ID id, hdf5::Shape const& shape, void const* no_data_value = nullptr);

Count _nr_objects;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,32 @@ namespace lue {


Value create_value(
hdf5::Group& parent, std::string const& name, hdf5::Datatype const& memory_datatype);
hdf5::Group& parent,
std::string const& name,
hdf5::Datatype const& memory_datatype,
void const* no_data_value = nullptr);

Value create_value(
hdf5::Group& parent,
std::string const& name,
hdf5::Datatype const& memory_datatype,
hdf5::Shape const& array_shape);
hdf5::Shape const& array_shape,
void const* no_data_value = nullptr);

Value create_value(
hdf5::Group& parent,
std::string const& name,
hdf5::Datatype const& file_datatype,
hdf5::Datatype const& memory_datatype);
hdf5::Datatype const& memory_datatype,
void const* no_data_value = nullptr);

Value create_value(
hdf5::Group& parent,
std::string const& name,
hdf5::Datatype const& file_datatype,
hdf5::Datatype const& memory_datatype,
hdf5::Shape const& array_shape);
hdf5::Shape const& array_shape,
void const* no_data_value = nullptr);

bool value_exists(hdf5::Group const& parent, std::string const& name);

Expand Down
14 changes: 10 additions & 4 deletions source/data_model/cxx/include/lue/array/same_shape/value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,26 +68,32 @@ namespace lue {


Value create_value(
hdf5::Group& parent, std::string const& name, hdf5::Datatype const& memory_datatype);
hdf5::Group& parent,
std::string const& name,
hdf5::Datatype const& memory_datatype,
void const* no_data_value = nullptr);

Value create_value(
hdf5::Group& parent,
std::string const& name,
hdf5::Datatype const& memory_datatype,
hdf5::Shape const& array_shape);
hdf5::Shape const& array_shape,
void const* no_data_value = nullptr);

Value create_value(
hdf5::Group& parent,
std::string const& name,
hdf5::Datatype const& file_datatype,
hdf5::Datatype const& memory_datatype);
hdf5::Datatype const& memory_datatype,
void const* no_data_value = nullptr);

Value create_value(
hdf5::Group& parent,
std::string const& name,
hdf5::Datatype const& file_datatype,
hdf5::Datatype const& memory_datatype,
hdf5::Shape const& array_shape);
hdf5::Shape const& array_shape,
void const* no_data_value = nullptr);

} // namespace same_shape
} // namespace data_model
Expand Down
17 changes: 17 additions & 0 deletions source/data_model/cxx/include/lue/core/array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,23 @@ namespace lue {
TransferPropertyList const& transfer_property_list,
void const* buffer);


template<typename Element>
void set_no_data_value(Element const no_data_value)
{
creation_property_list().set_fill_value<Element>(no_data_value);
}


template<typename Element>
auto no_data_value() const -> Element
{
return creation_property_list().get_fill_value<Element>();
}


auto has_no_data_value() const -> bool;

protected:

private:
Expand Down
11 changes: 8 additions & 3 deletions source/data_model/cxx/src/array/different_shape/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ namespace lue {
@param id The object ID
@param shape The shape of the object array
*/
void Value::expand(ID const id, hdf5::Shape const& shape)
void Value::expand(ID const id, hdf5::Shape const& shape, void const* no_data_value)
{
expand_core(id, shape);
expand_core(id, shape, no_data_value);

_nr_objects += 1;

Expand All @@ -111,7 +111,7 @@ namespace lue {
@param id The object ID
@param shape The shape of the object array
*/
void Value::expand_core(ID const id, hdf5::Shape const& array_shape)
void Value::expand_core(ID const id, hdf5::Shape const& array_shape, void const* no_data_value)
{
assert(!contains(id));

Expand All @@ -125,6 +125,11 @@ namespace lue {
// hdf5::chunk_shape(array_shape, file_datatype.size());
// creation_property_list.set_chunk(chunk_dimension_sizes);

if (no_data_value)
{
creation_property_list.set_fill_value(memory_datatype(), no_data_value);
}

/* auto dataset = */ hdf5::create_dataset(
this->id(), name, file_datatype(), dataspace, creation_property_list);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,18 @@ namespace lue {
@brief Create value @a name in @a parent
*/
Value create_value(
hdf5::Group& parent, std::string const& name, hdf5::Datatype const& memory_datatype)
hdf5::Group& parent,
std::string const& name,
hdf5::Datatype const& memory_datatype,
void const* no_data_value)
{
return create_value(
parent, name, file_datatype(memory_datatype), memory_datatype, hdf5::Shape{});
parent,
name,
file_datatype(memory_datatype),
memory_datatype,
hdf5::Shape{},
no_data_value);
}


Expand All @@ -151,10 +159,16 @@ namespace lue {
hdf5::Group& parent,
std::string const& name,
hdf5::Datatype const& memory_datatype,
hdf5::Shape const& array_shape)
hdf5::Shape const& array_shape,
void const* no_data_value)
{
return create_value(
parent, name, file_datatype(memory_datatype), memory_datatype, array_shape);
parent,
name,
file_datatype(memory_datatype),
memory_datatype,
array_shape,
no_data_value);
}


Expand All @@ -165,9 +179,11 @@ namespace lue {
hdf5::Group& parent,
std::string const& name,
hdf5::Datatype const& file_datatype,
hdf5::Datatype const& memory_datatype)
hdf5::Datatype const& memory_datatype,
void const* no_data_value)
{
return create_value(parent, name, file_datatype, memory_datatype, hdf5::Shape{});
return create_value(
parent, name, file_datatype, memory_datatype, hdf5::Shape{}, no_data_value);
}


Expand All @@ -184,7 +200,8 @@ namespace lue {
std::string const& name,
hdf5::Datatype const& file_datatype,
hdf5::Datatype const& memory_datatype,
hdf5::Shape const& array_shape)
hdf5::Shape const& array_shape,
void const* no_data_value)
{
// The rank of the underlying dataset is one larger than the rank of the
// object arrays. Object arrays are stored one after the other.
Expand All @@ -202,6 +219,11 @@ namespace lue {
hdf5::chunk_shape(array_shape, file_datatype.size())};
creation_property_list.set_chunk(chunk_dimension_sizes);

if (no_data_value)
{
creation_property_list.set_fill_value(memory_datatype, no_data_value);
}

hdf5::Dataset dataset{hdf5::create_dataset(
parent.id(), name, file_datatype, dataspace, creation_property_list)};

Expand Down
36 changes: 29 additions & 7 deletions source/data_model/cxx/src/array/same_shape/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,18 @@ namespace lue {
@brief Create value @a name in @a parent
*/
Value create_value(
hdf5::Group& parent, std::string const& name, hdf5::Datatype const& memory_datatype)
hdf5::Group& parent,
std::string const& name,
hdf5::Datatype const& memory_datatype,
void const* no_data_value)
{
return create_value(
parent, name, file_datatype(memory_datatype), memory_datatype, hdf5::Shape{});
parent,
name,
file_datatype(memory_datatype),
memory_datatype,
hdf5::Shape{},
no_data_value);
}


Expand All @@ -142,10 +150,16 @@ namespace lue {
hdf5::Group& parent,
std::string const& name,
hdf5::Datatype const& memory_datatype,
hdf5::Shape const& array_shape)
hdf5::Shape const& array_shape,
void const* no_data_value)
{
return create_value(
parent, name, file_datatype(memory_datatype), memory_datatype, array_shape);
parent,
name,
file_datatype(memory_datatype),
memory_datatype,
array_shape,
no_data_value);
}


Expand All @@ -156,9 +170,11 @@ namespace lue {
hdf5::Group& parent,
std::string const& name,
hdf5::Datatype const& file_datatype,
hdf5::Datatype const& memory_datatype)
hdf5::Datatype const& memory_datatype,
void const* no_data_value)
{
return create_value(parent, name, file_datatype, memory_datatype, hdf5::Shape{});
return create_value(
parent, name, file_datatype, memory_datatype, hdf5::Shape{}, no_data_value);
}


Expand All @@ -175,7 +191,8 @@ namespace lue {
std::string const& name,
hdf5::Datatype const& file_datatype,
hdf5::Datatype const& memory_datatype,
hdf5::Shape const& array_shape)
hdf5::Shape const& array_shape,
void const* no_data_value)
{
// The rank of the underlying dataset is one larger than the rank of the
// object arrays. Object arrays are stored one after the other.
Expand All @@ -191,6 +208,11 @@ namespace lue {
auto chunk_dimension_sizes = hdf5::chunk_shape(array_shape, file_datatype.size());
creation_property_list.set_chunk(chunk_dimension_sizes);

if (no_data_value)
{
creation_property_list.set_fill_value(memory_datatype, no_data_value);
}

hdf5::Dataset dataset{hdf5::create_dataset(
parent.id(), name, file_datatype, dataspace, creation_property_list)};

Expand Down
6 changes: 6 additions & 0 deletions source/data_model/cxx/src/core/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,11 @@ namespace lue {
_memory_datatype, memory_dataspace, hyperslab, transfer_property_list, buffer);
}


auto Array::has_no_data_value() const -> bool
{
return creation_property_list().fill_value_defined();
}

} // namespace data_model
} // namespace lue
60 changes: 60 additions & 0 deletions source/data_model/gdal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
add_test_conditionally(test)

configure_file(
include/configure.hpp.in
include/lue/gdal/configure.hpp
)

configure_file(
src/version.cpp.in
src/version.cpp
)

add_library(lue_gdal STATIC
src/blocks.cpp
src/compare_rasters.cpp
src/data_type.cpp
src/dataset.cpp
src/driver.cpp
src/error.cpp
src/raster.cpp
src/raster_band.cpp
${CMAKE_CURRENT_BINARY_DIR}/src/version.cpp
)

add_library(lue::gdal ALIAS lue_gdal)

set_target_properties(lue_gdal
PROPERTIES
EXPORT_NAME gdal
)

target_include_directories(lue_gdal
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
)

target_sources(lue_gdal
PUBLIC
FILE_SET HEADERS
BASE_DIRS
include
${CMAKE_CURRENT_BINARY_DIR}/include
FILES
include/lue
${CMAKE_CURRENT_BINARY_DIR}/include/lue/gdal/configure.hpp
)

# NOTE: Think twice before adding libraries here. lue::gdal is a simple, thin API around the
# GDAL API.
target_link_libraries(lue_gdal
PUBLIC
GDAL::GDAL
PRIVATE
fmt::fmt
)

lue_install_development_libraries(
TARGETS lue_gdal
)
15 changes: 15 additions & 0 deletions source/data_model/gdal/doc/lue_gdal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[TOC]

# lue_gdal {#lue_gdal}


# Introduction {#lue_gdal_introduction}
TODO


# Design
TODO


# See also {#lue_gdal_see_also}
- [GDAL API](https://gdal.org/api/index.html)
Loading

0 comments on commit 03e5ee3

Please sign in to comment.