The cl-proj Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The cl-proj Reference Manual

This is the cl-proj Reference Manual, version 4.9.2, generated automatically by Declt version 2.4 "Will Decker" on Wed Jun 20 11:19:42 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

CL-PROJ: Lisp bindings for the Proj.4 library

PROJ.4 is a cartographic projections library originally written by Gerald Evenden then of the USGS. PROJ.4 has been placed under an MIT license.

CL-PROJ provides CFFI-based Common Lisp bindings for the PROJ.4 library. It is placed under the Berkeley Software Distribution (BSD) license meaning that you can do almost everything you want with it.

PROJ.4 homepage is: proj4.org

Original CL-PROJ homepage was at the cl-proj.sourceforge.net, but current development and documentation is at the Bitbucket.

cl-proj can be installed using the Quicklisp system:

(ql:quicload :cl-proj)

Usage

Library loading and linking into the Lisp image is performed automatically when it is loaded by ASDF/QuickLisp.

Symbols are defined in the cl-proj package and are also available using the pj package nickname.

Constants, variables and functions are extremely close to the PROJ.4. Bindings for geodesic functions are also provided in addition to the core Proj4 API. Reference is in the <api.html> file that is supplied in the distribution.

Primary development platform is recent Ubuntu Linux distribution with recent versions of SBCL and ECL Common Lisps.

In addition to Proj4 library bindings this package a number of utility functions, including:

This package has been used to produce some maps in the collection-of-maps (Wiki).

Copying

Copyright (c) 2012,2015,2017 Victor Anyakin <anyakinvictor@yahoo.com>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the organization nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL Victor Anyakin BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMA

Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 cl-proj

Author

Victor Anyakin <anyakinvictor@yahoo.com>

License

BSD

Description

CL-PROJ provides Proj.4 library bindings

Version

4.9.2

Dependencies
Source

cl-proj.asd (file)

Component

src (module)


Next: , Previous: , Up: Top   [Contents][Index]

3 Modules

Modules are listed depth-first from the system components tree.


Previous: , Up: Modules   [Contents][Index]

3.1 cl-proj/src

Parent

cl-proj (system)

Location

src/

Components

Next: , Previous: , Up: Top   [Contents][Index]

4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

4.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.1 cl-proj.asd

Location

cl-proj.asd

Systems

cl-proj (system)

Packages

cl-proj-asd


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.2 cl-proj/src/package.lisp

Parent

src (module)

Location

src/package.lisp

Packages

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.3 cl-proj/src/grovel-proj-api.lisp

Dependency

package.lisp (file)

Parent

src (module)

Location

src/grovel-proj-api.lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.4 cl-proj/src/grovel-geodesic.lisp

Dependency

grovel-proj-api.lisp (file)

Parent

src (module)

Location

src/grovel-geodesic.lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.5 cl-proj/src/proj-api.lisp

Dependency

grovel-geodesic.lisp (file)

Parent

src (module)

Location

src/proj-api.lisp

Exported Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.6 cl-proj/src/geodesic.lisp

Dependency

proj-api.lisp (file)

Parent

src (module)

Location

src/geodesic.lisp

Exported Definitions
Internal Definitions

Previous: , Up: Lisp files   [Contents][Index]

4.1.7 cl-proj/src/util.lisp

Dependency

geodesic.lisp (file)

Parent

src (module)

Location

src/util.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

5.1 cl-proj-asd

Source

cl-proj.asd

Use List

Next: , Previous: , Up: Packages   [Contents][Index]

5.2 cl-proj

CL-PROJ provides bindings for the Proj.4 library.

Constants, variables and function names are extremely close to the native PROJ.4 library.

A number of utility functions are provided along with bare bindings.

Bindings for the geodesic API are also implemented.

Source

package.lisp (file)

Nickname

pj

Use List
Exported Definitions
Internal Definitions

Next: , Previous: , Up: Packages   [Contents][Index]

5.3 geodesic-types

Geodesic types produced by groveling the geodesic.h header file.

Source

package.lisp (file)

Nickname

geo-types

Use List
Used By List

cl-proj

Exported Definitions
Internal Definitions

Previous: , Up: Packages   [Contents][Index]

5.4 proj-types

Proj API types produced by groveling the proj_api.h header file.

Source

package.lisp (file)

Use List
Used By List

cl-proj

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

6.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.1 Constants

Constant: +deg-to-rad+
Package

proj-types

Source

/home/quickref/.cache/common-lisp/sbcl-1.4.0-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-proj-20171227-hg/src/grovel-proj-api.processed-grovel-file

Constant: +equatorial-radius+
Package

cl-proj

Source

geodesic.lisp (file)

Constant: +flattening+
Package

cl-proj

Source

geodesic.lisp (file)

Constant: +geodesic-version+
Package

geodesic-types

Source

/home/quickref/.cache/common-lisp/sbcl-1.4.0-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-proj-20171227-hg/src/grovel-geodesic.processed-grovel-file

Constant: +geodesic-version-major+
Package

geodesic-types

Source

/home/quickref/.cache/common-lisp/sbcl-1.4.0-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-proj-20171227-hg/src/grovel-geodesic.processed-grovel-file

Constant: +geodesic-version-minor+
Package

geodesic-types

Source

/home/quickref/.cache/common-lisp/sbcl-1.4.0-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-proj-20171227-hg/src/grovel-geodesic.processed-grovel-file

Constant: +geodesic-version-patch+
Package

geodesic-types

Source

/home/quickref/.cache/common-lisp/sbcl-1.4.0-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-proj-20171227-hg/src/grovel-geodesic.processed-grovel-file

Constant: +pj-version+
Package

proj-types

Source

/home/quickref/.cache/common-lisp/sbcl-1.4.0-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-proj-20171227-hg/src/grovel-proj-api.processed-grovel-file

Constant: +rad-to-deg+
Package

proj-types

Source

/home/quickref/.cache/common-lisp/sbcl-1.4.0-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-proj-20171227-hg/src/grovel-proj-api.processed-grovel-file


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.2 Symbol macros

Symbol Macro: pj-errno
Package

proj-types

Source

/home/quickref/.cache/common-lisp/sbcl-1.4.0-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-proj-20171227-hg/src/grovel-proj-api.processed-grovel-file

Expansion

(proj-types::%var-accessor-pj-errno)

Symbol Macro: pj-release
Package

proj-types

Source

/home/quickref/.cache/common-lisp/sbcl-1.4.0-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-proj-20171227-hg/src/grovel-proj-api.processed-grovel-file

Expansion

(proj-types::%var-accessor-pj-release)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.3 Macros

Macro: deg-to-rad VAL

Convert given value from degrees to radians.

Package

cl-proj

Source

util.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.4 Functions

Function: deg-to-rad-array X LEN

Converts numbers in the given native array of length LEN from degrees to radians and stores them in the same array.

Package

cl-proj

Source

util.lisp (file)

Function: direct-problem G LAT1 LON1 AZI1 S12
Package

cl-proj

Source

geodesic.lisp (file)

Function: dms-to-dec DEG &optional MIN SEC

@short{Converts a degree-minute-second representation to decimal degrees.}

For example, to convert 47°7’50.09 to decimal representation, call this function with following parameters:

@begin{code}
(dms-to-dec 47 7 50.9) => 47.130802
@end{code}

Package

cl-proj

Source

util.lisp (file)

Function: general-inverse-problem G LAT1 LON1 LAT2 LON2

@short{The general inverse geodesic calculation.}

@arg[g]{GEO-GEODESIC object specifying the ellipsoid.}
@param[in] lat1 latitude of point 1 (degrees).
@param[in] lon1 longitude of point 1 (degrees).
@param[in] lat2 latitude of point 2 (degrees).
@param[in] lon2 longitude of point 2 (degrees).
@param[out] ps12 pointer to the distance between point 1 and point 2 (meters).
@param[out] pazi1 pointer to the azimuth at point 1 (degrees). @param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees). @param[out] pm12 pointer to the reduced length of geodesic (meters). @param[out] pM12 pointer to the geodesic scale of point 2 relative to point 1 (dimensionless).
@param[out] pM21 pointer to the geodesic scale of point 1 relative to point 2 (dimensionless).
@param[out] pS12 pointer to the area under the geodesic (meters<sup>2</sup>).
@return e a12 arc length of between point 1 and point 2 (degrees).

e g must have been initialized with a call to geod_init(). e lat1 and e lat2 should be in the range [&minus;90&deg;, 90&deg;].

