Boost logo

Geometry :

Subject: [geometry] Douglas Peucker on 3D lines
From: Stephan Menzel (stephan.menzel_at_[hidden])
Date: 2012-06-20 04:02:02

Hi there,

I am currently using 1.49 geometry and I am generally impressed at the
neat design and ease of use. I do however have a few questions
concerning simplify that I would like to discuss.

My use case is a 3D LineString for an application that not
surprisingly represents a road definition. A very detailed though. I
need it down to the centimeters. Here's my types:

typedef boost::geometry::model::point<double, 3,
boost::geometry::cs::cartesian> Point;
typedef boost::geometry::model::segment<Point>
typedef boost::geometry::model::linestring<Point>

Now I import a line string from a different source that gives me a
large number of vertices, and I create points from them. However,
since many of the point are doubles and I want the line not so
detailed I like to run douglas peucker on it, but not agressive.

So I do this:

LineString raw = import();
LineString ret; // to be returned as result

typedef boost::geometry::strategy::distance::projected_point<Point>
typedef boost::geometry::strategy::simplify::douglas_peucker<Point,
PointSegmentDistanceStrategy> SimplificationStrategy;
SimplificationStrategy strat;
boost::geometry::simplify<LineString, double,
SimplificationStrategy>(raw, ret, 1.0, strat);

Now the first question is, the way I understand the docs, I shouldn't
have to specify a Strategy. But with the default strategy I get a
static assertion error telling me this is not supported for my point
type. Why?

Second question:
I have tried several PointSegmentDistanceStartegies, this was the only
one that compiled. The others threw plenty of errors at me as soon as
I got their headers included (MSVC2008). Are they different in what
they do or only in complexity and cost? In other words: Can I just use
that one that did compile or is in in some way worse than the others?

Third, and most important: What exactly does the max_distance
parameter mean? I was under the impression that this is the maximum
distance a point can be apart from another to be considerered for
deletion. Which would mean, as I understand it, that if I say 1.0
here, I will get points not further apart than 1millimeter (which
would be my unit here). Tests however show that I get a smooth line
with most segments roughly 1meter(!) length. Which makes the curve
appear quite rough at hills and sharp turns. So am I interpreting this
wrong? Can you help me understand this?

Last I would like to comment that the docs are wrong about simplify().
They state that the strategy parameter is first, while if fact it is
the last. So maybe that could be corrected.

Cheers and thanks in advance for hints to help me understand this...


Geometry list run by mateusz at