Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/fedora_rawhide/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ ctest -j$(nproc)

# Try EMBED_RESOURCE_DIRECTORY option
wget https://raw.githubusercontent.com/OSGeo/PROJ-data/refs/heads/master/us_nga/us_nga_egm96_15.tif
wget https://cdn.proj.org/fi_nls_ykj_etrs35fin.gpkg
mkdir grids
mv us_nga_egm96_15.tif grids
mv fi_nls_ykj_etrs35fin.gpkg grids
echo "Build with -DEMBED_RESOURCE_FILES=ON -DEMBED_RESOURCE_DIRECTORY=$PWD/grids"
CC=clang CXX=clang++ cmake .. -DEMBED_RESOURCE_DIRECTORY=$PWD/grids
make -j$(nproc)
Expand All @@ -36,6 +38,8 @@ echo 49 2 0 | bin/cs2cs "WGS84 + EGM96 height" EPSG:4979
echo 49 2 0 | bin/cs2cs "WGS84 + EGM96 height" EPSG:4979 | grep 44.643 >/dev/null || (echo "Expected 49dN 2dE 44.643 as a result" && /bin/false)
echo 0 0 0 | bin/cct +init=ITRF2000:ITRF96
echo 0 0 0 | bin/cct +init=ITRF2000:ITRF96 | grep 0.0067 >/dev/null || (echo "Expected 0.0067 0.0061 -0.0185 as a result" && /bin/false)
echo 3432087 6995748 0 | bin/cct +proj=tinshift +file=fi_nls_ykj_etrs35fin.gpkg
echo 3432087 6995748 0 | bin/cct +proj=tinshift +file=fi_nls_ykj_etrs35fin.gpkg | grep 431943.0905 >/dev/null || (echo "Expected 431943.0905 6992816.7826 0 as a result" && /bin/false)

echo "Build with -DEMBED_RESOURCE_FILES=ON -DEMBED_RESOURCE_DIRECTORY=$PWD/grids -DUSE_ONLY_EMBEDDED_RESOURCE_FILES=ON"
CC=clang CXX=clang++ cmake .. -DEMBED_RESOURCE_DIRECTORY=$PWD/grids -DUSE_ONLY_EMBEDDED_RESOURCE_FILES=ON
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
shell: cmd
if: steps.cache.outputs.cache-hit != 'true'
run: |
vcpkg install sqlite3[core,tool] tiff curl --triplet=${{ env.ARCH }}-windows
vcpkg install sqlite3[core,tool,rtree] tiff curl --triplet=${{ env.ARCH }}-windows

- name: Build
shell: cmd
Expand Down
2 changes: 1 addition & 1 deletion data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ set(ALL_SQL_IN "${CMAKE_CURRENT_BINARY_DIR}/all.sql.in")
set(PROJ_DB "${CMAKE_CURRENT_BINARY_DIR}/proj.db")
include(sql_filelist.cmake)

set(PROJ_DB_SQL_EXPECTED_MD5 "cca51e9e250f9c979e8f18bb483433e5")
set(PROJ_DB_SQL_EXPECTED_MD5 "a71b63a199da368414be93d819bf2e5b")

