aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/proj/coordinatesystem.hpp8
-rw-r--r--scripts/reference_exported_symbols.txt2
-rw-r--r--src/iso19111/c_api.cpp52
-rw-r--r--src/iso19111/coordinatesystem.cpp22
-rw-r--r--src/proj_experimental.h16
-rw-r--r--test/unit/test_c_api.cpp155
6 files changed, 255 insertions, 0 deletions
diff --git a/include/proj/coordinatesystem.hpp b/include/proj/coordinatesystem.hpp
index ffb908fc..985ac15b 100644
--- a/include/proj/coordinatesystem.hpp
+++ b/include/proj/coordinatesystem.hpp
@@ -352,19 +352,27 @@ class PROJ_GCC_DLL EllipsoidalCS final : public CoordinateSystem {
create(const util::PropertyMap &properties,
const CoordinateSystemAxisNNPtr &axis1,
const CoordinateSystemAxisNNPtr &axis2);
+
PROJ_DLL static EllipsoidalCSNNPtr
create(const util::PropertyMap &properties,
const CoordinateSystemAxisNNPtr &axis1,
const CoordinateSystemAxisNNPtr &axis2,
const CoordinateSystemAxisNNPtr &axis3);
+
PROJ_DLL static EllipsoidalCSNNPtr
createLatitudeLongitude(const common::UnitOfMeasure &unit);
+
PROJ_DLL static EllipsoidalCSNNPtr createLatitudeLongitudeEllipsoidalHeight(
const common::UnitOfMeasure &angularUnit,
const common::UnitOfMeasure &linearUnit);
+
PROJ_DLL static EllipsoidalCSNNPtr
createLongitudeLatitude(const common::UnitOfMeasure &unit);
+ PROJ_DLL static EllipsoidalCSNNPtr createLongitudeLatitudeEllipsoidalHeight(
+ const common::UnitOfMeasure &angularUnit,
+ const common::UnitOfMeasure &linearUnit);
+
//! @cond Doxygen_Suppress
/** \brief Typical axis order. */
diff --git a/scripts/reference_exported_symbols.txt b/scripts/reference_exported_symbols.txt
index 71de2d0e..c6937d18 100644
--- a/scripts/reference_exported_symbols.txt
+++ b/scripts/reference_exported_symbols.txt
@@ -202,6 +202,7 @@ osgeo::proj::cs::DateTimeTemporalCS::create(osgeo::proj::util::PropertyMap const
osgeo::proj::cs::DateTimeTemporalCS::~DateTimeTemporalCS()
osgeo::proj::cs::EllipsoidalCS::createLatitudeLongitudeEllipsoidalHeight(osgeo::proj::common::UnitOfMeasure const&, osgeo::proj::common::UnitOfMeasure const&)
osgeo::proj::cs::EllipsoidalCS::createLatitudeLongitude(osgeo::proj::common::UnitOfMeasure const&)
+osgeo::proj::cs::EllipsoidalCS::createLongitudeLatitudeEllipsoidalHeight(osgeo::proj::common::UnitOfMeasure const&, osgeo::proj::common::UnitOfMeasure const&)
osgeo::proj::cs::EllipsoidalCS::createLongitudeLatitude(osgeo::proj::common::UnitOfMeasure const&)
osgeo::proj::cs::EllipsoidalCS::create(osgeo::proj::util::PropertyMap const&, dropbox::oxygen::nn<std::shared_ptr<osgeo::proj::cs::CoordinateSystemAxis> > const&, dropbox::oxygen::nn<std::shared_ptr<osgeo::proj::cs::CoordinateSystemAxis> > const&)
osgeo::proj::cs::EllipsoidalCS::create(osgeo::proj::util::PropertyMap const&, dropbox::oxygen::nn<std::shared_ptr<osgeo::proj::cs::CoordinateSystemAxis> > const&, dropbox::oxygen::nn<std::shared_ptr<osgeo::proj::cs::CoordinateSystemAxis> > const&, dropbox::oxygen::nn<std::shared_ptr<osgeo::proj::cs::CoordinateSystemAxis> > const&)
@@ -878,6 +879,7 @@ proj_create_crs_to_crs
proj_create_crs_to_crs_from_pj
proj_create_cs
proj_create_ellipsoidal_2D_cs
+proj_create_ellipsoidal_3D_cs
proj_create_engineering_crs
proj_create_from_database
proj_create_from_name
diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp
index 312daeab..1ae79fa3 100644
--- a/src/iso19111/c_api.cpp
+++ b/src/iso19111/c_api.cpp
@@ -3763,6 +3763,58 @@ PJ *proj_create_ellipsoidal_2D_cs(PJ_CONTEXT *ctx,
// ---------------------------------------------------------------------------
+/** \brief Instantiate a Ellipsoidal 3D
+ *
+ * The returned object must be unreferenced with proj_destroy() after
+ * use.
+ * It should be used by at most one thread at a time.
+ *
+ * @param ctx PROJ context, or NULL for default context
+ * @param type Coordinate system type.
+ * @param horizontal_angular_unit_name Horizontal angular unit name.
+ * @param horizontal_angular_unit_conv_factor Horizontal angular unit conversion
+ * factor to SI.
+ * @param vertical_linear_unit_name Vertical linear unit name.
+ * @param vertical_linear_unit_conv_factor Vertical linear unit conversion
+ * factor to SI.
+ *
+ * @return Object that must be unreferenced with
+ * proj_destroy(), or NULL in case of error.
+ * @since 7.0
+ */
+
+PJ *proj_create_ellipsoidal_3D_cs(PJ_CONTEXT *ctx,
+ PJ_ELLIPSOIDAL_CS_3D_TYPE type,
+ const char *horizontal_angular_unit_name,
+ double horizontal_angular_unit_conv_factor,
+ const char *vertical_linear_unit_name,
+ double vertical_linear_unit_conv_factor) {
+ try {
+ switch (type) {
+ case PJ_ELLPS3D_LONGITUDE_LATITUDE_HEIGHT:
+ return pj_obj_create(
+ ctx, EllipsoidalCS::createLongitudeLatitudeEllipsoidalHeight(
+ createAngularUnit(horizontal_angular_unit_name,
+ horizontal_angular_unit_conv_factor),
+ createLinearUnit(vertical_linear_unit_name,
+ vertical_linear_unit_conv_factor)));
+
+ case PJ_ELLPS3D_LATITUDE_LONGITUDE_HEIGHT:
+ return pj_obj_create(
+ ctx, EllipsoidalCS::createLatitudeLongitudeEllipsoidalHeight(
+ createAngularUnit(horizontal_angular_unit_name,
+ horizontal_angular_unit_conv_factor),
+ createLinearUnit(vertical_linear_unit_name,
+ vertical_linear_unit_conv_factor)));
+ }
+ } catch (const std::exception &e) {
+ proj_log_error(ctx, __FUNCTION__, e.what());
+ }
+ return nullptr;
+}
+
+// ---------------------------------------------------------------------------
+
/** \brief Instantiate a ProjectedCRS
*
* The returned object must be unreferenced with proj_destroy() after
diff --git a/src/iso19111/coordinatesystem.cpp b/src/iso19111/coordinatesystem.cpp
index 5a852b0d..c452da44 100644
--- a/src/iso19111/coordinatesystem.cpp
+++ b/src/iso19111/coordinatesystem.cpp
@@ -789,6 +789,28 @@ EllipsoidalCS::createLongitudeLatitude(const common::UnitOfMeasure &unit) {
// ---------------------------------------------------------------------------
+/** \brief Instantiate a EllipsoidalCS with a Longitude (first), Latitude
+ * (second) axis and ellipsoidal height (third) axis.
+ *
+ * @param angularUnit Angular unit of the latitude and longitude axes.
+ * @param linearUnit Linear unit of the ellipsoidal height axis.
+ * @return a new EllipsoidalCS.
+ * @since 7.0
+ */
+EllipsoidalCSNNPtr EllipsoidalCS::createLongitudeLatitudeEllipsoidalHeight(
+ const common::UnitOfMeasure &angularUnit,
+ const common::UnitOfMeasure &linearUnit) {
+ return EllipsoidalCS::create(
+ util::PropertyMap(), CoordinateSystemAxis::createLONG_EAST(angularUnit),
+ CoordinateSystemAxis::createLAT_NORTH(angularUnit),
+ CoordinateSystemAxis::create(
+ util::PropertyMap().set(IdentifiedObject::NAME_KEY,
+ AxisName::Ellipsoidal_height),
+ AxisAbbreviation::h, AxisDirection::UP, linearUnit));
+}
+
+// ---------------------------------------------------------------------------
+
//! @cond Doxygen_Suppress
/** \brief Return the axis order in an enumerated way. */
EllipsoidalCS::AxisOrder EllipsoidalCS::axisOrder() const {
diff --git a/src/proj_experimental.h b/src/proj_experimental.h
index 0e97ac9f..5a96203c 100644
--- a/src/proj_experimental.h
+++ b/src/proj_experimental.h
@@ -130,6 +130,22 @@ PJ PROJ_DLL *proj_create_ellipsoidal_2D_cs(PJ_CONTEXT *ctx,
const char* unit_name,
double unit_conv_factor);
+/** Type of Ellipsoidal 3D coordinate system. */
+typedef enum
+{
+ /* Longitude-Latitude-Height(up) */
+ PJ_ELLPS3D_LONGITUDE_LATITUDE_HEIGHT,
+ /* Latitude-Longitude-Height(up) */
+ PJ_ELLPS3D_LATITUDE_LONGITUDE_HEIGHT,
+} PJ_ELLIPSOIDAL_CS_3D_TYPE;
+
+PJ PROJ_DLL *proj_create_ellipsoidal_3D_cs(PJ_CONTEXT *ctx,
+ PJ_ELLIPSOIDAL_CS_3D_TYPE type,
+ const char* horizontal_angular_unit_name,
+ double horizontal_angular_unit_conv_factor,
+ const char* vertical_linear_unit_name,
+ double vertical_linear_unit_conv_factor);
+
PJ_OBJ_LIST PROJ_DLL *proj_query_geodetic_crs_from_datum(
PJ_CONTEXT *ctx,
const char *crs_auth_name,
diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp
index 2a1c8577..52e6272c 100644
--- a/test/unit/test_c_api.cpp
+++ b/test/unit/test_c_api.cpp
@@ -3737,4 +3737,159 @@ TEST_F(CApi, proj_create_crs_to_crs_from_pj) {
"+step +proj=utm +zone=31 +ellps=WGS84");
}
+// ---------------------------------------------------------------------------
+
+static void
+check_axis_is_latitude(PJ_CONTEXT *ctx, PJ *cs, int axis_number,
+ const char *unit_name = "degree",
+ double unit_conv_factor = 0.017453292519943295,
+ const char *auth = "EPSG", const char *code = "9122") {
+
+ const char *name = nullptr;
+ const char *abbrev = nullptr;
+ const char *direction = nullptr;
+ double unitConvFactor = 0.0;
+ const char *unitName = nullptr;
+ const char *unitAuthority = nullptr;
+ const char *unitCode = nullptr;
+
+ EXPECT_TRUE(proj_cs_get_axis_info(ctx, cs, axis_number, &name, &abbrev,
+ &direction, &unitConvFactor, &unitName,
+ &unitAuthority, &unitCode));
+ ASSERT_NE(name, nullptr);
+ ASSERT_NE(abbrev, nullptr);
+ ASSERT_NE(direction, nullptr);
+ ASSERT_NE(unitName, nullptr);
+ if (auth) {
+ ASSERT_NE(unitAuthority, nullptr);
+ ASSERT_NE(unitCode, nullptr);
+ }
+ EXPECT_EQ(std::string(name), "Latitude");
+ EXPECT_EQ(std::string(abbrev), "lat");
+ EXPECT_EQ(std::string(direction), "north");
+ EXPECT_EQ(unitConvFactor, unit_conv_factor) << unitConvFactor;
+ EXPECT_EQ(std::string(unitName), unit_name);
+ if (auth) {
+ EXPECT_EQ(std::string(unitAuthority), auth);
+ EXPECT_EQ(std::string(unitCode), code);
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+static void
+check_axis_is_longitude(PJ_CONTEXT *ctx, PJ *cs, int axis_number,
+ const char *unit_name = "degree",
+ double unit_conv_factor = 0.017453292519943295,
+ const char *auth = "EPSG", const char *code = "9122") {
+
+ const char *name = nullptr;
+ const char *abbrev = nullptr;
+ const char *direction = nullptr;
+ double unitConvFactor = 0.0;
+ const char *unitName = nullptr;
+ const char *unitAuthority = nullptr;
+ const char *unitCode = nullptr;
+
+ EXPECT_TRUE(proj_cs_get_axis_info(ctx, cs, axis_number, &name, &abbrev,
+ &direction, &unitConvFactor, &unitName,
+ &unitAuthority, &unitCode));
+ ASSERT_NE(name, nullptr);
+ ASSERT_NE(abbrev, nullptr);
+ ASSERT_NE(direction, nullptr);
+ ASSERT_NE(unitName, nullptr);
+ if (auth) {
+ ASSERT_NE(unitAuthority, nullptr);
+ ASSERT_NE(unitCode, nullptr);
+ }
+ EXPECT_EQ(std::string(name), "Longitude");
+ EXPECT_EQ(std::string(abbrev), "lon");
+ EXPECT_EQ(std::string(direction), "east");
+ EXPECT_EQ(unitConvFactor, unit_conv_factor) << unitConvFactor;
+ EXPECT_EQ(std::string(unitName), unit_name);
+ if (auth) {
+ EXPECT_EQ(std::string(unitAuthority), auth);
+ EXPECT_EQ(std::string(unitCode), code);
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+static void check_axis_is_height(PJ_CONTEXT *ctx, PJ *cs, int axis_number,
+ const char *unit_name = "metre",
+ double unit_conv_factor = 1,
+ const char *auth = "EPSG",
+ const char *code = "9001") {
+
+ const char *name = nullptr;
+ const char *abbrev = nullptr;
+ const char *direction = nullptr;
+ double unitConvFactor = 0.0;
+ const char *unitName = nullptr;
+ const char *unitAuthority = nullptr;
+ const char *unitCode = nullptr;
+
+ EXPECT_TRUE(proj_cs_get_axis_info(ctx, cs, axis_number, &name, &abbrev,
+ &direction, &unitConvFactor, &unitName,
+ &unitAuthority, &unitCode));
+ ASSERT_NE(name, nullptr);
+ ASSERT_NE(abbrev, nullptr);
+ ASSERT_NE(direction, nullptr);
+ ASSERT_NE(unitName, nullptr);
+ if (auth) {
+ ASSERT_NE(unitAuthority, nullptr);
+ ASSERT_NE(unitCode, nullptr);
+ }
+ EXPECT_EQ(std::string(name), "Ellipsoidal height");
+ EXPECT_EQ(std::string(abbrev), "h");
+ EXPECT_EQ(std::string(direction), "up");
+ EXPECT_EQ(unitConvFactor, unit_conv_factor) << unitConvFactor;
+ EXPECT_EQ(std::string(unitName), unit_name);
+ if (auth) {
+ EXPECT_EQ(std::string(unitAuthority), auth);
+ EXPECT_EQ(std::string(unitCode), code);
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+TEST_F(CApi, proj_create_ellipsoidal_3D_cs) {
+
+ {
+ auto cs = proj_create_ellipsoidal_3D_cs(
+ m_ctxt, PJ_ELLPS3D_LATITUDE_LONGITUDE_HEIGHT, nullptr, 0, nullptr,
+ 0);
+ ObjectKeeper keeper_cs(cs);
+ ASSERT_NE(cs, nullptr);
+
+ EXPECT_EQ(proj_cs_get_type(m_ctxt, cs), PJ_CS_TYPE_ELLIPSOIDAL);
+
+ EXPECT_EQ(proj_cs_get_axis_count(m_ctxt, cs), 3);
+
+ check_axis_is_latitude(m_ctxt, cs, 0);
+
+ check_axis_is_longitude(m_ctxt, cs, 1);
+
+ check_axis_is_height(m_ctxt, cs, 2);
+ }
+
+ {
+ auto cs = proj_create_ellipsoidal_3D_cs(
+ m_ctxt, PJ_ELLPS3D_LONGITUDE_LATITUDE_HEIGHT, "foo", 0.5, "bar",
+ 0.6);
+ ObjectKeeper keeper_cs(cs);
+ ASSERT_NE(cs, nullptr);
+
+ EXPECT_EQ(proj_cs_get_type(m_ctxt, cs), PJ_CS_TYPE_ELLIPSOIDAL);
+
+ EXPECT_EQ(proj_cs_get_axis_count(m_ctxt, cs), 3);
+
+ check_axis_is_longitude(m_ctxt, cs, 0, "foo", 0.5, nullptr, nullptr);
+
+ check_axis_is_latitude(m_ctxt, cs, 1, "foo", 0.5, nullptr, nullptr);
+
+ check_axis_is_height(m_ctxt, cs, 2, "bar", 0.6, nullptr, nullptr);
+ }
+}
+
} // namespace