Closed Gotcha17 closed 1 month ago
Hi I wrote a little hint on https://github.com/maplibre/martin/issues/1246#issuecomment-2294157616 maybe this helps. I assume the key ist in you table definition where you define the additional fields
Thanks for your fast response @CptHolzschnauz
To clarify further: I am able to configure tiles with all the properties corresponding to the views columns. all the data is perfectly served in a maplibre web app. My goal is to add further fields into the TileJSON. This should be possible by providing a JSON object into the Description of the View on the PostgresDB. However, as described above that has not worked for me so far.
So you mean from other tables or with parameters? My answer was for additional fields in the same table with the GEOMETRY field. So this works for you? I assume we are doing the same stuff at the moment, you are talking about a VIEW, right? I think that is not possible, it's either from a TABLE or a FUNCTION. What I'm trying to achieve right now is to pass parameters to a PSQL FUNCTION. For a GET it's clear but how to implement that in the map.addSource from MapLibre is not clear to me. I just asked Stepan Kuzmin from MapBox. If i get an answer i will post here and then I plan to write a beginners guide for Martin..;=)
Just to drive the point home. This is how my redacted TileJSON looks like
and this is how it is suppose to look
I want to achieve this by executing this SQL command on my postgres db:
DO $do$ BEGIN EXECUTE 'COMMENT ON VIEW some_view IS $tj$' || $$ { "some_description": "some layer description" } $$::json || '$tj$'; END $do$;
Ok. So you modified auto_published in the config according to the manual and it did not worked out. So I can't help you, I think I'm working on a lower level ;=)
Anyway, the manual says: By default the description and name is database identifies about this table, and the bounds is queried from database. You can fine tune these by adjusting auto_publish section in configuration file. TileJSON in SQL Comments
Other than adjusting auto_publish section in configuration file, you can fine tune the TileJSON on the database side directly: Add a valid JSON as an SQL comment on the table.
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.
DO $do$ BEGIN
EXECUTE 'COMMENT ON TABLE table_source IS $tj$' || $$
{
"version": "1.2.3",
"attribution": "osm",
"description": "a description from table comment",
"foo": {"bar": "foo"}
}
$$::json || '$tj$';
END $do$;
Yeap, this is what I did. I can also see the comment on my VIEW via pgadmin but it has no effect on the TileJSON. I have also confirmed that this is a valid JSON.
@nyurik do you have an insight if this feature is exclusively working for TABLE and FUNCTION objects?
Hi @Gotcha17 I tried your json commnet and it works on Martin
v0.14.2.
The table
DROP TABLE IF EXISTS table_source;
CREATE TABLE table_source(gid serial PRIMARY KEY, geom geometry(GEOMETRY, 4326));
INSERT INTO table_source(geom) values (GeomFromEWKT('SRID=4326;POINT(0 0)'));
INSERT INTO table_source(geom) values (GeomFromEWKT('SRID=4326;POINT(-2 2)'));
INSERT INTO table_source(geom) values (GeomFromEWKT('SRID=4326;LINESTRING(0 0, 1 1)'));
INSERT INTO table_source(geom) values (GeomFromEWKT('SRID=4326;LINESTRING(2 2, 3 3)'));
The sql comment
DO $do$ BEGIN
EXECUTE 'COMMENT ON TABLE table_source IS $tj$' || $$
{
"source_name": "Some source name",
"source_description": "Some source description"
}
$$::json || '$tj$';
END $do$;
the tile json from martin
May I have your full comment and table structure to make a debug?
hey @sharkAndshark, I can confirm that this feature works fine when using a TABLE. However, if I am using a VIEW and reproducing all steps, then a standard TileJSON is displayed as provided in my previous comment.
Can you confirm this behavior and is it intended to only support provide this feature support for TABLEs and FUNCTIONs and not for VIEWs?
I made a test on view and it didn't work. I think it's a bug here. @Gotcha17 We will fix it.
Thanks @sharkAndshark and @nyurik !
Hey, i am trying to customize the TileJSON in order to have some additional parameters in it with my custom text.
I am running a
and using View as the tile source.
In this views I have tried to make change via the function as described in the docs without success.
Additionally, I have tried just to put a simple JSON formatted text into the View description e.g.:
without a effect.
This applies for both cases, "auto_publish" and specific configuration of the tile source via "tables" section of the config.yaml
In all cases just the "standard" generated TileJSON is displayed without any information from the view description. There are also any errors displayed, when I am setting
RUST_LOG=debug
.Do have any advise?