[Git][debian-gis-team/mapbox-geometry][master] 4 commits: New upstream version 1.1.0
Bas Couwenberg
gitlab at salsa.debian.org
Tue Jun 30 18:32:17 BST 2020
Bas Couwenberg pushed to branch master at Debian GIS Project / mapbox-geometry
Commits:
14299bf9 by Bas Couwenberg at 2020-06-30T19:24:21+02:00
New upstream version 1.1.0
- - - - -
d814d2ae by Bas Couwenberg at 2020-06-30T19:24:21+02:00
Update upstream source from tag 'upstream/1.1.0'
Update to upstream version '1.1.0'
with Debian dir bf387504f72509b56bbe43fc8707a83f2c3b233f
- - - - -
86624d7b by Bas Couwenberg at 2020-06-30T19:24:34+02:00
New upstream release.
- - - - -
0c9449f6 by Bas Couwenberg at 2020-06-30T19:25:08+02:00
Set distribution to unstable.
- - - - -
4 changed files:
- debian/changelog
- include/mapbox/feature.hpp
- test/feature.cpp
- test/io.cpp
Changes:
=====================================
debian/changelog
=====================================
@@ -1,12 +1,13 @@
-mapbox-geometry (1.0.0-2) UNRELEASED; urgency=medium
+mapbox-geometry (1.1.0-1) unstable; urgency=medium
+ * New upstream release.
* Bump Standards-Version to 4.5.0, no changes.
* Update gbp.conf to use --source-only-changes by default.
* Drop Name field from upstream metadata.
* Bump debhelper compat to 10, changes:
- Drop --parallel option, enabled by default
- -- Bas Couwenberg <sebastic at debian.org> Tue, 25 Dec 2018 22:33:34 +0100
+ -- Bas Couwenberg <sebastic at debian.org> Tue, 30 Jun 2020 19:25:01 +0200
mapbox-geometry (1.0.0-1) unstable; urgency=medium
=====================================
include/mapbox/feature.hpp
=====================================
@@ -24,6 +24,17 @@ constexpr bool operator<(const null_value_t&, const null_value_t&) { return fals
constexpr null_value_t null_value = null_value_t();
+#define DECLARE_VALUE_TYPE_ACCESOR(NAME, TYPE) \
+ TYPE* get##NAME() noexcept \
+ { \
+ return match( \
+ [](TYPE& val) -> TYPE* { return &val; }, \
+ [](auto&) -> TYPE* { return nullptr; }); \
+ } \
+ const TYPE* get##NAME() const noexcept \
+ { \
+ return const_cast<value*>(this)->get##NAME(); \
+ }
// Multiple numeric types (uint64_t, int64_t, double) are present in order to support
// the widest possible range of JSON numbers, which do not have a maximum range.
// Implementations that produce `value`s should use that order for type preference,
@@ -33,12 +44,50 @@ using value_base = mapbox::util::variant<null_value_t, bool, uint64_t, int64_t,
mapbox::util::recursive_wrapper<std::vector<value>>,
mapbox::util::recursive_wrapper<std::unordered_map<std::string, value>>>;
-struct value : value_base
+struct value : public value_base
{
- using value_base::value_base;
+ using array_type = std::vector<value>;
+ using object_type = std::unordered_map<std::string, value>;
+
+ value() : value_base(null_value) {}
+ value(null_value_t) : value_base(null_value) {}
+ value(bool v) : value_base(v) {}
+ value(const char* c) : value_base(std::string(c)) {}
+ value(std::string str) : value_base(std::move(str)) {}
+
+ template <typename T, typename std::enable_if_t<std::is_integral<T>::value, int> = 0,
+ typename std::enable_if_t<std::is_signed<T>::value, int> = 0>
+ value(T t) : value_base(int64_t(t))
+ {
+ }
+
+ template <typename T, typename std::enable_if_t<std::is_integral<T>::value, int> = 0,
+ typename std::enable_if_t<!std::is_signed<T>::value, int> = 0>
+ value(T t) : value_base(uint64_t(t))
+ {
+ }
+
+ template <typename T, typename std::enable_if_t<std::is_floating_point<T>::value, int> = 0>
+ value(T t) : value_base(double(t))
+ {
+ }
+ value(array_type array) : value_base(std::move(array)) {}
+ value(object_type object) : value_base(std::move(object)) {}
+
+ explicit operator bool() const { return !is<null_value_t>(); }
+
+ DECLARE_VALUE_TYPE_ACCESOR(Int, int64_t)
+ DECLARE_VALUE_TYPE_ACCESOR(Uint, uint64_t)
+ DECLARE_VALUE_TYPE_ACCESOR(Bool, bool)
+ DECLARE_VALUE_TYPE_ACCESOR(Double, double)
+ DECLARE_VALUE_TYPE_ACCESOR(Array, array_type)
+ DECLARE_VALUE_TYPE_ACCESOR(Object, object_type)
+ DECLARE_VALUE_TYPE_ACCESOR(String, std::string)
};
-using property_map = std::unordered_map<std::string, value>;
+#undef DECLARE_VALUE_TYPE_ACCESOR
+
+using property_map = value::object_type;
// The same considerations and requirement for numeric types apply as for `value_base`.
using identifier = mapbox::util::variant<null_value_t, uint64_t, int64_t, double, std::string>;
=====================================
test/feature.cpp
=====================================
@@ -7,6 +7,49 @@ using mapbox::feature::feature;
using mapbox::feature::feature_collection;
using mapbox::feature::null_value;
using mapbox::feature::null_value_t;
+using mapbox::feature::value;
+
+namespace {
+
+template <typename T, typename U>
+void checkType(U&& arg) try
+{
+ value v{std::forward<U>(arg)};
+ CHECK(v);
+ CHECK(v.template is<T>());
+ CHECK(v.template get<T>() == arg);
+}
+catch (...)
+{
+ FAIL();
+}
+
+} // namespace
+
+TEST_CASE("test value")
+{
+ CHECK(!value());
+ checkType<int64_t>(32);
+ checkType<uint64_t>(32u);
+ checkType<bool>(false);
+ checkType<std::string>("hello");
+
+ value intV{32};
+ CHECK_THROWS(intV.get<uint64_t>());
+
+ auto* result = intV.getInt();
+ CHECK(result);
+ CHECK(*result == 32);
+ *result = 100;
+ CHECK(intV.get<int64_t>() == 100);
+
+ CHECK_FALSE(intV.getUint());
+ CHECK_FALSE(intV.getBool());
+ CHECK_FALSE(intV.getDouble());
+ CHECK_FALSE(intV.getArray());
+ CHECK_FALSE(intV.getObject());
+ CHECK_FALSE(intV.getString());
+}
TEST_CASE("test feature")
{
=====================================
test/io.cpp
=====================================
@@ -5,6 +5,8 @@
TEST_CASE("operator<<")
{
+ mapbox::feature::null_value_t null;
+
mapbox::geometry::empty empty;
mapbox::geometry::point<double> point{10, 20};
mapbox::geometry::point<double> point2{30, 40};
@@ -16,6 +18,7 @@ TEST_CASE("operator<<")
mapbox::geometry::geometry_collection<double> collection{multiPolygon};
std::stringstream stream;
+ stream << null << std::endl;
stream << empty << std::endl;
stream << point << std::endl;
stream << lineString << std::endl;
@@ -31,6 +34,9 @@ TEST_CASE("operator<<")
std::getline(stream, line);
CHECK(line == std::string("[]"));
+ std::getline(stream, line);
+ CHECK(line == std::string("[]"));
+
std::getline(stream, line);
CHECK(line == std::string("[10,20]"));
View it on GitLab: https://salsa.debian.org/debian-gis-team/mapbox-geometry/-/compare/8b3297ff96a3dbaa1e8d6b479b4e54f18a9e7115...0c9449f6e39d66a8da67b8dc7194556732afee4e
--
View it on GitLab: https://salsa.debian.org/debian-gis-team/mapbox-geometry/-/compare/8b3297ff96a3dbaa1e8d6b479b4e54f18a9e7115...0c9449f6e39d66a8da67b8dc7194556732afee4e
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20200630/2481db9d/attachment-0001.html>
More information about the Pkg-grass-devel
mailing list