Skip to content

Using martin-cp to generate custom function tiles can only generate zoom 1 #1987

Description

@ljh2057

This is my custom function to achieve the conversion of 4490 coordinate system

 CREATE OR REPLACE
    FUNCTION f_lrdl_4490(z integer, x integer, y integer)
    RETURNS bytea AS $$
DECLARE
  mvt bytea;m numeric;minx numeric;maxy numeric;maxx numeric;miny numeric;
BEGIN
	m:=POWER(2,z);   
	minx := (x / m) * 360.0 - 180;
	maxx := ((x + 1) / m) * 360.0 - 180;
	miny := 90 - ((y + 1.0) / m) * 360.0;
	maxy := 90 - (y / m) * 360.0;
  SELECT INTO mvt ST_AsMVT(tile, 'f_lrdl_4490', 4096, 'geom') FROM (
    SELECT
      ST_AsMVTGeom(
          ST_CurveToLine(smgeometry),
          ST_MakeEnvelope(minx,miny,maxx,maxy,4490),
          4096, 64, true) AS geom,rn,rteg,name,null as elementId,null as elementType
    FROM pdc_lrdl
    WHERE smgeometry && ST_MakeEnvelope(minx,miny,maxx,maxy,4490) 
  ) as tile WHERE geom IS NOT NULL;
  RETURN mvt;
END
$$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE;

It can be accessed and loaded normally, the following is a screenshot of the loading

Image

This is the configuration file config.yaml of martin-cp

postgres:
  - connection_string: postgresql://user:password@192.168.1.1:5432/postgis
    functions:
      f_lrdl_4490:
        schema: public
        function: f_lrdl_4490

This is the command I used to generate tiles using martin-cp

martin-cp   --config mb_config.yaml  --encoding brotli --output-file f_lrdl_4490.mbtiles --min-zoom 1 --max-zoom 10 --bbox 72.004,0.829,137.834,55.827 --source f_lrdl_4490

The generated f_lrdl_4490.mbtiles file is only 12MB. After publishing it to the service, I found that there is data only when z=1, x=1, y=0. Through database query, I found that the data returned by f_lrdl_4490(1, 1, 0) is indeed 12MB. Can martin-cp only generate the first level for custom functions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions