#! /bin/sh # # Planimeter.cgi # cgi script for measuring the area of geodesic polygons # # Copyright (c) Charles Karney (2011-2022) and # licensed under the MIT/X11 License. For more information, see # https://geographiclib.sourceforge.io/ . ./utils.sh OPTION=`lookupkey "$QUERY_STRING" option` if test "$OPTION" = Reset; then INPUT= else INPUT=`lookupcheckkey "$QUERY_STRING" input` NORM=`lookupkey "$QUERY_STRING" norm` TYPE=`lookupkey "$QUERY_STRING" type` RHUMB=`lookupkey "$QUERY_STRING" rhumb` fi env > /tmp/env INPUTENC=`encodevalue "$INPUT"` if test "$TYPE" = "polyline"; then LINEFLAG=-l else LINEFLAG= fi if test "$RHUMB" = "rhumb"; then RHUMBFLAG=-R else RHUMBFLAG= fi EXECDIR=../bin # Don't add -E flag since this utility only treats the WGS84 ellipsoid COMMAND="Planimeter" VERSION=`$EXECDIR/$COMMAND --version | cut -f4 -d" "` STATUS= NUM= LEN= AREA= if test "$INPUT"; then STATUS=`echo "$INPUT" | head -1 | $EXECDIR/GeoConvert` if test $? -eq 0; then STATUS=OK OUTPUT=`echo "$INPUT" | $EXECDIR/$COMMAND $LINEFLAG $RHUMBFLAG | head -1` NUM="`echo $OUTPUT | cut -f1 -d' '`" LEN="`echo $OUTPUT | cut -f2 -d' '`" AREA="`echo $OUTPUT | cut -f3 -d' '`" if test "$NORM"; then TRANSFORMEDINPUT=`echo "$INPUT" | $EXECDIR/GeoConvert -p 20 | sed '/^ERROR/,$d'` INPUTENC=`encodevalue "$TRANSFORMEDINPUT"` fi fi # echo `date +"%F %T"` "$COMMAND: $INPUT" >> ../persistent/utilities.log fi echo Content-type: text/html echo cat < Online geodesic planimeter

Online geodesic polygon calculations using the Planimeter utility

Closed/open:    
Edge type:    

Enter the vertices as latitude longitude pairs, one per line:
   

Convert vertices to decimal degrees

Select action:
   

Results:

    STATUS             = $STATUS
    number of vertices = $NUM
    Perimeter (m)      = $LEN
    area (m^2)         = $AREA


In polygon mode, Planimeter (version $VERSION) calculates the perimeter and area of a polygon whose edges are either geodesics or rhumb lines on the WGS84 ellipsoid.

The edges of the polygon are given by the shortest geodesic or rhumb line between consecutive vertices. In certain cases, there may be two or many such shortest paths, and in that case, the polygon is not uniquely specified by its vertices. In such cases, insert an additional vertex near the middle of the long edge to define the boundary of the polygon.

Counter-clockwise traversal of a polygon results in a positive area. Arbitrarily complex polygons are allowed. In the case of self-intersecting polygons the area is accumulated "algebraically", i.e., the areas of the 2 loops in a figure-8 polygon will partially cancel. There is no need to close the polygon. Polygons may include one or both poles. In polyline mode, Planimeter calculates the length of the geodesic path joining the points.

Give the vertices in terms of latitude and longitude, for example (these all refer to the position of Timbuktu):

        16.776 -3.009
        16d47' -3d1'
        W3°0'34" N16°46'33"
        3:0:34W 16:46:33N
A blank line or a coordinate which cannot be understood causes the reading of vertices to be stopped.

For moderately complex polygons, the perimeter is accurate to about 200 nm and the area is accurate to about 0.1 m2.

Planimeter, which is a simple wrapper of the GeographicLib::PolygonAreaT class, is one of the utilities provided with GeographicLib. Geodesic areas can also be computed using JavaScript; see the JavaScript geodesic calculator. If you wish to use Planimeter directly, download and compile GeographicLib. The algorithms are described in C. F. F. Karney, Algorithms for geodesics, J. Geodesy 87, 43–55 (2013); DOI: 10.1007/s00190-012-0578-z; addenda: geod-addenda.html.


Charles Karney <charles@karney.com> (2022-04-10)
GeographicLib home EOF