add_custom_command(
OUTPUT ${PROJ_DB}
Expand Down
3 changes: 3 additions & 0 deletions data/sql/grid_alternatives.sql
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ VALUES
('fi_nls_n43_n60.json','fi_nls_n43_n60.json',NULL,'JSON','tinshift',0,NULL,'https://cdn.proj.org/fi_nls_n43_n60.json',1,1,NULL),
('fi_nls_n60_n2000.json','fi_nls_n60_n2000.json',NULL,'JSON','tinshift',0,NULL,'https://cdn.proj.org/fi_nls_n60_n2000.json',1,1,NULL),
('fi_nls_ykj_etrs35fin.json','fi_nls_ykj_etrs35fin.json',NULL,'JSON','tinshift',0,NULL,'https://cdn.proj.org/fi_nls_ykj_etrs35fin.json',1,1,NULL),
('NOT-YET-IN-GRID-TRANSFORMATION-fi_nls_n43_n60.gpkg','fi_nls_n43_n60.gpkg',NULL,'GPKG','tinshift',0,NULL,'https://cdn.proj.org/fi_nls_n43_n60.gpkg',1,1,NULL),
('NOT-YET-IN-GRID-TRANSFORMATION-fi_nls_n60_n2000.gpkg','fi_nls_n60_n2000.gpkg',NULL,'GPKG','tinshift',0,NULL,'https://cdn.proj.org/fi_nls_n60_n2000.gpkg',1,1,NULL),
('NOT-YET-IN-GRID-TRANSFORMATION-fi_nls_ykj_etrs35fin.gpkg','fi_nls_ykj_etrs35fin.gpkg',NULL,'GPKG','tinshift',0,NULL,'https://cdn.proj.org/fi_nls_ykj_etrs35fin.gpkg',1,1,NULL),

-- fr_ign - IGN France
('rgf93_ntf.gsb','fr_ign_ntf_r93.tif','ntf_r93.gsb','GTiff','hgridshift',1,NULL,'https://cdn.proj.org/fr_ign_ntf_r93.tif',1,1,NULL),
Expand Down
6 changes: 3 additions & 3 deletions data/sql/proj_db_table_defs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ CREATE TABLE grid_alternatives(
original_grid_name TEXT NOT NULL PRIMARY KEY, -- original grid name (e.g. Und_min2.5x2.5_egm2008_isw=82_WGS84_TideFree.gz). For LOS/LAS format, the .las files
proj_grid_name TEXT NOT NULL, -- PROJ >= 7 grid name (e.g us_nga_egm08_25.tif)
old_proj_grid_name TEXT, -- PROJ < 7 grid name (e.g egm08_25.gtx)
proj_grid_format TEXT NOT NULL, -- 'GTiff', 'GTX', 'NTv2', JSON
proj_grid_format TEXT NOT NULL, -- 'GTiff', 'GTX', 'NTv2', 'JSON', 'GPKG'
proj_method TEXT NOT NULL, -- gridshift, hgridshift, vgridshift, geoid_like, geocentricoffset, tinshift or velocity_grid
inverse_direction BOOLEAN NOT NULL CHECK (inverse_direction IN (0, 1)), -- whether the PROJ grid direction is reversed w.r.t to the authority one (TRUE in that case)
package_name TEXT, -- no longer used. Must be NULL
Expand All @@ -906,14 +906,14 @@ CREATE TABLE grid_alternatives(
directory TEXT, -- optional directory where the file might be located

CONSTRAINT fk_grid_alternatives_grid_packages FOREIGN KEY (package_name) REFERENCES grid_packages(package_name) ON DELETE CASCADE,
CONSTRAINT check_grid_alternatives_grid_fromat CHECK (proj_grid_format IN ('GTiff', 'GTX', 'NTv2', 'JSON')),
CONSTRAINT check_grid_alternatives_grid_fromat CHECK (proj_grid_format IN ('GTiff', 'GTX', 'NTv2', 'JSON', 'GPKG')),
CONSTRAINT check_grid_alternatives_proj_method CHECK (proj_method IN ('gridshift', 'hgridshift', 'vgridshift', 'geoid_like', 'geocentricoffset', 'tinshift', 'velocity_grid', 'defmodel')),
CONSTRAINT check_grid_alternatives_inverse_direction CHECK (NOT(proj_method = 'geoid_like' AND inverse_direction = 1)),
CONSTRAINT check_grid_alternatives_package_name CHECK (package_name IS NULL),
CONSTRAINT check_grid_alternatives_direct_download_url CHECK (NOT(direct_download IS NULL AND url IS NOT NULL)),
CONSTRAINT check_grid_alternatives_open_license_url CHECK (NOT(open_license IS NULL AND url IS NOT NULL)),
CONSTRAINT check_grid_alternatives_constraint_cdn CHECK (NOT(url LIKE 'https://cdn.proj.org/%' AND (direct_download = 0 OR open_license = 0 OR url != 'https://cdn.proj.org/' || proj_grid_name))),
CONSTRAINT check_grid_alternatives_tinshift CHECK ((proj_grid_format != 'JSON' AND proj_method != 'tinshift') OR (proj_grid_format = 'JSON' AND proj_method = 'tinshift'))
CONSTRAINT check_grid_alternatives_tinshift CHECK ((proj_grid_format NOT IN ('JSON','GPKG') AND proj_method != 'tinshift') OR (proj_grid_format IN ('JSON', 'GPKG') AND proj_method = 'tinshift'))
) WITHOUT ROWID;

CREATE INDEX idx_grid_alternatives_proj_grid_name ON grid_alternatives(proj_grid_name);
Expand Down
Binary file added data/tests/tinshift_crs_implicit.gpkg
Binary file not shown.
Empty file.
Binary file not shown.
Binary file added data/tests/tinshift_fallback_nearest_side.gpkg
Binary file not shown.
Binary file added data/tests/tinshift_simplified_kkj_etrs.gpkg
Binary file not shown.
Binary file added data/tests/tinshift_simplified_n60_n2000.gpkg
Binary file not shown.
7 changes: 6 additions & 1 deletion docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ All cached entries can be viewed using ``cmake -LAH`` from a build directory.

.. versionadded:: 9.6

Embed files from <directory> ending with .tif, .json or .pol in the PROJ library itself.
Embed files from <directory> ending with .tif, .json, .gpkg or .pol in the PROJ library itself.

The pointed directory can potentially be the full PROJ-data package (uncompressed).
In that case, about 6 GB of free disk and 16 GB of RAM are required to build PROJ.
Expand Down Expand Up @@ -604,3 +604,8 @@ Run PROJ tests
cd c:\dev\PROJ
cd _build.vs2019
ctest -V --build-config Release


.. spelling:word-list::

gpkg
115 changes: 15 additions & 100 deletions docs/source/operations/transformations/tinshift.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ Triangulated Irregular Network based transformation


The ``tinshift`` transformation takes one mandatory
argument, ``file``, that points to a JSON file, which contains the
argument, ``file``, that points to a :ref:`TIN JSON <tin_json>` or
:ref:`TIN GeoPackage <tin_gpkg>` file, which contains the
triangulation and associated metadata. Input and output coordinates must be
geographic or projected coordinates.
Depending on the content of the JSON file, horizontal, vertical or both
Depending on the content of the TIN file, horizontal, vertical or both
components of the coordinates may be transformed.

The transformation is invertible, with the same computational complexity than
Expand All @@ -37,7 +38,7 @@ Required

.. option:: +file=<filename>

Filename to the JSON file for the TIN.
Filename or URL to the JSON or GeoPackage file for the TIN.


Example
Expand Down Expand Up @@ -116,100 +117,14 @@ the inverse transformation), otherwise which triangle will be selected is
unspecified. Besides that, the triangulation does not need to have particular
properties (like being a Delaunay triangulation)

File format
+++++++++++

The triangulation is stored in a text-based format, using JSON as a serialization.

Below a minimal example, from the KKJ to ETRS89 transformation, with just a
single triangle:

.. literalinclude:: ../../../../data/tests/tinshift_crs_implicit.json
:language: json


So after the generic metadata, we define the input and output CRS (informative
only), and that the transformation affects horizontal components of
coordinates. We name the columns of the ``vertices`` and ``triangles`` arrays.
We defined the source and target coordinates of each vertex, and define a
triangle by referring to the index of its vertices in the ``vertices`` array.

More formally, the specific items for the triangulation file are:

input_crs
String identifying the CRS of source coordinates
in the vertices. Typically ``EPSG:XXXX``. If the transformation is for vertical
component, this should be the code for a compound CRS (can be EPSG:XXXX+YYYY
where XXXX is the code of the horizontal CRS and YYYY the code of the vertical CRS).
For example, for the KKJ->ETRS89 transformation, this is EPSG:2393
(``KKJ / Finland Uniform Coordinate System``). The input coordinates are assumed
to be passed in the "normalized for visualisation" / "GIS friendly" order,
that is longitude, latitude for geographic coordinates and
easting, northing for projected coordinates.


output_crs
String identifying the CRS of target coordinates in the vertices.
Typically ``EPSG:XXXX``. If the transformation is for vertical component,
this should be the code for a compound CRS (can be EPSG:XXXX+YYYY where
XXXX is the code of the horizontal CRS and YYYY the code of the vertical CRS).
For example, for the KKJ->ETRS89 transformation, this is EPSG:3067
(\"ETRS89 / TM35FIN(E,N)\"). The output coordinates will be returned in
the "normalized for visualisation" / "GIS friendly" order,
that is longitude, latitude for geographic coordinates and
easting, northing for projected coordinates.


transformed_components
Array which may contain one or two strings: "horizontal" when horizontal
components of the coordinates are transformed and/or "vertical" when the
vertical component is transformed.


fallback_strategy
String identifying how to treat points that do not fall into any of the
specified triangles. This item is available for ``format_version`` >= 1.1.
Possible values are ``none``, ``nearest_side`` and ``nearest_centroid``. The
default is ``none`` and signifies, that points that fall outside the
specified triangles are not transformed. This is also the behavior for
``format_version`` before 1.1. If ``fallback_strategy`` is set to
``nearest_side``, then points that do not fall into any triangle are
transformed according to the triangle closest to them by euclidean distance.
If ``fallback_strategy`` is set to ``nearest_centroid``, then points that do
not fall into any triangle are transformed according to the triangle with the
closest centroid (intersection of its medians).


vertices_columns
Specify the name of the columns of the rows in the ``vertices``
array. There must be exactly as many elements in ``vertices_columns`` as in a
row of ``vertices``. The following names have a special meaning: ``source_x``,
``source_y``, ``target_x``, ``target_y``, ``source_z``, ``target_z`` and
``offset_z``. ``source_x`` and ``source_y`` are compulsory.
``source_x`` is for the source longitude (in degree) or easting.
``source_y`` is for the source latitude (in degree) or northing.
``target_x`` and ``target_y`` are compulsory when ``horizontal`` is specified
in ``transformed_components``. (``source_z`` and ``target_z``) or
``offset_z`` are compulsory when ``vertical`` is specified in ``transformed_components``


triangles_columns
Specify the name of the columns of the rows in the
``triangles`` array. There must be exactly as many elements in ``triangles_columns``
as in a row of ``triangles``. The following names have a special meaning:
``idx_vertex1``, ``idx_vertex2``, ``idx_vertex3``. They are compulsory.


vertices
An array whose items are themselves arrays with as many columns as
described in ``vertices_columns``.


triangles
An array whose items are themselves arrays with as many columns as
described in ``triangles_columns``.
The value of the ``idx_vertexN`` columns must be indices
(between 0 and len(``vertices``-1) of items of the ``vertices`` array.

A `JSON schema <https://proj.org/schemas/triangulation.schema.json>`_ is available
for this file format.
JSON TIN File format
++++++++++++++++++++

See :ref:`tin_json`.

GeoPackage TIN File format
++++++++++++++++++++++++++

.. versionadded:: 9.8.0

See :ref:`tin_gpkg`.
3 changes: 3 additions & 0 deletions docs/source/specifications/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ for the sake of broader interoperability.

projjson
geodetictiffgrids
tin_gpkg
tin_json

Loading
Loading