// [[Rcpp::export]] Rcpp::List CPL_crs_from_epsg(int epsg) { OGRSpatialReference ref; if (ref.importFromEPSG(epsg) == OGRERR_NONE) return get_crs(&ref); else return get_crs(NULL); }
// [[Rcpp::export]] Rcpp::List CPL_crs_from_proj4string(Rcpp::CharacterVector p4s) { OGRSpatialReference ref; if (ref.importFromProj4(p4s[0]) == OGRERR_NONE) return get_crs(&ref); else { const char *cp = p4s[0]; Rf_warning("GDAL cannot import PROJ.4 string `%s': returning missing CRS\n", cp); return get_crs(NULL); } }
// [[Rcpp::export]] Rcpp::List CPL_crs_from_wkt(Rcpp::CharacterVector wkt) { char *cp = wkt[0]; OGRSpatialReference ref; #if GDAL_VERSION_MAJOR <= 2 && GDAL_VERSION_MINOR <= 2 handle_error(ref.importFromWkt(&cp)); #else handle_error(ref.importFromWkt( (const char*) cp)); #endif return get_crs(&ref); }
/** * ReadSubfr2 function * The function decodes the 2nd subframe of the GPS navigation data * according to the IS-GPS-200E section IS-GPS-200E : 20.3.3.4.1 Content * of Subframes 2 and 3 and updates the Satellite structure, * identified by its pointer. * @param *Sat The pointer of the Satellite structure * @param *data The pointer of the 300 bits */ void ReadSubfr2(Satellite * Sat, char * data) { (*Sat).iode_s2 = get_iode_s2((*Sat).subfr2); (*Sat).crs = get_crs((*Sat).subfr2); (*Sat).delta_n = get_delta_n((*Sat).subfr2); (*Sat).m0 = get_m0((*Sat).subfr2); (*Sat).cuc = get_cuc((*Sat).subfr2); (*Sat).e = get_e((*Sat).subfr2); (*Sat).cus = get_cus((*Sat).subfr2); (*Sat).sqrta = get_sqrta((*Sat).subfr2); (*Sat).toe = get_toe((*Sat).subfr2); (*Sat).ado = get_ado((*Sat).subfr2); }
Rcpp::List sfc_from_ogr(std::vector<OGRGeometry *> g, bool destroy = false) { Rcpp::List lst(g.size()); Rcpp::List crs = get_crs(g.size() && g[0] != NULL ? g[0]->getSpatialReference() : NULL); for (size_t i = 0; i < g.size(); i++) { if (g[i] == NULL) Rcpp::stop("NULL error in sfc_from_ogr"); // #nocov Rcpp::RawVector raw(g[i]->WkbSize()); handle_error(g[i]->exportToWkb(wkbNDR, &(raw[0]), wkbVariantIso)); lst[i] = raw; if (destroy) OGRGeometryFactory::destroyGeometry(g[i]); } Rcpp::List ret = CPL_read_wkb(lst, false, false); ret.attr("crs") = crs; ret.attr("class") = "sfc"; return ret; }