aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-10-02 16:28:46 +0200
committerEven Rouault <even.rouault@spatialys.com>2019-10-02 20:34:08 +0200
commitf32255aa1139568df8cfb646ea62ca900939c105 (patch)
tree496cf41d98468db2a74673619c235b2f71830889 /src
parenta167035343b1ac1d2905f17957cc974bfbfc800e (diff)
downloadPROJ-f32255aa1139568df8cfb646ea62ca900939c105.tar.gz
PROJ-f32255aa1139568df8cfb646ea62ca900939c105.zip
Add API and WKT mapping for 'nsper' to EPSG Vertical Persepective method
Relates to https://github.com/OSGeo/gdal/issues/1856
Diffstat (limited to 'src')
-rw-r--r--src/iso19111/c_api.cpp40
-rw-r--r--src/iso19111/coordinateoperation.cpp67
-rw-r--r--src/proj_constants.h15
-rw-r--r--src/proj_experimental.h11
4 files changed, 133 insertions, 0 deletions
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:
+ * <ul>
+ * <li> it is a 2D-only method, ignoring the ellipsoidal height of the point to
+ * project.</li>
+ * <li> it has only a spherical development.</li>
+ * <li> the height of the topocentric origin is ignored, and thus assumed to be
+ * 0.</li>
+ * </ul>
+ *
+ * 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<const OperationParameterValue *>(
+ 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 &paramValue = 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*/
/**@}*/