Subject: [Boost-bugs] [Boost C++ Libraries] #11346: Segment iterator does not work with ranges returning values instead of references
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-05-26 17:00:32
#11346: Segment iterator does not work with ranges returning values instead of
references
------------------------------+---------------------------
Reporter: eveith@⦠| Owner: barendgehrels
Type: Bugs | Status: new
Milestone: To Be Determined | Component: geometry
Version: Boost 1.57.0 | Severity: Problem
Keywords: |
------------------------------+---------------------------
The Boost.Geometry segment iterator does not work with ranges/custom
iterators that return a value instead of a reference when dereferenced.
The problem surfaced with the adaption of GDAL/OGR's geometry classes to
Boost.Geometry. All OGRSimpleCurve descendants (e.g., OGRLineString) have
only "copy-out" access to their points:
{{{
int getNumPoints() const { return nPointCount; }
void getPoint( int, OGRPoint * ) const;
double getX( int i ) const { return paoPoints[i].x; }
double getY( int i ) const { return paoPoints[i].y; }
double getZ( int i ) const;
}}}
The defeats the notion of a iterator de-reference operation that returns a
reference to the OGRPoint underlying a given OGRLineString. Thus, the
`iterator_facade`-implementing iterator adapter returns a value and not a
reference.
However, the attached test-case provided by Menelaos Karavelas fails to
properly iterate segments of a given linestring and produces the following
output:
{{{
geometry: LINESTRING(1 1,2 2,3 3,4 4,9 9)
points: (1, 1) (2, 2) (3, 3) (4, 4) (9, 9)
segments: ((2.0872e-317, 6.95257e-310), (6.91222e-310, 6.91222e-310))
((2.0872e-317, 6.95257e-310), (6.91222e-310, 6.91222e-310)) ((2.0872e-317,
6.95257e-310), (6.91222e-310, 6.91222e-310)) ((2.0872e-317, 6.95257e-310),
(6.91222e-310, 6.91222e-310))
}}}
The full iterator/adaptor code is located at https://github.com/eveith
/ogr-boost-adapter.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/11346> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:18 UTC