Skip to content

Commit 94b2b06

Browse files
committed
loading sf no longer initializes the RNG state
see r-quantities/units#409
1 parent ac49ec2 commit 94b2b06

23 files changed

+106
-210
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# version 1.0-21
22

3+
* loading `sf` no longer initializes the RNG state; see https://github.com/r-quantities/units/issues/409
4+
35
* fix `st_sample()` on geodetic coordinates; #2515
46

57
# version 1.0-20

inst/include/sf_RcppExports.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ namespace sf {
3333
}
3434
RObject rcpp_result_gen;
3535
{
36-
RNGScope RCPP_rngScope_gen;
3736
rcpp_result_gen = p_CPL_read_wkb(Shield<SEXP>(Rcpp::wrap(wkb_list)), Shield<SEXP>(Rcpp::wrap(EWKB)), Shield<SEXP>(Rcpp::wrap(spatialite)));
3837
}
3938
if (rcpp_result_gen.inherits("interrupted-error"))
@@ -54,7 +53,6 @@ namespace sf {
5453
}
5554
RObject rcpp_result_gen;
5655
{
57-
RNGScope RCPP_rngScope_gen;
5856
rcpp_result_gen = p_CPL_write_wkb(Shield<SEXP>(Rcpp::wrap(sfc)), Shield<SEXP>(Rcpp::wrap(EWKB)));
5957
}
6058
if (rcpp_result_gen.inherits("interrupted-error"))

src/RcppExports.cpp

Lines changed: 0 additions & 104 deletions
Large diffs are not rendered by default.

src/bbox.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "bbox.h"
44

5-
// [[Rcpp::export]]
5+
// [[Rcpp::export(rng=false)]]
66
Rcpp::NumericVector CPL_get_bbox(Rcpp::List sf, int depth = 0) {
77
Rcpp::NumericVector bb(4);
88
bb[0] = bb[1] = bb[2] = bb[3] = NA_REAL;

src/gdal.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void unset_error_handler(void)
6767
CPLSetErrorHandler((CPLErrorHandler)__err_silent);
6868
}
6969

70-
// [[Rcpp::export]]
70+
// [[Rcpp::export(rng=false)]]
7171
void CPL_gdal_init()
7272
{
7373
CPLSetErrorHandler((CPLErrorHandler)__err_handler);
@@ -77,15 +77,15 @@ void CPL_gdal_init()
7777
}
7878

7979
// #nocov start
80-
// [[Rcpp::export]]
80+
// [[Rcpp::export(rng=false)]]
8181
void CPL_gdal_cleanup_all()
8282
{
8383
OGRCleanupAll();
8484
OSRCleanup();
8585
}
8686
// #nocov end
8787

