From ff450b499854ede2c859ff76ea11384a5ce2bcd1 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Wed, 1 Feb 2012 15:52:17 -0500 Subject: [PATCH] Actual data-based sqlite statistics test, fix kinks in the implementation. --- plugins/input/sqlite/sqlite_datasource.cpp | 3 ++- tests/python_tests/sqlite_test.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/input/sqlite/sqlite_datasource.cpp b/plugins/input/sqlite/sqlite_datasource.cpp index f66938580..dc6cb3760 100644 --- a/plugins/input/sqlite/sqlite_datasource.cpp +++ b/plugins/input/sqlite/sqlite_datasource.cpp @@ -522,7 +522,7 @@ std::map sqlite_datasource::get_statistics() c { itr = desc_.get_descriptors().begin(); int col = 0; - for ( ; itr != end; ++itr, ++col) { + for ( ; itr != end; ++itr) { std::string fld_name = itr->get_name(); if (fld_name != key_field_ && itr->get_type() == mapnik::Double || @@ -533,6 +533,7 @@ std::map sqlite_datasource::get_statistics() c p["max"] = rs->column_double(col); col++; p["mean"] = rs->column_double(col); + col++; stats_[itr->get_name()] = p; } } diff --git a/tests/python_tests/sqlite_test.py b/tests/python_tests/sqlite_test.py index 32e0b8e54..2b93a6c37 100644 --- a/tests/python_tests/sqlite_test.py +++ b/tests/python_tests/sqlite_test.py @@ -41,6 +41,9 @@ if 'sqlite' in mapnik.DatasourceCache.instance().plugin_names(): def test_attachdb_with_multiple_files(): ds = mapnik.SQLite(file='../data/sqlite/world.sqlite', table='world_merc') stats = ds.statistics() + eq_(stats['pop2005']['min'], 0) + eq_(stats['pop2005']['max'], 1312978855) + eq_(stats['area']['max'], 1638094) print stats def test_attachdb_with_absolute_file():