Boost logo

Geometry :

Subject: Re: [geometry] Integrating OGR library with Boost.Geometry
From: Eric MSP Veith (eveith_at_[hidden])
Date: 2015-05-26 08:22:38


Hi Menelaos,

On Tuesday 26 May 2015 15:09:39, Menelaos Karavelas
<menelaos.karavelas_at_[hidden]> wrote:
xample, dereferrencing returns a value rather than a
> reference).
>
> What is your linestring's value type and reference type? In the
> implementation of the segment iterator it is assumed that, when
> dereferrencing an iterator on the points of the linestring, a reference
> (or const reference) is returned. If your linestring iterator returns
> point values then this could indeed be a problem.

My linestring iterator indeed returns "Value" and not "Value &" when
dereferencing. This is the code:

Value dereference() const
{
    assert(m_currentPointIndex < m_collection->getNumPoints());

    OGRPoint point;
    m_collection->getPoint(m_currentPointIndex, &point);
    return point;
}

As you might guess from the invocation, the OGR API only allows "copy-out"
access to the points of a linestring, no reference.

I just checked the header of the OGRPoint class and saw that there's no
OGRPoint(const OGRPoint &p) copy constructor defined. Meh, I guess I have the
culprint now.

What would you advise as the best course of action --- a wrapper class? (I've
solid C++ skills, but am by no means an expert, and therefore grateful for
hints regarding the best solution.)

Thanks
        Eric



Geometry list run by mateusz at loskot.net