tickets: 8563
This data as json
id | created | changetime | last_pulled_from_trac | stage | status | component | type | severity | version | resolution | summary | description | owner | reporter | keywords | easy | has_patch | needs_better_patch | needs_tests | needs_docs | ui_ux |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8563 | 2008-08-26 18:14:25 | 2008-08-27 17:03:01 | 2022-03-06 03:42:35.269436 | Accepted | closed | GIS | dev | invalid | [gis] Current locale considered when converting a geometry to WKT | I'm getting a OGRGeometry Exception intermittently, when saving a form. After debuging the code I noticed that the WKT string generated from geometries were taking the current locale into account, thus raising the Exceptions due to a bad WKT string representation. Here goes an example: {{{ >>> import locale >>> from django.contrib.gis.geos import Point >>> p = Point(-45.23, -23.15) >>> p.wkt 'POINT (-45.2299999999999969 -23.1499999999999986)' >>> locale.getlocale() (None, None) >>> locale.setlocale(locale.LC_ALL, ('pt_BR','UTF-8')) 'pt_BR.UTF8' >>> p.wkt 'POINT (-45,2299999999999969 -23,1499999999999986)' }}} Notice de comma "," for decimal separator in the last output. It must be something in the GEOS C library and in this case should be fixed there, but maybe it should be avoided reseting de locale before calling the C routine and restoring the locale to what it was just after. I think the reason this problem was not always happening is related to the some setlocale thread safety issue. I was using the wkt from the geometry in a custom form PointField to get the coordinate transformed to the desired srid. | jbronn | luizvital <luiz.vital@gmail.com> | geos locale | 0 | 0 | 0 | 0 | 0 | 0 |