<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;">I did something like this where i took the input points in the order given, and then compared the angle measurements of the lines leaving each point. If the angle measurement was not around 90 +- 10 degrees we flipped the last two coordinates.<br><br>We basically just did a little trigonometry. I don't have the process i have here with me but it was fairly simple after i remembered my trig from college.<br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Brian Krebs <brian.krebs@KORTERRA.COM><br>To: MAPSERVER-DEV@LISTS.UMN.EDU<br>Sent: Tuesday, September 26, 2006 5:10:59 PM<br>Subject: [UMN_MAPSERVER-DEV] Drawing a polygon given multiple points<br><br>
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
text-decoration:underline;}
span.EmailStyle17
        {
font-family:Arial;
color:windowtext;}
_filtered {
margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {}
-->
</style>
<div class="Section1">
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">IĒve ran into a situation where I have multiple
lat/long coordinates in no particular order and I need to use them to create a
polygon so there arenĒt any intersecting lines. The code IĒve
written so far loops through the coordinates and creates a new line point using
line.add(new pointObj(x, y, 0, 0)) for each one. Unfortunately, there is
no guarantee that the data we receive from other companies is going to be in
any logical order.</span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">As an example, say I had 4 points and I want to create a box:</span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">If we receive them in the following order, we get a box. </span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">-2, 2</span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">2, 2</span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">2, -2</span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">-2, -2</span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">If we receive them in this order, we get an hourglass type
shape.</span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">-2, 2</span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">2, 2</span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">-2, -2</span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">2, -2</span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Is there any function or some simplified algorithm that will
put these coordinates into a proper order? I need something that will
figure out the order no matter how many points there are.</span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Thanks</span></font></p>
</div>
</div><br></div></div></body></html>