Package

cl-proj

Source

geodesic.lisp (file)

Function: general-position L FLAGS S12_A12

@short{The general position function.}

@arg[l]{GEO-LINE object specifying the geodesic line.}
@arg[flags] bitor’ed combination of GEOD-FLAGS; e flags &
GEOD_ARCMODE determines the meaning of e s12_a12 and e flags & GEOD_LONG_UNROLL ’unrolls’ e lon2; if e flags & GEOD_ARCMODE is 0,
then e l must have been initialized with e caps |= GEOD_DISTANCE_IN. @param[in] s12_a12 if e flags & GEOD_ARCMODE is 0, this is the
distance between point 1 and point 2 (meters); otherwise it is the
arc length between point 1 and point 2 (degrees); it can be
negative.
@param[out] plat2 pointer to the latitude of point 2 (degrees). @param[out] plon2 pointer to the longitude of point 2 (degrees); requires that e l was initialized with e caps |= GEOD_LONGITUDE.
@param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees). @param[out] ps12 pointer to the distance between point 1 and point 2 (meters); requires that e l was initialized with e caps |= GEOD_DISTANCE.
@param[out] pm12 pointer to the reduced length of geodesic (meters); requires that e l was initialized with e caps |= GEOD_REDUCEDLENGTH. @param[out] pM12 pointer to the geodesic scale of point 2 relative to point 1 (dimensionless); requires that e l was initialized with e caps |= GEOD_GEODESICSCALE.
@param[out] pM21 pointer to the geodesic scale of point 1 relative to point 2 (dimensionless); requires that e l was initialized with e caps |= GEOD_GEODESICSCALE.
@param[out] pS12 pointer to the area under the geodesic (meters<sup>2</sup>); requires that e l was initialized with e caps |= GEOD_AREA.
@return e a12 arc length of between point 1 and point 2 (degrees).

e l must have been initialized with a call to geod_lineinit() with e
caps |= GEOD_DISTANCE_IN. The value e azi2 returned is in the range [&minus;180&deg;, 180&deg;). Any of the ’return’ arguments e plat2,
etc., may be replaced by 0, if you do not need some quantities
computed. Requesting a value which e l is not capable of computing
is not an error; the corresponding argument will not be altered.

With e flags & GEOD_LONG_UNROLL bit set, the longitude is ’unrolled’ so that the quantity e lon2 &minus; e lon1 indicates how many times and in what sense the geodesic encircles the ellipsoid.

Example, compute way points between JFK and Singapore Changi Airport
using geod_genposition(). In this example, the points are evenly space in arc length (and so only approximately equally space in distance). This is faster than using geod_position() would be appropriate if drawing the path on a map.

(let ((g (pj:make-geodesic)))
(multiple-value-bind (a12 azi1 azi2)
(pj:general-inverse-problem g 40.64 -73.78 1.36 103.99)
(declare (ignore azi2))
(let ((l (pj:make-geo-line g 40.64 -73.78 azi1 ’(:latitude :longitude))))) (loop :for i :from 0 :to 100
:do (multiple-value-bind (s12 lati loni)
(general-position l ’(:arcmode) (* i a12 0.01))
(declare (ignore s12))
(format t "~,5f ~,5f~%" lati loni))))))

Package

cl-proj

Source

geodesic.lisp (file)

Function: geo-position L S12

@short{Compute the position along a geod_geodesicline.}

@arg[l]{a pointer to the geod_geodesicline object specifying the geodesic line.} @arg[s12]{distance between point 1 and point 2 (meters); it can be negative.}

param[out] plat2 pointer to the latitude of point 2 (degrees).
param[out] plon2 pointer to the longitude of point 2 (degrees); requires that e l was initialized with e caps |= GEOD_LONGITUDE.
param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees).

e l must have been initialized with a call to geod_lineinit() with e
caps |= GEOD_DISTANCE_IN. The values of e lon2 and e azi2 returned are
in the range [&minus;180&deg;, 180&deg;). Any of the ’return’ arguments
e plat2, etc., may be replaced by 0, if you do not need some quantities computed.

Example, compute way points between JFK and Singapore Changi Airport
the ’obvious’ way using GEO-DIRECT:

@begin{code}
(let ((g (pj:make-geodesic)))
(multiple-value-bind (s12 azi1 azi2)
(pj:inverse-problem g 40.64 -73.78 1.36 103.99)
(loop :for i :from 0 :to 100
:do (multiple-value-bind (lati loni azii)
(pj:direct-problem g 40.64 -73.78 azi1 (* i s12 0.01))
(declare (ignore azii))
(format t "~,5f ~,5f~%" lati loni)))))
@end{code}

A faster way using GEOD-POSITION:

@begin{code}
(let ((g (pj:make-geodesic)))
(multiple-value-bind (s12 azi1 azi2)
(pj:inverse-problem g 40.64 -73.78 1.36 103.99)
(declare (ignore azi2))
(let ((l (pj:make-geo-line g 40.64 -73.78 azi1)))
(loop :for i :from 0 :to 100
:do (multiple-value-bind (lati loni azii)
(pj:geo-position l (* s12 i 0.01))
(declare (ignore azii))
(format t "~,5f ~,5f~%" lati loni))))))
@end{code}

Package

cl-proj

Source

geodesic.lisp (file)

Function: geo-transform SRC DST POINTS &key DEGS

@short{Transform between coordinate systems.}

The GEO-TRANSFORM function may be used to transform points between the two provided coordinate systems. In addition to converting between cartographic projection coordinates and geographic coordinates, this function also takes care of datum shifts if possible between the source and destination coordinate system. Unlike @fun{PJ-FWD} and @fun{PJ-INV} it is also allowable for the coordinate system definitions (PJ *) to be geographic coordinate systems (defined as +proj=latlong). The x, y and z arrays contain the input values of the points, and are replaced with the output values. The point_offset should indicate the spacing the of x,y,z arrays, normally 1. The function returns zero on success, or the error number (also in @variable{pj-errno}) on failure.

The z array may be passed as NULL if Z values are not available.

@arg[src]{source (input) coordinate system.}
@arg[dst]{destination (output) coordinate system.}
@arg[points]{A list of X, Y and Z coordinate triple values.} @arg[digs]{Set this T if source coordinates are degrees.}

@return{The return is zero on success, or a PROJ.4 error code.}

Memory associated with the projection may be freed with @fun{pj-free}.

Package

cl-proj

Source

util.lisp (file)

Function: geod-init G A F

Initialize a geod_geodesic object.

@param[out] g a pointer to the object to be initialized. @param[in] a the equatorial radius (meters). @param[in] f the flattening.

Package

cl-proj

Source

geodesic.lisp (file)

Function: inverse-problem G LAT1 LON1 LAT2 LON2

@short{Solve the inverse geodesic problem.}

Returns three values:
* distance between point 1 and point 2 (meters).
* azimuth at point 1 (degrees).
* (forward) azimuth at point 2 (degrees).

Example, determine the distance between JFK and Singapore Changi Airport:

(let ((g (pj:make-geodesic)))
(multiple-value-bind (ps12 pazi1 pazi2) (pj:inverse-problem g 40.64 -73.78 1.36 103.99) (declare (ignore pazi1 pazi2))
(format t "~,3f~%" ps12)))

See: ‘GEOD-INVERSE’

Package

cl-proj

Source

geodesic.lisp (file)

Function: make-geo-line G LAT1 LON1 AZI1 &optional CAPS

@short{Initialize a geod_geodesicline object.}

@arg[g]{a pointer to the geod_geodesic object specifying the ellipsoid.} @arg[lat1]{latitude of point 1 (degrees).}
@arg[lon1]{longitude of point 1 (degrees).}
@arg[azi1]{azimuth at point 1 (degrees).}
@arg[caps]{bitor’ed combination of geod_mask() values specifying the capabilities the geod_geodesicline object should possess, i.e., which quantities can be returned in calls to geod_position() and geod_genposition().}

e g must have been initialized with a call to geod_init(). e lat1 should be in the range [&minus;90&deg;, 90&deg;].

The geod_mask values are see ‘GEOD-MASK’:
- GEOD_LATITUDE for the latitude e lat2; this is
added automatically,
- GEOD_LONGITUDE for the latitude e lon2,
- GEOD_AZIMUTH for the latitude e azi2; this is
added automatically,
- GEOD_DISTANCE for the distance e s12,
- GEOD_REDUCEDLENGTH for the reduced length e m12,
- GEOD_GEODESICSCALE for the geodesic scales e M12
and e M21,
- GEOD_AREA for the area e S12,
- GEOD_DISTANCE_IN permits the length of the
geodesic to be given in terms of e s12; without this capability the length can only be specified in terms of arc length.

