Common Lisp Package: GEO

README:

FUNCTION

Public

BEARING-DIFFERENCE (BEARING1 BEARING2)

Returns the difference between BEARING1 and BEARING2. The result will be in the range [-pi,+pi). Note: this is more correct than simply taking (- BEARING1 BEARING2).

BEARINGS (POINT1 POINT2 POINT3)

Returns the final bearing of travel from POINT1 to POINT2, the relative bearing required to then travel on to POINT3, and the initial bearing of travel from POINT2 to POINT3.

CLOSEST-POINT (POINT POINTS &KEY (KEY #'IDENTITY))

Returns the closest point of the given list of POINTS to the given reference POINT. POINTS must not be empty. If KEY is supplied, it will be applied to each item of POINTS, and is expected to return the point to be used for comparison with the reference POINT. In this case, it is the original item from POINTS--which may be a non-point, and not the return value from KEY--that is returned.

COERCE-POINT (POINT POINT-TYPE COORDINATE-TYPE)

Coerces POINT to be an instance of POINT-TYPE with coordinates of COORDINATE-TYPE.

DESCRIBE-BEARING (RADIANS)

Given a bearing in radians, returns a symbol describing its direction.

DESCRIBE-RELATIVE-BEARING (RADIANS)

Given a relative bearing in radians in the range [-pi,+pi), returns two symbols describing its direction (LEFT, NIL, RIGHT) and absolute angle (STRAIGHT, OBTUSE, RIGHT, ACUTE, REVERSE). Note that angle descriptions are approximate and intended for human consumption.

DISTANCE-BETWEEN (POINT1 POINT2)

Returns the distance from point1 to point2.

DOUGLAS-PEUCKER (POINTS THRESHOLD-DISTANCE &OPTIONAL SLOW-AND-ACCURATE-P)

Simplifies the polyline expressed by POINTS. The result is a vector, parallel to POINTS, of either NIL (the corresponding point has been discarded), T (the corresponding point is an endpoint), or a DISTANCE (the distance between the point and the "parent" line it extended from internally; longer means more prominent). When SLOW-AND-ACCURATE-P is true, distance calculations from points to line segments are made more precise by finding the approximate closest point on the line segment, using the slow, O(log2 n) CLOSEST-POINT-ON method (to an accuracy of THRESHOLD-DISTANCE). Otherwise, a faster method is used, which is accurate e.g. on a Spokane<-->Portland scale but not as accurate on a Seattle<-->Washington, D.C. scale.

FINAL-BEARING (POINT1 POINT2)

Returns the final bearing to head from POINT1 to POINT2, in radians.

FINAL-BEARING% (REVERSE-INITIAL-BEARING)

Given an initial bearing from POINT2 to POINT1 (REVERSE-INITIAL-BEARING), returns the final bearing to head from POINT1 to POINT2, in radians.

GOOGLE-POLYLINE (POINTS &KEY POLYLINE-STREAM LEVELS-STREAM PREROUND-P (SIMPLIFICATION-THRESHOLD (DISTANCE-METERS 1)) (ZOOM-FACTOR 2) (NUM-LEVELS 18))

Encodes the given list of POINTS with Google's encoded polyline coding. The result is two sequences of characters: POLYLINE-STREAM determines how the encoded polyline string is returned, and LEVELS-STREAM determines how the encoded point-levels string is returned. The possible values for both parameters are NIL, to return the result as a string; T, to write the result to *STANDARD-OUTPUT*; or a stream, to write the result to that stream. When both results are returned as strings, this function returns encoded polyline string and the encoded point-levels string; otherwise, it returns only a single string, or no values. PREROUND-P, when true, pre-rounds point coordinates to the Google encoded real precision of 10**-5. This yields better registration with other map features, such as streets, and may result in better polyline simplification. This is slower, but won't be noticably so with polylines that have on the order of 1000 points. SIMPLIFICATION-THRESHOLD denotes the resolution that the polyline will be simplified to. ZOOM-FACTOR is roughly the factor of magnification with each zoom-in operation of the Google Map. This should match your "zoomFactor" argument to GPolyline.fromEncoded(). NUM-LEVELS is the number of zoom-levels to encode the polyline with. Ideally, this should be equal to the number of zoom-levels your map has: G_NORMAL_MAPs have 18 zoom levels. This should match your "numLevels" argument to GPolyline.fromEncoded(). Each point must be WGS-84.

GOOGLE-POLYLINE-NON-NEGATIVE-INTEGER (N STREAM)

Encodes a non-negative integer N with Google's encoded polyline coding. The result is a sequence of characters which is written to STREAM.

GOOGLE-POLYLINE-REAL (N STREAM)

Encodes a real number N with Google's encoded polyline coding. The result is a sequence of characters which is written to STREAM.

GOOGLE-POLYLINE-SIGNED-INTEGER (N STREAM)

Encodes an integer N with Google's encoded polyline coding. The result is a sequence of characters which is written to STREAM.

GREATEST-DISTANCE (POINT1 POINT2 &REST REST-POINTS)

Returns the greatest distance between any two of the given points.

INITIAL-BEARING (POINT1 POINT2)

Returns the initial bearing to head from point1 to point2, in radians.

INTERPOLATE-BETWEEN-POINTS (POINT1 POINT2 PROPORTION)

Returns the point that occurs PROPORTION of the distance between POINT1 and POINT2.

NORMALIZE-RADIANS (RADIANS)

Normalizes the RADIANS to the range [0,2pi).

POINT-EQUAL (P1 P2)

Returns whether the two given points are within one millionth of a degree of each other in both latitude and longitude.

POINT-FROM-POINT-IN-DIRECTION (POINT INITIAL-BEARING DISTANCE)

Given a starting POINT, an INITIAL-BEARING (in radians), and a distance, returns the point you'd end up at. (POINT-FROM-POINT-IN-DIRECTION POINT INITIAL-BEARING DISTANCE) = (POINT-FROM-POINT-IN-DIRECTION POINT (FINAL-BEARING% INITIAL-BEARING) (DISTANCE- DISTANCE))

POLYGON (VERTICES)

Creates a closed, non-self-intersecting polygon with POINTs given in VERTICES.

RELATIVE-BEARING (POINT1 POINT2 POINT3)

Having travelled from POINT1 to POINT2, returns the relative bearing to then travel from POINT2 to POINT3, in radians in the range [-pi,+pi).

RELATIVE-BEARING% (INITIAL-BEARING FINAL-BEARING)

Given a FINAL-BEARING from POINT1 to POINT2 and an INITIAL-BEARING from POINT2 to POINT3, returns the relative bearing in radians in the range [-pi,+pi).

REVERSE (SEQUENCE)

Return a new sequence containing the same elements but in reverse order.

Undocumented

CENTIMETERS (DISTANCE)

DECIMETERS (DISTANCE)

DEGREES->RADIANS (DEGREES)

DISTANCE* (&REST DISTANCES)

DISTANCE+ (&REST DISTANCES)

DISTANCE- (&REST DISTANCES)

DISTANCE-ABS (DISTANCE)

DISTANCE-CENTIMETERS (CENTIMETERS)

DISTANCE-DECIMETERS (DECIMETERS)

DISTANCE-FEET (FEET)

DISTANCE-FURLONGS (FURLONGS)

DISTANCE-INCHES (INCHES)

DISTANCE-KILOMETERS (KILOMETERS)

DISTANCE-MAX (&REST DISTANCES)

DISTANCE-METERS (METERS)

DISTANCE-MICROMETERS (MICROMETERS)

DISTANCE-MILES (MILES)

DISTANCE-MILLIMETERS (MILLIMETERS)

DISTANCE-MIN (&REST DISTANCES)

DISTANCE-MINUSP (DISTANCE)

DISTANCE-NANOMETERS (NANOMETERS)

DISTANCE-PLUSP (DISTANCE)

DISTANCE-YARDS (YARDS)

DISTANCE-ZEROP (DISTANCE)

DISTANCE/ (&REST DISTANCES)

DISTANCE/= (&REST DISTANCES)

DISTANCE< (&REST DISTANCES)

DISTANCE<= (&REST DISTANCES)

DISTANCE= (&REST DISTANCES)

DISTANCE> (&REST DISTANCES)

DISTANCE>= (&REST DISTANCES)

FEET (DISTANCE)

FURLONGS (DISTANCE)

GOOGLE-POLYLINE-LEVELS (DISTANCES SIMPLIFICATION-THRESHOLD ZOOM-FACTOR NUM-LEVELS STREAM)

GOOGLE-POLYLINE-POINTS (POINTS STREAM)

INCHES (DISTANCE)

KILOMETERS (DISTANCE)

LINE-SEGMENT (POINT1 POINT2)

METERS (DISTANCE)

MICROMETERS (DISTANCE)

MIDPOINT (POINTS)

MIDPOINT-CARTESIAN (POINTS)

MILES (DISTANCE)

MILLIMETERS (DISTANCE)

NANOMETERS (DISTANCE)

POINT-CARTESIAN (X Y Z)

POINT-DEG (LATITUDE LONGITUDE)

POINT-RAD (LATITUDE LONGITUDE)

RADIANS->DEGREES (RADIANS)

SPHERE-CENTRAL-ANGLE (POINT1 POINT2)

YARDS (DISTANCE)

Private

ASSOC* (ITEM ALIST &KEY (KEY #'IDENTITY) (TEST #'EQL) (DEFAULT 'NIL))

Like ASSOC, but returns the CDR of the matching entry, or DEFAULT if there was no match. (ASSOC* ...) is a SETF-able place. e.g. (defparameter *test-alist* '()) => *TEST-ALIST* (assoc* 'a *test-alist*) => NIL (push 1 (assoc* 'a *test-alist*)) => (1) (push 2 (assoc* 'a *test-alist*)) => (2 1) (assoc* 'a *test-alist*) => (2 1) *test-alist* => ((A 2 1)) (setf (assoc* 'b *test-alist*) 'notalist) => NOTALIST (setf (assoc* 'a *test-alist*) 'notalist) => NOTALIST (assoc* 'a *test-alist*) => NOTALIST *test-alist* => ((B . NOTALIST) (A . NOTALIST))

COMPOSE (&REST FUNCTIONS)

Returns the composition of a sequence of functions (designated by FUNCTIONS), yielding a new function. The new function passes all its arguments to the last given function. Each other given function gets called, from last to first, with the values of the call of its successive function. The new function returns all the values returned by the first given function. For single-argument functions a and b, and single-value functions b and c: (FUNCALL (COMPOSE a b c) x y z) == (a (b (c x y z))) For any function f: (COMPOSE f) == f For any values x, y, and z: COMPOSE == VALUES (FUNCALL (COMPOSE)) => ; no value (FUNCALL (COMPOSE) x) => x (FUNCALL (COMPOSE) x y z) => x y z

DISTANCE-OP (FUNCTION)

Given a function which takes any number of numbers and returns any number of numbers, returns a modified version which instead takes any number of numbers or distances (coercing to meters) and returns distance values.

Undocumented

CARTESIAN->SPHERICAL-COORDS (X Y Z)

DISTANCE-PICOMETERS (PICOMETERS)

HAVERSINE (X)

MEAN (VALUES)

NSORT (SEQUENCE PREDICATE &KEY (KEY NIL KEY-SPEC-P))

NSTABLE-SORT (SEQUENCE PREDICATE &KEY (KEY NIL KEY-SPEC-P))

PICOMETERS (DISTANCE)

SORT (SEQUENCE PREDICATE &KEY (KEY NIL KEY-SPEC-P))

SQUARE (N)

STABLE-SORT (SEQUENCE PREDICATE &KEY (KEY NIL KEY-SPEC-P))

MACRO

Private

DEFDISTANCE-UNIT (PLURAL-NAME MULTIPLIER REFERENCE-UNIT)

Define that one distance unit "plural-name" equals "multiplier" "reference-unit"s, where plural-name and reference-unit are the plural names of units of length, as symbols, and multiplier is a side-effect-free Lisp expression evaluating to a constant number. Where NAME is the given plural-name, defines a constructor function DISTANCE-NAME and an accessor method NAME (which depend on similarly-named constructors and accessors of the reference unit).

LAMBDA* (ARGS &BODY BODY)

Creates a function. Takes an extended, rather than an ordinary, lambda list.

GENERIC-FUNCTION

Public

BOUNDING-BOX (OBJECT)

Returns the bounding box of the given object, as a RECTANGLES:RECTANGLE. The resulting rectangle must list two coordinates for each sequence: latitude and longitude, both in degrees.

CLOSEST-POINT-ON (OBJECT POINT &OPTIONAL PRECISION)

Returns the point on the OBJECT closest to the POINT, to the given accuracy (default 1dm).

CONTAINS? (CONTAINING-OBJ OBJ)

Returns whether OBJ is contained within CONTAINING-OBJ.

INTERSECTION (LINE1 LINE2)

Returns a new point where the two given lines intersect, or nil if they do not, or if they have infinite intersections.

POINT->CARTESIAN (POINT)

Coerces the given spherical or cartesian point to a cartesian-coordinate POINT. For spherical points, the radius of the sphere is assumed to be 1.

POINT->SPHERICAL (POINT)

Coerces the given spherical or cartesian point to a spherical-coordinate POINT. For cartesian points, the altitude is lost.

POINT-EQL (POINT1 POINT2)

Returns whether the two given points express the exact same value.

POINT-HASH-KEY (POINT)

Returns a value that is unique for POINT for the predicate #'EQUALP.

RATIONAL-DISTANCE (DISTANCE)

Returns a distance whose value is expressed by a number of type RATIONAL.

RATIONAL-POINT-CARTESIAN (POINT-CARTESIAN)

Returns a point-cartesian based on a rational-type number, like RATIONAL.

SLOPE (LINE)

Returns the slope of the given line, as a number (or nil for infinity).

Undocumented

LATITUDE-DEG (POINT)

LATITUDE-RAD (POINT)

LONGITUDE-DEG (POINT)

LONGITUDE-RAD (POINT)

Private

Undocumented

COERCE-METERS (N)

SLOT-ACCESSOR

Public

EDGES (OBJECT)

Alternative representation as a sequence of LINE-SEGMENTs.

LATITUDE-RADS (OBJECT)

The radians latitude of each vertex of POINTS, in sequence, as a double float. Included for optimizations.

LONGITUDE-RADS (OBJECT)

The radians longitude of each vertex of POINTS, in sequence, as a double float. Included for optimizations.

VERTICES (OBJECT)

The POINTs comprising this polygon.

Undocumented

POINT1 (OBJECT)

POINT2 (OBJECT)

X (OBJECT)

Y (OBJECT)

Z (OBJECT)

VARIABLE

Public

Undocumented

*EARTH-QUADRATIC-MEAN-RADIUS-M*

*PRINT-POINT-AS*

CLASS

Public

Undocumented

DISTANCE

LINE-SEGMENT (POINT1 POINT2)

POINT

POINT-CARTESIAN (X Y Z)

POINT-DEG (LATITUDE LONGITUDE)

POINT-RAD (LATITUDE LONGITUDE)

POLYGON (VERTICES)