Opened 17 years ago

Closed 17 years ago

#1968 closed defect (fixed)

calling setRotation() causes a Fatal Error

Reported by: byteterra@… Owned by: warmerdam
Priority: high Milestone: 5.0 release
Component: MapScript-PHP Version: 4.10
Severity: major Keywords:
Cc:

Description (last modified by warmerdam)

I use the MS4W (mapserver 4.10) package with PHP5 on a PC with WindowsXP Pro
with Apache 2.0.59 and I noticed that calling:

$map->setExtent()
$map->setSize()
$map->setRotation() 

(the sequence matters) causes an error at the line that calls setRotation().

Fatal Error: [MapServer Error]: msCalculateScale(): Invalid image width or height

However, if I use the following sequence

$map->setSize()
$map->setExtent()
$map->setRotation() 

it seems to work.

I've prepared a small example that demonstrates this behaviour. Here's the
download link: http://terra.newstrekker.com/setrotation.zip

Note that the EXTENT and the SIZE are not set in the mapfile itself.

MFG
Stefan Schmidhammer

Change History (3)

comment:1 by fwarmerdam, 17 years ago

Status: newassigned
The problem turned out to be multi-part. 

First, the php_mapscript.c setRotation() code was checking the return value
of msMapSetRotation() against MS_TRUE instead of MS_SUCCESS.  This resulted
in a false positive for an error.  But the error that actually gets reported
at this point was an old one that occured during the msMapSetExtents() call
which does calculate scale, but ignores error codes from the scale calculation.
Nevertheless it does leave an error on the error stack waiting to be picked
up later. 

To deal with this, I modified msMapSetExtents() (mapobject.c) to only recompute
the scale if the map size is also already set. 

All the changes were made in the 4.99 (cvs head).  I think the php change
should be retrofit to 4.10.x but I'm somewhat more nervous about the scale
calculation change. 

comment:2 by fwarmerdam, 17 years ago

the php_mapscript patch looks like this:

retrieving revision 1.261
diff -r1.260 -r1.261
2c2
<  * $Id: php_mapscript.c,v 1.260 2006/09/06 16:42:36 dan Exp $
---
>  * $Id: php_mapscript.c,v 1.261 2006/11/22 17:26:45 frank Exp $
32a33,35
>  * Revision 1.261  2006/11/22 17:26:45  frank
>  * fixed setRotation() to check for MS_SUCCESS, not MS_TRUE (bug 1968)
>  *
120c123
< #define PHPMS_VERSION "($Revision: 1.260 $ $Date: 2006/09/06 16:42:36 $)"
---
> #define PHPMS_VERSION "($Revision: 1.261 $ $Date: 2006/11/22 17:26:45 $)"
1868c1871
<     if ((nStatus = mapObj_setRotation(self, pAngle->value.dval)) != MS_TRUE)
---
>     if ((nStatus = mapObj_setRotation(self, pAngle->value.dval)) != MS_SUCCESS)

comment:3 by warmerdam, 17 years ago

Description: modified (diff)
Milestone: 5.0 release
Resolution: fixed
Status: assignedclosed

I think the changes in trunk are sufficient. I'm not going to try and backport to 4.10 at this point.

Note: See TracTickets for help on using tickets.