Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

rouault
Copy link
Member

@rouault rouault commented Feb 4, 2025

(on top of PR #4393; only last commit is specific to this PR)

Fixes #4392

/** \brief Transform boundary, taking into account 3D coordinates.
 *
 * Transform boundary densifying the edges to account for nonlinear
 * transformations along these edges and extracting the outermost bounds.
 *
 * Note that the current implementation is not "perfect" when the source CRS is
 * geocentric, the target CRS is geographic, and the input bounding box
 * includes the center of the Earth, a pole or the antimeridian. In those
 * circumstances, exact values of the latitude of longitude of discontinuity
 * will not be returned.
 *
 * If one of the source or target CRS of the transformation is not 3D, the
 * values of *out_zmin / *out_zmax may not be significant.
 *
 * For 2D or "2.5D" transformation (that is planar component is
 * geographic/coordinates and 3D axis is elevation), the documentation of
 * proj_trans_bounds() applies.
 *
 * @param context The PJ_CONTEXT object.
 * @param P The PJ object representing the transformation.
 * @param direction The direction of the transformation.
 * @param xmin Minimum bounding coordinate of the first axis in source CRS
 *             (target CRS if direction is inverse).
 * @param ymin Minimum bounding coordinate of the second axis in source CRS.
 *             (target CRS if direction is inverse).
 * @param zmin Minimum bounding coordinate of the third axis in source CRS.
 *             (target CRS if direction is inverse).
 * @param xmax Maximum bounding coordinate of the first axis in source CRS.
 *             (target CRS if direction is inverse).
 * @param ymax Maximum bounding coordinate of the second axis in source CRS.
 *             (target CRS if direction is inverse).
 * @param zmax Maximum bounding coordinate of the third axis in source CRS.
 *             (target CRS if direction is inverse).
 * @param out_xmin Minimum bounding coordinate of the first axis in target CRS
 *             (source CRS if direction is inverse).
 * @param out_ymin Minimum bounding coordinate of the second axis in target CRS.
 *             (source CRS if direction is inverse).
 * @param out_zmin Minimum bounding coordinate of the third axis in target CRS.
 *             (source CRS if direction is inverse).
 * @param out_xmax Maximum bounding coordinate of the first axis in target CRS.
 *             (source CRS if direction is inverse).
 * @param out_ymax Maximum bounding coordinate of the second axis in target CRS.
 *             (source CRS if direction is inverse).
 * @param out_zmax Maximum bounding coordinate of the third axis in target CRS.
 *             (source CRS if direction is inverse).
 * @param densify_pts Recommended to use 21. This is the number of points
 *     to use to densify the bounding polygon in the transformation.
 * @return an integer. 1 if successful. 0 if failures encountered.
 * @since 9.6
 */

@rouault rouault added the funded through GSP Work funded through the GDAL Sponsorship Program label Feb 4, 2025
@rouault rouault added this to the 9.6.0 milestone Feb 4, 2025
@rouault rouault force-pushed the proj_trans_bounds_3D branch 3 times, most recently from 8a6c085 to 51f6720 Compare February 4, 2025 20:36
@nyalldawson
Copy link
Contributor

Thanks @rouault !

@rouault rouault force-pushed the proj_trans_bounds_3D branch 2 times, most recently from f1e0ef6 to 6158a7d Compare February 5, 2025 09:16
No functional change, just moving code around.

4D_api.cpp has become quite large and a set of 'random' things, that
didn't correlate well with the '4D' naming. Some re-organization was needed.

Create following files:
- src/area.cpp: PJ_AREA related code
- src/coordinates.cpp: functions related to coordinate manipulation
- src/coord_operation.cpp: PJCoordOperation methods
- src/create.cpp: pj_create_internal() related stuff
- src/crs_to_crs.cpp: proj_create_crs_to_crs() and the like
- src/dist.cpp: distance related functions
- src/info.cpp: proj_info() and proj_pj_info()
- src/trans.cpp: proj_trans(), proj_trans_array(), proj_trans_generic(), proj_roundtrip()
- src/trans_bounds.cpp: proj_trans_bounds()

Some other functions also moved to more relevant existing source files.
Fixes OSGeo#4392

```c++
/** \brief Transform boundary, taking into account 3D coordinates.
 *
 * Transform boundary densifying the edges to account for nonlinear
 * transformations along these edges and extracting the outermost bounds.
 *
 * Note that the current implementation is not "perfect" when the source CRS is
 * geocentric, the target CRS is geographic, and the input bounding box
 * includes the center of the Earth, a pole or the antimeridian. In those
 * circumstances, exact values of the latitude of longitude of discontinuity
 * will not be returned.
 *
 * If one of the source or target CRS of the transformation is not 3D, the
 * values of *out_zmin / *out_zmax may not be significant.
 *
 * For 2D or "2.5D" transformation (that is planar component is
 * geographic/coordinates and 3D axis is elevation), the documentation of
 * proj_trans_bounds() applies.
 *
 * @param context The PJ_CONTEXT object.
 * @param P The PJ object representing the transformation.
 * @param direction The direction of the transformation.
 * @param xmin Minimum bounding coordinate of the first axis in source CRS
 *             (target CRS if direction is inverse).
 * @param ymin Minimum bounding coordinate of the second axis in source CRS.
 *             (target CRS if direction is inverse).
 * @param zmin Minimum bounding coordinate of the third axis in source CRS.
 *             (target CRS if direction is inverse).
 * @param xmax Maximum bounding coordinate of the first axis in source CRS.
 *             (target CRS if direction is inverse).
 * @param ymax Maximum bounding coordinate of the second axis in source CRS.
 *             (target CRS if direction is inverse).
 * @param zmax Maximum bounding coordinate of the third axis in source CRS.
 *             (target CRS if direction is inverse).
 * @param out_xmin Minimum bounding coordinate of the first axis in target CRS
 *             (source CRS if direction is inverse).
 * @param out_ymin Minimum bounding coordinate of the second axis in target CRS.
 *             (source CRS if direction is inverse).
 * @param out_zmin Minimum bounding coordinate of the third axis in target CRS.
 *             (source CRS if direction is inverse).
 * @param out_xmax Maximum bounding coordinate of the first axis in target CRS.
 *             (source CRS if direction is inverse).
 * @param out_ymax Maximum bounding coordinate of the second axis in target CRS.
 *             (source CRS if direction is inverse).
 * @param out_zmax Maximum bounding coordinate of the third axis in target CRS.
 *             (source CRS if direction is inverse).
 * @param densify_pts Recommended to use 21. This is the number of points
 *     to use to densify the bounding polygon in the transformation.
 * @return an integer. 1 if successful. 0 if failures encountered.
 * @SInCE 9.6
 */
```
@rouault rouault force-pushed the proj_trans_bounds_3D branch from 6158a7d to 99a8b73 Compare February 5, 2025 10:15
@snowman2
Copy link
Contributor

snowman2 commented Feb 6, 2025

Would there be any benefit to adding the time component?

One idea I have was for this to behave like proj_trans and make z and t optional. Then, this would become the successor of proj_trans_bounds.

@rouault
Copy link
Member Author

rouault commented Feb 6, 2025

Would there be any benefit to adding the time component?

I considered that for about 1000 ms, but failed to see the practical interest, so I preferred to keep things simpler.

@rouault rouault merged commit 77bb0cc into OSGeo:master Feb 6, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

funded through GSP Work funded through the GDAL Sponsorship Program

Projects

None yet

Development

Successfully merging this pull request may close these issues.

proj_trans_bounds for 3d bounding boxes

3 participants