
Geometry : 
Subject: Re: [geometry] [Boostusers] please help; using buffer() extensions
From: Barend Gehrels (barend_at_[hidden])
Date: 20130227 16:45:11
On 2722013 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 firstorder model that
> assumes meters/degreelongitude 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.
A few changes has been committed today so please update if necessary.
I mentioned that negative buffers (for deflate) are possible  that is
currently not running, I will come back to this.
But it is possible to use assymetric buffers (on linestrings). As
joinstrategies you can use "join_round" (like below) and "join_miter"
(with sharp corners).
Regards, Barend
// Complete example, using Boost.Geometry extension for buffer (not yet
released), buffering a polygon:
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/multi/geometries/multi_polygon.hpp>
#include <boost/geometry/extensions/algorithms/buffer/buffer_inserter.hpp>
#include <boost/geometry/extensions/strategies/buffer.hpp>
int main()
{
typedef boost::geometry::model::d2::point_xy<double> point_type;
typedef boost::geometry::model::polygon<point_type> polygon;
// Polygon
{
polygon my_polygon;
boost::geometry::read_wkt("POLYGON ((0 0,0 5,4 5,4 4,3 3,2 4,2
1,3 2,4 1,4 0,0 0))", my_polygon);
boost::geometry::model::multi_polygon<polygon> my_output;
boost::geometry::buffer_inserter<polygon>
(
my_polygon,
std::back_inserter(my_output),
boost::geometry::strategy::buffer::distance_assymetric<double>(0.4, 0.4),
boost::geometry::strategy::buffer::join_round<point_type, point_type>()
);
std::cout << "Input polygon, area: " <<
boost::geometry::area(my_polygon) << std::endl;
std::cout << "Output, area: " <<
boost::geometry::area(my_output) << std::endl;
}
return 0;
}
The input / output (if converted to SVG) looks as below (green input,
orange output):
Geometry list run by mateusz at loskot.net