GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing geographiclib.sourceforge.io — JSDoc: Tutorial: Examples of use Jump to
Online examplesJavaScript is most useful for deploying applications that run in the browser. Two such examples that illustrate the use of these JavaScript packages are:
These are available in the samples directory of the git repository. geodesic namespaceThis capabilities of these package are all exposed through the geodesic namespace and DMS module. These can brought into scope in various ways. Using node after installing the package with npmIf npm has been used to install geographiclib-geodesic and geographiclib-dms via
then in node, you can do
The following descriptions mostly focus in the
Using node with a free-standing geographiclib-geodesic.jsIf you have
A similar prescription works if HTML with your own version of geographiclib-geodesic.min.jsLoad geographiclib-geodesic.min.js with
This ".min.js" version has been "minified" by removing comments and redundant white space; this is appropriate for web applications. HTML downloading geographiclib-geodesic.min.js from SourceForgeLoad
Loading scripts with AMDThis uses require.js (which you can download here) to load geographiclib asynchronously. Your web page includes
where
Specifying the ellipsoidOnce geodesic has been brought into scope, the ellipsoid is defined via the Geodesic constructor using the equatorial radius a in meters and the flattening f, for example
These are the parameters for the WGS84 ellipsoid and this comes predefined by the package as
Note that you can set f = 0 to give a sphere (on which geodesics are great circles) and f < 0 to give a prolate ellipsoid. The rest of the examples on this page assume the following assignments
with the understanding that the first two lines should be replaced
with the appropriate construction needed to bring the geodesic
and DMS into scope. Of course, if you aren't doing
DMS conversions, there's no need to define Basic geodesic calculationsThe distance from Wellington, NZ (41.32S, 174.81E) to Salamanca, Spain (40.96N, 5.50W) using Geodesic.Inverse:
→ The point the point 20000 km SW of Perth, Australia (32.06S, 115.74E) using Geodesic.Direct:
→ The area between the geodesic from JFK Airport (40.6N, 73.8W) to LHR Airport (51.6N, 0.5W) and the equator. This is an example of setting the outmask parameter, see The library interface, "The outmask and caps parameters".
→ Computing waypointsConsider the geodesic between Beijing Airport (40.1N, 116.6E) and San Fransisco Airport (37.6N, 122.4W). Compute waypoints and azimuths at intervals of 1000 km using Geodesic.InverseLine and GeodesicLine.Position:
gives
The inclusion of Geodesic.LONG_UNROLL in the call to GeodesicLine.Position ensures that the longitude does not jump on crossing the international dateline. If the purpose of computing the waypoints is to plot a smooth geodesic, then it's not important that they be exactly equally spaced. In this case, it's faster to parameterize the line in terms of the spherical arc length with GeodesicLine.ArcPosition instead of the distance. Here the spacing is about 1° of arc which means that the distance between the waypoints will be about 60 NM.
gives
The variation in the distance between these waypoints is on the order of 1/f. Measuring areasMeasure the area of Antarctica using Geodesic.Polygon and the PolygonArea class:
→ If the points of the polygon are being selected interactively, then PolygonArea.TestPoint can be used to report the area and perimeter for a polygon with a tentative final vertex which tracks the mouse pointer. Degrees, minutes, seconds conversionCompute the azimuth for geodesic from JFK (73.8W, 40.6N) to Paris CDG (49°01'N, 2°33'E) using the DMS module:
→ |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |