[OpenLayers-Users] Fwd: Can I draw a "great circle" Vector?

Bill Thoen bthoen at gisnet.com
Thu Oct 2 09:34:53 EDT 2008


Hi Arnd and Ken,

When I wrote that trac wiki article about great circle algorithms 
(http://trac.openlayers.org/wiki/GreatCircleAlgorithms) I included the 
math for the functions, but I guess I should have just included the js 
code to make it easier for others to use. But my problem is that I don't 
know the OpenLayers code well enough yet to write those three functions 
so that they are integrated properly with the OL library. But for my own 
purposes I've implemented GreatCircleDistance(), GreatCircleBearing() 
and GreatCircleWaypoint() as extensions to point.js.

Basically, to draw a great circle route, you break the route into short 
steps. Then for each step you first calculate the bearing to the 
destination from the starting point or the current waypoint (call 
GreatCircleBearing()) then use that result to calculate the coordinates 
of the next waypoint (call GreatCircleWaypoint()). Collect the waypoints 
into a linestring and you've got your great circle route.

Regarding Ed Williams' Aviation formulary site 
(http://williams.best.vwh.net/avform.htm, which is great and is where I 
got the math to do this) he uses an annoying convention where west 
longitude is positive, so if you're transcribing algorithms from there, 
watch your signs!

I'd be interested in putting these great circle functions into an 
OpenLayers compatible module or patch, but I need help from someone who 
knows the OpenLayers conventions and how to build new modules into the 
library. (I've got lots of experience with GIS, but I'm pretty new to 
JavaScript and OpenLayers.)  So if you're interested in this, let me 
know. I could use the help. In the meantime, I'll put together the code 
I have into a short demonstration and get it out there so people can 
tinker with it.

- Bill Thoen


Arnd Wippermann wrote:
> Hi Ken,
>
> Also interested in this question I have found 2 functions at the mentioned
> side http://williams.best.vwh.net/avform.htm to calculate the distance and
> the waypoints between 2 points. (In the trac... Point.js I could not see a
> way to calculate the waypoints)
>
> I have for own purposes build a simple application to test the haversine
> lines. It seems to be all right.
> http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/orthodrome.html
>
> There are two points, that could be moved around, and then you can calculate
> the route.
>
> Script:
> http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/javascript/orthodro
> me.js
>
> The way I create the line features are a bit unusable (Write a WKT string
> and then use the OpenLayers.Format parser to import the WKT string). There
> are other ways to do this with OpenLayers.
>
> To get a curve you have to approximate the haversine line with a couple of
> lines. I have choosen 100 lines to get a smooth curve.
>
> Arnd Wippermann
>
>
> -----Ursprüngliche Nachricht-----
> Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
> Auftrag von Ken Martin
> Gesendet: Dienstag, 30. September 2008 22:23
> An: users-request at openlayers.org
> Betreff: [OpenLayers-Users] Can I draw a "great circle" Vector?
>
> Newbie (and incredibly impressed) user. :)
>
> I'm drawing lines based on example code I've grabbed from openlayers.org,
> which is essentially using this...
>
> var lineFeature = new OpenLayers.Feature.Vector(
>                                        new
> OpenLayers.Geometry.LineString(pointList),null,style_green);
>
> It's working great, but I'd like the lines to be "great circle" or
> "haversine" lines.
>
> Possible?
>
> I have seen the following, but not sure how to use it for this...
> http://trac.openlayers.org/wiki/GreatCircleAlgorithms
>
> Thanks! :)
>
> Ken Martin
>
>   



More information about the Users mailing list