A value of e caps = 0 is treated as GEOD_LATITUDE | GEOD_LONGITUDE | GEOD_AZIMUTH | GEOD_DISTANCE_IN (to support the solution of the ’standard’ direct problem).

Package

cl-proj

Source

geodesic.lisp (file)

Function: make-geo-polygon &optional POLYLINEP

@short{Initialize a geod_polygon object.}

@arg[polylinep]{non-NIL if a polyline instead of a polygon.}

If e polylinep is NIL, then the sequence of vertices and edges added by geod_polygon_addpoint() and geod_polygon_addedge() define a polygon and the perimeter and area are returned by geod_polygon_compute(). If e polylinep is non-zero, then the vertices and edges define a polyline and only the perimeter is returned by geod_polygon_compute().

The area and perimeter are accumulated at two times the standard floating point precision to guard against the loss of accuracy with many-sided polygons. At any point you can ask for the perimeter and area so far.

An example of the use of this function is given in the documentation for geod_polygon_compute().

Package

cl-proj

Source

geodesic.lisp (file)

Function: make-geodesic &key A F
Package

cl-proj

Source

geodesic.lisp (file)

Function: parse-degrees PATTERN STR &key DEC START

@short{Utility function to parse string representation of angles like: 47°7’50}

PATTERN is a list that consists of strings and keywords: where :D stands for degrees, :M for minutes and :S for seconds.

For instance, next command parses 47°7’50.09:

@begin{code}
(parse-degrees ’(:d "°" :m "’" :s ) "47°7’50.09") => 47 7 50.09 @end{code}

If an optional key DEC is set to True, returns decimal representation of the parsed angle.

Package

cl-proj

Source

util.lisp (file)

Function: perpendicular-distance POINT LINE1 LINE2

@short{Calculates a distance from a point to the line specified by two points on a Discartes surface.}

Package

cl-proj

Source

util.lisp (file)

Function: pj-acquire-lock ()
Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-apply-gridshift ARG0 ARG1 POINT-COUNT POINT-OFFSET X Y Z
Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-cleanup-lock ()
Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-compare-datums SRCDEFN DSTDEFN
Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-dalloc ARG0
Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-datum-transform SRC DST POINT-COUNT POINT-OFFSET X Y Z
Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-deallocate-grids ()
Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-free ARG0

This is the application callable entry point for destroying a projection definition. It does work generic to all projection types, and then calls the projection specific free function to do local work.

Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-fwd ARG0 P

Forward cartographic projection.

Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-geocentric-to-geodetic A ES POINT-COUNT POINT-OFFSET X Y Z
Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-geodetic-to-geocentric A ES POINT-COUNT POINT-OFFSET X Y Z
Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-get-def P OPTIONS

Returns the PROJ.4 command string that would produce this definition expanded as much as possible. For instance, +init= calls and +datum= definitions would be expanded.

Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-get-errno-ref ()
Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-get-release ()
Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-init ARGC ARGV

Main entry point for initialing a PJ projections definition. Note that the projection specific function is called to do the initial allocation so it can be created large enough to hold projection specific parameters.

Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-init-plus DEFINITION

@short{Convert a string representation of a coordinate system definition into an internal representation.}

This function converts a string representation of a coordinate system definition into a projPJ object suitable for use with other API functions. On failure the function will return NULL and set pj_errno. The definition should be of the general form "+proj=tmerc +lon_0 +datum=WGS84". Refer to PROJ.4 documentation and the General Parameters notes for additional details.

Coordinate system objects allocated with PJ-INIT-PLUS should be deallocated with @fun{PJ-FREE}.

Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-inv ARG0 P

Inverse cartographic projection.

Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-is-geocent ARG0
Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-is-latlong ARG0
Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-latlong-from-proj ARG0

Return a PJ* definition defining the lat/long coordinate system on which a projection is based. If the coordinate system passed in is latlong, a clone of the same will be returned.

Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-malloc ARG0
Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-pr-list ARG0
Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-release-lock ()
Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-set-finder ARG0
Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-set-searchpath COUNT PATH

Path control for callers that can’t practically provide pj_set_finder() style callbacks. Call with (0,NULL) as args to clear the searchpath set.

Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-strerrno ARG0
Package

cl-proj

Source

proj-api.lisp (file)

Function: pj-transform SRC DST POINT-COUNT POINT-OFFSET X Y Z

@short{Transform between coordinate systems.}

The PJ-TRANSFORM function may be used to transform points
between the two provided coordinate systems. In addition to
converting between cartographic projection coordinates and geographic
coordinates, this function also takes care of datum shifts if
possible between the source and destination coordinate system.
Unlike @fun{PJ-FWD} and @fun{PJ-INV} it is also allowable for the
coordinate system definitions (PJ *) to be geographic coordinate
systems (defined as +proj=latlong). The x, y and z arrays contain
the input values of the points, and are replaced with the output
values. The point_offset should indicate the spacing the of x,y,z
arrays, normally 1. The function returns zero on success, or the
error number (also in @variable{pj-errno}) on failure.

The z array may be passed as NULL if Z values are not available.

@arg[src]{source (input) coordinate system.}

@arg[dst]{destination (output) coordinate system.}

@arg[point_count]{the number of points to be processed (the size of the x/y/z arrays).}

@arg[point_offset]{the step size from value to value (measured in
doubles) within the x/y/z arrays - normally 1 for a packed array. May
be used to operate on xyz interleaved point arrays.}

X/Y/Z: The array of X, Y and Z coordinate values passed as input,
and modified in place for output. The Z may optionally be NULL.

@return{The return is zero on success, or a PROJ.4 error code.}

Memory associated with the projection may be freed with @fun{pj-free}.

Package

cl-proj

Source

proj-api.lisp (file)

Function: polygon-add-edge G P AZI S
Package

cl-proj

Source

geodesic.lisp (file)

Function: polygon-add-point G P LAT LON
Package

cl-proj

Source

geodesic.lisp (file)

Function: polygon-area G LATS LONS

@short{A simple interface for computing the area of a geodesic polygon.}

@param[in] g a pointer to the geod_geodesic object specifying the ellipsoid.
@param[in] lats an array of latitudes of the polygon vertices (degrees). @param[in] lons an array of longitudes of the polygon vertices (degrees). @param[in] n the number of vertices.
@param[out] pA pointer to the area of the polygon (meters<sup>2</sup>). @param[out] pP pointer to the perimeter of the polygon (meters).

e lats should be in the range [&minus;90&deg;, 90&deg;].

Only simple polygons (which are not self-intersecting) are allowed. There’s no need to ’close’ the polygon by repeating the first vertex. The area returned is signed with counter-clockwise traversal being treated as positive.

Example, compute the area of Antarctica:

(let ((g (pj:make-geodesic))
(lats ’(-72.9 -71.9 -74.9 -74.3 -77.5 -77.4 -71.7 -65.9 -65.7 -66.6 -66.9 -69.8 -70.0 -71.0 -77.3 -77.9 -74.7))
(lons ’(-74 -102 -102 -131 -163 163 172 140 113
88 59 25 -4 -14 -33 -46 -61)))
(multiple-value-bind (count pa pp)
(pj:polygon-area g lats lons)
(declare (ignore count))
(list pa pp)))

Package

cl-proj

Source

geodesic.lisp (file)

Function: polygon-compute G P &key REVERSE SIGN
Package

cl-proj

Source

geodesic.lisp (file)

Function: polygon-test-point G P LAT LON &key REVERSE SIGN
Package

cl-proj

Source

geodesic.lisp (file)

Function: render-point OX OY EXTENT SIZE &key SRC-CS DST-CS DEBUG

@short{Renders the point with given coordinates using the Proj API and adjusts it to be displayed within a screen with given width and height.}

@arg[extent]{specifies the geographic extents of the original surface area that is displayed within the screen with given @code{size}.

@code{extent} is a plist with properties (:minx :maxx :miny :maxy) specifying geographic bounds in the source geographic system.}

@arg[size]{is a plist specifying (:width and :height) of the resulting image in pixels.}

@arg[oX]{Easting long?}
@arg[oY]{Northing lat?}

@arg[src-cs]{Proj.4 string specifying the source coordinate system} @arg[dst-cs]{Proj.4 string specifying the destination coordinate system}

@begin{return}

