[geos-devel] Re: [GEOS] #260: Problem using locale with WKTReader
GEOS
geos-trac at osgeo.org
Mon Jun 15 04:43:25 EDT 2009
#260: Problem using locale with WKTReader
-----------------------+----------------------------------------------------
Reporter: del | Owner: geos-devel at lists.osgeo.org
Type: task | Status: reopened
Priority: major | Milestone: 3.1.1
Component: Default | Version: 3.1.0
Severity: Annoyance | Resolution:
Keywords: |
-----------------------+----------------------------------------------------
Changes (by yabo):
* status: closed => reopened
* version: 3.0.3 => 3.1.0
* resolution: duplicate =>
Comment:
Hello,
I believe the problem isn't totally fixed yet. I'm using geos 3.1, here is
a minimal test case that englithens the bug :
{{{
#include <locale.h>
#include <iostream>
#include <geos/geom/Point.h>
#include <geos/io/WKTReader.h>
#include <geos/io/WKTWriter.h>
int main(int argc, char* argv[])
{
setlocale(LC_ALL, argv[2]);
geos::io::WKTReader r;
geos::geom::Point* p = (geos::geom::Point*) r.read(argv[1]);
geos::io::WKTWriter w;
std::cout << w.write(p) << std::endl;
}
}}}
{{{
yabo at xen ~/dev/geos_test_1 $ ./a.out 'POINT(42.42 0)' 'C'
POINT (42.4200000000000017 0.0000000000000000)
yabo at xen ~/dev/geos_test_1 $ ./a.out 'POINT(42.42 0)' 'en_EN.UTF8'
POINT (42.4200000000000017 0.0000000000000000)
yabo at xen ~/dev/geos_test_1 $ ./a.out 'POINT(42.42 0)' 'fr_FR.UTF8'
terminate called after throwing an instance of 'geos::io::ParseException'
what(): ParseException: Expected number but encountered word: '42.42'
Aborted
yabo at xen ~/dev/geos_test_1 $
}}}
I'm using Gentoo linux on a 64bit platform with geos 3.1.
{{{
yabo at xen ~/dev/geos_test_1 $ uname -ap
Linux xen 2.6.28-gentoo-r5 #8 SMP PREEMPT Mon May 18 11:55:05 CEST 2009
x86_64 AMD Phenom(tm) II X4 810 Processor AuthenticAMD GNU/Linux
yabo at xen ~/dev/geos_test_1 $ emerge -pv geos
These are the packages that would be merged, in order:
Calculating dependencies... done!
[ebuild R ] sci-libs/geos-3.1.0 USE="python -doc -ruby" 0 kB
Total: 1 package (1 reinstall), Size of downloads: 0 kB
yabo at xen ~/dev/geos_test_1 $
}}}
After inspecting the code, the point of failure is, as said in the first
report, in io/StringTokenizer.cpp:76 where the strtod function is used,
which is a locale-dependant function.
--
Ticket URL: <http://trac.osgeo.org/geos/ticket/260#comment:2>
GEOS <http://geos.refractions.net/>
GEOS (Geometry Engine - Open Source) is a C++ port of the Java Topology Suite (JTS).
More information about the geos-devel
mailing list