diff --git a/.Rbuildignore b/.Rbuildignore index 29bec85..cc5b1fe 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -3,7 +3,6 @@ CHANGES ChangeLog TODO oChangeLog -build-prep.sh build-release.sh src/sp.h.in .travis.yml diff --git a/DESCRIPTION b/DESCRIPTION index 99b4653..cc7b23c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: sp -Version: 2.1-4 +Version: 2.2-0 Title: Classes and Methods for Spatial Data Authors@R: c(person("Edzer", "Pebesma", role = c("aut", "cre"), email = "edzer.pebesma@uni-muenster.de"), diff --git a/README.md b/README.md index 46ace29..29adcd4 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ R Classes and Methods for Spatial Data. Note that this is package will (slowly) be deprecated, in favor of package `sf`. It is in maintenance mode, and currently requires `sf` for coordinate reference system validation and coordinate transformation, conversion and (re)projection. +From version 2.2-0, `sp` has dropped the export of a compiled C API formerly used by `rgdal` and `rgeos` + From version 2.1-0, `sp` has dropped `maptools`, `rgdal` and `rgeos` as suggested packages. From version 2.0-0, `sp` evolution status is changed to `2L` to use **sf** internally in place of `rgdal`, from default `0L` until now. See [this report](https://r-spatial.org/r/2023/05/15/evolution4.html) for adaptation details, and [this report](https://r-spatial.org/r/2023/04/10/evolution3.html) for progress on retiring `maptools`, `rgdal` and `rgeos`. diff --git a/build-prep.sh b/build-prep.sh deleted file mode 100755 index fe452a7..0000000 --- a/build-prep.sh +++ /dev/null @@ -1,6 +0,0 @@ -# run before R CMD build sp -VERSION=`awk '/Version:/{print $2}' DESCRIPTION` -sed -e 's/@VERSION@/'$VERSION'/' src/sp.h.in > src/sp.h -cp -p src/sp.h inst/include -cp -p src/sp_xports.c inst/include -grep SP_VERSION inst/include/sp.h diff --git a/build-release.sh b/build-release.sh index 51f70a6..bbbce06 100755 --- a/build-release.sh +++ b/build-release.sh @@ -1,4 +1,3 @@ -sh ./build-prep.sh git2cl > xx cat xx ChangeLog > inst/ChangeLog rm xx diff --git a/inst/include/sp.h b/inst/include/sp.h deleted file mode 100644 index 9cf0ede..0000000 --- a/inst/include/sp.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef R_SP_H -#define R_SP_H - -#ifdef SP_XPORT -# define SP_PREFIX(name) SP_XPORT(name) -#else -# define SP_PREFIX(name) name -#endif -/* remember to touch local_stubs.c */ - -#define SP_VERSION "2.1-4" - -#include -/* RSB 091203 */ -#include -#define R_OFFSET 1 -#include -#include - -/* from insiders.c - -int pipbb(double pt1, double pt2, double *bbs); -int between(double x, double low, double up); -SEXP insiders(SEXP n1, SEXP bbs); */ - -/* from pip.c */ - -#ifndef MIN -# define MIN(a,b) ((a)>(b)?(b):(a)) -#endif -#ifndef MAX -# define MAX(a,b) ((a)>(b)?(a):(b)) -#endif - -#define BUFSIZE 8192 - -/* polygon structs: */ -typedef struct { - double x, y; -} PLOT_POINT; - -typedef struct { - PLOT_POINT min, max; -} MBR; - -typedef struct polygon { - MBR mbr; - int lines; - PLOT_POINT *p; - int close; /* 1 - is closed polygon */ -} POLYGON; - -void setup_poly_minmax(POLYGON *pl); -char InPoly(PLOT_POINT q, POLYGON *Poly); -SEXP R_point_in_polygon_sp(SEXP px, SEXP py, SEXP polx, SEXP poly); -void sarea(double *heights, int *nx, int *ny, double *w, double *h, - double *sa, int *bycell); -void spRFindCG( int *n, double *x, double *y, double *xc, double *yc, - double *area ); -void sp_gcdist(double *lon1, double *lon2, double *lat1, double *lat2, - double *dist); -void sp_dists(double *u, double *v, double *uout, double *vout, - int *n, double *dists, int *lonlat); -void sp_dists_NN(double *u1, double *v1, double *u2, double *v2, - int *n, double *dists, int *lonlat); -void sp_lengths(double *u, double *v, int *n, double *lengths, int *lonlat); -SEXP sp_zerodist(SEXP pp, SEXP pncol, SEXP zero, SEXP lonlat, SEXP mcmp); -SEXP sp_duplicates(SEXP pp, SEXP pncol, SEXP zero, SEXP lonlat, SEXP mcmp); -SEXP pointsInBox(SEXP lb, SEXP px, SEXP py); -SEXP tList(SEXP nl, SEXP m); - -/* RSB 091203 */ - -#define DIM 2 /* Dimension of points */ -typedef double tPointd[DIM]; /* type double point */ - -double SP_PREFIX(Area2)(const tPointd a, const tPointd b, const tPointd c); -void SP_PREFIX(FindCG)(int n, tPointd *P, tPointd CG, double *Areasum2); -void SP_PREFIX(Centroid3)(const tPointd p1, const tPointd p2, - const tPointd p3, tPointd c); -void SP_PREFIX(spRFindCG_c)(const SEXP n, const SEXP coords, - double *xc, double *yc, double *area ); -void SP_PREFIX(comm2comment)(char *buf, int bufsiz, int *comm, int nps); - -SEXP SP_PREFIX(Polygon_c)(const SEXP coords, const SEXP n, const SEXP hole); -SEXP SP_PREFIX(Polygons_c)(const SEXP pls, const SEXP ID); -SEXP SP_PREFIX(SpatialPolygons_c)(const SEXP pls, const SEXP pO, const SEXP p4s); -SEXP SP_PREFIX(bboxCalcR_c)(const SEXP pls); -SEXP SP_PREFIX(Polygon_validate_c)(const SEXP obj); -SEXP SP_PREFIX(Polygons_validate_c)(const SEXP obj); -SEXP SP_PREFIX(SpatialPolygons_validate_c)(const SEXP obj); -SEXP SP_PREFIX(SpatialPolygons_getIDs_c)(const SEXP obj); -SEXP SP_PREFIX(SpatialPolygons_plotOrder_c)(const SEXP pls); -SEXP SP_PREFIX(comment2comm)(const SEXP obj); -SEXP SP_PREFIX(sp_linkingTo_version)(void); -#endif -/* remember to touch local_stubs.c */ - diff --git a/inst/include/sp_xports.c b/inst/include/sp_xports.c deleted file mode 100644 index 0155287..0000000 --- a/inst/include/sp_xports.c +++ /dev/null @@ -1,677 +0,0 @@ -#define USING_R 1 - -#include "sp.h" -/* remember to touch local_stubs.c */ - -SEXP SP_PREFIX(sp_linkingTo_version)(void) { - SEXP ans; - PROTECT(ans = NEW_CHARACTER(1)); - SET_STRING_ELT(ans, 0, - COPY_TO_USER_STRING(SP_VERSION)); - UNPROTECT(1); - return(ans); -} - -SEXP SP_PREFIX(Polygon_c)(const SEXP coords, const SEXP n, const SEXP ihole) { - - SEXP SPans, labpt, Area, ringDir, hole, cls; - double area, xc, yc; - double *x, *y; - int pc=0, rev=FALSE; - int i, ii, nn=INTEGER_POINTER(n)[0]; - SEXP valid; - SEXP ccopy, /* copy of coords to go into returned structure */ - dim1; - - for (i=0; i 2) { - xc = (NUMERIC_POINTER(ccopy)[0] + - NUMERIC_POINTER(ccopy)[(nn-1)])/2.0; - yc = (NUMERIC_POINTER(ccopy)[nn] + - NUMERIC_POINTER(ccopy)[nn+(nn-1)])/2.0; - } - } - } - -// rchk MAKE_CLASS allocates RSB 180602 - PROTECT(cls = MAKE_CLASS("Polygon")); pc++; - PROTECT(SPans = NEW_OBJECT(cls)); pc++; - PROTECT(ringDir = NEW_INTEGER(1)); pc++; - INTEGER_POINTER(ringDir)[0] = (area > 0.0) ? -1 : 1; -// -1 cw hole, 1 ccw not-hole - -/* RSB 100126 fixing hole assumption - thanks to Javier Munoz for report */ - - if (INTEGER_POINTER(ihole)[0] == NA_INTEGER) { // trust ring direction - if (INTEGER_POINTER(ringDir)[0] == 1) - INTEGER_POINTER(ihole)[0] = 0; - else if (INTEGER_POINTER(ringDir)[0] == -1) - INTEGER_POINTER(ihole)[0] = 1; - } else { // trust hole - if (INTEGER_POINTER(ihole)[0] == 1 && - INTEGER_POINTER(ringDir)[0] == 1) { - rev = TRUE; - INTEGER_POINTER(ringDir)[0] = -1; - } - if (INTEGER_POINTER(ihole)[0] == 0 && - INTEGER_POINTER(ringDir)[0] == -1) { - rev = TRUE; - INTEGER_POINTER(ringDir)[0] = 1; - } - } - PROTECT(hole = NEW_LOGICAL(1)); pc++; - if (INTEGER_POINTER(ihole)[0] == 1) LOGICAL_POINTER(hole)[0] = TRUE; - else LOGICAL_POINTER(hole)[0] = FALSE; - - if (rev) { - x = (double *) R_alloc((size_t) nn, sizeof(double)); - y = (double *) R_alloc((size_t) nn, sizeof(double)); - for (i=0; i 1) { - for (i=0; i UX) UX = x; - if (y > UY) UY = y; - if (x < LX) LX = x; - if (y < LY) LY = y; - } - } - } - - PROTECT(ans = NEW_NUMERIC(4)); pc++; - NUMERIC_POINTER(ans)[0] = LX; - NUMERIC_POINTER(ans)[1] = LY; - NUMERIC_POINTER(ans)[2] = UX; - NUMERIC_POINTER(ans)[3] = UY; - PROTECT(dim = NEW_INTEGER(2)); pc++; - INTEGER_POINTER(dim)[0] = 2; - INTEGER_POINTER(dim)[1] = 2; - setAttrib(ans, R_DimSymbol, dim); - PROTECT(dimnames = NEW_LIST(2)); pc++; - SET_VECTOR_ELT(dimnames, 0, NEW_CHARACTER(2)); - SET_STRING_ELT(VECTOR_ELT(dimnames, 0), 0, COPY_TO_USER_STRING("x")); - SET_STRING_ELT(VECTOR_ELT(dimnames, 0), 1, COPY_TO_USER_STRING("y")); - SET_VECTOR_ELT(dimnames, 1, NEW_CHARACTER(2)); - SET_STRING_ELT(VECTOR_ELT(dimnames, 1), 0, COPY_TO_USER_STRING("min")); - SET_STRING_ELT(VECTOR_ELT(dimnames, 1), 1, COPY_TO_USER_STRING("max")); - setAttrib(ans, R_DimNamesSymbol, dimnames); - UNPROTECT(pc); - return(ans); - -} - -void SP_PREFIX(spRFindCG_c)(const SEXP n, const SEXP coords, - double *xc, double *yc, double *area ) { - - int i, nn; - tPointd *P; - tPointd CG; - double Areasum2; - - nn = INTEGER_POINTER(n)[0]; - P = (tPointd *) R_alloc((size_t) nn, sizeof(tPointd)); - for (i=0; i 15) error("comment2comm: buffer overflow"); - strncpy(s, &buf[0], (size_t) nss[0]); - s[nss[0]] = '\0'; - - c[0] = atoi(s); - for (i=0; i 15) error("comment2comm: buffer overflow"); - strncpy(s, &buf[(nss[i]+1)], (size_t) k); - s[k] = '\0'; - c[i+1] = atoi(s); - } - - for (i=0, k=0; i<(ns+1); i++) if (c[i] == 0) k++; - - PROTECT(ans = NEW_LIST((k))); pc++; - co = (int *) R_alloc((size_t) k, sizeof(int)); - coo = (int *) R_alloc((size_t) k, sizeof(int)); - for (i=0; i 1) { - for (j=0; j<(ns+1); j++) - if (c[j] == coo[i]) - INTEGER_POINTER(VECTOR_ELT(ans, i))[jj++] = j + R_OFFSET; - } - } - - UNPROTECT(pc); - return(ans); -} - -void SP_PREFIX(comm2comment)(char *buf, int bufsiz, int *comm, int nps) { - char cbuf[15]; - int i, nc, nc1, pr; - - nc = (int) (ceil(log10(nps)+1.0)+1.0); - nc1 = (nc*nps)+1; - if (bufsiz < nc1) error("comm2comment: buffer overflow"); - - pr = snprintf(buf, bufsiz, "%d", comm[0]); - bufsiz -= pr; - for (i = 1; i < nps; i++) { - snprintf(cbuf, 15, " %d", comm[i]); - if (strlen(cbuf) >= bufsiz) - error("comm2comment: buffer overflow"); - strncat(buf, cbuf, bufsiz); - bufsiz -= strlen(cbuf); - } - strcat(buf, "\0"); - return; -} - -/* remember to touch local_stubs.c */ diff --git a/src/gcdist.c b/src/gcdist.c index 33d4cc0..ba25d96 100644 --- a/src/gcdist.c +++ b/src/gcdist.c @@ -46,7 +46,7 @@ void sp_dists_NN(double *u1, double *v1, double *u2, double *v2, void sp_lengths(double *u, double *v, int *n, double *lengths, int *lonlat) { int N = *n, j; double gc[1]; - if (N < 2) error("N less than 2"); + if (N < 2) Rf_error("N less than 2"); if (lonlat[0] == 0) for (j=0; j < N-1; j++) diff --git a/src/init.c b/src/init.c index a9ffa79..fa567f1 100644 --- a/src/init.c +++ b/src/init.c @@ -39,7 +39,7 @@ static R_CallMethodDef CallEntries[] = { {"SpatialPolygons_getIDs_c", (DL_FUNC) &SpatialPolygons_getIDs_c, 1}, {"SpatialPolygons_plotOrder_c", (DL_FUNC) &SpatialPolygons_plotOrder_c, 1}, {"comment2comm", (DL_FUNC) &comment2comm, 1}, - {"sp_linkingTo_version", (DL_FUNC) &sp_linkingTo_version, 0}, +/* {"sp_linkingTo_version", (DL_FUNC) &sp_linkingTo_version, 0}, */ {NULL, NULL, 0} }; diff --git a/src/pip2.c b/src/pip2.c index ee2af1c..5c7a999 100644 --- a/src/pip2.c +++ b/src/pip2.c @@ -14,17 +14,17 @@ SEXP tList(const SEXP nl, const SEXP m); SEXP tList(const SEXP nl, const SEXP m0) { - int n=length(nl), m=INTEGER_POINTER(m0)[0], i, ii, j, jj, *k, pc=0; + int n=Rf_length(nl), m=INTEGER_POINTER(m0)[0], i, ii, j, jj, *k, pc=0; SEXP res; PROTECT(res = NEW_LIST(m)); pc++; k = (int *) R_alloc((size_t) m, sizeof(int)); for (j=0; j 0) { for (j=0; j= m) error("invalid indices"); + if (jj < 0 || jj >= m) Rf_error("invalid indices"); k[jj]++; } } @@ -32,7 +32,7 @@ SEXP tList(const SEXP nl, const SEXP m0) { for (j=0; j 0) { for (j=0; j /* RSB 091203 */ @@ -52,47 +47,46 @@ typedef struct polygon { void setup_poly_minmax(POLYGON *pl); char InPoly(PLOT_POINT q, POLYGON *Poly); -SEXP R_point_in_polygon_sp(SEXP px, SEXP py, SEXP polx, SEXP poly); +SEXP R_point_in_polygon_sp(SEXP px, SEXP py, SEXP polx, SEXP poly); /* point.in.polygon.R */ void sarea(double *heights, int *nx, int *ny, double *w, double *h, - double *sa, int *bycell); + double *sa, int *bycell); /* surfaceArea.R */ void spRFindCG( int *n, double *x, double *y, double *xc, double *yc, - double *area ); + double *area ); /* SpatialPolygons-internals.R */ void sp_gcdist(double *lon1, double *lon2, double *lat1, double *lat2, double *dist); void sp_dists(double *u, double *v, double *uout, double *vout, - int *n, double *dists, int *lonlat); + int *n, double *dists, int *lonlat); /* spdists.R */ void sp_dists_NN(double *u1, double *v1, double *u2, double *v2, - int *n, double *dists, int *lonlat); -void sp_lengths(double *u, double *v, int *n, double *lengths, int *lonlat); -SEXP sp_zerodist(SEXP pp, SEXP pncol, SEXP zero, SEXP lonlat, SEXP mcmp); -SEXP sp_duplicates(SEXP pp, SEXP pncol, SEXP zero, SEXP lonlat, SEXP mcmp); -SEXP pointsInBox(SEXP lb, SEXP px, SEXP py); -SEXP tList(SEXP nl, SEXP m); + int *n, double *dists, int *lonlat); /* spdists.R */ +void sp_lengths(double *u, double *v, int *n, double *lengths, int *lonlat); /* SpatialLines-methods.R */ +SEXP sp_zerodist(SEXP pp, SEXP pncol, SEXP zero, SEXP lonlat, SEXP mcmp); /* zerodist.R */ +SEXP sp_duplicates(SEXP pp, SEXP pncol, SEXP zero, SEXP lonlat, SEXP mcmp); /* zerodist.R */ +SEXP pointsInBox(SEXP lb, SEXP px, SEXP py); /* point.in.polygon.R */ +SEXP tList(SEXP nl, SEXP m); /* point.in.polygon.R */ /* RSB 091203 */ #define DIM 2 /* Dimension of points */ typedef double tPointd[DIM]; /* type double point */ -double SP_PREFIX(Area2)(const tPointd a, const tPointd b, const tPointd c); -void SP_PREFIX(FindCG)(int n, tPointd *P, tPointd CG, double *Areasum2); -void SP_PREFIX(Centroid3)(const tPointd p1, const tPointd p2, +double Area2(const tPointd a, const tPointd b, const tPointd c); +void FindCG(int n, tPointd *P, tPointd CG, double *Areasum2); +void Centroid3(const tPointd p1, const tPointd p2, const tPointd p3, tPointd c); -void SP_PREFIX(spRFindCG_c)(const SEXP n, const SEXP coords, +void spRFindCG_c(const SEXP n, const SEXP coords, double *xc, double *yc, double *area ); -void SP_PREFIX(comm2comment)(char *buf, int bufsiz, int *comm, int nps); - -SEXP SP_PREFIX(Polygon_c)(const SEXP coords, const SEXP n, const SEXP hole); -SEXP SP_PREFIX(Polygons_c)(const SEXP pls, const SEXP ID); -SEXP SP_PREFIX(SpatialPolygons_c)(const SEXP pls, const SEXP pO, const SEXP p4s); -SEXP SP_PREFIX(bboxCalcR_c)(const SEXP pls); -SEXP SP_PREFIX(Polygon_validate_c)(const SEXP obj); -SEXP SP_PREFIX(Polygons_validate_c)(const SEXP obj); -SEXP SP_PREFIX(SpatialPolygons_validate_c)(const SEXP obj); -SEXP SP_PREFIX(SpatialPolygons_getIDs_c)(const SEXP obj); -SEXP SP_PREFIX(SpatialPolygons_plotOrder_c)(const SEXP pls); -SEXP SP_PREFIX(comment2comm)(const SEXP obj); -SEXP SP_PREFIX(sp_linkingTo_version)(void); +void comm2comment(char *buf, int bufsiz, int *comm, int nps); + +SEXP Polygon_c(const SEXP coords, const SEXP n, const SEXP hole); /* SpatialPolygons-methods.R */ +SEXP Polygons_c(const SEXP pls, const SEXP ID); /* SpatialPolygons-methods.R */ +SEXP SpatialPolygons_c(const SEXP pls, const SEXP pO, const SEXP p4s); /* SpatialPolygons-methods.R */ +SEXP bboxCalcR_c(const SEXP pls); /* SpatialPolygonsDataFrame-methods.R */ +SEXP Polygon_validate_c(const SEXP obj); /* Class-SpatialPolygons.R */ +SEXP Polygons_validate_c(const SEXP obj); /* Class-SpatialPolygons.R */ +SEXP SpatialPolygons_validate_c(const SEXP obj); /* Class-SpatialPolygons.R */ +SEXP SpatialPolygons_getIDs_c(const SEXP obj); /* chfids.R Class-SpatialPolygons.R SpatialPolygonsDataFrame-methods.R */ +SEXP SpatialPolygons_plotOrder_c(const SEXP pls); /* SpatialPolygonsDataFrame-methods.R SpatialPolygons-methods.R */ +SEXP comment2comm(const SEXP obj); +// SEXP sp_linkingTo_version(void); #endif -/* remember to touch local_stubs.c */ diff --git a/src/sp.h.in b/src/sp.h.in deleted file mode 100644 index dce352e..0000000 --- a/src/sp.h.in +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef R_SP_H -#define R_SP_H - -#ifdef SP_XPORT -# define SP_PREFIX(name) SP_XPORT(name) -#else -# define SP_PREFIX(name) name -#endif -/* remember to touch local_stubs.c */ - -#define SP_VERSION "@VERSION@" - -#include -/* RSB 091203 */ -#include -#define R_OFFSET 1 -#include -#include - -/* from insiders.c - -int pipbb(double pt1, double pt2, double *bbs); -int between(double x, double low, double up); -SEXP insiders(SEXP n1, SEXP bbs); */ - -/* from pip.c */ - -#ifndef MIN -# define MIN(a,b) ((a)>(b)?(b):(a)) -#endif -#ifndef MAX -# define MAX(a,b) ((a)>(b)?(a):(b)) -#endif - -#define BUFSIZE 8192 - -/* polygon structs: */ -typedef struct { - double x, y; -} PLOT_POINT; - -typedef struct { - PLOT_POINT min, max; -} MBR; - -typedef struct polygon { - MBR mbr; - int lines; - PLOT_POINT *p; - int close; /* 1 - is closed polygon */ -} POLYGON; - -void setup_poly_minmax(POLYGON *pl); -char InPoly(PLOT_POINT q, POLYGON *Poly); -SEXP R_point_in_polygon_sp(SEXP px, SEXP py, SEXP polx, SEXP poly); -void sarea(double *heights, int *nx, int *ny, double *w, double *h, - double *sa, int *bycell); -void spRFindCG( int *n, double *x, double *y, double *xc, double *yc, - double *area ); -void sp_gcdist(double *lon1, double *lon2, double *lat1, double *lat2, - double *dist); -void sp_dists(double *u, double *v, double *uout, double *vout, - int *n, double *dists, int *lonlat); -void sp_dists_NN(double *u1, double *v1, double *u2, double *v2, - int *n, double *dists, int *lonlat); -void sp_lengths(double *u, double *v, int *n, double *lengths, int *lonlat); -SEXP sp_zerodist(SEXP pp, SEXP pncol, SEXP zero, SEXP lonlat, SEXP mcmp); -SEXP sp_duplicates(SEXP pp, SEXP pncol, SEXP zero, SEXP lonlat, SEXP mcmp); -SEXP pointsInBox(SEXP lb, SEXP px, SEXP py); -SEXP tList(SEXP nl, SEXP m); - -/* RSB 091203 */ - -#define DIM 2 /* Dimension of points */ -typedef double tPointd[DIM]; /* type double point */ - -double SP_PREFIX(Area2)(const tPointd a, const tPointd b, const tPointd c); -void SP_PREFIX(FindCG)(int n, tPointd *P, tPointd CG, double *Areasum2); -void SP_PREFIX(Centroid3)(const tPointd p1, const tPointd p2, - const tPointd p3, tPointd c); -void SP_PREFIX(spRFindCG_c)(const SEXP n, const SEXP coords, - double *xc, double *yc, double *area ); -void SP_PREFIX(comm2comment)(char *buf, int bufsiz, int *comm, int nps); - -SEXP SP_PREFIX(Polygon_c)(const SEXP coords, const SEXP n, const SEXP hole); -SEXP SP_PREFIX(Polygons_c)(const SEXP pls, const SEXP ID); -SEXP SP_PREFIX(SpatialPolygons_c)(const SEXP pls, const SEXP pO, const SEXP p4s); -SEXP SP_PREFIX(bboxCalcR_c)(const SEXP pls); -SEXP SP_PREFIX(Polygon_validate_c)(const SEXP obj); -SEXP SP_PREFIX(Polygons_validate_c)(const SEXP obj); -SEXP SP_PREFIX(SpatialPolygons_validate_c)(const SEXP obj); -SEXP SP_PREFIX(SpatialPolygons_getIDs_c)(const SEXP obj); -SEXP SP_PREFIX(SpatialPolygons_plotOrder_c)(const SEXP pls); -SEXP SP_PREFIX(comment2comm)(const SEXP obj); -SEXP SP_PREFIX(sp_linkingTo_version)(void); -#endif -/* remember to touch local_stubs.c */ - diff --git a/src/sp_xports.c b/src/sp_xports.c index 0155287..ad228e7 100644 --- a/src/sp_xports.c +++ b/src/sp_xports.c @@ -3,16 +3,16 @@ #include "sp.h" /* remember to touch local_stubs.c */ -SEXP SP_PREFIX(sp_linkingTo_version)(void) { +/* SEXP sp_linkingTo_version(void) { SEXP ans; PROTECT(ans = NEW_CHARACTER(1)); SET_STRING_ELT(ans, 0, - COPY_TO_USER_STRING(SP_VERSION)); + Rf_mkChar(SP_VERSION)); UNPROTECT(1); return(ans); -} +} */ -SEXP SP_PREFIX(Polygon_c)(const SEXP coords, const SEXP n, const SEXP ihole) { +SEXP Polygon_c(const SEXP coords, const SEXP n, const SEXP ihole) { SEXP SPans, labpt, Area, ringDir, hole, cls; double area, xc, yc; @@ -25,9 +25,9 @@ SEXP SP_PREFIX(Polygon_c)(const SEXP coords, const SEXP n, const SEXP ihole) { for (i=0; i 15) error("comment2comm: buffer overflow"); + if (nss[0] > 15) Rf_error("comment2comm: buffer overflow"); strncpy(s, &buf[0], (size_t) nss[0]); s[nss[0]] = '\0'; c[0] = atoi(s); for (i=0; i 15) error("comment2comm: buffer overflow"); + if (k > 15) Rf_error("comment2comm: buffer overflow"); strncpy(s, &buf[(nss[i]+1)], (size_t) k); s[k] = '\0'; c[i+1] = atoi(s); @@ -653,20 +653,20 @@ SEXP SP_PREFIX(comment2comm)(const SEXP obj) { return(ans); } -void SP_PREFIX(comm2comment)(char *buf, int bufsiz, int *comm, int nps) { +void comm2comment(char *buf, int bufsiz, int *comm, int nps) { char cbuf[15]; int i, nc, nc1, pr; nc = (int) (ceil(log10(nps)+1.0)+1.0); nc1 = (nc*nps)+1; - if (bufsiz < nc1) error("comm2comment: buffer overflow"); + if (bufsiz < nc1) Rf_error("comm2comment: buffer overflow"); pr = snprintf(buf, bufsiz, "%d", comm[0]); bufsiz -= pr; for (i = 1; i < nps; i++) { snprintf(cbuf, 15, " %d", comm[i]); if (strlen(cbuf) >= bufsiz) - error("comm2comment: buffer overflow"); + Rf_error("comm2comment: buffer overflow"); strncat(buf, cbuf, bufsiz); bufsiz -= strlen(cbuf); } @@ -674,4 +674,4 @@ void SP_PREFIX(comm2comment)(char *buf, int bufsiz, int *comm, int nps) { return; } -/* remember to touch local_stubs.c */ + diff --git a/src/zerodist.c b/src/zerodist.c index a577c6e..0a4a317 100644 --- a/src/zerodist.c +++ b/src/zerodist.c @@ -34,12 +34,12 @@ SEXP sp_zerodist(SEXP pp, SEXP pncol, SEXP zero, SEXP lonlat, SEXP mcmp) { ll = INTEGER_POINTER(lonlat)[0]; cmp = INTEGER_POINTER(mcmp)[0]; if (ll && ncol != 2) - error("for longlat data, coordinates should be two-dimensional"); + Rf_error("for longlat data, coordinates should be two-dimensional"); nrow = LENGTH(pp)/ncol; zerodist2 = NUMERIC_POINTER(zero)[0] * NUMERIC_POINTER(zero)[0]; x = (double **) malloc((size_t) nrow * sizeof(double *)); if (x == NULL) - error("could not allocate vector of %lu bytes in zerodist", + Rf_error("could not allocate vector of %lu bytes in zerodist", (long unsigned int) (nrow * sizeof(double *))); for (i = 0; i < nrow; i++) x[i] = &(NUMERIC_POINTER(pp)[i*ncol]); @@ -49,7 +49,7 @@ SEXP sp_zerodist(SEXP pp, SEXP pncol, SEXP zero, SEXP lonlat, SEXP mcmp) { if (is_zero(x[i], x[j], ncol, ll, zerodist2, cmp)) { which = (unsigned int *) realloc(which, (size_t) (nzero+2) * sizeof(unsigned int)); if (which == NULL) - error("could not allocate vector of %u bytes in zerodist", + Rf_error("could not allocate vector of %u bytes in zerodist", nzero + 2); which[nzero] = j; /* lowest */ which[nzero + 1] = i; @@ -77,12 +77,12 @@ SEXP sp_duplicates(SEXP pp, SEXP pncol, SEXP zero, SEXP lonlat, SEXP mcmp) { ll = INTEGER_POINTER(lonlat)[0]; cmp = INTEGER_POINTER(mcmp)[0]; if (ll && ncol != 2) - error("for longlat data, coordinates should be two-dimensional"); + Rf_error("for longlat data, coordinates should be two-dimensional"); nrow = LENGTH(pp)/ncol; zerodist2 = NUMERIC_POINTER(zero)[0] * NUMERIC_POINTER(zero)[0]; x = (double **) malloc((size_t) nrow * sizeof(double *)); if (x == NULL) - error("could not allocate vector of %lu bytes in zerodist", + Rf_error("could not allocate vector of %lu bytes in zerodist", (long unsigned int) (nrow * sizeof(double *))); for (i = 0; i < nrow; i++) x[i] = &(NUMERIC_POINTER(pp)[i*ncol]); diff --git a/vignettes/sp_gallery.Rmd b/vignettes/sp_gallery.Rmd index 723828b..a97c52a 100644 --- a/vignettes/sp_gallery.Rmd +++ b/vignettes/sp_gallery.Rmd @@ -220,7 +220,7 @@ plot(geometry(meuse.grid), add = TRUE, col = grey(.8)) ``` Read -[this](http://r-spatial.org/r/2016/03/08/plotting-spatial-grids.html) +[this](https://r-spatial.org/r/2016/03/08/plotting-spatial-grids.html) blog post to find out more about the options available (and limitations) for plotting gridded data with base plot methods in sp.