Problem drawing image with java/mapscript when starting with a blank mapObj
James Dracup
jamesdracup at HOTMAIL.COM
Mon Jul 10 03:39:04 PDT 2006
No need for a bug, I had a play over the weekend and found my error.
I am populating my mapObj from tables in a db. If the value is not null in
the db, I call the corresponding set method in mapscript. In my 'style'
table I have 'size' column which was set to have a default value of 0, and
was never null. I therefore always called styleObj.setSize() - usually
passing 0. That I think is what was messing me up - changing the default to
null for that column fixed the issue.
The reason it worked when passed through a .map file, and the reason I did
not initially spot the mistake, was because SIZE is not set in the STYLE
section on any of the map files - so it looked as if the mapObjs were the
same, but in fact reloading it caused the size value to be forgotten.
Umberto, thanks for the prompt response in any case and - at a guess from
your name - congratulations on the World Cup :)
Cheers,
James.
----Original Message Follows----
From: "Umberto Nicoletti" <umberto.nicoletti at gmail.com>
To: "James Dracup" <jamesdracup at hotmail.com>
CC: MAPSERVER-USERS at lists.umn.edu
Subject: Re: [UMN_MAPSERVER-USERS] Problem drawing image with java/mapscript
when starting with a blank mapObj
Date: Sat, 8 Jul 2006 12:11:17 +0200
Please open an issue on mapserver bugzilla.
I'll look into ti asap.
Umberto
On 7/7/06, James Dracup <jamesdracup at hotmail.com> wrote:
>Hello,
>
>I am using java/mapscript embedded inside a java program and am having a
>few
>problems. I wonder if anybody has any suggestions, or if it is something
>obvious I have missed?
>
>I create a new mapObj in java, but NOT from a .map file, a blank one:
>
>mapObj mapobj = new mapObj(null);
>
>There is then a fairly long and complicated chunk of code to populate that
>mapObj from a db and user input with settings and layers etc. etc.
>
>I finally do:
>
>byte[] bytes = mapobj.draw().getBytes();
>
>Intending to then further process in java the image returned.
>
>However, I always get a blank (just background colour) image. Initially I
>thought I'd missed something out when setting the parameters for the
>various
>mapscript objects, but, having looked at that for a while, I now do not
>think that is the problem.
>
>If I do a mapobj.save("MapFileName.map") - the .map file outputted is
>perfect, and works fine (displays a map) in all contexts (cgi-bin, java
>mapscript).
>
>I can load that .map file into a new mapObj, and the image produced is
>fine:
>
>mapObj newmapobj = new mapObj("MapFileName.map");
>byte[] bytes = newmapobj.draw().getBytes();
>
>If I then do a newmapobj.save("MapFileToCompare.map") - the .map file
>outputted is absolutely and completely identical (did a diff) to the
>original one outputted.
>
>So I am really confused - it seems to me the mapObj's are identical - so
>why
>do I need to go via the file system in order to produce an image? What
>changes, and how can I avoid it?
>
>Any thoughts,
>Thanks,
>James
>
More information about the MapServer-users
mailing list