Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic support for tiles from GeoPackage files. #122

Closed
wants to merge 1 commit into from

Conversation

cyberpython
Copy link
Contributor

@cyberpython cyberpython commented Jul 12, 2022

Implements basic support (direct loading, no caching) of tiles from GeoPackage files.

Merging this would introduce a dependency to NGA's GeoPackage Java (https://github.com/ngageoint/geopackage-java).

This could be useful as GeoPackage provides an easy to use file format to transfer raster tile pyramids (similar to MBTiles, but an OGC standard) in addition to vector map data.

For info on GeoPackage please see: https://www.geopackage.org/

An example is available at cyberpython/jxmapviewer2@931329d260d634c44c5cef54d3ae86af5ce46216 (note that the JxMapViewer2 version referenced in the pom.xml is fictional as this merge request is about the functionality used by the example).

@msteiger
Copy link
Owner

Thanks, this looking promising ... how did you create the osm-sample.gpkg file?

@cyberpython
Copy link
Contributor Author

To create the osm-sample.gpkg file I used the URL TileGenerator from the GeoPackage Java project (https://github.com/ngageoint/geopackage-java).

As it turns out, I had forgotten that I have modified the project to work with Gradle instead of Maven, and thus the instructions in the comments of the example mentioned in the PR description above will not work out of the box.

One needs to do the following to use the unmodified GeoPackage Java tile-download tool to generate a GeoPackage file that contains OSM tiles for levels 1-10 for an area around Rome (note that below the user agent string is set to impersonate a Firefox web browser):

git clone https://github.com/ngageoint/geopackage-java.git
cd geopackage-java
mvn clean install -Pstandalone  -DskipTests
cd target
java -classpath geopackage-*standalone.jar -Dhttp.agent="Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0" mil.nga.geopackage.io.URLTileGen -epsg 4326 -bbox -180,-85,180,85 osm-sample.gpkg osm-tiles "http://a.tile.openstreetmap.org/{z}/{x}/{y}.png" 0 5
java -classpath geopackage-*standalone.jar -Dhttp.agent="Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0" mil.nga.geopackage.io.URLTileGen -epsg 4326 -bbox 11,38,18,43 osm-sample.gpkg osm-tiles "http://a.tile.openstreetmap.org/{z}/{x}/{y}.png" 5 10

The comment in the example code has been fixed and the link to the example has been updated in the PR description above.

@msteiger
Copy link
Owner

Thanks, I was able to generate the file now. Will look into it a bit deeper next week.

@msteiger
Copy link
Owner

I'm a bit torn on this one to be honest. It looks good, but it would also be good to not have any external dependencies..

@cyberpython
Copy link
Contributor Author

There are alternatives if one wants to load data from a GeoPackage file on a JxMapViewer2 map, e.g. they can load the GeoPackage on a Spring Boot powered slippymap service and query the file for the requested tiles (I even have the equivalent written in Python with FastAPI here: https://github.com/cyberpython/slippypkg ) so long as they can run a server to serve the tiles.

Thus, not a big issue if this does not get merged - feel free to close the PR.

@msteiger
Copy link
Owner

I thought about putting it in the Examples project, but it would also include the extra dependency there. So maybe closing this PR is the best thing to do. We could still refer to your implementation as an example to integrate GeoPackage data in the README.

@msteiger
Copy link
Owner

Thanks for your contribution! I linked to your code from the README: d016e4c

@msteiger msteiger closed this Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants