Closed valodo closed 7 months ago
@valodo this is a long standing wart in tegola, but essentially tegola is trying to infer your geometry type by forming up some SQL and then making a roundtrip to the database. This works when the SQL is simple, but can break in other situations. The work around is to set the geometry_type
attribute on the provider.layer config:
[[providers]]
name = "geometries"
type = "mvt_postgis"
uri = "postgres://admin:admin@pgsql-1:5432/geometries"
srid = 3857
[[providers.layers]]
name = "polygon"
geometry_type = "polygon"
sql = "SELECT id, ST_AsMVTGeom(web_mercator_geometry, !BBOX!) AS geom FROM public.polygon WHERE web_mercator_geometry && !BBOX!"
[[providers.layers]]
name = "line"
geometry_type = "linestring"
sql = "SELECT id, ST_AsMVTGeom(web_mercator_geometry, !BBOX!) AS geom FROM public.line WHERE web_mercator_geometry && !BBOX!"
Thank you for your answer. The configuration with geometry_type solves the problem.
Great!
Hello,
I'm trying to create two layers (polygon and line) using mvt_postgis as provider type, but Tegola shows the following error:
Error: could not register providers: error fetching geometry type for layer (polygon): layer (polygon) returned unsupported geometry type (<nil>) if custom parameters are used, remember to set geometry_type for the provider could not register providers: error fetching geometry type for layer (polygon): layer (polygon) returned unsupported geometry type (<nil>) if custom parameters are used, remember to set geometry_type for the provider
I run Tegola using TEGOLA_SQL_DEBUG=LAYER_SQL:EXECUTE_SQL environment variable and --log-level TRACE in order to understand the problem. However, there was not any detailed information and it stops.
Tegola is configured as follow:
The polygon table contains the following geometry with SRID 3857:
POLYGON((1413593.3073259895 5144415.67802485,1413593.3073259895 5144416.077882397,1413593.5072557947 5144416.077882397,1413593.5072557947 5144415.67802485,1413593.3073259895 5144415.67802485))
Instead, the line table contains the following geometry with SRID 3857:
LINESTRING(1408373.086449311 5130567.4123749705,1408371.0812513235 5130565.82138195,1408370.770669944 5130565.292494416,1408370.3621274128 5130564.5972656775)
Is there a way to understand what is the problem and how the geometries are null?