Groups > DB2 > DB2 Spatial server > Re: How to control number formatting for ST_AsGML?




How to control number formatting for ST_AsGML?

How to control number formatting for ST_AsGML?
Tue, 02 Jan 2007 16:58:25 EST
Hi, is there any way to control number formatting for ST_AsGML? I'm using
spatial extender for DB2 V8.2 on a Windows 2000 box with german language
settings. I would like to get numbers with a decimal *point* inside a gml:X tag:
3.14159 (not with a comma, as it is the default for the german locale:
3,14159).

I've tried to change the decimal separator in Windows, no luck. I've changed the
database territory to USA, no luck.

Any ideas?

Post Reply
Re: How to control number formatting for ST_AsGML?
Wed, 03 Jan 2007 10:27:09 +010
Markus Neifer wrote:

> Hi, is there any way to control number formatting for ST_AsGML? I'm using
> spatial extender for DB2 V8.2 on a Windows 2000 box with german language
> settings. I would like to get numbers with a decimal *point* inside a
> gml:X tag: 3.14159 (not with a comma, as it is the default for the german
> locale: 3,14159).

I just had a look at the code.  We make sure that the locale "English"
and
the '.' as decimal separator are used when _parsing_ GML in the constructor
functions.  However, this is not done for the ST_AsGML/ST_AsText yet. :-( 
I've opened an internal defect to get this fixed in the future.

> I've tried to change the decimal separator in Windows, no luck.

Have you restarted DB2 after this change?  Better yet, reboot Windows!
How do other programs behave?

> I've 
> changed the database territory to USA, no luck.

You could try to set the environment variables LANG and DB2LANG
to "English".

-- 
Knut Stolze
DB2 z/OS Utilities Development
Post Reply
Re: How to control number formatting for ST_AsGML?
Wed, 03 Jan 2007 13:33:28 EST
> However, this is not done for the ST_AsGML/ST_AsText yet. :-( 
> I've opened an internal defect to get this fixed in
> the future.

Thank you. According to the spec for GML2, gml:X is of type xsd:decimal which
uses a point as its decimal separator. Thus it is a good idea to fix this.

> Have you restarted DB2 after this change?  Better
> yet, reboot Windows!
> How do other programs behave?

1) I've set LANG, DB2LANG, LC_ALL and LC_NUMERIC to "en_US". I've
changed the country settings so that the decimal separator is a point and the
thousands separator is a comma.

2) Rebooted windows.

3) The windows calculator now uses a point as the decimal separator and a comma
as the thousands separator.

4) Spatial extender doesn't care:

select cast(db2gse.st_asgml(shape) as char(200))
from airports
fetch first 1 row only
;

1                                                                               
                                                                                
                                      
------------------------------------
<gml:MultiPoint srsName="EPSG:4326">
  <gml:PointMember>
    <gml:Point>
      <gml:coord>
        <gml:X>-118,4080753</gml:X>
        <gml:Y>33,9425358</gml:Y>
      </gml:coord>
    </gml:Point>
  </gml:PointMember>
</gml:MultiPoint>              

  1 record(s) selected.

Post Reply
Re: How to control number formatting for ST_AsGML?
Wed, 03 Jan 2007 22:16:15 +010
Markus Neifer wrote:

>> However, this is not done for the ST_AsGML/ST_AsText yet. :-(
>> I've opened an internal defect to get this fixed in
>> the future.
> 
> Thank you. According to the spec for GML2, gml:X is of type xsd:decimal
> which uses a point as its decimal separator. Thus it is a good idea to fix
> this.

Markus, could you possibly open a PMR with IBM support?  That would
tremendously help in fixing this because it makes the process easier.

>> Have you restarted DB2 after this change?  Better
>> yet, reboot Windows!
>> How do other programs behave?
> 
> 1) I've set LANG, DB2LANG, LC_ALL and LC_NUMERIC to "en_US". I've
changed
> the country settings so that the decimal separator is a point and the
> thousands separator is a comma.

Try "English" instead of "en_US" as well.

> 3) The windows calculator now uses a point as the decimal separator and a
> comma as the thousands separator.

That's good.

> 4) Spatial extender doesn't care:
> 
> select cast(db2gse.st_asgml(shape) as char(200))
> from airports
> fetch first 1 row only
> ;
> 
> 1
> ------------------------------------
> <gml:MultiPoint srsName="EPSG:4326">
>   <gml:PointMember>
>     <gml:Point>
>       <gml:coord>
>         <gml:X>-118,4080753</gml:X>
>         <gml:Y>33,9425358</gml:Y>
>       </gml:coord>
>     </gml:Point>
>   </gml:PointMember>
> </gml:MultiPoint>

Do you have a C compiler on your Windows system?  If so, I could provide you
with some UDFs that check the locale used by Windows.  Actually, we may be
able to change the locale setting that way as well...
(I don't use Windows, so I can't do that myself.)

-- 
Knut Stolze
DB2 z/OS Utilities Development
Post Reply
about | contact