Skip to content

Commit

Permalink
Merge pull request OSGeo#2780 from mwtoews/nlohmann_json_interface_lib
Browse files Browse the repository at this point in the history
CMake: remove external nlohmann_json from INTERFACE_LINK_LIBRARIES target
  • Loading branch information
a0x8o committed Jul 19, 2021
1 parent 529f80a commit b74235c
Show file tree
Hide file tree
Showing 12 changed files with 691 additions and 15 deletions.
1 change: 1 addition & 0 deletions docs/source/operations/projections/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ Projections map the spherical 3D space to a flat 2D space.
robin
rouss
rpoly
s2
sch
sinu
somerc
Expand Down
120 changes: 120 additions & 0 deletions docs/source/operations/projections/s2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
.. _s2:

********************************************************************************
S2
********************************************************************************

+---------------------+----------------------------------------------------------+
| **Classification** | Miscellaneous |
+---------------------+----------------------------------------------------------+
| **Available forms** | Forward and inverse, ellipsoidal |
+---------------------+----------------------------------------------------------+
| **Defined area** | Global |
+---------------------+----------------------------------------------------------+
| **Alias** | s2 |
+---------------------+----------------------------------------------------------+
| **Domain** | 2D |
+---------------------+----------------------------------------------------------+
| **Input type** | Geodetic coordinates |
+---------------------+----------------------------------------------------------+
| **Output type** | Projected coordinates |
+---------------------+----------------------------------------------------------+

.. versionadded:: 8.2

The S2 projection, like the Quadrilateralized Spherical Cube (QSC) projection, projects
a sphere surface onto the six sides of a cube:

.. image:: ../../../images/qsc_concept.jpg
:width: 500 px
:align: center
:alt: Quadrilateralized Spherical Cube

S2 was created by Google to represent geographic data on the whole earth. The documentation can be found
at `S2 Geometry <https://s2geometry.io/>`_ It works by first
projecting a point on the sphere to a face of the cube. These are called u,v-coordinates, and they are in [-1,1] x [-1,1].
This step is followed by a non-linear transformation to normalize the area of rectangles on the sphere. There are three
different choices available for this transformation, meaning that S2 is a family of projections. The final output is in
s,t-coordinates, which are in [0,1] x [0,1].
See the comments in `S2 Code <https://github.com/google/s2geometry/blob/0c4c460bdfe696da303641771f9def900b3e440f/src/s2/s2coords.h#L226>`_
for an explanation of the tradeoff between speed and area-preservation. Note that the projection is azimuthal when "none" or
"linear" is selected for the area-normalization, but it is not azimuthal when "quadratic" or "tangent" is chosen. See
S2's `Earthcube page <https://s2geometry.io/resources/earthcube>`_
to visualize the unfolded cube and the orientation of each face.

In this implementation, the cube side is selected by choosing one of the following six projection centers:

+-------------------------+--------------------+
| ``+lat_0=0 +lon_0=0`` | front cube side |
+-------------------------+--------------------+
| ``+lat_0=0 +lon_0=90`` | right cube side |
+-------------------------+--------------------+
| ``+lat_0=0 +lon_0=180`` | back cube side |
+-------------------------+--------------------+
| ``+lat_0=0 +lon_0=-90`` | left cube side |
+-------------------------+--------------------+
| ``+lat_0=90`` | top cube side |
+-------------------------+--------------------+
| ``+lat_0=-90`` | bottom cube side |
+-------------------------+--------------------+

The specific transformation can be chosen with the UVtoST parameter:

+-------------------------+-----------------------------+
| ``+UVtoST=linear`` | fastest, no normalization |
+-------------------------+-----------------------------+
| ``+UVtoST=quadratic`` | fast, good normalization |
+-------------------------+-----------------------------+
| ``+UVtoST=tangent`` | slowest, best normalization |
+-------------------------+-----------------------------+
| ``+UVtoST=none`` | returns u,v-coordinates |
+-------------------------+-----------------------------+

Furthermore, this implementation allows the projection to be applied to ellipsoids.
A preceding shift to a sphere is performed automatically; see :cite:`LambersKolb2012` for details.
The output of the projection is in s,t-coordinates ([0,1] x [0,1]), so only the
eccentricity of the ellipse is taken into account: the absolute value of the axes does
not affect the output.


Usage
###############################################################################

The following example uses S2 on the right face::

echo 90 0 | ../bin/proj +proj=s2 +lat_0=0 +lon_0=90 +ellps=WGS84 +UVtoST=linear

0.5 0.5

Explanation:

