Common Lisp Package: 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.

README:

FUNCTION

Public

DMS-TO-DEC (DEG &OPTIONAL (MIN 0.0d0) (SEC 0.0d0))

@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}

PARSE-DEGREES (PATTERN STR &KEY DEC)

Utility function to parse lines like: 47°7'50 If an optional key DEC is set to true converts parsed data into decimal representation with DMS-TO-DEC function.

PERPENDICULAR-DISTANCE (POINT LINE1 LINE2)

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

PJ-FWD (ARG0 ARG1)

Forward cartographic projection.

PJ-INIT-PLUS (ARG0)

@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}.

PJ-INV (ARG0 ARG1)

Inverse cartographic projection.

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}.

RENDER-POINT (OX OY EXTENT SIZE &KEY (SRC-CS +proj=latlong +ellps=WGS84 +datum=WGS84) (DST-CS +proj=utm +zone=35 +ellps=WGS84 +datum=WGS84 +units=m +no_defs) (DEBUG NIL))

@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}

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.}

Undocumented

PJ-ACQUIRE-LOCK

PJ-APPLY-GRIDSHIFT (ARG0 ARG1 POINT_COUNT POINT_OFFSET X Y Z)

PJ-CLEANUP-LOCK

PJ-COMPARE-DATUMS (SRCDEFN DSTDEFN)

PJ-DALLOC (ARG0)

PJ-DATUM-TRANSFORM (SRC DST POINT_COUNT POINT_OFFSET X Y Z)

PJ-DEALLOCATE-GRIDS

PJ-FREE (ARG0)

PJ-GEOCENTRIC-TO-GEODETIC (A ES POINT_COUNT POINT_OFFSET X Y Z)

PJ-GEODETIC-TO-GEOCENTRIC (A ES POINT_COUNT POINT_OFFSET X Y Z)

PJ-GET-DEF (ARG0 ARG1)

PJ-GET-ERRNO-REF

PJ-GET-RELEASE

PJ-INIT (ARG0 ARG1)

PJ-IS-GEOCENT (ARG0)

PJ-IS-LATLONG (ARG0)

PJ-LATLONG-FROM-PROJ (ARG0)

PJ-MALLOC (ARG0)

PJ-PR-LIST (ARG0)

PJ-RELEASE-LOCK

PJ-SET-FINDER (ARG0)

PJ-SET-SEARCHPATH (COUNT PATH)

PJ-STRERRNO (ARG0)

Private

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}

Undocumented

%VAR-ACCESSOR-PJ-ERRNO

SETF%VAR-ACCESSOR-PJ-ERRNO (VALUE)

%VAR-ACCESSOR-PJ-RELEASE

SETF%VAR-ACCESSOR-PJ-RELEASE (VALUE)

CLASS

Private

Undocumented

PROJUV-TCLASS

CONSTANT

Public

Undocumented

+DEG-TO-RAD+

+PJ-VERSION+

+RAD-TO-DEG+