In case of success returns multiple values:

@code{pixelX pixelY relX relY pt.x pt.y}

Where @code{pixelX} and @code{pixelY} are coordinates of the given point in pixels within given screen; @code{relX} and @code{relY} is a relative position of the given point; @code{pt.X} and @code{pt.Y} are rendered coordinates of the given point.

@end{return}

Package

cl-proj

Source

util.lisp (file)

Function: simplify POINTS EPSILON

@short{Simplifies the given polyline using the Ramer–Douglas–Peucker
algorithm.}

Given a curve composed of line segments, this function finds and
returns a similar curve with fewer points. The algorithm defines
’dissimilar’ based on the maximum distance between the original curve
and the simplified curve. The simplified curve consists of a subset of
the points that defined the original curve.

Check the @a[http://en.wikipedia.org/wiki/Ramer–Douglas–Peucker_algorithm]{Ramer–Douglas–Peucker algorithm} article on Wikipedia.

@arg[points]{coordinates (x y) of points that specify the polyline}

@arg[epsilon]{distance}

@return{Given a curve composed of line segments, this function finds
and returns a similar curve with fewer points.}

Package

cl-proj

Source

util.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

6.1.5 Classes

Class: geo-line ()
Package

cl-proj

Source

geodesic.lisp (file)

Direct superclasses

geo-object (class)

Class: geo-polygon ()
Package

cl-proj

Source

geodesic.lisp (file)

Direct superclasses

geo-object (class)

Class: geodesic ()
Package

cl-proj

Source

geodesic.lisp (file)

Direct superclasses

geo-object (class)


Previous: , Up: Definitions   [Contents][Index]

6.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.1 Constants

Constant: size-of-geod-geodesic
Package

geodesic-types

Source

/home/quickref/.cache/common-lisp/sbcl-1.4.0-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-proj-20171227-hg/src/grovel-geodesic.processed-grovel-file

Constant: size-of-geod-geodesicline
Package

geodesic-types

Source

/home/quickref/.cache/common-lisp/sbcl-1.4.0-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-proj-20171227-hg/src/grovel-geodesic.processed-grovel-file

Constant: size-of-geod-polygon
Package

geodesic-types

Source

/home/quickref/.cache/common-lisp/sbcl-1.4.0-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-proj-20171227-hg/src/grovel-geodesic.processed-grovel-file

Constant: size-of-proj-uv
Package

proj-types

Source

/home/quickref/.cache/common-lisp/sbcl-1.4.0-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-proj-20171227-hg/src/grovel-proj-api.processed-grovel-file


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.2 Functions

Function: %var-accessor-pj-errno ()
Function: (setf %var-accessor-pj-errno) VALUE
Package

proj-types

Source

/home/quickref/.cache/common-lisp/sbcl-1.4.0-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-proj-20171227-hg/src/grovel-proj-api.processed-grovel-file

Function: %var-accessor-pj-release ()
Function: (setf %var-accessor-pj-release) VALUE
Package

proj-types

Source

/home/quickref/.cache/common-lisp/sbcl-1.4.0-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-proj-20171227-hg/src/grovel-proj-api.processed-grovel-file

Function: convert-flags-to-foreign FLAGS ENUM

Converts list of flags from the given ENUM into a foreign/native integer using bitwise OR (LOGIOR).

Flags can be declared using Groveler as a CENUM.

Package

cl-proj

Source

geodesic.lisp (file)

Function: dec-to-merc-ex ()

Example program from the Proj.4 API documentation.

The following program reads latitude and longitude values in decimal degress, performs Mercator projection with a Clarke 1866 ellipsoid and a 33° latitude of true scale and prints the projected cartesian values in meters.

For this program, an input of ’-16 20.25’ would give a result of ’-1495284.21 1920596.79’.

Program sources can be found at: @a[http://trac.osgeo.org/proj/wiki/ProjAPI]{the ProjAPI page}

Package

cl-proj

Source

util.lisp (file)

Function: general-direct-problem G LAT1 LON1 AZI1 FLAGS S12_A12

@short{The general direct geodesic problem.}

@arg[g]{a pointer to the geod_geodesic object specifying the ellipsoid.} @arg[lat1]{latitude of point 1 (degrees).}
@arg[lon1]{longitude of point 1 (degrees).}
@arg[azi1]{azimuth at point 1 (degrees).}
@arg[flags]{bitor’ed combination of geod_flags(); e flags & GEOD_ARCMODE determines the meaning of e s12_a12 and e flags & GEOD_LONG_UNROLL ’unrolls’ e lon2.}
@arg[s12_a12]{if flags & GEOD_ARCMODE is 0, this is the distance between point 1 and point 2 (meters); otherwise it is the arc length between point 1 and point 2 (degrees); it can be negative.}

@param[out] plat2 pointer to the latitude of point 2 (degrees). @param[out] plon2 pointer to the longitude of point 2 (degrees). @param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees). @param[out] ps12 pointer to the distance between point 1 and point 2 (meters).
@param[out] pm12 pointer to the reduced length of geodesic (meters). @param[out] pM12 pointer to the geodesic scale of point 2 relative to point 1 (dimensionless).
@param[out] pM21 pointer to the geodesic scale of point 1 relative to point 2 (dimensionless).
@param[out] pS12 pointer to the area under the geodesic (meters<sup>2</sup>).
@return e a12 arc length of between point 1 and point 2 (degrees).

e g must have been initialized with a call to geod_init(). e lat1 should be in the range [&minus;90&deg;, 90&deg;]. The function value e a12 equals e s12_a12 if e flags & GEOD_ARCMODE. Any of the ’return’ arguments, e plat2, etc., may be replaced by 0, if you do not need some quantities computed.

With e flags & GEOD_LONG_UNROLL bit set, the longitude is ’unrolled’ so that the quantity e lon2 &minus; e lon1 indicates how many times and in what sense the geodesic encircles the ellipsoid.

Package

cl-proj

Source

geodesic.lisp (file)

Function: geod-direct G LAT1 LON1 AZI1 S12 PLAT2 PLON2 PAZI2

Solve the direct geodesic problem.

@param[in] g a pointer to the geod_geodesic object specifying the ellipsoid.
@param[in] lat1 latitude of point 1 (degrees).
@param[in] lon1 longitude of point 1 (degrees).
@param[in] azi1 azimuth at point 1 (degrees).
@param[in] s12 distance between point 1 and point 2 (meters); it can be negative.
@param[out] plat2 pointer to the latitude of point 2 (degrees). @param[out] plon2 pointer to the longitude of point 2 (degrees). @param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees).

e g must have been initialized with a call to geod_init(). e lat1 should be in the range [&minus;90&deg;, 90&deg;]. The values of e lon2 and e azi2 returned are in the range [&minus;180&deg;, 180&deg;). Any of the ’return’ arguments e plat2, etc., may be replaced by 0, if you do not need some quantities computed.

If either point is at a pole, the azimuth is defined by keeping the longitude fixed, writing e lat = &plusmn;(90&deg; &minus; &epsilon;), and taking the limit &epsilon; &rarr; 0+. An arc length greater that 180&deg; signifies a geodesic which is not a shortest path. (For a prolate ellipsoid, an additional condition is necessary for a shortest path: the longitudinal extent must not exceed of 180&deg;.)

Example, determine the point 10000 km NE of JFK:

struct geod_geodesic g;
double lat, lon;
geod_init(&g, 6378137, 1/298.257223563);
geod_direct(&g, 40.64, -73.78, 45.0, 10e6, &lat, &lon, 0); printf("%.5f %.5fn", lat, lon);

Package

cl-proj

Source

geodesic.lisp (file)

Function: geod-gendirect G LAT1 LON1 AZI1 FLAGS S12_A12 PLAT2 PLON2 PAZI2 PS12 PM12 P-M12 PM21 P-S12

The general direct geodesic problem.