88-
// [[Rcpp::export]]
88+
// [[Rcpp::export(rng=false)]]
8989
const char* CPL_gdal_version(const char* what = "RELEASE_NAME")
9090
{
9191
return GDALVersionInfo(what);
@@ -193,7 +193,7 @@ OGRSpatialReference *OGRSrs_from_crs(Rcpp::List crs) {
193193
return dest;
194194
}
195195

196-
// [[Rcpp::export]]
196+
// [[Rcpp::export(rng=false)]]
197197
Rcpp::List CPL_crs_parameters(Rcpp::List crs) {
198198

199199
char *cp = NULL;
@@ -370,7 +370,7 @@ int srid_from_crs(Rcpp::List crs) {
370370
return(ret_val);
371371
}
372372

373-
// [[Rcpp::export]]
373+
// [[Rcpp::export(rng=false)]]
374374
Rcpp::LogicalVector CPL_crs_equivalent(Rcpp::List crs1, Rcpp::List crs2) {
375375

376376
OGRSpatialReference *srs1 = OGRSrs_from_crs(crs1);
@@ -504,7 +504,7 @@ Rcpp::List sfc_from_ogr(std::vector<OGRGeometry *> g, bool destroy = false) {
504504
return ret;
505505
}
506506

507-
// [[Rcpp::export]]
507+
// [[Rcpp::export(rng=false)]]
508508
Rcpp::List CPL_crs_from_input(Rcpp::CharacterVector input) {
509509
OGRSpatialReference *ref = new OGRSpatialReference;
510510
handle_axis_order(ref);
@@ -519,7 +519,7 @@ Rcpp::List CPL_crs_from_input(Rcpp::CharacterVector input) {
519519
return crs;
520520
}
521521

522-
// [[Rcpp::export]]
522+
// [[Rcpp::export(rng=false)]]
523523
Rcpp::List CPL_roundtrip(Rcpp::List sfc) { // for debug purposes
524524
std::vector<OGRGeometry *> g = ogr_from_sfc(sfc, NULL);
525525
for (size_t i = 0; i < g.size(); i++) {
@@ -531,7 +531,7 @@ Rcpp::List CPL_roundtrip(Rcpp::List sfc) { // for debug purposes
531531
return sfc_from_ogr(g, true); // destroys g;
532532
}
533533

534-
// [[Rcpp::export]]
534+
// [[Rcpp::export(rng=false)]]
535535
Rcpp::List CPL_circularstring_to_linestring(Rcpp::List sfc) { // need to pass more parameters?
536536
std::vector<OGRGeometry *> g = ogr_from_sfc(sfc, NULL);
537537
std::vector<OGRGeometry *> out(g.size());
@@ -543,7 +543,7 @@ Rcpp::List CPL_circularstring_to_linestring(Rcpp::List sfc) { // need to pass mo
543543
return sfc_from_ogr(out, true); // destroys out;
544544
}
545545

546-
// [[Rcpp::export]]
546+
// [[Rcpp::export(rng=false)]]
547547
Rcpp::List CPL_multisurface_to_multipolygon(Rcpp::List sfc) { // need to pass more parameters?
548548
std::vector<OGRGeometry *> g = ogr_from_sfc(sfc, NULL);
549549
std::vector<OGRGeometry *> out(g.size());
@@ -560,7 +560,7 @@ Rcpp::List CPL_multisurface_to_multipolygon(Rcpp::List sfc) { // need to pass mo
560560
return sfc_from_ogr(out, true); // destroys out;
561561
}
562562

563-
// [[Rcpp::export]]
563+
// [[Rcpp::export(rng=false)]]
564564
Rcpp::List CPL_compoundcurve_to_linear(Rcpp::List sfc) { // need to pass more parameters?
565565
std::vector<OGRGeometry *> g = ogr_from_sfc(sfc, NULL);
566566
std::vector<OGRGeometry *> out(g.size());
@@ -572,7 +572,7 @@ Rcpp::List CPL_compoundcurve_to_linear(Rcpp::List sfc) { // need to pass more pa
572572
return sfc_from_ogr(out, true); // destroys out;
573573
}
574574

575-
// [[Rcpp::export]]
575+
// [[Rcpp::export(rng=false)]]
576576
Rcpp::List CPL_curve_to_linestring(Rcpp::List sfc) { // need to pass more parameters? #nocov start
577577
std::vector<OGRGeometry *> g = ogr_from_sfc(sfc, NULL);
578578
std::vector<OGRGeometry *> out(g.size());
@@ -583,7 +583,7 @@ Rcpp::List CPL_curve_to_linestring(Rcpp::List sfc) { // need to pass more parame
583583
return sfc_from_ogr(out, true); // destroys out;
584584
} // #nocov end
585585

586-
// [[Rcpp::export]]
586+
// [[Rcpp::export(rng=false)]]
587587
Rcpp::LogicalVector CPL_can_transform(Rcpp::List src, Rcpp::List dst) {
588588
if (src.size() != 2 || dst.size() != 2)
589589
return false;
@@ -605,7 +605,7 @@ Rcpp::LogicalVector CPL_can_transform(Rcpp::List src, Rcpp::List dst) {
605605
return false;
606606
}
607607

608-
// [[Rcpp::export]]
608+
// [[Rcpp::export(rng=false)]]
609609
Rcpp::List CPL_transform(Rcpp::List sfc, Rcpp::List crs,
610610
Rcpp::NumericVector AOI, Rcpp::CharacterVector pipeline, bool reverse = false,
611611
double desired_accuracy = -1.0, bool allow_ballpark = true) {
@@ -674,7 +674,7 @@ Rcpp::List CPL_transform(Rcpp::List sfc, Rcpp::List crs,
674674
return ret;
675675
}
676676

677-
// [[Rcpp::export]]
677+
// [[Rcpp::export(rng=false)]]
678678
Rcpp::NumericVector CPL_transform_bounds(Rcpp::NumericVector bb, Rcpp::List crs_dst,
679679
int densify_pts = 21) {
680680

@@ -722,7 +722,7 @@ Rcpp::NumericVector CPL_transform_bounds(Rcpp::NumericVector bb, Rcpp::List crs_
722722
return ret;
723723
}
724724

725-
// [[Rcpp::export]]
725+
// [[Rcpp::export(rng=false)]]
726726
Rcpp::List CPL_wrap_dateline(Rcpp::List sfc, Rcpp::CharacterVector opt, bool quiet = true) {
727727

728728
std::vector <char *> options = create_options(opt, quiet);
@@ -735,7 +735,7 @@ Rcpp::List CPL_wrap_dateline(Rcpp::List sfc, Rcpp::CharacterVector opt, bool qui
735735
return sfc_from_ogr(ret, true); // destroys ret;
736736
}
737737

738-
// [[Rcpp::export]]
738+
// [[Rcpp::export(rng=false)]]
739739
Rcpp::List CPL_get_gdal_drivers(int dummy) {
740740

741741
int ndr = GetGDALDriverManager()->GetDriverCount();
@@ -766,7 +766,7 @@ Rcpp::List CPL_get_gdal_drivers(int dummy) {
766766
Rcpp::Named("vsi") = vsi_attr);
767767
}
768768

769-
// [[Rcpp::export]]
769+
// [[Rcpp::export(rng=false)]]
770770
Rcpp::List CPL_sfc_from_wkt(Rcpp::CharacterVector wkt) {
771771
std::vector<OGRGeometry *> g(wkt.size());
772772
OGRGeometryFactory f;
@@ -781,13 +781,13 @@ Rcpp::List CPL_sfc_from_wkt(Rcpp::CharacterVector wkt) {
781781
return sfc_from_ogr(g, true);
782782
}
783783

784-
// [[Rcpp::export]]
784+
// [[Rcpp::export(rng=false)]]
785785
Rcpp::LogicalVector CPL_gdal_with_geos() {
786786
bool withGEOS = OGRGeometryFactory::haveGEOS();
787787
return Rcpp::LogicalVector::create(withGEOS);
788788
}
789789

790-
// [[Rcpp::export]]
790+
// [[Rcpp::export(rng=false)]]
791791
Rcpp::LogicalVector CPL_axis_order_authority_compliant(Rcpp::LogicalVector authority_compliant) {
792792
if (authority_compliant.size() > 1)
793793
Rcpp::stop("argument authority_compliant should have length 0 or 1"); // #nocov

src/gdal_geom.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include "gdal_sf_pkg.h"
77

8-
// [[Rcpp::export]]
8+
// [[Rcpp::export(rng=false)]]
99
Rcpp::NumericVector CPL_area(Rcpp::List sfc) {
1010
std::vector<OGRGeometry *> g = ogr_from_sfc(sfc, NULL);
1111
Rcpp::NumericVector out(sfc.length());
@@ -29,7 +29,7 @@ Rcpp::NumericVector CPL_area(Rcpp::List sfc) {
2929
return out;
3030
}
3131

32-
// [[Rcpp::export]]
32+
// [[Rcpp::export(rng=false)]]
3333
Rcpp::IntegerVector CPL_gdal_dimension(Rcpp::List sfc, bool NA_if_empty = true) {
3434
std::vector<OGRGeometry *> g = ogr_from_sfc(sfc, NULL);
3535
Rcpp::IntegerVector out(sfc.length());
@@ -44,7 +44,7 @@ Rcpp::IntegerVector CPL_gdal_dimension(Rcpp::List sfc, bool NA_if_empty = true)
4444
return out;
4545
}
4646

47-
// [[Rcpp::export]]
47+
// [[Rcpp::export(rng=false)]]
4848
Rcpp::NumericVector CPL_length(Rcpp::List sfc) {
4949
std::vector<OGRGeometry *> g = ogr_from_sfc(sfc, NULL);
5050
Rcpp::NumericVector out(sfc.length());
@@ -80,7 +80,7 @@ Rcpp::NumericVector CPL_length(Rcpp::List sfc) {
8080
return out;
8181
}
8282

83-
// [[Rcpp::export]]
83+
// [[Rcpp::export(rng=false)]]
8484
Rcpp::List CPL_gdal_segmentize(Rcpp::List sfc, double dfMaxLength = 0.0) {
8585

8686
if (dfMaxLength <= 0.0)
@@ -94,7 +94,7 @@ Rcpp::List CPL_gdal_segmentize(Rcpp::List sfc, double dfMaxLength = 0.0) {
9494
return ret;
9595
}
9696

97-
// [[Rcpp::export]]
97+
// [[Rcpp::export(rng=false)]]
9898
Rcpp::List CPL_gdal_linestring_sample(Rcpp::List sfc, Rcpp::List distLst) {
9999
if (sfc.size() != distLst.size())
100100
Rcpp::stop("sfc and dist should have equal length"); // #nocov

src/gdal_read.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ size_t count_features(OGRLayer *poLayer) {
135135
return n;
136136
}
137137

138-
// [[Rcpp::export]]
138+
// [[Rcpp::export(rng=false)]]
139139
Rcpp::List CPL_get_layers(Rcpp::CharacterVector datasource, Rcpp::CharacterVector options, bool do_count = false) {
140140

141141
if (datasource.size() != 1)
@@ -633,7 +633,7 @@ Rcpp::List CPL_ogr_layer_setup(Rcpp::CharacterVector datasource, Rcpp::Character
633633
return Rcpp::List::create(dataset_xptr, layer_xptr);
634634
}
635635

636-
// [[Rcpp::export]]
636+
// [[Rcpp::export(rng=false)]]
637637
Rcpp::List CPL_read_ogr(Rcpp::CharacterVector datasource, Rcpp::CharacterVector layer,
638638
Rcpp::CharacterVector query,
639639
Rcpp::CharacterVector options, bool quiet, Rcpp::NumericVector toTypeUser,

src/gdal_read_stream.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class GDALStreamWrapper {
7070

7171
#endif
7272

73-
// [[Rcpp::export]]
73+
// [[Rcpp::export(rng=false)]]
7474
Rcpp::List CPL_read_gdal_stream(
7575
Rcpp::RObject stream_xptr,
7676
Rcpp::CharacterVector datasource, Rcpp::CharacterVector layer,

0 commit comments

Comments
 (0)