* S2 projection is selected with ``+proj=s2``.
* The WGS84 ellipsoid is specified with ``+ellps=WGS84``.
* The cube side is selected with ``+lat_0=... +lon_0=...``.
* The normalization transformation is selected with ``+UVtoST=...``.

Parameters
################################################################################

.. note:: All parameters for the projection are optional.

.. include:: ../options/lon_0.rst

.. include:: ../options/lat_0.rst

.. include:: ../options/ellps.rst

.. option:: +UVtoST=<value>

The area-normalization transformation. Choose from {linear, quadratic, tangent, none}

*Defaults to "quadratic".*

.. include:: ../options/x_0.rst

.. include:: ../options/y_0.rst

Further reading
################################################################################

#. `S2's Website <https://s2geometry.io/>`_
1 change: 1 addition & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ libproj_la_SOURCES = \
projections/putp6.cpp \
projections/qsc.cpp \
projections/robin.cpp \
projections/s2.cpp \
projections/sch.cpp \
projections/sts.cpp \
projections/urm5.cpp \
Expand Down
4 changes: 0 additions & 4 deletions src/bin_projsync.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ set_target_properties(bin_projsync
OUTPUT_NAME projsync)
target_link_libraries(bin_projsync PRIVATE ${PROJ_LIBRARIES})
target_compile_options(bin_projsync PRIVATE ${PROJ_CXX_WARN_FLAGS})
if(NLOHMANN_JSON STREQUAL "external")
target_compile_definitions(bin_projsync PRIVATE EXTERNAL_NLOHMANN_JSON)
target_link_libraries(bin_projsync PRIVATE nlohmann_json::nlohmann_json)
endif()

install(TARGETS bin_projsync
DESTINATION ${BINDIR})
Expand Down
1 change: 0 additions & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#include "filemanager.hpp"
#include <math.h>


/**************************************************************************************/
static paralist *string_to_paralist (PJ_CONTEXT *ctx, char *definition) {
/***************************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion src/iso19111/operation/parammappings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ static const MethodMapping projectionMethodMappings[] = {

{PROJ_WKT2_NAME_METHOD_QUADRILATERALIZED_SPHERICAL_CUBE, 0,
"Quadrilateralized_Spherical_Cube", "qsc", nullptr, paramsNatOrigin},

{PROJ_WKT2_NAME_METHOD_SPHERICAL_CROSS_TRACK_HEIGHT, 0,
"Spherical_Cross_Track_Height", "sch", nullptr, paramsSch},

Expand Down
4 changes: 3 additions & 1 deletion src/lib_proj.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ set(SRC_LIBPROJ_PROJECTIONS
projections/putp6.cpp
projections/qsc.cpp
projections/robin.cpp
projections/s2.cpp
projections/sch.cpp
projections/sts.cpp
projections/urm5.cpp
Expand Down Expand Up @@ -398,7 +399,8 @@ target_link_libraries(proj PRIVATE ${SQLITE3_LIBRARY})

if(NLOHMANN_JSON STREQUAL "external")
target_compile_definitions(proj PRIVATE EXTERNAL_NLOHMANN_JSON)
target_link_libraries(proj PRIVATE nlohmann_json::nlohmann_json)
target_link_libraries(proj
PRIVATE $<BUILD_INTERFACE:nlohmann_json::nlohmann_json>)
endif()

if(TIFF_ENABLED)
Expand Down
1 change: 1 addition & 0 deletions src/pj_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ PROJ_HEAD(qsc, "Quadrilateralized Spherical Cube")
PROJ_HEAD(robin, "Robinson")
PROJ_HEAD(rouss, "Roussilhe Stereographic")
PROJ_HEAD(rpoly, "Rectangular Polyconic")
PROJ_HEAD(s2, "S2")
PROJ_HEAD(sch, "Spherical Cross-track Height")
PROJ_HEAD(set, "Set coordinate value")
PROJ_HEAD(sinu, "Sinusoidal (Sanson-Flamsteed)")
Expand Down
3 changes: 3 additions & 0 deletions src/proj_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@
#define PROJ_WKT2_NAME_METHOD_QUADRILATERALIZED_SPHERICAL_CUBE \
"Quadrilateralized Spherical Cube"

#define PROJ_WKT2_NAME_METHOD_S2 \
"S2"

#define PROJ_WKT2_NAME_METHOD_SPHERICAL_CROSS_TRACK_HEIGHT \
"Spherical Cross-Track Height"

Expand Down
Loading

0 comments on commit b74235c

Please sign in to comment.