@param[in] g a pointer to the geod_geodesic object specifying the ellipsoid.
@param[in] lat1 latitude of point 1 (degrees).
@param[in] lon1 longitude of point 1 (degrees).
@param[in] azi1 azimuth at point 1 (degrees).
@param[in] flags bitor’ed combination of geod_flags(); e flags & GEOD_ARCMODE determines the meaning of e s12_a12 and e flags & GEOD_LONG_UNROLL ’unrolls’ e lon2.
@param[in] s12_a12 if e flags & GEOD_ARCMODE is 0, this is the distance between point 1 and point 2 (meters); otherwise it is the arc length between point 1 and point 2 (degrees); it can be negative. @param[out] plat2 pointer to the latitude of point 2 (degrees). @param[out] plon2 pointer to the longitude of point 2 (degrees). @param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees). @param[out] ps12 pointer to the distance between point 1 and point 2 (meters).
@param[out] pm12 pointer to the reduced length of geodesic (meters). @param[out] pM12 pointer to the geodesic scale of point 2 relative to point 1 (dimensionless).
@param[out] pM21 pointer to the geodesic scale of point 1 relative to point 2 (dimensionless).
@param[out] pS12 pointer to the area under the geodesic (meters<sup>2</sup>).
@return e a12 arc length of between point 1 and point 2 (degrees).

e g must have been initialized with a call to geod_init(). e lat1 should be in the range [&minus;90&deg;, 90&deg;]. The function value e a12 equals e s12_a12 if e flags & GEOD_ARCMODE. Any of the ’return’ arguments, e plat2, etc., may be replaced by 0, if you do not need some quantities computed.

With e flags & GEOD_LONG_UNROLL bit set, the longitude is ’unrolled’ so that the quantity e lon2 &minus; e lon1 indicates how many times and in what sense the geodesic encircles the ellipsoid.

Package

cl-proj

Source

geodesic.lisp (file)

Function: geod-geninverse G LAT1 LON1 LAT2 LON2 PS12 PAZI1 PAZI2 PM12 P-M12 PM21 P-S12

The general inverse geodesic calculation.

@param[in] g a pointer to the geod_geodesic object specifying the ellipsoid.
@param[in] lat1 latitude of point 1 (degrees).
@param[in] lon1 longitude of point 1 (degrees).
@param[in] lat2 latitude of point 2 (degrees).
@param[in] lon2 longitude of point 2 (degrees).
@param[out] ps12 pointer to the distance between point 1 and point 2 (meters).
@param[out] pazi1 pointer to the azimuth at point 1 (degrees). @param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees). @param[out] pm12 pointer to the reduced length of geodesic (meters). @param[out] pM12 pointer to the geodesic scale of point 2 relative to point 1 (dimensionless).
@param[out] pM21 pointer to the geodesic scale of point 1 relative to point 2 (dimensionless).
@param[out] pS12 pointer to the area under the geodesic (meters<sup>2</sup>).
@return e a12 arc length of between point 1 and point 2 (degrees).

e g must have been initialized with a call to geod_init(). e lat1 and e lat2 should be in the range [&minus;90&deg;, 90&deg;]. Any of the ’return’ arguments e ps12, etc., may be replaced by 0, if you do not need some quantities computed.

Package

cl-proj

Source

geodesic.lisp (file)

Function: geod-genposition L FLAGS S12_A12 PLAT2 PLON2 PAZI2 PS12 PM12 P-M12 PM21 P-S12

The general position function.

@param[in] l a pointer to the geod_geodesicline object specifying the geodesic line.
@param[in] flags bitor’ed combination of geod_flags(); e flags & GEOD_ARCMODE determines the meaning of e s12_a12 and e flags & GEOD_LONG_UNROLL ’unrolls’ e lon2; if e flags & GEOD_ARCMODE is 0, then e l must have been initialized with e caps |= GEOD_DISTANCE_IN. @param[in] s12_a12 if e flags & GEOD_ARCMODE is 0, this is the
distance between point 1 and point 2 (meters); otherwise it is the arc length between point 1 and point 2 (degrees); it can be negative.
@param[out] plat2 pointer to the latitude of point 2 (degrees). @param[out] plon2 pointer to the longitude of point 2 (degrees); requires that e l was initialized with e caps |= GEOD_LONGITUDE.
@param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees). @param[out] ps12 pointer to the distance between point 1 and point 2 (meters); requires that e l was initialized with e caps |= GEOD_DISTANCE.
@param[out] pm12 pointer to the reduced length of geodesic (meters); requires that e l was initialized with e caps |= GEOD_REDUCEDLENGTH. @param[out] pM12 pointer to the geodesic scale of point 2 relative to point 1 (dimensionless); requires that e l was initialized with e caps |= GEOD_GEODESICSCALE.
@param[out] pM21 pointer to the geodesic scale of point 1 relative to point 2 (dimensionless); requires that e l was initialized with e caps |= GEOD_GEODESICSCALE.
@param[out] pS12 pointer to the area under the geodesic (meters<sup>2</sup>); requires that e l was initialized with e caps |= GEOD_AREA.
@return e a12 arc length of between point 1 and point 2 (degrees).

e l must have been initialized with a call to geod_lineinit() with e caps |= GEOD_DISTANCE_IN. The value e azi2 returned is in the range [&minus;180&deg;, 180&deg;). Any of the ’return’ arguments e plat2, etc., may be replaced by 0, if you do not need some quantities computed. Requesting a value which e l is not capable of computing
is not an error; the corresponding argument will not be altered.

With e flags & GEOD_LONG_UNROLL bit set, the longitude is ’unrolled’ so that the quantity e lon2 &minus; e lon1 indicates how many times and in what sense the geodesic encircles the ellipsoid.

Example, compute way points between JFK and Singapore Changi Airport using geod_genposition(). In this example, the points are evenly space in arc length (and so only approximately equally space in distance). This is faster than using geod_position() would be appropriate if drawing the path on a map.
@code{.c}
struct geod_geodesic g;
struct geod_geodesicline l;
double a12, azi1, lat[101], lon[101];
int i;
geod_init(&g, 6378137, 1/298.257223563);
a12 = geod_geninverse(&g, 40.64, -73.78, 1.36, 103.99,
0, &azi1, 0, 0, 0, 0, 0);
geod_lineinit(&l, &g, 40.64, -73.78, azi1, GEOD_LATITUDE | GEOD_LONGITUDE); for (i = 0; i < 101; ++i) {
geod_genposition(&l, 1, i * a12 * 0.01,
lat + i, lon + i, 0, 0, 0, 0, 0, 0);
printf("%.5f %.5fn", lat[i], lon[i]);
}
@endcode

Package

cl-proj

Source

geodesic.lisp (file)

Function: geod-inverse G LAT1 LON1 LAT2 LON2 PS12 PAZI1 PAZI2

Solve the inverse geodesic problem.

@param[in] g a pointer to the geod_geodesic object specifying the ellipsoid.
@param[in] lat1 latitude of point 1 (degrees).
@param[in] lon1 longitude of point 1 (degrees).
@param[in] lat2 latitude of point 2 (degrees).
@param[in] lon2 longitude of point 2 (degrees).
@param[out] ps12 pointer to the distance between point 1 and point 2 (meters).
@param[out] pazi1 pointer to the azimuth at point 1 (degrees). @param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees).

e g must have been initialized with a call to geod_init(). e lat1 and e lat2 should be in the range [&minus;90&deg;, 90&deg;]. The values of e azi1 and e azi2 returned are in the range [&minus;180&deg;, 180&deg;). Any of the ’return’ arguments, e ps12, etc., may be replaced by 0, if you do not need some quantities computed.

If either point is at a pole, the azimuth is defined by keeping the longitude fixed, writing e lat = &plusmn;(90&deg; &minus; &epsilon;), and taking the limit &epsilon; &rarr; 0+.

The solution to the inverse problem is found using Newton’s method. If this fails to converge (this is very unlikely in geodetic applications but does occur for very eccentric ellipsoids), then the bisection method is used to refine the solution.

Example, determine the distance between JFK and Singapore Changi Airport:

@code{.c}
struct geod_geodesic g;
double s12;
geod_init(&g, 6378137, 1/298.257223563);
geod_inverse(&g, 40.64, -73.78, 1.36, 103.99, &s12, 0, 0); printf("%.3fn", s12);
@endcode

Package

cl-proj

Source

geodesic.lisp (file)

Function: geod-lineinit L G LAT1 LON1 AZI1 CAPS

Initialize a geod_geodesicline object.

@param[out] l a pointer to the object to be initialized.
@param[in] g a pointer to the geod_geodesic object specifying the ellipsoid.
@param[in] lat1 latitude of point 1 (degrees).
@param[in] lon1 longitude of point 1 (degrees).
@param[in] azi1 azimuth at point 1 (degrees).
@param[in] caps bitor’ed combination of geod_mask() values specifying the capabilities the geod_geodesicline object should possess, i.e., which quantities can be returned in calls to geod_position() and geod_genposition().

e g must have been initialized with a call to geod_init(). e lat1 should be in the range [&minus;90&deg;, 90&deg;].

