Boost logo

Boost Users :

Subject: Re: [Boost-users] [Geometry] please help; using buffer() extensions
From: John Lilley (john.lilley_at_[hidden])
Date: 2013-02-27 18:18:31


On 27-2-2013 22:13, John Lilley wrote:
>>Thanks Barend!  I think I am almost there, but there is a kink that I am trying to work out.  If I have coordinates expressed in degrees longitude/latitude, can I operate directly on those coordinates without first transforming >>them to a "flat" projection like UTM?  It is easy enough to get meters/degree latitude, but longitudinal distortion is another matter.  Does the distance_strategy have anything to do with this?  I can accept a first-order >>model that assumes meters/degree-longitude is constant over the entire shape.

>Hi John, list,
>As promised today, below the example. W.r.t. coordinates, the buffer operation uses intersections etc internally, and they are not yet ported to latlong. So you might use it but you will indeed get distortions then. So yes, the >best is to transform first to a cartesian system... The distance_strategy cannot fix this.

Thanks, I think that I can deal with the flattening projections.

However, I am having compiler trouble with linestring and multi_linestring:

// definitions
namespace BGNS = boost::geometry;
namespace BGBUFNS = BGNS::strategy::buffer;
typedef BGNS::model::d2::point_xy<double> BoostPoint;
typedef BGNS::model::multi_point<BoostPoint> BoostMultiPoint;
typedef BGNS::model::polygon<BoostPoint> BoostPolygon;
typedef BGNS::model::linestring<BoostPoint> BoostPolyline;
typedef BGNS::model::multi_polygon<BoostPolygon> BoostMultiPolygon;
typedef BGNS::model::multi_linestring<BoostPolyline> BoostMultiPolyline;
typedef BGBUFNS::join_miter<BoostPoint, BoostPoint> BoostMiterJoinStrategy;
typedef BGBUFNS::join_round<BoostPoint, BoostPoint> BoostRoundJoinStrategy;
typedef BGBUFNS::distance_assymetric<double> BoostDistanceStrategyType;

// polyline:
BoostPolyline bpl;
std::vector<BoostPolygon> boostPolysOut;
BoostDistanceStrategyType ds(amount,amount);
BoostMiterJoinStrategy js;
*** error line *** BGNS::buffer_inserter<BoostPolygon>(bpl, std::back_inserter(boostPolysOut), ds, js);

1>------ Build started: Project: etl6_EngCore, Configuration: Debug x64 ------
1> DL_GeometryBasics.cpp
1>F:\DataManagement\RPDM\Server\libraries\boost\boost/geometry/extensions/algorithms/buffer/buffered_piece_collection.hpp(1124): warning C4267: 'initializing' : conversion from 'size_t' to 'const int', possible loss of data
1> F:\DataManagement\RPDM\Server\libraries\boost\boost/geometry/extensions/algorithms/buffer/buffered_piece_collection.hpp(1123) : while compiling class template member function 'void boost::geometry::detail::buffer::buffered_piece_collection<Ring>::start_new_ring(void)'
1> with
1> [
1> Ring=boost::geometry::model::ring<Acme::BoostPoint,true,true,std::vector,std::allocator>
1> ]
1> F:\DataManagement\RPDM\Server\libraries\boost\boost/geometry/extensions/algorithms/buffer/buffer_inserter.hpp(357) : see reference to class template instantiation 'boost::geometry::detail::buffer::buffered_piece_collection<Ring>' being compiled
1> with
1> [
1> Ring=boost::geometry::model::ring<Acme::BoostPoint,true,true,std::vector,std::allocator>
1> ]
1> DL_GeometryBasics.cpp(2218) : see reference to function template instantiation 'void boost::geometry::buffer_inserter<Acme::BoostPolygon,Acme::BoostPolyline,std::back_insert_iterator<_Container>,Acme::BoostDistanceStrategyType,Acme::BoostMiterJoinStrategy>(const GeometryInput &,OutputIterator,const DistanceStrategy &,const JoinStrategy &)' being compiled
1> with
1> [
1> _Container=std::vector<Acme::BoostPolygon>,
1> GeometryInput=Acme::BoostPolyline,
1> OutputIterator=std::back_insert_iterator<std::vector<Acme::BoostPolygon>>,
1> DistanceStrategy=Acme::BoostDistanceStrategyType,
1> JoinStrategy=Acme::BoostMiterJoinStrategy
1> ]
1>F:\DataManagement\RPDM\Server\libraries\boost\boost/geometry/extensions/algorithms/buffer/buffered_piece_collection.hpp(589): warning C4267: 'return' : conversion from 'size_t' to 'int', possible loss of data
1> F:\DataManagement\RPDM\Server\libraries\boost\boost/geometry/extensions/algorithms/buffer/buffered_piece_collection.hpp(579) : while compiling class template member function 'int boost::geometry::detail::buffer::buffered_piece_collection<Ring>::piece_count(const boost::geometry::detail::buffer::buffered_piece_collection<Ring>::buffer_occupation_info &)'
1> with
1> [
1> Ring=boost::geometry::model::ring<Acme::BoostPoint,true,true,std::vector,std::allocator>
1> ]
1>F:\DataManagement\RPDM\Server\libraries\boost\boost/geometry/extensions/algorithms/buffer/buffered_piece_collection.hpp(1142): warning C4267: 'return' : conversion from 'size_t' to 'int', possible loss of data
1> F:\DataManagement\RPDM\Server\libraries\boost\boost/geometry/extensions/algorithms/buffer/buffered_piece_collection.hpp(1134) : while compiling class template member function 'int boost::geometry::detail::buffer::buffered_piece_collection<Ring>::add_point(const boost::geometry::model::d2::point_xy<CoordinateType> &)'
1> with
1> [
1> Ring=boost::geometry::model::ring<Acme::BoostPoint,true,true,std::vector,std::allocator>,
1> CoordinateType=double
1> ]
1>F:\DataManagement\RPDM\Server\libraries\boost\boost/geometry/extensions/algorithms/buffer/buffered_piece_collection.hpp(1153): warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
1> F:\DataManagement\RPDM\Server\libraries\boost\boost/geometry/extensions/algorithms/buffer/buffered_piece_collection.hpp(1146) : while compiling class template member function 'boost::geometry::detail::buffer::buffered_piece_collection<Ring>::piece &boost::geometry::detail::buffer::buffered_piece_collection<Ring>::add_piece(boost::geometry::detail::buffer::piece_type,bool)'
1> with
1> [
1> Ring=boost::geometry::model::ring<Acme::BoostPoint,true,true,std::vector,std::allocator>
1> ]
1>F:\DataManagement\RPDM\Server\libraries\boost\boost/geometry/extensions/algorithms/buffer/buffered_piece_collection.hpp(1189): warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
1> F:\DataManagement\RPDM\Server\libraries\boost\boost/geometry/extensions/algorithms/buffer/buffer_inserter.hpp(192) : see reference to function template instantiation 'boost::geometry::detail::buffer::buffered_piece_collection<Ring>::piece &boost::geometry::detail::buffer::buffered_piece_collection<Ring>::add_piece<std::vector<_Ty>>(boost::geometry::detail::buffer::piece_type,const Range &)' being compiled
1> with
1> [
1> Ring=boost::geometry::model::ring<Acme::BoostPoint,true,true,std::vector,std::allocator>,
1> _Ty=Acme::BoostPoint,
1> Range=std::vector<Acme::BoostPoint>
1> ]
1> F:\DataManagement\RPDM\Server\libraries\boost\boost/geometry/extensions/algorithms/buffer/buffer_inserter.hpp(280) : see reference to function template instantiation 'void boost::geometry::detail::buffer::buffer_range<RingOutput,Tag>::iterate<Collection,std::_Vector_const_iterator<_Myvec>,DistanceStrategy,JoinStrategy>(Collection &,Iterator,Iterator,boost::geometry::buffer_side_selector,const DistanceStrategy &,const JoinStrategy &,bool)' being compiled
1> with
1> [
1> RingOutput=boost::geometry::model::ring<Acme::BoostPoint,true,true,std::vector,std::allocator>,
1> Tag=boost::geometry::linestring_tag,
1> Collection=boost::geometry::detail::buffer::buffered_piece_collection<boost::geometry::model::ring<Acme::BoostPoint,true,true,std::vector,std::allocator>>,
1> _Myvec=std::_Vector_val<Acme::BoostPoint,std::allocator<Acme::BoostPoint>>,
1> DistanceStrategy=Acme::BoostDistanceStrategyType,
1> JoinStrategy=Acme::BoostMiterJoinStrategy,
1> Iterator=std::_Vector_const_iterator<std::_Vector_val<Acme::BoostPoint,std::allocator<Acme::BoostPoint>>>
1> ]
1> F:\DataManagement\RPDM\Server\libraries\boost\boost/geometry/extensions/algorithms/buffer/buffer_inserter.hpp(364) : see reference to function template instantiation 'void boost::geometry::dispatch::buffer_inserter<Tag,RingInput,RingOutput>::apply<boost::geometry::detail::buffer::buffered_piece_collection<Ring>,DistanceStrategy,JoinStrategy>(const Linestring &,Collection &,const DistanceStrategy &,const JoinStrategy &)' being compiled
1> with
1> [
1> Tag=boost::geometry::linestring_tag,
1> RingInput=Acme::BoostPolyline,
1> RingOutput=Acme::BoostPolygon,
1> Ring=boost::geometry::model::ring<Acme::BoostPoint,true,true,std::vector,std::allocator>,
1> DistanceStrategy=Acme::BoostDistanceStrategyType,
1> JoinStrategy=Acme::BoostMiterJoinStrategy,
1> Linestring=Acme::BoostPolyline,
1> Collection=boost::geometry::detail::buffer::buffered_piece_collection<boost::geometry::model::ring<Acme::BoostPoint,true,true,std::vector,std::allocator>>
1> ]
1>f:\datamanagement\rpdm\server\engine\dl_eng_core\dl_geometrybasics.cpp(2267): error C4716: 'Acme::ShapeOperator::InflateRound_' : must return a value
1>f:\datamanagement\rpdm\server\engine\dl_eng_core\dl_geometrybasics.cpp(2270): error C4716: 'Acme::ShapeOperator::InflateRound_' : must return a value
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

