From 5298a737c8586b74eda901ca6a45fb19c135ae14 Mon Sep 17 00:00:00 2001 From: artemp Date: Thu, 11 Aug 2016 15:57:22 +0100 Subject: [PATCH 01/21] update deps --- deps/mapbox/variant | 2 +- test/data | 2 +- test/data-visual | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deps/mapbox/variant b/deps/mapbox/variant index 8e2f69641..aaddee927 160000 --- a/deps/mapbox/variant +++ b/deps/mapbox/variant @@ -1 +1 @@ -Subproject commit 8e2f6964157885f1655c1673d65f3aea9b90fe18 +Subproject commit aaddee9270e3956cee98cdd7d04aea848d69f5f0 diff --git a/test/data b/test/data index e74f1cef0..ca5716fce 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit e74f1cef09d579d6ff414cb56970adbe43b7a91b +Subproject commit ca5716fcef3ed33b319d3047f7d8190bf6ed6081 diff --git a/test/data-visual b/test/data-visual index 48c10bbef..bb0a8927f 160000 --- a/test/data-visual +++ b/test/data-visual @@ -1 +1 @@ -Subproject commit 48c10bbef90017f94ab529c43287d8bb84f14159 +Subproject commit bb0a8927f4305df861d1b5c6366216bb4e530975 From 74d7726b2d49916cca24529c0f4cc1689eb84a6f Mon Sep 17 00:00:00 2001 From: bergwerkgis Date: Fri, 12 Aug 2016 05:27:55 +0000 Subject: [PATCH 02/21] remove unneeded 'u8' --- test/unit/core/expressions_test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unit/core/expressions_test.cpp b/test/unit/core/expressions_test.cpp index c10982f78..22ba3c00d 100644 --- a/test/unit/core/expressions_test.cpp +++ b/test/unit/core/expressions_test.cpp @@ -180,14 +180,14 @@ TEST_CASE("expressions") //'\u265C\u265E\u265D\u265B\u265A\u265D\u265E\u265C' - black chess figures // replace black knights with white knights auto val0 = eval(u8"'\u265C\u265E\u265D\u265B\u265A\u265D\u265E\u265C'.replace('\u265E','\u2658')"); - auto val1 = eval(u8"'♜♞♝♛♚♝♞♜'.replace('♞','♘')"); // ==> expected ♜♘♝♛♚♝♘♜ + auto val1 = eval("'♜♞♝♛♚♝♞♜'.replace('♞','♘')"); // ==> expected ♜♘♝♛♚♝♘♜ TRY_CHECK(val0 == val1); TRY_CHECK(val0.to_string() == val1.to_string()); // UTF-8 TRY_CHECK(val0.to_unicode() == val1.to_unicode()); // Unicode (UTF-16) // following test will fail if boost_regex is built without ICU support (unpaired surrogates in output) - TRY_CHECK(eval("[name].replace('(\\B)|( )',' ') ") == tr.transcode(u8"Q u é b e c")); - TRY_CHECK(eval("'Москва'.replace('(? Date: Fri, 12 Aug 2016 11:04:30 +0100 Subject: [PATCH 03/21] json stringifier - add missing quoting in nested json objects (ref #3491) --- include/mapnik/json/stringifier.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mapnik/json/stringifier.hpp b/include/mapnik/json/stringifier.hpp index 93906f6ec..44b9425d8 100644 --- a/include/mapnik/json/stringifier.hpp +++ b/include/mapnik/json/stringifier.hpp @@ -86,7 +86,7 @@ struct stringifier { if (first) first = false; else str += ","; - str += kv.first; + str += "\"" + kv.first + "\""; str += ":"; str += mapnik::util::apply_visitor(*this, kv.second); } From 5c11fe49f9d428d140f73d513d43cebed4678a81 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 12 Aug 2016 11:05:50 +0100 Subject: [PATCH 04/21] geoson+topojson tests - correct expected test data (ref #3491) --- test/unit/datasource/geojson.cpp | 8 ++++---- test/unit/datasource/topojson.cpp | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/test/unit/datasource/geojson.cpp b/test/unit/datasource/geojson.cpp index 1edeb4b55..60052db8b 100644 --- a/test/unit/datasource/geojson.cpp +++ b/test/unit/datasource/geojson.cpp @@ -701,12 +701,12 @@ TEST_CASE("geojson") { attr{"description", tr.transcode("Test: \u005C")}, attr{"double", mapnik::value_double(1.1)}, attr{"int", mapnik::value_integer(1)}, - attr{"object", tr.transcode("{name:\"waka\",spaces:\"value with spaces\",int:1,double:1.1,boolean:false" - ",NOM_FR:\"Québec\",array:[\"string\",\"value with spaces\",3,1.1,null,true" - ",\"Québec\"],another_object:{name:\"nested object\"}}")}, + attr{"object", tr.transcode("{\"name\":\"waka\",\"spaces\":\"value with spaces\",\"int\":1,\"double\":1.1,\"boolean\":false" + ",\"NOM_FR\":\"Québec\",\"array\":[\"string\",\"value with spaces\",3,1.1,null,true" + ",\"Québec\"],\"another_object\":{\"name\":\"nested object\"}}")}, attr{"spaces", tr.transcode("this has spaces")}, attr{"array", tr.transcode("[\"string\",\"value with spaces\",3,1.1,null,true," - "\"Québec\",{name:\"object within an array\"}," + "\"Québec\",{\"name\":\"object within an array\"}," "[\"array\",\"within\",\"an\",\"array\"]]")}, attr{"empty_array", tr.transcode("[]")}, attr{"empty_object", tr.transcode("{}")}, diff --git a/test/unit/datasource/topojson.cpp b/test/unit/datasource/topojson.cpp index 6b1a2e1b1..41d9b1908 100644 --- a/test/unit/datasource/topojson.cpp +++ b/test/unit/datasource/topojson.cpp @@ -48,7 +48,6 @@ bool parse_topology(std::string const& filename, mapnik::topojson::topology & to return (result && (itr == end)); } - } TEST_CASE("topojson") @@ -97,12 +96,12 @@ TEST_CASE("topojson") attr{"description", tr.transcode("Test: \u005C")}, attr{"double", mapnik::value_double(1.1)}, attr{"int", mapnik::value_integer(1)}, - attr{"object", tr.transcode("{name:\"waka\",spaces:\"value with spaces\",int:1,double:1.1,boolean:false" - ",NOM_FR:\"Québec\",array:[\"string\",\"value with spaces\",3,1.1,null,true" - ",\"Québec\"],another_object:{name:\"nested object\"}}")}, + attr{"object", tr.transcode("{\"name\":\"waka\",\"spaces\":\"value with spaces\",\"int\":1,\"double\":1.1,\"boolean\":false" + ",\"NOM_FR\":\"Québec\",\"array\":[\"string\",\"value with spaces\",3,1.1,null,true" + ",\"Québec\"],\"another_object\":{\"name\":\"nested object\"}}")}, attr{"spaces", tr.transcode("this has spaces")}, attr{"array", tr.transcode("[\"string\",\"value with spaces\",3,1.1,null,true," - "\"Québec\",{name:\"object within an array\"}," + "\"Québec\",{\"name\":\"object within an array\"}," "[\"array\",\"within\",\"an\",\"array\"]]")}, attr{"empty_array", tr.transcode("[]")}, attr{"empty_object", tr.transcode("{}")}, From f9c321583f0022b5989f2cc72eef79a3f36ff0ad Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 12 Aug 2016 15:56:29 +0100 Subject: [PATCH 05/21] update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c3c00ba9..9840af1ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ Released: xx-xx-xx - Added support for quantising small (less than 3 pixel) images (ref #3466) - Added support for natural logarithm function in expressions (ref #3475) - Improved logic determining if certain compiler features are available e.g `inheriting constructors` (MSVC) +- GeoJSON - corrected quoting in `stringgifird` objects (ref #3491) ## 3.0.11 From 843f96083d08e2da8a8520a2331c679188b88c97 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Fri, 12 Aug 2016 16:00:21 -0700 Subject: [PATCH 06/21] update libwebp, always link mason packages --- bootstrap.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index 62eb1ecf6..113d60f8c 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -30,7 +30,6 @@ function install() { MASON_PLATFORM_ID=$(mason env MASON_PLATFORM_ID) if [[ ! -d ./mason_packages/${MASON_PLATFORM_ID}/${1}/${2} ]]; then mason install $1 $2 - mason link $1 $2 if [[ ${3:-false} != false ]]; then LA_FILE=$(mason prefix $1 $2)/lib/$3.la if [[ -f ${LA_FILE} ]]; then @@ -40,6 +39,7 @@ function install() { fi fi fi + mason link $1 $2 } ICU_VERSION="55.1" @@ -60,7 +60,7 @@ function install_mason_deps() { install protobuf 2.6.1 & # technically protobuf is not a mapnik core dep, but installing # here by default helps make mapnik-vector-tile builds easier - install webp 0.4.2 libwebp & + install webp 0.5.0 libwebp & install gdal 1.11.2 libgdal & install boost 1.61.0 & install boost_libsystem 1.61.0 & From 31814b32d090885758b04b9c910a05518dd10f24 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 15 Aug 2016 10:41:30 +0100 Subject: [PATCH 07/21] rename `empty_featureset` => `invalid_featureset` to avoid ambiguity + add helper `is_valid` method --- include/mapnik/featureset.hpp | 14 +++++++++----- 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 +- 10 files changed, 24 insertions(+), 20 deletions(-) diff --git a/include/mapnik/featureset.hpp b/include/mapnik/featureset.hpp index 6886d8755..e528d7de0 100644 --- a/include/mapnik/featureset.hpp +++ b/include/mapnik/featureset.hpp @@ -41,21 +41,25 @@ struct MAPNIK_DECL Featureset : private util::noncopyable virtual ~Featureset() {} }; - -struct MAPNIK_DECL empty_featureset final : Featureset +struct MAPNIK_DECL invalid_featureset final : Featureset { feature_ptr next() { return feature_ptr(); } - ~empty_featureset() {} + ~invalid_featureset() {} }; using featureset_ptr = std::shared_ptr; -inline featureset_ptr make_empty_featureset() +inline featureset_ptr make_invalid_featureset() { - return std::make_shared(); + return std::make_shared(); +} + +inline bool is_valid(featureset_ptr const& ptr) +{ + return (dynamic_cast(ptr.get()) == nullptr) ? false : true; } } diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index 4a246b404..322940528 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -431,7 +431,7 @@ mapnik::featureset_ptr csv_datasource::features(mapnik::query const& q) const return std::make_shared(filename_, filter, locator_, separator_, quote_, headers_, ctx_); } } - return mapnik::make_empty_featureset(); + return mapnik::make_invalid_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 d2ebc2d54..eec7c6f15 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -588,7 +588,7 @@ mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) cons } // otherwise return an empty featureset - return mapnik::make_empty_featureset(); + return mapnik::make_invalid_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 2943962fc..706a376e3 100644 --- a/plugins/input/ogr/ogr_datasource.cpp +++ b/plugins/input/ogr/ogr_datasource.cpp @@ -560,7 +560,7 @@ featureset_ptr ogr_datasource::features(query const& q) const } } - return mapnik::make_empty_featureset(); + return mapnik::make_invalid_featureset(); } featureset_ptr ogr_datasource::features_at_point(coord2d const& pt, double tol) const @@ -603,5 +603,5 @@ featureset_ptr ogr_datasource::features_at_point(coord2d const& pt, double tol) } } - return mapnik::make_empty_featureset(); + return mapnik::make_invalid_featureset(); } diff --git a/plugins/input/pgraster/pgraster_datasource.cpp b/plugins/input/pgraster/pgraster_datasource.cpp index ced1810b5..e6eddf758 100644 --- a/plugins/input/pgraster/pgraster_datasource.cpp +++ b/plugins/input/pgraster/pgraster_datasource.cpp @@ -998,7 +998,7 @@ featureset_ptr pgraster_datasource::features_with_context(query const& q,process } - return mapnik::make_empty_featureset(); + return mapnik::make_invalid_featureset(); } @@ -1011,7 +1011,7 @@ featureset_ptr pgraster_datasource::features_at_point(coord2d const& pt, double if (pool) { shared_ptr conn = pool->borrowObject(); - if (!conn) return mapnik::make_empty_featureset(); + if (!conn) return mapnik::make_invalid_featureset(); if (conn->isOK()) { @@ -1082,7 +1082,7 @@ featureset_ptr pgraster_datasource::features_at_point(coord2d const& pt, double } } - return mapnik::make_empty_featureset(); + return mapnik::make_invalid_featureset(); } box2d pgraster_datasource::envelope() const diff --git a/plugins/input/postgis/postgis_datasource.cpp b/plugins/input/postgis/postgis_datasource.cpp index 2653e5757..10ce521d0 100644 --- a/plugins/input/postgis/postgis_datasource.cpp +++ b/plugins/input/postgis/postgis_datasource.cpp @@ -942,7 +942,7 @@ featureset_ptr postgis_datasource::features_with_context(query const& q,processo } - return mapnik::make_empty_featureset(); + return mapnik::make_invalid_featureset(); } @@ -955,7 +955,7 @@ featureset_ptr postgis_datasource::features_at_point(coord2d const& pt, double t if (pool) { shared_ptr conn = pool->borrowObject(); - if (!conn) return mapnik::make_empty_featureset(); + if (!conn) return mapnik::make_invalid_featureset(); if (conn->isOK()) { @@ -1030,7 +1030,7 @@ featureset_ptr postgis_datasource::features_at_point(coord2d const& pt, double t } } - return mapnik::make_empty_featureset(); + return mapnik::make_invalid_featureset(); } box2d postgis_datasource::envelope() const diff --git a/plugins/input/raster/raster_datasource.cpp b/plugins/input/raster/raster_datasource.cpp index 38a6aa94c..e059247cd 100644 --- a/plugins/input/raster/raster_datasource.cpp +++ b/plugins/input/raster/raster_datasource.cpp @@ -224,5 +224,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_empty_featureset(); + return mapnik::make_invalid_featureset(); } diff --git a/plugins/input/sqlite/sqlite_datasource.cpp b/plugins/input/sqlite/sqlite_datasource.cpp index 37e44117b..28add6453 100644 --- a/plugins/input/sqlite/sqlite_datasource.cpp +++ b/plugins/input/sqlite/sqlite_datasource.cpp @@ -551,7 +551,7 @@ featureset_ptr sqlite_datasource::features(query const& q) const using_subquery_); } - return mapnik::make_empty_featureset(); + return mapnik::make_invalid_featureset(); } featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt, double tol) const @@ -631,5 +631,5 @@ featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt, double to using_subquery_); } - return mapnik::make_empty_featureset(); + return mapnik::make_invalid_featureset(); } diff --git a/plugins/input/topojson/topojson_datasource.cpp b/plugins/input/topojson/topojson_datasource.cpp index e6cab26d8..2cfad1fb8 100644 --- a/plugins/input/topojson/topojson_datasource.cpp +++ b/plugins/input/topojson/topojson_datasource.cpp @@ -284,7 +284,7 @@ mapnik::featureset_ptr topojson_datasource::features(mapnik::query const& q) con } } // otherwise return an empty featureset pointer - return mapnik::make_empty_featureset(); + return mapnik::make_invalid_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 9f1b6a5ed..ec0d9f83e 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -746,7 +746,7 @@ featureset_ptr Map::query_point(unsigned index, double x, double y) const else s << " (map has no layers)"; throw std::out_of_range(s.str()); } - return mapnik::make_empty_featureset(); + return mapnik::make_invalid_featureset(); } featureset_ptr Map::query_map_point(unsigned index, double x, double y) const From 008a6eb4cfd76fc6dbc500417c6c5031c1247348 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 15 Aug 2016 10:44:54 +0100 Subject: [PATCH 08/21] test geojson - add empty featurecollection test --- test/data | 2 +- test/unit/datasource/geojson.cpp | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/test/data b/test/data index ca5716fce..14eabf8f4 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit ca5716fcef3ed33b319d3047f7d8190bf6ed6081 +Subproject commit 14eabf8f407294e71636cddfce68297a4f4e0303 diff --git a/test/unit/datasource/geojson.cpp b/test/unit/datasource/geojson.cpp index 60052db8b..cf3214862 100644 --- a/test/unit/datasource/geojson.cpp +++ b/test/unit/datasource/geojson.cpp @@ -96,6 +96,25 @@ TEST_CASE("geojson") { } } + SECTION("GeoJSON an empty FeatureCollection") + { + for (auto cache_features : {true, false}) + { + mapnik::parameters params; + params["type"] = "geojson"; + params["file"] = "./test/data/json/empty_featurecollection.json"; + params["cache_features"] = cache_features; + auto ds = mapnik::datasource_cache::instance().create(params); + CHECK(ds != nullptr); + auto fs = all_features(ds); + REQUIRE(mapnik::is_valid(fs)); + while (auto f = fs->next()) + { + CHECK(false); // shouldn't get here + } + } + } + SECTION("GeoJSON invalid Point") { for (auto cache_features : {true, false}) @@ -285,8 +304,6 @@ TEST_CASE("geojson") { } auto features = ds->features(query); auto features2 = ds->features_at_point(ds->envelope().center(),0); - REQUIRE(features != nullptr); - REQUIRE(features2 != nullptr); auto feature = features->next(); auto feature2 = features2->next(); REQUIRE(feature != nullptr); @@ -404,7 +421,6 @@ TEST_CASE("geojson") { query.add_property_name(field.get_name()); } auto features = ds->features(query); - REQUIRE(features != nullptr); auto feature = features->next(); REQUIRE(feature != nullptr); REQUIRE(feature->envelope() == mapnik::box2d(123,456,123,456)); @@ -693,7 +709,6 @@ TEST_CASE("geojson") { REQUIRE_FIELD_NAMES(fields, names); auto fs = all_features(ds); - REQUIRE(bool(fs)); std::initializer_list attrs = { attr{"name", tr.transcode("Test")}, attr{"NOM_FR", tr.transcode("Québec")}, From 0471f3369a2667a362bc30e7d9949a55e588f14c Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 15 Aug 2016 12:20:19 +0100 Subject: [PATCH 09/21] add order_by_name helper method --- include/mapnik/feature_layer_desc.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/mapnik/feature_layer_desc.hpp b/include/mapnik/feature_layer_desc.hpp index 9d1186a7c..cd69d831f 100644 --- a/include/mapnik/feature_layer_desc.hpp +++ b/include/mapnik/feature_layer_desc.hpp @@ -94,12 +94,21 @@ public: { return extra_params_; } + bool has_name(std::string const& name) const { auto result = std::find_if(std::begin(descriptors_), std::end(descriptors_), [&name](attribute_descriptor const& desc) { return name == desc.get_name();}); return result != std::end(descriptors_); } + void order_by_name() + { + std::sort(std::begin(descriptors_), std::end(descriptors_), + [](attribute_descriptor const& d0, attribute_descriptor const& d1) + { + return d0.get_name() < d1.get_name(); + }); + } private: std::string name_; std::string encoding_; From 046c9638e197cd1591e6e0a2ab23643c2446e5be Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 15 Aug 2016 12:21:02 +0100 Subject: [PATCH 10/21] GeoJSON - ensure descriptors order is consistent ( ref #3494) --- plugins/input/geojson/geojson_datasource.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp index eec7c6f15..422fcf0a5 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -233,7 +233,6 @@ void geojson_datasource::initialise_disk_index(std::string const& filename) mapnik::util::file file(filename_); if (!file) throw mapnik::datasource_exception("GeoJSON Plugin: could not open: '" + filename_ + "'"); - for (auto const& pos : positions) { std::fseek(file.get(), pos.first, SEEK_SET); @@ -243,7 +242,7 @@ void geojson_datasource::initialise_disk_index(std::string const& filename) auto const* start = record.data(); auto const* end = start + record.size(); mapnik::context_ptr ctx = std::make_shared(); - mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx,1)); + mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx, -1)); using namespace boost::spirit; standard::space_type space; if (!boost::spirit::qi::phrase_parse(start, end, @@ -254,6 +253,7 @@ void geojson_datasource::initialise_disk_index(std::string const& filename) } initialise_descriptor(feature); } + desc_.order_by_name(); } template @@ -339,6 +339,7 @@ void geojson_datasource::initialise_index(Iterator start, Iterator end) } } } + desc_.order_by_name(); } template From b9279feee2c1795efe018166989a4a3396cf5248 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 15 Aug 2016 12:49:43 +0100 Subject: [PATCH 11/21] fix `is_valid` logic (ref #3494) --- include/mapnik/featureset.hpp | 2 +- test/unit/datasource/geojson.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mapnik/featureset.hpp b/include/mapnik/featureset.hpp index e528d7de0..a6ad4e85d 100644 --- a/include/mapnik/featureset.hpp +++ b/include/mapnik/featureset.hpp @@ -59,7 +59,7 @@ inline featureset_ptr make_invalid_featureset() inline bool is_valid(featureset_ptr const& ptr) { - return (dynamic_cast(ptr.get()) == nullptr) ? false : true; + return (dynamic_cast(ptr.get()) == nullptr) ? true : false; } } diff --git a/test/unit/datasource/geojson.cpp b/test/unit/datasource/geojson.cpp index cf3214862..6d953c8bd 100644 --- a/test/unit/datasource/geojson.cpp +++ b/test/unit/datasource/geojson.cpp @@ -107,7 +107,7 @@ TEST_CASE("geojson") { auto ds = mapnik::datasource_cache::instance().create(params); CHECK(ds != nullptr); auto fs = all_features(ds); - REQUIRE(mapnik::is_valid(fs)); + REQUIRE(!mapnik::is_valid(fs)); while (auto f = fs->next()) { CHECK(false); // shouldn't get here From 1e8f471448dd413e7c8ffd8650612377672964fb Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 16 Aug 2016 10:53:57 +0100 Subject: [PATCH 12/21] minor formatting --- include/mapnik/feature_kv_iterator.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/mapnik/feature_kv_iterator.hpp b/include/mapnik/feature_kv_iterator.hpp index 77b292fd5..1def2e7c2 100644 --- a/include/mapnik/feature_kv_iterator.hpp +++ b/include/mapnik/feature_kv_iterator.hpp @@ -46,12 +46,11 @@ class feature_impl; class MAPNIK_DECL feature_kv_iterator : public boost::iterator_facade const, + std::tuple const, boost::forward_traversal_tag> { public: using value_type = std::tuple; - feature_kv_iterator (feature_impl const& f, bool begin = false); private: friend class boost::iterator_core_access; From f3252d00f43b4070243f262c490057fffaff53c3 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 16 Aug 2016 10:55:56 +0100 Subject: [PATCH 13/21] expose "num_features_to_query" datasource parameter (ref #3495) --- plugins/input/geojson/geojson_datasource.cpp | 12 ++++++------ plugins/input/geojson/geojson_datasource.hpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp index 422fcf0a5..90270873d 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -116,7 +116,8 @@ geojson_datasource::geojson_datasource(parameters const& params) inline_string_(), extent_(), features_(), - tree_(nullptr) + tree_(nullptr), + num_features_to_query_(*params.get("num_features_to_query",5)) { boost::optional inline_string = params.get("inline"); if (inline_string) @@ -233,6 +234,7 @@ void geojson_datasource::initialise_disk_index(std::string const& filename) mapnik::util::file file(filename_); if (!file) throw mapnik::datasource_exception("GeoJSON Plugin: could not open: '" + filename_ + "'"); + mapnik::context_ptr ctx = std::make_shared(); for (auto const& pos : positions) { std::fseek(file.get(), pos.first, SEEK_SET); @@ -241,7 +243,6 @@ void geojson_datasource::initialise_disk_index(std::string const& filename) std::fread(record.data(), pos.second, 1, file.get()); auto const* start = record.data(); auto const* end = start + record.size(); - mapnik::context_ptr ctx = std::make_shared(); mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx, -1)); using namespace boost::spirit; standard::space_type space; @@ -314,6 +315,7 @@ void geojson_datasource::initialise_index(Iterator start, Iterator end) tree_ = std::make_unique(boxes); // calculate total extent std::size_t feature_count = 0; + mapnik::context_ptr ctx = std::make_shared(); for (auto const& item : boxes) { auto const& box = std::get<0>(item); @@ -326,7 +328,6 @@ void geojson_datasource::initialise_index(Iterator start, Iterator end) // NOTE: this doesn't yield correct answer for geoJSON in general, just an indication Iterator itr2 = start + geometry_index.first; Iterator end2 = itr2 + geometry_index.second; - mapnik::context_ptr ctx = std::make_shared(); mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx,-1)); // temp feature if (!boost::spirit::qi::phrase_parse(itr2, end2, (geojson_datasource_static_feature_grammar)(boost::phoenix::ref(*feature)), space) @@ -356,7 +357,7 @@ void geojson_datasource::parse_geojson(Iterator start, Iterator end) try { bool result = boost::spirit::qi::phrase_parse(itr, end, (geojson_datasource_static_fc_grammar) - (boost::phoenix::ref(ctx),boost::phoenix::ref(start_id), boost::phoenix::ref(callback)), + (boost::phoenix::ref(ctx), boost::phoenix::ref(start_id), boost::phoenix::ref(callback)), space); if (!result || itr != end) { @@ -458,7 +459,7 @@ boost::optional geojson_datasource::get_geometry_ mapnik::util::file file(filename_); if (!file) throw mapnik::datasource_exception("GeoJSON Plugin: could not open: '" + filename_ + "'"); - + mapnik::context_ptr ctx = std::make_shared(); for (auto const& pos : positions) { std::fseek(file.get(), pos.first, SEEK_SET); @@ -467,7 +468,6 @@ boost::optional geojson_datasource::get_geometry_ std::fread(record.data(), pos.second, 1, file.get()); auto const* start = record.data(); auto const* end = start + record.size(); - mapnik::context_ptr ctx = std::make_shared(); mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx, -1)); // temp feature using namespace boost::spirit; standard::space_type space; diff --git a/plugins/input/geojson/geojson_datasource.hpp b/plugins/input/geojson/geojson_datasource.hpp index a50bd9567..5ba36a66b 100644 --- a/plugins/input/geojson/geojson_datasource.hpp +++ b/plugins/input/geojson/geojson_datasource.hpp @@ -104,7 +104,7 @@ private: std::unique_ptr tree_; bool cache_features_ = true; bool has_disk_index_ = false; - const std::size_t num_features_to_query_ = 5; + const std::size_t num_features_to_query_; }; From 3788b2781ece30a4f191d8d8393b28e64ae39626 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 16 Aug 2016 15:36:43 +0100 Subject: [PATCH 14/21] tiny format --- src/svg/svg_parser.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/svg/svg_parser.cpp b/src/svg/svg_parser.cpp index 2483bae56..827f557fc 100644 --- a/src/svg/svg_parser.cpp +++ b/src/svg/svg_parser.cpp @@ -111,7 +111,6 @@ mapnik::color parse_color(T & error_messages, const char* str) } catch (mapnik::config_error const& ex) { - error_messages.emplace_back(ex.what()); } return c; From 1a29b35717317705fc18db29d02d72e06514b71d Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 16 Aug 2016 15:45:12 +0100 Subject: [PATCH 15/21] GeoJSON unit tests- ensure descriptors are ordered by name (ref #3494) --- test/data | 2 +- test/unit/datasource/geojson.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/test/data b/test/data index 14eabf8f4..fb1529e22 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit 14eabf8f407294e71636cddfce68297a4f4e0303 +Subproject commit fb1529e225b36f8a3077ad23f7005951a07c8a7e diff --git a/test/unit/datasource/geojson.cpp b/test/unit/datasource/geojson.cpp index 6d953c8bd..bcc9fa2e6 100644 --- a/test/unit/datasource/geojson.cpp +++ b/test/unit/datasource/geojson.cpp @@ -115,6 +115,26 @@ TEST_CASE("geojson") { } } + SECTION("GeoJSON attribute descriptors are alphabetically ordered") + { + for (auto cache_features : {true, false}) + { + mapnik::parameters params; + params["type"] = "geojson"; + params["file"] = "./test/data/json/properties.json"; + params["cache_features"] = cache_features; + auto ds = mapnik::datasource_cache::instance().create(params); + CHECK(ds != nullptr); + std::vector expected_names = {"a", "b", "c", "d", "e"}; + auto fields = ds->get_descriptor().get_descriptors(); + std::size_t index = 0; + for (auto const& field : fields) + { + REQUIRE(field.get_name() == expected_names[index++]); + } + } + } + SECTION("GeoJSON invalid Point") { for (auto cache_features : {true, false}) From 7c455561382ff3d82ee1bbd2adc816899c9580a9 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 16 Aug 2016 16:00:24 +0100 Subject: [PATCH 16/21] update font path --- demo/c++/rundemo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/c++/rundemo.cpp b/demo/c++/rundemo.cpp index c20c288cf..ff7907d2e 100644 --- a/demo/c++/rundemo.cpp +++ b/demo/c++/rundemo.cpp @@ -55,7 +55,7 @@ int main ( int, char** ) try { std::cout << " running demo ... \n"; datasource_cache::instance().register_datasources("plugins/input/"); - freetype_engine::register_font("fonts/dejavu-fonts-ttf-2.35/ttf/DejaVuSans.ttf"); + freetype_engine::register_font("fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSans.ttf"); Map m(800,600); m.set_background(parse_color("white")); From 6613222b8448f4d6382c4bfb4d0c8d276871e409 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 22 Aug 2016 12:14:41 +0100 Subject: [PATCH 17/21] mapnik::variant - use `std::tuple` instead of `mpl::vector` and remove Boost.MPL dependency --- include/mapnik/config.hpp | 14 -------------- include/mapnik/util/variant.hpp | 5 ++--- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/include/mapnik/config.hpp b/include/mapnik/config.hpp index a05caf9d4..a9168e59f 100644 --- a/include/mapnik/config.hpp +++ b/include/mapnik/config.hpp @@ -52,18 +52,4 @@ #define PROJ_ENVELOPE_POINTS 20 -#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS - -#ifndef BOOST_MPL_LIMIT_VECTOR_SIZE - #define BOOST_MPL_LIMIT_VECTOR_SIZE 30 -#else - #warning "WARNING: BOOST_MPL_LIMIT_VECTOR_SIZE is already defined. Ensure config.hpp is included before any Boost headers" -#endif - -#ifndef BOOST_MPL_LIMIT_LIST_SIZE - #define BOOST_MPL_LIMIT_LIST_SIZE 30 -#else - #warning "WARNING: BOOST_MPL_LIMIT_LIST_SIZE is already defined. Ensure config.hpp is included before any Boost headers" -#endif - #endif // MAPNIK_CONFIG_HPP diff --git a/include/mapnik/util/variant.hpp b/include/mapnik/util/variant.hpp index 87cfb70ff..6c2d21b3e 100644 --- a/include/mapnik/util/variant.hpp +++ b/include/mapnik/util/variant.hpp @@ -28,7 +28,7 @@ #pragma GCC diagnostic push #include -#include // spirit support +#include // spirit support #pragma GCC diagnostic pop namespace mapnik { namespace util { @@ -36,14 +36,13 @@ namespace mapnik { namespace util { template using recursive_wrapper = typename mapbox::util::recursive_wrapper; - template class variant : public mapbox::util::variant { public: // tell spirit that this is an adapted variant struct adapted_variant_tag; - using types = boost::mpl::vector; + using types = std::tuple; // inherit ctor's using mapbox::util::variant::variant; }; From 0ae2f1311c4b5b4212beca38a8720a5bb26be34b Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 22 Aug 2016 10:50:08 -0700 Subject: [PATCH 18/21] update test data if UPDATE env set --- test/data | 2 +- test/unit/datasource/ogr.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/test/data b/test/data index fb1529e22..ca5716fce 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit fb1529e225b36f8a3077ad23f7005951a07c8a7e +Subproject commit ca5716fcef3ed33b319d3047f7d8190bf6ed6081 diff --git a/test/unit/datasource/ogr.cpp b/test/unit/datasource/ogr.cpp index 5401c1fe2..5b785f9b2 100644 --- a/test/unit/datasource/ogr.cpp +++ b/test/unit/datasource/ogr.cpp @@ -21,7 +21,7 @@ *****************************************************************************/ #include "catch.hpp" - +#include #include #include #include @@ -45,8 +45,10 @@ TEST_CASE("ogr") { mapnik::image_rgba8 im(256,256); mapnik::agg_renderer ren(m, im); ren.apply(); - //mapnik::save_to_file(im, "./test/data/images/point_json.png"); std::string filename("./test/data/images/point_json.png"); + if (std::getenv("UPDATE") != nullptr) { + mapnik::save_to_file(im, filename); + } std::unique_ptr reader(mapnik::get_image_reader(filename,"png")); mapnik::image_any data = reader->read(0, 0, reader->width(), reader->height()); mapnik::image_rgba8 expected = mapnik::util::get(data); From 4dae4d43c5d22c35749cbdc20498fcdc1af62e43 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 22 Aug 2016 11:15:42 -0700 Subject: [PATCH 19/21] restore test/data version - accidentally changed in 0ae2f1311c4 --- test/data | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/data b/test/data index ca5716fce..fb1529e22 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit ca5716fcef3ed33b319d3047f7d8190bf6ed6081 +Subproject commit fb1529e225b36f8a3077ad23f7005951a07c8a7e From b6cc48fd4002121d118f1e7976bf30b5344c87ce Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 22 Aug 2016 11:40:06 -0700 Subject: [PATCH 20/21] Revert "mapnik::variant - use `std::tuple` instead of `mpl::vector` and remove Boost.MPL dependency" This reverts commit 6613222b8448f4d6382c4bfb4d0c8d276871e409. --- include/mapnik/config.hpp | 14 ++++++++++++++ include/mapnik/util/variant.hpp | 5 +++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/mapnik/config.hpp b/include/mapnik/config.hpp index a9168e59f..a05caf9d4 100644 --- a/include/mapnik/config.hpp +++ b/include/mapnik/config.hpp @@ -52,4 +52,18 @@ #define PROJ_ENVELOPE_POINTS 20 +#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS + +#ifndef BOOST_MPL_LIMIT_VECTOR_SIZE + #define BOOST_MPL_LIMIT_VECTOR_SIZE 30 +#else + #warning "WARNING: BOOST_MPL_LIMIT_VECTOR_SIZE is already defined. Ensure config.hpp is included before any Boost headers" +#endif + +#ifndef BOOST_MPL_LIMIT_LIST_SIZE + #define BOOST_MPL_LIMIT_LIST_SIZE 30 +#else + #warning "WARNING: BOOST_MPL_LIMIT_LIST_SIZE is already defined. Ensure config.hpp is included before any Boost headers" +#endif + #endif // MAPNIK_CONFIG_HPP diff --git a/include/mapnik/util/variant.hpp b/include/mapnik/util/variant.hpp index 6c2d21b3e..87cfb70ff 100644 --- a/include/mapnik/util/variant.hpp +++ b/include/mapnik/util/variant.hpp @@ -28,7 +28,7 @@ #pragma GCC diagnostic push #include -#include // spirit support +#include // spirit support #pragma GCC diagnostic pop namespace mapnik { namespace util { @@ -36,13 +36,14 @@ namespace mapnik { namespace util { template using recursive_wrapper = typename mapbox::util::recursive_wrapper; + template class variant : public mapbox::util::variant { public: // tell spirit that this is an adapted variant struct adapted_variant_tag; - using types = std::tuple; + using types = boost::mpl::vector; // inherit ctor's using mapbox::util::variant::variant; }; From fe007915df7d7d79d3ca17034ad1cae888ecd10f Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 23 Aug 2016 15:27:06 +0100 Subject: [PATCH 21/21] Revert "Revert "mapnik::variant - use `std::tuple` instead of `mpl::vector` and remove Boost.MPL dependency"" and remove `` This reverts commit b6cc48fd4002121d118f1e7976bf30b5344c87ce. --- include/mapnik/config.hpp | 14 -------------- include/mapnik/util/variant.hpp | 8 +------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/include/mapnik/config.hpp b/include/mapnik/config.hpp index a05caf9d4..a9168e59f 100644 --- a/include/mapnik/config.hpp +++ b/include/mapnik/config.hpp @@ -52,18 +52,4 @@ #define PROJ_ENVELOPE_POINTS 20 -#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS - -#ifndef BOOST_MPL_LIMIT_VECTOR_SIZE - #define BOOST_MPL_LIMIT_VECTOR_SIZE 30 -#else - #warning "WARNING: BOOST_MPL_LIMIT_VECTOR_SIZE is already defined. Ensure config.hpp is included before any Boost headers" -#endif - -#ifndef BOOST_MPL_LIMIT_LIST_SIZE - #define BOOST_MPL_LIMIT_LIST_SIZE 30 -#else - #warning "WARNING: BOOST_MPL_LIMIT_LIST_SIZE is already defined. Ensure config.hpp is included before any Boost headers" -#endif - #endif // MAPNIK_CONFIG_HPP diff --git a/include/mapnik/util/variant.hpp b/include/mapnik/util/variant.hpp index 87cfb70ff..27993ce3f 100644 --- a/include/mapnik/util/variant.hpp +++ b/include/mapnik/util/variant.hpp @@ -26,24 +26,18 @@ #include #include -#pragma GCC diagnostic push -#include -#include // spirit support -#pragma GCC diagnostic pop - namespace mapnik { namespace util { template using recursive_wrapper = typename mapbox::util::recursive_wrapper; - template class variant : public mapbox::util::variant { public: // tell spirit that this is an adapted variant struct adapted_variant_tag; - using types = boost::mpl::vector; + using types = std::tuple; // inherit ctor's using mapbox::util::variant::variant; };