The geod_mask values are [see geod_mask()]:
- e caps |= GEOD_LATITUDE for the latitude e lat2; this is
added automatically,
- e caps |= GEOD_LONGITUDE for the latitude e lon2,
- e caps |= GEOD_AZIMUTH for the latitude e azi2; this is
added automatically,
- e caps |= GEOD_DISTANCE for the distance e s12,
- e caps |= GEOD_REDUCEDLENGTH for the reduced length e m12,
- e caps |= GEOD_GEODESICSCALE for the geodesic scales e M12
and e M21,
- e caps |= GEOD_AREA for the area e S12,
- e caps |= GEOD_DISTANCE_IN permits the length of the
geodesic to be given in terms of e s12; without this capability the length can only be specified in terms of arc length.
.
A value of e caps = 0 is treated as GEOD_LATITUDE | GEOD_LONGITUDE | GEOD_AZIMUTH | GEOD_DISTANCE_IN (to support the solution of the ’standard’ direct problem).

Package

cl-proj

Source

geodesic.lisp (file)

Function: geod-polygon-addedge G P AZI S

Add an edge to the polygon or polyline.

@param[in] g a pointer to the geod_geodesic object specifying the ellipsoid.
@param[in,out] p a pointer to the geod_polygon object specifying the polygon.
@param[in] azi azimuth at current point (degrees).
@param[in] s distance from current point to next point (meters).

e g and e p must have been initialized with calls to geod_init() and geod_polygon_init(), respectively. The same e g must be used for all the points and edges in a polygon. This does nothing if no points have been added yet. The e lat and e lon fields of e p give the location of the new vertex.

Package

cl-proj

Source

geodesic.lisp (file)

Function: geod-polygon-addpoint G P LAT LON

Add a point to the polygon or polyline.

@param[in] g a pointer to the geod_geodesic object specifying the ellipsoid.
@param[in,out] p a pointer to the geod_polygon object specifying the polygon.
@param[in] lat the latitude of the point (degrees).
@param[in] lon the longitude of the point (degrees).

e g and e p must have been initialized with calls to geod_init() and geod_polygon_init(), respectively. The same e g must be used for all the points and edges in a polygon. e lat should be in the range [&minus;90&deg;, 90&deg;].

An example of the use of this function is given in the documentation for geod_polygon_compute().

Package

cl-proj

Source

geodesic.lisp (file)

Function: geod-polygon-compute G P REVERSE SIGN PA PP

Return the results for a polygon.

@param[in] g a pointer to the geod_geodesic object specifying the ellipsoid.
@param[in] p a pointer to the geod_polygon object specifying the polygon. @param[in] reverse if non-zero then clockwise (instead of counter-clockwise) traversal counts as a positive area.
@param[in] sign if non-zero then return a signed result for the area if the polygon is traversed in the ’wrong’ direction instead of returning the area for the rest of the earth.
@param[out] pA pointer to the area of the polygon (meters<sup>2</sup>); only set if e polyline is non-zero in the call to geod_polygon_init(). @param[out] pP pointer to the perimeter of the polygon or length of the polyline (meters).
@return the number of points.

The area and perimeter are accumulated at two times the standard floating point precision to guard against the loss of accuracy with many-sided polygons. Only simple polygons (which are not self-intersecting) are allowed. There’s no need to ’close’ the polygon by repeating the first vertex. Set e pA or e pP to zero, if you do not want the corresponding quantity returned.

Example, compute the perimeter and area of the geodesic triangle with vertices (0&deg;N,0&deg;E), (0&deg;N,90&deg;E), (90&deg;N,0&deg;E). @code{.c}
double A, P;
int n;
struct geod_geodesic g;
struct geod_polygon p;
geod_init(&g, 6378137, 1/298.257223563);
geod_polygon_init(&p, 0);

geod_polygon_addpoint(&g, &p, 0, 0);
geod_polygon_addpoint(&g, &p, 0, 90);
geod_polygon_addpoint(&g, &p, 90, 0);
n = geod_polygon_compute(&g, &p, 0, 1, &A, &P);
printf("%d %.8f %.3fn", n, P, A);
@endcode

Package

cl-proj

Source

geodesic.lisp (file)

Function: geod-polygon-init P POLYLINEP

Initialize a geod_polygon object.

@param[out] p a pointer to the object to be initialized.
@param[in] polylinep non-zero if a polyline instead of a polygon.

If e polylinep is zero, then the sequence of vertices and edges added by geod_polygon_addpoint() and geod_polygon_addedge() define a polygon and the perimeter and area are returned by geod_polygon_compute(). If e polylinep is non-zero, then the vertices and edges define a polyline and only the perimeter is returned by geod_polygon_compute().

The area and perimeter are accumulated at two times the standard floating point precision to guard against the loss of accuracy with many-sided polygons. At any point you can ask for the perimeter and area so far.

An example of the use of this function is given in the documentation for geod_polygon_compute().

Package

cl-proj

Source

geodesic.lisp (file)

Function: geod-polygon-testedge G P AZI S REVERSE SIGN PA PP

Return the results assuming a tentative final test point is added via an azimuth and distance; however, the data for the test point is not saved. This lets you report a running result for the perimeter and area as the user moves the mouse cursor. Ordinary floating point arithmetic is used to accumulate the data for the test point; thus the area and perimeter returned are less accurate than if geod_polygon_addedge() and geod_polygon_compute() are used.

@param[in] g a pointer to the geod_geodesic object specifying the ellipsoid.
@param[in] p a pointer to the geod_polygon object specifying the polygon. @param[in] azi azimuth at current point (degrees).
@param[in] s distance from current point to final test point (meters). @param[in] reverse if non-zero then clockwise (instead of counter-clockwise) traversal counts as a positive area.
@param[in] sign if non-zero then return a signed result for the area if the polygon is traversed in the ’wrong’ direction instead of returning the area for the rest of the earth.
@param[out] pA pointer to the area of the polygon (meters<sup>2</sup>); only set if e polyline is non-zero in the call to geod_polygon_init(). @param[out] pP pointer to the perimeter of the polygon or length of the polyline (meters).
@return the number of points.

Package

cl-proj

Source

geodesic.lisp (file)

Function: geod-polygon-testpoint G P LAT LON REVERSE SIGN PA PP

Return the results assuming a tentative final test point is added; however, the data for the test point is not saved. This lets you report a running result for the perimeter and area as the user moves the mouse cursor. Ordinary floating point arithmetic is used to accumulate the data for the test point; thus the area and perimeter returned are less accurate than if geod_polygon_addpoint() and geod_polygon_compute() are used.

@param[in] g a pointer to the geod_geodesic object specifying the ellipsoid.
@param[in] p a pointer to the geod_polygon object specifying the polygon. @param[in] lat the latitude of the test point (degrees).
@param[in] lon the longitude of the test point (degrees).
@param[in] reverse if non-zero then clockwise (instead of counter-clockwise) traversal counts as a positive area.
@param[in] sign if non-zero then return a signed result for the area if the polygon is traversed in the ’wrong’ direction instead of returning the area for the rest of the earth.
@param[out] pA pointer to the area of the polygon (meters<sup>2</sup>); only set if e polyline is non-zero in the call to geod_polygon_init(). @param[out] pP pointer to the perimeter of the polygon or length of the polyline (meters).
@return the number of points.

e lat should be in the range [&minus;90&deg;, 90&deg;].

Package

cl-proj

Source

geodesic.lisp (file)

Function: geod-polygonarea G LATS LONS N PA PP

A simple interface for computing the area of a geodesic polygon.

@param[in] g a pointer to the geod_geodesic object specifying the ellipsoid.
@param[in] lats an array of latitudes of the polygon vertices (degrees). @param[in] lons an array of longitudes of the polygon vertices (degrees). @param[in] n the number of vertices.
@param[out] pA pointer to the area of the polygon (meters<sup>2</sup>). @param[out] pP pointer to the perimeter of the polygon (meters).

e lats should be in the range [&minus;90&deg;, 90&deg;].

Only simple polygons (which are not self-intersecting) are allowed. There’s no need to ’close’ the polygon by repeating the first vertex. The area returned is signed with counter-clockwise traversal being treated as positive.

