Hello All,<br><br>So, I have made quite a bit of progress with this function, but I am having a little problem. It does not work with all datasets. <br><br>For debuging, the program outputs the point coordinates using the toString() function each time it checks for coincident points (when checking if polyline segments touch end to end). Some points show as being equal using toString() but don't return true when checked using ==. I suspect that this is due to rounding errors maybe, but that doesn't quite seem right because the source data are equal double values. Does the toString() function show all the decimal points for the point coordinates? Is there a better way to check if points are coincident (better than ==)?<br>
<br>I can send out the code if anyone is interested.<br><br>Thanks for all your help.<br><br>Matt<br><br><br><div class="gmail_quote">On Tue, Sep 15, 2009 at 11:10 PM, Matthew Denno <span dir="ltr"><<a href="mailto:mgdenno@gmail.com" target="_blank">mgdenno@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;">Update: So I thought that QgsPolyline->at(int).x() and QgsPolyline->at(int).y() methods were working but upon further investigation, they aren't working either. It only returns the correct x value for x1. All of the other values are very small i.e. 1e-308<br>
<br><div class="gmail_quote">On Tue, Sep 15, 2009 at 10:09 PM, Matthew Denno <span dir="ltr"><<a href="mailto:mgdenno@gmail.com" target="_blank">mgdenno@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;">
Thank you everyone for your help. I really apprecand iate 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.<div>
<div></div><div><br>
<br>
<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><div><div></div><div>
<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" target="_blank">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><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><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><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>
</div></div></div></div></blockquote></div><br>
</blockquote></div><br>