2015-12-22 50 views
1

我試圖找到兩個multi_polygon幾何的交集。它不會編譯涉及add_rings.hpp和convert_ring.hpp的錯誤。boost multi_polygon相交不編譯

下面是一些測試代碼,我試圖編譯:

#include "stdafx.h" 

#include <vector> 
#include <sstream> 
#include <iostream> 

#include <boost/geometry.hpp> 
#include <boost/geometry/geometries/point_xy.hpp> 
#include <boost/geometry/geometries/geometries.hpp> 

namespace bg = boost::geometry; 

// Typedef to simplify our point object declaration. 
typedef bg::model::d2::point_xy<double> boostPoint; 

// Typedef to simplify our polygon object declaration. 
typedef bg::model::polygon<boostPoint,true> boostPolygon; 

// Typedef to simplify our polygon object declaration. 
typedef bg::model::multi_polygon<boostPolygon> boostMultiPolygon; 

int _tmain(int argc, _TCHAR* argv[]) 
{ 
    std::string multiPolyOne = "MULTIPOLYGON(((2 2,2 12,12 12,12 2,2 2)),((6 6,6 9,9 9,9 6,6 6)))"; 
    std::string multiPolyTwo = "MULTIPOLYGON(((2 2,2 12,12 12,12 2,2 2)),((3 3,3 13,13 13,13 3,3 3)))"; 
    std::string multiPolyThree = "MULTIPOLYGON(((4 4,4 8,8 8,8 4,4 4),(5 5,6 5,6 6,5 6,5 5)))"; 

    boostMultiPolygon mp1, mp2, mp3; 

    // A deque required by boost. 
    std::deque<boostMultiPolygon> output; 

    // boost method we will be using. 
    using bg::read_wkt; 

    read_wkt(multiPolyOne,mp1); 
    read_wkt(multiPolyTwo,mp2); 
    read_wkt(multiPolyThree,mp3); 

    // Run the boost intersection. 
    bg::intersection(mp1, mp2, output); 

    return 0; 
} 

這將產生以下錯誤:

c:\sourcecode\commoncomponents\boost\boost_1_59_0\boost\geometry\algorithms\detail\overlay\convert_ring.hpp(41): error C2664: 'boost::mpl::assertion_failed' : cannot convert parameter 1 from 'boost::mpl::failed ************(__thiscall boost::geometry::detail::overlay::convert_ring<Tag>::NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TAG::* ***********)(boost::mpl::assert_::types<T )' to 'boost::mpl::assert<false>::type' 
      with 
      [ 
       Tag=tag_out, 
       T1=tag_out 
      ] 
      No constructor could take the source type, or constructor overload resolution was ambiguous 
      c:\sourcecode\commoncomponents\boost\boost_1_59_0\boost\geometry\algorithms\detail\overlay\add_rings.hpp(47) : see reference to class template instantiation 'boost::geometry::detail::overlay::convert_ring<Tag>' being compiled 
      with 
      [ 
       Tag=tag_out 
      ] 
      c:\sourcecode\commoncomponents\boost\boost_1_59_0\boost\geometry\algorithms\detail\overlay\add_rings.hpp(105) : see reference to function template instantiation 'void boost::geometry::detail::overlay::convert_and_add<GeometryOut,Geometry1,Geometry2,RingCollection>(GeometryOut &,const Geometry1 &,const Geometry2 &,const RingCollection &,boost::geometry::ring_identifier,bool,bool)' being compiled 
      with 
      [ 
       GeometryOut=OneOut, 
       Geometry1=boostMultiPolygon, 
       Geometry2=boostMultiPolygon, 
       RingCollection=ring_container_type 
      ] 
      c:\sourcecode\commoncomponents\boost\boost_1_59_0\boost\geometry\algorithms\detail\overlay\overlay.hpp(268) : see reference to function template instantiation 'OutputIterator boost::geometry::detail::overlay::add_rings<GeometryOut,std::map<_Kty,_Ty>,Geometry1,Geometry2,ring_container_type,OutputIterator>(const SelectionMap &,const Geometry1 &,const Geometry2 &,const RingCollection &,OutputIterator)' being compiled 
      with 
      [ 
       OutputIterator=std::back_insert_iterator<std::deque<boostMultiPolygon>>, 
       GeometryOut=OneOut, 
       _Kty=boost::geometry::ring_identifier, 
       _Ty=properties, 
       Geometry1=boostMultiPolygon, 
       Geometry2=boostMultiPolygon, 
       SelectionMap=std::map<boost::geometry::ring_identifier,properties>, 
       RingCollection=ring_container_type 
      ] 
      c:\sourcecode\commoncomponents\boost\boost_1_59_0\boost\geometry\algorithms\detail\intersection\interface.hpp(57) : see reference to function template instantiation 'OutputIterator boost::geometry::detail::overlay::overlay<Geometry1,Geometry2,Reverse1,Reverse2,ReverseOut,GeometryOut,Direction>::apply<RobustPolicy,std::back_insert_iterator<_Container>,Strategy>(const Geometry1 &,const Geometry2 &,const RobustPolicy &,OutputIterator,const Strategy &)' being compiled 
      with 
      [ 
       OutputIterator=std::back_insert_iterator<std::deque<boostMultiPolygon>>, 
       Geometry1=boostMultiPolygon, 
       Geometry2=boostMultiPolygon, 
       Reverse1=false, 
       Reverse2=false, 
       ReverseOut=false, 
       GeometryOut=OneOut, 
       Direction=overlay_intersection, 
       RobustPolicy=rescale_policy_type, 
       _Container=std::deque<boostMultiPolygon>, 
       Strategy=boost::geometry::strategy_intersection<boost::geometry::cartesian_tag,boostMultiPolygon,boostMultiPolygon,boost::geometry::model::d2::point_xy<double>,rescale_policy_type> 
      ] 
      c:\sourcecode\commoncomponents\boost\boost_1_59_0\boost\geometry\algorithms\detail\intersection\interface.hpp(139) : see reference to function template instantiation 'bool boost::geometry::dispatch::intersection<Geometry1,Geometry2>::apply<rescale_policy_type,GeometryOut,boost::geometry::strategy_intersection<Tag,Geometry1,Geometry2,IntersectionPoint,RobustPolicy>>(const Geometry1 &,const Geometry2 &,const RobustPolicy &,GeometryOut &,const Strategy &)' being compiled 
      with 
      [ 
       Geometry1=boostMultiPolygon, 
       Geometry2=boostMultiPolygon, 
       GeometryOut=std::deque<boostMultiPolygon>, 
       Tag=boost::geometry::cartesian_tag, 
       IntersectionPoint=boost::geometry::model::d2::point_xy<double>, 
       RobustPolicy=rescale_policy_type, 
       Strategy=boost::geometry::strategy_intersection<boost::geometry::cartesian_tag,boostMultiPolygon,boostMultiPolygon,boost::geometry::model::d2::point_xy<double>,rescale_policy_type> 
      ] 
      c:\sourcecode\commoncomponents\boost\boost_1_59_0\boost\geometry\algorithms\detail\intersection\interface.hpp(300) : see reference to function template instantiation 'bool boost::geometry::resolve_variant::intersection<Geometry1,Geometry2>::apply<GeometryOut>(const Geometry1 &,const Geometry2 &,GeometryOut &)' being compiled 
      with 
      [ 
       Geometry1=boostMultiPolygon, 
       Geometry2=boostMultiPolygon, 
       GeometryOut=std::deque<boostMultiPolygon> 
      ] 
      c:\boost_test\test1\runtest2\runtest2.cpp(65) : see reference to function template instantiation 'bool boost::geometry::intersection<boostMultiPolygon,boostMultiPolygon,std::deque<_Ty>>(const Geometry1 &,const Geometry2 &,GeometryOut &)' being compiled 
      with 
      [ 
       _Ty=boostMultiPolygon, 
       Geometry1=boostMultiPolygon, 
       Geometry2=boostMultiPolygon, 
       GeometryOut=std::deque<boostMultiPolygon> 
      ] 
