$include_dir="/home/hyper-archives/geometry/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [geometry] Integrating OGR library with Boost.Geometry
From: Menelaos Karavelas (menelaos.karavelas_at_[hidden])
Date: 2015-05-22 01:42:58
Hello Eric.
On 21/05/2015 06:35 μμ, Eric MSP Veith wrote:
> Hello list,
>
> earlier this year I adapted the OGRGeometry subclasses to the boost.Geometry
> models. My adapter code is available at <https://github.com/eveith/ogr-boost-adapter>.
>
> Everything was done on the basis of boost 1.56.0, where tests ran
> successfully. I've now upgraded my Linux distribution, which also pulled boost
> 1.57.0. I recompiled everything, but much to my surprise, my adapter code
> stopped working!
>
> At first I thought the iterator code somehow had a bug lurking in it that
> caused the failure, but I can successfully retrieve all points on an
> OGRLineString without problems.
I cannot really tell what the problem is but there is one thing that I 
think needs investigation:
Please make sure that you have correctly defined the specializations 
required by Boost.Range. It seems that you are missing the 
range_mutable_iterator specialization. See 
http://www.boost.org/doc/libs/1_58_0/libs/range/doc/html/range/reference/extending.html 
for the details.
I do not know is this the root cause of your problem, but it seems to be 
that you need to have this specialization anyway.
Another thing: would it be possible to also try with boost 1.58? It 
would be helpful to know if the problem persists there.
> However, bg::distance() between two OGRLineStrings returns 0 instead of the
> proper result. Is anybody aware of a change in bg::distance or Boost.Range
> that might cause the failure? After having checked that the iterator works
> forwards and backwards, I'm unsure where to begin with the debugging.
>
> Here's the test code that I use. bg::distance(OGRLineString &, OGRLineString
> &) always returns 0.0:
>
> ---%<---
> void BoostOGRLineStringAdapterTest::testGeometryMultiLineString()
> {
>      typedef bg::model::linestring<OGRPoint> boostLinestring;
>      boostLinestring bls1, bls2;
>
>      OGRLineString *ls1 = new OGRLineString(),
>              *ls2 = new OGRLineString(),
>              *ls3 = new OGRLineString();
>      auto distantPoint = new OGRPoint(15.0, 15.0);
>      OGRSpatialReference *sref = new OGRSpatialReference();
>
>      OGRErr rc = sref->importFromEPSG(4326);
>      QVERIFY(OGRERR_NONE == rc);
>      ls1->assignSpatialReference(sref);
>      ls2->assignSpatialReference(sref);
>      ls3->assignSpatialReference(sref);
>      distantPoint->assignSpatialReference(sref);
>
>      ls1->addPoint(0.0, 0.0);
>      ls1->addPoint(1.0, 1.0);
>      ls1->addPoint(2.0, 2.0);
>      ls1->addPoint(3.0, 3.0);
>      ls1->addPoint(4.0, 4.0);
>
>      bls1.push_back(OGRPoint(0.0, 0.0));
>      bls1.push_back(OGRPoint(1.0, 1.0));
>      bls1.push_back(OGRPoint(2.0, 2.0));
>      bls1.push_back(OGRPoint(3.0, 3.0));
>      bls1.push_back(OGRPoint(4.0, 4.0));
>
>      ls2->addPoint(17.0, 17.0);
>      ls2->addPoint(21.0, 21.0);
>      ls2->addPoint(33.0, 33.0);
>      ls2->addPoint(76.0, 56.0);
>
>      bls2.push_back(OGRPoint(17.0, 17.0));
>      bls2.push_back(OGRPoint(21.0, 21.0));
>      bls2.push_back(OGRPoint(33.0, 33.0));
>      bls2.push_back(OGRPoint(76.0, 56.0));
>
>      ls3->addPoint(42.0, 34.2);
>      ls3->addPoint(72.0, 14.2);
>      ls3->addPoint(67.0, 34.2);
>      ls3->addPoint(82.0,  2.2);
>      ls3->addPoint(5.0, 17.2);
>
>      QCOMPARE(
>              bg::crosses(*ls1, *distantPoint),
>              ls1->Crosses(distantPoint));
>      QCOMPARE(
>              bg::intersects(*ls1, *distantPoint),
>              ls1->Intersects(distantPoint));
>
>
>      for (int i = 0; i != ls1->getNumPoints(); ++i) {
>          auto p = new OGRPoint();
>          ls1->getPoint(i, p);
>
>          QCOMPARE(
>                  bg::distance(*p, *distantPoint),
>                  p->Distance(distantPoint));
>      }
>
>      QCOMPARE(
>              bg::distance(*ls1, *distantPoint),
>              ls1->Distance(distantPoint));
>      QCOMPARE(
>              bg::distance(*ls3, *distantPoint),
>              ls3->Distance(distantPoint));
>      QCOMPARE(
>              bg::distance(*ls2, *distantPoint),
>              ls2->Distance(distantPoint));
>      QCOMPARE(
>              bg::distance(bls1, bls2),
>              ls1->Distance(ls2));
>      QCOMPARE(
>              bg::distance(bls1, bls2),
>              bg::distance(*ls1, *ls2));
>      QCOMPARE(
>              bg::distance(*ls1, *ls2),
>              ls1->Distance(ls2));
>
Which one(s) of the three tests above fail? All of them? Just the second?
Please let me know of your findings.
Best,
- m.
>      delete sref;
> }
> --->%---
>
> Thanks alot in advance for any hints!
>
> 			--- Eric
> _______________________________________________
> Geometry mailing list
> Geometry_at_[hidden]
> http://listarchives.boost.org/mailman/listinfo.cgi/geometry