[mapserver-users] ogr/mysql: trim spaces/padding for numeric fields?

P.Romero romero619 at hotmail.com
Sat Mar 28 10:39:13 PDT 2009


Im trying to use ogr's mysql driver to create a points layer that will be
converted to an imagemap.
Im using the following template to create the imagemap:
 
<map id="mymap" name="mymap">
[resultset layer=mypoints]
[feature]
<area shape="circle" coords="[shpxy precision=0 proj=image yf=",7" xf=","]"
title="[buoyName]-[lat],[lon]" href="#" alt="[buoyName]-[lat],[lon]">
[/feature]
[/resultset]
<map>
 
 
the problem is that ogr pads numeric mysql fields with a very large amount
of whitespace. Here is some of my output:
 
<area 

            shape="circle" 

            coords="178,274,7" 

            title="42055:                     2@                  160" 

            href="#" 

            alt="42055:                      2@                   160"

/>
 
the (double) numeric fields [lat] and [lon] are being left-padded with a lot
of whitespace (each field is 22 spaces long in total).
running my ovf file from the command line with ogrinfo produces the same
result; a lot of unecessary left-padding.

OGRFeature(mypoints):88

  max(recTS) (Integer) = 1238258520

  buoyName (String) = 41114

  lat (Real) =                     28

  lon (Real) =                    -80

  MAG (Real) =                    -371

  WDIR (Real) =                    -99

  WSPD (Real) =                    -99

  ADIR (Real) =                      81

  ts (DateTime) = 2009/03/13 11:42:00

  POINT (-80.219999999999999 27.55 0)

 

Ogr's output also shows the 20+space left-padding for the double&int fields.

 

Im trying to access my imagemap using a url in this format:

 

http://localhost/cgi-bin/mapserv?map=/data/www/html/test/test.map
<http://localhost/cgi-bin/mapserv?map=/data/www/html/test/test.map&mode=nque
ry&searchmap=true> &mode=nquery&searchmap=true

 

I also tried embedding php code to try to preprocess the variables:

 

<map id="mymap" name="mymap">
[resultset layer=mypoints]
[feature]
<area shape="circle" coords="[shpxy precision=0 proj=image yf=",7" xf=","]"
title="[buoyName]-<?php trim([lat]):>,[lon]" href="#"
alt="[buoyName]-[lat],[lon]">
[/feature]
[/resultset]
<map>

 

 but this obviously didn't work, Im assuming since cgi was processing &
returning the results, so php was never even called upon.

 

Questions:
How can I remove this padding? 
Is this padding by design, or a bug in ogrinfo?

Is there any other way that I can pre-process these variables prior to
sending them to the browser, (using php or some other means) so that I can
process&format them based on my needs?


Please help,
Thanks,
P.Romero

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20090328/97083077/attachment.htm>


More information about the MapServer-users mailing list