Skip to content

Commit

Permalink
deploy: 60ae6cf
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Mar 11, 2024
1 parent ee36936 commit 95126ec
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 12 deletions.
27 changes: 22 additions & 5 deletions mbtiles-diff.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,15 @@ <h1 class="menu-title">Martin Tile Server Documentation</h1>
<main>
<h1 id="diffing-mbtiles"><a class="header" href="#diffing-mbtiles">Diffing MBTiles</a></h1>
<h2 id="mbtiles-diff"><a class="header" href="#mbtiles-diff"><code>mbtiles diff</code></a></h2>
<p>Copy command can also be used to compare two mbtiles files and generate a delta (diff) file. The diff file can be <a href="#mbtiles-apply-patch">applied</a> to the <code>src_file.mbtiles</code> elsewhere, to avoid copying/transmitting the entire modified dataset. The delta file will contain all tiles that are different between the two files (modifications, insertions, and deletions as <code>NULL</code> values), for both the tile and metadata tables.</p>
<p>There is one exception: <code>agg_tiles_hash</code> metadata value will be renamed to <code>agg_tiles_hash_in_diff</code>, and a new <code>agg_tiles_hash</code> will be generated for the diff file itself. This is done to avoid confusion when applying the diff file to the original file, as the <code>agg_tiles_hash</code> value will be different after the diff is applied. The <code>apply-diff</code> command will automatically rename the <code>agg_tiles_hash_in_diff</code> value back to <code>agg_tiles_hash</code> when applying the diff.</p>
<p>Copy command can also be used to compare two mbtiles files and generate a delta (diff) file. The diff file can
be <a href="#mbtiles-apply-patch">applied</a> to the <code>src_file.mbtiles</code> elsewhere, to avoid copying/transmitting the entire
modified dataset. The delta file will contain all tiles that are different between the two files (modifications,
insertions, and deletions as <code>NULL</code> values), for both the tile and metadata tables.</p>
<p>There is one exception: <code>agg_tiles_hash</code> metadata value will be renamed to <code>agg_tiles_hash_after_apply</code>, and a
new <code>agg_tiles_hash</code> will be generated for the diff file itself. This is done to avoid confusion when applying the diff
file to the original file, as the <code>agg_tiles_hash</code> value will be different after the diff is applied. The <code>apply-diff</code>
command will automatically rename the <code>agg_tiles_hash_after_apply</code> value back to <code>agg_tiles_hash</code> when applying the
diff.</p>
<pre><code class="language-shell"># This command will compare `file1.mbtiles` and `file2.mbtiles`, and generate a new diff file `diff.mbtiles`.
mbtiles diff file1.mbtiles file2.mbtiles diff.mbtiles

