go-spatial / tegola-postgis

A version of of tegola that that leverages PostGIS ST_AsMVT
MIT License
6 stars 2 forks source link

Support provider layers that don't have a feature_id #8

Open ARolek opened 4 years ago

ARolek commented 4 years ago

Some layers greatly benefit from having a feature_id encoded in them while others do not. Currently tegola-postgis assumes a feature_id will be encoded. If the user defines the id_fieldname in a provider layer then that field will be encoded as the feature ID in the tile. If the id_fieldname is not set then the default column name of gid is used. But what about situations where no feature ID needs to encoded? In this instance tegola-postgis throws the following error:

[ERROR] handle_map_layer_zxy.go:165: error marshalling tile: ERROR: mvt_agg_transfn: Could not find column '' of integer type (SQLSTATE XX000)

A quick workaround is to hardcode the feature id by adding the following SQL statement to the provider layer:

gid AS 1

All features for that provider layer will now have the feature ID of 1. This is not ideal, but according to the MVT spec feature IDs SHOULD be unique, but it does not say MUST be unique.