From c1117a4d33cf9fb7db9c5dbbc9172bce6b13bf77 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Tue, 29 Oct 2024 09:52:35 +0000 Subject: [PATCH 1/3] Empty featureset instead of invalid + `bool is_empty(featureset_ptr)` --- include/mapnik/featureset.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/mapnik/featureset.hpp b/include/mapnik/featureset.hpp index e300ff120..1ca576034 100644 --- a/include/mapnik/featureset.hpp +++ b/include/mapnik/featureset.hpp @@ -41,21 +41,21 @@ struct MAPNIK_DECL Featureset : private util::noncopyable virtual ~Featureset() {} }; -struct MAPNIK_DECL invalid_featureset : Featureset +struct MAPNIK_DECL empty_featureset : Featureset { feature_ptr next() { return feature_ptr(); } }; using featureset_ptr = std::shared_ptr; -inline featureset_ptr make_invalid_featureset() +inline featureset_ptr make_empty_featureset() { - return std::make_shared(); + return std::make_shared(); } -inline bool is_valid(featureset_ptr const& ptr) +inline bool is_empty(featureset_ptr const& ptr) { - return (dynamic_cast(ptr.get()) == nullptr) ? true : false; + return (dynamic_cast(ptr.get()) != nullptr) ? true : false; } } // namespace mapnik From cd082c5872e4c91152c4457a21d579e8749909b2 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Tue, 29 Oct 2024 09:56:03 +0000 Subject: [PATCH 2/3] Update version to 4.0.3 --- include/mapnik/version.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mapnik/version.hpp b/include/mapnik/version.hpp index 696f7c410..f38f043a5 100644 --- a/include/mapnik/version.hpp +++ b/include/mapnik/version.hpp @@ -27,7 +27,7 @@ #define MAPNIK_MAJOR_VERSION 4 #define MAPNIK_MINOR_VERSION 0 -#define MAPNIK_PATCH_VERSION 2 +#define MAPNIK_PATCH_VERSION 3 #define MAPNIK_VERSION MAPNIK_VERSION_ENCODE(MAPNIK_MAJOR_VERSION, MAPNIK_MINOR_VERSION, MAPNIK_PATCH_VERSION) From 92b1ea9cebe847d088b10331486b4c57dc79d944 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Tue, 29 Oct 2024 10:19:22 +0000 Subject: [PATCH 3/3] Commit staged changes --- plugins/input/csv/csv_datasource.cpp | 2 +- plugins/input/geojson/geojson_datasource.cpp | 2 +- plugins/input/ogr/ogr_datasource.cpp | 4 ++-- plugins/input/pgraster/pgraster_datasource.cpp | 6 +++--- plugins/input/postgis/postgis_datasource.cpp | 6 +++--- plugins/input/raster/raster_datasource.cpp | 2 +- plugins/input/sqlite/sqlite_datasource.cpp | 4 ++-- plugins/input/topojson/topojson_datasource.cpp | 2 +- src/map.cpp | 2 +- src/memory_datasource.cpp | 4 ++-- test/unit/datasource/memory.cpp | 4 ++-- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index 074f331a1..ce150d4ee 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -436,7 +436,7 @@ mapnik::featureset_ptr csv_datasource::features(mapnik::query const& q) const ctx_); } } - return mapnik::make_invalid_featureset(); + return mapnik::make_empty_featureset(); } mapnik::featureset_ptr csv_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp index ff7104d31..b72ae028a 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -595,7 +595,7 @@ mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) cons } } // otherwise return an empty featureset - return mapnik::make_invalid_featureset(); + return mapnik::make_empty_featureset(); } mapnik::featureset_ptr geojson_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const diff --git a/plugins/input/ogr/ogr_datasource.cpp b/plugins/input/ogr/ogr_datasource.cpp index 4d4d3508e..3f47654bf 100644 --- a/plugins/input/ogr/ogr_datasource.cpp +++ b/plugins/input/ogr/ogr_datasource.cpp @@ -558,7 +558,7 @@ featureset_ptr ogr_datasource::features(query const& q) const } } - return mapnik::make_invalid_featureset(); + return mapnik::make_empty_featureset(); } featureset_ptr ogr_datasource::features_at_point(coord2d const& pt, double tol) const @@ -595,5 +595,5 @@ featureset_ptr ogr_datasource::features_at_point(coord2d const& pt, double tol) } } - return mapnik::make_invalid_featureset(); + return mapnik::make_empty_featureset(); } diff --git a/plugins/input/pgraster/pgraster_datasource.cpp b/plugins/input/pgraster/pgraster_datasource.cpp index 40d002fcb..4068aa0c6 100644 --- a/plugins/input/pgraster/pgraster_datasource.cpp +++ b/plugins/input/pgraster/pgraster_datasource.cpp @@ -959,7 +959,7 @@ featureset_ptr pgraster_datasource::features_with_context(query const& q, proces ); } - return mapnik::make_invalid_featureset(); + return mapnik::make_empty_featureset(); } featureset_ptr pgraster_datasource::features_at_point(coord2d const& pt, double tol) const @@ -972,7 +972,7 @@ featureset_ptr pgraster_datasource::features_at_point(coord2d const& pt, double { shared_ptr conn = pool->borrowObject(); if (!conn) - return mapnik::make_invalid_featureset(); + return mapnik::make_empty_featureset(); if (conn->isOK()) { @@ -1042,7 +1042,7 @@ featureset_ptr pgraster_datasource::features_at_point(coord2d const& pt, double } } - return mapnik::make_invalid_featureset(); + return mapnik::make_empty_featureset(); } box2d pgraster_datasource::envelope() const diff --git a/plugins/input/postgis/postgis_datasource.cpp b/plugins/input/postgis/postgis_datasource.cpp index 251b16b56..7f0bc7621 100644 --- a/plugins/input/postgis/postgis_datasource.cpp +++ b/plugins/input/postgis/postgis_datasource.cpp @@ -890,7 +890,7 @@ featureset_ptr postgis_datasource::features_with_context(query const& q, process twkb_encoding_); } - return mapnik::make_invalid_featureset(); + return mapnik::make_empty_featureset(); } featureset_ptr postgis_datasource::features_at_point(coord2d const& pt, double tol) const @@ -903,7 +903,7 @@ featureset_ptr postgis_datasource::features_at_point(coord2d const& pt, double t { shared_ptr conn = pool->borrowObject(); if (!conn) - return mapnik::make_invalid_featureset(); + return mapnik::make_empty_featureset(); if (conn->isOK()) { @@ -973,7 +973,7 @@ featureset_ptr postgis_datasource::features_at_point(coord2d const& pt, double t } } - return mapnik::make_invalid_featureset(); + return mapnik::make_empty_featureset(); } box2d postgis_datasource::envelope() const diff --git a/plugins/input/raster/raster_datasource.cpp b/plugins/input/raster/raster_datasource.cpp index c6031a611..f467a456b 100644 --- a/plugins/input/raster/raster_datasource.cpp +++ b/plugins/input/raster/raster_datasource.cpp @@ -227,5 +227,5 @@ featureset_ptr raster_datasource::features_at_point(coord2d const&, double tol) { MAPNIK_LOG_WARN(raster) << "raster_datasource: feature_at_point not supported"; - return mapnik::make_invalid_featureset(); + return mapnik::make_empty_featureset(); } diff --git a/plugins/input/sqlite/sqlite_datasource.cpp b/plugins/input/sqlite/sqlite_datasource.cpp index afc9b9f30..b1f82e6dc 100644 --- a/plugins/input/sqlite/sqlite_datasource.cpp +++ b/plugins/input/sqlite/sqlite_datasource.cpp @@ -561,7 +561,7 @@ featureset_ptr sqlite_datasource::features(query const& q) const using_subquery_); } - return mapnik::make_invalid_featureset(); + return mapnik::make_empty_featureset(); } featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt, double tol) const @@ -640,5 +640,5 @@ featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt, double to using_subquery_); } - return mapnik::make_invalid_featureset(); + return mapnik::make_empty_featureset(); } diff --git a/plugins/input/topojson/topojson_datasource.cpp b/plugins/input/topojson/topojson_datasource.cpp index 8ef251b47..b53e03daf 100644 --- a/plugins/input/topojson/topojson_datasource.cpp +++ b/plugins/input/topojson/topojson_datasource.cpp @@ -277,7 +277,7 @@ mapnik::featureset_ptr topojson_datasource::features(mapnik::query const& q) con } } // otherwise return an empty featureset pointer - return mapnik::make_invalid_featureset(); + return mapnik::make_empty_featureset(); } mapnik::featureset_ptr topojson_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const diff --git a/src/map.cpp b/src/map.cpp index 96b3e2b1b..dfef663b4 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -738,7 +738,7 @@ featureset_ptr Map::query_point(unsigned index, double x, double y) const s << " (map has no layers)"; throw std::out_of_range(s.str()); } - return mapnik::make_invalid_featureset(); + return mapnik::make_empty_featureset(); } featureset_ptr Map::query_map_point(unsigned index, double x, double y) const diff --git a/src/memory_datasource.cpp b/src/memory_datasource.cpp index 6c9d045a6..93b05d220 100644 --- a/src/memory_datasource.cpp +++ b/src/memory_datasource.cpp @@ -125,7 +125,7 @@ featureset_ptr memory_datasource::features(const query& q) const { if (features_.empty()) { - return mapnik::make_invalid_featureset(); + return mapnik::make_empty_featureset(); } return std::make_shared(q.get_bbox(), *this, bbox_check_); } @@ -134,7 +134,7 @@ featureset_ptr memory_datasource::features_at_point(coord2d const& pt, double to { if (features_.empty()) { - return mapnik::make_invalid_featureset(); + return mapnik::make_empty_featureset(); } box2d box = box2d(pt.x, pt.y, pt.x, pt.y); box.pad(tol); diff --git a/test/unit/datasource/memory.cpp b/test/unit/datasource/memory.cpp index f476f64c7..967f887cb 100644 --- a/test/unit/datasource/memory.cpp +++ b/test/unit/datasource/memory.cpp @@ -7,7 +7,7 @@ * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. +i * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -36,7 +36,7 @@ TEST_CASE("memory datasource") mapnik::datasource_ptr ds = std::make_shared(params); CHECK(ds != nullptr); auto fs = all_features(ds); - REQUIRE(!mapnik::is_valid(fs)); + REQUIRE(mapnik::is_empty(fs)); while (auto f = fs->next()) { CHECK(false); // shouldn't get here