Commit 670398b8 authored by Julien Osman's avatar Julien Osman
Browse files

ENH: Add SpatialReference::FromGeogCS

parent 55fea8c4
......@@ -132,6 +132,22 @@ public:
static SpatialReference FromUTM(unsigned int zone, hemisphere hem);
/**
* \brief Build a SpatialReference from the datum, ellipsoid, prime meridian and angular units
*
* See OGRSpatialReference::SetGeogCS for more details.
*
* \param GeogName user visible name for the geographic coordinate system
* \param DatumName key name for this datum.
* \param SpheroidName user visible spheroid name
* \param SemiMajor the semi major axis of the spheroid
* \param InvFlattening the inverse flattening for the spheroid
* \throws InvalidSRDescriptionException in case of failure of FromGeogCS()
*/
static SpatialReference FromGeogCS(const std::string& GeogName, const std::string& DatumName,
const std::string& SpheroidName, const double SemiMajor,
const double InvFlattening);
/// Copy constructor
SpatialReference(const SpatialReference& other) noexcept;
......
......@@ -185,6 +185,22 @@ SpatialReference SpatialReference::FromUTM(unsigned int zone, hemisphere hem)
return SpatialReference(std::move(tmpSR));
}
SpatialReference SpatialReference::FromGeogCS(const std::string& GeogName, const std::string& DatumName,
const std::string& SpheroidName, const double SemiMajor,
const double InvFlattening)
{
OGRSpatialReferencePtr tmpSR(new OGRSpatialReference());
OGRErr code = tmpSR->SetGeogCS(GeogName.c_str(), DatumName.c_str(), SpheroidName.c_str(), SemiMajor, InvFlattening);
if (code != OGRERR_NONE)
{
std::ostringstream oss;
oss << "(InvalidSRDescriptionException) "
<< "FromGeogCS(" << GeogName << ", " << DatumName << ", " << SpheroidName << ", " << SemiMajor << ", " << InvFlattening << ")";
throw std::runtime_error(oss.str());
}
return SpatialReference(std::move(tmpSR));
}
std::string SpatialReference::ToWkt() const
{
char* cwkt;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment