Skip to content

Commit

Permalink
deploy: fa1bf4b
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkAndshark committed Sep 12, 2023
1 parent 17959ef commit 1ca27b2
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 4 deletions.
50 changes: 48 additions & 2 deletions print.html
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,52 @@ <h2 id="postgresql-ssl-connections"><a class="header" href="#postgresql-ssl-conn
<p>By default, <code>sslmode</code> is set to <code>prefer</code> which means that SSL is used if the server supports it, but the connection is not aborted if the server does not support it. This is the default behavior of <code>psql</code> and is the most compatible option. Use the <code>sslmode</code> param to set a different <code>sslmode</code>, e.g. <code>postgresql://user:password@host/db?sslmode=require</code>.</p>
<div style="break-before: page; page-break-before: always;"></div><h1 id="table-sources"><a class="header" href="#table-sources">Table Sources</a></h1>
<p>Table Source is a database table which can be used to query <a href="https://github.com/mapbox/vector-tile-spec">vector tiles</a>. If a <a href="pg-connections.html">PostgreSQL connection string</a> is given, Martin will publish all tables as data sources if they have at least one geometry column. If geometry column SRID is 0, a default SRID must be set, or else that geo-column/table will be ignored. All non-geometry table columns will be published as vector tile feature tags (properties).</p>
<h1 id="modifying-tilejson"><a class="header" href="#modifying-tilejson">Modifying Tilejson</a></h1>
<p>Martin will automatically generate a <code>TileJSON</code> manifest for each table source. It will contain the <code>name</code>, <code>description</code>, <code>minzoom</code>, <code>maxzoom</code>, <code>bounds</code> and <code>vector_layer</code> information.
For example, if there is a table <code>public.table_source</code>:
the default <code>TileJSON</code> might look like this (note that URL will be automatically adjusted to match the request host):</p>
<p>The table:</p>
<pre><code class="language-sql">CREATE TABLE &quot;public&quot;.&quot;table_source&quot; ( &quot;gid&quot; int4 NOT NULL, &quot;geom&quot; &quot;public&quot;.&quot;geometry&quot; );
</code></pre>
<p>The TileJSON:</p>
<pre><code class="language-json">{
&quot;tilejson&quot;: &quot;3.0.0&quot;,
&quot;tiles&quot;: [
&quot;http://localhost:3000/table_source/{z}/{x}/{y}&quot;
],
&quot;vector_layers&quot;: [
{
&quot;id&quot;: &quot;table_source&quot;,
&quot;fields&quot;: {
&quot;gid&quot;: &quot;int4&quot;
}
}
],
&quot;bounds&quot;: [
-2.0,
-1.0,
142.84131509869133,
45.0
],
&quot;description&quot;: &quot;public.table_source.geom&quot;,
&quot;name&quot;: &quot;table_source&quot;
}
</code></pre>
<p>By default the <code>description</code> and <code>name</code> is database identifies about this table, and the bounds is queried from database. You can fine tune these by adjusting <code>auto_publish</code> section in <a href="https://maplibre.org/martin/config-file.html#config-example">configuration file</a>.</p>
<h2 id="tilejson-in-sql-comments"><a class="header" href="#tilejson-in-sql-comments">TileJSON in SQL Comments</a></h2>
<p>Other than adjusting <code>auto_publish</code> section in configuration file, you can fine tune the <code>TileJSON</code> on the database side directly: Add a valid JSON as an SQL comment on the table.</p>
<p>Martin will merge table comment into the generated TileJSON using JSON Merge patch. The following example update description and adds attribution, version, foo(even a nested DIY field) fields to the TileJSON. </p>
<pre><code class="language-sql">DO $do$ BEGIN
EXECUTE 'COMMENT ON TABLE table_source IS $tj$' || $$
{
&quot;version&quot;: &quot;1.2.3&quot;,
&quot;attribution&quot;: &quot;osm&quot;,
&quot;description&quot;: &quot;a description from table comment&quot;,
&quot;foo&quot;: {&quot;bar&quot;: &quot;foo&quot;}
}
$$::json || '$tj$';
END $do$;
</code></pre>
<div style="break-before: page; page-break-before: always;"></div><h1 id="postgresql-function-sources"><a class="header" href="#postgresql-function-sources">PostgreSQL Function Sources</a></h1>
<p>Function Source is a database function which can be used to query <a href="https://github.com/mapbox/vector-tile-spec">vector tiles</a>. When started, Martin will look for the functions with a suitable signature. A function that takes <code>z integer</code> (or <code>zoom integer</code>), <code>x integer</code>, <code>y integer</code>, and an optional <code>query json</code> and returns <code>bytea</code>, can be used as a Function Source. Alternatively the function could return a record with a single <code>bytea</code> field, or a record with two fields of types <code>bytea</code> and <code>text</code>, where the <code>text</code> field is an etag key (i.e. md5 hash).</p>
<div class="table-wrapper"><table><thead><tr><th>Argument</th><th>Type</th><th>Description</th></tr></thead><tbody>
Expand Down Expand Up @@ -674,7 +720,7 @@ <h2 id="function-with-query-parameters"><a class="header" href="#function-with-q
<p>You can access this params using <a href="https://www.postgresql.org/docs/current/functions-json.html">json operators</a>:</p>
<pre><code class="language-sql ignore">...WHERE answer = (query_params-&gt;'objectParam'-&gt;&gt;'answer')::int;
</code></pre>
<h2 id="modifying-tilejson"><a class="header" href="#modifying-tilejson">Modifying TileJSON</a></h2>
<h2 id="modifying-tilejson-1"><a class="header" href="#modifying-tilejson-1">Modifying TileJSON</a></h2>
<p>Martin will automatically generate a basic <a href="https://github.com/mapbox/tilejson-spec">TileJSON</a> manifest for each function source that will contain the name and description of the function, plus optionally <code>minzoom</code>, <code>maxzoom</code>, and <code>bounds</code> (if they were specified via one of the configuration methods). For example, if there is a function <code>public.function_zxy_query_jsonb</code>, the default <code>TileJSON</code> might look like this (note that URL will be automatically adjusted to match the request host):</p>
<pre><code class="language-json">{
&quot;tilejson&quot;: &quot;3.0.0&quot;,
Expand All @@ -685,7 +731,7 @@ <h2 id="modifying-tilejson"><a class="header" href="#modifying-tilejson">Modifyi
&quot;description&quot;: &quot;public.function_zxy_query_jsonb&quot;
}
</code></pre>
<h3 id="tilejson-in-sql-comments"><a class="header" href="#tilejson-in-sql-comments">TileJSON in SQL Comments</a></h3>
<h3 id="tilejson-in-sql-comments-1"><a class="header" href="#tilejson-in-sql-comments-1">TileJSON in SQL Comments</a></h3>
<p>To modify automatically generated <code>TileJSON</code>, you can add a valid JSON as an SQL comment on the function. Martin will merge function comment into the generated <code>TileJSON</code> using <a href="https://www.rfc-editor.org/rfc/rfc7386">JSON Merge patch</a>. The following example adds <code>attribution</code> and <code>version</code> fields to the <code>TileJSON</code>.</p>
<p><strong>Note:</strong> This example uses <code>EXECUTE</code> to ensure that the comment is a valid JSON (or else PostgreSQL will throw an error). You can use other methods of creating SQL comments.</p>
<pre><code class="language-sql">DO $do$ BEGIN
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.

46 changes: 46 additions & 0 deletions sources-pg-tables.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,52 @@ <h1 class="menu-title">Martin Tile Server Documentation</h1>
<main>
<h1 id="table-sources"><a class="header" href="#table-sources">Table Sources</a></h1>
<p>Table Source is a database table which can be used to query <a href="https://github.com/mapbox/vector-tile-spec">vector tiles</a>. If a <a href="pg-connections.html">PostgreSQL connection string</a> is given, Martin will publish all tables as data sources if they have at least one geometry column. If geometry column SRID is 0, a default SRID must be set, or else that geo-column/table will be ignored. All non-geometry table columns will be published as vector tile feature tags (properties).</p>
<h1 id="modifying-tilejson"><a class="header" href="#modifying-tilejson">Modifying Tilejson</a></h1>
<p>Martin will automatically generate a <code>TileJSON</code> manifest for each table source. It will contain the <code>name</code>, <code>description</code>, <code>minzoom</code>, <code>maxzoom</code>, <code>bounds</code> and <code>vector_layer</code> information.
For example, if there is a table <code>public.table_source</code>:
the default <code>TileJSON</code> might look like this (note that URL will be automatically adjusted to match the request host):</p>
<p>The table:</p>
<pre><code class="language-sql">CREATE TABLE &quot;public&quot;.&quot;table_source&quot; ( &quot;gid&quot; int4 NOT NULL, &quot;geom&quot; &quot;public&quot;.&quot;geometry&quot; );
</code></pre>
<p>The TileJSON:</p>
<pre><code class="language-json">{
&quot;tilejson&quot;: &quot;3.0.0&quot;,
&quot;tiles&quot;: [
&quot;http://localhost:3000/table_source/{z}/{x}/{y}&quot;
],
&quot;vector_layers&quot;: [
{
&quot;id&quot;: &quot;table_source&quot;,
&quot;fields&quot;: {
&quot;gid&quot;: &quot;int4&quot;
}
}
],
&quot;bounds&quot;: [
-2.0,
-1.0,
142.84131509869133,
45.0
],
&quot;description&quot;: &quot;public.table_source.geom&quot;,
&quot;name&quot;: &quot;table_source&quot;
}
</code></pre>
<p>By default the <code>description</code> and <code>name</code> is database identifies about this table, and the bounds is queried from database. You can fine tune these by adjusting <code>auto_publish</code> section in <a href="https://maplibre.org/martin/config-file.html#config-example">configuration file</a>.</p>
<h2 id="tilejson-in-sql-comments"><a class="header" href="#tilejson-in-sql-comments">TileJSON in SQL Comments</a></h2>
<p>Other than adjusting <code>auto_publish</code> section in configuration file, you can fine tune the <code>TileJSON</code> on the database side directly: Add a valid JSON as an SQL comment on the table.</p>
<p>Martin will merge table comment into the generated TileJSON using JSON Merge patch. The following example update description and adds attribution, version, foo(even a nested DIY field) fields to the TileJSON. </p>
<pre><code class="language-sql">DO $do$ BEGIN
EXECUTE 'COMMENT ON TABLE table_source IS $tj$' || $$
{
&quot;version&quot;: &quot;1.2.3&quot;,
&quot;attribution&quot;: &quot;osm&quot;,
&quot;description&quot;: &quot;a description from table comment&quot;,
&quot;foo&quot;: {&quot;bar&quot;: &quot;foo&quot;}
}
$$::json || '$tj$';
END $do$;
</code></pre>

</main>

Expand Down

0 comments on commit 1ca27b2

Please sign in to comment.