diff --git a/bindings/python/mapnik_geometry.cpp b/bindings/python/mapnik_geometry.cpp index c7c1d5462..9b7c3fb14 100644 --- a/bindings/python/mapnik_geometry.cpp +++ b/bindings/python/mapnik_geometry.cpp @@ -270,10 +270,10 @@ void export_geometry() { using namespace boost::python; - enum_("GeometryType") - .value("Point",mapnik::Point) - .value("LineString",mapnik::LineString) - .value("Polygon",mapnik::Polygon) + enum_("GeometryType") + .value("Point",mapnik::geometry_type::types::Point) + .value("LineString",mapnik::geometry_type::types::LineString) + .value("Polygon",mapnik::geometry_type::types::Polygon) ; #if BOOST_VERSION >= 104700 diff --git a/include/mapnik/geometry.hpp b/include/mapnik/geometry.hpp index c3f616f5f..1db96e0c6 100644 --- a/include/mapnik/geometry.hpp +++ b/include/mapnik/geometry.hpp @@ -34,25 +34,29 @@ namespace mapnik { -enum eGeomType { - Unknown = 0, - Point = 1, - LineString = 2, - Polygon = 3 -}; - template class Container=vertex_vector> class geometry : private mapnik::noncopyable { + public: + static const std::uint8_t geometry_bits = 7; + enum types : std::uint8_t + { + Unknown = 0x00, + Point = 0x01, + LineString = 0x02, + Polygon = 0x03, + PolygonExterior = Polygon, + PolygonInterior = Polygon | ( 1 << geometry_bits) + }; typedef T coord_type; typedef Container container_type; typedef typename container_type::value_type value_type; typedef typename container_type::size_type size_type; private: container_type cont_; - eGeomType type_; - mutable unsigned itr_; + types type_; + mutable size_type itr_; public: geometry() @@ -60,17 +64,22 @@ public: itr_(0) {} - explicit geometry(eGeomType type) + explicit geometry(types type) : type_(type), itr_(0) {} - eGeomType type() const + types type() const { - return type_; + return static_cast(type_ & types::Polygon); } - void set_type(eGeomType type) + bool interior() const + { + return static_cast(type_ >> geometry_bits); + } + + void set_type(types type) { type_ = type; } @@ -91,7 +100,7 @@ public: double x = 0; double y = 0; rewind(0); - for (unsigned i=0; i < size(); ++i) + for (size_type i = 0; i < size(); ++i) { unsigned cmd = vertex(&x,&y); if (cmd == SEG_CLOSE) continue; diff --git a/include/mapnik/grid/grid_marker_helpers.hpp b/include/mapnik/grid/grid_marker_helpers.hpp index 5acb73a5d..0d1b0bb2e 100644 --- a/include/mapnik/grid/grid_marker_helpers.hpp +++ b/include/mapnik/grid/grid_marker_helpers.hpp @@ -79,11 +79,11 @@ struct raster_markers_rasterizer_dispatch_grid marker_placement_e placement_method = sym_.get_marker_placement(); box2d bbox_(0,0, src_.width(),src_.height()); if (placement_method != MARKER_LINE_PLACEMENT || - path.type() == Point) + path.type() == geometry_type::types::Point) { double x = 0; double y = 0; - if (path.type() == LineString) + if (path.type() == geometry_type::types::LineString) { if (!label::middle_point(path, x, y)) return; @@ -216,11 +216,11 @@ struct vector_markers_rasterizer_dispatch_grid { marker_placement_e placement_method = sym_.get_marker_placement(); if (placement_method != MARKER_LINE_PLACEMENT || - path.type() == Point) + path.type() == geometry_type::types::Point) { double x = 0; double y = 0; - if (path.type() == LineString) + if (path.type() == geometry_type::types::LineString) { if (!label::middle_point(path, x, y)) return; @@ -294,4 +294,3 @@ private: } #endif - diff --git a/include/mapnik/json/geometry_generator_grammar.hpp b/include/mapnik/json/geometry_generator_grammar.hpp index 63d3a1f9e..407d8ff76 100644 --- a/include/mapnik/json/geometry_generator_grammar.hpp +++ b/include/mapnik/json/geometry_generator_grammar.hpp @@ -202,17 +202,17 @@ struct geometry_generator_grammar : coordinates = point | linestring | polygon ; - point = &uint_(mapnik::Point)[_1 = _type(_val)] + point = &uint_(mapnik::geometry_type::types::Point)[_1 = _type(_val)] << point_coord [_1 = _first(_val)] ; - linestring = &uint_(mapnik::LineString)[_1 = _type(_val)] + linestring = &uint_(mapnik::geometry_type::types::LineString)[_1 = _type(_val)] << lit('[') << coords << lit(']') ; - polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)] + polygon = &uint_(mapnik::geometry_type::types::Polygon)[_1 = _type(_val)] << lit('[') << coords2 << lit("]]") @@ -280,12 +280,12 @@ struct multi_geometry_generator_grammar : using boost::spirit::karma::string; geometry_types.add - (mapnik::Point,"\"Point\"") - (mapnik::LineString,"\"LineString\"") - (mapnik::Polygon,"\"Polygon\"") - (mapnik::Point + 3,"\"MultiPoint\"") - (mapnik::LineString + 3,"\"MultiLineString\"") - (mapnik::Polygon + 3,"\"MultiPolygon\"") + (mapnik::geometry_type::types::Point,"\"Point\"") + (mapnik::geometry_type::types::LineString,"\"LineString\"") + (mapnik::geometry_type::types::Polygon,"\"Polygon\"") + (mapnik::geometry_type::types::Point + 3,"\"MultiPoint\"") + (mapnik::geometry_type::types::LineString + 3,"\"MultiLineString\"") + (mapnik::geometry_type::types::Polygon + 3,"\"MultiPolygon\"") ; start %= ( eps(phoenix::at_c<1>(_a))[_a = _multi_type(_val)] diff --git a/include/mapnik/marker_helpers.hpp b/include/mapnik/marker_helpers.hpp index 44e33e6e4..008386552 100644 --- a/include/mapnik/marker_helpers.hpp +++ b/include/mapnik/marker_helpers.hpp @@ -94,11 +94,11 @@ struct vector_markers_rasterizer_dispatch marker_placement_e placement_method = sym_.get_marker_placement(); if (placement_method != MARKER_LINE_PLACEMENT || - path.type() == Point) + path.type() == mapnik::geometry_type::types::Point) { double x = 0; double y = 0; - if (path.type() == LineString) + if (path.type() == mapnik::geometry_type::types::LineString) { if (!label::middle_point(path, x, y)) return; @@ -206,11 +206,11 @@ struct raster_markers_rasterizer_dispatch box2d bbox_(0,0, src_.width(),src_.height()); if (placement_method != MARKER_LINE_PLACEMENT || - path.type() == Point) + path.type() == mapnik::geometry_type::types::Point) { double x = 0; double y = 0; - if (path.type() == LineString) + if (path.type() == mapnik::geometry_type::types::LineString) { if (!label::middle_point(path, x, y)) return; @@ -477,7 +477,7 @@ void apply_markers_multi(feature_impl & feature, Converter& converter, markers_s double x, y; if (label::centroid_geoms(feature.paths().begin(), feature.paths().end(), x, y)) { - geometry_type pt(Point); + geometry_type pt(geometry_type::types::Point); pt.move_to(x, y); // unset any clipping since we're now dealing with a point converter.template unset(); diff --git a/include/mapnik/symbolizer_hash.hpp b/include/mapnik/symbolizer_hash.hpp index db89ff8a9..2b34f4b44 100644 --- a/include/mapnik/symbolizer_hash.hpp +++ b/include/mapnik/symbolizer_hash.hpp @@ -41,7 +41,7 @@ struct symbolizer_hash // specialisation for polygon_symbolizer static std::size_t value(polygon_symbolizer const& sym) { - std::size_t seed = Polygon; + std::size_t seed = geometry_type::types::Polygon; boost::hash_combine(seed, sym.get_fill().rgba()); boost::hash_combine(seed, sym.get_opacity()); return seed; @@ -50,7 +50,7 @@ struct symbolizer_hash // specialisation for line_symbolizer static std::size_t value(line_symbolizer const& sym) { - std::size_t seed = LineString; + std::size_t seed = geometry_type::types::LineString; boost::hash_combine(seed, sym.get_stroke().get_color().rgba()); boost::hash_combine(seed, sym.get_stroke().get_width()); boost::hash_combine(seed, sym.get_stroke().get_opacity()); diff --git a/include/mapnik/util/geometry_svg_generator.hpp b/include/mapnik/util/geometry_svg_generator.hpp index 1ffff0d8b..e6db2f80a 100644 --- a/include/mapnik/util/geometry_svg_generator.hpp +++ b/include/mapnik/util/geometry_svg_generator.hpp @@ -171,7 +171,7 @@ namespace mapnik { namespace util { svg = point | linestring | polygon ; - point = &uint_(mapnik::Point)[_1 = _type(_val)] + point = &uint_(mapnik::geometry_type::types::Point)[_1 = _type(_val)] << svg_point [_1 = _first(_val)] ; @@ -181,11 +181,11 @@ namespace mapnik { namespace util { << lit('\"') ; - linestring = &uint_(mapnik::LineString)[_1 = _type(_val)] + linestring = &uint_(mapnik::geometry_type::types::LineString)[_1 = _type(_val)] << lit("d=\"") << svg_path << lit("\"") ; - polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)] + polygon = &uint_(mapnik::geometry_type::types::Polygon)[_1 = _type(_val)] << lit("d=\"") << svg_path << lit("\"") ; diff --git a/include/mapnik/util/geometry_to_wkb.hpp b/include/mapnik/util/geometry_to_wkb.hpp index f3a0ac5e8..6aaeb629a 100644 --- a/include/mapnik/util/geometry_to_wkb.hpp +++ b/include/mapnik/util/geometry_to_wkb.hpp @@ -143,7 +143,7 @@ wkb_buffer_ptr to_point_wkb( GeometryType const& g, wkbByteOrder byte_order) wkb_buffer_ptr wkb(new wkb_buffer(size)); wkb_stream ss(wkb->buffer(), wkb->size()); ss.write(reinterpret_cast(&byte_order),1); - int type = static_cast(mapnik::Point); + int type = static_cast(mapnik::geometry_type::types::Point); write(ss,type,4,byte_order); double x = 0; double y = 0; @@ -163,7 +163,7 @@ wkb_buffer_ptr to_line_string_wkb( GeometryType const& g, wkbByteOrder byte_orde wkb_buffer_ptr wkb(new wkb_buffer(size)); wkb_stream ss(wkb->buffer(), wkb->size()); ss.write(reinterpret_cast(&byte_order),1); - int type = static_cast(mapnik::LineString); + int type = static_cast(mapnik::geometry_type::types::LineString); write(ss,type,4,byte_order); write(ss,num_points,4,byte_order); double x = 0; @@ -211,7 +211,7 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order) wkb_buffer_ptr wkb(new wkb_buffer(size)); wkb_stream ss(wkb->buffer(), wkb->size()); ss.write(reinterpret_cast(&byte_order),1); - int type = static_cast(mapnik::Polygon); + int type = static_cast(mapnik::geometry_type::types::Polygon); write(ss,type,4,byte_order); write(ss,num_rings,4,byte_order); @@ -237,13 +237,13 @@ wkb_buffer_ptr to_wkb(GeometryType const& g, wkbByteOrder byte_order ) switch (g.type()) { - case mapnik::Point: + case mapnik::geometry_type::types::Point: wkb = to_point_wkb(g, byte_order); break; - case mapnik::LineString: + case mapnik::geometry_type::types::LineString: wkb = to_line_string_wkb(g, byte_order); break; - case mapnik::Polygon: + case mapnik::geometry_type::types::Polygon: wkb = to_polygon_wkb(g, byte_order); break; default: diff --git a/include/mapnik/vertex_vector.hpp b/include/mapnik/vertex_vector.hpp index 44fbd7884..82b878f7a 100644 --- a/include/mapnik/vertex_vector.hpp +++ b/include/mapnik/vertex_vector.hpp @@ -55,12 +55,12 @@ public: // required for iterators support typedef boost::tuple value_type; typedef std::size_t size_type; - + typedef std::uint8_t command_size; private: unsigned num_blocks_; unsigned max_blocks_; coord_type** vertices_; - unsigned char** commands_; + command_size** commands_; size_type pos_; public: @@ -90,7 +90,7 @@ public: return pos_; } - void push_back (coord_type x,coord_type y,unsigned command) + void push_back (coord_type x,coord_type y,command_size command) { unsigned block = pos_ >> block_shift; if (block >= num_blocks_) @@ -98,9 +98,9 @@ public: allocate_block(block); } coord_type* vertex = vertices_[block] + ((pos_ & block_mask) << 1); - unsigned char* cmd= commands_[block] + (pos_ & block_mask); + command_size* cmd= commands_[block] + (pos_ & block_mask); - *cmd = static_cast(command); + *cmd = static_cast(command); *vertex++ = x; *vertex = y; ++pos_; @@ -130,11 +130,11 @@ private: { coord_type** new_vertices = static_cast(::operator new (sizeof(coord_type*)*((max_blocks_ + grow_by) * 2))); - unsigned char** new_commands = (unsigned char**)(new_vertices + max_blocks_ + grow_by); + command_size** new_commands = (command_size**)(new_vertices + max_blocks_ + grow_by); if (vertices_) { std::memcpy(new_vertices,vertices_,max_blocks_ * sizeof(coord_type*)); - std::memcpy(new_commands,commands_,max_blocks_ * sizeof(unsigned char*)); + std::memcpy(new_commands,commands_,max_blocks_ * sizeof(command_size*)); ::operator delete(vertices_); } vertices_ = new_vertices; @@ -144,7 +144,7 @@ private: vertices_[block] = static_cast (::operator new(sizeof(coord_type)*(block_size * 2 + block_size / (sizeof(coord_type))))); - commands_[block] = (unsigned char*)(vertices_[block] + block_size*2); + commands_[block] = (command_size*)(vertices_[block] + block_size*2); ++num_blocks_; } }; diff --git a/include/mapnik/wkt/wkt_grammar.hpp b/include/mapnik/wkt/wkt_grammar.hpp index b657cb90e..47e7e8e84 100644 --- a/include/mapnik/wkt/wkt_grammar.hpp +++ b/include/mapnik/wkt/wkt_grammar.hpp @@ -97,7 +97,7 @@ struct wkt_grammar : qi::grammar ::= point - point_tagged_text = no_case[lit("POINT")] [ _a = new_(Point) ] + point_tagged_text = no_case[lit("POINT")] [ _a = new_(geometry_type::types::Point) ] >> ( point_text(_a) [push_back(_val,_a)] | eps[cleanup_(_a)][_pass = false]) ; @@ -108,7 +108,7 @@ struct wkt_grammar : qi::grammar ::= linestring - linestring_tagged_text = no_case[lit("LINESTRING")] [ _a = new_(LineString) ] + linestring_tagged_text = no_case[lit("LINESTRING")] [ _a = new_(geometry_type::types::LineString) ] >> (linestring_text(_a)[push_back(_val,_a)] | eps[cleanup_(_a)][_pass = false]) ; @@ -118,7 +118,7 @@ struct wkt_grammar : qi::grammar ::= polygon - polygon_tagged_text = no_case[lit("POLYGON")] [ _a = new_(Polygon) ] + polygon_tagged_text = no_case[lit("POLYGON")] [ _a = new_(geometry_type::types::Polygon) ] >> ( polygon_text(_a)[push_back(_val,_a)] | eps[cleanup_(_a)][_pass = false]) ; @@ -134,7 +134,7 @@ struct wkt_grammar : qi::grammar ::= | { }* multipoint_text = (lit('(') - >> ((eps[_a = new_(Point)] + >> ((eps[_a = new_(geometry_type::types::Point)] >> (point_text(_a) | empty_set) [push_back(_val,_a)] | eps[cleanup_(_a)][_pass = false]) % lit(',')) >> lit(')')) | empty_set @@ -146,7 +146,7 @@ struct wkt_grammar : qi::grammar ::= | { }* multilinestring_text = (lit('(') - >> ((eps[_a = new_(LineString)] + >> ((eps[_a = new_(geometry_type::types::LineString)] >> ( points(_a)[push_back(_val,_a)] | eps[cleanup_(_a)][_pass = false])) % lit(',')) @@ -159,7 +159,7 @@ struct wkt_grammar : qi::grammar ::= | { }* multipolygon_text = (lit('(') - >> ((eps[_a = new_(Polygon)] + >> ((eps[_a = new_(geometry_type::types::Polygon)] >> ( polygon_text(_a)[push_back(_val,_a)] | eps[cleanup_(_a)][_pass = false])) % lit(',')) diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index e1478cd36..db6521115 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -773,7 +773,7 @@ void csv_datasource::parse_csv(T & stream, { if (parsed_x && parsed_y) { - mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::Point); + mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::geometry_type::types::Point); pt->move_to(x,y); feature->add_geometry(pt); features_.push_back(feature); diff --git a/plugins/input/gdal/gdal_featureset.cpp b/plugins/input/gdal/gdal_featureset.cpp index b87555add..f0804fcbd 100644 --- a/plugins/input/gdal/gdal_featureset.cpp +++ b/plugins/input/gdal/gdal_featureset.cpp @@ -523,7 +523,7 @@ feature_ptr gdal_featureset::get_feature_at_point(mapnik::coord2d const& pt) { // construct feature feature_ptr feature = feature_factory::create(ctx_,1); - geometry_type * point = new geometry_type(mapnik::Point); + geometry_type * point = new geometry_type(mapnik::geometry_type::types::Point); point->move_to(pt.x, pt.y); feature->add_geometry(point); feature->put("value",value); diff --git a/plugins/input/occi/occi_featureset.cpp b/plugins/input/occi/occi_featureset.cpp index fe0455742..1cb0cf4cc 100644 --- a/plugins/input/occi/occi_featureset.cpp +++ b/plugins/input/occi/occi_featureset.cpp @@ -377,7 +377,7 @@ void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature) } void occi_featureset::convert_ordinates(mapnik::feature_ptr feature, - const mapnik::eGeomType& geom_type, + const mapnik::geometry::types& geom_type, const std::vector& elem_info, const std::vector& ordinates, const int dimensions, @@ -404,7 +404,7 @@ void occi_featureset::convert_ordinates(mapnik::feature_ptr feature, int next_interp = elem_info[i + 2]; bool is_linear_element = true; bool is_unknown_etype = false; - mapnik::eGeomType gtype = mapnik::Point; + mapnik::geometry::types gtype = mapnik::Point; switch (etype) { diff --git a/plugins/input/occi/occi_featureset.hpp b/plugins/input/occi/occi_featureset.hpp index cb4e7cb9e..e81e24071 100644 --- a/plugins/input/occi/occi_featureset.hpp +++ b/plugins/input/occi/occi_featureset.hpp @@ -55,7 +55,7 @@ public: private: void convert_geometry (SDOGeometry* geom, mapnik::feature_ptr feature); void convert_ordinates (mapnik::feature_ptr feature, - const mapnik::eGeomType& geom_type, + const mapnik::geometry::types& geom_type, const std::vector& elem_info, const std::vector& ordinates, const int dimensions, diff --git a/plugins/input/ogr/ogr_converter.cpp b/plugins/input/ogr/ogr_converter.cpp index cce0336e5..19beeae1d 100644 --- a/plugins/input/ogr/ogr_converter.cpp +++ b/plugins/input/ogr/ogr_converter.cpp @@ -79,7 +79,7 @@ void ogr_converter::convert_geometry(OGRGeometry* geom, feature_ptr feature) void ogr_converter::convert_point(OGRPoint* geom, feature_ptr feature) { - std::unique_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::geometry_type::types::Point)); point->move_to(geom->getX(), geom->getY()); feature->paths().push_back(point.release()); } @@ -87,7 +87,7 @@ void ogr_converter::convert_point(OGRPoint* geom, feature_ptr feature) void ogr_converter::convert_linestring(OGRLineString* geom, feature_ptr feature) { int num_points = geom->getNumPoints(); - std::unique_ptr line(new geometry_type(mapnik::LineString)); + std::unique_ptr line(new geometry_type(mapnik::geometry_type::types::LineString)); line->move_to(geom->getX(0), geom->getY(0)); for (int i = 1; i < num_points; ++i) { @@ -108,7 +108,7 @@ void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature) capacity += interior->getNumPoints(); } - std::unique_ptr poly(new geometry_type(mapnik::Polygon)); + std::unique_ptr poly(new geometry_type(mapnik::geometry_type::types::Polygon)); poly->move_to(exterior->getX(0), exterior->getY(0)); for (int i = 1; i < num_points; ++i) diff --git a/plugins/input/osm/osm_featureset.cpp b/plugins/input/osm/osm_featureset.cpp index e72c597ff..db0f62255 100644 --- a/plugins/input/osm/osm_featureset.cpp +++ b/plugins/input/osm/osm_featureset.cpp @@ -65,7 +65,7 @@ feature_ptr osm_featureset::next() feature = feature_factory::create(ctx_, cur_item->id); double lat = static_cast(cur_item)->lat; double lon = static_cast(cur_item)->lon; - geometry_type* point = new geometry_type(mapnik::Point); + geometry_type* point = new geometry_type(mapnik::geometry_type::types::Point); point->move_to(lon, lat); feature->add_geometry(point); } @@ -86,11 +86,11 @@ feature_ptr osm_featureset::next() geometry_type* geom; if (static_cast(cur_item)->is_polygon()) { - geom = new geometry_type(mapnik::Polygon); + geom = new geometry_type(mapnik::geometry_type::types::Polygon); } else { - geom = new geometry_type(mapnik::LineString); + geom = new geometry_type(mapnik::geometry_type::types::LineString); } geom->move_to(static_cast(cur_item)->nodes[0]->lon, diff --git a/plugins/input/shape/shape_featureset.cpp b/plugins/input/shape/shape_featureset.cpp index 01176bc48..cce768704 100644 --- a/plugins/input/shape/shape_featureset.cpp +++ b/plugins/input/shape/shape_featureset.cpp @@ -89,7 +89,7 @@ feature_ptr shape_featureset::next() double y = record.read_double(); if (!filter_.pass(mapnik::box2d(x,y,x,y))) continue; - std::unique_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::geometry_type::types::Point)); point->move_to(x, y); feature->paths().push_back(point.release()); break; @@ -105,7 +105,7 @@ feature_ptr shape_featureset::next() { double x = record.read_double(); double y = record.read_double(); - std::unique_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::geometry_type::types::Point)); point->move_to(x, y); feature->paths().push_back(point.release()); } diff --git a/plugins/input/shape/shape_index_featureset.cpp b/plugins/input/shape/shape_index_featureset.cpp index aab9b188c..c896b9208 100644 --- a/plugins/input/shape/shape_index_featureset.cpp +++ b/plugins/input/shape/shape_index_featureset.cpp @@ -101,7 +101,7 @@ feature_ptr shape_index_featureset::next() { double x = record.read_double(); double y = record.read_double(); - std::unique_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::geometry_type::types::Point)); point->move_to(x, y); feature->paths().push_back(point.release()); break; @@ -117,7 +117,7 @@ feature_ptr shape_index_featureset::next() { double x = record.read_double(); double y = record.read_double(); - std::unique_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::geometry_type::types::Point)); point->move_to(x, y); feature->paths().push_back(point.release()); } diff --git a/plugins/input/shape/shape_io.cpp b/plugins/input/shape/shape_io.cpp index 858e54ef3..cceb7198e 100644 --- a/plugins/input/shape/shape_io.cpp +++ b/plugins/input/shape/shape_io.cpp @@ -96,7 +96,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry int num_points = record.read_ndr_integer(); if (num_parts == 1) { - std::unique_ptr line(new geometry_type(mapnik::LineString)); + std::unique_ptr line(new geometry_type(mapnik::geometry_type::types::LineString)); record.skip(4); double x = record.read_double(); double y = record.read_double(); @@ -120,7 +120,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry int start, end; for (int k = 0; k < num_parts; ++k) { - std::unique_ptr line(new geometry_type(mapnik::LineString)); + std::unique_ptr line(new geometry_type(mapnik::geometry_type::types::LineString)); start = parts[k]; if (k == num_parts - 1) { @@ -159,7 +159,7 @@ void shape_io::read_polygon(shape_file::record_type & record, mapnik::geometry_c for (int k = 0; k < num_parts; ++k) { - std::unique_ptr poly(new geometry_type(mapnik::Polygon)); + std::unique_ptr poly(new geometry_type(mapnik::geometry_type::types::Polygon)); int start = parts[k]; int end; if (k == num_parts - 1) diff --git a/src/agg/process_building_symbolizer.cpp b/src/agg/process_building_symbolizer.cpp index d4d7dae05..65f1e6b79 100644 --- a/src/agg/process_building_symbolizer.cpp +++ b/src/agg/process_building_symbolizer.cpp @@ -91,8 +91,8 @@ void agg_renderer::process(building_symbolizer const& sym, geometry_type const& geom = feature.get_geometry(i); if (geom.size() > 2) { - boost::scoped_ptr frame(new geometry_type(LineString)); - boost::scoped_ptr roof(new geometry_type(Polygon)); + boost::scoped_ptr frame(new geometry_type(geometry_type::types::LineString)); + boost::scoped_ptr roof(new geometry_type(geometry_type::types::Polygon)); std::deque face_segments; double x0 = 0; double y0 = 0; @@ -124,7 +124,7 @@ void agg_renderer::process(building_symbolizer const& sym, for (; itr!=end; ++itr) { - boost::scoped_ptr faces(new geometry_type(Polygon)); + boost::scoped_ptr faces(new geometry_type(geometry_type::types::Polygon)); faces->move_to(itr->get<0>(),itr->get<1>()); faces->line_to(itr->get<2>(),itr->get<3>()); faces->line_to(itr->get<2>(),itr->get<3>() + height); diff --git a/src/agg/process_markers_symbolizer.cpp b/src/agg/process_markers_symbolizer.cpp index 2e8b5469d..33e207413 100644 --- a/src/agg/process_markers_symbolizer.cpp +++ b/src/agg/process_markers_symbolizer.cpp @@ -142,8 +142,8 @@ void agg_renderer::process(markers_symbolizer const& sym, converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_); if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.template set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 //else if (type == LineString) @@ -182,8 +182,8 @@ void agg_renderer::process(markers_symbolizer const& sym, converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_); if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.template set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 //else if (type == LineString) @@ -220,13 +220,13 @@ void agg_renderer::process(markers_symbolizer const& sym, if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.template set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 - //else if (type == LineString) + //else if (type == geometry_type::types::LineString) // converter.template set(); - // don't clip if type==Point + // don't clip if type==geometry_type::types::Point } converter.template set(); //always transform if (sym.smooth() > 0.0) converter.template set(); // optional smooth converter diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index 4da8ef52c..d74977285 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -360,8 +360,8 @@ void cairo_renderer_base::process(building_symbolizer const& sym, if (geom.size() > 2) { - boost::scoped_ptr frame(new geometry_type(LineString)); - boost::scoped_ptr roof(new geometry_type(Polygon)); + boost::scoped_ptr frame(new geometry_type(geometry_type::types::LineString)); + boost::scoped_ptr roof(new geometry_type(geometry_type::types::Polygon)); std::deque face_segments; double x0 = 0; double y0 = 0; @@ -392,7 +392,7 @@ void cairo_renderer_base::process(building_symbolizer const& sym, std::deque::const_iterator end=face_segments.end(); for (; itr != end; ++itr) { - boost::scoped_ptr faces(new geometry_type(Polygon)); + boost::scoped_ptr faces(new geometry_type(geometry_type::types::Polygon)); faces->move_to(itr->get<0>(), itr->get<1>()); faces->line_to(itr->get<2>(), itr->get<3>()); faces->line_to(itr->get<2>(), itr->get<3>() + height); @@ -987,11 +987,11 @@ struct markers_dispatch marker_placement_e placement_method = sym_.get_marker_placement(); if (placement_method != MARKER_LINE_PLACEMENT || - path.type() == Point) + path.type() == geometry_type::types::Point) { double x = 0; double y = 0; - if (path.type() == LineString) + if (path.type() == geometry_type::types::LineString) { if (!label::middle_point(path, x, y)) return; @@ -1076,11 +1076,11 @@ struct markers_dispatch_2 marker_placement_e placement_method = sym_.get_marker_placement(); if (placement_method != MARKER_LINE_PLACEMENT || - path.type() == Point) + path.type() == geometry_type::types::Point) { double x = 0; double y = 0; - if (path.type() == LineString) + if (path.type() == geometry_type::types::LineString) { if (!label::middle_point(path, x, y)) return; @@ -1200,13 +1200,13 @@ void cairo_renderer_base::process(markers_symbolizer const& sym, if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 - //else if (type == LineString) + //else if (type == geometry_type::types::LineString) // converter.template set(); - // don't clip if type==Point + // don't clip if type==geometry_type::types::Point } converter.set(); //always transform if (sym.smooth() > 0.0) converter.set(); // optional smooth converter @@ -1225,13 +1225,13 @@ void cairo_renderer_base::process(markers_symbolizer const& sym, if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 - //else if (type == LineString) + //else if (type == geometry_type::types::LineString) // converter.template set(); - // don't clip if type==Point + // don't clip if type==geometry_type::types::Point } converter.set(); //always transform if (sym.smooth() > 0.0) converter.set(); // optional smooth converter @@ -1255,13 +1255,13 @@ void cairo_renderer_base::process(markers_symbolizer const& sym, if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 - //else if (type == LineString) + //else if (type == geometry_type::types::LineString) // converter.template set(); - // don't clip if type==Point + // don't clip if type==geometry_type::types::Point } converter.set(); //always transform if (sym.smooth() > 0.0) converter.set(); // optional smooth converter diff --git a/src/grid/process_building_symbolizer.cpp b/src/grid/process_building_symbolizer.cpp index 5e089d272..941917fda 100644 --- a/src/grid/process_building_symbolizer.cpp +++ b/src/grid/process_building_symbolizer.cpp @@ -78,8 +78,8 @@ void grid_renderer::process(building_symbolizer const& sym, geometry_type & geom = feature.get_geometry(i); if (geom.size() > 2) { - boost::scoped_ptr frame(new geometry_type(LineString)); - boost::scoped_ptr roof(new geometry_type(Polygon)); + boost::scoped_ptr frame(new geometry_type(geometry_type::types::LineString)); + boost::scoped_ptr roof(new geometry_type(geometry_type::types::Polygon)); std::deque face_segments; double x0(0); double y0(0); @@ -106,7 +106,7 @@ void grid_renderer::process(building_symbolizer const& sym, std::deque::const_iterator itr=face_segments.begin(); for (;itr!=face_segments.end();++itr) { - boost::scoped_ptr faces(new geometry_type(Polygon)); + boost::scoped_ptr faces(new geometry_type(geometry_type::types::Polygon)); faces->move_to(itr->get<0>(),itr->get<1>()); faces->line_to(itr->get<2>(),itr->get<3>()); faces->line_to(itr->get<2>(),itr->get<3>() + height); diff --git a/src/grid/process_markers_symbolizer.cpp b/src/grid/process_markers_symbolizer.cpp index 81180f481..1f274f10c 100644 --- a/src/grid/process_markers_symbolizer.cpp +++ b/src/grid/process_markers_symbolizer.cpp @@ -150,8 +150,8 @@ void grid_renderer::process(markers_symbolizer const& sym, converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_); if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.template set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 //else if (type == LineString) @@ -192,8 +192,8 @@ void grid_renderer::process(markers_symbolizer const& sym, converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_); if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.template set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 //else if (type == LineString) @@ -237,8 +237,8 @@ void grid_renderer::process(markers_symbolizer const& sym, converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_); if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.template set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 //else if (type == LineString) diff --git a/src/json/geometry_grammar.cpp b/src/json/geometry_grammar.cpp index dba2589c4..70172f7c2 100644 --- a/src/json/geometry_grammar.cpp +++ b/src/json/geometry_grammar.cpp @@ -107,16 +107,16 @@ geometry_grammar::geometry_grammar() | (eps(_r2 == 6) > multipolygon_coordinates(_r1)) ; - point_coordinates = eps[ _a = new_(Point) ] + point_coordinates = eps[ _a = new_(geometry_type::types::Point) ] > ( point(SEG_MOVETO,_a) [push_back(_r1,_a)] | eps[cleanup_(_a)][_pass = false] ) ; - linestring_coordinates = eps[ _a = new_(LineString)] + linestring_coordinates = eps[ _a = new_(geometry_type::types::LineString)] > -(points(_a) [push_back(_r1,_a)] | eps[cleanup_(_a)][_pass = false]) ; - polygon_coordinates = eps[ _a = new_(Polygon) ] + polygon_coordinates = eps[ _a = new_(geometry_type::types::Polygon) ] > ((lit('[') > -(points(_a)[close_path_(_a)] % lit(',')) > lit(']')) [push_back(_r1,_a)] diff --git a/src/symbolizer_helpers.cpp b/src/symbolizer_helpers.cpp index 5f1693c44..91abab87d 100644 --- a/src/symbolizer_helpers.cpp +++ b/src/symbolizer_helpers.cpp @@ -219,8 +219,8 @@ void text_symbolizer_helper::initialize_geometries() // don't bother with empty geometries if (geom.size() == 0) continue; - eGeomType type = geom.type(); - if (type == Polygon) + geometry_type::types type = geom.type(); + if (type == geometry_type::types::Polygon) { largest_box_only = sym_.largest_bbox_only(); if (sym_.get_minimum_path_length() > 0) @@ -284,7 +284,7 @@ void text_symbolizer_helper::initialize_points() // https://github.com/mapnik/mapnik/issues/1423 bool success = false; // https://github.com/mapnik/mapnik/issues/1350 - if (geom.type() == LineString) + if (geom.type() == geometry_type::types::LineString) { success = label::middle_point(geom, label_x,label_y); } diff --git a/src/wkb.cpp b/src/wkb.cpp index 838d43de7..caf5aaeec 100644 --- a/src/wkb.cpp +++ b/src/wkb.cpp @@ -250,7 +250,7 @@ private: { double x = read_double(); double y = read_double(); - std::unique_ptr pt(new geometry_type(Point)); + std::unique_ptr pt(new geometry_type(geometry_type::types::Point)); pt->move_to(x, y); paths.push_back(pt.release()); } @@ -269,7 +269,7 @@ private: { double x = read_double(); double y = read_double(); - std::unique_ptr pt(new geometry_type(Point)); + std::unique_ptr pt(new geometry_type(geometry_type::types::Point)); pos_ += 8; // double z = read_double(); pt->move_to(x, y); paths.push_back(pt.release()); @@ -292,7 +292,7 @@ private: { CoordinateArray ar(num_points); read_coords(ar); - std::unique_ptr line(new geometry_type(LineString)); + std::unique_ptr line(new geometry_type(geometry_type::types::LineString)); line->move_to(ar[0].x, ar[0].y); for (int i = 1; i < num_points; ++i) { @@ -319,7 +319,7 @@ private: { CoordinateArray ar(num_points); read_coords_xyz(ar); - std::unique_ptr line(new geometry_type(LineString)); + std::unique_ptr line(new geometry_type(geometry_type::types::LineString)); line->move_to(ar[0].x, ar[0].y); for (int i = 1; i < num_points; ++i) { @@ -345,7 +345,7 @@ private: int num_rings = read_integer(); if (num_rings > 0) { - std::unique_ptr poly(new geometry_type(Polygon)); + std::unique_ptr poly(new geometry_type(geometry_type::types::Polygon)); for (int i = 0; i < num_rings; ++i) { int num_points = read_integer(); @@ -381,7 +381,7 @@ private: int num_rings = read_integer(); if (num_rings > 0) { - std::unique_ptr poly(new geometry_type(Polygon)); + std::unique_ptr poly(new geometry_type(geometry_type::types::Polygon)); for (int i = 0; i < num_rings; ++i) { int num_points = read_integer(); diff --git a/src/wkt/wkt_generator.cpp b/src/wkt/wkt_generator.cpp index 16f81bfe5..5b7e57407 100644 --- a/src/wkt/wkt_generator.cpp +++ b/src/wkt/wkt_generator.cpp @@ -72,20 +72,20 @@ wkt_generator::wkt_generator(bool single) wkt = point | linestring | polygon ; - point = &uint_(mapnik::Point)[_1 = _type(_val)] + point = &uint_(mapnik::geometry_type::types::Point)[_1 = _type(_val)] << string[ phoenix::if_ (single) [_1 = "Point("] .else_[_1 = "("]] << point_coord [_1 = _first(_val)] << lit(')') ; - linestring = &uint_(mapnik::LineString)[_1 = _type(_val)] + linestring = &uint_(mapnik::geometry_type::types::LineString)[_1 = _type(_val)] << string[ phoenix::if_ (single) [_1 = "LineString("] .else_[_1 = "("]] << coords << lit(')') ; - polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)] + polygon = &uint_(mapnik::geometry_type::types::Polygon)[_1 = _type(_val)] << string[ phoenix::if_ (single) [_1 = "Polygon("] .else_[_1 = "("]] << coords2 @@ -126,9 +126,9 @@ wkt_multi_generator::wkt_multi_generator() using boost::spirit::karma::_a; geometry_types.add - (mapnik::Point,"Point") - (mapnik::LineString,"LineString") - (mapnik::Polygon,"Polygon") + (mapnik::geometry_type::types::Point,"Point") + (mapnik::geometry_type::types::LineString,"LineString") + (mapnik::geometry_type::types::Polygon,"Polygon") ; wkt = eps(phoenix::at_c<1>(_a))[_a = _multi_type(_val)] diff --git a/tests/cpp_tests/fontset_runtime_test.cpp b/tests/cpp_tests/fontset_runtime_test.cpp index 4e287296a..14ec2d83a 100644 --- a/tests/cpp_tests/fontset_runtime_test.cpp +++ b/tests/cpp_tests/fontset_runtime_test.cpp @@ -43,7 +43,7 @@ int main(int argc, char** argv) mapnik::transcoder tr("utf-8"); mapnik::value_unicode_string ustr = tr.transcode("hello world!"); feature->put("name",ustr); - mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::Point); + mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::geometry_type::types::Point); pt->move_to(128,128); feature->add_geometry(pt); boost::shared_ptr ds = boost::make_shared(); diff --git a/tests/cpp_tests/geometry_converters_test.cpp b/tests/cpp_tests/geometry_converters_test.cpp index 9e9f59b85..26986259b 100644 --- a/tests/cpp_tests/geometry_converters_test.cpp +++ b/tests/cpp_tests/geometry_converters_test.cpp @@ -23,7 +23,7 @@ struct output_geometry_backend { - output_geometry_backend(boost::ptr_vector & paths, mapnik::eGeomType type) + output_geometry_backend(boost::ptr_vector & paths, mapnik::geometry_type::types type) : paths_(paths), type_(type) {} @@ -42,7 +42,7 @@ struct output_geometry_backend paths_.push_back(geom_ptr.release()); } boost::ptr_vector & paths_; - mapnik::eGeomType type_; + mapnik::geometry_type::types type_; }; boost::optional linestring_bbox_clipping(mapnik::box2d bbox, @@ -56,7 +56,7 @@ boost::optional linestring_bbox_clipping(mapnik::box2d bbox line_symbolizer sym; CoordTransform t(bbox.width(),bbox.height(), bbox); boost::ptr_vector output_paths; - output_geometry_backend backend(output_paths, mapnik::LineString); + output_geometry_backend backend(output_paths, mapnik::geometry_type::types::LineString); typedef boost::mpl::vector conv_types; vertex_converter, output_geometry_backend, line_symbolizer, @@ -96,7 +96,7 @@ boost::optional polygon_bbox_clipping(mapnik::box2d bbox, polygon_symbolizer sym; CoordTransform t(bbox.width(),bbox.height(), bbox); boost::ptr_vector output_paths; - output_geometry_backend backend(output_paths, mapnik::Polygon); + output_geometry_backend backend(output_paths, mapnik::geometry_type::types::Polygon); typedef boost::mpl::vector conv_types; vertex_converter, output_geometry_backend, polygon_symbolizer, diff --git a/tests/cpp_tests/label_algo_test.cpp b/tests/cpp_tests/label_algo_test.cpp index d997d19b9..268f63595 100644 --- a/tests/cpp_tests/label_algo_test.cpp +++ b/tests/cpp_tests/label_algo_test.cpp @@ -19,7 +19,7 @@ int main(int argc, char** argv) double x,y; // single point - mapnik::geometry_type pt(mapnik::Point); + mapnik::geometry_type pt(mapnik::geometry_type::types::Point); pt.move_to(10,10); BOOST_TEST( mapnik::label::centroid(pt, x, y) ); BOOST_TEST( x == 10 ); @@ -32,7 +32,7 @@ int main(int argc, char** argv) BOOST_TEST_EQ( y, 15 ); // line with two verticies - mapnik::geometry_type line(mapnik::LineString); + mapnik::geometry_type line(mapnik::geometry_type::types::LineString); line.move_to(0,0); line.move_to(50,50); BOOST_TEST( mapnik::label::centroid(line, x, y) );