Expand All @@ -198,12 +205,22 @@ <h2 id="mbtiles-diff"><a class="header" href="#mbtiles-diff"><code>mbtiles diff<
[INFO ] The agg_tiles_hashes=E95C1081447FB25674DCC1EB97F60C26 has been verified for file2a.mbtiles
</code></pre>
<h2 id="mbtiles-apply-patch"><a class="header" href="#mbtiles-apply-patch"><code>mbtiles apply-patch</code></a></h2>
<p>Apply the diff file generated with the <code>mbtiles diff</code> command above to an MBTiles file. The diff file can be applied to the <code>src_file.mbtiles</code> that has been previously downloaded to avoid copying/transmitting the entire modified dataset again. The <code>src_file.mbtiles</code> will modified in-place. It is also possible to apply the diff file while copying the source file to a new destination file, by using the <a href="mbtiles-copy.html#mbtiles-copy---apply-patch"><code>mbtiles copy --apply-patch</code></a> command.</p>
<p>Note that the <code>agg_tiles_hash_in_diff</code> metadata value will be renamed to <code>agg_tiles_hash</code> when applying the diff. This is done to avoid confusion when applying the diff file to the original file, as the <code>agg_tiles_hash</code> value will be different after the diff is applied.</p>
<p>Apply the diff file generated with the <code>mbtiles diff</code> command above to an MBTiles file. The diff file can be applied to
the <code>src_file.mbtiles</code> that has been previously downloaded to avoid copying/transmitting the entire modified dataset
again. The <code>src_file.mbtiles</code> will modified in-place. It is also possible to apply the diff file while copying the
source file to a new destination file, by using
the <a href="mbtiles-copy.html#mbtiles-copy---apply-patch"><code>mbtiles copy --apply-patch</code></a> command.</p>
<p>Note that the <code>agg_tiles_hash_after_apply</code> metadata value will be renamed to <code>agg_tiles_hash</code> when applying the diff.
This is done to avoid confusion when applying the diff file to the original file, as the <code>agg_tiles_hash</code> value will be
different after the diff is applied.</p>
<pre><code class="language-shell">mbtiles apply-patch src_file.mbtiles diff_file.mbtiles
</code></pre>
<h4 id="applying-diff-with-sqlite"><a class="header" href="#applying-diff-with-sqlite">Applying diff with SQLite</a></h4>
<p>Another way to apply the diff is to use the <code>sqlite3</code> command line tool directly. This SQL will delete all tiles from <code>src_file.mbtiles</code> that are set to <code>NULL</code> in <code>diff_file.mbtiles</code>, and then insert or update all new tiles from <code>diff_file.mbtiles</code> into <code>src_file.mbtiles</code>, where both files are of <code>flat</code> type. The name of the diff file is passed as a query parameter to the sqlite3 command line tool, and then used in the SQL statements. Note that this does not update the <code>agg_tiles_hash</code> metadata value, so it will be incorrect after the diff is applied.</p>
<p>Another way to apply the diff is to use the <code>sqlite3</code> command line tool directly. This SQL will delete all tiles
from <code>src_file.mbtiles</code> that are set to <code>NULL</code> in <code>diff_file.mbtiles</code>, and then insert or update all new tiles
from <code>diff_file.mbtiles</code> into <code>src_file.mbtiles</code>, where both files are of <code>flat</code> type. The name of the diff file is
passed as a query parameter to the sqlite3 command line tool, and then used in the SQL statements. Note that this does
not update the <code>agg_tiles_hash</code> metadata value, so it will be incorrect after the diff is applied.</p>
<pre><code class="language-shell">sqlite3 src_file.mbtiles \
-bail \
-cmd ".parameter set @diffDbFilename diff_file.mbtiles" \
Expand Down
27 changes: 22 additions & 5 deletions print.html
Original file line number Diff line number Diff line change
Expand Up @@ -1406,8 +1406,15 @@ <h2 id="mbtiles-copy---apply-patch"><a class="header" href="#mbtiles-copy---appl
</code></pre>
<div style="break-before: page; page-break-before: always;"></div><h1 id="diffing-mbtiles"><a class="header" href="#diffing-mbtiles">Diffing MBTiles</a></h1>
<h2 id="mbtiles-diff"><a class="header" href="#mbtiles-diff"><code>mbtiles diff</code></a></h2>
<p>Copy command can also be used to compare two mbtiles files and generate a delta (diff) file. The diff file can be <a href="mbtiles-diff.html#mbtiles-apply-patch">applied</a> to the <code>src_file.mbtiles</code> elsewhere, to avoid copying/transmitting the entire modified dataset. The delta file will contain all tiles that are different between the two files (modifications, insertions, and deletions as <code>NULL</code> values), for both the tile and metadata tables.</p>
<p>There is one exception: <code>agg_tiles_hash</code> metadata value will be renamed to <code>agg_tiles_hash_in_diff</code>, and a new <code>agg_tiles_hash</code> will be generated for the diff file itself. This is done to avoid confusion when applying the diff file to the original file, as the <code>agg_tiles_hash</code> value will be different after the diff is applied. The <code>apply-diff</code> command will automatically rename the <code>agg_tiles_hash_in_diff</code> value back to <code>agg_tiles_hash</code> when applying the diff.</p>
<p>Copy command can also be used to compare two mbtiles files and generate a delta (diff) file. The diff file can
be <a href="mbtiles-diff.html#mbtiles-apply-patch">applied</a> to the <code>src_file.mbtiles</code> elsewhere, to avoid copying/transmitting the entire
modified dataset. The delta file will contain all tiles that are different between the two files (modifications,
insertions, and deletions as <code>NULL</code> values), for both the tile and metadata tables.</p>
<p>There is one exception: <code>agg_tiles_hash</code> metadata value will be renamed to <code>agg_tiles_hash_after_apply</code>, and a
new <code>agg_tiles_hash</code> will be generated for the diff file itself. This is done to avoid confusion when applying the diff
file to the original file, as the <code>agg_tiles_hash</code> value will be different after the diff is applied. The <code>apply-diff</code>
command will automatically rename the <code>agg_tiles_hash_after_apply</code> value back to <code>agg_tiles_hash</code> when applying the
diff.</p>
<pre><code class="language-shell"># This command will compare `file1.mbtiles` and `file2.mbtiles`, and generate a new diff file `diff.mbtiles`.
mbtiles diff file1.mbtiles file2.mbtiles diff.mbtiles

