tegola: Add custom params to sql query is not working

I have an issue with my config.toml configuration. This is my config.toml file:(I removed the webserver and providers section)

[[providers.layers]]
name = "locations"
geometry_fieldname = "geometry"
id_fieldname = "vector_tile_id"
geometry_type = "Point"
fields = []
sql = "SELECT ST_AsBinary(geometry) AS geometry,vector_tile_id FROM events.locations WHERE geometry && !BBOX! !PARAM!"


[[maps]]
name = "monitors-events"

[[maps.layers]]
name = "locations"
provider_layer = "monitors-events.locations"

[[maps.params]]
name = "accountId"
token = "!PARAM!"
type = "string"
sql = "AND acc_id = ?"
default_sql = "123"

this is my tegola start command: serve --config /opt/config/config.toml

this is my image: image: gospatial/tegola

this is my error I see in the container: [ERROR] map.go:342: err fetching tile (z: 0, x: 0, y: 0) features: error running layer (locations) SQL (SELECT ST_AsBinary(geometry) AS geometry,vector_tile_id FROM events.locations WHERE geometry && ST_MakeEnvelope(-185.62499997416083,-85.5133983078662,185.62499997416083,85.5133983078662,4326) !PARAM!): ERROR: syntax error at end of input (SQLSTATE 42601)

I have 2 questions:

  1. What do I need to change to fix the error and return locations based on the custom param?(acctId in my example)
  2. I want to return in the same response Point and Polygon, is it possible? If I remove the geometry_type in the provider layer the tegola server is crashed.

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 21 (13 by maintainers)

Most upvoted comments

edge was updated the same time v0.16 was released, so to me it seems that it might be a bit outdated 🤔

One minor thing caught my eye: you’d probably want to use default_value = "123" instead of default_sql = "123". Sorry, I’ll be unavailable until tomorrow.

Thanks! I tried also what you said and I got the same error.

I want to return Polygon and Point in the same response is it something I can do? @bemyak I tried and I get this error: [ERROR] handle_map_layer_zxy.go:175: error marshalling tile: ERROR: syntax error at or near “PARAM” (SQLSTATE 42601)