I want to use T-rex as vector tileserver on Windows. I load osm.pbf file (from geofabrik) to PostGIS database with osm2pgsql successfully.

When I run the server with the following commands, I get the error message :

  • Command :

t_rex serve --dbconn postgresql://Myuser:Mypass@localhost/Mydb

  • Error :

ERROR IO error: invalid utf-8 sequence of 1 bytes from index 34

Even when I just want to generate the config file, same error :

t_rex genconfig --dbconn postgresql://Myuser:Mypass@localhost/Mydb

I suspect this is a postgis setup problem ... that may not have anything to do with T-rex? Unless it is an import configuration problem?

Note that using T-rex directly with a pbf file does not pose this problem (t_rex serve --datasource My.osm.pbf).

  • what encoding is your database in? (see this answer on how to find this). I'd expect osm2pgsql to create it in utf8 but if it's in something like latin-1 that might be the problem
    – Steven Kay
    Sep 24 '18 at 17:04
  • Thank you for your suggestion. Unfortunately, the database is well encoded in utf8 (command SHOW SERVER_ENCODING)
    – David
    Sep 29 '18 at 14:00

Please try the following

SELECT pg_encoding_to_char(encoding), datname FROM pg_database order by datname;

That should show the per-database encodings. The SHOW SERVER_ENCODING that I suggested seems to show the default encoding, but import tools are free to choose a different encoding when they create a database

I think I've seen encoding issues before using shp2pgsql, but not osm2pgsql.

If your database still shows up as utf-8, i'd suggest raising an issue on the github page

  • hi, thank you for your proposal. This command confirms me that the data is in utf8. I loaded the same data using osmosis. The schema of the database obtained is different, but with t-rex I no longer have this error message (I have other problems because the map does not appear, but it is not the object of this exchange).
    – David
    Oct 1 '18 at 17:12
  • no problem! i'm a bit puzzled as osm2pgsql appears to correctly set the encoding on the database. perhaps its some genuine data glitch which osmosis cleans up to t_rex's satisfaction, but osm2pgsql doesn't.
    – Steven Kay
    Oct 1 '18 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.