Skip to content

Commit

Permalink
Fix gcc 13 build
Browse files Browse the repository at this point in the history
Fixes #119
  • Loading branch information
dbaston committed Jun 4, 2024
1 parent 3177ef6 commit b85217a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
20 changes: 7 additions & 13 deletions src/map_feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class MapFeature : public Feature

DoubleArray get_double_array(const std::string& name) const override
{
return get<DoubleArray>(name);
return std::get<DoubleArray>(m_map.at(name));
}

void set(const std::string& name, std::int32_t value) override
Expand All @@ -79,7 +79,7 @@ class MapFeature : public Feature

IntegerArray get_integer_array(const std::string& name) const override
{
return get<IntegerArray>(name);
return std::get<IntegerArray>(m_map.at(name));
}

void set(const std::string& name, std::int64_t value) override
Expand All @@ -94,7 +94,7 @@ class MapFeature : public Feature

Integer64Array get_integer64_array(const std::string& name) const override
{
return get<Integer64Array>(name);
return std::get<Integer64Array>(m_map.at(name));
}

void set(const std::string& name, std::string value) override
Expand Down Expand Up @@ -130,30 +130,24 @@ class MapFeature : public Feature
return m_map;
}

template<typename T>
T get(const std::string& field) const
{
return std::get<T>(m_map.at(field));
}

std::string get_string(const std::string& name) const override
{
return get<std::string>(name);
return std::get<std::string>(m_map.at(name));
}

double get_double(const std::string& name) const override
{
return get<double>(name);
return std::get<double>(m_map.at(name));
}

std::int32_t get_int(const std::string& name) const override
{
return get<std::int32_t>(name);
return std::get<std::int32_t>(m_map.at(name));
}

std::int64_t get_int64(const std::string& name) const override
{
return get<std::int64_t>(name);
return std::get<std::int64_t>(m_map.at(name));
}

private:
Expand Down
1 change: 1 addition & 0 deletions src/raster.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <array>
#include <cmath>
#include <cstdint>
#include <limits>
#include <variant>

Expand Down
1 change: 1 addition & 0 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#pragma once

#include <algorithm>
#include <cstdint>
#include <limits>
#include <map>
#include <memory>
Expand Down
16 changes: 8 additions & 8 deletions test/test_operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ TEST_CASE("Operations dispatch to the correct RasterStats function", "[operation

const MapFeature& f = writer.m_feature;

CHECK(f.get<double>(stat) == Approx(expected));
CHECK(f.get_double(stat) == Approx(expected));
}

TEMPLATE_TEST_CASE("result_type returns correct result", "[operation]", double, float, std::int8_t, std::uint8_t, std::int16_t, std::uint16_t, std::int32_t, std::uint32_t, std::int64_t, std::uint64_t)
Expand Down Expand Up @@ -285,8 +285,8 @@ TEMPLATE_TEST_CASE("no error if feature does not intersect raster", "[processor]
processor.process();

const MapFeature& f = writer.m_feature;
CHECK(f.get<double>("count") == 0);
CHECK(std::isnan(f.get<double>("median")));
CHECK(f.get_double("count") == 0);
CHECK(std::isnan(f.get_double("median")));
}

TEMPLATE_TEST_CASE("correct result for feature partially intersecting raster", "[processor]", FeatureSequentialProcessor, RasterSequentialProcessor)
Expand Down Expand Up @@ -316,8 +316,8 @@ TEMPLATE_TEST_CASE("correct result for feature partially intersecting raster", "
processor.process();

const MapFeature& f = writer.m_feature;
CHECK(f.get<double>("count") == 1);
CHECK(f.get<double>("median") == 3);
CHECK(f.get_double("count") == 1);
CHECK(f.get_double("median") == 3);
}

TEMPLATE_TEST_CASE("include_col and include_geom work as expected", "[processor]", FeatureSequentialProcessor, RasterSequentialProcessor)
Expand Down Expand Up @@ -352,9 +352,9 @@ TEMPLATE_TEST_CASE("include_col and include_geom work as expected", "[processor]
ds.next();

const MapFeature& f = writer.m_feature;
CHECK(f.get<double>("count") == 4.0);
CHECK(f.get<std::string>("fid") == "15");
CHECK(f.get<std::int32_t>("type") == 13);
CHECK(f.get_double("count") == 4.0);
CHECK(f.get_string("fid") == "15");
CHECK(f.get_int("type") == 13);
CHECK(GEOSEquals_r(context, f.geometry(), ds.feature().geometry()) == 1);
}

Expand Down

0 comments on commit b85217a

Please sign in to comment.