c:\sourcecode\commoncomponents\boost\boost_1_59_0\boost\geometry\algorithms\detail\overlay\convert_ring.hpp(41): error C2866: 'boost::geometry::detail::overlay::convert_ring<Tag>::mpl_assertion_in_line_80' : a const static data member of a managed type must be initialized at the point of declaration 
      with 
      [ 
       Tag=tag_out 
      ] 
c:\sourcecode\commoncomponents\boost\boost_1_59_0\boost\geometry\algorithms\detail\overlay\add_rings.hpp(47): error C2039: 'apply' : is not a member of 'boost::geometry::detail::overlay::convert_ring<Tag>' 
      with 
      [ 
       Tag=tag_out 
      ] 
c:\sourcecode\commoncomponents\boost\boost_1_59_0\boost\geometry\algorithms\detail\overlay\add_rings.hpp(47): error C3861: 'apply': identifier not found 
c:\sourcecode\commoncomponents\boost\boost_1_59_0\boost\geometry\algorithms\detail\overlay\add_rings.hpp(53): error C2039: 'apply' : is not a member of 'boost::geometry::detail::overlay::convert_ring<Tag>' 
      with 
      [ 
       Tag=tag_out 
      ] 
c:\sourcecode\commoncomponents\boost\boost_1_59_0\boost\geometry\algorithms\detail\overlay\add_rings.hpp(53): error C3861: 'apply': identifier not found 
c:\sourcecode\commoncomponents\boost\boost_1_59_0\boost\geometry\algorithms\detail\overlay\add_rings.hpp(59): error C2039: 'apply' : is not a member of 'boost::geometry::detail::overlay::convert_ring<Tag>' 
      with 
      [ 
       Tag=tag_out 
      ] 
c:\sourcecode\commoncomponents\boost\boost_1_59_0\boost\geometry\algorithms\detail\overlay\add_rings.hpp(59): error C3861: 'apply': identifier not found 
+0

我一無所知庫,但也許[這](http://coliru.stacked-crooked.com/a/fc8562b76d6319ed)可以幫助,直到出現真正的答案。 – llonesmiz

+0

非常感謝。這是一個很大的幫助。 –

回答

1

您的評論被誤導:

// A deque required by boost. 

這不是:

幾何形狀的集合(例如std::vectorstd::dequeboost::geometry::multi*),它的value_type滿足一個PointLineStringPolygon concept,或者是輸出的幾何形狀(如一個盒子)

boostMultiPolygon output; 

修復它

+0

謝謝。那樣做了。我正在增強一個我在網上找到的用於POLYGON處理的代碼片段,看起來這個代碼是必需的。 –