Opened 10 years ago

Closed 10 years ago

#3084 closed defect (fixed)

shp2pgsql - illegal number format when specific system locale set

Reported by: infrag Owned by: pramsey
Priority: medium Milestone:
Component: postgis Version: 2.1.x
Keywords: Cc:

Description

I come across faulty behavior of shp2pgsql tool. When system locale is set to some locale with i.e. different decimal separator sign shp2pgsql produces faulty output.

I had my locale on ubuntu linux set to LANG=cs_CZ.UTF-8 then shp2pgsql output illegal format of GEOMETRY:

… MULTIPOLYGON(((-759009,328 -1010948,384,-758995,543 -1010943,409, …

You can see the collision of decimal delimiters with point separators. When I changed LOCALE to LANG=en.UTF-8 the output was correct:

… MULTIPOLYGON(((-759009.328 -1010948.384,-758995.543 -1010943.409, …

The output of shp2pgsql should be locale independent since only one number format is acceptable by postgres/postgis.

Similar faults could exist for various locales and various types which should be output.

Change History (5)

comment:1 by pramsey, 10 years ago

If you "export LANG=C" does the problem go away?

comment:2 by pramsey, 10 years ago

Resolution: worksforme
Status: newclosed

I cannot reproduce this, for two reasons:

  • the default mode of shp2pgsql is to create the geometry in EWKB form, so there's no chance for locale to have anything to do with it
  • when I do change my locale (export LANG=de_DE) and force shp2pgsql to emit WKT (-w flag) I still get decimals as "." not as ","

comment:3 by infrag, 10 years ago

Resolution: worksforme
Status: closedreopened

Yes we need to emit WKT (-w flag). Have you tried export LANG=cs_CZ.UTF-8 as i noted in the comment?

comment:4 by pramsey, 10 years ago

Well, I don't know WTF I was doing last month when testing this, but I got it to reproduce on the first try just now. Will see if we can force locale to be C for our purposes.

comment:5 by pramsey, 10 years ago

Resolution: fixed
Status: reopenedclosed

Fixed in 2.1 at r13438 and trunk at r13438

Note: See TracTickets for help on using tickets.