Thank you everyone for your help. I really appreciate it as I am trying to learn the QGIS API and C++. I think that I have a solid plan to achieve my goal now. However, I seem to be stuck on something that I think should be simple, looping through the points of a QgsPolyline. If I iterate through the Polylines and print out the point coordinates using ->at(int).x() I can print out x1, y1, x2, and y2 with out problems. But, if I try to iterate through the points of the polyline and print out the coordinates, I get x1, y1 and then a bunch of junk values for the first 3 polylines and then eventually it ends unexpectedly. Below is the code I am trying to use.<br>
<br>
<meta name="qrichtext" content="1"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css">
p, li { white-space: pre-wrap; }
</style>
<p style="margin: 0px; text-indent: 0px;"> //now iterate through each polyline feature</p>
<p style="margin: 0px; text-indent: 0px;"> while (mypPolylineLayer->nextFeature(currentPolylineFeat))</p>
<p style="margin: 0px; text-indent: 0px;"> {</p>
<p style="margin: 0px; text-indent: 0px;"> qDebug("feature = %i",f);</p>
<p style="margin: 0px; text-indent: 0px;"> ++f;</p><p style="margin: 0px; text-indent: 0px;"><br></p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;"> //get point geometry for current feature</p>
<p style="margin: 0px; text-indent: 0px;"> QgsGeometry * currentPolylineGeom = currentPolylineFeat.geometry();</p>
<p style="margin: 0px; text-indent: 0px;"> QgsPolyline * currentPolyline;</p>
<p style="margin: 0px; text-indent: 0px;"> currentPolyline = &currentPolylineGeom->asPolyline();</p>
<p style="margin: 0px; text-indent: 0px;"> </p>
<p style="margin: 0px; text-indent: 0px;"> //this part works</p>
<p style="margin: 0px; text-indent: 0px;"> qDebug() << "x1 = " << currentPolyline->at(0).x();</p>
<p style="margin: 0px; text-indent: 0px;"> qDebug() << "y1 = " << currentPolyline->at(0).y();</p>
<p style="margin: 0px; text-indent: 0px;"> qDebug() << "x2 = " << currentPolyline->at(1).x();</p>
<p style="margin: 0px; text-indent: 0px;"> qDebug() << "y2 = " << currentPolyline->at(1).y();</p><p style="margin: 0px; text-indent: 0px;"><br></p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;"> QgsPolyline::const_iterator it = currentPolyline->constBegin();</p>
<p style="margin: 0px; text-indent: 0px;"> for(; it != currentPolyline->constEnd(); ++it)</p>
<p style="margin: 0px; text-indent: 0px;"> {</p>
<p style="margin: 0px; text-indent: 0px;"> //this part doesn't</p>
<p style="margin: 0px; text-indent: 0px;"> qDebug() << "x = " << (*it).x();</p>
<p style="margin: 0px; text-indent: 0px;"> qDebug() << "y = " << (*it).y();</p>
<p style="margin: 0px; text-indent: 0px;"> }</p>
<p style="margin: 0px; text-indent: 0px;"> }</p><br><br><div class="gmail_quote">On Tue, Sep 15, 2009 at 5:48 AM, Carson Farmer <span dir="ltr"><<a href="mailto:carson.farmer@gmail.com">carson.farmer@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Basically the polylines need to be "dissolved" first. Is there an existing function to acheive this? </blockquote>
</div><div><br>You will likely need to do this yourself by finding segments that share a node, and creating a single line from all the associated QgsPoints.<br> <br></div><div class="im"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Also, is there an enexisting function to union polygons programaticlly?<br></blockquote></div><div><br>Certainly, check out QgsGeometry.combine() in the docs.<br><font color="#888888"><br>Carson<br></font></div></div><div>
<div></div><div class="h5"><br clear="all"><br>-- <br>Carson Farmer<br>
National Centre for Geocomputation<br>John Hume Building,<br>National University of Ireland, Maynooth,<br>Maynooth,<br>Co. Kildare,<br>Ireland.<br><a href="http://www.carsonfarmer.com" target="_blank">www.carsonfarmer.com</a><br>
</div></div></blockquote></div><br>