示例#1
0
void OGRSXFDataSource::SetVertCS(const long iVCS, SXFPassport& passport)
{
    if (!CSLTestBoolean(CPLGetConfigOption("SXF_SET_VERTCS", "NO")))
        return;

    const long nEPSG = aoVCS[iVCS];

    if (nEPSG == 0)
    {
        CPLError(CE_Warning, CPLE_NotSupported, "SXF. Vertical coordinate system (SXF index %ld) not supported", iVCS);
        return;
    }

    OGRSpatialReference* sr = new OGRSpatialReference();
    OGRErr eImportFromEPSGErr = sr->importFromEPSG(nEPSG);
    if (eImportFromEPSGErr != OGRERR_NONE)
    {
        CPLError( CE_Warning, CPLE_None, "SXF. Vertical coordinate system (SXF index %ld, EPSG %ld) import from EPSG error", iVCS, nEPSG);
        return;
    }

    if (sr->IsVertical() != 1)
    {
        CPLError( CE_Warning, CPLE_None, "SXF. Coordinate system (SXF index %ld, EPSG %ld) is not Vertical", iVCS, nEPSG);
        return;
    }

    //passport.stMapDescription.pSpatRef->SetVertCS("Baltic", "Baltic Sea");
    OGRErr eSetVertCSErr = passport.stMapDescription.pSpatRef->SetVertCS(sr->GetAttrValue("VERT_CS"), sr->GetAttrValue("VERT_DATUM"));
    if (eSetVertCSErr != OGRERR_NONE)
    {
        CPLError(CE_Warning, CPLE_None, "SXF. Vertical coordinate system (SXF index %ld, EPSG %ld) set error", iVCS, nEPSG);
        return;
    }
}
示例#2
0
文件: gdal.cpp 项目: rundel/sfr
// [[Rcpp::export]]
Rcpp::List CPL_crs_parameters(std::string p4s) {
	Rcpp::List out(7);
	OGRErr Err;
	OGRSpatialReference *srs = new OGRSpatialReference;
	handle_error(srs->importFromProj4(p4s.c_str()));
	out(0) = Rcpp::NumericVector::create(srs->GetSemiMajor());
	out(1) = Rcpp::NumericVector::create(srs->GetSemiMinor());
	Rcpp::NumericVector InvFlattening(1);
	srs->GetInvFlattening(&Err);
	if (Err == OGRERR_FAILURE)
		InvFlattening(0) = NA_REAL; // #nocov
	else
		InvFlattening(0) = srs->GetInvFlattening(NULL); // for +ellps=sphere, still zero :-(
	out(2) = InvFlattening;
	out(3) = Rcpp::CharacterVector::create(srs->GetAttrValue("UNIT", 0));
	out(4) = Rcpp::LogicalVector::create(srs->IsVertical());
	char *cp;
	srs->exportToPrettyWkt(&cp);
	out(5) = Rcpp::CharacterVector::create(cp);
	CPLFree(cp);
	srs->exportToWkt(&cp);
	out(6) = Rcpp::CharacterVector::create(cp);
	CPLFree(cp);
	delete srs;
	return out;
}