• Antelope Release 5.5 Mac OS X 10.8.5 2015-04-21

 

NAME

polycode, polytype, writePolygonData, readPolygon, isGeographicallyInside, inWhichPolygons, windrose distance_to_polygon, distanceToPolygon - routines for polygon handling

SYNOPSIS

#include "polygon.h"

int polycode(char *type)

char *polytype(int code)

int writePolygonData(Dbptr db, Point *poly,
	int npoints, char *pname, int closed,
	int level, char *ptype, char *auth,
	char *dir, char *dfile, int pcode);

int readPolygon(Dbptr db, Point **Poly);

Dbptr inWhichPolygons(Dbptr db,Point P);

char *windrose(double azimuth);

int isGeographicallyInside(Point P, Point *polygon, int n);

double distanceToPolygon(Dbptr db,Point P);

double distance_to_polygon(Point P, Point *polygon, int n);

SUPPORT


Contributed code: NO BRTT support.
THIS PIECE OF SOFTWARE WAS CONTRIBUTED BY THE ANTELOPE USER COMMUNITY. BRTT DISCLAIMS ALL OWNERSHIP, LIABILITY, AND SUPPORT FOR THIS PIECE OF SOFTWARE.

FOR HELP WITH THIS PIECE OF SOFTWARE, PLEASE CONTACT THE CONTRIBUTING AUTHOR.

DESCRIPTION

polycode, polytype

These routines translate from textual description to integers. Currently, the following types are supported:
s4 -> sun4 byte integer
i4 -> intel order 4 byte integer
t4 -> sun 4 byte float
u4 -> intel order 4 byte float
Note that when integer are selected as storage type, the actual values are multiplied by 1e6 to preserve some of the original resolution. polytype returns -1 if nothing is found, polycode returns - in that case.

windrose

returns the direction in textual form -> N, NNE,NE,... Note that the string has to be freed by the user.

writePolygonData

db 	-> database pointer must be in schema polygon1.2
poly	-> vertices
npoints	-> number of vertices
pname	-> label of polygon, e.g. "border of Austria"
closed	-> closed flag, distinction between open polylines and closed polygons
level	-> integer allowing different levels of accuracy
ptype	-> type of polygon, e.g. "cb" (could mean coutry border)
auth	-> author
dir,dfile
	-> file and path for storage. If NULL, some default values are used.
pcode	-> storage type (see polycode above)
writes polygon data to a file and fills a database row pointing to that file. returns dbINVALID or record number if successful.

readPolygon

reads Polygon data into array Polygon, returns number of vertices.

isGeographicallyInside

returns TRUE (1) if point P falls entirely in Polygon P (with n vertices)

inWhichPolygons

returns all rows of database db where point P falls into.

distance_to_polygon

returns minimum distance in degrees to a given polygon using an algorithm by Paul Burke (1988).

distanceToPolygon

returns minimum distance from a given point to polygons in a database.

LIBRARY

-lpolygon

DIAGNOSTICS

The error messages should tell what went wrong...

SEE ALSO

dbhelp polygon1.2

perlpolygon(3p)

winding(3p)

http://paulbourke.net/geometry/pointlineplane/

BUGS AND CAVEATS

All vertices of a polygon and the point under test for inclusion must be within the same hemisphere. The routine windrose does not exactly fit in here, but for the moment beeing I need it somewhere...

AUTHOR

These routines are based on a Pascal library I wrote many years ago. As this is based on the same BSSA article as Kent Lindquists (Lindquist Consulting) winding number routines, the similarities are apparent.
Nikolaus Horn, 2003, 2014

ZAMG / Vienna, Nikolaus.Horn@zamg.ac.at

Antelope User Group Contributed Software
Printer icon