1 #ifndef R_SP_H
2 #define R_SP_H
3 
4 #ifdef SP_XPORT
5 # define SP_PREFIX(name) SP_XPORT(name)
6 #else
7 # define SP_PREFIX(name) name
8 #endif
9 /* remember to touch local_stubs.c */
10 
11 #define SP_VERSION "1.4-6"
12 
13 #include <R.h>
14 /* RSB 091203 */
15 #include <Rdefines.h>
16 #define R_OFFSET 1
17 #include <Rinternals.h>
18 #include <Rmath.h>
19 
20 /* from insiders.c
21 
22 int pipbb(double pt1, double pt2, double *bbs);
23 int between(double x, double low, double up);
24 SEXP insiders(SEXP n1, SEXP bbs); */
25 
26 /* from pip.c */
27 
28 #ifndef MIN
29 # define MIN(a,b) ((a)>(b)?(b):(a))
30 #endif
31 #ifndef MAX
32 # define MAX(a,b) ((a)>(b)?(a):(b))
33 #endif
34 
35 #define BUFSIZE 8192
36 
37 /* polygon structs: */
38 typedef struct {
39 	double		x, y;
40 } PLOT_POINT;
41 
42 typedef struct {
43 	PLOT_POINT	min, max;
44 } MBR;
45 
46 typedef struct polygon {
47 	MBR mbr;
48 	int lines;
49 	PLOT_POINT	*p;
50     int close; /* 1 - is closed polygon */
51 } POLYGON;
52 
53 void setup_poly_minmax(POLYGON *pl);
54 char InPoly(PLOT_POINT q, POLYGON *Poly);
55 SEXP R_point_in_polygon_sp(SEXP px, SEXP py, SEXP polx, SEXP poly);
56 void sarea(double *heights, int *nx, int *ny, double *w, double *h,
57 	double *sa, int *bycell);
58 void spRFindCG( int *n, double *x, double *y, double *xc, double *yc,
59 		double *area );
60 void sp_gcdist(double *lon1, double *lon2, double *lat1, double *lat2,
61 		double *dist);
62 void sp_dists(double *u, double *v, double *uout, double *vout,
63 		int *n, double *dists, int *lonlat);
64 void sp_dists_NN(double *u1, double *v1, double *u2, double *v2,
65         int *n, double *dists, int *lonlat);
66 void sp_lengths(double *u, double *v, int *n, double *lengths, int *lonlat);
67 SEXP sp_zerodist(SEXP pp, SEXP pncol, SEXP zero, SEXP lonlat, SEXP mcmp);
68 SEXP sp_duplicates(SEXP pp, SEXP pncol, SEXP zero, SEXP lonlat, SEXP mcmp);
69 SEXP pointsInBox(SEXP lb, SEXP px, SEXP py);
70 SEXP tList(SEXP nl, SEXP m);
71 
72 /* RSB 091203 */
73 
74 #define DIM     2               /* Dimension of points */
75 typedef double  tPointd[DIM];   /* type double point */
76 
77 double  SP_PREFIX(Area2)(const tPointd a, const tPointd b, const tPointd c);
78 void    SP_PREFIX(FindCG)(int n, tPointd *P, tPointd CG, double *Areasum2);
79 void    SP_PREFIX(Centroid3)(const tPointd p1, const tPointd p2,
80 	const tPointd p3, tPointd c);
81 void SP_PREFIX(spRFindCG_c)(const SEXP n, const SEXP coords,
82 	double *xc, double *yc, double *area );
83 void SP_PREFIX(comm2comment)(char *buf, int bufsiz, int *comm, int nps);
84 
85 SEXP SP_PREFIX(Polygon_c)(const SEXP coords, const SEXP n, const SEXP hole);
86 SEXP SP_PREFIX(Polygons_c)(const SEXP pls, const SEXP ID);
87 SEXP SP_PREFIX(SpatialPolygons_c)(const SEXP pls, const SEXP pO, const SEXP p4s);
88 SEXP SP_PREFIX(bboxCalcR_c)(const SEXP pls);
89 SEXP SP_PREFIX(Polygon_validate_c)(const SEXP obj);
90 SEXP SP_PREFIX(Polygons_validate_c)(const SEXP obj);
91 SEXP SP_PREFIX(SpatialPolygons_validate_c)(const SEXP obj);
92 SEXP SP_PREFIX(SpatialPolygons_getIDs_c)(const SEXP obj);
93 SEXP SP_PREFIX(SpatialPolygons_plotOrder_c)(const SEXP pls);
94 SEXP SP_PREFIX(comment2comm)(const SEXP obj);
95 SEXP SP_PREFIX(sp_linkingTo_version)();
96 #endif
97 /* remember to touch local_stubs.c */
98 
99