diff --git a/plugins/input/occi/occi_featureset.cpp b/plugins/input/occi/occi_featureset.cpp index 1eb89a68c..9d850b1e7 100644 --- a/plugins/input/occi/occi_featureset.cpp +++ b/plugins/input/occi/occi_featureset.cpp @@ -241,14 +241,18 @@ void occi_featureset::convert_geometry (SDOGeometry* geom, feature_ptr feature, { if (ordinates_size >= dimensions) { + const bool is_single_geom = true; + const bool is_point_type = false; + const bool multiple_geoms = false; + convert_ordinates (feature, mapnik::LineString, elem_info, ordinates, dimensions, - true, // is_single_geom - false, // is_point_type - false); // multiple_geometries + is_single_geom, + is_point_type, + multiple_geoms); } } break; @@ -256,14 +260,18 @@ void occi_featureset::convert_geometry (SDOGeometry* geom, feature_ptr feature, { if (ordinates_size >= dimensions) { + const bool is_single_geom = true; + const bool is_point_type = false; + const bool multiple_geoms = false; + convert_ordinates (feature, mapnik::Polygon, elem_info, ordinates, dimensions, - true, // is_single_geom - false, // is_point_type - false); // multiple_geometries + is_single_geom, + is_point_type, + multiple_geoms); } } break; @@ -273,6 +281,7 @@ void occi_featureset::convert_geometry (SDOGeometry* geom, feature_ptr feature, { const bool is_single_geom = false; const bool is_point_type = true; + const bool multiple_geoms = true; // Todo - force using true as multiple_geometries until we have proper multipoint handling // http://trac.mapnik.org/ticket/458 @@ -282,9 +291,9 @@ void occi_featureset::convert_geometry (SDOGeometry* geom, feature_ptr feature, elem_info, ordinates, dimensions, - false, // is_single_geom - true, // is_point_type - true); // multiple_geometries + is_single_geom, + is_point_type, + multiple_geoms); } } break; @@ -292,13 +301,16 @@ void occi_featureset::convert_geometry (SDOGeometry* geom, feature_ptr feature, { if (ordinates_size >= dimensions) { + const bool is_single_geom = false; + const bool is_point_type = false; + convert_ordinates (feature, mapnik::LineString, elem_info, ordinates, dimensions, - false, // is_single_geom - false, // is_point_type + is_single_geom, + is_point_type, multiple_geometries); } @@ -308,13 +320,16 @@ void occi_featureset::convert_geometry (SDOGeometry* geom, feature_ptr feature, { if (ordinates_size >= dimensions) { + const bool is_single_geom = false; + const bool is_point_type = false; + convert_ordinates (feature, mapnik::Polygon, elem_info, ordinates, dimensions, - false, // is_single_geom - false, // is_point_type + is_single_geom, + is_point_type, multiple_geometries); } @@ -332,8 +347,8 @@ void occi_featureset::convert_geometry (SDOGeometry* geom, feature_ptr feature, elem_info, ordinates, dimensions, - false, // is_single_geom, - false, // is_point_type + is_single_geom, + is_point_type, multiple_geometries); } } diff --git a/plugins/input/sqlite/sqlite_types.hpp b/plugins/input/sqlite/sqlite_types.hpp index 7659bcff1..49ae59f1e 100644 --- a/plugins/input/sqlite/sqlite_types.hpp +++ b/plugins/input/sqlite/sqlite_types.hpp @@ -135,9 +135,8 @@ public: const char* column_text (int col, int& len) { - const char* text = (const char*) sqlite3_column_text (stmt_, col); len = sqlite3_column_bytes (stmt_, col); - return text; + return (const char*) sqlite3_column_text (stmt_, col); } const char* column_text (int col) @@ -147,9 +146,8 @@ public: const void* column_blob (int col, int& bytes) { - const char* blob = (const char*) sqlite3_column_blob (stmt_, col); bytes = sqlite3_column_bytes (stmt_, col); - return blob; + return (const char*) sqlite3_column_blob (stmt_, col); } sqlite3_stmt* get_statement() diff --git a/src/wkb.cpp b/src/wkb.cpp index d3c067fa0..2e434f990 100644 --- a/src/wkb.cpp +++ b/src/wkb.cpp @@ -29,6 +29,7 @@ // boost #include +#include namespace mapnik { @@ -56,9 +57,16 @@ public: wkbMultiPoint=4, wkbMultiLineString=5, wkbMultiPolygon=6, - wkbGeometryCollection=7 + wkbGeometryCollection=7, + wkbPointZ=1001, + wkbLineStringZ=1002, + wkbPolygonZ=1003, + wkbMultiPointZ=1004, + wkbMultiLineStringZ=1005, + wkbMultiPolygonZ=1006, + wkbGeometryCollectionZ=1007 }; - + wkb_reader(const char* wkb,unsigned size, wkbFormat format) : wkb_(wkb), size_(size), @@ -68,10 +76,9 @@ public: // try to determine WKB format automatically if (format_ == wkbAuto) { - if (size > 38 - && wkb_[0] == 0x00 - && (wkb_[1] == 0x00 || wkb_[1] == 0x01) - && wkb_[38] == 0x7C) + if (size >= 44 + && (unsigned char)(wkb_[0]) == (unsigned char)(0x00) + && (unsigned char)(wkb_[38]) == (unsigned char)(0x7C)) { format_ = wkbSpatiaLite; } @@ -86,19 +93,25 @@ public: case wkbSpatiaLite: byteOrder_ = (wkbByteOrder) wkb_[1]; pos_ = 39; +#ifdef MAPNIK_DEBUG_WKB + std::clog << "wkb_reader: format is wkbSpatiaLite" << std::endl; +#endif break; case wkbGeneric: default: byteOrder_ = (wkbByteOrder) wkb_[0]; pos_ = 1; +#ifdef MAPNIK_DEBUG_WKB + std::clog << "wkb_reader: format is wkbGeneric" << std::endl; +#endif break; } #ifndef MAPNIK_BIG_ENDIAN - needSwap_=byteOrder_?wkbXDR:wkbNDR; + needSwap_ = byteOrder_ ? wkbXDR : wkbNDR; #else - needSwap_=byteOrder_?wkbNDR:wkbXDR; + needSwap_ = byteOrder_ ? wkbNDR : wkbXDR; #endif } @@ -106,7 +119,13 @@ public: void read_multi(boost::ptr_vector & paths) { - int type=read_integer(); + int type = read_integer(); + +#ifdef MAPNIK_DEBUG_WKB + std::clog << "wkb_reader: read_multi " + << wkb_geometry_type_string(type) << " " << type << std::endl; +#endif + switch (type) { case wkbPoint: @@ -130,6 +149,27 @@ public: case wkbGeometryCollection: read_collection(paths); break; + case wkbPointZ: + read_point_xyz(paths); + break; + case wkbLineStringZ: + read_linestring_xyz(paths); + break; + case wkbPolygonZ: + read_polygon_xyz(paths); + break; + case wkbMultiPointZ: + read_multipoint_xyz(paths); + break; + case wkbMultiLineStringZ: + read_multilinestring_xyz(paths); + break; + case wkbMultiPolygonZ: + read_multipolygon_xyz(paths); + break; + case wkbGeometryCollectionZ: + read_collection(paths); + break; default: break; } @@ -137,7 +177,12 @@ public: void read(boost::ptr_vector & paths) { - int type=read_integer(); + int type = read_integer(); + +#ifdef MAPNIK_DEBUG_WKB + std::clog << "wkb_reader: read " << wkb_geometry_type_string(type) << " " << type << std::endl; +#endif + switch (type) { case wkbPoint: @@ -161,6 +206,27 @@ public: case wkbGeometryCollection: read_collection_2(paths); break; + case wkbPointZ: + read_point_xyz(paths); + break; + case wkbLineStringZ: + read_linestring_xyz(paths); + break; + case wkbPolygonZ: + read_polygon_xyz(paths); + break; + case wkbMultiPointZ: + read_multipoint_xyz_2(paths); + break; + case wkbMultiLineStringZ: + read_multilinestring_xyz_2(paths); + break; + case wkbMultiPolygonZ: + read_multipolygon_xyz_2(paths); + break; + case wkbGeometryCollectionZ: + read_collection_2(paths); + break; default: break; } @@ -173,13 +239,13 @@ private: boost::int32_t n; if (needSwap_) { - read_int32_xdr(wkb_+pos_,n); + read_int32_xdr(wkb_ + pos_, n); } else { - read_int32_ndr(wkb_+pos_,n); + read_int32_ndr(wkb_ + pos_, n); } - pos_+=4; + pos_ += 4; return n; } @@ -195,127 +261,236 @@ private: { read_double_ndr(wkb_ + pos_, d); } - pos_+=8; + pos_ += 8; return d; } void read_coords(CoordinateArray& ar) { - int size=sizeof(coord)*ar.size(); - if (!needSwap_) + if (! needSwap_) { - std::memcpy(&ar[0],wkb_+pos_,size); - pos_+=size; + for (unsigned i = 0; i < ar.size(); ++i) + { + read_double_ndr(wkb_ + pos_, ar[i].x); + read_double_ndr(wkb_ + pos_ + 8, ar[i].y); + pos_ += 16; // skip XY + } } else { for (unsigned i=0;i & paths) { - geometry_type * pt = new geometry_type(Point); + geometry_type* pt = new geometry_type(Point); double x = read_double(); double y = read_double(); - pt->move_to(x,y); + pt->move_to(x, y); paths.push_back(pt); } void read_multipoint(boost::ptr_vector & paths) { int num_points = read_integer(); - for (int i=0;i & paths) { - geometry_type * pt = new geometry_type(MultiPoint); + geometry_type* pt = new geometry_type(MultiPoint); int num_points = read_integer(); - for (int i=0;imove_to(x,y); + pt->move_to(x, y); } paths.push_back(pt); } - + + void read_point_xyz(boost::ptr_vector & paths) + { + geometry_type* pt = new geometry_type(Point); + double x = read_double(); + double y = read_double(); + pos_ += 8; // double z = read_double(); + pt->move_to(x, y); + paths.push_back(pt); + } + + void read_multipoint_xyz(boost::ptr_vector & paths) + { + int num_points = read_integer(); + for (int i = 0; i < num_points; ++i) + { + pos_ += 5; + read_point_xyz(paths); + } + } + + void read_multipoint_xyz_2(boost::ptr_vector & paths) + { + geometry_type* pt = new geometry_type(MultiPoint); + int num_points = read_integer(); + for (int i = 0; i < num_points; ++i) + { + pos_ += 5; + double x = read_double(); + double y = read_double(); + pos_ += 8; // double z = read_double(); + pt->move_to(x, y); + } + paths.push_back(pt); + } + + void read_linestring(boost::ptr_vector & paths) { - geometry_type * line = new geometry_type(LineString); - int num_points=read_integer(); + geometry_type* line = new geometry_type(LineString); + int num_points = read_integer(); CoordinateArray ar(num_points); read_coords(ar); line->set_capacity(num_points); - line->move_to(ar[0].x,ar[0].y); - for (int i=1;imove_to(ar[0].x, ar[0].y); + for (int i = 1; i < num_points; ++i) { - line->line_to(ar[i].x,ar[i].y); + line->line_to(ar[i].x, ar[i].y); } paths.push_back(line); } void read_multilinestring(boost::ptr_vector & paths) { - int num_lines=read_integer(); - for (int i=0;i & paths) { - geometry_type * line = new geometry_type(MultiLineString); - int num_lines=read_integer(); + geometry_type* line = new geometry_type(MultiLineString); + int num_lines = read_integer(); unsigned capacity = 0; - for (int i=0;iset_capacity(capacity); - line->move_to(ar[0].x,ar[0].y); - for (int j=1;jmove_to(ar[0].x, ar[0].y); + for (int j = 1; j < num_points; ++j) { - line->line_to(ar[j].x,ar[j].y); + line->line_to(ar[j].x, ar[j].y); } } paths.push_back(line); } - + + void read_linestring_xyz(boost::ptr_vector & paths) + { + geometry_type* line = new geometry_type(LineString); + int num_points = read_integer(); + CoordinateArray ar(num_points); + read_coords_xyz(ar); + line->set_capacity(num_points); + line->move_to(ar[0].x, ar[0].y); + for (int i = 1; i < num_points; ++i) + { + line->line_to(ar[i].x, ar[i].y); + } + paths.push_back(line); + } + + void read_multilinestring_xyz(boost::ptr_vector & paths) + { + int num_lines = read_integer(); + for (int i = 0; i < num_lines; ++i) + { + pos_ += 5; + read_linestring_xyz(paths); + } + } + + void read_multilinestring_xyz_2(boost::ptr_vector & paths) + { + geometry_type* line = new geometry_type(MultiLineString); + int num_lines = read_integer(); + unsigned capacity = 0; + for (int i = 0; i < num_lines; ++i) + { + pos_ += 5; + int num_points = read_integer(); + capacity += num_points; + CoordinateArray ar(num_points); + read_coords_xyz(ar); + line->set_capacity(capacity); + line->move_to(ar[0].x, ar[0].y); + for (int j = 1; j < num_points; ++j) + { + line->line_to(ar[j].x, ar[j].y); + } + } + paths.push_back(line); + } + + void read_polygon(boost::ptr_vector & paths) { - geometry_type * poly = new geometry_type(Polygon); - int num_rings=read_integer(); + geometry_type* poly = new geometry_type(Polygon); + int num_rings = read_integer(); unsigned capacity = 0; - for (int i=0;iset_capacity(capacity); - poly->move_to(ar[0].x,ar[0].y); - for (int j=1;jmove_to(ar[0].x, ar[0].y); + for (int j = 1; j < num_points; ++j) { - poly->line_to(ar[j].x,ar[j].y); + poly->line_to(ar[j].x, ar[j].y); } } paths.push_back(poly); @@ -323,60 +498,148 @@ private: void read_multipolygon(boost::ptr_vector & paths) { - int num_polys=read_integer(); - for (int i=0;i & paths) { - geometry_type * poly = new geometry_type(MultiPolygon); - int num_polys=read_integer(); + geometry_type* poly = new geometry_type(MultiPolygon); + int num_polys = read_integer(); unsigned capacity = 0; - for (int i=0;iset_capacity(capacity); - poly->move_to(ar[0].x,ar[0].y); - for (int j=1;jmove_to(ar[0].x, ar[0].y); + for (int j = 1; j < num_points; ++j) { - poly->line_to(ar[j].x,ar[j].y); + poly->line_to(ar[j].x, ar[j].y); } - poly->line_to(ar[0].x,ar[0].y); + poly->line_to(ar[0].x, ar[0].y); } } paths.push_back(poly); } + void read_polygon_xyz(boost::ptr_vector & paths) + { + geometry_type* poly = new geometry_type(Polygon); + int num_rings = read_integer(); + unsigned capacity = 0; + for (int i = 0; i < num_rings; ++i) + { + int num_points = read_integer(); + capacity += num_points; + CoordinateArray ar(num_points); + read_coords_xyz(ar); + poly->set_capacity(capacity); + poly->move_to(ar[0].x, ar[0].y); + for (int j = 1; j < num_points; ++j) + { + poly->line_to(ar[j].x, ar[j].y); + } + } + paths.push_back(poly); + } + + void read_multipolygon_xyz(boost::ptr_vector & paths) + { + int num_polys = read_integer(); + for (int i = 0; i < num_polys; ++i) + { + pos_ += 5; + read_polygon_xyz(paths); + } + } + + void read_multipolygon_xyz_2(boost::ptr_vector & paths) + { + geometry_type* poly = new geometry_type(MultiPolygon); + int num_polys = read_integer(); + unsigned capacity = 0; + for (int i = 0; i < num_polys; ++i) + { + pos_ += 5; + int num_rings = read_integer(); + for (int r = 0; r < num_rings; ++r) + { + int num_points = read_integer(); + capacity += num_points; + CoordinateArray ar(num_points); + read_coords_xyz(ar); + poly->set_capacity(capacity); + poly->move_to(ar[0].x, ar[0].y); + for (int j = 1; j < num_points; ++j) + { + poly->line_to(ar[j].x, ar[j].y); + } + poly->line_to(ar[0].x, ar[0].y); + } + } + paths.push_back(poly); + } + + void read_collection(boost::ptr_vector & paths) { - int num_geometries=read_integer(); - for (int i=0;i & paths) { - int num_geometries=read_integer(); - for (int i=0;i& paths, @@ -385,10 +648,14 @@ void geometry_utils::from_wkb (boost::ptr_vector& paths, bool multiple_geometries, wkbFormat format) { - wkb_reader reader(wkb,size,format); + wkb_reader reader(wkb, size, format); if (multiple_geometries) + { return reader.read_multi(paths); + } else + { return reader.read(paths); + } } } diff --git a/workspace/bindings.pri b/workspace/bindings.pri new file mode 100644 index 000000000..acd4f6753 --- /dev/null +++ b/workspace/bindings.pri @@ -0,0 +1,49 @@ + +HEADERS += \ + $$PWD/../bindings/python/mapnik_enumeration.hpp \ + $$PWD/../bindings/python/mapnik_svg.hpp \ + $$PWD/../bindings/python/mapnik_value_converter.hpp \ + $$PWD/../bindings/python/python_grid_utils.hpp \ + $$PWD/../bindings/python/python_optional.hpp + +SOURCES += \ + $$PWD/../bindings/python/mapnik_color.cpp \ + $$PWD/../bindings/python/mapnik_coord.cpp \ + $$PWD/../bindings/python/mapnik_datasource.cpp \ + $$PWD/../bindings/python/mapnik_datasource_cache.cpp \ + $$PWD/../bindings/python/mapnik_envelope.cpp \ + $$PWD/../bindings/python/mapnik_expression.cpp \ + $$PWD/../bindings/python/mapnik_feature.cpp \ + $$PWD/../bindings/python/mapnik_featureset.cpp \ + $$PWD/../bindings/python/mapnik_font_engine.cpp \ + $$PWD/../bindings/python/mapnik_geometry.cpp \ + $$PWD/../bindings/python/mapnik_glyph_symbolizer.cpp \ + $$PWD/../bindings/python/mapnik_grid.cpp \ + $$PWD/../bindings/python/mapnik_grid_view.cpp \ + $$PWD/../bindings/python/mapnik_image.cpp \ + $$PWD/../bindings/python/mapnik_image_view.cpp \ + $$PWD/../bindings/python/mapnik_inmem_metawriter.cpp \ + $$PWD/../bindings/python/mapnik_layer.cpp \ + $$PWD/../bindings/python/mapnik_line_pattern_symbolizer.cpp \ + $$PWD/../bindings/python/mapnik_line_symbolizer.cpp \ + $$PWD/../bindings/python/mapnik_map.cpp \ + $$PWD/../bindings/python/mapnik_markers_symbolizer.cpp \ + $$PWD/../bindings/python/mapnik_palette.cpp \ + $$PWD/../bindings/python/mapnik_parameters.cpp \ + $$PWD/../bindings/python/mapnik_point_symbolizer.cpp \ + $$PWD/../bindings/python/mapnik_polygon_pattern_symbolizer.cpp \ + $$PWD/../bindings/python/mapnik_polygon_symbolizer.cpp \ + $$PWD/../bindings/python/mapnik_proj_transform.cpp \ + $$PWD/../bindings/python/mapnik_projection.cpp \ + $$PWD/../bindings/python/mapnik_python.cpp \ + $$PWD/../bindings/python/mapnik_query.cpp \ + $$PWD/../bindings/python/mapnik_raster_colorizer.cpp \ + $$PWD/../bindings/python/mapnik_raster_symbolizer.cpp \ + $$PWD/../bindings/python/mapnik_rule.cpp \ + $$PWD/../bindings/python/mapnik_shield_symbolizer.cpp \ + $$PWD/../bindings/python/mapnik_stroke.cpp \ + $$PWD/../bindings/python/mapnik_style.cpp \ + $$PWD/../bindings/python/mapnik_symbolizer.cpp \ + $$PWD/../bindings/python/mapnik_text_symbolizer.cpp \ + $$PWD/../bindings/python/mapnik_view_transform.cpp \ + $$PWD/../bindings/python/python_cairo.cpp diff --git a/workspace/mapnik.pro b/workspace/mapnik.pro index 5672de642..60a86e6be 100644 --- a/workspace/mapnik.pro +++ b/workspace/mapnik.pro @@ -201,8 +201,13 @@ SOURCES += \ ../src/unicode.cpp \ ../src/warp.cpp \ ../src/wkb.cpp - + +OTHER_FILES += \ + ../SConstruct \ + ../config.py + include(plugins.pri) +include(bindings.pri) unix { DEFINES += LINUX=1