postgis / docker-postgis

Docker image for PostGIS
https://hub.docker.com/r/postgis/postgis/
MIT License
1.39k stars 466 forks source link

ST_AsMVT is missing in 14-3.2 #287

Closed pumelo closed 2 years ago

pumelo commented 2 years ago

I don't know if it was ever there, but ST_AsMVT is not present in 14-3.2 Are there any plans to make it available. I guess the reason for not having it is some kind of dependency eg. protobuf?

Quoting form the postgis documentation at https://postgis.net/docs/postgis_installation.html#install_requirements:

To enable ST_AsMVT protobuf-c library 1.1.0 or higher (for usage) and the protoc-c compiler (for building) are required. Also, pkg-config is required to verify the correct minimum version of protobuf-c. See protobuf-c. By default, Postgis will use Wagyu to validate MVT polygons faster which requires a c++11 compiler. It will use CXXFLAGS and the same compiler as the PostgreSQL installation. To disable this and use GEOS instead use the --without-wagyu during the configure step.

ImreSamu commented 2 years ago

Hi @pumelo,

I don't know if it was ever there, but ST_AsMVT is not present in 14-3.2

Thanks for opening this issue! Please, share your minimal test code/script.


From here ( https://github.com/postgis/postgis/blob/stable-3.2/regress/core/mvt_jsonb.sql#L1_L6= ) please, can you test that (J1, J2) examples work? ( expected results : here )

J1,J2 examples:

SELECT 'J1', encode(ST_AsMVT(q, 'test', 4096, 'geom'), 'base64') FROM (SELECT '{"c1":1,"c2":"abcd"}'::jsonb,
    ST_AsMVTGeom(ST_GeomFromText('POINT(25 17)'),
    ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false) AS geom) AS q;
SELECT 'J2', encode(ST_AsMVT(q, 'test', 4096, 'geom'), 'base64') FROM (SELECT '{"c1":"abcd", "c2":"abcd"}'::jsonb,
    ST_AsMVTGeom(ST_GeomFromText('POINT(25 17)'),
    ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false) AS geom) AS q;

my test steps & log:

user@gis:~$ docker pull postgis/postgis:14-3.2
14-3.2: Pulling from postgis/postgis
Digest: sha256:307524a7e13ff820177f624277d2ac99d599d23203108e692cb5e25025786b6d
Status: Image is up to date for postgis/postgis:14-3.2
docker.io/postgis/postgis:14-3.2

user@gis:~$ docker run --name some-postgis -e POSTGRES_PASSWORD=mysecretpassword -d postgis/postgis:14-3.2
6638c98643e4ec782bde267b43d607590c9f6cb32e8fd1f7542d136810a3dc91

user@gis:~$ docker exec -ti some-postgis psql -U postgres
psql (14.2 (Debian 14.2-1.pgdg110+1))
Type "help" for help.

postgres=# SELECT 'J1', encode(ST_AsMVT(q, 'test', 4096, 'geom'), 'base64') FROM (SELECT '{"c1":1,"c2":"abcd"}'::jsonb,
    ST_AsMVTGeom(ST_GeomFromText('POINT(25 17)'),
    ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false) AS geom) AS q;
 ?column? |                                encode                                
----------+----------------------------------------------------------------------
 J1       | Gi8KBHRlc3QSDhIEAAABARgBIgQJMt4/GgJjMRoCYzIiAigBIgYKBGFiY2QogCB4Ag==
(1 row)

postgres=# SELECT 'J2', encode(ST_AsMVT(q, 'test', 4096, 'geom'), 'base64') FROM (SELECT '{"c1":"abcd", "c2":"abcd"}'::jsonb,
    ST_AsMVTGeom(ST_GeomFromText('POINT(25 17)'),
    ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false) AS geom) AS q;
 ?column? |                            encode                            
----------+--------------------------------------------------------------
 J2       | GisKBHRlc3QSDhIEAAABABgBIgQJMt4/GgJjMRoCYzIiBgoEYWJjZCiAIHgC
(1 row)

I guess the reason for not having it is some kind of dependency eg. protobuf?

as I see the libprotobuf-c1 is in the package

user@gis:~$  docker run -it --rm postgis/postgis:14-3.2 bash -c "apt list --installed | grep proto"

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libprotobuf-c1/now 1.3.3-1+b2 amd64 [installed,local]
pumelo commented 2 years ago

@ImreSamu thanks for your detailed reply.

Indeed, this was my fault, and it it working correctly. Sorry for wasting your precious time on this.