From a167035343b1ac1d2905f17957cc974bfbfc800e Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 2 Oct 2019 16:33:03 +0200 Subject: nsper: add a comment to relate it to EPSG Vertical Perspective --- src/projections/nsper.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/projections/nsper.cpp b/src/projections/nsper.cpp index 059b9f71..852d0c98 100644 --- a/src/projections/nsper.cpp +++ b/src/projections/nsper.cpp @@ -4,6 +4,11 @@ #include "proj_internal.h" #include +/* Note: EPSG Guidance 7-2 describes a Vertical Perspective method (EPSG::9838), + * that extends 'nsper' with ellipsoidal development, and a ellipsoidal height + * of topocentric origin for the projection plan. + */ + namespace { // anonymous namespace enum Mode { N_POLE = 0, -- cgit v1.2.3 From f32255aa1139568df8cfb646ea62ca900939c105 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 2 Oct 2019 16:28:46 +0200 Subject: Add API and WKT mapping for 'nsper' to EPSG Vertical Persepective method Relates to https://github.com/OSGeo/gdal/issues/1856 --- src/iso19111/c_api.cpp | 40 +++++++++++++++++++++ src/iso19111/coordinateoperation.cpp | 67 ++++++++++++++++++++++++++++++++++++ src/proj_constants.h | 15 ++++++++ src/proj_experimental.h | 11 ++++++ 4 files changed, 133 insertions(+) (limited to 'src') diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp index 090d59a1..27a727dc 100644 --- a/src/iso19111/c_api.cpp +++ b/src/iso19111/c_api.cpp @@ -6266,6 +6266,46 @@ PJ *proj_create_conversion_equal_earth(PJ_CONTEXT *ctx, double center_long, } return nullptr; } + +// --------------------------------------------------------------------------- + +/** \brief Instantiate a conversion based on the Vertical Perspective projection + * method. + * + * See osgeo::proj::operation::Conversion::createVerticalPerspective(). + * + * Linear parameters are expressed in (linear_unit_name, + * linear_unit_conv_factor). + * Angular parameters are expressed in (ang_unit_name, ang_unit_conv_factor). + * + * @since 7.0 + */ +PJ *proj_create_conversion_vertical_perspective( + PJ_CONTEXT *ctx, double topo_origin_lat, double topo_origin_long, + double topo_origin_height, double view_point_height, double false_easting, + double false_northing, const char *ang_unit_name, + double ang_unit_conv_factor, const char *linear_unit_name, + double linear_unit_conv_factor) { + SANITIZE_CTX(ctx); + try { + UnitOfMeasure linearUnit( + createLinearUnit(linear_unit_name, linear_unit_conv_factor)); + UnitOfMeasure angUnit( + createAngularUnit(ang_unit_name, ang_unit_conv_factor)); + auto conv = Conversion::createVerticalPerspective( + PropertyMap(), Angle(topo_origin_lat, angUnit), + Angle(topo_origin_long, angUnit), + Length(topo_origin_height, linearUnit), + Length(view_point_height, linearUnit), + Length(false_easting, linearUnit), + Length(false_northing, linearUnit)); + return proj_create_conversion(ctx, conv); + } catch (const std::exception &e) { + proj_log_error(ctx, __FUNCTION__, e.what()); + } + return nullptr; +} + /* END: Generated by scripts/create_c_api_projections.py*/ // --------------------------------------------------------------------------- diff --git a/src/iso19111/coordinateoperation.cpp b/src/iso19111/coordinateoperation.cpp index d4f2903f..6e6d4cec 100644 --- a/src/iso19111/coordinateoperation.cpp +++ b/src/iso19111/coordinateoperation.cpp @@ -4577,6 +4577,52 @@ ConversionNNPtr Conversion::createEqualEarth( // --------------------------------------------------------------------------- +/** \brief Instantiate a conversion based on the [Vertical Perspective] + * (https://proj.org/operations/projections/nsper.html) projection method. + * + * This method is defined as [EPSG:9838] + * (https://www.epsg-registry.org/export.htm?gml=urn:ogc:def:method:EPSG::9838) + * + * The PROJ implementation of the EPSG Vertical Perspective has the current + * limitations with respect to the method described in EPSG: + *
    + *
  • it is a 2D-only method, ignoring the ellipsoidal height of the point to + * project.
  • + *
  • it has only a spherical development.
  • + *
  • the height of the topocentric origin is ignored, and thus assumed to be + * 0.
  • + *
+ * + * For completness, PROJ adds the falseEasting and falseNorthing parameter, + * which are not described in EPSG. They should usually be set to 0. + * + * @param properties See \ref general_properties of the conversion. If the name + * is not provided, it is automatically set. + * @param topoOriginLat Latitude of topocentric origin + * @param topoOriginLong Longitude of topocentric origin + * @param topoOriginHeight Ellipsoidal height of topocentric origin. Ignored by + * PROJ (that is assumed to be 0) + * @param viewPointHeight Viewpoint height with respect to the + * topocentric/mapping plane. In the case where topoOriginHeight = 0, this is + * the height above the ellipsoid surface at topoOriginLat, topoOriginLong. + * @param falseEasting See \ref false_easting . (not in EPSG) + * @param falseNorthing See \ref false_northing . (not in EPSG) + * @return a new Conversion. + * + * @since 7.0 + */ +ConversionNNPtr Conversion::createVerticalPerspective( + const util::PropertyMap &properties, const common::Angle &topoOriginLat, + const common::Angle &topoOriginLong, const common::Length &topoOriginHeight, + const common::Length &viewPointHeight, const common::Length &falseEasting, + const common::Length &falseNorthing) { + return create(properties, EPSG_CODE_METHOD_VERTICAL_PERSPECTIVE, + createParams(topoOriginLat, topoOriginLong, topoOriginHeight, + viewPointHeight, falseEasting, falseNorthing)); +} + +// --------------------------------------------------------------------------- + //! @cond Doxygen_Suppress static OperationParameterNNPtr createOpParamNameEPSGCode(int code) { @@ -5450,6 +5496,27 @@ void Conversion::_exportToWKT(io::WKTFormatter *formatter) const { } } } + // Same for false easting / false northing for Vertical Perspective + else if (methodEPSGCode == EPSG_CODE_METHOD_VERTICAL_PERSPECTIVE) { + auto opParamvalue = + dynamic_cast( + genOpParamvalue.get()); + if (opParamvalue) { + const auto paramEPSGCode = + opParamvalue->parameter()->getEPSGCode(); + if (paramEPSGCode == EPSG_CODE_PARAMETER_FALSE_EASTING || + paramEPSGCode == EPSG_CODE_PARAMETER_FALSE_NORTHING) { + const auto ¶mValue = opParamvalue->parameterValue(); + if (paramValue->type() == + ParameterValue::Type::MEASURE) { + const auto &measure = paramValue->value(); + if (measure.getSIValue() == 0) { + continue; + } + } + } + } + } genOpParamvalue->_exportToWKT(formatter, mapping); } } diff --git a/src/proj_constants.h b/src/proj_constants.h index d3f33c73..619d9d91 100644 --- a/src/proj_constants.h +++ b/src/proj_constants.h @@ -212,6 +212,9 @@ #define EPSG_NAME_METHOD_LABORDE_OBLIQUE_MERCATOR "Laborde Oblique Mercator" #define EPSG_CODE_METHOD_LABORDE_OBLIQUE_MERCATOR 9813 +#define EPSG_NAME_METHOD_VERTICAL_PERSPECTIVE "Vertical Perspective" +#define EPSG_CODE_METHOD_VERTICAL_PERSPECTIVE 9838 + /* ------------------------------------------------------------------------ */ /* Projection parameters */ @@ -301,6 +304,18 @@ #define EPSG_NAME_PARAMETER_ELLIPSOID_SCALE_FACTOR "Ellipsoid scaling factor" #define EPSG_CODE_PARAMETER_ELLIPSOID_SCALE_FACTOR 1038 +#define EPSG_NAME_PARAMETER_LATITUDE_TOPOGRAPHIC_ORIGIN "Latitude of topocentric origin" +#define EPSG_CODE_PARAMETER_LATITUDE_TOPOGRAPHIC_ORIGIN 8834 + +#define EPSG_NAME_PARAMETER_LONGITUDE_TOPOGRAPHIC_ORIGIN "Longitude of topocentric origin" +#define EPSG_CODE_PARAMETER_LONGITUDE_TOPOGRAPHIC_ORIGIN 8835 + +#define EPSG_NAME_PARAMETER_ELLIPSOIDAL_HEIGHT_TOPOCENTRIC_ORIGIN "Ellipsoidal height of topocentric origin" +#define EPSG_CODE_PARAMETER_ELLIPSOIDAL_HEIGHT_TOPOCENTRIC_ORIGIN 8836 + +#define EPSG_NAME_PARAMETER_VIEWPOINT_HEIGHT "Viewpoint height" +#define EPSG_CODE_PARAMETER_VIEWPOINT_HEIGHT 8840 + /* ------------------------------------------------------------------------ */ /* Other conversions and transformations */ diff --git a/src/proj_experimental.h b/src/proj_experimental.h index dcb2e888..9a1a6045 100644 --- a/src/proj_experimental.h +++ b/src/proj_experimental.h @@ -918,6 +918,17 @@ PJ PROJ_DLL *proj_create_conversion_equal_earth( const char* ang_unit_name, double ang_unit_conv_factor, const char* linear_unit_name, double linear_unit_conv_factor); +PJ PROJ_DLL *proj_create_conversion_vertical_perspective( + PJ_CONTEXT *ctx, + double topo_origin_lat, + double topo_origin_long, + double topo_origin_height, + double view_point_height, + double false_easting, + double false_northing, + const char* ang_unit_name, double ang_unit_conv_factor, + const char* linear_unit_name, double linear_unit_conv_factor); + /* END: Generated by scripts/create_c_api_projections.py*/ /**@}*/ -- cgit v1.2.3