Expand All @@ -1423,12 +1430,22 @@ <h2 id="mbtiles-diff"><a class="header" href="#mbtiles-diff"><code>mbtiles diff<
[INFO ] The agg_tiles_hashes=E95C1081447FB25674DCC1EB97F60C26 has been verified for file2a.mbtiles
</code></pre>
<h2 id="mbtiles-apply-patch"><a class="header" href="#mbtiles-apply-patch"><code>mbtiles apply-patch</code></a></h2>
<p>Apply the diff file generated with the <code>mbtiles diff</code> command above to an MBTiles file. The diff file can be applied to the <code>src_file.mbtiles</code> that has been previously downloaded to avoid copying/transmitting the entire modified dataset again. The <code>src_file.mbtiles</code> will modified in-place. It is also possible to apply the diff file while copying the source file to a new destination file, by using the <a href="mbtiles-copy.html#mbtiles-copy---apply-patch"><code>mbtiles copy --apply-patch</code></a> command.</p>
<p>Note that the <code>agg_tiles_hash_in_diff</code> metadata value will be renamed to <code>agg_tiles_hash</code> when applying the diff. This is done to avoid confusion when applying the diff file to the original file, as the <code>agg_tiles_hash</code> value will be different after the diff is applied.</p>
<p>Apply the diff file generated with the <code>mbtiles diff</code> command above to an MBTiles file. The diff file can be applied to
the <code>src_file.mbtiles</code> that has been previously downloaded to avoid copying/transmitting the entire modified dataset
again. The <code>src_file.mbtiles</code> will modified in-place. It is also possible to apply the diff file while copying the
source file to a new destination file, by using
the <a href="mbtiles-copy.html#mbtiles-copy---apply-patch"><code>mbtiles copy --apply-patch</code></a> command.</p>
<p>Note that the <code>agg_tiles_hash_after_apply</code> metadata value will be renamed to <code>agg_tiles_hash</code> when applying the diff.
This is done to avoid confusion when applying the diff file to the original file, as the <code>agg_tiles_hash</code> value will be
different after the diff is applied.</p>
<pre><code class="language-shell">mbtiles apply-patch src_file.mbtiles diff_file.mbtiles
</code></pre>
<h4 id="applying-diff-with-sqlite"><a class="header" href="#applying-diff-with-sqlite">Applying diff with SQLite</a></h4>
<p>Another way to apply the diff is to use the <code>sqlite3</code> command line tool directly. This SQL will delete all tiles from <code>src_file.mbtiles</code> that are set to <code>NULL</code> in <code>diff_file.mbtiles</code>, and then insert or update all new tiles from <code>diff_file.mbtiles</code> into <code>src_file.mbtiles</code>, where both files are of <code>flat</code> type. The name of the diff file is passed as a query parameter to the sqlite3 command line tool, and then used in the SQL statements. Note that this does not update the <code>agg_tiles_hash</code> metadata value, so it will be incorrect after the diff is applied.</p>
<p>Another way to apply the diff is to use the <code>sqlite3</code> command line tool directly. This SQL will delete all tiles
from <code>src_file.mbtiles</code> that are set to <code>NULL</code> in <code>diff_file.mbtiles</code>, and then insert or update all new tiles
from <code>diff_file.mbtiles</code> into <code>src_file.mbtiles</code>, where both files are of <code>flat</code> type. The name of the diff file is
passed as a query parameter to the sqlite3 command line tool, and then used in the SQL statements. Note that this does
not update the <code>agg_tiles_hash</code> metadata value, so it will be incorrect after the diff is applied.</p>
<pre><code class="language-shell">sqlite3 src_file.mbtiles \
-bail \
-cmd ".parameter set @diffDbFilename diff_file.mbtiles" \
Expand Down
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion searchindex.json

Large diffs are not rendered by default.

0 comments on commit 95126ec

Please sign in to comment.