diff --git a/bindings/python/mapnik_feature.cpp b/bindings/python/mapnik_feature.cpp index 99beff758..31e0434b4 100644 --- a/bindings/python/mapnik_feature.cpp +++ b/bindings/python/mapnik_feature.cpp @@ -212,7 +212,7 @@ void export_feature() ; class_, - boost::noncopyable>("Feature",init("Default ctor.")) + boost::noncopyable>("Feature",init("Default ctor.")) .def("id",&Feature::id) .def("__str__",&Feature::to_string) .def("add_geometries_from_wkb", &feature_add_geometries_from_wkb) diff --git a/include/mapnik/feature.hpp b/include/mapnik/feature.hpp index d6a88a2aa..199240ac0 100644 --- a/include/mapnik/feature.hpp +++ b/include/mapnik/feature.hpp @@ -106,7 +106,7 @@ public: typedef std::vector cont_type; typedef feature_kv_iterator iterator; - feature_impl(context_ptr const& ctx, int id) + feature_impl(context_ptr const& ctx, mapnik::value_integer id) : id_(id), ctx_(ctx), data_(ctx_->mapping_.size()), @@ -114,9 +114,9 @@ public: raster_() {} - inline int id() const { return id_;} + inline mapnik::value_integer id() const { return id_;} - inline void set_id(int id) { id_ = id;} + inline void set_id(mapnik::value_integer id) { id_ = id;} template void put(context_type::key_type const& key, T const& val) @@ -304,7 +304,7 @@ public: } private: - int id_; + mapnik::value_integer id_; context_ptr ctx_; cont_type data_; boost::ptr_vector geom_cont_; diff --git a/include/mapnik/feature_factory.hpp b/include/mapnik/feature_factory.hpp index 955ca2431..b3e91a64a 100644 --- a/include/mapnik/feature_factory.hpp +++ b/include/mapnik/feature_factory.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include // boost #include @@ -34,7 +35,7 @@ namespace mapnik { struct feature_factory { - static boost::shared_ptr create (context_ptr const& ctx, int fid) + static boost::shared_ptr create (context_ptr const& ctx, mapnik::value_integer fid) { //return boost::allocate_shared(boost::pool_allocator(),fid); //return boost::allocate_shared(boost::fast_pool_allocator(),fid); diff --git a/include/mapnik/grid/grid.hpp b/include/mapnik/grid/grid.hpp index b8dcf3e42..af137e2b9 100644 --- a/include/mapnik/grid/grid.hpp +++ b/include/mapnik/grid/grid.hpp @@ -257,7 +257,7 @@ public: }; -typedef MAPNIK_DECL hit_grid grid; +typedef MAPNIK_DECL hit_grid grid; } #endif //MAPNIK_GRID_HPP diff --git a/include/mapnik/grid/grid_pixel.hpp b/include/mapnik/grid/grid_pixel.hpp index 8aa713076..e8d5483bf 100644 --- a/include/mapnik/grid/grid_pixel.hpp +++ b/include/mapnik/grid/grid_pixel.hpp @@ -171,6 +171,11 @@ struct gray32 typedef agg::int32 value_type; typedef agg::int64u calc_type; typedef agg::int64 long_type; + // NOTE: don't touch this enum since enums cannot be + // 64 bit and we need to ensure that alpha = base_mask + // in grid_pixfmt.hpp#blend_hiline#l256 + // otherwise code will get invoked that breaks + // with 32 bit or 64 bit ints (blender_gray::blend_pix) enum base_scale_e { base_shift = 16, @@ -186,8 +191,8 @@ struct gray32 gray32() {} //-------------------------------------------------------------------- - gray32(unsigned v_, unsigned a_=base_mask) : - v(agg::int32(v_)), a(agg::int32(a_)) {} + gray32(value_type v_, unsigned a_=base_mask) : + v(v_), a(value_type(a_)) {} //-------------------------------------------------------------------- gray32(const self_type& c, unsigned a_) : @@ -308,9 +313,14 @@ struct gray64 typedef agg::int64 value_type; typedef agg::int64u calc_type; typedef agg::int64 long_type; + // NOTE: don't touch this enum since enums cannot be + // 64 bit and we need to ensure that alpha = base_mask + // in grid_pixfmt.hpp#blend_hiline#l256 + // otherwise code will get invoked that breaks + // with 32 bit or 64 bit ints (blender_gray::blend_pix) enum base_scale_e { - base_shift = 32, + base_shift = 16, base_scale = 1 << base_shift, base_mask = base_scale - 1 }; @@ -323,8 +333,8 @@ struct gray64 gray64() {} //-------------------------------------------------------------------- - gray64(value_type v_, value_type a_=base_mask) : - v(v_), a(a_) {} + gray64(value_type v_, unsigned a_=base_mask) : + v(v_), a(value_type(a_)) {} //-------------------------------------------------------------------- gray64(const self_type& c, unsigned a_) : diff --git a/include/mapnik/grid/grid_pixfmt.hpp b/include/mapnik/grid/grid_pixfmt.hpp index 315d89109..30c43fcd2 100644 --- a/include/mapnik/grid/grid_pixfmt.hpp +++ b/include/mapnik/grid/grid_pixfmt.hpp @@ -258,7 +258,16 @@ public: const color_type& c, agg::int8u cover) { - if (c.a) + value_type* p = (value_type*) + m_rbuf->row_ptr(x, y, len) + x * Step + Offset; + do + { + *p = c.v; + p += Step; + } + while(--len); + // We ignore alpha since grid_renderer is a binary renderer for now + /*if (c.a) { value_type* p = (value_type*) m_rbuf->row_ptr(x, y, len) + x * Step + Offset; @@ -282,7 +291,7 @@ public: } while(--len); } - } + }*/ } diff --git a/include/mapnik/grid/grid_renderer_base.hpp b/include/mapnik/grid/grid_renderer_base.hpp index b21601827..be7dd41cf 100644 --- a/include/mapnik/grid/grid_renderer_base.hpp +++ b/include/mapnik/grid/grid_renderer_base.hpp @@ -29,7 +29,7 @@ namespace mapnik { -typedef agg::renderer_base grid_renderer_base_type; +typedef agg::renderer_base grid_renderer_base_type; } diff --git a/include/mapnik/grid/grid_view.hpp b/include/mapnik/grid/grid_view.hpp index a33e1656a..1f190c8a4 100644 --- a/include/mapnik/grid/grid_view.hpp +++ b/include/mapnik/grid/grid_view.hpp @@ -201,7 +201,7 @@ private: feature_type const& features_; }; -typedef hit_grid_view > grid_view; +typedef hit_grid_view > grid_view; } diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index b130459fa..88a2169e5 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -398,7 +398,7 @@ void csv_datasource::parse_csv(T & stream, throw mapnik::datasource_exception("CSV Plugin: could not detect column headers with the name of wkt, geojson, x/y, or latitude/longitude - this is required for reading geometry data"); } - int feature_count(0); + mapnik::value_integer feature_count(0); bool extent_initialized = false; std::size_t num_headers = headers_.size(); @@ -652,7 +652,7 @@ void csv_datasource::parse_csv(T & stream, } } - // now, add attributes, skipping any WKT or JSON fiels + // now, add attributes, skipping any WKT or JSON fields if ((has_wkt_field) && (i == wkt_idx)) continue; if ((has_json_field) && (i == json_idx)) continue; /* First we detect likely strings, then try parsing likely numbers, @@ -664,27 +664,34 @@ void csv_datasource::parse_csv(T & stream, to assume are numbers) */ + bool matched = false; bool has_dot = value.find(".") != std::string::npos; if (value.empty() || (value_length > 20) || (value_length > 1 && !has_dot && value[0] == '0')) { + matched = true; feature->put(fld_name,tr.transcode(value.c_str())); if (feature_count == 1) { desc_.add_descriptor(mapnik::attribute_descriptor(fld_name,mapnik::String)); } } - else if ((value[0] >= '0' && value[0] <= '9') || value[0] == '-') + else if ((value[0] >= '0' && value[0] <= '9') || + value[0] == '-' || + value[0] == '+' || + value[0] == '.') { - double float_val = 0.0; - std::string::const_iterator str_beg = value.begin(); - std::string::const_iterator str_end = value.end(); - bool r = qi::phrase_parse(str_beg,str_end,qi::double_,ascii::space,float_val); - if (r && (str_beg == str_end)) + bool has_e = value.find("e") != std::string::npos; + if (has_dot || has_e) { - if (has_dot) + double float_val = 0.0; + std::string::const_iterator str_beg = value.begin(); + std::string::const_iterator str_end = value.end(); + if (qi::phrase_parse(str_beg,str_end,qi::double_,ascii::space,float_val) + && (str_beg == str_end)) { + matched = true; feature->put(fld_name,float_val); if (feature_count == 1) { @@ -693,9 +700,17 @@ void csv_datasource::parse_csv(T & stream, fld_name,mapnik::Double)); } } - else + } + else + { + mapnik::value_integer int_val = 0; + std::string::const_iterator str_beg = value.begin(); + std::string::const_iterator str_end = value.end(); + if (qi::phrase_parse(str_beg,str_end,qi::long_long,ascii::space,int_val) + && (str_beg == str_end)) { - feature->put(fld_name,static_cast(float_val)); + matched = true; + feature->put(fld_name,int_val); if (feature_count == 1) { desc_.add_descriptor( @@ -704,19 +719,8 @@ void csv_datasource::parse_csv(T & stream, } } } - else - { - // fallback to normal string - feature->put(fld_name,tr.transcode(value.c_str())); - if (feature_count == 1) - { - desc_.add_descriptor( - mapnik::attribute_descriptor( - fld_name,mapnik::String)); - } - } } - else + if (!matched) { // fallback to normal string feature->put(fld_name,tr.transcode(value.c_str())); diff --git a/plugins/input/geos/geos_featureset.cpp b/plugins/input/geos/geos_featureset.cpp index 8c8fba58a..78f85234c 100644 --- a/plugins/input/geos/geos_featureset.cpp +++ b/plugins/input/geos/geos_featureset.cpp @@ -44,14 +44,14 @@ using mapnik::feature_factory; geos_featureset::geos_featureset(GEOSGeometry* geometry, GEOSGeometry* extent, - int identifier, + mapnik::value_integer feature_id, std::string const& field, std::string const& field_name, std::string const& encoding) : geometry_(geometry), tr_(new transcoder(encoding)), extent_(extent), - identifier_(identifier), + feature_id_(feature_id), field_(field), field_name_(field_name), already_rendered_(false), @@ -108,7 +108,7 @@ feature_ptr geos_featureset::next() geos_wkb_ptr wkb(geometry_); if (wkb.is_valid()) { - feature_ptr feature(feature_factory::create(ctx_,identifier_)); + feature_ptr feature(feature_factory::create(ctx_,feature_id_)); if (geometry_utils::from_wkb(feature->paths(), wkb.data(), diff --git a/plugins/input/geos/geos_featureset.hpp b/plugins/input/geos/geos_featureset.hpp index 29674dd8e..3a9ccd97d 100644 --- a/plugins/input/geos/geos_featureset.hpp +++ b/plugins/input/geos/geos_featureset.hpp @@ -41,7 +41,7 @@ class geos_featureset : public mapnik::Featureset public: geos_featureset(GEOSGeometry* geometry, GEOSGeometry* extent, - int identifier, + mapnik::value_integer feature_id, std::string const& field, std::string const& field_name, std::string const& encoding); @@ -52,7 +52,7 @@ private: GEOSGeometry* geometry_; boost::scoped_ptr tr_; geos_feature_ptr extent_; - int identifier_; + mapnik::value_integer feature_id_; std::string field_; std::string field_name_; bool already_rendered_; diff --git a/plugins/input/kismet/kismet_featureset.hpp b/plugins/input/kismet/kismet_featureset.hpp index 2982ac927..2be6c2e40 100644 --- a/plugins/input/kismet/kismet_featureset.hpp +++ b/plugins/input/kismet/kismet_featureset.hpp @@ -51,7 +51,7 @@ public: private: std::list const& knd_list_; boost::scoped_ptr tr_; - int feature_id_; + mapnik::value_integer feature_id_; std::list::const_iterator knd_list_it; mapnik::projection source_; mapnik::context_ptr ctx_; diff --git a/plugins/input/occi/occi_featureset.hpp b/plugins/input/occi/occi_featureset.hpp index 90804dcc4..42710b80f 100644 --- a/plugins/input/occi/occi_featureset.hpp +++ b/plugins/input/occi/occi_featureset.hpp @@ -70,7 +70,7 @@ private: occi_connection_ptr conn_; oracle::occi::ResultSet* rs_; boost::scoped_ptr tr_; - mutable int feature_id_; + mapnik::value_integer feature_id_; mapnik::context_ptr ctx_; bool use_wkb_; std::vector buffer_; diff --git a/plugins/input/ogr/ogr_featureset.cpp b/plugins/input/ogr/ogr_featureset.cpp index f8b8a7ef7..202fe78e6 100644 --- a/plugins/input/ogr/ogr_featureset.cpp +++ b/plugins/input/ogr/ogr_featureset.cpp @@ -88,7 +88,7 @@ feature_ptr ogr_featureset::next() { // ogr feature ids start at 0, so add one to stay // consistent with other mapnik datasources that start at 1 - const int feature_id = (poFeature->GetFID() + 1); + mapnik::value_integer feature_id = (poFeature->GetFID() + 1); feature_ptr feature(feature_factory::create(ctx_,feature_id)); OGRGeometry* geom = poFeature->GetGeometryRef(); diff --git a/plugins/input/ogr/ogr_index_featureset.cpp b/plugins/input/ogr/ogr_index_featureset.cpp index cae937afe..e74aec06b 100644 --- a/plugins/input/ogr/ogr_index_featureset.cpp +++ b/plugins/input/ogr/ogr_index_featureset.cpp @@ -99,7 +99,7 @@ feature_ptr ogr_index_featureset::next() // ogr feature ids start at 0, so add one to stay // consistent with other mapnik datasources that start at 1 - int feature_id = (poFeature->GetFID() + 1); + mapnik::value_integer feature_id = (poFeature->GetFID() + 1); feature_ptr feature(feature_factory::create(ctx_,feature_id)); OGRGeometry* geom=poFeature->GetGeometryRef(); diff --git a/plugins/input/osm/osm.h b/plugins/input/osm/osm.h index d64cce469..532320dcb 100644 --- a/plugins/input/osm/osm.h +++ b/plugins/input/osm/osm.h @@ -23,6 +23,7 @@ #ifndef OSM_H #define OSM_H +#include #include #include #include @@ -65,7 +66,7 @@ public: struct osm_item { - long id; + mapnik::value_integer id; std::map keyvals; virtual std::string to_string(); virtual ~osm_item() {} diff --git a/plugins/input/osm/osmparser.cpp b/plugins/input/osm/osmparser.cpp index ec9ed3047..8651d6432 100644 --- a/plugins/input/osm/osmparser.cpp +++ b/plugins/input/osm/osmparser.cpp @@ -6,7 +6,7 @@ #include osm_item* osmparser::cur_item=NULL; -long osmparser::curID=0; +mapnik::value_integer osmparser::curID=0; bool osmparser::in_node=false, osmparser::in_way=false; osm_dataset* osmparser::components=NULL; std::string osmparser::error=""; diff --git a/plugins/input/osm/osmparser.h b/plugins/input/osm/osmparser.h index 21dffd7e9..acbe2ceb2 100644 --- a/plugins/input/osm/osmparser.h +++ b/plugins/input/osm/osmparser.h @@ -23,6 +23,7 @@ #ifndef OSMPARSER_H #define OSMPARSER_H +#include #include #include #include @@ -41,7 +42,7 @@ public: private: static osm_item *cur_item; - static long curID; + static mapnik::value_integer curID; static bool in_node, in_way; static osm_dataset* components; static std::string error; diff --git a/plugins/input/postgis/postgis_featureset.hpp b/plugins/input/postgis/postgis_featureset.hpp index 013a7de0f..754b42388 100644 --- a/plugins/input/postgis/postgis_featureset.hpp +++ b/plugins/input/postgis/postgis_featureset.hpp @@ -56,7 +56,7 @@ private: context_ptr ctx_; boost::scoped_ptr tr_; unsigned totalGeomSize_; - int feature_id_; + mapnik::value_integer feature_id_; bool key_field_; }; diff --git a/plugins/input/raster/raster_featureset.hpp b/plugins/input/raster/raster_featureset.hpp index fe72e06c0..d4db2e3c6 100644 --- a/plugins/input/raster/raster_featureset.hpp +++ b/plugins/input/raster/raster_featureset.hpp @@ -315,7 +315,7 @@ public: private: LookupPolicy policy_; - int feature_id_; + mapnik::value_integer feature_id_; mapnik::context_ptr ctx_; mapnik::box2d extent_; mapnik::box2d bbox_; diff --git a/plugins/input/sqlite/sqlite_featureset.cpp b/plugins/input/sqlite/sqlite_featureset.cpp index 69142adfd..e80e22c98 100644 --- a/plugins/input/sqlite/sqlite_featureset.cpp +++ b/plugins/input/sqlite/sqlite_featureset.cpp @@ -73,7 +73,7 @@ feature_ptr sqlite_featureset::next() return feature_ptr(); } - feature_ptr feature = feature_factory::create(ctx_,rs_->column_integer(1)); + feature_ptr feature = feature_factory::create(ctx_,rs_->column_integer64(1)); if (!geometry_utils::from_wkb(feature->paths(), data, size, format_)) continue; @@ -104,7 +104,7 @@ feature_ptr sqlite_featureset::next() { case SQLITE_INTEGER: { - feature->put(fld_name_str, rs_->column_integer(i)); + feature->put(fld_name_str, rs_->column_integer64(i)); break; } diff --git a/plugins/input/sqlite/sqlite_featureset.hpp b/plugins/input/sqlite/sqlite_featureset.hpp index d696814b0..c0dbb7cd0 100644 --- a/plugins/input/sqlite/sqlite_featureset.hpp +++ b/plugins/input/sqlite/sqlite_featureset.hpp @@ -53,7 +53,7 @@ private: boost::shared_ptr rs_; mapnik::context_ptr ctx_; boost::scoped_ptr tr_; - mapnik::box2d const& bbox_; + mapnik::box2d bbox_; mapnik::wkbFormat format_; bool spatial_index_; bool using_subquery_; diff --git a/plugins/input/sqlite/sqlite_utils.hpp b/plugins/input/sqlite/sqlite_utils.hpp index fb81ce62b..c691be327 100644 --- a/plugins/input/sqlite/sqlite_utils.hpp +++ b/plugins/input/sqlite/sqlite_utils.hpp @@ -640,7 +640,7 @@ public: found_table = true; const char* fld_name = rs->column_text(1); std::string fld_type(rs->column_text(2)); - int fld_pk = rs->column_integer(5); + sqlite_int64 fld_pk = rs->column_integer64(5); boost::algorithm::to_lower(fld_type); // TODO - how to handle primary keys on multiple columns ? diff --git a/plugins/input/templates/helloworld/hello_featureset.hpp b/plugins/input/templates/helloworld/hello_featureset.hpp index ffdce76f6..976d3ccde 100644 --- a/plugins/input/templates/helloworld/hello_featureset.hpp +++ b/plugins/input/templates/helloworld/hello_featureset.hpp @@ -23,7 +23,7 @@ public: private: // members are up to you, but these are recommended mapnik::box2d const& box_; - mutable int feature_id_; + mapnik::value_integer feature_id_; boost::scoped_ptr tr_; mapnik::context_ptr ctx_; }; diff --git a/src/grid/grid.cpp b/src/grid/grid.cpp index f3815df37..e58901e52 100644 --- a/src/grid/grid.cpp +++ b/src/grid/grid.cpp @@ -138,6 +138,6 @@ void hit_grid::add_feature(mapnik::feature_impl & feature) } -template class hit_grid; +template class hit_grid; } diff --git a/tests/data/csv/64bit_int.csv b/tests/data/csv/64bit_int.csv new file mode 100644 index 000000000..a36badb88 --- /dev/null +++ b/tests/data/csv/64bit_int.csv @@ -0,0 +1,3 @@ +x,y,bigint +0,0,2147483648 +0,0,9223372036854775807 diff --git a/tests/data/csv/number_types.csv b/tests/data/csv/number_types.csv new file mode 100644 index 000000000..d767bbbf6 --- /dev/null +++ b/tests/data/csv/number_types.csv @@ -0,0 +1,9 @@ +x,y,floats +0,0,.0 +0,0,+.0 +0,0,1e-06 +0,0,-1e-06 +0,0,0.000001 +0,0,1.234e+16 +0,0,1.234e16 +0,0,"1.234e16" \ No newline at end of file diff --git a/tests/data/sqlite/64bit_int.sqlite b/tests/data/sqlite/64bit_int.sqlite new file mode 100644 index 000000000..2918ddee4 Binary files /dev/null and b/tests/data/sqlite/64bit_int.sqlite differ diff --git a/tests/python_tests/csv_test.py b/tests/python_tests/csv_test.py index ea57f245d..fb8335150 100644 --- a/tests/python_tests/csv_test.py +++ b/tests/python_tests/csv_test.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- import glob +import sys from nose.tools import * from utilities import execution_path @@ -529,6 +530,46 @@ if 'csv' in mapnik.DatasourceCache.plugin_names(): eq_(desc['geometry_type'],mapnik.DataGeometryType.Point) eq_(len(ds.all_features()),1) + def test_that_64bit_int_fields_work(**kwargs): + ds = get_csv_ds('64bit_int.csv') + eq_(len(ds.fields()),3) + eq_(ds.fields(),['x','y','bigint']) + eq_(ds.field_types(),['int','int','int']) + fs = ds.featureset() + feat = fs.next() + eq_(feat['bigint'],2147483648) + feat = fs.next() + eq_(feat['bigint'],sys.maxint) + eq_(feat['bigint'],9223372036854775807) + eq_(feat['bigint'],0x7FFFFFFFFFFFFFFF) + desc = ds.describe() + eq_(desc['geometry_type'],mapnik.DataGeometryType.Point) + eq_(len(ds.all_features()),2) + + def test_various_number_types(**kwargs): + ds = get_csv_ds('number_types.csv') + eq_(len(ds.fields()),3) + eq_(ds.fields(),['x','y','floats']) + eq_(ds.field_types(),['int','int','float']) + fs = ds.featureset() + feat = fs.next() + eq_(feat['floats'],.0) + feat = fs.next() + eq_(feat['floats'],+.0) + feat = fs.next() + eq_(feat['floats'],1e-06) + feat = fs.next() + eq_(feat['floats'],-1e-06) + feat = fs.next() + eq_(feat['floats'],0.000001) + feat = fs.next() + eq_(feat['floats'],1.234e+16) + feat = fs.next() + eq_(feat['floats'],1.234e+16) + desc = ds.describe() + eq_(desc['geometry_type'],mapnik.DataGeometryType.Point) + eq_(len(ds.all_features()),8) + if __name__ == "__main__": setup() [eval(run)(visual=True) for run in dir() if 'test_' in run] diff --git a/tests/python_tests/filter_test.py b/tests/python_tests/filter_test.py index 9cfaf2ecd..6a6200f39 100644 --- a/tests/python_tests/filter_test.py +++ b/tests/python_tests/filter_test.py @@ -239,7 +239,9 @@ null_equality = [ [.1,False,float], [False,False,int], # TODO - should become bool [True,False,int], # TODO - should become bool - [None,True,None] + [None,True,None], + [2147483648,False,int], + [922337203685477580,False,int] ] def test_expressions_with_null_equality(): @@ -285,7 +287,9 @@ truthyness = [ [.1,True,float], [False,False,int], # TODO - should become bool [True,True,int], # TODO - should become bool - [None,False,None] + [None,False,None], + [2147483648,True,int], + [922337203685477580,True,int] ] def test_expressions_for_thruthyness(): diff --git a/tests/python_tests/postgis_test.py b/tests/python_tests/postgis_test.py index c0bd56b54..619326588 100644 --- a/tests/python_tests/postgis_test.py +++ b/tests/python_tests/postgis_test.py @@ -132,6 +132,12 @@ CREATE TABLE test7(gid serial PRIMARY KEY, geom geometry); INSERT INTO test7(gid, geom) values (1, GeomFromEWKT('SRID=4326;GEOMETRYCOLLECTION(MULTILINESTRING((10 10,20 20,10 40),(40 40,30 30,40 20,30 10)),LINESTRING EMPTY)')); ''' +insert_table_8 = ''' +CREATE TABLE test8(gid serial PRIMARY KEY,int_field bigint, geom geometry); +INSERT INTO test8(gid, int_field, geom) values (1, 2147483648, ST_MakePoint(1,1)); +INSERT INTO test8(gid, int_field, geom) values (2, 922337203685477580, ST_MakePoint(1,1)); +''' + def postgis_setup(): call('dropdb %s' % MAPNIK_TEST_DBNAME,silent=True) @@ -146,6 +152,7 @@ def postgis_setup(): call("""psql -q %s -c '%s'""" % (MAPNIK_TEST_DBNAME,insert_table_5b),silent=False) call('''psql -q %s -c "%s"''' % (MAPNIK_TEST_DBNAME,insert_table_6),silent=False) call('''psql -q %s -c "%s"''' % (MAPNIK_TEST_DBNAME,insert_table_7),silent=False) + call('''psql -q %s -c "%s"''' % (MAPNIK_TEST_DBNAME,insert_table_8),silent=False) def postgis_takedown(): pass @@ -472,7 +479,21 @@ if 'postgis' in mapnik.DatasourceCache.plugin_names() \ t.start() t.join() - + def test_that_64bit_int_fields_work(): + ds = mapnik.PostGIS(dbname=MAPNIK_TEST_DBNAME, + table='test8') + eq_(len(ds.fields()),2) + eq_(ds.fields(),['gid','int_field']) + eq_(ds.field_types(),['int','int']) + fs = ds.featureset() + feat = fs.next() + eq_(feat.id(),1) + eq_(feat['gid'],1) + eq_(feat['int_field'],2147483648) + feat = fs.next() + eq_(feat.id(),2) + eq_(feat['gid'],2) + eq_(feat['int_field'],922337203685477580) atexit.register(postgis_takedown) diff --git a/tests/python_tests/render_grid_test.py b/tests/python_tests/render_grid_test.py index 1b5147081..aaa28a923 100644 --- a/tests/python_tests/render_grid_test.py +++ b/tests/python_tests/render_grid_test.py @@ -268,16 +268,24 @@ def test_32bit_int_id(): eq_(grid.get_pixel(128,128),int32) utf1 = grid.encode('utf',resolution=4) eq_(utf1['keys'],[str(int32)]) - - # this will fail because it is used internally to mark alpha - #max_neg = -(int32+1) - # so we use max neg-1 max_neg = -(int32) grid = gen_grid_for_id(max_neg) eq_(grid.get_pixel(128,128),max_neg) utf1 = grid.encode('utf',resolution=4) eq_(utf1['keys'],[str(max_neg)]) +def test_64bit_int_id(): + int64 = 0x7FFFFFFFFFFFFFFF + grid = gen_grid_for_id(int64) + eq_(grid.get_pixel(128,128),int64) + utf1 = grid.encode('utf',resolution=4) + eq_(utf1['keys'],[str(int64)]) + max_neg = -(int64) + grid = gen_grid_for_id(max_neg) + eq_(grid.get_pixel(128,128),max_neg) + utf1 = grid.encode('utf',resolution=4) + eq_(utf1['keys'],[str(max_neg)]) + def test_id_zero(): grid = gen_grid_for_id(0) eq_(grid.get_pixel(128,128),0) diff --git a/tests/python_tests/sqlite_test.py b/tests/python_tests/sqlite_test.py index dc94f1f1e..b0c8f864e 100644 --- a/tests/python_tests/sqlite_test.py +++ b/tests/python_tests/sqlite_test.py @@ -360,6 +360,25 @@ if 'sqlite' in mapnik.DatasourceCache.plugin_names(): eq_(len(feat.geometries()),1) eq_(feat.geometries()[0].to_wkt(),'Point(0 0)') + + def test_that_64bit_int_fields_work(): + ds = mapnik.SQLite(file='../data/sqlite/64bit_int.sqlite', + table='int_table', + use_spatial_index=False + ) + eq_(len(ds.fields()),3) + eq_(ds.fields(),['OGC_FID','id','bigint']) + eq_(ds.field_types(),['int','int','int']) + fs = ds.featureset() + feat = fs.next() + eq_(feat.id(),1) + eq_(feat['OGC_FID'],1) + eq_(feat['bigint'],2147483648) + feat = fs.next() + eq_(feat.id(),2) + eq_(feat['OGC_FID'],2) + eq_(feat['bigint'],922337203685477580) + if __name__ == "__main__": setup() [eval(run)() for run in dir() if 'test_' in run]