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