Skip to content

tinshift: support TIN GeoPackage files#4603

Open
rouault wants to merge 2 commits into
OSGeo:masterfrom
rouault:tinshift_gpkg
Open

tinshift: support TIN GeoPackage files#4603
rouault wants to merge 2 commits into
OSGeo:masterfrom
rouault:tinshift_gpkg

Conversation

@rouault
Copy link
Copy Markdown
Member

@rouault rouault commented Nov 9, 2025

Such files are equivalent to already supported TIN JSON files, but scale better for arbitrarily large triangulations, in particular for network-based access.

The format is defined in source/specifications/tin_gpkg.rst and the https://github.com/rouault/PROJ-data/blob/tin_json_to_tin_gpkg/grid_tools/tin_json_to_tin_gpkg.py Python script may be used o convert an existing TIN JSON into a TIN GeoPackage.

$ echo 3432087 6995748 0 | PROJ_NETWORK=ON PROJ_DATA=data bin/cct +proj=tinshift +file=fi_nls_ykj_etrs35fin.gpkg
431943.0905 6992816.7826 0.0000 inf
$ echo 3432087 6995748 0 | PROJ_NETWORK=ON PROJ_DATA=data bin/cct +proj=tinshift +file=fi_nls_ykj_etrs35fin.json
431943.0905 6992816.7826 0.0000 inf
$ echo 3432087 6995748 0 | PROJ_NETWORK=ON PROJ_DATA=data bin/cct +proj=tinshift +file=fi_nls_n60_n2000.gpkg
3432087.0000 6995748.0000 0.3161 inf
$ echo 3432087 6995748 0 | PROJ_NETWORK=ON PROJ_DATA=data bin/cct +proj=tinshift +file=fi_nls_n60_n2000.json
3432087.0000 6995748.0000 0.3161 inf

Fixes #3732

@rouault rouault added this to the 9.8.0 milestone Nov 9, 2025
@rouault rouault force-pushed the tinshift_gpkg branch 2 times, most recently from 6ef4d73 to 29eacff Compare November 9, 2025 22:33
Copy link
Copy Markdown
Contributor

@jjimenezshaw jjimenezshaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't review the complete algorithm yet. But one usual optimization is to start searching on the last triangle successfully returned. If searched points an near, they will probably be in the same triangle. Is it something to include in the API somehow? Or just an implementation detail? (I want to think it is an implementation detail, but I am not sure. In that case we should store the last used triangle threadsafe somewhere)

Comment thread src/transformations/tinshift_gpkg.cpp Outdated
@rouault
Copy link
Copy Markdown
Member Author

rouault commented Nov 9, 2025

But one usual optimization is to start searching on the last triangle successfully returned.

good idea. Implemented now

@rouault rouault force-pushed the tinshift_gpkg branch 3 times, most recently from 52e3960 to 73575dc Compare November 9, 2025 23:44
Comment thread appveyor.yml Outdated
Comment thread src/transformations/tinshift.cpp Outdated
Comment thread src/transformations/tinshift_gpkg.cpp
Comment thread src/transformations/tinshift_gpkg.hpp

-------------------------------------------------------------------------------
===============================================================================
Test +proj=tinshift with GeoPackage files on network
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this using curl or sqlite3 directly? Is it getting the whole file, or is it "cloud optimized"?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use our NetworkFile implementation that uses curl underneath and range request, and plug it into sqlite3 I/O layer. That way we can have piece wise access to the parts of the file we need, and benefit from the local caching in our ~/.local/share/proj/cache.db of the chunks we have already read.

From my test on a synthetic grid of 500x500 nodes, with each square divided into 2 triangles, that generates a GeoPackage file of ~ 64 MB. The first access to extract a triangle involves ~ 20 network requests of 16 KB each. Accesses to other parts (not close to each other) of the file afterwards take between 6 and 14 requests.

It seems that FlatGeoBuf spatial index (packed Hilbert RTree) would involve less requests, but FlatGeoBuf supports only one layer per file, and we need 2 layers. The FlatGeoBuf files would also be larger than the GeoPackage one (presumably because both the triangle geometry and the RTree need to be stored, whereas with GeoPackage we only store the RTree of the bbox of the triangles, but not the geometry of the triangles themselves, just the indices to the vertices), although file size is probably less of a concern. We could possibly have a .tar of 2 flatgeobuf files? I'm not sure if that's worth the complication.

Such files are equivalent to already supported TIN JSON files, but scale
better for arbitrarily large triangulations, in particular for
network-based access.

The format is defined in source/specifications/tin_gpkg.rst and the
https://github.com/OSGeo/PROJ-data/blob/master/grid_tools/tin_json_to_gpkg_tin.py
Python script may be used o convert an existing TIN JSON into a TIN
GeoPackage.
@rouault
Copy link
Copy Markdown
Member Author

rouault commented Jan 6, 2026

@GlenRice-NOAA Did you get a chance to test this feature?

@GlenRice-NOAA
Copy link
Copy Markdown

No, I have not. I will try to get to it in the next couple of weeks.

@jjimenezshaw
Copy link
Copy Markdown
Contributor

@GlenRice-NOAA any progress? Release 9.8.0 is coming soon

@GlenRice-NOAA
Copy link
Copy Markdown

I'm planning on having it tested by the end of the week. Thanks for checking in.

@GlenRice-NOAA
Copy link
Copy Markdown

Can we bump this to the next release?

@rouault
Copy link
Copy Markdown
Member Author

rouault commented Feb 10, 2026

Can we bump this to the next release?

you mean 9.9 (likely to be released towards end of this year) ? Sure, no emergency from my side

@GlenRice-NOAA
Copy link
Copy Markdown

Thank you.

@kbevers kbevers modified the milestones: 9.8.0, 9.9.0 Mar 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 2, 2026

The PROJ project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last two months and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add terminal output examples if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@github-actions github-actions Bot added the stale label May 2, 2026
@rouault
Copy link
Copy Markdown
Member Author

rouault commented May 2, 2026

Keep open

@github-actions github-actions Bot removed the stale label May 3, 2026
@mwtoews mwtoews added the pinned Prevent stale-bot from closing an issue label May 3, 2026
@rouault
Copy link
Copy Markdown
Member Author

rouault commented May 11, 2026

@GlenRice-NOAA Any ETA on when you will be able to give feedback on this?

@GlenRice-NOAA
Copy link
Copy Markdown

We have someone new working on it (again). We think we can provide feedback in the next month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pinned Prevent stale-bot from closing an issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Large JSON TIN support

5 participants