go-spatial / tegola

Tegola is a Mapbox Vector Tile server written in Go
http://tegola.io/
MIT License
1.26k stars 193 forks source link

bug with id_fieldname : primary key which is not an integer #807

Closed lhapaipai closed 2 years ago

lhapaipai commented 2 years ago

I have a postgis database where the primary key values of my tables are not integers but identifiers of the type "MYFEATURE0001" "MYFEATURE0002" ...

if I declare my layer with this field I get an error with tegola :

[[providers.layers]]
name = "batiments"
geometry_fieldname = "geom"
id_fieldname = "id"
geometry_type = "MultiPolygon"
tablename = "public.bati"
$ tegola version
v0.13.0
$ tegola serve --config ./config.toml 
2021-09-06 22:58:52 [INFO] root.go:61: Loading config file: ./config.toml
2021-09-06 22:58:52 [INFO] config.go:306: loading local config (./config.toml)
2021-09-06 22:58:52 [INFO] providers.go:82: registering provider(type): principal (postgis)
2021/09/06 22:58:52 observers.go:16: none: map[]
2021-09-06 22:58:52 [INFO] server.go:94: starting tegola server on port :8080
2021/09/06 22:59:22 map.go:304: err fetching tile (z: 10, x: 100, y: 100) features: for layer (batiments) strconv.ParseUint: parsing "MYFEATURE0002": invalid syntax

of course, it is possible to find an alternative (create a field that takes the role of primary key ...) but in some cases it can be annoying.

In any case, thanks for your application !!

ARolek commented 2 years ago

@lhapaipai This has been discussed a few times, and the underlying issue is that the MVT spec requires uint64. Here are some references:

The first reference has some suggestions around building uint-based ids from a string. The last reference is on the MVT spec itself with some additional discussion.

lhapaipai commented 2 years ago

Thank you and sorry for the duplicate ...

ARolek commented 2 years ago

@lhapaipai no worries! I'm just trying to keep the issues somewhat under control. ;-)