Thursday, 15 March 2012

c++ - Boost intersection -


I have a problem with the promotion algorithm. I'm not sure whether I got an error or it's a bug.

  #include & lt; Boost / geometry / algorithm / intersection. HP & gt; # Include & lt; Boost / version.hpp & gt; #include & lt; Boost / geometry.hpp & gt; #include & lt; Boost / geometry / geometries / point_xy.hpp & gt; #include & lt; Boost / geometry / geometries / ring.hpp & gt; #include & lt; Boost / geometry / geometries / polygon.hpp & gt; Int main () {typedef boost :: geometry :: model :: d2 :: point_xy & lt; Double & gt; BoostPointXY; Typedef Promotion :: Geometry :: Model :: Polygon & lt; BoostPointXY & gt; BoostPolygon; BoostPolygon polyOne, PolyTu; Promotion :: Geometry :: read_wkt ("Polygon (45, 4), (45, 17), (44, 19), (44, 22), (50, 20), (51.5, 17), (58, 4), (60, 0), (53, 0), (45, 0), (45, 4)), "polyon"; Promotion :: Geometry :: read_wkt ("Polygon ((-10, -5), (0, 25), (43, 25), (45, 20), (50, 20), (60, 0), ( 5, 0), (5, -5), (-10, -5)), "Polyteuo"; Std :: vector & lt; BoostPolygon & gt; MultiPoly; Promote: Geometry :: Correct (PolyOne); Promote: Geometry :: Correct (polyTwo); Promote: Geometry :: intersection (PolyOne, polyTwo, multiPoly); Std :: cout & lt; & Lt; "Multi-size" & lt; & Lt; Multipol Size () & lt; & Lt; Std :: endl; Std :: cout & lt; & Lt; "Boost use" & lt; & Lt; BOOST_VERSION / 100000 & lt; & Lt; "." // major version & lt; & Lt; BOOST_VERSION / 100% 1000 & lt; & Lt; "." // short version & lt; & Lt; BOOST_VERSION% 100 // patch level & lt; & Lt; Std :: endl; }  

Output:

  Size of multi-boost boost 1.55.0  

But multiplex size should be 1 Or? When this is a bug, can anyone test with an existing 1.57 boost? I can not currently change my promotion version

thanks

Your WKT data Is invalid:

  Boost :: Geometry :: read_wkt ("Polygon (45 45, 45, 17, 44, 19, 44, 22, 50, 20, 51.5, 17, 58 4, 60 0, 53 0, 45 0, 45 4)) ", polyon); Promotion :: Geometry :: read_wkt ("Polygon (" -10 - 5, 25, 43, 25, 45, 20, 50, 20, 60 0, 5, 5 - 5, -10 - 5)) ", Polyteuo);  

Your sample has used many invalid (?) Internal rings.

You now get:

  Size of multi 1  

  #include & lt; Boost / geometry.hpp & gt; # Include & lt; Boost / geometry / algorithms / intersection HP & gt; #include & lt; Boost / geometry / geometries / point_xy.hpp & gt; #include & lt; Boost / geometry / geometries / polygon.hpp & gt; #include & lt; Boost / geometry / geometries / ring.hpp & gt; #include & lt; Boost / geometry / io / io.hpp & gt; # Include & lt; Fstream & gt; # Include & lt; Iostream & gt; Int main () {typedef boost :: geometry :: model :: d2 :: point_xy & lt; Double & gt; BoostPointXY; Typedef Promotion :: Geometry :: Model :: Polygon & lt; BoostPointXY & gt; BoostPolygon; BoostPolygon polyOne, PolyTu; Promotion :: Geometry :: read_wkt ("Polygon (45 45, 45, 17, 44, 19, 44 22, 50 20, 51.5 17, 58 4, 60 0, 53 0, 45 0, 45 4))", polyon ; Promotion :: Geometry :: read_wkt ("Polygon (Polyvuo) (" Polygon (Polygrave (-10 - 5, 25, 43, 25, 45, 20, 50, 20, 60, 5, 5, 5, -10-5)); Promote: Geometry :: Correct (PolyOne); Promote: Geometry :: Correct (polyTwo); {Std :: ofstream svg ("/ tmp / svg.svg"); Promote: Geometry :: svg_mapper & lt; BoostPointXY & gt; Mapper (SVG, 400, 400); Mapper.add (PolyOne); Mapper.add (polyTwo); Mapper.map (polyone, "fill-opacity: 0.5; Fill: RGB (153204,0); stroke: RGB (153204,0; stroke-width: 2"); Mapper.map (polytoobo, "fill-opacity: 0.5; fill: RGB (204153,0) stroke: RGB (204153,0; stroke-width: 2"); } Std :: vector & lt; BoostPolygon & gt; MultiPoly; Promote: Geometry :: intersection (PolyOne, polyTwo, multiPoly); Std :: cout & lt; & Lt; "Multi-size" & lt; & Lt; Multipol Size () & lt; & Lt; Std :: endl; }  

No comments:

Post a Comment