Example, compute the area of Antarctica:
@code{.c}
double
lats[] = {-72.9, -71.9, -74.9, -74.3, -77.5, -77.4, -71.7, -65.9, -65.7, -66.6, -66.9, -69.8, -70.0, -71.0, -77.3, -77.9, -74.7}, lons[] = {-74, -102, -102, -131, -163, 163, 172, 140, 113,
88, 59, 25, -4, -14, -33, -46, -61};
struct geod_geodesic g;
double A, P;
geod_init(&g, 6378137, 1/298.257223563);
geod_polygonarea(&g, lats, lons, (sizeof lats) / (sizeof lats[0]), &A, &P); printf("%.0f %.2fn", A, P);
@endcode

Package

cl-proj

Source

geodesic.lisp (file)

Function: geod-position L S12 PLAT2 PLON2 PAZI2

@short{Compute the position along a geod_geodesicline.}

@arg[l]{a pointer to the geod_geodesicline object specifying the geodesic line.}
@arg[s12]{distance between point 1 and point 2 (meters); it can be negative.}

param[out] plat2 pointer to the latitude of point 2 (degrees). param[out] plon2 pointer to the longitude of point 2 (degrees); requires that e l was initialized with e caps |= GEOD_LONGITUDE.
param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees).

e l must have been initialized with a call to geod_lineinit() with e caps |= GEOD_DISTANCE_IN. The values of e lon2 and e azi2 returned are in the range [&minus;180&deg;, 180&deg;). Any of the ’return’ arguments e plat2, etc., may be replaced by 0, if you do not need some quantities computed.

Example, compute way points between JFK and Singapore Changi Airport the ’obvious’ way using geod_direct():

@begin{code}
struct geod_geodesic g;
double s12, azi1, lat[101],lon[101];
int i;
geod_init(&g, 6378137, 1/298.257223563);
geod_inverse(&g, 40.64, -73.78, 1.36, 103.99, &s12, &azi1, 0);
for (i = 0; i < 101; ++i) {
geod_direct(&g, 40.64, -73.78, azi1, i * s12 * 0.01, lat + i, lon + i, 0); printf("%.5f %.5fn", lat[i], lon[i]);
}
@end{code}

A faster way using geod_position():

@begin{code}
struct geod_geodesic g;
struct geod_geodesicline l;
double s12, azi1, lat[101],lon[101];
int i;
geod_init(&g, 6378137, 1/298.257223563);
geod_inverse(&g, 40.64, -73.78, 1.36, 103.99, &s12, &azi1, 0); geod_lineinit(&l, &g, 40.64, -73.78, azi1, 0);
for (i = 0; i < 101; ++i) {
geod_position(&l, i * s12 * 0.01, lat + i, lon + i, 0);
printf("%.5f %.5fn", lat[i], lon[i]);
}
@end{code}

Package

cl-proj

Source

geodesic.lisp (file)

Function: missile-range LAT LON RADIUS &key COUNT OUT

Produce a GeoJSON Polygon circumscribing the ciricle with the
given radius (in meters) with the given center.

Count specifies the number of points the Polygon will contain, the
higher the number, the smoother the circle.

Example: area within Hwasong-12 missile range when fired from
Pyongyang? NB: here we assume the range to be 4500, however, Wikipedia mentions estimates within range of 3700-6000 km.

(with-open-file (out "range.json" :direction :output :if-exists :supersede) (missile-range 39.033333 125.75 (* 4500 1000) :out out))

The resulting GeoJSON file can be converted to other formats (like
Google Earth-compatible KML) with the ogr2ogr command-line
application:

ogr2ogr -f KML range.kml range.json

Package

cl-proj

Source

util.lisp (file)

Function: polygon-test-edge G P AZI S &key REVERSE SIGN
Package

cl-proj

Source

geodesic.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.3 Generic functions

Generic Function: pointer OBJECT
Generic Function: (setf pointer) NEW-VALUE OBJECT
Package

cl-proj

Methods
Method: pointer (GEO-OBJECT geo-object)

automatically generated reader method

Source

geodesic.lisp (file)

Method: (setf pointer) NEW-VALUE (GEO-OBJECT geo-object)

automatically generated writer method

Source

geodesic.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

6.2.4 Classes

Class: geo-object ()
Package

cl-proj

Source

geodesic.lisp (file)

Direct superclasses

standard-object (class)

Direct subclasses
Direct methods
  • pointer (method)
  • pointer (method)
Direct slots
Slot: pointer
Type

(or null cffi-sys:foreign-pointer)

Initargs

:pointer

Readers

pointer (generic function)

Writers

(setf pointer) (generic function)

Class: geod-geodesic-tclass ()
Package

geodesic-types

Source

/home/quickref/.cache/common-lisp/sbcl-1.4.0-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-proj-20171227-hg/src/grovel-geodesic.processed-grovel-file

Direct superclasses
  • translatable-foreign-type (class)
  • foreign-struct-type (class)
Class: geod-geodesicline-tclass ()
Package

geodesic-types

Source

/home/quickref/.cache/common-lisp/sbcl-1.4.0-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-proj-20171227-hg/src/grovel-geodesic.processed-grovel-file

Direct superclasses
  • translatable-foreign-type (class)
  • foreign-struct-type (class)
Class: geod-polygon-tclass ()
Package

geodesic-types

Source

/home/quickref/.cache/common-lisp/sbcl-1.4.0-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-proj-20171227-hg/src/grovel-geodesic.processed-grovel-file

Direct superclasses
  • translatable-foreign-type (class)
  • foreign-struct-type (class)
Class: proj-uv-tclass ()
Package

proj-types

Source

/home/quickref/.cache/common-lisp/sbcl-1.4.0-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/cl-proj-20171227-hg/src/grovel-proj-api.processed-grovel-file

Direct superclasses
  • translatable-foreign-type (class)
  • foreign-struct-type (class)

Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   C   F   L   M  
Index Entry  Section

C
cl-proj.asd: The cl-proj<dot>asd file
cl-proj/src: The cl-proj/src module
cl-proj/src/geodesic.lisp: The cl-proj/src/geodesic<dot>lisp file
cl-proj/src/grovel-geodesic.lisp: The cl-proj/src/grovel-geodesic<dot>lisp file
cl-proj/src/grovel-proj-api.lisp: The cl-proj/src/grovel-proj-api<dot>lisp file
cl-proj/src/package.lisp: The cl-proj/src/package<dot>lisp file
cl-proj/src/proj-api.lisp: The cl-proj/src/proj-api<dot>lisp file
cl-proj/src/util.lisp: The cl-proj/src/util<dot>lisp file

F
File, Lisp, cl-proj.asd: The cl-proj<dot>asd file
File, Lisp, cl-proj/src/geodesic.lisp: The cl-proj/src/geodesic<dot>lisp file
File, Lisp, cl-proj/src/grovel-geodesic.lisp: The cl-proj/src/grovel-geodesic<dot>lisp file
File, Lisp, cl-proj/src/grovel-proj-api.lisp: The cl-proj/src/grovel-proj-api<dot>lisp file
File, Lisp, cl-proj/src/package.lisp: The cl-proj/src/package<dot>lisp file
File, Lisp, cl-proj/src/proj-api.lisp: The cl-proj/src/proj-api<dot>lisp file
File, Lisp, cl-proj/src/util.lisp: The cl-proj/src/util<dot>lisp file

L
Lisp File, cl-proj.asd: The cl-proj<dot>asd file
Lisp File, cl-proj/src/geodesic.lisp: The cl-proj/src/geodesic<dot>lisp file
Lisp File, cl-proj/src/grovel-geodesic.lisp: The cl-proj/src/grovel-geodesic<dot>lisp file
Lisp File, cl-proj/src/grovel-proj-api.lisp: The cl-proj/src/grovel-proj-api<dot>lisp file
Lisp File, cl-proj/src/package.lisp: The cl-proj/src/package<dot>lisp file
Lisp File, cl-proj/src/proj-api.lisp: The cl-proj/src/proj-api<dot>lisp file
Lisp File, cl-proj/src/util.lisp: The cl-proj/src/util<dot>lisp file

M
Module, cl-proj/src: The cl-proj/src module

