<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    Regular Polygons are fine for many applications.&nbsp; I needed range
    rings for ocean races, which did not correctly reflect the
    projection of the map.&nbsp; Although it projected like a nice round
    circle, the correct shape should have been oval.<br>
    <br>
    Did not find a geographic circle function in OL, so I adapted one
    from one found online.<br>
    <br>
    I present it here should anyone want it, or have a better idea, or
    want to point out that this was in OL all along.<br>
    <br>
    <b>function GeoCircle(latin, lonin, radius)// thanks to VE site for
      basic algo. Returns an OL Polygon of diameter in nautical miles<br>
      &nbsp; {<br>
      &nbsp;&nbsp;&nbsp; var locs = new Array();<br>
      &nbsp;&nbsp;&nbsp; var lat1 = latin * Math.PI/180.0;<br>
      &nbsp;&nbsp;&nbsp; var lon1 = lonin * Math.PI/180.0;<br>
      &nbsp;&nbsp;&nbsp; var d = radius/3440.07;// change this value to the radius of
      the Earth in your units<br>
      &nbsp;&nbsp;&nbsp; var x;<br>
      &nbsp;&nbsp;&nbsp; for (x = 0; x &lt;= 360; x+=6)&nbsp; //gives 60 points.&nbsp; More than
      enough for a smooth circle most likely<br>
      &nbsp;&nbsp;&nbsp; {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var tc = (x / 90)* Math.PI / 2;<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var lat =
Math.asin(Math.sin(lat1)*Math.cos(d)+Math.cos(lat1)*Math.sin(d)*Math.cos(tc));<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lat = 180.0 * lat / Math.PI;<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var lon;<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (Math.cos(lat1)==0)<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lon=lonin; // endpoint a pole<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lon = ((lon1 - Math.asin(Math.sin(tc) *
      Math.sin(d)/Math.cos(lat1)) + Math.PI) % (2 * Math.PI)) - Math.PI;<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lon = 180.0 * lon / Math.PI;<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var loc = new pt(lon,lat);<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; locs.push(loc);<br>
      &nbsp;&nbsp;&nbsp; }<br>
      &nbsp;&nbsp;&nbsp; var poly = new OpenLayers.Feature.Vector(new
      OpenLayers.Geometry.Polygon(new
      OpenLayers.Geometry.LinearRing(locs)));<br>
      &nbsp;&nbsp;&nbsp; <br>
      &nbsp;&nbsp;&nbsp; return poly;&nbsp; //this can be added to a map<br>
      }<br>
    </b><br>
  </body>
</html>