<div dir="ltr">Thanks a lot Javier. I'll test this and come back to you.<div><br></div><div>Here is a download link to the shapefile causing this issue for me: <a href="https://filesender.renater.fr/?s=download&token=da2a7ff6-9755-4086-b1ed-71c6ebc72a0f">https://filesender.renater.fr/?s=download&token=da2a7ff6-9755-4086-b1ed-71c6ebc72a0f</a></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le lun. 16 oct. 2023 à 15:21, Even Rouault <<a href="mailto:even.rouault@spatialys.com">even.rouault@spatialys.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>

  
    
  
  <div>
    <p><br>
    </p>
    <div>Le 16/10/2023 à 15:15, Javier Jimenez
      Shaw via gdal-dev a écrit :<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">
        <div>Do you mean a MultiLineString?</div>
        <div><br>
        </div>
        <div>This piece of code is working for me (I hope without any
          bug).<br>
        </div>
        <div><br>
        </div>
        <div><span style="font-family:monospace">if
            (wkbFlatten(poGeometry->getGeometryType()) ==
            wkbMultiLineString)</span></div>
        <div><span style="font-family:monospace">   
            multiLineStringGeometry(poGeometry);</span></div>
        <div><span style="font-family:monospace">...<br>
          </span></div>
        <div><span style="font-family:monospace">           
            multiLineStringGeometry(OGRGeometry* poGeometry)<br>
                        {<br>
                            OGRMultiLineString* multiLine =
            dynamic_cast<OGRMultiLineString*>(poGeometry);<br>
                            int numGeometries =
            multiLine->getNumGeometries();<br>
                            for (int i = 0; i < numGeometries; i++)<br>
                            {<br>
                                OGRGeometry* eachGeometry =
            multiLine->getGeometryRef(i);<br>
                                OGRLineString* line =
            dynamic_cast<OGRLineString*>(eachGeometry);<br>
                                // do whatever with that LineString<br>
                            }</span></div>
        <div><span style="font-family:monospace">            }</span><br>
        </div>
      </div>
    </blockquote>
    <p>Can further be simplified to something like:<br>
    </p>
    <div><span style="font-family:monospace">           
        multiLineStringGeometry(const OGRGeometry* poGeometry)<br>
                    {<br>
                        for (const OGRLineString* line:
        poGeometry->toMultiLineString())<br>
                        {<br>
                            // do whatever with that LineString<br>
                        }</span></div>
    <span style="font-family:monospace">            }</span>
    <p></p>
    <blockquote type="cite"><br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Mon, 16 Oct 2023 at 12:14,
          Roland Baviere via gdal-dev <<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div dir="ltr">Hi all,
            <div><br>
            </div>
            <div> I hope this e-mel finds you well.</div>
            <div><br>
            </div>
            <div>I am trying to read a shapefile layer from OGR from a
              C++ application following the tutorial found here: <a href="https://gdal.org/tutorials/vector_api_tut.html#reading-from-ogr" target="_blank">https://gdal.org/tutorials/vector_api_tut.html#reading-from-ogr</a></div>
            <div><br>
            </div>
            <div>We have difficulties with a layer containing PolyLines
              with several parts.</div>
            <div><br>
            </div>
            <div>The pre-existing code works fine for polylines having a
              unique part.</div>
            <div><br>
            </div>
            <div>Do you have any example or advice to help me implement
              a version that works for polylines containing several
              parts. My intention is to display each shape on a map, so
              I need to retrieve the coordinates of points and draw
              segment between points when relevant.</div>
            <div><br>
            </div>
            <div>Thanks a lot for your help.</div>
            <div><br>
            </div>
            <div>Kind regards,</div>
            <div><br>
            </div>
            <div>Roland</div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div>//// CODE THAT WORKS for "simple" polylines but fails
              when dealiing with a polyline containing several parts</div>
            <div> </div>
            <div>int o = 0;<br>
            </div>
            <div>                        for(auto y :
              poGeometry->toLineString()) {<br>
                                          if (o == 0) {<br>
                                              line.mInCoord =
              QGeoCoordinate(y.getX(), y.getY());<br>
                                          } else if (o ==
              (poGeometry->toLineString()->getNumPoints() - 1)) {<br>
                                              line.mOutCoord =
              QGeoCoordinate(y.getX(), y.getY());<br>
                                          } else {<br>
                                             
              line.mPath.addCoordinate(QGeoCoordinate(y.getX(),
              y.getY()));<br>
                                          }<br>
                                          qDebug() << o;<br>
                                          o++;<br>
                                      }<br>
            </div>
            <div><br>
            </div>
          </div>
          _______________________________________________<br>
          gdal-dev mailing list<br>
          <a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
          <a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
        </blockquote>
      </div>
      <br>
      <fieldset></fieldset>
      <pre>_______________________________________________
gdal-dev mailing list
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
    </blockquote>
    <pre cols="72">-- 
<a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
  </div>

</blockquote></div>