Jump to:   C   F   L   M  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   %   (  
C   D   F   G   I   M   P   R   S  
Index Entry  Section

%
%var-accessor-pj-errno: Internal functions
%var-accessor-pj-release: Internal functions

(
(setf %var-accessor-pj-errno): Internal functions
(setf %var-accessor-pj-release): Internal functions
(setf pointer): Internal generic functions
(setf pointer): Internal generic functions

C
convert-flags-to-foreign: Internal functions

D
dec-to-merc-ex: Internal functions
deg-to-rad: Exported macros
deg-to-rad-array: Exported functions
direct-problem: Exported functions
dms-to-dec: Exported functions

F
Function, %var-accessor-pj-errno: Internal functions
Function, %var-accessor-pj-release: Internal functions
Function, (setf %var-accessor-pj-errno): Internal functions
Function, (setf %var-accessor-pj-release): Internal functions
Function, convert-flags-to-foreign: Internal functions
Function, dec-to-merc-ex: Internal functions
Function, deg-to-rad-array: Exported functions
Function, direct-problem: Exported functions
Function, dms-to-dec: Exported functions
Function, general-direct-problem: Internal functions
Function, general-inverse-problem: Exported functions
Function, general-position: Exported functions
Function, geo-position: Exported functions
Function, geo-transform: Exported functions
Function, geod-direct: Internal functions
Function, geod-gendirect: Internal functions
Function, geod-geninverse: Internal functions
Function, geod-genposition: Internal functions
Function, geod-init: Exported functions
Function, geod-inverse: Internal functions
Function, geod-lineinit: Internal functions
Function, geod-polygon-addedge: Internal functions
Function, geod-polygon-addpoint: Internal functions
Function, geod-polygon-compute: Internal functions
Function, geod-polygon-init: Internal functions
Function, geod-polygon-testedge: Internal functions
Function, geod-polygon-testpoint: Internal functions
Function, geod-polygonarea: Internal functions
Function, geod-position: Internal functions
Function, inverse-problem: Exported functions
Function, make-geo-line: Exported functions
Function, make-geo-polygon: Exported functions
Function, make-geodesic: Exported functions
Function, missile-range: Internal functions
Function, parse-degrees: Exported functions
Function, perpendicular-distance: Exported functions
Function, pj-acquire-lock: Exported functions
Function, pj-apply-gridshift: Exported functions
Function, pj-cleanup-lock: Exported functions
Function, pj-compare-datums: Exported functions
Function, pj-dalloc: Exported functions
Function, pj-datum-transform: Exported functions
Function, pj-deallocate-grids: Exported functions
Function, pj-free: Exported functions
Function, pj-fwd: Exported functions
Function, pj-geocentric-to-geodetic: Exported functions
Function, pj-geodetic-to-geocentric: Exported functions
Function, pj-get-def: Exported functions
Function, pj-get-errno-ref: Exported functions
Function, pj-get-release: Exported functions
Function, pj-init: Exported functions
Function, pj-init-plus: Exported functions
Function, pj-inv: Exported functions
Function, pj-is-geocent: Exported functions
Function, pj-is-latlong: Exported functions
Function, pj-latlong-from-proj: Exported functions
Function, pj-malloc: Exported functions
Function, pj-pr-list: Exported functions
Function, pj-release-lock: Exported functions
Function, pj-set-finder: Exported functions
Function, pj-set-searchpath: Exported functions
Function, pj-strerrno: Exported functions
Function, pj-transform: Exported functions
Function, polygon-add-edge: Exported functions
Function, polygon-add-point: Exported functions
Function, polygon-area: Exported functions
Function, polygon-compute: Exported functions
Function, polygon-test-edge: Internal functions
Function, polygon-test-point: Exported functions
Function, render-point: Exported functions
Function, simplify: Exported functions

G
general-direct-problem: Internal functions
general-inverse-problem: Exported functions
general-position: Exported functions
Generic Function, (setf pointer): Internal generic functions
Generic Function, pointer: Internal generic functions
geo-position: Exported functions
geo-transform: Exported functions
geod-direct: Internal functions
geod-gendirect: Internal functions
geod-geninverse: Internal functions
geod-genposition: Internal functions
geod-init: Exported functions
geod-inverse: Internal functions
geod-lineinit: Internal functions
geod-polygon-addedge: Internal functions
geod-polygon-addpoint: Internal functions
geod-polygon-compute: Internal functions
geod-polygon-init: Internal functions
geod-polygon-testedge: Internal functions
geod-polygon-testpoint: Internal functions
geod-polygonarea: Internal functions
geod-position: Internal functions

I
inverse-problem: Exported functions

M
Macro, deg-to-rad: Exported macros
make-geo-line: Exported functions
make-geo-polygon: Exported functions
make-geodesic: Exported functions
Method, (setf pointer): Internal generic functions
Method, pointer: Internal generic functions
missile-range: Internal functions

P
parse-degrees: Exported functions
perpendicular-distance: Exported functions
pj-acquire-lock: Exported functions
pj-apply-gridshift: Exported functions
pj-cleanup-lock: Exported functions
pj-compare-datums: Exported functions
pj-dalloc: Exported functions
pj-datum-transform: Exported functions
pj-deallocate-grids: Exported functions
pj-free: Exported functions
pj-fwd: Exported functions
pj-geocentric-to-geodetic: Exported functions
pj-geodetic-to-geocentric: Exported functions
pj-get-def: Exported functions
pj-get-errno-ref: Exported functions
pj-get-release: Exported functions
pj-init: Exported functions
pj-init-plus: Exported functions
pj-inv: Exported functions
pj-is-geocent: Exported functions
pj-is-latlong: Exported functions
pj-latlong-from-proj: Exported functions
pj-malloc: Exported functions
pj-pr-list: Exported functions
pj-release-lock: Exported functions
pj-set-finder: Exported functions
pj-set-searchpath: Exported functions
pj-strerrno: Exported functions
pj-transform: Exported functions
pointer: Internal generic functions
pointer: Internal generic functions
polygon-add-edge: Exported functions
polygon-add-point: Exported functions
polygon-area: Exported functions
polygon-compute: Exported functions
polygon-test-edge: Internal functions
polygon-test-point: Exported functions

R
render-point: Exported functions

S
simplify: Exported functions

Jump to:   %   (  
C   D   F   G   I   M   P   R   S  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   +  
C   P   S  
Index Entry  Section

+
+deg-to-rad+: Exported constants
+equatorial-radius+: Exported constants
+flattening+: Exported constants
+geodesic-version+: Exported constants
+geodesic-version-major+: Exported constants
+geodesic-version-minor+: Exported constants
+geodesic-version-patch+: Exported constants
+pj-version+: Exported constants
+rad-to-deg+: Exported constants

C
Constant, +deg-to-rad+: Exported constants
Constant, +equatorial-radius+: Exported constants
Constant, +flattening+: Exported constants
Constant, +geodesic-version+: Exported constants
Constant, +geodesic-version-major+: Exported constants
Constant, +geodesic-version-minor+: Exported constants
Constant, +geodesic-version-patch+: Exported constants
Constant, +pj-version+: Exported constants
Constant, +rad-to-deg+: Exported constants
Constant, size-of-geod-geodesic: Internal constants
Constant, size-of-geod-geodesicline: Internal constants
Constant, size-of-geod-polygon: Internal constants
Constant, size-of-proj-uv: Internal constants

P
pj-errno: Exported symbol macros
pj-release: Exported symbol macros
pointer: Internal classes

S
size-of-geod-geodesic: Internal constants
size-of-geod-geodesicline: Internal constants
size-of-geod-polygon: Internal constants
size-of-proj-uv: Internal constants
Slot, pointer: Internal classes
Symbol Macro, pj-errno: Exported symbol macros
Symbol Macro, pj-release: Exported symbol macros

Jump to:   +  
C   P   S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   G   P   S  
Index Entry  Section

C
cl-proj: The cl-proj system
cl-proj: The cl-proj package
cl-proj-asd: The cl-proj-asd package
Class, geo-line: Exported classes
Class, geo-object: Internal classes
Class, geo-polygon: Exported classes
Class, geod-geodesic-tclass: Internal classes
Class, geod-geodesicline-tclass: Internal classes
Class, geod-polygon-tclass: Internal classes
Class, geodesic: Exported classes
Class, proj-uv-tclass: Internal classes

G
geo-line: Exported classes
geo-object: Internal classes
geo-polygon: Exported classes
geod-geodesic-tclass: Internal classes
geod-geodesicline-tclass: Internal classes
geod-polygon-tclass: Internal classes
geodesic: Exported classes
geodesic-types: The geodesic-types package

P
Package, cl-proj: The cl-proj package
Package, cl-proj-asd: The cl-proj-asd package
Package, geodesic-types: The geodesic-types package
Package, proj-types: The proj-types package
proj-types: The proj-types package
proj-uv-tclass: Internal classes

S
System, cl-proj: The cl-proj system

Jump to:   C   G   P   S