// multi_polyline:
BoostMultiPolyline boostLines;
std::vector<BoostPolygon> boostPolysOut;
BoostDistanceStrategyType ds(amount,amount);
BoostMiterJoinStrategy js;
*** error line *** BGNS::buffer_inserter<BoostPolygon>(boostLines, std::back_inserter(boostPolysOut), ds, js);

// Compiler output on MSVC++ 2010:
1>------ Build started: Project: etl6_EngCore, Configuration: Debug x64 ------
1> DL_GeometryBasics.cpp
1>F:\DataManagement\RPDM\Server\libraries\boost\boost/geometry/extensions/algorithms/buffer/buffer_inserter.hpp(364): error C2039: 'apply' : is not a member of 'boost::geometry::dispatch::buffer_inserter<Tag,RingInput,RingOutput>'
1> with
1> [
1> Tag=boost::geometry::multi_linestring_tag,
1> RingInput=Acme::BoostMultiPolyline,
1> RingOutput=Acme::BoostPolygon
1> ]
1> DL_GeometryBasics.cpp(2218) : see reference to function template instantiation 'void boost::geometry::buffer_inserter<Acme::BoostPolygon,Acme::BoostMultiPolyline,std::back_insert_iterator<_Container>,Acme::BoostDistanceStrategyType,Acme::BoostMiterJoinStrategy>(const GeometryInput &,OutputIterator,const DistanceStrategy &,const JoinStrategy &)' being compiled
1> with
1> [
1> _Container=std::vector<Acme::BoostPolygon>,
1> GeometryInput=Acme::BoostMultiPolyline,
1> OutputIterator=std::back_insert_iterator<std::vector<Acme::BoostPolygon>>,
1> DistanceStrategy=Acme::BoostDistanceStrategyType,
1> JoinStrategy=Acme::BoostMiterJoinStrategy
1> ]
1>F:\DataManagement\RPDM\Server\libraries\boost\boost/geometry/extensions/algorithms/buffer/buffer_inserter.hpp(364): error C3861: 'apply': identifier not found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net