<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><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">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>