Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

tinshift: support TIN GeoPackage files#4603

Open
rouault wants to merge 2 commits intoOSGeo:master from
rouault:tinshift_gpkg
Open

tinshift: support TIN GeoPackage files #4603
rouault wants to merge 2 commits intoOSGeo:master from
rouault:tinshift_gpkg

Conversation

@rouault
Copy link
Member

@rouault rouault commented Nov 9, 2025
edited
Loading

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

Copy link
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)

Copy link
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

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

@jjimenezshaw jjimenezshaw Nov 11, 2025

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
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.
Copy link
Member Author

rouault commented Jan 6, 2026

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

Copy link

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

Copy link
Contributor

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

Copy link

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

Copy link

Can we bump this to the next release?

Copy link
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

Copy link

Thank you.

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

Reviewers

@jjimenezshaw jjimenezshaw jjimenezshaw left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

9.8.0

Development

Successfully merging this pull request may close these issues.

Large JSON TIN support

AltStyle によって変換されたページ (->オリジナル) /