<font size=2 face="sans-serif">Thanks for your responses!</font>
<br><font size=2 face="sans-serif">We can't change the settings, Refused
by the system admin, too many applications are using the database and the
actual settings.</font>
<br>
<br>
<br><font size=2 face="sans-serif">The response of the WFS contains the
comma, and it is in GML</font>
<br><tt><font size=2> <gml:featureMember><br>
       <ms:SMDVDP_STAT_METE fid="SMDVDP_STAT_METE.2153"><br>
         <ms:LONG_STAT>-64,2131</ms:LONG_STAT><br>
       </ms:SMDVDP_STAT_METE><br>
     </gml:featureMember></font></tt>
<br>
<br><font size=2 face="sans-serif">The comma and decimals are not truncated
by an XML validator, they are truncated by </font><tt><font size=2>GetFieldAsDouble</font></tt>
<br>
<br><font size=2 face="sans-serif">But Maybe, it thinks that there are
2 values...-64 and 2131.</font>
<br><font size=2 face="sans-serif">On my side, A patch would be to replace
the , by ., use </font><tt><font size=2>GetFieldAsDouble</font></tt><font size=2 face="sans-serif">
and replace . by , .....</font>
<br>
<br><font size=2 face="sans-serif">Many countries in the world are using
a comma as decimal separator there must be a solution....</font>
<br><font size=2 face="sans-serif">What do you think,</font><tt><font size=2>
Does GetFieldAsDouble</font></tt><font size=2 face="sans-serif"> should
be able to manage the ,''?</font>
<br>
<br><font size=2 face="sans-serif">thanks!</font>
<br>
<br>
<br>
<br>
<p>
<br>
<br>
<br>
<table width=100% style="border-collapse:collapse;">
<tr valign=top height=8>
<td width=40% style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><font size=1 face="sans-serif"><b>Even
Rouault <even.rouault@spatialys.com></b> </font>
<p><font size=1 face="sans-serif">2015-05-13 17:02</font>
<td width=59% style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;">
<table width=100% style="border-collapse:collapse;">
<tr valign=top height=21>
<td width=57 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;">
<div align=right><font size=1 face="sans-serif">A</font></div>
<td style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><font size=1 face="sans-serif">Steve.Toutant@inspq.qc.ca</font>
<tr valign=top height=21>
<td width=57 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;">
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><font size=1 face="sans-serif">gdal-dev@lists.osgeo.org</font>
<tr valign=top height=21>
<td width=57 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;">
<div align=right><font size=1 face="sans-serif">Objet</font></div>
<td style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><font size=1 face="sans-serif">Re:
[gdal-dev] RE Python ogr GetFieldAsString problem</font></table>
<br>
<table width=393 style="border-collapse:collapse;">
<tr valign=top height=8>
<td width=57 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;">
<td width=336 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"></table>
<br></table>
<br>
<br>
<br>
<br>
<br><tt><font size=2>Steve,<br>
<br>
I believe comma as decimal separator is invalid for a XML double. Hence
the GML<br>
driver only parses the value up to the comma. This could likely be improved
to<br>
accept comma, but technically I believe a XML validator would reject this
GML.<br>
<br>
Even<br>
<br>
> More info.....<br>
> ogr2ogr --version = GDAL 1.10.1, released 2013/08/26<br>
> python --version = Python 2.7.3<br>
><br>
> I have modified my script to get the field type<br>
> while feat is not None:<br>
>           feat_defn = layer.GetLayerDefn()<br>
>           field_defn =<br>
> feat_defn.GetFieldDefn(feat_defn.GetFieldIndex(attribut))<br>
>           print field_defn.GetType()<br>
>           if field_defn.GetType() == ogr.OFTReal:<br>
>             print "%.4f" %
feat.GetFieldAsDouble(attribut)<br>
>           output.add(feat.GetFieldAsString(attribut))<br>
>           feat = layer.GetNextFeature()<br>
><br>
> It detects that it is a real, But GetFieldAsDouble also truncate the
value<br>
> at the comma<br>
><br>
><br>
><br>
> Steve Toutant/INSPQ/SSSS<br>
> 2015-05-13 15:11<br>
><br>
> A<br>
> gdal-dev@lists.osgeo.org<br>
> cc<br>
><br>
> Objet<br>
> Python ogr GetFieldAsString problem<br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
> I'm trying to parse a GML and read all the values of an attribute.<br>
> Example<br>
> <gml:featureMember><br>
>       <ms:SMDVDP_STAT_METE fid="SMDVDP_STAT_METE.2153"><br>
>         <ms:LONG_STAT>-64,2131</ms:LONG_STAT><br>
>       </ms:SMDVDP_STAT_METE><br>
>     </gml:featureMember><br>
><br>
> DescribeFeatureType for this layer returns<br>
> <element name="LONG_STAT" minOccurs="0" type="double"/><br>
><br>
> wfs_ds = ogr.Open(tmp_file.name)  #tmp_file.name is the response
of a WFS<br>
> getFeature request<br>
> layer = wfs_ds.GetLayerByName('SMDVDP_STAT_METE ')<br>
> feat = layer.GetNextFeature()<br>
>       while feat is not None:<br>
>           output.add(feat.GetFieldAsString('LONG_STAT'))<br>
>           feat = layer.GetNextFeature()<br>
><br>
> (At runtime, the WFs, layer and attribute can be anything of any type.
And<br>
> decimal separator, can be ',' or '.')<br>
> The problem is that feat.GetFieldAsString('LONG_STAT') truncate the
string<br>
> to the comma<br>
><br>
> So instead of having -64,2131, I get -64 in the output<br>
><br>
> What is the appropriate way to get the value of an attribute?<br>
><br>
> thanks you!<br>
><br>
><br>
><br>
><br>
><br>
><br>
<br>
<br>
-- <br>
Spatialys - Geospatial professional services<br>
</font></tt><a href=http://www.spatialys.com/><tt><font size=2>http://www.spatialys.com</font></tt></a><tt><font size=2><br>
</font></tt>
<br>
<br>
<br>