From 161469ed638f2feabe8534983b20f51d3e5370aa Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Wed, 5 Aug 2015 13:47:17 -0500 Subject: [PATCH] Fixed an issue with fields over size of int32 in OGR plugin and added tests to cover this situation. --- plugins/input/ogr/ogr_featureset.cpp | 10 ++-- plugins/input/ogr/ogr_index_featureset.cpp | 10 ++-- test/data | 2 +- test/unit/datasource/ogr.cpp | 58 ++++++++++++++++++++++ 4 files changed, 73 insertions(+), 7 deletions(-) create mode 100644 test/unit/datasource/ogr.cpp diff --git a/plugins/input/ogr/ogr_featureset.cpp b/plugins/input/ogr/ogr_featureset.cpp index 3d46fcf87..267ebc017 100644 --- a/plugins/input/ogr/ogr_featureset.cpp +++ b/plugins/input/ogr/ogr_featureset.cpp @@ -125,13 +125,17 @@ feature_ptr ogr_featureset::next() switch (type_oid) { case OFTInteger: -#if GDAL_VERSION_MAJOR >= 2 - case OFTInteger64: -#endif { feature->put( fld_name, poFeature->GetFieldAsInteger(i)); break; } +#if GDAL_VERSION_MAJOR >= 2 + case OFTInteger64: + { + feature->put( fld_name, poFeature->GetFieldAsInteger64(i)); + break; + } +#endif case OFTReal: { diff --git a/plugins/input/ogr/ogr_index_featureset.cpp b/plugins/input/ogr/ogr_index_featureset.cpp index c59ef29fa..9338f954d 100644 --- a/plugins/input/ogr/ogr_index_featureset.cpp +++ b/plugins/input/ogr/ogr_index_featureset.cpp @@ -148,13 +148,17 @@ feature_ptr ogr_index_featureset::next() switch (type_oid) { case OFTInteger: -#if GDAL_VERSION_MAJOR >= 2 - case OFTInteger64: -#endif { feature->put(fld_name,poFeature->GetFieldAsInteger (i)); break; } +#if GDAL_VERSION_MAJOR >= 2 + case OFTInteger64: + { + feature->put( fld_name, poFeature->GetFieldAsInteger64(i)); + break; + } +#endif case OFTReal: { diff --git a/test/data b/test/data index d0a23b2a5..3b1f481ac 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit d0a23b2a512d2ea83f08a9c1dc50e9b9b4a08dd5 +Subproject commit 3b1f481ac2ceeb780255cd4c76a42ae06197b9bc diff --git a/test/unit/datasource/ogr.cpp b/test/unit/datasource/ogr.cpp new file mode 100644 index 000000000..3dddb8599 --- /dev/null +++ b/test/unit/datasource/ogr.cpp @@ -0,0 +1,58 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2015 Artem Pavlenko + * + * 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. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#include "catch.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include + +TEST_CASE("ogr") { + + std::string geojson_plugin("./plugins/input/ogr.input"); + if (mapnik::util::exists(geojson_plugin)) + { + SECTION("ogr point feature") + { + mapnik::Map m(256,256); + mapnik::load_map(m, "./test/data/good_maps/point_json.xml"); + std::string fontdir("fonts/"); + REQUIRE( m.register_fonts(fontdir , true ) ); + m.zoom_all(); + 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"); + 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); + REQUIRE(mapnik::compare(expected, im) == 0); + } + + } +}