You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@baremaps.apache.org by bc...@apache.org on 2024/01/05 14:39:24 UTC
(incubator-baremaps) branch pmtiles-header created (now dab1a70e)
This is an automated email from the ASF dual-hosted git repository.
bchapuis pushed a change to branch pmtiles-header
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git
at dab1a70e Fix the header of the pmtiles
This branch includes the following new commits:
new dab1a70e Fix the header of the pmtiles
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(incubator-baremaps) 01/01: Fix the header of the pmtiles
Posted by bc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bchapuis pushed a commit to branch pmtiles-header
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git
commit dab1a70eecebf0aaceaa6c1cc15be2e13fb4ed00
Author: Bertil Chapuis <bc...@gmail.com>
AuthorDate: Fri Jan 5 15:39:13 2024 +0100
Fix the header of the pmtiles
---
.run/basemap-export-pmtiles.run.xml | 2 +-
.../apache/baremaps/tilestore/pmtiles/Header.java | 32 ++++++++++++++++++++++
.../baremaps/tilestore/pmtiles/PMTilesWriter.java | 2 +-
.../baremaps/workflow/tasks/ExportVectorTiles.java | 3 +-
4 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/.run/basemap-export-pmtiles.run.xml b/.run/basemap-export-pmtiles.run.xml
index 840a4774..d6c8830d 100644
--- a/.run/basemap-export-pmtiles.run.xml
+++ b/.run/basemap-export-pmtiles.run.xml
@@ -2,7 +2,7 @@
<configuration default="false" name="basemap-export-pmtiles" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="org.apache.baremaps.cli.Baremaps" />
<module name="baremaps-cli" />
- <option name="PROGRAM_PARAMETERS" value="map export --tileset tileset.js --repository tiles.mbtiles --format pmtiles" />
+ <option name="PROGRAM_PARAMETERS" value="map export --tileset tileset.js --repository tiles.pmtiles --format pmtiles" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/basemap" />
<method v="2">
<option name="Make" enabled="true" />
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/tilestore/pmtiles/Header.java b/baremaps-core/src/main/java/org/apache/baremaps/tilestore/pmtiles/Header.java
index b1e3bddf..81dcc929 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/tilestore/pmtiles/Header.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/tilestore/pmtiles/Header.java
@@ -30,8 +30,40 @@ class Header {
private long leafDirectoryLength;
private long tileDataOffset;
private long tileDataLength;
+
+ /**
+ * Number of Addressed Tiles
+ * <p>
+ * The Number of Addressed Tiles is an 8-byte field specifying the total number of tiles in the PMTiles archive, before RunLength Encoding.
+ * <p>
+ * A value of 0 indicates that the number is unknown.
+ * <p>
+ * This field is encoded as a little-endian 64-bit unsigned integer.
+ */
private long numAddressedTiles;
+
+ /**
+ * Number of Tile Entries
+ * <p>
+ * The Number of Tile Entries is an 8-byte field specifying the total number of tile entries: entries where RunLength is greater than 0.
+ * <p>
+ * A value of 0 indicates that the number is unknown.
+ * <p>
+ * This field is encoded as a little-endian 64-bit unsigned integer.
+ *
+ * @return the number of tile entries
+ */
private long numTileEntries;
+
+ /**
+ * Number of tile entries.
+ * <p>
+ * The Number of Tile Contents is an 8-byte field specifying the total number of blobs in the tile data section.
+ * <p>
+ * A value of 0 indicates that the number is unknown.
+ * <p>
+ * This field is encoded as a little-endian 64-bit unsigned integer.
+ */
private long numTileContents;
private boolean clustered;
private Compression internalCompression;
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/tilestore/pmtiles/PMTilesWriter.java b/baremaps-core/src/main/java/org/apache/baremaps/tilestore/pmtiles/PMTilesWriter.java
index 892a692d..5b50e5d0 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/tilestore/pmtiles/PMTilesWriter.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/tilestore/pmtiles/PMTilesWriter.java
@@ -178,7 +178,7 @@ public class PMTilesWriter {
var header = new Header();
header.setNumAddressedTiles(numTiles);
header.setNumTileEntries(numTiles);
- header.setNumTileContents(numTiles);
+ header.setNumTileContents(tileHashToOffset.size());
header.setClustered(true);
header.setInternalCompression(compression);
diff --git a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExportVectorTiles.java b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExportVectorTiles.java
index 8e277ef8..7a44864f 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExportVectorTiles.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ExportVectorTiles.java
@@ -147,8 +147,7 @@ public class ExportVectorTiles implements Task {
return tilesStore;
case pmtiles:
Files.deleteIfExists(repository);
- var tileStore = new PMTilesStore(repository, source);
- return tileStore;
+ return new PMTilesStore(repository, source);
default:
throw new IllegalArgumentException("Unsupported format");
}